solver.Add(solver.Sum()<X) Or solver.Add(sum .. Or model.Add( sum .. ?

272 views
Skip to first unread message

CK CK

unread,
Oct 11, 2023, 1:56:11 PM10/11/23
to or-tools-discuss

Should we use solver.Add(solver.Sum( only CP?
model.Add( sum in MIP ?
When we use solver.Add(sum ?

Priidik Vilumaa

unread,
Oct 12, 2023, 2:05:00 AM10/12/23
to or-tools-discuss

Add the constraint as per the solver you are using requires. If you do it wrong you'll hear about it.

sum vs Sum: https://groups.google.com/g/or-tools-discuss/c/IaozQRNxcIE/m/lnPZLwQmAgAJ

Best,
Priidik

CK CK

unread,
Oct 12, 2023, 3:15:35 PM10/12/23
to or-tools-discuss
Thanks!
 if you know the size is small, use sum(). If the size is data dependent, use Sum().
The API is cp_model.LinearExpr.Sum() for CP-SAT

четверг, 12 октября 2023 г. в 09:05:00 UTC+3, vil...@gmail.com:
Reply all
Reply to author
Forward
0 new messages