How to declare Optimization function?

49 views Asked by At

I am working on the Vehicle Routing Problem. My question is, we have to Minimise the total Distance covered by the Vehicle. Where in the code we specify we have to Minimise the distance covered? In drl file we give all the Constraint for consideration. What if I want to get Maxmium distance covered by Vehicle. Could anyone help me in understanding where to specify Max/Min for the given problem? Or guide me to any tutorial/document to get an answer to this question?

Thanks

1

There are 1 answers

0
Geoffrey De Smet On

To maximize the distance covered by the vehicles in total, simply replace penalize with reward for that constraint. That will trigger a positive score instead of a negative score impact for each distance unit (km or time). It will replace the stick with the carrot for OptaPlanner.

Do note that won't load balance the distance per vehicle. A solution with two vehicles of distance 100 each (totaling 200) will be cast aside for a solution with one vehicle distance 300 and one vehicle distance 10 (totaling 310). Load balancing is possible too, see the docs section on "fairness".