DotNet Reference
.Net Reference
IntegerExpressions.cs
Go to the documentation of this file.
38 public static void AddOrIncrement(this Dictionary<IntVar, long> dict, IntVar key, long increment)
41 System.Runtime.InteropServices.CollectionsMarshal.GetValueRefOrAddDefault(dict, key, out _) += increment;
55 public static void TrySetCapacity<TField, TValues>(this RepeatedField<TField> field, IEnumerable<TValues> values)
64 public static void TryEnsureCapacity<TValue, TValues>(this List<TValue> list, IEnumerable<TValues> values)
66 // Check for ICollection as the generic version is not covariant and TValues could be LinearExpr, IntVar, ...
348 public static long GetVarValueMap(LinearExpr e, long initial_coeff, Dictionary<IntVar, long> dict)
392 throw new ArgumentException("Cannot interpret '" + term.expr.ToString() + "' in an integer expression");
398 public static LinearExpr RebuildLinearExprFromLinearExpressionProto(LinearExpressionProto proto, CpModelProto model)
522 public LinearExprBuilder AddWeightedSum(IEnumerable<LinearExpr> exprs, IEnumerable<long> coefficients)
533 public LinearExprBuilder AddWeightedSum(IEnumerable<LinearExpr> exprs, IEnumerable<int> coefficients)
544 public LinearExprBuilder AddWeightedSum(IEnumerable<ILiteral> literals, IEnumerable<int> coefficients)
555 public LinearExprBuilder AddWeightedSum(IEnumerable<ILiteral> literals, IEnumerable<long> coefficients)
566 public LinearExprBuilder AddWeightedSum(IEnumerable<BoolVar> vars, IEnumerable<long> coefficients)
577 public LinearExprBuilder AddWeightedSum(IEnumerable<BoolVar> vars, IEnumerable<int> coefficients)
664 {
671 {
725 {
733 {
744 {
812 {
961 {
968 {
975 {
982 {
989 {
static BoundedLinearExpression operator>(long v, LinearExpr a)
Definition: IntegerExpressions.cs:287
static LinearExpr operator -(LinearExpr a)
Definition: IntegerExpressions.cs:247
LinearExprBuilder AddWeightedSum(IEnumerable< BoolVar > vars, IEnumerable< long > coefficients)
Adds sum(vars[i] * coeffs[i]) to the builder.
Definition: IntegerExpressions.cs:566
static long GetVarValueMap(LinearExpr e, long initial_coeff, Dictionary< IntVar, long > dict)
Definition: IntegerExpressions.cs:348
LinearExprBuilder AddWeightedSum(IEnumerable< LinearExpr > exprs, IEnumerable< long > coefficients)
Adds sum(exprs[i] * coeffs[i]) to the builder.
Definition: IntegerExpressions.cs:522
static LinearExpr WeightedSum(IEnumerable< ILiteral > literals, IEnumerable< long > coeffs)
Creates Sum(literals[i] * coeffs[i]).
Definition: IntegerExpressions.cs:131
Some constraints supports linear expression instead of just using a reference to a variable.
Definition: CpModel.pb.cs:695
static LinearExpr Constant(long value)
Creates a constant expression.
Definition: IntegerExpressions.cs:196
static LinearExpr Term(BoolVar var, long coeff)
Creates var * coeff.
Definition: IntegerExpressions.cs:168
LinearExprBuilder Add(long constant)
Adds constant to the builder.
Definition: IntegerExpressions.cs:453
LinearExprBuilder(int sizeHint=2)
Definition: IntegerExpressions.cs:428
BoundedLinearExpression(long lb, LinearExpr expr, long ub)
Definition: IntegerExpressions.cs:855
static LinearExpr operator -(LinearExpr a, long v)
Definition: IntegerExpressions.cs:227
Definition: util/Domain.cs:11
static BoundedLinearExpression operator>(LinearExpr a, LinearExpr b)
Definition: IntegerExpressions.cs:317
long [] FlattenedIntervals()
Definition: util/Domain.cs:84
static BoundedLinearExpression operator<(long v, LinearExpr a)
Definition: IntegerExpressions.cs:307
static BoundedLinearExpression operator !=(LinearExpr a, LinearExpr b)
Definition: IntegerExpressions.cs:257
static LinearExpr WeightedSum(IEnumerable< ILiteral > literals, IEnumerable< int > coeffs)
Creates Sum(literals[i] * coeffs[i]).
Definition: IntegerExpressions.cs:125
static LinearExpr Affine(LinearExpr expr, long coeff, long offset)
Creates expr * coeff + offset.
Definition: IntegerExpressions.cs:174
LinearExprBuilder AddTerm(ILiteral literal, long coefficient)
Adds literal * coefficient to the builder.
Definition: IntegerExpressions.cs:467
Holds a linear constraint: expression ∈ domain
Definition: IntegerExpressions.cs:844
IntVar(CpModelProto model, long lb, long ub, string name)
Definition: IntegerExpressions.cs:700
LinearExprBuilder AddWeightedSum(IEnumerable< ILiteral > literals, IEnumerable< long > coefficients)
Adds sum(literals[i] * coeffs[i]) to the builder.
Definition: IntegerExpressions.cs:555
Holds a integer variable with a discrete domain.
Definition: IntegerExpressions.cs:689
static LinearExpr Affine(BoolVar var, long coeff, long offset)
Creates var * coeff + offset.
Definition: IntegerExpressions.cs:190
Holds a Boolean variable or its negation.
Definition: IntegerExpressions.cs:25
Definition: IntArrayHelper.cs:14
LinearExprBuilder AddWeightedSum(IEnumerable< LinearExpr > exprs, IEnumerable< int > coefficients)
Adds sum(exprs[i] * coeffs[i]) to the builder.
Definition: IntegerExpressions.cs:533
static LinearExpr operator *(long v, LinearExpr a)
Definition: IntegerExpressions.cs:242
int GetIndex()
Returns the index of the variable in the underlying CpModelProto.
Definition: IntegerExpressions.cs:718
static BoundedLinearExpression operator >=(long v, LinearExpr a)
Definition: IntegerExpressions.cs:277
override string ToString()
Definition: CpModel.pb.cs:392
static LinearExpr operator -(LinearExpr a, LinearExpr b)
Definition: IntegerExpressions.cs:222
LinearExprBuilder AddSum(IEnumerable< LinearExpr > exprs)
Adds sum(exprs) to the builder.
Definition: IntegerExpressions.cs:489
static LinearExpr Term(ILiteral literal, long coeff)
Creates literal * coeff.
Definition: IntegerExpressions.cs:155
static BoundedLinearExpression operator >=(BoundedLinearExpression a, long v)
Definition: IntegerExpressions.cs:942
static void AddOrIncrement(this Dictionary< IntVar, long > dict, IntVar key, long increment)
Definition: IntegerExpressions.cs:38
static LinearExpr Sum(IEnumerable< BoolVar > vars)
Creates Sum(vars).
Definition: IntegerExpressions.cs:107
static LinearExprBuilder NewBuilder(int sizeHint=2)
Creates a builder class for linear expression.
Definition: IntegerExpressions.cs:202
static BoundedLinearExpression operator !=(LinearExpr a, long v)
Definition: IntegerExpressions.cs:267
LinearExprBuilder AddWeightedSum(IEnumerable< ILiteral > literals, IEnumerable< int > coefficients)
Adds sum(literals[i] * coeffs[i]) to the builder.
Definition: IntegerExpressions.cs:544
static void TrySetCapacity< TField, TValues >(this RepeatedField< TField > field, IEnumerable< TValues > values)
Definition: IntegerExpressions.cs:55
static Domain VariableDomain(Google.OrTools.Sat.IntegerVariableProto variable_proto)
Definition: CpSatHelper.cs:64
static BoundedLinearExpression operator>(BoundedLinearExpression a, long v)
Definition: IntegerExpressions.cs:951
static LinearExpr WeightedSum(IEnumerable< LinearExpr > exprs, IEnumerable< int > coeffs)
Creates Sum(exprs[i] * coeffs[i]).
Definition: IntegerExpressions.cs:113
static BoundedLinearExpression operator>(LinearExpr a, long v)
Definition: IntegerExpressions.cs:282
LinearExprBuilder AddSum(IEnumerable< ILiteral > literals)
Adds sum(literals) to the builder.
Definition: IntegerExpressions.cs:500
static void TryEnsureCapacity< TValue, TValues >(this List< TValue > list, IEnumerable< TValues > values)
Definition: IntegerExpressions.cs:64
override string ToString()
Definition: IntegerExpressions.cs:587
IntVar(CpModelProto model, Domain domain, string name)
Definition: IntegerExpressions.cs:691
Definition: IntArrayHelper.cs:14
static BoundedLinearExpression operator<(LinearExpr a, long v)
Definition: IntegerExpressions.cs:302
static BoundedLinearExpression operator >=(LinearExpr a, LinearExpr b)
Definition: IntegerExpressions.cs:312
override string ToString()
Definition: IntegerExpressions.cs:905
LinearExprBuilder Add(ILiteral literal)
Adds literal to the builder.
Definition: IntegerExpressions.cs:441
NotBoolVar(BoolVar boolvar)
Definition: IntegerExpressions.cs:801
LinearExprBuilder AddSum(IEnumerable< BoolVar > vars)
Adds sum(vars) to the builder.
Definition: IntegerExpressions.cs:511
A builder class for linear expressions.
Definition: IntegerExpressions.cs:426
LinearExpr Right
Definition: IntegerExpressions.cs:968
IntVar(CpModelProto model, int index)
Definition: IntegerExpressions.cs:711
static LinearExpr operator *(LinearExpr a, long v)
Definition: IntegerExpressions.cs:237
pbc::RepeatedField< int > Vars
Definition: CpModel.pb.cs:748
Definition: util/Domain.cs:17
static LinearExpr Term(LinearExpr expr, long coeff)
Creates expr * coeff.
Definition: IntegerExpressions.cs:149
LinearExprBuilder AddTerm(BoolVar var, long coefficient)
Adds var * coefficient to the builder.
Definition: IntegerExpressions.cs:482
static BoundedLinearExpression operator<(LinearExpr a, LinearExpr b)
Definition: IntegerExpressions.cs:327
static BoundedLinearExpression operator<=(BoundedLinearExpression a, long v)
Definition: IntegerExpressions.cs:924
pbc::RepeatedField< global::Google.OrTools.Sat.IntegerVariableProto > Variables
The associated Protos should be referred by their index in these fields.
Definition: CpModel.pb.cs:8716
Definition: CpSatHelper.cs:15
BoolVar(CpModelProto model, int index)
Definition: IntegerExpressions.cs:780
BoundedLinearExpression(LinearExpr left, long v, bool equality)
Definition: IntegerExpressions.cs:873
pbc::RepeatedField< long > Domain
The variable domain given as a sorted list of n disjoint intervals [min, max] and encoded as [min_0,...
Definition: CpModel.pb.cs:354
Holds a linear expression: sum (ai * xi) + b.
Definition: IntegerExpressions.cs:92
static BoundedLinearExpression operator==(LinearExpr a, LinearExpr b)
Definition: IntegerExpressions.cs:252
LinearExpr NotAsExpr()
Returns the Boolean negation of that variable as a linear expression.
Definition: IntegerExpressions.cs:791
override string ToString()
Definition: IntegerExpressions.cs:828
pbc::RepeatedField< long > Coeffs
Definition: CpModel.pb.cs:759
int Index
Returns the index of the variable in the underlying CpModelProto.
Definition: IntegerExpressions.cs:725
string Name()
Returns the name of the variable given upon creation.
Definition: IntegerExpressions.cs:756
static LinearExpr WeightedSum(IEnumerable< BoolVar > vars, IEnumerable< long > coeffs)
Creates Sum(vars[i] * coeffs[i]).
Definition: IntegerExpressions.cs:143
static BoundedLinearExpression operator<(BoundedLinearExpression a, long v)
Definition: IntegerExpressions.cs:933
static LinearExpr Affine(ILiteral literal, long coeff, long offset)
Creates literal * coeff + offset.
Definition: IntegerExpressions.cs:184
static BoundedLinearExpression operator<=(LinearExpr a, long v)
Definition: IntegerExpressions.cs:292
static LinearExpr operator+(LinearExpr a, LinearExpr b)
Definition: IntegerExpressions.cs:207
Definition: IntegerExpressions.cs:75
LinearExpr NotAsExpr()
Returns the Boolean negation of the literal as a linear expression.
static LinearExpr RebuildLinearExprFromLinearExpressionProto(LinearExpressionProto proto, CpModelProto model)
Definition: IntegerExpressions.cs:398
LinearExpr NotAsExpr()
Returns the Boolean negation of the literal as a linear expression.
Definition: IntegerExpressions.cs:823
static LinearExpr WeightedSum(IEnumerable< LinearExpr > exprs, IEnumerable< long > coeffs)
Creates Sum(exprs[i] * coeffs[i]).
Definition: IntegerExpressions.cs:119
static LinearExpr operator -(long v, LinearExpr a)
Definition: IntegerExpressions.cs:232
static LinearExpr WeightedSum(IEnumerable< BoolVar > vars, IEnumerable< int > coeffs)
Creates Sum(vars[i] * coeffs[i]).
Definition: IntegerExpressions.cs:137
BoolVar(CpModelProto model, String name)
Definition: IntegerExpressions.cs:776
static LinearExpr Sum(IEnumerable< ILiteral > literals)
Creates Sum(literals).
Definition: IntegerExpressions.cs:101
static LinearExpr Prod(LinearExpr e, long v)
Definition: IntegerExpressions.cs:332
Definition: CpModel.pb.cs:12
LinearExprBuilder AddTerm(LinearExpr expr, long coefficient)
Adds expr * coefficient to the builder.
Definition: IntegerExpressions.cs:460
LinearExprBuilder AddWeightedSum(IEnumerable< BoolVar > vars, IEnumerable< int > coefficients)
Adds sum(vars[i] * coeffs[i]) to the builder.
Definition: IntegerExpressions.cs:577
LinearExprBuilder Add(LinearExpr expr)
Adds expr to the builder.
Definition: IntegerExpressions.cs:435
static LinearExpr Sum(IEnumerable< LinearExpr > exprs)
Creates Sum(exprs).
Definition: IntegerExpressions.cs:95
static BoundedLinearExpression operator >=(LinearExpr a, long v)
Definition: IntegerExpressions.cs:272
BoundedLinearExpression(LinearExpr left, LinearExpr right, bool equality)
Definition: IntegerExpressions.cs:864