-
Notifications
You must be signed in to change notification settings - Fork 456
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
(edrt) Allow multi. chargers per link #2919
(edrt) Allow multi. chargers per link #2919
Conversation
...main/java/org/matsim/contrib/drt/extension/edrt/scheduler/EmptyVehicleChargingScheduler.java
Outdated
Show resolved
Hide resolved
List<Charger> chargers = linkToChargerMap.get(currentLink.getId()); | ||
if (chargers != null) { | ||
// Pick a random charger of all available chargers at this link | ||
Charger charger = chargers.get(RND.nextInt(chargers.size())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead take the one with highest number of unused plugs. If there is none with unused plugs, take the one with shortest queue or lowest queue.size/plugCount
. You could also include charger power in choosing the charger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
List<Charger> chargers = linkToChargersMap.get(currentLink.getId()); | ||
if (chargers != null) { | ||
// Take the charger with the smallest queue | ||
Charger charger = chargers.stream().min(Comparator.comparing(e -> e.getLogic().getQueuedVehicles().size())).orElseThrow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace comparing()
with comparingInt()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also change
min(Comparator.comparing(e -> e.getLogic().getQueuedVehicles().size()))
to something like this:
mapToInt(e -> e.getLogic().getQueuedVehicles().size()).min()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mapToInt(e -> e.getLogic().getQueuedVehicles().size()).min()
but we want to get the Charger with the lowest number of queued vehicles. The object of intreset is charger not the int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True:-) Suggesting code changes without trying them in an IDE...
The default EmptyVehicleChargingScheduler throws an error, if more than one charger has been deployed per link. If multiple chargers are available, a random charger is now selected in this PR.