简体   繁体   English

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

[英]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.我想知道如何使用 OR-Tools 在 C# 中实现SUM操作。 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请参阅: https://github.com/google/or-tools/blob/master/ortools/sat/doc/integer_arithmetic.md

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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