You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing a flattening performance issue with a model for vehicle routing.
cvrp.tar.gz contains everything to reproduce the issue. There is a model and three instances of different sizes. The model is split into three parts: cvrp_cp, cvrp and vrp. These parts can be considered as a class hierarchy with cvrp_cp a subclass of cvrp and cvrp a subclass of vrp with superclasses declaring predicates and constants to be defined by subclasses. In particular, vrp declares and uses the predicate delivery implemented by cvrp_cp.
Reproduction steps:
tar xzf cvrp.tar.gz
cd cvrp
time minizinc -c cvrp_cp.mzn X-n469-k138.dzn
On my old i5 laptop, the runtime for this instance is about 40 seconds.
I managed to trace down the issue to the argument TravelTimes (a matrix) to delivery. When I remove this argument (and let delivery take TravelTimes from its environment), the runtime drops by an order of magnitude:
delivery with TravelTimes
delivery without TravelTimes
X-n101-k25
0.5s
0.3s
X-n469-k138
40s
5s
X-n1001-k43
103s
9s
You'll find the relevant code at the end of vrp.mzn; look out for the comments SLOW and FAST.
(Btw, the two variants of the model yield identical FlatZinc output.)
The text was updated successfully, but these errors were encountered:
Just to elaborate on the problem. The problem here is that when using an exponential computational comprehension (TravelTime) as an argument to a custom predicate (delivery), there is seems to be a big overhead in the flattening time compared to when this comprehension is only stored globally in the environment.
It sounds as if the comprehension is evaluated multiple times when passed in as an argument.
I am experiencing a flattening performance issue with a model for vehicle routing.
cvrp.tar.gz contains everything to reproduce the issue. There is a model and three instances of different sizes. The model is split into three parts:
cvrp_cp
,cvrp
andvrp
. These parts can be considered as a class hierarchy withcvrp_cp
a subclass ofcvrp
andcvrp
a subclass ofvrp
with superclasses declaring predicates and constants to be defined by subclasses. In particular,vrp
declares and uses the predicatedelivery
implemented bycvrp_cp
.Reproduction steps:
On my old i5 laptop, the runtime for this instance is about 40 seconds.
I managed to trace down the issue to the argument
TravelTimes
(a matrix) todelivery
. When I remove this argument (and letdelivery
takeTravelTimes
from its environment), the runtime drops by an order of magnitude:delivery
withTravelTimes
delivery
withoutTravelTimes
You'll find the relevant code at the end of
vrp.mzn
; look out for the commentsSLOW
andFAST
.(Btw, the two variants of the model yield identical FlatZinc output.)
The text was updated successfully, but these errors were encountered: