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 working on a scheduling problem using CP. The behavior that I want is the following:
if at least one of a set of optional interval variables is present, then an integer variable is equal to 1.
If the 'set' was small I would explicitly write the constraint using the overloaded OR operator '|'. But the set is huge. I tried doing a loop:
for var in set:
expr += presenceOf(x) |
but this outputs an error. I also tried nested logical or to no avail. Is there a way to create the the logical statement
presenceOf(x1) | presenceOf(x2) | ... | presenceOf(x_n)
where 'n' is large?
The text was updated successfully, but these errors were encountered:
Hello,
Would it be possible to share a code snippet to reproduce that issue ? What kind of error do you get ?
What is the value of a large n in your case ?
Otherwise, could you try something like: mdl.add(mdl.any([mdl.presence_of(itv) for itv in set]) == IntegerVar)
sets = [masonry, facade, painting, roofing, plumbing, carpentry, ceiling] expr = 0 for itv_var in sets: expr += presenceOf(x) |
This generates a syntax error because of the type (stupid but just wanted to try it). The next snippet is trying the nested logical_or:
sets = [facade, painting, roofing, plumbing, carpentry, ceiling] expr = logical_or(masonry,None) for itv_var in sets: expr = logical_or(itv_var, expr)
And this generates a CPO expression can not be used as boolean. I actually found a solution after trial and error and I verified it via the exported model file. I tried
sets = [facade, painting, roofing, plumbing, carpentry, ceiling] mdl0.add(logical_or([presence_of(itv_var) for itv_var in sets]) == (IntegerVar==1))
Hello,
I am working on a scheduling problem using CP. The behavior that I want is the following:
if at least one of a set of optional interval variables is present, then an integer variable is equal to 1.
If the 'set' was small I would explicitly write the constraint using the overloaded OR operator '|'. But the set is huge. I tried doing a loop:
for var in set:
expr += presenceOf(x) |
but this outputs an error. I also tried nested logical or to no avail. Is there a way to create the the logical statement
presenceOf(x1) | presenceOf(x2) | ... | presenceOf(x_n)
where 'n' is large?
The text was updated successfully, but these errors were encountered: