0

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.

Antti29
  • 2,953
  • 12
  • 34
  • 36

1 Answers1

0

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.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120