From 6ce5d2519e7c833bea7e9b189f7b3bce7d2c0415 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Thu, 11 Jul 2013 16:26:34 +0200 Subject: [PATCH] improve Instances and enhance SolomonReader with fixedCost setting --- jsprit-instances/instances/.DS_Store | Bin 6148 -> 0 bytes .../src/main/java/readers/SolomonReader.java | 10 +++++++++- .../src/main/java/util/Instances.java | 18 ++++++++++++------ 3 files changed, 21 insertions(+), 7 deletions(-) delete mode 100644 jsprit-instances/instances/.DS_Store diff --git a/jsprit-instances/instances/.DS_Store b/jsprit-instances/instances/.DS_Store deleted file mode 100644 index eb2fd83b5f7ed4606fe40b6b875726c16b149592..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}T>S5T0$TP5psf1idYuizI^7gNG0*cobUb!HOoP&_HQQlh8wnMtmV3!Kd(f zoY`HA#q=toGcfzj&d+A^L3T3$ApAUX0c-%UPzePY6+-UHP|YL@L{wa31OepXBAtbk ziiLioi}v1x2S{KJ(bxSaAx2)q*(6Rg$9WgEdSh$5X<0kg-f$34qh#SH`7}yzdgEl# zi=$B(%x{&Q1zDc@!CXbIgKUfuW%rY0g7(m458@~r-`PjYrR%tD>AIbwEtltK4%(+3 zrzl!2t7X4g2gfHDSN))Pd@7$cg@SfXvaew^zN{=Zm;q*h8DIvOflUmUTg2Mkl)!#w zfEoC=4AA)?Q3*YRrABph;GkLn#0I*RpiR95)kuS$!BQheP=qc;)TP3-7($n$Uz$A6 zV5w1;gD}m9Fi-w$UW9r&t}j(O2u~xA%m6d6&OlvHZMy$2@sp`+^4Cjv#tbk6e~baq z==QokzLdFJzr7yawG#Cnm4xz2GEmT7`w74aog;@TsN<4s%<~ME8fg{st8zsC5m1Ei JzzqBV10ObmL)8EP diff --git a/jsprit-instances/src/main/java/readers/SolomonReader.java b/jsprit-instances/src/main/java/readers/SolomonReader.java index 936d4f62..c8ce1f4b 100644 --- a/jsprit-instances/src/main/java/readers/SolomonReader.java +++ b/jsprit-instances/src/main/java/readers/SolomonReader.java @@ -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(); diff --git a/jsprit-instances/src/main/java/util/Instances.java b/jsprit-instances/src/main/java/util/Instances.java index f9f57d60..57c91364 100644 --- a/jsprit-instances/src/main/java/util/Instances.java +++ b/jsprit-instances/src/main/java/util/Instances.java @@ -104,6 +104,7 @@ public class Instances { /** * Returns a collection of {@link BenchmarkInstance} which are Solomon instances. *
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. + *
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. *
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. + *
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. *
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. + *
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. *
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. + *
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. *
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. + *
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. *
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. + *
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())); }