-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIFO / LIFO in Pick and Drop #922
Comments
Any response, good or bad ... |
|
And v7.0 is expected by end December? Could you direct to any document or correspondence on how to add wrappers to Routing.h using SWIG? |
something like this works for me: # Add a dimension for setting FIFO constraints
def fifo_fn(a, b):
"""
Just increment by one
"""
return 1
routing.AddDimension(
fifo_fn, # total time function callback
0, # allowed time slack
int(total_nodes),
True,
'FIFO')
fifo_dimension = routing.GetDimensionOrDie('FIFO') then later early_condition = fifo_dimension.CumulVar(picku_a_index) <= fifo_dimension.CumulVar(picku_b_index)
fifo_constraint = fifo_dimension.CumulVar(deliv_a_index) <= fifo_dimension.CumulVar(deliv_b_index)
expression = solver.ConditionalExpression(
early_condition,
fifo_constraint,
1)
solver.AddConstraint(
expression >= 1
) If you just use time_dimension, you get issues because it has slack...the "FIFO" dimension above has zero slack and so can guarantee ever increasing values for each route. If you have multiple vehicles, you have to add a "same vehicle" constraint as well to the conditional constraint. |
Thx. |
On Tue, Dec 04, 2018 at 10:03:57PM -0800, Guy wrote:
Thx.
How do we get picku/deliv_a/b_index ? these are not known in advance.
Of course they are known in advance. Those are your pickups and
deliveries. Just do two nested for loops
|
Node indices are known however, the visit order is not known in advance. |
No, it's means if the condition is verified i.e. "pickup a before pickup b" THEN "deliver a must be before deliver b". Using a conditional expression mean the constraint will only be active only if the condition is respected. It also means you have to write it in both direction hence the "two nested for loops" comment from @jmarca note: Open question, I don't know if the condition should also check that node are active see #847 (comment) |
Cool |
If we are using explicit Node indexes, is it I correct that we would need such a conditions-set per each possible combination of tasks (task = pick+drop)? |
Not sure we can make it generic AFAIK. note: That's why I would push forward to have support of
|
FIFO and LIFO? Would the above changes be accessible in all languages? |
Does 7.0 actually auto-implement these NxN constraints, or uses a better way to manage State? |
Two points. First, to @Mizux point about considering active nodes, I've run this in lots of tests and have never had an issue, and nodes are dropped all the time in my tests. Second it's not necessarily NxN constraints (where N is the number of pickups). You only have to set the conditional constraints on those pairs for which the B node falls inside of the A node service time. That is, if it is impossible to have A in the truck when picking up B, then there is no need to impose the conditional constraint at all. The only case in which there are NxN constraints is if the time windows for all pickups extend for the entire simulation. Note that I skipped those sorts of details in my original post because they seemed like an implementation detail. Yes it is O(N^2) constraints in the limit, but it depends on what you are solving. And hopefully the underlying constraint solver can handle lots of constraints! |
Thx, I expressed a complex case where the only constraint on visit order is FIFO/LIFO. |
I understood the other issue to imply that there may be problems with the constraints if a node is not active. I don't think that is a concern here for the conditional constraints I'm proposing due to my observed evidence—my solver runs often cannot assign all nodes in the solution. So some nodes are not active, and yet I see no issues that indicate we'd also have to add a check to see if a node is active. So in context, a good thing.On Dec 5, 2018 23:38, Guy <notifications@github.com> wrote:Thx,
Is: "nodes are dropped all the time in my tests." good or bad in this context?
I expressed a complex case where the only constraint on visit order is FIFO/LIFO.
Indeed, other constraints may allow to duilute the NxN conditions.
(Actually, N/2 x N/2 as each task involves two Nodes).
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.
|
Should be fixed on master ! |
Impressive! |
Can you suggest a scheme to apply LIFO or FIFO constraint across the entire fleet?
Seems complex, since we do not know in advance which Pick & Drop Nodes are served by each vehicle, and at what times ....
The text was updated successfully, but these errors were encountered: