0
votes

Currently using OptaPlanner for calculating score in a CVRP problem.

if (demand > capacity) 
    hardScore -= (demand - capacity);

If there is a heterogeneous fleet, how can I calculate a hard score?

I want to use a vehicle with small capacity if number of demand is less than the vehicle assigned by OptaPlanner.

1

1 Answers

0
votes

Don't mix 2 constraints. These are 2 different constraints:

  • Each vehicle must have enough capacity (usually a hard constraint) - already implemented in the OptaPlanner example.
  • Prefer using smaller vehicles over bigger ones (usually a soft constraint). Normally there's a price per km per vehicle type, so this factors in the distance driven too in the soft score penalty.

Just implement the second constraint, starting from the OptaPlanner VRP example.