mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
improve GendreauAlgo
This commit is contained in:
parent
f25c9079dc
commit
07f6af9e56
5 changed files with 20 additions and 18 deletions
|
|
@ -41,9 +41,9 @@ import basics.route.TourActivity.JobActivity;
|
|||
|
||||
import util.RandomNumberGeneration;
|
||||
|
||||
final class GendreauPostOpt implements SearchStrategyModule{
|
||||
final class Gendreau implements SearchStrategyModule{
|
||||
|
||||
private final static Logger log = Logger.getLogger(GendreauPostOpt.class);
|
||||
private final static Logger log = Logger.getLogger(Gendreau.class);
|
||||
|
||||
private final static String NAME = "gendreauPostOpt";
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ final class GendreauPostOpt implements SearchStrategyModule{
|
|||
this.shareOfJobsToRuin = shareOfJobsToRuin;
|
||||
}
|
||||
|
||||
public GendreauPostOpt(VehicleRoutingProblem vrp, RuinStrategy ruin, AbstractInsertionStrategy insertionStrategy) {
|
||||
public Gendreau(VehicleRoutingProblem vrp, RuinStrategy ruin, AbstractInsertionStrategy insertionStrategy) {
|
||||
super();
|
||||
this.routeAlgorithm = insertionStrategy.getRouteAlgorithm();
|
||||
this.ruin = ruin;
|
||||
|
|
@ -77,7 +77,7 @@ final class GendreauPostOpt implements SearchStrategyModule{
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[name=gendreauPostOpt][iterations="+nOfIterations+"][share2ruin="+shareOfJobsToRuin+"]";
|
||||
return "[name=gendreau][iterations="+nOfIterations+"][share2ruin="+shareOfJobsToRuin+"]";
|
||||
}
|
||||
|
||||
public void setRandom(Random random) {
|
||||
|
|
@ -746,11 +746,11 @@ public class VehicleRoutingAlgorithms {
|
|||
return module;
|
||||
}
|
||||
|
||||
if(moduleName.equals("gendreauPostOpt")){
|
||||
if(moduleName.equals("gendreau")){
|
||||
int iterations = moduleConfig.getInt("iterations");
|
||||
double share = moduleConfig.getDouble("share");
|
||||
String ruinName = moduleConfig.getString("ruin[@name]");
|
||||
if(ruinName == null) throw new IllegalStateException("gendreauPostOpt.ruin[@name] is missing. set it to \"radialRuin\" or \"randomRuin\"");
|
||||
if(ruinName == null) throw new IllegalStateException("gendreau.ruin[@name] is missing. set it to \"radialRuin\" or \"randomRuin\"");
|
||||
String ruinId = moduleConfig.getString("ruin[@id]");
|
||||
if(ruinId == null) ruinId = "noId";
|
||||
ModKey ruinKey = makeKey(ruinName,ruinId);
|
||||
|
|
@ -762,7 +762,7 @@ public class VehicleRoutingAlgorithms {
|
|||
}
|
||||
|
||||
String insertionName = moduleConfig.getString("insertion[@name]");
|
||||
if(insertionName == null) throw new IllegalStateException("gendreauPostOpt.insertion[@name] is missing. set it to \"regretInsertion\" or \"bestInsertion\"");
|
||||
if(insertionName == null) throw new IllegalStateException("gendreau.insertion[@name] is missing. set it to \"regretInsertion\" or \"bestInsertion\"");
|
||||
String insertionId = moduleConfig.getString("insertion[@id]");
|
||||
if(insertionId == null) insertionId = "noId";
|
||||
ModKey insertionKey = makeKey(insertionName,insertionId);
|
||||
|
|
@ -775,12 +775,12 @@ public class VehicleRoutingAlgorithms {
|
|||
insertion = createInsertionStrategy(insertionConfigs.get(0), vrp, vehicleFleetManager, activityStates, prioListeners, executorService, nuOfThreads);
|
||||
algorithmListeners.addAll(prioListeners);
|
||||
}
|
||||
GendreauPostOpt postOpt = new GendreauPostOpt(vrp, ruin, insertion);
|
||||
postOpt.setShareOfJobsToRuin(share);
|
||||
postOpt.setNuOfIterations(iterations);
|
||||
postOpt.setFleetManager(vehicleFleetManager);
|
||||
definedClasses.put(strategyModuleKey, postOpt);
|
||||
return postOpt;
|
||||
Gendreau gendreau = new Gendreau(vrp, ruin, insertion);
|
||||
gendreau.setShareOfJobsToRuin(share);
|
||||
gendreau.setNuOfIterations(iterations);
|
||||
gendreau.setFleetManager(vehicleFleetManager);
|
||||
definedClasses.put(strategyModuleKey, gendreau);
|
||||
return gendreau;
|
||||
}
|
||||
throw new NullPointerException("no module found with moduleName=" + moduleName +
|
||||
"\n\tcheck config whether the correct names are used" +
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ public class VrpXMLReader{
|
|||
if(distC != null) typeBuilder.setCostPerDistance(distC);
|
||||
// if(start != null && end != null) typeBuilder.setTimeSchedule(new TimeSchedule(start, end));
|
||||
VehicleTypeImpl type = typeBuilder.build();
|
||||
types.put(type.typeId, type);
|
||||
types.put(type.getTypeId(), type);
|
||||
vrpBuilder.addVehicleType(type);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -166,14 +166,16 @@
|
|||
|
||||
<xs:group name="gendreau_group">
|
||||
<xs:sequence>
|
||||
<xs:element name="itertions" type="xs:integer"/>
|
||||
<xs:element name="iterations" type="xs:integer"/>
|
||||
<xs:element name="share" type="xs:double"/>
|
||||
<xs:element name="ruin" type="ruinType"/>
|
||||
<xs:element name="insertion" type="insertionType"/>
|
||||
</xs:sequence>
|
||||
</xs:group>
|
||||
|
||||
<xs:complexType name="ruinType">
|
||||
<xs:sequence>
|
||||
<xs:element name="share" minOccurs="1" maxOccurs="1">
|
||||
<xs:element name="share" minOccurs="0" maxOccurs="1">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:double">
|
||||
<xs:minInclusive value="0.0"/>
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ public class GendreauPostOptTest {
|
|||
|
||||
RuinRadial radialRuin = RuinRadial.newInstance(vrp, 0.2, new JobDistanceAvgCosts(vrp.getTransportCosts()), new JobRemoverImpl(), updater);
|
||||
AbstractInsertionStrategy insertionStrategy = new BestInsertion(routeAlgorithm);
|
||||
GendreauPostOpt postOpt = new GendreauPostOpt(vrp, radialRuin, insertionStrategy);
|
||||
Gendreau postOpt = new Gendreau(vrp, radialRuin, insertionStrategy);
|
||||
postOpt.setFleetManager(fleetManager);
|
||||
VehicleRoutingProblemSolution newSolution = postOpt.runAndGetSolution(sol);
|
||||
|
||||
|
|
@ -245,7 +245,7 @@ public class GendreauPostOptTest {
|
|||
|
||||
RuinRadial radialRuin = RuinRadial.newInstance(vrp, 0.2, new JobDistanceAvgCosts(vrp.getTransportCosts()), new JobRemoverImpl(), updater);
|
||||
AbstractInsertionStrategy insertionStrategy = new BestInsertion(routeAlgorithm);
|
||||
GendreauPostOpt postOpt = new GendreauPostOpt(vrp, radialRuin, insertionStrategy);
|
||||
Gendreau postOpt = new Gendreau(vrp, radialRuin, insertionStrategy);
|
||||
postOpt.setShareOfJobsToRuin(1.0);
|
||||
postOpt.setNuOfIterations(1);
|
||||
postOpt.setFleetManager(fleetManager);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue