Skip to content

Commit

Permalink
change to junit 5 and correct spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
rewertvsp committed Jan 11, 2024
1 parent 843d8f4 commit 7d631d8
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 124 deletions.
15 changes: 6 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,6 @@
<version>${matsim.version}</version>
</dependency>


<!-- Include the JUnit testing library. Not transitive. -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>

<!--MATSim test infrastructure. Not transitive. -->
<dependency>
<groupId>org.matsim</groupId>
Expand All @@ -102,6 +93,12 @@
<version>${matsim.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>


</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
* battery. The base for calculating the consumption is only the driven
* distance and not the transported weight or other influences. But is
* possible to integrate it.
*
* !! No recharging is integrated. Vehicles are totally loaded at the
* beginning.
*
Expand All @@ -50,7 +49,7 @@ class DistanceConstraintUtils {

/**
* Creates a VehicleRoutingCostMatrix for calculating the distance between all
* different locations of a carrier. Matrix has informations about the distance
* different locations of a carrier. Matrix has information about the distance
* and the travelTime between every location. This is necessary for the
* distanceConstraint for the electric vehicles, because in the normal
* netBasedCosts only costs and travelTimes are calculated. Therefore for every
Expand Down Expand Up @@ -153,7 +152,7 @@ static VehicleRoutingTransportCostsMatrix createMatrix(VehicleRoutingProblem.Bui
}

/**
* Creates the distance constrain
* Creates the distance constraint
*
*/
class DistanceConstraint implements HardActivityConstraint {
Expand All @@ -175,15 +174,15 @@ class DistanceConstraint implements HardActivityConstraint {
}

/**
* When adding a TourActivity to the tour and the vehicle of the tour is
* electric drive the algorithm always checks the fulfilled method if all
* conditions (constraints) are fulfilled or not. This method is always been
* checked by the distance constraint, if the new vehicle is electric. Because
* When adding a TourActivity to the tour, and the vehicle of the tour is
* electric drive, the algorithm always checks the fulfilled method if all
* conditions (constraints) are fulfilled or not. This method is always
* checked by the distance constraint if the new vehicle is electric. Because
* every activity is added separately and the pickup before the delivery of a
* shipment, it will investigate which additional distance is necessary for the
* pickup and which minimal additional distance of the associated Delivery is
* needed. This is also important for the fulfilled decision of this function.
* At the end the conditions checks if the electric consumption of the tour
* In the end, the conditions checks if the electric consumption of the tour
* including the additional shipment is possible with the used capacity of the
* battery.
*/
Expand All @@ -194,15 +193,15 @@ public ConstraintsStatus fulfilled(JobInsertionContext context, TourActivity pre
double additionalDistance;

VehicleType vehicleTypeOfNewVehicle = vehicleTypes.getVehicleTypes()
.get(Id.create(context.getNewVehicle().getType().getTypeId().toString(), VehicleType.class));
.get(Id.create(context.getNewVehicle().getType().getTypeId(), VehicleType.class));

if (vehicleTypeOfNewVehicle.getEngineInformation().getAttributes()
.getAttribute("fuelType").equals("electricity")) {

Double electricityCapacityinkWh = (Double) vehicleTypeOfNewVehicle.getEngineInformation().getAttributes()
.getAttribute("engeryCapacity");
Double electricityCapacityInkWh = (Double) vehicleTypeOfNewVehicle.getEngineInformation().getAttributes()
.getAttribute("energyCapacity");
Double electricityConsumptionPerkm = (Double) vehicleTypeOfNewVehicle.getEngineInformation().getAttributes()
.getAttribute("engeryConsumptionPerKm");
.getAttribute("energyConsumptionPerKm");
Double routeConsumption = null;

Double routeDistance = stateManager.getRouteState(context.getRoute(), distanceStateId, Double.class);
Expand All @@ -224,7 +223,7 @@ public ConstraintsStatus fulfilled(JobInsertionContext context, TourActivity pre
double additionalConsumption = additionalDistance * (electricityConsumptionPerkm / 1000);
double newRouteConsumption = routeConsumption + additionalConsumption;

if (newRouteConsumption > electricityCapacityinkWh) {
if (newRouteConsumption > electricityCapacityInkWh) {
return ConstraintsStatus.NOT_FULFILLED;
} else
return ConstraintsStatus.FULFILLED;
Expand All @@ -237,12 +236,12 @@ public ConstraintsStatus fulfilled(JobInsertionContext context, TourActivity pre
* Finds a minimal additional distance for the tour, when a pickup is added to
* the plan. The AssociatedActivities contains both activities of a job which
* should be added to the existing tour. The TourActivities which are already in
* the tour are found in context.getRoute().getTourActivities. In this method
* the position of the new pickup is fixed and three options of the location of
* the tour are found in context.getRoute().getTourActivities. In this method,
* the position of the new pickup is fixed, and three options of the location of
* the delivery activity will be checked: delivery between every other activity
* after the pickup, delivery as the last activity before the end and delivery
* directly behind the new pickup. This method gives back the minimal distance
* of this three options.
* of these three options.
*
* @param context
* @param newAct
Expand All @@ -256,17 +255,17 @@ private double findMinimalAdditionalDistance(JobInsertionContext context, TourAc
if (context.getAssociatedActivities().get(1).getName().contains("deliverShipment")) {
TourActivity assignedDelivery = context.getAssociatedActivities().get(1);
minimalAdditionalDistance = 0;
int indexNextActicity = nextAct.getIndex();
int indexNextActivity = nextAct.getIndex();
int index = 0;
int countIndex = 0;

// search the index of the activity behind the pickup activity which should be
// added to the tour
for (TourActivity tourActivity : context.getRoute().getTourActivities().getActivities()) {
if (tourActivity.getIndex() == indexNextActicity) {
if (tourActivity.getIndex() == indexNextActivity) {
while (countIndex < context.getRoute().getTourActivities().getActivities().size()) {
if (context.getRoute().getTourActivities().getActivities().get(countIndex)
.getIndex() == indexNextActicity) {
.getIndex() == indexNextActivity) {
index = countIndex;
break;
}
Expand All @@ -275,7 +274,7 @@ private double findMinimalAdditionalDistance(JobInsertionContext context, TourAc
break;
}

// search the minimal distance between every exiting TourAcitivity
// search the minimal distance between every exiting TourActivity
while ((index + 1) < context.getRoute().getTourActivities().getActivities().size()) {
TourActivity activityBefore = context.getRoute().getTourActivities().getActivities().get(index);
TourActivity activityAfter = context.getRoute().getTourActivities().getActivities().get(index + 1);
Expand All @@ -286,7 +285,7 @@ private double findMinimalAdditionalDistance(JobInsertionContext context, TourAc
}
// checks the distance if the delivery is the last activity before the end of
// the tour
if (context.getRoute().getTourActivities().getActivities().size() > 0) {
if (!context.getRoute().getTourActivities().getActivities().isEmpty()) {
TourActivity activityLastDelivery = context.getRoute().getTourActivities().getActivities()
.get(context.getRoute().getTourActivities().getActivities().size() - 1);
TourActivity activityEnd = context.getRoute().getEnd();
Expand Down Expand Up @@ -326,7 +325,7 @@ private double getDistance(TourActivity from, TourActivity to) {
}

/**
* Given class for working with the a distance constraint
* Given class for working with a distance constraint
*
*/
class DistanceUpdater implements StateUpdater, ActivityVisitor {
Expand Down
Loading

0 comments on commit 7d631d8

Please sign in to comment.