Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public String toString() {

private double getThreshold(int iteration) {
double scheduleVariable = (double) iteration / (double) nOfTotalIterations;
// logger.debug("iter={} totalIter={} scheduling={}", iteration, nOfTotalIterations, scheduleVariable);
// logger.debug("iter={} totalIter={} scheduling={}", iteration,
// nOfTotalIterations, scheduleVariable);
double currentThreshold = initialThreshold * Math.exp(-Math.log(2) * scheduleVariable / alpha);
return currentThreshold;
}
Expand All @@ -108,7 +109,7 @@ public void informAlgorithmStarts(VehicleRoutingProblem problem, VehicleRoutingA
this.nOfTotalIterations = algorithm.getMaxIterations();

/*
* randomWalk to determine standardDev
* randomWalk to determine standardDev
*/
final double[] results = new double[nOfRandomWalks];

Expand All @@ -121,7 +122,7 @@ public void informAlgorithmStarts(VehicleRoutingProblem problem, VehicleRoutingA
@Override
public void informIterationEnds(int iteration, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) {
double result = Solutions.bestOf(solutions).getCost();
// logger.info("result={}", result);
// logger.info("result={}", result);
results[iteration - 1] = result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void informAlgorithmStarts(VehicleRoutingProblem problem, VehicleRoutingA
double now = System.currentTimeMillis();

/*
* randomWalk to determine standardDev
* randomWalk to determine standardDev
*/
final double[] results = new double[nOfRandomWalks];

Expand All @@ -64,7 +64,7 @@ public void informAlgorithmStarts(VehicleRoutingProblem problem, VehicleRoutingA
@Override
public void informIterationEnds(int iteration, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) {
double result = Solutions.bestOf(solutions).getCost();
// logger.info("result={}", result);
// logger.info("result={}", result);
results[iteration - 1] = result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ public InsertionData getInsertionData(final VehicleRoute currentRoute, final Job
additionalICostsAtRouteLevel += additionalAccessEgressCalculator.getCosts(insertionContext);

/*
generate new start and end for new vehicle
*/
* generate new start and end for new vehicle
*/
Start start = new Start(newVehicle.getStartLocation(), newVehicle.getEarliestDeparture(), Double.MAX_VALUE);
start.setEndTime(newVehicleDepartureTime);
End end = new End(newVehicle.getEndLocation(), 0.0, newVehicle.getLatestArrival());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ public InsertionData getInsertionData(VehicleRoute currentRoute, Job jobToInsert
} else currentStart = currentRoute.getStart().getEndTime();

vehicleDepartureTimes.add(currentStart);
// double earliestDeparture = newVehicle.getEarliestDeparture();
// double latestEnd = newVehicle.getLatestArrival();
// double earliestDeparture = newVehicle.getEarliestDeparture();
// double latestEnd = newVehicle.getLatestArrival();

for (int i = 0; i < nOfDepartureTimes; i++) {
double neighborStartTime_earlier = currentStart - (i + 1) * timeSlice;
// if(neighborStartTime_earlier > earliestDeparture) {
// if(neighborStartTime_earlier > earliestDeparture) {
vehicleDepartureTimes.add(neighborStartTime_earlier);
// }
// }
double neighborStartTime_later = currentStart + (i + 1) * timeSlice;
// if(neighborStartTime_later < latestEnd) {
// if(neighborStartTime_later < latestEnd) {
vehicleDepartureTimes.add(neighborStartTime_later);
// }
// }
}

InsertionData bestIData = null;
Expand All @@ -84,7 +84,7 @@ else if (iData.getInsertionCost() < bestIData.getInsertionCost()) {
bestIData = iData;
}
}
// log.info(bestIData);
// log.info(bestIData);
return bestIData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ public JobInsertionCostsCalculator build() {
// addInsertionListeners(withFixed.getInsertionListener());
}
if (timeScheduling) {
// baseCalculator = new CalculatesServiceInsertionWithTimeSchedulingInSlices(baseCalculator,timeSlice,neighbors);
// baseCalculator = new
// CalculatesServiceInsertionWithTimeSchedulingInSlices(baseCalculator,timeSlice,neighbors);
CalculatesServiceInsertionWithTimeScheduling wts = new CalculatesServiceInsertionWithTimeScheduling(baseCalculator, timeSlice, neighbors);
CalculatorPlusListeners calcPlusListeners = new CalculatorPlusListeners(wts);
calcPlusListeners.getInsertionListener().add(new CalculatesServiceInsertionWithTimeScheduling.KnowledgeInjection(wts));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public double getCosts(JobInsertionContext iFacts, TourActivity prevAct, TourAct
}

/*
* calculates the path costs with new vehicle, c(forwardPath,newVehicle).
* calculates the path costs with new vehicle, c(forwardPath,newVehicle).
*/
double forwardPathCost_newVehicle = auxilliaryPathCostCalculator.costOfPath(path, depTimeAtPrevAct, iFacts.getNewDriver(), iFacts.getNewVehicle());
return forwardPathCost_newVehicle - (actCostsOld(iFacts.getRoute(), path.get(path.size() - 1)) - actCostsOld(iFacts.getRoute(), prevAct));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public InsertionData getInsertionData(final VehicleRoute currentRoute, final Job
tourEnd = true;
}
boolean not_fulfilled_break = true;
for(TimeWindow timeWindow : service.getTimeWindows()) {
for (TimeWindow timeWindow : service.getTimeWindows()) {
deliveryAct2Insert.setTheoreticalEarliestOperationStartTime(timeWindow.getStart());
deliveryAct2Insert.setTheoreticalLatestOperationStartTime(timeWindow.getEnd());
ActivityContext activityContext = new ActivityContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public InsertionData getInsertionData(final VehicleRoute currentRoute, final Job
/**
* map that memorizes the costs with newVehicle, which is a cost-snapshot at tour-activities.
*/
// Map<TourActivity,Double> activity2costWithNewVehicle = new HashMap<TourActivity,Double>();
// Map<TourActivity,Double> activity2costWithNewVehicle = new
// HashMap<TourActivity,Double>();

/**
* priority queue that stores insertion-data by insertion-costs in ascending order.
Expand Down Expand Up @@ -199,7 +200,7 @@ public InsertionData getInsertionData(final VehicleRoute currentRoute, final Job
* memorize transport and activity costs with new vehicle without inserting k
*/
sumOf_prevCosts_newVehicle += transportCost_prevAct_nextAct_newVehicle + activityCost_nextAct;
// activity2costWithNewVehicle.put(nextAct, sumOf_prevCosts_newVehicle);
// activity2costWithNewVehicle.put(nextAct, sumOf_prevCosts_newVehicle);

/**
* departure time at nextAct with new vehicle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ else if (pickupShipmentConstraintStatus.equals(ConstraintsStatus.FULFILLED)) {
continue;
}

/*
--------------------------------
*/
/*
* --------------------------------
*/
//deliverShipmentLoop
int j = i;
boolean tourEnd_deliveryLoop = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ public InsertionData getInsertionData(final VehicleRoute currentRoute, final Job
continue;
}

/*
--------------------------------
*/
/*
* --------------------------------
*/
//deliverShipmentLoop
int j = i;
boolean tourEndInDeliveryLoop = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ public void ruinStarts(Collection<VehicleRoute> routes) {

@Override
public void ruinEnds(Collection<VehicleRoute> routes, Collection<Job> unassignedJobs) {
// log.debug("ruin ends");
// log.debug("ruin ends");
ruinListeners.ruinEnds(routes, unassignedJobs);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void begin(VehicleRoute route) {
@Override
public void visit(TourActivity activity) {
states.putInternalTypedActivityState(activity, route.getVehicle(), InternalStates.FUTURE_WAITING, futureWaiting);
if(!(activity instanceof BreakActivity)) {
if (!(activity instanceof BreakActivity)) {
futureWaiting += Math.max(activity.getTheoreticalEarliestOperationStartTime() - activity.getArrTime(), 0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prev
// nextLocation = nextAct.getLocation();
}

/*
* if latest arrival of vehicle (at its end) is smaller than earliest operation start times of activities,
* then vehicle can never conduct activities.
*
* |--- vehicle's operation time ---|
* |--- prevAct or newAct or nextAct ---|
*/
/*
* if latest arrival of vehicle (at its end) is smaller than earliest operation
* start times of activities,
* then vehicle can never conduct activities.
*
* |--- vehicle's operation time ---|
* |--- prevAct or newAct or nextAct ---|
*/
double newAct_theoreticalEarliestOperationStartTime = newAct.getTheoreticalEarliestOperationStartTime();

if (latestVehicleArrival < prevAct.getTheoreticalEarliestOperationStartTime() ||
Expand All @@ -86,35 +87,37 @@ public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prev
return ConstraintsStatus.NOT_FULFILLED_BREAK;
}
/*
* if the latest operation start-time of new activity is smaller than the earliest start of prev. activity,
* if the latest operation start-time of new activity is smaller than the
* earliest start of prev. activity,
* then
*
* |--- prevAct ---|
* |--- newAct ---|
* |--- prevAct ---|
* |--- newAct ---|
*/
if (newAct.getTheoreticalLatestOperationStartTime() < prevAct.getTheoreticalEarliestOperationStartTime()) {
return ConstraintsStatus.NOT_FULFILLED_BREAK;
}

/*
* |--- prevAct ---|
* |- earliest arrival of vehicle
* |--- nextAct ---|
*/
/*
* |--- prevAct ---|
* |- earliest arrival of vehicle
* |--- nextAct ---|
*/

double arrTimeAtNextOnDirectRouteWithNewVehicle = prevActDepTime + routingCosts.getTransportTime(prevLocation, nextLocation, prevActDepTime, iFacts.getNewDriver(), iFacts.getNewVehicle());
if (arrTimeAtNextOnDirectRouteWithNewVehicle > latestArrTimeAtNextAct) {
return ConstraintsStatus.NOT_FULFILLED_BREAK;
}

/*
* |--- newAct ---|
* |--- nextAct ---|
*/
/*
* |--- newAct ---|
* |--- nextAct ---|
*/
if (newAct.getTheoreticalEarliestOperationStartTime() > nextAct.getTheoreticalLatestOperationStartTime()) {
return ConstraintsStatus.NOT_FULFILLED;
}
// log.info("check insertion of " + newAct + " between " + prevAct + " and " + nextAct + ". prevActDepTime=" + prevActDepTime);
// log.info("check insertion of " + newAct + " between " + prevAct + " and " +
// nextAct + ". prevActDepTime=" + prevActDepTime);
double arrTimeAtNewAct = prevActDepTime + routingCosts.getTransportTime(prevLocation, newLocation, prevActDepTime, iFacts.getNewDriver(), iFacts.getNewVehicle());
double endTimeAtNewAct = Math.max(arrTimeAtNewAct, newAct.getTheoreticalEarliestOperationStartTime()) + activityCosts.getActivityDuration(newAct, arrTimeAtNewAct,iFacts.getNewDriver(),iFacts.getNewVehicle());
double latestArrTimeAtNewAct =
Expand All @@ -124,11 +127,11 @@ public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prev
- activityCosts.getActivityDuration(newAct, arrTimeAtNewAct, iFacts.getNewDriver(), iFacts.getNewVehicle())
);

/*
* |--- prevAct ---|
* |--- vehicle's arrival @newAct
* latest arrival of vehicle @newAct ---|
*/
/*
* |--- prevAct ---|
* |--- vehicle's arrival @newAct
* latest arrival of vehicle @newAct ---|
*/
if (arrTimeAtNewAct > latestArrTimeAtNewAct) {
return ConstraintsStatus.NOT_FULFILLED;
}
Expand All @@ -138,15 +141,15 @@ public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prev
return ConstraintsStatus.FULFILLED;
}
}
// log.info(newAct + " arrTime=" + arrTimeAtNewAct);
// log.info(newAct + " arrTime=" + arrTimeAtNewAct);

double arrTimeAtNextAct = endTimeAtNewAct + routingCosts.getTransportTime(newLocation, nextLocation, endTimeAtNewAct, iFacts.getNewDriver(), iFacts.getNewVehicle());

/*
* |--- newAct ---|
* |--- vehicle's arrival @nextAct
* latest arrival of vehicle @nextAct ---|
*/
/*
* |--- newAct ---|
* |--- vehicle's arrival @nextAct
* latest arrival of vehicle @nextAct ---|
*/
if (arrTimeAtNextAct > latestArrTimeAtNextAct) {
return ConstraintsStatus.NOT_FULFILLED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static Builder newInstance(String id) {

protected Activity activity;

Builder(String id){
Builder(String id) {
this.id = id;
timeWindows = new TimeWindowsImpl();
timeWindows.add(TimeWindow.newInstance(0.0, Double.MAX_VALUE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public End(String locationId, double theoreticalStart, double theoreticalEnd) {

public End(End end) {
this.location = end.getLocation();
// this.locationId = end.getLocation().getId();
// this.locationId = end.getLocation().getId();
theoretical_earliestOperationStartTime = end.getTheoreticalEarliestOperationStartTime();
theoretical_latestOperationStartTime = end.getTheoreticalLatestOperationStartTime();
arrTime = end.getArrTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void extractTypes(Collection<Vehicle> vehicles) {
for (Vehicle v : vehicles) {
// VehicleTypeKey typeKey = new VehicleTypeKey(v.getType().getTypeId(), v.getStartLocation().getId(), v.getEndLocation().getId(), v.getEarliestDeparture(), v.getLatestArrival(), v.getSkills(), v.isReturnToDepot());
types.put(v.getVehicleTypeIdentifier(), v);
// sortedTypes.add(typeKey);
// sortedTypes.add(typeKey);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
import com.graphhopper.jsprit.core.util.ChristofidesReader;
import com.graphhopper.jsprit.core.util.JobType;
import com.graphhopper.jsprit.core.util.Solutions;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Collection;

import static org.junit.Assert.assertEquals;

public class CVRPwithDeliveries_IT {

@Test
Expand All @@ -38,8 +37,8 @@ public void whenSolvingVRPNC1withDeliveriesWithJsprit_solutionsMustNoBeWorseThan
VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(530.0, Solutions.bestOf(solutions).getCost(), 50.0);
assertEquals(5, Solutions.bestOf(solutions).getRoutes().size());
Assertions.assertEquals(530.0, Solutions.bestOf(solutions).getCost(), 50.0);
Assertions.assertEquals(5, Solutions.bestOf(solutions).getRoutes().size());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
import com.graphhopper.jsprit.core.util.ChristofidesReader;
import com.graphhopper.jsprit.core.util.JobType;
import com.graphhopper.jsprit.core.util.Solutions;
import org.junit.Test;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Collection;

import static org.junit.Assert.assertEquals;

public class CVRPwithPickups_IT {

Expand All @@ -38,8 +39,8 @@ public void whenSolvingVRPNC1WithPickups_solutionsMustNoBeWorseThan5PercentOfBes
VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.FAST_REGRET,"true").buildAlgorithm();
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(530.0, Solutions.bestOf(solutions).getCost(), 50.0);
assertEquals(5, Solutions.bestOf(solutions).getRoutes().size());
Assertions.assertEquals(530.0, Solutions.bestOf(solutions).getCost(), 50.0);
Assertions.assertEquals(5, Solutions.bestOf(solutions).getRoutes().size());
}

}
Loading