Visit stops in 1st time window 1st then then orders in 2nd time window #4107
-
Hi I am writing the algorithm in C#. I am having an issue with the routing solver regarding the order of the stops a vehicle must visit, I have stops split into two different time windows. the orders that should be visited 1st are in a time window [0,59] and the second set of orders overlap the first set in time window [39,105]. I need to know how I can achieve that the orders in time window [0,59] are tried to be visited first. long penalty = 1000;
for (int i = 1; i < num_nodes; ++i)
{
if (stoplist[i].StopOrder == 1)
{
penalty = 1;
}
else if (stoplist[i].StopOrder == 2)
{
penalty = 0;
}
routing.AddDisjunction(new long[] { manager.NodeToIndex(i) }, penalty);
} Setting the max cardinality where the stop order equals 1 gets visited but the others are dropped in the time window [39,105]. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Enforcing it as hard-constraint is probably the easier one:
Enforcing it through an objective / soft is imho not that easy in the routing-solver as objective-structures are kind of fixed (opposed to the CP-solver mechanism in the hard-constraint parts) with good reasons: internal invariants. There might be some "hacky" way of introducing VERY COSTLY transition-costs between those antichains reversed (arc from order in group SECOND -> order in group FIRST = EXPENSIVE!; then one would also add DEPOT -> SECOND = EXPENSIVE). Those are some quick ideas. The former approach is linked to many official examples. Search for the term "precedence" in the repo. |
Beta Was this translation helpful? Give feedback.
Enforcing it as hard-constraint is probably the easier one:
Enforcing it through an objective / soft is imho not that easy in the routing-solver as objective-structures are kind of fixed (opposed to the CP-solver mechanism in the hard-constraint parts) with good reasons: internal invariants.
There might be some "hacky" way of introducing VERY COSTLY transition-costs between those antichains reversed (arc from order in group SECOND -> order in group FIRST = EXPENSIVE!; then one would also add DEPOT -> SECOND = EX…