From 1ae8b9891b172d09ecf0ba89cf243cb85b2c3495 Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Tue, 31 May 2022 16:25:10 +0200 Subject: [PATCH] [CP-SAT] fix scheduling bug --- ortools/sat/cumulative.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ortools/sat/cumulative.cc b/ortools/sat/cumulative.cc index 4326c2919b..b3ce923da0 100644 --- a/ortools/sat/cumulative.cc +++ b/ortools/sat/cumulative.cc @@ -168,6 +168,15 @@ std::function Cumulative( // precedence graph, not just task in direct precedence. Make sure not to // create to many such constraints though. if (parameters.use_hard_precedences_in_cumulative_constraint()) { + // The CumulativeIsAfterSubsetConstraint() always reset the helper to the + // forward time direction, so it is important to also precompute the + // precedence relation using the same direction! This is needed in case + // the helper has already been used and set in the other direction. + if (!helper->SynchronizeAndSetTimeDirection(true)) { + model->GetOrCreate()->NotifyThatModelIsUnsat(); + return; + } + std::vector index_to_end_vars; std::vector index_to_task; std::vector before;