Can VRPTW models take a negative cost matrix? #4177
Replies: 2 comments 1 reply
-
Again: Take it with a grain of salt (no or-tools dev) While the more general question incorporating all cases sounds like trouble, in your case, it seems, using 1 or M doesn't influence correctness assuming " i -> i which are anyway disallowed in VRP solutions". Without that assumption, one has to look into it in more detail. Correctness given, now looking at performance, i would highly expect the M variant at least as good (or better) as the 1 variant. In general, as much as possible is done BEFORE asking the cp-solver (in the routing-solver) and while forbidden self-loops are a-priori fixed domains (no runtime-propagation needed), it's potentially less efficient to check than non-improving costs. If you are interested in analyzing it, use This gives you something like:
Now i claim:
That being said. I did some presolve-experiments in the past converting forbidden-arcs (again VariableDomainFilter)` into bigMs and there was no improvement. So maybe this kind of optimization is too much, as long as correctness is given. Greetings, Sascha |
Beta Was this translation helpful? Give feedback.
-
One other thing to be aware of, the value at each node of each dimension must be zero or positive. If it is negative due to a negative link cost, it will get truncated *silently* to zero. At least, that was my experience a few years back.
As I recall I was doing something like modeling the need for a break as something that decreased as a vehicle moved, so I had negative links for that "dimension" but nothing worked right because nothing went negative. I had to bump everything up by some hard floor, so that if it went below the positive floor, it was time for a break.
But the negative link costs technically worked in my use case for a VRP.
James
…On Thu, Apr 11, 2024 at 08:07:05AM -0700, onecable5781 wrote:
Thank you.
Actually, regarding correctness, the idea of adding a constant to all entries will only work for a TSP with a single vehicle. With a VRP, it may not work.
I will have to rethink my strategy. It does appears that it may not be easy to incorporate negative costs in VRPTW of ortools.
Thank you for your detailed input -- it gives me a lot to delve into.
--
Reply to this email directly or view it on GitHub:
#4177 (reply in thread)
You are receiving this because you are subscribed to this thread.
Message ID: ***@***.***>
--
James E. Marca
Activimetrics LLC
|
Beta Was this translation helpful? Give feedback.
-
Hello,
I have an application where the cost matrix of a VRPTW can be negative while the transit times are nonnegative. The objective is to minimize the total cost of all routes subject to satisfying all other regular VRPTW constraints - each customer is visited exactly once within the time windows without letting the negative costs lead to otherwise infeasible routes.
A similar recent discussion #4019 seems to suggest to bump up all costs by a constant addition so that the minimum after bumping is 0
So, if my original cost matrix for a 2 customer problem is
my current understanding is that I should be modifying it to:
wherein I have added a +1 to each entry.
My question is about the diagonal 0s of the original cost matrix. Since the diagonal elements are self loops of type i -> i which are anyway disallowed in VRP solutions, should my original cost matrix be considered to be:
where M is some large positive number in which case, the modified cost matrix which I submit to OR Tools will be different? Or, is the underlying OR Tools solver clever enough to never worry about self loops of type i -> i and hence it does not matter what M is in the original cost matrix in which case, it might as well be 0.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions