简体   繁体   中英

How to implement SUM operation in Google OR-Tools for C#

I would like to know how can I implement a SUM operation in C# using OR-Tools. In my problem, I have the following constraint:

Constraint

NOTE: My problem is a Linear Programming Problem.

You can use arithmetic operators:

model.Add(4 * r + 2 * p == 56);

or

model.Add(LinearExpr.Sum(new IntVar[] {r, p}) == 20);

See: https://github.com/google/or-tools/blob/master/ortools/sat/doc/integer_arithmetic.md

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM