That is a difficult one, and hopefully someone else will share how
they've solved it.
For me, my approach is to accept that the solution won't be optimal,
and then to implement a hack that gets me close enough. For the one
real-world problem for which I needed to address this sort of problem,
the pickup and delivery points were scattered fairly uniformly, so it
was good enough to keep the number of passengers served roughly equal
(limit the total number of pickup nodes visited). The other leavening
factor in my application was that the client was okay with having some
vehicles with excess capacity, as they could be used to handle new
requests and broken schedules due to passenger no-shows.
I'm also using python.
I think if I needed to *really* tackle this sort of problem, trying to
make all vehicles have roughly the same distance or time spent
traveling, I would stop being lazy and learn C++ again, so that you
can use the method "add dimension with dependent dimension". With
that kind of a dimension, it might be possible to increase the cost of
adding more distance to a vehicle exponentially (guessing---maybe a
power law would work?), such that the solver would find a cheaper
solution by spreading the distance traveled around. In other words,
make the cost of adding additional distance to a vehicle *worse* that
assigning a slightly longer total trip length to two or more vehicles.
Without turning to C++, it might be possible to do a two-stage
solution? Run one solver process, get an "optimal" result and a
total distance value for the solution, compute the ideal ave distance
per vehicle using this value, then re-run the solver but this
time with a constraint that vehicles can't exceed the ideal distance
per vehicle, plus say 2% to allow for the fact that the new solution
will likely be a little bit longer.
Actually, looking at V7.0, it *might* be the case that this function
is now exposed to Python? I don't see any IF DEF guards around
https://github.com/google/or-tools/blob/v7.0/ortools/constraint_solver/routing.h#L459
That would be super cool if true.
Ah, hopes dashed:
https://github.com/google/or-tools/blob/v7.0/ortools/constraint_solver/python/routing.i#L71
I think. Although maybe not, as the %include routing.h comes after
the above line. (Obv. I need to relearn C++...)
Maybe someone else will chime in with an actual solution?
Regards,
James
--
James E. Marca