Skip to content

Commit

Permalink
Revert "Merge branch 'DC_integration' into charging_behavior_rework"
Browse files Browse the repository at this point in the history
This reverts commit 298a7fe, reversing
changes made to 3c6c0fc.
  • Loading branch information
ladenaw committed Apr 29, 2024
1 parent 298a7fe commit 643c037
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 753 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ name: Build Docker
on:
push:
branches: [docker_integration, charging_behavior_rework]

jobs:

build_docker_and_push_to_registry:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -138,38 +138,15 @@ public void handleEvent(ActivityStartEvent event) {

if (PlanUtils.isCharging(actType)) {

//hier entsteht das Problem !!
// hier ist es besser, die Koordinaten des Events zu nutzten
Activity activity = PlanUtils.getActivity(person.getSelectedPlan(), time);
//Coord activityCoord = activity != null ? activity.getCoord() : network.getLinks().get(event.getLinkId()).getCoord();
Coord activityCoord = event.getCoord();
// Location choice

//charging_behavior_rework: Post-Merge work neccessary!
//List<Charger> suitableChargers = findSuitableChargers(activityCoord, ev);
//Charger selectedCharger = suitableChargers.stream()
// .filter(charger -> charger.getAllowedVehicles().contains(evId))
// .findFirst()
// .orElse(null);

List<Charger> suitableChargers;
if(event.getActType()=="car fast charging"){
suitableChargers = findSuitableChargers(activityCoord, ev,true);
}
else{
suitableChargers = findSuitableChargers(activityCoord, ev,false);
}
Charger selectedCharger = null;
Coord activityCoord = activity != null ? activity.getCoord() : network.getLinks().get(event.getLinkId()).getCoord();

// Use private charger if possible
for(Charger charger : suitableChargers)
{
if (charger.getAllowedVehicles().contains(evId))
{
selectedCharger = charger;
break;
}
}
// Location choice
List<Charger> suitableChargers = findSuitableChargers(activityCoord, ev);
Charger selectedCharger = suitableChargers.stream()
.filter(charger -> charger.getAllowedVehicles().contains(evId))
.findFirst()
.orElse(null);

// Select public charger if no private charger is available
if(selectedCharger == null)
Expand Down Expand Up @@ -341,47 +318,16 @@ public void handleEvent(ActivityEndEvent event) {
* If a charger is private, only allowed vehicles can charge there
*/

private List<Charger> findSuitableChargers(Coord stopCoord, ElectricVehicle electricVehicle, boolean only_fast_chargers) {
private List<Charger> findSuitableChargers(Coord stopCoord, ElectricVehicle electricVehicle) {

List<Charger> filteredChargers = new ArrayList<>();
// charging_behavior_rework
//
// filteredChargers = chargingInfrastructure.getChargers().values().stream()
// .filter(charger -> charger.getAllowedVehicles().isEmpty() || charger.getAllowedVehicles().contains(electricVehicle.getId()))
// .filter(charger -> DistanceUtils.calculateDistance(stopCoord, charger.getCoord()) < parkingSearchRadius)
// .filter(charger -> electricVehicle.getChargerTypes().contains(charger.getChargerType()))
// .filter(charger -> charger.getLogic().getPluggedVehicles().size() < charger.getPlugCount())
// .collect(Collectors.toList());

List<Charger> allChargers = new ArrayList<>();
chargingInfrastructure.getChargers().values().forEach(charger -> {allChargers.add(charger);});

chargingInfrastructure.getChargers().values().forEach(charger -> {
// filter out private chargers unless vehicle is allowed
if (charger.getAllowedVehicles().isEmpty() || charger.getAllowedVehicles().contains(electricVehicle.getId())) {
// filter out chargers that are out of range
if (DistanceUtils.calculateDistance(stopCoord, charger.getCoord()) < parkingSearchRadius) {
// filter out chargers with wrong type
//if (electricVehicle.getChargerTypes().contains(charger.getChargerType())) {
if (only_fast_chargers == true){
if(charger.getChargerType().contains("dc")) {
// filter out occupied chargers
if ((charger.getLogic().getPluggedVehicles().size() < charger.getPlugCount())) {
filteredChargers.add(charger);
}
}
}
else{
if(electricVehicle.getChargerTypes().stream().filter(o -> o.equals(charger.getChargerType())).findFirst().isPresent()){
// filter out occupied chargers
if ((charger.getLogic().getPluggedVehicles().size() < charger.getPlugCount())) {
filteredChargers.add(charger);
}
}
}
}
}
});

filteredChargers = chargingInfrastructure.getChargers().values().stream()
.filter(charger -> charger.getAllowedVehicles().isEmpty() || charger.getAllowedVehicles().contains(electricVehicle.getId()))
.filter(charger -> DistanceUtils.calculateDistance(stopCoord, charger.getCoord()) < parkingSearchRadius)
.filter(charger -> electricVehicle.getChargerTypes().contains(charger.getChargerType()))
.filter(charger -> charger.getLogic().getPluggedVehicles().size() < charger.getPlugCount())
.collect(Collectors.toList());

return filteredChargers;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ public final class UrbanEVConfigGroup extends ReflectiveConfigGroup {
public static final String BATTERY_HEALTH_STRESS_UTILITY = "batteryHealthStressUtility";
static final String BATTERY_HEALTH_STRESS_UTILITY_EXP = "The utility of exceeding the optimal soc to the max (scoring is calculated linearly depending on the offset from the optimal soc)";

public static final String DC_CHARGING_UTILITY = "dcChargingUtility";
static final String DC_CHARGING_UTILITY_EXP = "The utility of using a fast charger";


// DataIO

public static final String VEHICLE_TYPES_FILE = "vehicleTypesFile";
Expand Down Expand Up @@ -138,9 +134,6 @@ public final class UrbanEVConfigGroup extends ReflectiveConfigGroup {

@NotNull
private double batteryHealthStressUtility = -0.1;

@NotNull
private double dcChargingUtility = -10;

// Charging parameters
@Positive
Expand Down Expand Up @@ -227,13 +220,7 @@ public Map<String, String> getComments() {

@StringSetter(HOME_CHARGING_UTILITY)
public void setHomeChargingUtility(double homeChargingUtility) { this.homeChargingUtility = homeChargingUtility; }

@StringGetter(DC_CHARGING_UTILITY)
public double getdcChargingUtility() { return dcChargingUtility; }

@StringSetter(DC_CHARGING_UTILITY)
public void setdcChargingUtility(double dcChargingUtility) { this.dcChargingUtility = dcChargingUtility; }

@StringGetter(SOC_DIFFERENCE_UTILITY)
public double getSocDifferenceUtility() { return socDifferenceUtility; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@
import org.matsim.core.replanning.PlanStrategy;
import org.matsim.core.replanning.PlanStrategyImpl;
import org.matsim.core.replanning.selectors.ExpBetaPlanSelector;
import org.matsim.core.router.TripRouter;

import javax.inject.Inject;
import javax.inject.Provider;

public class ChangeChargingBehaviour implements Provider<PlanStrategy> {

private Scenario scenario;
@Inject private Provider<TripRouter> tripRouterProvider;
@Inject public ChangeChargingBehaviour(Scenario scenario) {

@Inject
public ChangeChargingBehaviour(Scenario scenario) {
this.scenario = scenario;
}

@Override
public PlanStrategy get() {
double logitScaleFactor = 1.0;
PlanStrategyImpl.Builder builder = new PlanStrategyImpl.Builder(new ExpBetaPlanSelector<>(logitScaleFactor));
ChangeChargingBehaviourModule changeChargingBehaviourModule = new ChangeChargingBehaviourModule(scenario, tripRouterProvider);
ChangeChargingBehaviourModule changeChargingBehaviourModule = new ChangeChargingBehaviourModule(scenario);
builder.addStrategyModule(changeChargingBehaviourModule);
return builder.build();
}
Expand Down
Loading

0 comments on commit 643c037

Please sign in to comment.