Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(charging): provide the charging stations within a certain area #446

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kschrab
Copy link
Contributor

@kschrab kschrab commented Dec 12, 2024

Description

What is this PR about?

Issue(s) related to this PR

  • Resolves issue # / internal issue

Affected parts of the online documentation

Changes in the documentation required?

Definition of Done

Prerequisites

  • You have read CONTRIBUTING.md carefully.
  • You have signed the Contributor License Agreement.
  • Your GitHub user id is linked with your Eclipse Account.

Required

  • The title of this merge request follows the scheme type(scope): description (in the style of Conventional Commits)
  • You have assigned a suitable label to this pull request (e.g., enhancement, or bugfix)
  • origin/main has been merged into your Fork.
  • Coding guidelines have been followed (see CONTRIBUTING.md).
  • All checks on GitHub pass.
  • All tests on Jenkins pass.

Requested (can be enforced by maintainers)

  • New functionality is covered by unit tests or integration tests. Code coverage must not decrease.
  • If a bug has been fixed, a new unit test has been written (beforehand) to prove misbehavior
  • There are no new SpotBugs warnings.

Special notes to reviewer

@@ -46,4 +46,7 @@ public class EventNicenessPriorityRegister {

// batteryUpdated
public final static long BATTERY_UPDATED = -99_998_900;

// discover charging stations
public final static long CHARGING_STATIONS_DISCOVERY = -99_998_900;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can somebody explain me at which point the "niceness" is required? What is the effect of this priorization and why do we need it and don't go with FCFS?

Why do we use this only sometimes (in process(final EnvironmentSensorUpdates environmentSensorUpdates) it's not used)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, our DefaultEventScheduler doesn't care about the niceness of an event.
It uses a PriorityQueue using the time as priority. If there a ties, i.e. same execution time, Events are executed in an arbitrary order. I think ideally, we would use the defined niceness values to deterministically break those ties.

In the (highly unstable) MultiThreadedEventScheduler the niceness value is actually used. However, I'm not certain if it has any effect there.

So yes, we don't use this properly anyhow, but if we would it would be to break ties (I think)

@iwillitried for this reason the value of CHARGING_STATIONS_DISCOVERY should probably be unique.

@@ -46,4 +46,7 @@ public class EventNicenessPriorityRegister {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is only the first number positive, but then we count from strong negative upwards.

In other words: I do not understand, if the VEHICLE_ADDED or the UNIT_REMOVED is the message with the highest priority, as both are at the "border" of that Zahlenstrahl

@kschrab @schwepmo


@Override
public int hashCode() {
return new HashCodeBuilder(9, 97)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are those magic numbers here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are the seeds for the hash function. Refer to the Apache Documentation for more insights :)

Copy link
Contributor

@hoelger hoelger Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove magic numbers, e.g.

// seeds: hard-coded, randomly chosen, non-zero, odd number
final static int INITIAL_ODD_NUMBER= 9;
final static int MULTIPLIER_ODD_NUMBER = 97;
return new HashCodeBuilder(INITIAL_ODD_NUMBER, MULTIPLIER_ODD_NUMBER);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary. At least we don't typically do it when overriding the hashCode function.

Probably the most sensible solution would be to use the default constructor of HashCodeBuilder, which uses 37 and 17 by default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

@Serial
private static final long serialVersionUID = 1L;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have the serial number here? If it's an interaction-specific thing, why don't we use it in the response as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interaction implements Serializable, if we would do distributed simulation in some way or another and serialize/deserialize interactions between remote hosts, this UID would be used to assure that all sides have the same class version loaded. When adding new Interactions giving a serialVersionUID of 1 is good, indicating version 1.

Now what we should consider though is that we update this ID whenever we change Interactions in a meaningful manner.

(see https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Serializable.html)

I hope this suffices as a explanation 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of adding the new ChargingStationDiscoveryResponse interaction. We could/should handle the querying of Charging Stations similar to that of traffic lights (see line 370). Though instead of requiring enabled perception, we assume that EVs have access to a static map of all charging stations.

At least this is how I understood the intention of @kschrab.

.tiles
/logs/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be necessary, please remove

@@ -63,6 +75,11 @@ protected boolean handleEventResource(Object resource, long eventType) {
return true;
}

if (resource instanceof ChargingStationDiscoveryResponse response) {
onCharginStationDiscoveryResponse((ChargingStationDiscoveryResponse) response);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast is not necessary

Suggested change
onCharginStationDiscoveryResponse((ChargingStationDiscoveryResponse) response);
onCharginStationDiscoveryResponse(response);

}

@Serial
private static final long serialVersionUID = 1L;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interaction implements Serializable, if we would do distributed simulation in some way or another and serialize/deserialize interactions between remote hosts, this UID would be used to assure that all sides have the same class version loaded. When adding new Interactions giving a serialVersionUID of 1 is good, indicating version 1.

Now what we should consider though is that we update this ID whenever we change Interactions in a meaningful manner.

(see https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Serializable.html)

I hope this suffices as a explanation 😅


@Override
public int hashCode() {
return new HashCodeBuilder(9, 97)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary. At least we don't typically do it when overriding the hashCode function.

Probably the most sensible solution would be to use the default constructor of HashCodeBuilder, which uses 37 and 17 by default.


@Override
public int hashCode() {
return new HashCodeBuilder(9, 97)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*
* @param searchArea The area where the charging stations are search
*/
void sendChargingStationDiscoveryRequest(GeoCircle searchArea);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably define the search area as a GeoArea.

Suggested change
void sendChargingStationDiscoveryRequest(GeoCircle searchArea);
void sendChargingStationDiscoveryRequest(GeoArea searchArea);

Furthermore, we should also discuss what signatures are relevant.
I can think of:

  • getClosestChargingStation(GeoPosition position) & getClosestChargingStation() -> returns the closest charging station either to the current position of the vehicle or to a specified position. E.g., when running low on battery.
    • Here we should also consider if we just want to consider spatial proximity or also the travel time. As charging stations at the opposite direction of a highway can actually be quite far -> getShortestPathChargingStation(...)
  • getChargingStationsInArea(GeoArea geoArea) -> your use case
  • getChargingStationsWithinRange(double distance) -> Get all charging stations that can be reached within a distance
  • getChargingStationsAlongRoute(double maxDetour) -> Get all charging stations that are located along the route. This requires advanced routing though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants