1 new SolutionCostCalculator() {
2
3 @Override
4 public double getCosts(VehicleRoutingProblemSolution solution) {
5 double c = 0.0;
6 for(VehicleRoute r : solution.getRoutes()){
7 c += stateManager.getRouteState(r, InternalStates.COSTS, Double.class);
8 c += r.getVehicle().getType().getVehicleCostParams().fix;
9 }
10 c += solution.getUnassignedJobs().size() * c * .1;
11 return c;
12 }
13
14 });
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(vrp,"input/algorithm.xml");
vraBuilder.addDefaultCostCalculators();
vraBuilder.addCoreConstraints();
final StateManager stateManager = new StateManager(vrp);
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
vraBuilder.setStateAndConstraintManager(stateManager,constraintManager);
vraBuilder.setObjectiveFunction(new SolutionCostCalculator() {
@Override
public double getCosts(VehicleRoutingProblemSolution solution) {
double c = 0.0;
for(VehicleRoute r : solution.getRoutes()){
c += stateManager.getRouteState(r, InternalStates.COSTS, Double.class);
c += r.getVehicle().getType().getVehicleCostParams().fix;
}
c += solution.getUnassignedJobs().size() * c * .2;
return c;
}
});
VehicleRoutingAlgorithm vra = vraBuilder.build();
@service class: Each service has a unique id which you can use to add an arbitrary number of additional information. You can just define a profit map for your services and retrieve the profits from it if you need it. You do not even need the id, you can just put the service into your map like this: Map<Service,Double> profitMap ...
--
You received this message because you are subscribed to the Google Groups "jsprit-mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsprit-mailing-...@googlegroups.com.
To post to this group, send email to jsprit-ma...@googlegroups.com.
Visit this group at http://groups.google.com/group/jsprit-mailing-list.
For more options, visit https://groups.google.com/d/optout.
I think Yang's issue might have a similar underlying cause to the one I described here where I attempt to implement soft time windows:
https://groups.google.com/forum/#!topic/jsprit-mailing-list/osxd6LM8KPU
On Wed Nov 19 2014 at 2:39:33 PM Yang Yang <teddy...@gmail.com> wrote:
thanks Stefan ! could u please address my next question too? (regarding the CostMatrix example)--
On Wednesday, November 19, 2014 2:35:08 PM UTC-8, Stefan Schröder wrote:Look at this to set your own objFunction:
https://github.com/jsprit/playground/blob/master/src/stackoverflow/Stackoverflow_RelatedJobs_13_and_21_inSameRoute.java@service class: Each service has a unique id which you can use to add an arbitrary number of additional information. You can just define a profit map for your services and retrieve the profits from it if you need it. You do not even need the id, you can just put the service into your map like this: Map<Service,Double> profitMap ...
You received this message because you are subscribed to the Google Groups "jsprit-mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsprit-mailing-list+unsub...@googlegroups.com.