MTZ-style decomposition of Circuit#354
Conversation
|
MTZ is a weakened form of the existing decomposition (happy to show the derivation) that assumes the circuit is at top level. In other words, the decomposition is not a "top level definition" + local constraints. There is a way to use these, but right now it will be incorrect under negation. |
|
(nonetheless, kudos for being on the lookout out for the most efficient decomposition!) |
|
I think it's weird to decompose in other places than decompose_globals, I know we discussed this a bit elsewhere as well but if a global has multiple decompositions the right place for those decompositions are in the global itself (so a decompose_linear which defaults to the normal decomposition making it backwards compatibel) |
|
So I did some testing, and this decomposition is indeed about 3x faster for gurobi, but only works in the non reified case. |
|
Made some tests with room assignment problems that have many alldifferents. What you say seems true in small problems with just a few alldifferent constraints, but when I created a larger problem (with 88 alldifferent constraints). I have the following results: With linear decomposition of alldifferent constraints:
With the normal decomposition of alldifferent constraints:
Thus, the linear decomposition is much more efficient in solving (which is the important part) and even faster in the transformations. |
|
This should be reconsidered as part of, or after #836 |
|
Merged current master into this PR, and update the decomposition with the new style (e.g, avoid making aux vars). Also a noticeable speedup compared to the standard decomposition -- examples/tsp.py runs in 0.3s instead of 5s on master. There is a bizarre bug in Exact/the Exact interface which causes the CI to fail |
|
the regular decompose does an _no_partial_functions on order, while the linear decompose does not. An omission? or is the regular one too strict? |
|
In the linear one, we only index with constants, so no need to safen here : ) |
tias
left a comment
There was a problem hiding this comment.
I see, its good to explain and be explicit on such things...
e.g. that we need no partial becuase we are indexing with an expression that could be out of bounds (updated doc)
also, explaining the new decomposition, e.g. that one forbids self-loops and the other enforces an increasing counter/topological order by which loops are not allowed because they would point to a lower order-nr (udpated doc)
assuming you agree with the doc comments added, do merge
|
Hmm enabling the "not_circuit" test for all solvers reveals some problems... Will investigate and request for a re-review when fixed |
…n_circuit' into linear_decomposition_circuit
|
forgot to commit the second doc update, on the order part. |
… into linear_decomposition_circuit
|
So as it turns out, the modifications I made to the MTZ encoding don't work for negative contexts after all... E.g.., So in summary, the decomposition works but in limited cases:
How should we proceed? We could use this PR to introduce the "decompose_positive" function for globals after all? Then the future MDD-decomp can build on this one. |
|
Converting this PR to draft again, as we first need a way for determining which decomposition to call at toplevel/positive/nested contexts. |
|
re-implemented as part of #1006 |
Ok, so I could not help myself and implement a custom decomposition for the
Circuitconstraint inlinearize_constraint.Its inspired by TSP models for MIP: https://how-to.aimms.com/Articles/332/332-Miller-Tucker-Zemlin-formulation.html
This allows us to run all of the examples with gurobi within 20s, so I think its a nice quality of life improvement for us :).