VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(builder).read("src/test/resources/pdp.xml");
VehicleRoutingProblem vrp = builder.build();
final StateManager stateManager = new StateManager(vrp);
stateManager.updateLoadStates();
// stateManager.updateTimeWindowStates();
stateManager.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager));
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
// constraintManager.addTimeWindowConstraint();
constraintManager.addLoadConstraint();
VehicleFleetManager fleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
BestInsertionBuilder bestIBuilder = new BestInsertionBuilder(vrp, fleetManager, stateManager,constraintManager);
InsertionStrategy bestInsertion = bestIBuilder.build();
RuinStrategy radial = new RadialRuinStrategyFactory( 0.3, new AvgServiceAndShipmentDistance(vrp.getTransportCosts())).createStrategy(vrp);
RuinStrategy random = new RandomRuinStrategyFactory(0.5).createStrategy(vrp);
SolutionCostCalculator solutionCostCalculator = new SolutionCostCalculator() {
@Override
public double getCosts(VehicleRoutingProblemSolution solution) {
double costs = 0.0;
for(VehicleRoute route : solution.getRoutes()){
costs += stateManager.getRouteState(route, InternalStates.COSTS, Double.class);
}
return costs;
}
};