mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
reformat according to .editorconfig
This commit is contained in:
parent
3696f361d3
commit
e5bc5f87cb
41 changed files with 52 additions and 51 deletions
|
|
@ -32,8 +32,8 @@ class ConcurrentInsertionNoiseMaker implements SoftActivityConstraint, Iteration
|
||||||
this.noiseLevel = noiseLevel;
|
this.noiseLevel = noiseLevel;
|
||||||
this.noiseProbability = noiseProbability;
|
this.noiseProbability = noiseProbability;
|
||||||
this.maxCosts = maxCosts;
|
this.maxCosts = maxCosts;
|
||||||
randomArray = new Random[vrp.getNuActivities()+2];
|
randomArray = new Random[vrp.getNuActivities() + 2];
|
||||||
for(int i=0;i<randomArray.length;i++){
|
for (int i = 0; i < randomArray.length; i++) {
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
r.setSeed(random.nextLong());
|
r.setSeed(random.nextLong());
|
||||||
randomArray[i] = r;
|
randomArray[i] = r;
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ class JobNeighborhoodsImpl implements JobNeighborhoods {
|
||||||
for (Job j : vrp.getJobs().values()) {
|
for (Job j : vrp.getJobs().values()) {
|
||||||
if (i == j) continue;
|
if (i == j) continue;
|
||||||
double distance = jobDistance.getDistance(i, j);
|
double distance = jobDistance.getDistance(i, j);
|
||||||
if(distance > maxDistance) maxDistance = distance;
|
if (distance > maxDistance) maxDistance = distance;
|
||||||
ReferencedJob refNode = new ReferencedJob(j, distance);
|
ReferencedJob refNode = new ReferencedJob(j, distance);
|
||||||
treeSet.add(refNode);
|
treeSet.add(refNode);
|
||||||
nuOfDistancesStored++;
|
nuOfDistancesStored++;
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class JobNeighborhoodsImplWithCapRestriction implements JobNeighborhoods {
|
||||||
for (Job j : vrp.getJobs().values()) {
|
for (Job j : vrp.getJobs().values()) {
|
||||||
if (i == j) continue;
|
if (i == j) continue;
|
||||||
double distance = jobDistance.getDistance(i, j);
|
double distance = jobDistance.getDistance(i, j);
|
||||||
if(distance > maxDistance) maxDistance = distance;
|
if (distance > maxDistance) maxDistance = distance;
|
||||||
ReferencedJob refNode = new ReferencedJob(j, distance);
|
ReferencedJob refNode = new ReferencedJob(j, distance);
|
||||||
if (treeSet.size() < capacity) {
|
if (treeSet.size() < capacity) {
|
||||||
treeSet.add(refNode);
|
treeSet.add(refNode);
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,8 @@ public class UpdateVehicleDependentPracticalTimeWindows implements RouteVisitor,
|
||||||
double potentialLatestArrivalTimeAtCurrAct = latestArrTimeAtPrevAct - transportCosts.getBackwardTransportTime(activity.getLocation(), prevLocation,
|
double potentialLatestArrivalTimeAtCurrAct = latestArrTimeAtPrevAct - transportCosts.getBackwardTransportTime(activity.getLocation(), prevLocation,
|
||||||
latestArrTimeAtPrevAct, route.getDriver(), vehicle) - activity.getOperationTime();
|
latestArrTimeAtPrevAct, route.getDriver(), vehicle) - activity.getOperationTime();
|
||||||
double latestArrivalTime = Math.min(activity.getTheoreticalLatestOperationStartTime(), potentialLatestArrivalTimeAtCurrAct);
|
double latestArrivalTime = Math.min(activity.getTheoreticalLatestOperationStartTime(), potentialLatestArrivalTimeAtCurrAct);
|
||||||
if(latestArrivalTime < activity.getTheoreticalEarliestOperationStartTime()){
|
if (latestArrivalTime < activity.getTheoreticalEarliestOperationStartTime()) {
|
||||||
stateManager.putTypedInternalRouteState(route,vehicle,InternalStates.SWITCH_NOT_FEASIBLE,true);
|
stateManager.putTypedInternalRouteState(route, vehicle, InternalStates.SWITCH_NOT_FEASIBLE, true);
|
||||||
}
|
}
|
||||||
stateManager.putInternalTypedActivityState(activity, vehicle, InternalStates.LATEST_OPERATION_START_TIME, latestArrivalTime);
|
stateManager.putInternalTypedActivityState(activity, vehicle, InternalStates.LATEST_OPERATION_START_TIME, latestArrivalTime);
|
||||||
latest_arrTimes_at_prevAct[vehicle.getVehicleTypeIdentifier().getIndex()] = latestArrivalTime;
|
latest_arrTimes_at_prevAct[vehicle.getVehicleTypeIdentifier().getIndex()] = latestArrivalTime;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import jsprit.core.problem.misc.JobInsertionContext;
|
||||||
/**
|
/**
|
||||||
* Created by schroeder on 19/09/15.
|
* Created by schroeder on 19/09/15.
|
||||||
*/
|
*/
|
||||||
public class SwitchNotFeasible implements HardRouteConstraint{
|
public class SwitchNotFeasible implements HardRouteConstraint {
|
||||||
|
|
||||||
private StateManager stateManager;
|
private StateManager stateManager;
|
||||||
|
|
||||||
|
|
@ -17,8 +17,9 @@ public class SwitchNotFeasible implements HardRouteConstraint{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean fulfilled(JobInsertionContext insertionContext) {
|
public boolean fulfilled(JobInsertionContext insertionContext) {
|
||||||
Boolean notFeasible = stateManager.getRouteState(insertionContext.getRoute(),insertionContext.getNewVehicle(), InternalStates.SWITCH_NOT_FEASIBLE,Boolean.class);
|
Boolean notFeasible = stateManager.getRouteState(insertionContext.getRoute(), insertionContext.getNewVehicle(), InternalStates.SWITCH_NOT_FEASIBLE, Boolean.class);
|
||||||
if(notFeasible == null || insertionContext.getRoute().getVehicle().getVehicleTypeIdentifier().equals(insertionContext.getNewVehicle().getVehicleTypeIdentifier())) return true;
|
if (notFeasible == null || insertionContext.getRoute().getVehicle().getVehicleTypeIdentifier().equals(insertionContext.getNewVehicle().getVehicleTypeIdentifier()))
|
||||||
|
return true;
|
||||||
else return !notFeasible;
|
else return !notFeasible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public double[][][] getMatrix(){
|
public double[][][] getMatrix() {
|
||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -560,7 +560,7 @@ public class MeetTimeWindowConstraint_IT {
|
||||||
VehicleRoutingAlgorithm algorithm = Jsprit.Builder.newInstance(vrp).buildAlgorithm();
|
VehicleRoutingAlgorithm algorithm = Jsprit.Builder.newInstance(vrp).buildAlgorithm();
|
||||||
algorithm.setMaxIterations(1000);
|
algorithm.setMaxIterations(1000);
|
||||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(algorithm.searchSolutions());
|
VehicleRoutingProblemSolution solution = Solutions.bestOf(algorithm.searchSolutions());
|
||||||
for(VehicleRoute r : solution.getRoutes()){
|
for (VehicleRoute r : solution.getRoutes()) {
|
||||||
assertTrue(r.getVehicle().getEarliestDeparture() <= r.getDepartureTime());
|
assertTrue(r.getVehicle().getEarliestDeparture() <= r.getDepartureTime());
|
||||||
assertTrue(r.getVehicle().getLatestArrival() >= r.getEnd().getArrTime());
|
assertTrue(r.getVehicle().getLatestArrival() >= r.getEnd().getArrTime());
|
||||||
}
|
}
|
||||||
|
|
@ -576,7 +576,7 @@ public class MeetTimeWindowConstraint_IT {
|
||||||
VehicleRoutingAlgorithm algorithm = new SchrimpfFactory().createAlgorithm(vrp);
|
VehicleRoutingAlgorithm algorithm = new SchrimpfFactory().createAlgorithm(vrp);
|
||||||
algorithm.setMaxIterations(1000);
|
algorithm.setMaxIterations(1000);
|
||||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(algorithm.searchSolutions());
|
VehicleRoutingProblemSolution solution = Solutions.bestOf(algorithm.searchSolutions());
|
||||||
for(VehicleRoute r : solution.getRoutes()){
|
for (VehicleRoute r : solution.getRoutes()) {
|
||||||
assertTrue(r.getVehicle().getEarliestDeparture() <= r.getDepartureTime());
|
assertTrue(r.getVehicle().getEarliestDeparture() <= r.getDepartureTime());
|
||||||
assertTrue(r.getVehicle().getLatestArrival() >= r.getEnd().getArrTime());
|
assertTrue(r.getVehicle().getLatestArrival() >= r.getEnd().getArrTime());
|
||||||
}
|
}
|
||||||
|
|
@ -592,7 +592,7 @@ public class MeetTimeWindowConstraint_IT {
|
||||||
VehicleRoutingAlgorithm algorithm = new GreedySchrimpfFactory().createAlgorithm(vrp);
|
VehicleRoutingAlgorithm algorithm = new GreedySchrimpfFactory().createAlgorithm(vrp);
|
||||||
algorithm.setMaxIterations(1000);
|
algorithm.setMaxIterations(1000);
|
||||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(algorithm.searchSolutions());
|
VehicleRoutingProblemSolution solution = Solutions.bestOf(algorithm.searchSolutions());
|
||||||
for(VehicleRoute r : solution.getRoutes()){
|
for (VehicleRoute r : solution.getRoutes()) {
|
||||||
assertTrue(r.getVehicle().getEarliestDeparture() <= r.getDepartureTime());
|
assertTrue(r.getVehicle().getEarliestDeparture() <= r.getDepartureTime());
|
||||||
assertTrue(r.getVehicle().getLatestArrival() >= r.getEnd().getArrTime());
|
assertTrue(r.getVehicle().getLatestArrival() >= r.getEnd().getArrTime());
|
||||||
}
|
}
|
||||||
|
|
@ -602,10 +602,10 @@ public class MeetTimeWindowConstraint_IT {
|
||||||
private FastVehicleRoutingTransportCostsMatrix createMatrix() throws IOException {
|
private FastVehicleRoutingTransportCostsMatrix createMatrix() throws IOException {
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(new File("src/test/resources/matrix.txt")));
|
BufferedReader reader = new BufferedReader(new FileReader(new File("src/test/resources/matrix.txt")));
|
||||||
String line;
|
String line;
|
||||||
FastVehicleRoutingTransportCostsMatrix.Builder builder = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(11,false);
|
FastVehicleRoutingTransportCostsMatrix.Builder builder = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(11, false);
|
||||||
while((line = reader.readLine()) != null){
|
while ((line = reader.readLine()) != null) {
|
||||||
String[] split = line.split("\t");
|
String[] split = line.split("\t");
|
||||||
builder.addTransportDistance(Integer.parseInt(split[0]),Integer.parseInt(split[1]),Double.parseDouble(split[2]));
|
builder.addTransportDistance(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Double.parseDouble(split[2]));
|
||||||
builder.addTransportTime(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Double.parseDouble(split[3]));
|
builder.addTransportTime(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Double.parseDouble(split[3]));
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue