Help understanding relational expressions in Choco 4

29 views
Skip to first unread message

uh oh

unread,
Feb 25, 2021, 5:03:07 PM2/25/21
to choco-solver

Hi,

I have a constraint from an older version of choco I am trying to convert:

LCF.ifThenElse(
   ICF.arithm(xIn[j][i],"=",0),
   LCF.and(
      ICF.arithm(xOut[j][i],"=",0),
      ICF.arithm(p[j][i],"=",0)
    ),
    ICF.table(new IntVar[]{xIn[j][i], xOut[j][i],p[j][i]}, tupleSB, strategy)
);


Essentially, if xIn = 0, then xOut = 0 and p = 0, else Apply table constraint to (xIn, xOut, p)

I'm a little confused if need to create a relational expression with xOut and p to assign their values, or use model.ifThenElse(...)

Thanks, and would be happy for any help

cpru...@gmail.com

unread,
Apr 20, 2021, 11:09:45 AM4/20/21
to choco-solver
Hi,
I would do that:
model.ifThenElse(
           model.arithm(xIn[j][i],"=",0),
           model.and(
              model.arithm(xOut[j][i],"=",0),
              model.arithm(p[j][i],"=",0)
            ),
            model.table(new IntVar[]{xIn[j][i], xOut[j][i],p[j][i]}, tupleSB, strategy)
        );
But you should define the first condition and implication as an additional tuple in the table.


Hope that helsp,
CP
Reply all
Reply to author
Forward
0 new messages