Java - MODEL_INVALID when I try to use addMultiplicationEquality with linear expressions

27 views
Skip to first unread message

Neil Aggarwal

unread,
Aug 13, 2025, 12:18:44 PMAug 13
to or-tools...@googlegroups.com
Hello all:

According to the docs, CpModel has this method:
addMultiplicationEquality(LinearArgument target,
LinearArgument left,
LinearArgument right)

So, I am supposed to be able to use IntVar and LiteralExpr in
the arguments.

But when I do, I am getting a MODEL_INVALID result.

I am attaching a sample class.

Any idea what is going wrong?

Thank you,
Neil

--
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
We offer 30 year loans on single family houses!
MultiplicationTest.java

Laurent Perron

unread,
Aug 13, 2025, 2:01:54 PMAug 13
to or-tools...@googlegroups.com
The java doc is lacking w.r.t. C++ and Python.

All linear expressions must be of the form a * var + b (1-var affine expression).

Furthermore, if you enable logging, you should see an explanatory error message.
Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/or-tools-discuss/c6bc1089cb80d5d2832c8782e20d9faa%40mail.gmail.com.

Neil Aggarwal

unread,
Aug 13, 2025, 3:35:55 PMAug 13
to or-tools...@googlegroups.com

> All linear expressions must be of the form a * var + b (1-var affine expression).

 

Ahhh, got it.  I updated my code to use IntVars for the terms and it works

now.  I am attaching the code in case someone else runs into this problem.

MultiplicationTest.java
Reply all
Reply to author
Forward
0 new messages