mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
add buildFastCVRP test
This commit is contained in:
parent
f7ff7aeeca
commit
75c54103ad
2 changed files with 21 additions and 10 deletions
|
|
@ -1,12 +1,13 @@
|
|||
package algorithms;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Solutions;
|
||||
|
||||
import algorithms.HardConstraints.HardActivityLevelConstraint;
|
||||
import algorithms.acceptors.AcceptNewIfBetterThanWorst;
|
||||
import algorithms.selectors.SelectBest;
|
||||
|
|
@ -45,12 +46,10 @@ public class BuildFastCVRPAlgoTest {
|
|||
VehicleFleetManager fleetManager = new InfiniteVehicles(vrp.getVehicles());
|
||||
JobInsertionCalculator finalServiceInsertion = new CalculatesVehTypeDepServiceInsertion(fleetManager, serviceInsertion);
|
||||
|
||||
// UpdateStates stateUpdater = new UpdateStates(stateManager, vrp.getTransportCosts(), vrp.getActivityCosts());
|
||||
|
||||
BestInsertion bestInsertion = new BestInsertion(finalServiceInsertion);
|
||||
|
||||
RuinRadial radial = new RuinRadial(vrp, 0.3, new JobDistanceAvgCosts(vrp.getTransportCosts()));
|
||||
RuinRandom random = new RuinRandom(vrp, 0.5);
|
||||
RuinRadial radial = new RuinRadial(vrp, 0.15, new JobDistanceAvgCosts(vrp.getTransportCosts()));
|
||||
RuinRandom random = new RuinRandom(vrp, 0.25);
|
||||
|
||||
SearchStrategy randomStrategy = new SearchStrategy(new SelectBest(), new AcceptNewIfBetterThanWorst(1));
|
||||
RuinAndRecreateModule randomModule = new RuinAndRecreateModule("randomRuin_bestInsertion", bestInsertion, random);
|
||||
|
|
@ -81,17 +80,20 @@ public class BuildFastCVRPAlgoTest {
|
|||
vra.getSearchStrategyManager().addSearchStrategyModuleListener(new UpdateLoadAtRouteLevel(stateManager));
|
||||
|
||||
VehicleRoutingProblemSolution iniSolution = new CreateInitialSolution(bestInsertion).createInitialSolution(vrp);
|
||||
System.out.println("ini: costs="+iniSolution.getCost()+";#routes="+iniSolution.getRoutes().size());
|
||||
// System.out.println("ini: costs="+iniSolution.getCost()+";#routes="+iniSolution.getRoutes().size());
|
||||
vra.addInitialSolution(iniSolution);
|
||||
|
||||
vra.setNuOfIterations(1000);
|
||||
vra.setPrematureBreak(200);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVRA(){
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
System.out.println("costs="+Solutions.getBest(solutions).getCost()+";#routes="+Solutions.getBest(solutions).getRoutes().size());
|
||||
// System.out.println("costs="+Solutions.getBest(solutions).getCost()+";#routes="+Solutions.getBest(solutions).getRoutes().size());
|
||||
assertEquals(530.0, Solutions.getBest(solutions).getCost(),15.0);
|
||||
assertEquals(5, Solutions.getBest(solutions).getRoutes().size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue