From 8f34060ebcdb2f991fd20326a9132995d7be0a81 Mon Sep 17 00:00:00 2001 From: wout4 Date: Fri, 13 Oct 2023 13:00:29 +0200 Subject: [PATCH] make circuit decomposition work with all ranges and adapt tests --- cpmpy/expressions/globalconstraints.py | 14 +++++++++++--- tests/test_globalconstraints.py | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cpmpy/expressions/globalconstraints.py b/cpmpy/expressions/globalconstraints.py index ef30f82ca..cf89863ba 100644 --- a/cpmpy/expressions/globalconstraints.py +++ b/cpmpy/expressions/globalconstraints.py @@ -272,15 +272,23 @@ def decompose(self): https://github.com/MiniZinc/libminizinc/blob/master/share/minizinc/std/fzn_circuit.mzn """ succ = cpm_array(self.args) + n = len(succ) - order = intvar(0,n-1, shape=n) + order = intvar(0,n-1, shape=n,name='order') constraining = [] constraining += [AllDifferent(succ)] # different successors constraining += [AllDifferent(order)] # different orders constraining += [order[n-1] == 0] # symmetry breaking, last one is '0' + a = boolvar(name = 'a') - defining = [order[0] == succ[0]] - defining += [order[i] == succ[order[i-1]] for i in range(1,n)] # first one is successor of '0', ith one is successor of i-1 + #defining = [a == ((min(succ) >= 0) & (max(succ)= 0) & (Maximum(succ)