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

activated skillConstraints

This commit is contained in:
oblonski 2014-07-03 10:04:05 +02:00
parent 34abc1b737
commit ddb00ce1ce
3 changed files with 19 additions and 15 deletions

View file

@ -112,7 +112,7 @@ public class VehicleRoutingAlgorithm {
/** /**
* Adds solution to the collection of initial solutions. * Adds solution to the collection of initial solutions.
* *
* @param solution * @param solution to the set of initialSolutions
*/ */
public void addInitialSolution(VehicleRoutingProblemSolution solution){ public void addInitialSolution(VehicleRoutingProblemSolution solution){
initialSolutions.add(solution); initialSolutions.add(solution);
@ -121,7 +121,7 @@ public class VehicleRoutingAlgorithm {
/** /**
* Sets premature termination. * Sets premature termination.
* *
* @param prematureAlgorithmTermination * @param prematureAlgorithmTermination that terminates the algorithm according to its termination criterion
*/ */
public void setPrematureAlgorithmTermination(PrematureAlgorithmTermination prematureAlgorithmTermination){ public void setPrematureAlgorithmTermination(PrematureAlgorithmTermination prematureAlgorithmTermination){
this.prematureAlgorithmTermination = prematureAlgorithmTermination; this.prematureAlgorithmTermination = prematureAlgorithmTermination;

View file

@ -58,8 +58,8 @@ public class VehicleRoutingAlgorithmBuilder {
/** /**
* Constructs the builder with the problem and an algorithmConfigFile. Latter is to configure and specify the ruin-and-recreate meta-heuristic. * 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 to solve
* @param algorithmConfig * @param algorithmConfig config file of VehicleRoutingAlgorithm
*/ */
public VehicleRoutingAlgorithmBuilder(VehicleRoutingProblem problem, String algorithmConfig) { public VehicleRoutingAlgorithmBuilder(VehicleRoutingProblem problem, String algorithmConfig) {
this.vrp=problem; this.vrp=problem;
@ -69,9 +69,9 @@ public class VehicleRoutingAlgorithmBuilder {
/** /**
* Constructs the builder with the problem and an algorithmConfig. Latter is to configure and specify the ruin-and-recreate meta-heuristic. * Constructs the builder with the problem and an algorithmConfig. Latter is to configure and specify the ruin-and-recreate meta-heuristic.
* *
* @param problem * @param problem to solve
* @param algorithmConfig * @param algorithmConfig config file of VehicleRoutingAlgorithm
*/ */
public VehicleRoutingAlgorithmBuilder(VehicleRoutingProblem problem, AlgorithmConfig algorithmConfig) { public VehicleRoutingAlgorithmBuilder(VehicleRoutingProblem problem, AlgorithmConfig algorithmConfig) {
this.vrp=problem; this.vrp=problem;
@ -85,7 +85,7 @@ public class VehicleRoutingAlgorithmBuilder {
* <p>If objective function is not set, a default function is applied (which basically minimizes * <p>If objective function is not set, a default function is applied (which basically minimizes
* fixed and variable transportation costs ({@link VariablePlusFixedSolutionCostCalculatorFactory}). * fixed and variable transportation costs ({@link VariablePlusFixedSolutionCostCalculatorFactory}).
* *
* @param objectiveFunction * @param objectiveFunction to be minimized
* @see VariablePlusFixedSolutionCostCalculatorFactory * @see VariablePlusFixedSolutionCostCalculatorFactory
*/ */
public void setObjectiveFunction(SolutionCostCalculator objectiveFunction) { public void setObjectiveFunction(SolutionCostCalculator objectiveFunction) {
@ -95,7 +95,7 @@ public class VehicleRoutingAlgorithmBuilder {
/** /**
* Sets stateManager to memorize states. * Sets stateManager to memorize states.
* *
* @param stateManager * @param stateManager that memorizes your states
* @see StateManager * @see StateManager
*/ */
public void setStateManager(StateManager stateManager) { public void setStateManager(StateManager stateManager) {
@ -105,7 +105,7 @@ public class VehicleRoutingAlgorithmBuilder {
/** /**
* Adds core constraints. * Adds core constraints.
* *
* <p>Thus, it adds vehicle-capacity and time-window constraints and their * <p>Thus, it adds vehicle-capacity, time-window and skills constraints and their
* required stateUpdater. * required stateUpdater.
* *
*/ */
@ -130,8 +130,8 @@ public class VehicleRoutingAlgorithmBuilder {
/** /**
* Sets state- and constraintManager. * Sets state- and constraintManager.
* *
* @param stateManager * @param stateManager that memorizes your states
* @param constraintManager * @param constraintManager that manages your constraints
* @see StateManager * @see StateManager
* @see ConstraintManager * @see ConstraintManager
*/ */
@ -143,7 +143,7 @@ public class VehicleRoutingAlgorithmBuilder {
/** /**
* Sets nuOfThreads. * Sets nuOfThreads.
* *
* @param nuOfThreads * @param nuOfThreads to be operated
*/ */
public void setNuOfThreads(int nuOfThreads){ public void setNuOfThreads(int nuOfThreads){
this.nuOfThreads=nuOfThreads; this.nuOfThreads=nuOfThreads;
@ -154,7 +154,7 @@ public class VehicleRoutingAlgorithmBuilder {
* *
* <p>If algorithmConfigFile is set, it reads the configuration. * <p>If algorithmConfigFile is set, it reads the configuration.
* *
* @return * @return the algorithm
*/ */
public VehicleRoutingAlgorithm build() { public VehicleRoutingAlgorithm build() {
if(stateManager == null) stateManager = new StateManager(vrp.getTransportCosts()); if(stateManager == null) stateManager = new StateManager(vrp.getTransportCosts());
@ -167,8 +167,10 @@ public class VehicleRoutingAlgorithmBuilder {
if(addCoreConstraints){ if(addCoreConstraints){
constraintManager.addLoadConstraint(); constraintManager.addLoadConstraint();
constraintManager.addTimeWindowConstraint(); constraintManager.addTimeWindowConstraint();
stateManager.updateLoadStates(); constraintManager.addSkillsConstraint();
stateManager.updateLoadStates();
stateManager.updateTimeWindowStates(); stateManager.updateTimeWindowStates();
stateManager.updateSkillStates();
} }
if(algorithmConfig==null){ if(algorithmConfig==null){
algorithmConfig = new AlgorithmConfig(); algorithmConfig = new AlgorithmConfig();

View file

@ -489,6 +489,7 @@ public class VehicleRoutingAlgorithms {
} }
stateManager.updateLoadStates(); stateManager.updateLoadStates();
stateManager.updateTimeWindowStates(); stateManager.updateTimeWindowStates();
stateManager.updateSkillStates();
stateManager.addStateUpdater(new UpdateEndLocationIfRouteIsOpen()); stateManager.addStateUpdater(new UpdateEndLocationIfRouteIsOpen());
stateManager.addStateUpdater(new OpenRouteStateVerifier()); stateManager.addStateUpdater(new OpenRouteStateVerifier());
stateManager.addStateUpdater(new UpdateActivityTimes(vrp.getTransportCosts())); stateManager.addStateUpdater(new UpdateActivityTimes(vrp.getTransportCosts()));
@ -501,6 +502,7 @@ public class VehicleRoutingAlgorithms {
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager,vrp.getConstraints()); ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager,vrp.getConstraints());
constraintManager.addTimeWindowConstraint(); constraintManager.addTimeWindowConstraint();
constraintManager.addLoadConstraint(); constraintManager.addLoadConstraint();
constraintManager.addSkillsConstraint();
return readAndCreateAlgorithm(vrp, config, nuOfThreads, null, stateManager, constraintManager, true); return readAndCreateAlgorithm(vrp, config, nuOfThreads, null, stateManager, constraintManager, true);
} }