Minimize routing costs in Python

71 views
Skip to first unread message

Borja Menéndez Moreno

unread,
Jun 23, 2021, 9:39:35 AM6/23/21
to or-tools-discuss
Hi folks,

I'm addressing a CVRPTW problem in which I need to minimize the costs associated to the routes generated as following:
  • For routes <= 50km, 50€/route.
  • For routes between 50 and 150 km, 60€/route.
  • For routes > 150 km, 0.40€/km per route.
I think the best way to achieve this is through piecewise linear functions, but this is not available in Python. So first question here: is there any plan to implement that in Python? If not:
  1. Is it possible to consider as the objective function the minimization of this cost in C++ through piecewise linear functions? If so, do you have any example for that?
  2. I've seen several discussions around this like [1, 2] and I could do something similar: create several vehicles with a fixed cost of 50 and others at a fixed cost of 60 through the routing model, and then set the span upper bound for the vehicles of cost 50, and set a cumulvar soft upper bound for the rest through the routing dimension that only considers the distance. But some questions arise here: what is the meaning of cost here? Is the cost of the routing dimension added to the fixed cost of each vehicle? I mean, is it a cost added to the arc cost evaluator or could it be handled as a different (and the ideal) cost to minimize?
  3. Would it be possible to achieve more or less similar results through the combination of convex piecewise expressions and semi continuous expressions? If so, is there any example of using this?
  4. In order to not rewrite the solution, would it be possible to export the model to something that can be interpreted through the C++ library so I can easily add the piecewise linear function to the already built model?
Thank you very much in advance,

Borja.

Reply all
Reply to author
Forward
0 new messages