mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
added constructor for AlgortihmConfig
This commit is contained in:
parent
602b7d8864
commit
f7ab1bc01f
1 changed files with 26 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
package jsprit.core.algorithm;
|
package jsprit.core.algorithm;
|
||||||
|
|
||||||
|
import jsprit.core.algorithm.io.AlgorithmConfig;
|
||||||
|
import jsprit.core.algorithm.io.AlgorithmConfigXmlReader;
|
||||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||||
import jsprit.core.algorithm.state.StateManager;
|
import jsprit.core.algorithm.state.StateManager;
|
||||||
import jsprit.core.algorithm.state.UpdateActivityTimes;
|
import jsprit.core.algorithm.state.UpdateActivityTimes;
|
||||||
|
|
@ -17,7 +19,9 @@ import jsprit.core.problem.solution.SolutionCostCalculator;
|
||||||
*/
|
*/
|
||||||
public class VehicleRoutingAlgorithmBuilder {
|
public class VehicleRoutingAlgorithmBuilder {
|
||||||
|
|
||||||
private final String algorithmConfig;
|
private String algorithmConfigFile;
|
||||||
|
|
||||||
|
private AlgorithmConfig algorithmConfig;
|
||||||
|
|
||||||
private final VehicleRoutingProblem vrp;
|
private final VehicleRoutingProblem vrp;
|
||||||
|
|
||||||
|
|
@ -34,13 +38,26 @@ public class VehicleRoutingAlgorithmBuilder {
|
||||||
private int nuOfThreads=0;
|
private int nuOfThreads=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the builder.
|
* Constructs the builder with the problem and an algorithmConfigFile. Latter is to configure and specify the ruin-and-recreate meta-heuristic.
|
||||||
*
|
*
|
||||||
* @param problem
|
* @param problem
|
||||||
* @param algorithmConfig
|
* @param algorithmConfig
|
||||||
*/
|
*/
|
||||||
public VehicleRoutingAlgorithmBuilder(VehicleRoutingProblem problem, String algorithmConfig) {
|
public VehicleRoutingAlgorithmBuilder(VehicleRoutingProblem problem, String algorithmConfig) {
|
||||||
this.vrp=problem;
|
this.vrp=problem;
|
||||||
|
this.algorithmConfigFile=algorithmConfig;
|
||||||
|
this.algorithmConfig=null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs the builder with the problem and an algorithmConfig. Latter is to configure and specify the ruin-and-recreate meta-heuristic.
|
||||||
|
*
|
||||||
|
* @param problem
|
||||||
|
* @param algorithmConfig
|
||||||
|
*/
|
||||||
|
public VehicleRoutingAlgorithmBuilder(VehicleRoutingProblem problem, AlgorithmConfig algorithmConfig) {
|
||||||
|
this.vrp=problem;
|
||||||
|
this.algorithmConfigFile=null;
|
||||||
this.algorithmConfig=algorithmConfig;
|
this.algorithmConfig=algorithmConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,6 +134,8 @@ public class VehicleRoutingAlgorithmBuilder {
|
||||||
/**
|
/**
|
||||||
* Builds and returns the algorithm.
|
* Builds and returns the algorithm.
|
||||||
*
|
*
|
||||||
|
* <p>If algorithmConfigFile is set, it reads the configuration.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public VehicleRoutingAlgorithm build() {
|
public VehicleRoutingAlgorithm build() {
|
||||||
|
|
@ -133,6 +152,11 @@ public class VehicleRoutingAlgorithmBuilder {
|
||||||
stateManager.updateLoadStates();
|
stateManager.updateLoadStates();
|
||||||
stateManager.updateTimeWindowStates();
|
stateManager.updateTimeWindowStates();
|
||||||
}
|
}
|
||||||
|
if(algorithmConfig==null){
|
||||||
|
algorithmConfig = new AlgorithmConfig();
|
||||||
|
AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig);
|
||||||
|
xmlReader.read(algorithmConfigFile);
|
||||||
|
}
|
||||||
return VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, algorithmConfig, nuOfThreads, solutionCostCalculator, stateManager, constraintManager, addDefaultCostCalculators);
|
return VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, algorithmConfig, nuOfThreads, solutionCostCalculator, stateManager, constraintManager, addDefaultCostCalculators);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue