mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
fixes
This commit is contained in:
parent
aae0ec2328
commit
a83bed51c5
2 changed files with 16 additions and 3 deletions
|
|
@ -427,11 +427,11 @@ public class VehicleRoutingAlgorithms {
|
|||
return createAlgo(vrp, algorithmConfig.getXMLConfiguration(), nThreads, null, null);
|
||||
}
|
||||
|
||||
public static VehicleRoutingAlgorithm readAndCreateAlgorithm(VehicleRoutingProblem vrp, int nThreads, String configFileName, SolutionCostCalculator solutionCostCalculator) {
|
||||
public static VehicleRoutingAlgorithm readAndCreateAlgorithm(VehicleRoutingProblem vrp, int nThreads, String configFileName, StateManager stateMan, SolutionCostCalculator solutionCostCalculator) {
|
||||
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
|
||||
AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig);
|
||||
xmlReader.read(configFileName);
|
||||
return createAlgo(vrp, algorithmConfig.getXMLConfiguration(), nThreads, null, solutionCostCalculator);
|
||||
return createAlgo(vrp, algorithmConfig.getXMLConfiguration(), nThreads, stateMan, solutionCostCalculator);
|
||||
}
|
||||
|
||||
private static class OpenRouteStateVerifier implements StateUpdater, ReverseActivityVisitor {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.graphhopper.jsprit.core.algorithm.ruin.RuinStrategy;
|
|||
import com.graphhopper.jsprit.core.algorithm.ruin.listener.RuinListener;
|
||||
import com.graphhopper.jsprit.core.algorithm.selector.SelectBest;
|
||||
import com.graphhopper.jsprit.core.algorithm.selector.SolutionSelector;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||
import com.graphhopper.jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
|
|
@ -50,6 +51,9 @@ import java.util.Collection;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
|
||||
public class TestAlgorithmReader {
|
||||
|
|
@ -288,8 +292,17 @@ public class TestAlgorithmReader {
|
|||
@Test
|
||||
public void testWithVehicleRoutingAlgorithm() {
|
||||
SolutionCostCalculator solutionCostCalculator = Mockito.mock(SolutionCostCalculator.class);
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, 10, getClass().getResource("algorithmConfig_withoutIterations.xml").getFile(), solutionCostCalculator);
|
||||
StateManager stateMan = Mockito.mock(StateManager.class);
|
||||
doNothing().when(stateMan).updateLoadStates();
|
||||
doNothing().when(stateMan).updateTimeWindowStates();
|
||||
doNothing().when(stateMan).updateSkillStates();
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, 10, getClass().getResource("algorithmConfig_withoutIterations.xml").getFile(), stateMan, solutionCostCalculator);
|
||||
vra.getObjectiveFunction().equals(solutionCostCalculator);
|
||||
|
||||
verify(stateMan, times(2)).updateLoadStates();
|
||||
verify(stateMan, times(2)).updateTimeWindowStates();
|
||||
verify(stateMan, times(2)).updateSkillStates();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue