如何在 Google OR-Tools for C# 中实现 SUM 运算

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

我想知道如何使用 OR-Tools 在 C# 中实现 SUM 运算。在我的问题中,我有以下约束:

Constraint

注意:我的问题是线性规划问题。

您可以使用算术运算符:

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

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

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