VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(builder).read("src/test/resources/pd_solomon_r101.xml");
vrp = builder.build();
final StateManager stateManager = new StateManager(vrp);
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
constraintManager.addTimeWindowConstraint();
constraintManager.addLoadConstraint();
VehicleFleetManager fleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
BestInsertionBuilder iBuilder = new BestInsertionBuilder(vrp, fleetManager, stateManager, constraintManager);
// iBuilder.setConstraintManager(constraintManger);
InsertionStrategy bestInsertion = iBuilder.build();
RuinStrategy radial = new RadialRuinStrategyFactory( 0.15, new AvgServiceDistance(vrp.getTransportCosts())).createStrategy(vrp);
RuinStrategy random = new RandomRuinStrategyFactory(0.25).createStrategy(vrp);
SolutionCostCalculator solutionCostCalculator = new SolutionCostCalculator() {
@Override
public double getCosts(VehicleRoutingProblemSolution solution) {
double costs = 0.0;
for(VehicleRoute route : solution.getRoutes()){
Double cost_of_route = stateManager.getRouteState(route, InternalStates.COSTS, Double.class);
if(cost_of_route == null) cost_of_route = 0.;
costs += cost_of_route;
}
return costs;
}