From b6270fe7e8d6c406a89de11596df81e95c22a9b4 Mon Sep 17 00:00:00 2001 From: Lennart Adenaw Date: Wed, 20 Sep 2023 14:32:01 +0200 Subject: [PATCH] max soc retrieval function --- .../charging/ChargeUpToTypeMaxSocStrategy.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/tum/mw/ftm/matsim/contrib/urban_ev/charging/ChargeUpToTypeMaxSocStrategy.java b/src/main/java/de/tum/mw/ftm/matsim/contrib/urban_ev/charging/ChargeUpToTypeMaxSocStrategy.java index 6344866..2fc0724 100644 --- a/src/main/java/de/tum/mw/ftm/matsim/contrib/urban_ev/charging/ChargeUpToTypeMaxSocStrategy.java +++ b/src/main/java/de/tum/mw/ftm/matsim/contrib/urban_ev/charging/ChargeUpToTypeMaxSocStrategy.java @@ -42,14 +42,14 @@ * @author Michal Maciejewski (michalm) */ public class ChargeUpToTypeMaxSocStrategy implements ChargingStrategy { + private final Charger charger; private final double maxRelativeSoc; - private final Map maxRelativeSocByChargerType = Stream.of(new Object[][] {{ "private_ac", 0.8 },{ "public_dc", 0.8 }, { "public_ac", 0.9 }, { "default", 0.5 }}).collect(Collectors.toMap(data -> (String) data[0], data -> (double) data[1])); - + public ChargeUpToTypeMaxSocStrategy(Charger charger) { - this.maxRelativeSoc = maxRelativeSocByChargerType.getOrDefault(charger.getChargerType(), 1.0); + this.maxRelativeSoc = getMaxRelativeSoc(charger); if (maxRelativeSoc < 0 || maxRelativeSoc > 1) { throw new IllegalArgumentException(); @@ -67,4 +67,10 @@ public double calcRemainingEnergyToCharge(ElectricVehicle ev) { public double calcRemainingTimeToCharge(ElectricVehicle ev) { return ((BatteryCharging)ev.getChargingPower()).calcChargingTime(charger, calcRemainingEnergyToCharge(ev)); } + + public static double getMaxRelativeSoc(Charger charger) + { + final Map maxRelativeSocByChargerType = Stream.of(new Object[][] {{ "private_ac", 0.8 },{ "public_dc", 0.8 }, { "public_ac", 0.9 }, { "default", 0.5 }}).collect(Collectors.toMap(data -> (String) data[0], data -> (double) data[1])); + return maxRelativeSocByChargerType.getOrDefault(charger.getChargerType(), 1.0); + } }