mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
Merge branch 'simplify-state-updates' into bicycle
This commit is contained in:
commit
b37ab653e1
2 changed files with 43 additions and 18 deletions
|
|
@ -392,12 +392,12 @@ public class VehicleRoutingAlgorithms {
|
||||||
* @return {@link VehicleRoutingAlgorithm}
|
* @return {@link VehicleRoutingAlgorithm}
|
||||||
*/
|
*/
|
||||||
public static VehicleRoutingAlgorithm createAlgorithm(final VehicleRoutingProblem vrp, final AlgorithmConfig algorithmConfig){
|
public static VehicleRoutingAlgorithm createAlgorithm(final VehicleRoutingProblem vrp, final AlgorithmConfig algorithmConfig){
|
||||||
return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),0);
|
return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static VehicleRoutingAlgorithm readAndCreateAlgorithm(final VehicleRoutingProblem vrp, final XMLConfiguration config){
|
public static VehicleRoutingAlgorithm readAndCreateAlgorithm(final VehicleRoutingProblem vrp, final XMLConfiguration config){
|
||||||
return createAlgo(vrp,config,0);
|
return createAlgo(vrp,config,0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -411,7 +411,7 @@ public class VehicleRoutingAlgorithms {
|
||||||
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
|
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
|
||||||
AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig);
|
AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig);
|
||||||
xmlReader.read(configURL);
|
xmlReader.read(configURL);
|
||||||
return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),0);
|
return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -425,17 +425,26 @@ public class VehicleRoutingAlgorithms {
|
||||||
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
|
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
|
||||||
AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig);
|
AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig);
|
||||||
xmlReader.read(configFileName);
|
xmlReader.read(configFileName);
|
||||||
return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),0);
|
return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),0, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VehicleRoutingAlgorithm readAndCreateAlgorithm(final VehicleRoutingProblem vrp, final String configFileName, StateManager stateManager){
|
||||||
|
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
|
||||||
|
AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig);
|
||||||
|
xmlReader.read(configFileName);
|
||||||
|
return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),0, stateManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VehicleRoutingAlgorithm readAndCreateAlgorithm(VehicleRoutingProblem vrp, int nThreads, String configFileName) {
|
public static VehicleRoutingAlgorithm readAndCreateAlgorithm(VehicleRoutingProblem vrp, int nThreads, String configFileName) {
|
||||||
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
|
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
|
||||||
AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig);
|
AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig);
|
||||||
xmlReader.read(configFileName);
|
xmlReader.read(configFileName);
|
||||||
return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),nThreads);
|
return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),nThreads, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static VehicleRoutingAlgorithm createAlgo(final VehicleRoutingProblem vrp, XMLConfiguration config, int nuOfThreads){
|
|
||||||
|
|
||||||
|
private static VehicleRoutingAlgorithm createAlgo(final VehicleRoutingProblem vrp, XMLConfiguration config, int nuOfThreads, StateManager stateMan){
|
||||||
|
|
||||||
|
|
||||||
// map to store constructed modules
|
// map to store constructed modules
|
||||||
|
|
@ -484,7 +493,13 @@ public class VehicleRoutingAlgorithms {
|
||||||
final VehicleFleetManager vehicleFleetManager = createFleetManager(vrp);
|
final VehicleFleetManager vehicleFleetManager = createFleetManager(vrp);
|
||||||
|
|
||||||
//create state-manager
|
//create state-manager
|
||||||
final StateManager stateManager = new StateManager(vrp);
|
final StateManager stateManager;
|
||||||
|
if(stateMan!=null) {
|
||||||
|
stateManager = stateMan;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
stateManager = new StateManager(vrp);
|
||||||
|
}
|
||||||
stateManager.updateLoadStates();
|
stateManager.updateLoadStates();
|
||||||
stateManager.updateTimeWindowStates();
|
stateManager.updateTimeWindowStates();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,10 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
|
||||||
|
|
||||||
private VehicleRoutingProblem vrp;
|
private VehicleRoutingProblem vrp;
|
||||||
|
|
||||||
|
private boolean updateLoad = false;
|
||||||
|
|
||||||
|
private boolean updateTWs = false;
|
||||||
|
|
||||||
public StateManager(VehicleRoutingProblem vrp) {
|
public StateManager(VehicleRoutingProblem vrp) {
|
||||||
super();
|
super();
|
||||||
this.vrp = vrp;
|
this.vrp = vrp;
|
||||||
|
|
@ -277,6 +281,8 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLoadStates() {
|
public void updateLoadStates() {
|
||||||
|
if(!updateLoad){
|
||||||
|
updateLoad=true;
|
||||||
UpdateLoads updateLoads = new UpdateLoads(this);
|
UpdateLoads updateLoads = new UpdateLoads(this);
|
||||||
addActivityVisitor(updateLoads);
|
addActivityVisitor(updateLoads);
|
||||||
addListener(updateLoads);
|
addListener(updateLoads);
|
||||||
|
|
@ -284,8 +290,12 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
|
||||||
addActivityVisitor(new UpdateMaxLoad(this));
|
addActivityVisitor(new UpdateMaxLoad(this));
|
||||||
addActivityVisitor(new UpdateMaxLoad_(this));
|
addActivityVisitor(new UpdateMaxLoad_(this));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updateTimeWindowStates() {
|
public void updateTimeWindowStates() {
|
||||||
|
if(!updateTWs){
|
||||||
|
updateTWs=true;
|
||||||
addActivityVisitor(new UpdateTimeWindow(this, vrp.getTransportCosts()));
|
addActivityVisitor(new UpdateTimeWindow(this, vrp.getTransportCosts()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue