1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

improve Instances and enhance SolomonReader with fixedCost setting

This commit is contained in:
Stefan Schroeder 2013-07-11 16:26:34 +02:00
parent 72f9cd70ba
commit 6ce5d2519e
3 changed files with 21 additions and 7 deletions

Binary file not shown.

View file

@ -68,11 +68,19 @@ public class SolomonReader {
private double variableCostProjectionFactor = 1;
private double fixedCostPerVehicle = 0.0;
public SolomonReader(VehicleRoutingProblem.Builder vrpBuilder) {
super();
this.vrpBuilder = vrpBuilder;
}
public SolomonReader(VehicleRoutingProblem.Builder vrpBuilder, double fixedCostPerVehicle) {
super();
this.vrpBuilder = vrpBuilder;
this.fixedCostPerVehicle=fixedCostPerVehicle;
}
public void read(String solomonFile){
vrpBuilder.setFleetSize(FleetSize.INFINITE);
BufferedReader reader = getReader(solomonFile);
@ -98,7 +106,7 @@ public class SolomonReader {
double serviceTime = Double.parseDouble(tokens[6])*timeProjectionFactor;
if(counter == 10){
VehicleTypeImpl.Builder typeBuilder = VehicleTypeImpl.Builder.newInstance("solomonType", vehicleCapacity);
typeBuilder.setCostPerDistance(1.0*variableCostProjectionFactor).setFixedCost(100);
typeBuilder.setCostPerDistance(1.0*variableCostProjectionFactor).setFixedCost(fixedCostPerVehicle);
VehicleTypeImpl vehicleType = typeBuilder.build();

View file

@ -104,6 +104,7 @@ public class Instances {
/**
* Returns a collection of {@link BenchmarkInstance} which are Solomon instances.
* <p>Note that this assumes that within the folder 'inputFolder' 9 C1-instances are located with their original name, i.e. C101.txt,C102.txt,...,C109.txt.
* <p>Note that unlike the original problems, a fixed-cost value of 1000 is set for each employed vehicle.
* @param inputFolder where solomon C1 instances are located. It must end without '/' such as instances/solomon.
*
* @return a collection of {@link BenchmarkInstance}
@ -115,7 +116,7 @@ public class Instances {
for(int i=0;i<9;i++){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
String file = inputFolder + "/C1"+ getInstanceNu(i+1) + ".txt";
new SolomonReader(builder).read(file);
new SolomonReader(builder,1000).read(file);
VehicleRoutingProblem p = builder.build();
instances.add(new BenchmarkInstance("C1" + getInstanceNu(i+1), p, bestKnown.get(i).doubleValue(), bestKnowVehicles.get(i).doubleValue()));
}
@ -125,6 +126,7 @@ public class Instances {
/**
* Returns a collection of {@link BenchmarkInstance} which are Solomon instances.
* <p>Note that this assumes that within the folder 'inputFolder' 8 C2-instances are located with their original name, i.e. C201.txt,C202.txt,...,C208.txt.
* <p>Note that unlike the original problems, a fixed-cost value of 1000 is set for each employed vehicle.
* @param inputFolder where solomon C2 instances are located. It must end without '/' such as instances/solomon.
* @return a collection of {@link BenchmarkInstance}
*/
@ -135,7 +137,7 @@ public class Instances {
for(int i=0;i<8;i++){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
String file = inputFolder + "/C2"+ getInstanceNu(i+1) + ".txt";
new SolomonReader(builder).read(file);
new SolomonReader(builder,1000).read(file);
VehicleRoutingProblem p = builder.build();
instances.add(new BenchmarkInstance("C2" + getInstanceNu(i+1), p, bestKnown.get(i).doubleValue(), bestKnowVehicles.get(i).doubleValue()));
}
@ -145,6 +147,7 @@ public class Instances {
/**
* Returns a collection of {@link BenchmarkInstance} which are Solomon instances.
* <p>Note that this assumes that within the folder 'inputFolder' 12 R1-instances are located with their original name, i.e. R101.txt,R102.txt,...,R112.txt.
* <p>Note that unlike the original problems, a fixed-cost value of 1000 is set for each employed vehicle.
* @param inputFolder where solomon R1 instances are located. It must end without '/' such as instances/solomon.
* @return a collection of {@link BenchmarkInstance}
*/
@ -155,7 +158,7 @@ public class Instances {
for(int i=0;i<12;i++){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
String file = inputFolder + "/R1"+ getInstanceNu(i+1) + ".txt";
new SolomonReader(builder).read(file);
new SolomonReader(builder,1000).read(file);
VehicleRoutingProblem p = builder.build();
instances.add(new BenchmarkInstance("R1" + getInstanceNu(i+1), p, bestKnown.get(i).doubleValue(), bestKnowVehicles.get(i).doubleValue()));
}
@ -165,6 +168,7 @@ public class Instances {
/**
* Returns a collection of {@link BenchmarkInstance} which are Solomon instances.
* <p>Note that this assumes that within the folder 'inputFolder' 11 R1-instances are located with their original name, i.e. R201.txt,R202.txt,...,R111.txt.
* <p>Note that unlike the original problems, a fixed-cost value of 1000 is set for each employed vehicle.
* @param inputFolder TODO
* @param inputFolder where solomon R2 instances are located. It must end without '/' such as instances/solomon.
* @return a collection of {@link BenchmarkInstance}
@ -176,7 +180,7 @@ public class Instances {
for(int i=0;i<11;i++){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
String file = inputFolder + "/R2"+ getInstanceNu(i+1) + ".txt";
new SolomonReader(builder).read(file);
new SolomonReader(builder,1000).read(file);
VehicleRoutingProblem p = builder.build();
instances.add(new BenchmarkInstance("R2" + getInstanceNu(i+1), p, bestKnown.get(i).doubleValue(), bestKnowVehicles.get(i).doubleValue()));
}
@ -186,6 +190,7 @@ public class Instances {
/**
* Returns a collection of {@link BenchmarkInstance} which are Solomon instances.
* <p>Note that this assumes that within the folder 'inputFolder' 8 RC1-instances are located with their original name, i.e. RC101.txt,RC102.txt,...,RC108.txt.
* <p>Note that unlike the original problems, a fixed-cost value of 1000 is set for each employed vehicle.
* @param inputFolder where solomon RC1 instances are located. It must end without '/' such as instances/solomon.
* @return a collection of {@link BenchmarkInstance}
*/
@ -196,7 +201,7 @@ public class Instances {
for(int i=0;i<8;i++){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
String file = inputFolder + "/RC1"+ getInstanceNu(i+1) + ".txt";
new SolomonReader(builder).read(file);
new SolomonReader(builder,1000).read(file);
VehicleRoutingProblem p = builder.build();
instances.add(new BenchmarkInstance("RC1" + getInstanceNu(i+1), p, bestKnown.get(i).doubleValue(), bestKnowVehicles.get(i).doubleValue()));
}
@ -206,6 +211,7 @@ public class Instances {
/**
* Returns a collection of {@link BenchmarkInstance} which are Solomon instances.
* <p>Note that this assumes that within the folder 'inputFolder' 8 RC2-instances are located with their original name, i.e. RC201.txt,RC202.txt,...,RC208.txt.
* <p>Note that unlike the original problems, a fixed-cost value of 1000 is set for each employed vehicle.
* @param inputFolder TODO
* @param inputFolder where solomon RC2 instances are located. It must end without '/' such as instances/solomon.
* @return a collection of {@link BenchmarkInstance}
@ -217,7 +223,7 @@ public class Instances {
for(int i=0;i<8;i++){
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
String file = inputFolder + "/RC2"+ getInstanceNu(i+1) + ".txt";
new SolomonReader(builder).read(file);
new SolomonReader(builder,1000).read(file);
VehicleRoutingProblem p = builder.build();
instances.add(new BenchmarkInstance("RC2" + getInstanceNu(i+1), p, bestKnown.get(i).doubleValue(), bestKnowVehicles.get(i).doubleValue()));
}