DotNet Reference
.Net Reference
CpModel.cs
Go to the documentation of this file.
786 public Constraint AddMultiplicationEquality(LinearExpr target, LinearExpr left, LinearExpr right)
874 public IntervalVar NewOptionalIntervalVar<S, D, E>(S start, D size, E end, ILiteral is_present, string name)
905 public IntervalVar NewOptionalFixedSizeIntervalVar<S>(S start, long size, ILiteral is_present, string name)
All affine expressions must take different values.
Definition: CpModel.pb.cs:1171
pbc::RepeatedField< global::Google.OrTools.Sat.LinearExpressionProto > Exprs
Definition: CpModel.pb.cs:1218
This constraint forces a sequence of variables to be accepted by an automaton.
Definition: CpModel.pb.cs:4243
Specialized automaton constraint.
Definition: Constraints.cs:276
Argument of the constraints of the form OP(literals).
Definition: CpModel.pb.cs:514
pbc::RepeatedField< int > Literals
Definition: CpModel.pb.cs:561
Holds a linear constraint: expression ∈ domain
Definition: IntegerExpressions.cs:861
LinearExpr Right
Definition: IntegerExpressions.cs:984
The circuit constraint is defined on a graph where the arc presence are controlled by literals.
Definition: CpModel.pb.cs:3203
pbc::RepeatedField< int > EnforcementLiteral
The constraint will be enforced iff all literals listed here are true.
Definition: CpModel.pb.cs:4923
global::Google.OrTools.Sat.LinearArgumentProto IntProd
The int_prod constraint forces the target to equal the product of all variables.
Definition: CpModel.pb.cs:5076
global::Google.OrTools.Sat.NoOverlap2DConstraintProto NoOverlap2D
The no_overlap_2d constraint prevents a set of boxes from overlapping.
Definition: CpModel.pb.cs:5284
global::Google.OrTools.Sat.BoolArgumentProto BoolOr
The bool_or constraint forces at least one literal to be true.
Definition: CpModel.pb.cs:4934
global::Google.OrTools.Sat.BoolArgumentProto BoolAnd
The bool_and constraint forces all of the literals to be true.
Definition: CpModel.pb.cs:4953
global::Google.OrTools.Sat.LinearArgumentProto IntDiv
The int_div constraint forces the target to equal exprs[0] / exprs[1].
Definition: CpModel.pb.cs:5036
global::Google.OrTools.Sat.CumulativeConstraintProto Cumulative
The cumulative constraint ensures that for any integer point, the sum of the demands of the intervals...
Definition: CpModel.pb.cs:5301
global::Google.OrTools.Sat.AutomatonConstraintProto Automaton
The automaton constraint forces a sequence of variables to be accepted by an automaton.
Definition: CpModel.pb.cs:5203
global::Google.OrTools.Sat.TableConstraintProto Table
The table constraint enforces what values a tuple of variables may take.
Definition: CpModel.pb.cs:5187
global::Google.OrTools.Sat.LinearArgumentProto LinMax
The lin_max constraint forces the target to equal the maximum of all linear expressions.
Definition: CpModel.pb.cs:5093
global::Google.OrTools.Sat.LinearConstraintProto Linear
The linear constraint enforces a linear inequality among the variables, such as 0 <= x + 2y <= 10.
Definition: CpModel.pb.cs:5109
global::Google.OrTools.Sat.NoOverlapConstraintProto NoOverlap
The no_overlap constraint prevents a set of intervals from overlapping; in scheduling,...
Definition: CpModel.pb.cs:5269
global::Google.OrTools.Sat.AllDifferentConstraintProto AllDiff
The all_diff constraint forces all variables to take different values.
Definition: CpModel.pb.cs:5124
global::Google.OrTools.Sat.CircuitConstraintProto Circuit
The circuit constraint takes a graph and forces the arcs present (with arc presence indicated by a li...
Definition: CpModel.pb.cs:5156
global::Google.OrTools.Sat.BoolArgumentProto AtMostOne
The at_most_one constraint enforces that no more than one literal is true at the same time.
Definition: CpModel.pb.cs:4978
global::Google.OrTools.Sat.ElementConstraintProto Element
The element constraint forces the variable with the given index to be equal to the target.
Definition: CpModel.pb.cs:5140
global::Google.OrTools.Sat.InverseConstraintProto Inverse
The inverse constraint forces two arrays to be inverses of each other: the values of one are the indi...
Definition: CpModel.pb.cs:5219
global::Google.OrTools.Sat.LinearArgumentProto IntMod
The int_mod constraint forces the target to equal exprs[0] % exprs[1].
Definition: CpModel.pb.cs:5053
global::Google.OrTools.Sat.BoolArgumentProto ExactlyOne
The exactly_one constraint force exactly one literal to true and no more.
Definition: CpModel.pb.cs:5004
global::Google.OrTools.Sat.ReservoirConstraintProto Reservoir
The reservoir constraint forces the sum of a set of active demands to always be between a specified m...
Definition: CpModel.pb.cs:5236
global::Google.OrTools.Sat.BoolArgumentProto BoolXor
The bool_xor constraint forces an odd number of the literals to be true.
Definition: CpModel.pb.cs:5019
global::Google.OrTools.Sat.RoutesConstraintProto Routes
The routes constraint implements the vehicle routing problem.
Definition: CpModel.pb.cs:5171
pbc::RepeatedField< global::Google.OrTools.Sat.DecisionStrategyProto > SearchStrategy
Defines the strategy that the solver should follow when the search_branching parameter is set to FIXE...
Definition: CpModel.pb.cs:8791
global::Google.OrTools.Sat.PartialVariableAssignment SolutionHint
Solution hint.
Definition: CpModel.pb.cs:8813
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
pbc::RepeatedField< global::Google.OrTools.Sat.ConstraintProto > Constraints
Definition: CpModel.pb.cs:8727
global::Google.OrTools.Sat.CpObjectiveProto Objective
The objective to minimize.
Definition: CpModel.pb.cs:8739
void AddAssumption(ILiteral lit)
Adds a literal to the model as assumption.
Definition: CpModel.cs:1052
Constraint AddInverse(IEnumerable< IntVar > direct, IEnumerable< IntVar > reverse)
Adds Inverse(variables, inverseVariables).
Definition: CpModel.cs:447
Constraint AddLinearExpressionInDomain(LinearExpr expr, Domain domain)
Adds expr ∈ domain.
Definition: CpModel.cs:159
IntervalVar NewOptionalFixedSizeIntervalVar< S >(S start, long size, ILiteral is_present, string name)
Creates an optional interval variable from an affine expression start, a fixed size,...
Definition: CpModel.cs:905
IntervalVar NewIntervalVar< S, D, E >(S start, D size, E end, string name)
Creates an interval variable from three affine expressions start, size, and end.
Definition: CpModel.cs:816
TableConstraint AddAllowedAssignments(IEnumerable< IntVar > vars)
Adds AllowedAssignments(variables).
Definition: CpModel.cs:348
void Minimize(LinearExpr obj)
Adds a minimization objective of a linear expression.
Definition: CpModel.cs:996
Constraint AddBoolXor(IEnumerable< ILiteral > literals)
Adds XOr(literals) == true.
Definition: CpModel.cs:653
void AddMapDomain(IntVar var, IEnumerable< IntVar > bool_vars, long offset=0)
Definition: CpModel.cs:505
Constraint AddAtLeastOne(IEnumerable< ILiteral > literals)
Same as AddBoolOr: ∑(literals) ≥ 1.
Definition: CpModel.cs:586
IntervalVar NewFixedSizeIntervalVar< S >(S start, long size, string name)
Creates an interval variable from an affine expression start, and a fixed size.
Definition: CpModel.cs:844
void AddDecisionStrategy(IEnumerable< IntVar > vars, DecisionStrategyProto.Types.VariableSelectionStrategy var_str, DecisionStrategyProto.Types.DomainReductionStrategy dom_str)
Adds DecisionStrategy(variables, var_str, dom_str).
Definition: CpModel.cs:1022
IntervalVar NewOptionalIntervalVar< S, D, E >(S start, D size, E end, ILiteral is_present, string name)
Creates an optional interval variable from three affine expressions start, size, and end,...
Definition: CpModel.cs:874
Boolean ExportToFile(String file)
Write the model as a protocol buffer to file.
Definition: CpModel.cs:1143
AutomatonConstraint AddAutomaton(IEnumerable< IntVar > vars, long starting_state, IEnumerable< long > final_states)
Adds an automaton constraint.
Definition: CpModel.cs:416
Constraint AddMaxEquality(LinearExpr target, IEnumerable< LinearExpr > exprs)
Adds target == Max(exprs).
Definition: CpModel.cs:692
Constraint AddDivisionEquality< T, N, D >(T target, N num, D denom)
Adds target == num / denom (integer division rounded towards 0).
Definition: CpModel.cs:712
ReservoirConstraint AddReservoirConstraint(long minLevel, long maxLevel)
Adds a reservoir constraint with optional refill/emptying events.
Definition: CpModel.cs:493
Constraint AddExactlyOne(IEnumerable< ILiteral > literals)
Adds ExactlyOne(literals): ∑(literals) == 1.
Definition: CpModel.cs:615
Constraint AddNoOverlap(IEnumerable< IntervalVar > intervals)
Adds NoOverlap(intervalVars).
Definition: CpModel.cs:926
BoolVar NewBoolVar(string name)
Creates an Boolean variable with given domain.
Definition: CpModel.cs:97
CircuitConstraint AddCircuit()
Adds and returns an empty circuit constraint.
Definition: CpModel.cs:308
LinearExpressionProto GetLinearExpressionProto(LinearExpr expr, bool negate=false)
Definition: CpModel.cs:1192
Constraint AddElement(IntVar index, IEnumerable< IntVar > vars, IntVar target)
Adds the element constraint: variables[index] == target.
Definition: CpModel.cs:240
Constraint AddMinEquality(LinearExpr target, IEnumerable< LinearExpr > exprs)
Adds target == Min(exprs).
Definition: CpModel.cs:672
Constraint AddAtMostOne(IEnumerable< ILiteral > literals)
Adds AtMostOne(literals): ∑(literals) ≤ 1.
Definition: CpModel.cs:596
Constraint AddMultiplicationEquality(LinearExpr target, IEnumerable< LinearExpr > exprs)
Adds target == ∏(exprs).
Definition: CpModel.cs:766
void Maximize(LinearExpr obj)
Adds a maximization objective of a linear expression.
Definition: CpModel.cs:1002
IntVar NewIntVar(long lb, long ub, string name)
Creates an integer variable with domain [lb, ub].
Definition: CpModel.cs:63
Constraint AddBoolAnd(IEnumerable< ILiteral > literals)
Adds And(literals) == true.
Definition: CpModel.cs:634
Constraint AddBoolOr(IEnumerable< ILiteral > literals)
Adds Or(literals) == true.
Definition: CpModel.cs:567
Constraint AddModuloEquality< T, V, M >(T target, V v, M m)
Adds target == v % m.
Definition: CpModel.cs:748
Constraint AddElement(IntVar index, IEnumerable< long > values, IntVar target)
Adds the element constraint: values[index] == target.
Definition: CpModel.cs:261
CumulativeConstraint AddCumulative< C >(C capacity)
Adds Cumulative(capacity).
Definition: CpModel.cs:982
MultipleCircuitConstraint AddMultipleCircuit()
Adds and returns an empty multiple circuit constraint.
Definition: CpModel.cs:326
IntVar NewIntVarFromDomain(Domain domain, string name)
Creates an integer variable with given domain.
Definition: CpModel.cs:77
LinearExpr GetLinearExpr< X >(X x)
Definition: CpModel.cs:1175
Constraint AddMultiplicationEquality(LinearExpr target, LinearExpr left, LinearExpr right)
Adds target == left * right.
Definition: CpModel.cs:786
Constraint AddElement(IntVar index, IEnumerable< int > values, IntVar target)
Adds the element constraint: values[index] == target.
Definition: CpModel.cs:282
Constraint AddAllDifferent(IEnumerable< LinearExpr > exprs)
Adds the constraint AllDifferent(exprs).
Definition: CpModel.cs:221
String Validate()
Returns a non empty string explaining the issue if the model is invalid.
Definition: CpModel.cs:1153
Constraint Add(BoundedLinearExpression lin)
Adds a linear constraint to the model.
Definition: CpModel.cs:193
Constraint AddAbsEquality(LinearExpr target, LinearExpr expr)
Adds target == abs(expr).
Definition: CpModel.cs:730
Constraint AddLinearConstraint(LinearExpr expr, long lb, long ub)
Adds lb ≤ expr ≤ ub.
Definition: CpModel.cs:142
void AddAssumptions(IEnumerable< ILiteral > literals)
Adds multiple literals to the model as assumptions.
Definition: CpModel.cs:1058
TableConstraint AddForbiddenAssignments(IEnumerable< IntVar > vars)
Adds ForbiddenAssignments(variables).
Definition: CpModel.cs:376
double Offset
The displayed objective is always: scaling_factor * (sum(coefficients[i] * objective_vars[i]) + offse...
Definition: CpModel.pb.cs:6467
pbc::RepeatedField< int > Vars
The linear terms of the objective to minimize.
Definition: CpModel.pb.cs:6438
pbc::RepeatedField< long > Coeffs
Definition: CpModel.pb.cs:6449
Definition: CpSatHelper.cs:15
static string ValidateModel(Google.OrTools.Sat.CpModelProto model_proto)
Definition: CpSatHelper.cs:59
static bool WriteModelToFile(Google.OrTools.Sat.CpModelProto model_proto, string filename)
Definition: CpSatHelper.cs:69
static string ModelStats(Google.OrTools.Sat.CpModelProto model_proto)
Definition: CpSatHelper.cs:49
The sum of the demands of the intervals at each interval point cannot exceed a capacity.
Definition: CpModel.pb.cs:2606
global::Google.OrTools.Sat.LinearExpressionProto Capacity
Definition: CpModel.pb.cs:2653
Specialized cumulative constraint.
Definition: Constraints.cs:365
Container for nested types declared in the DecisionStrategyProto message type.
Definition: CpModel.pb.cs:7412
VariableSelectionStrategy
The order in which the variables above should be considered.
Definition: CpModel.pb.cs:7419
DomainReductionStrategy
Once a variable has been chosen, this enum describe what decision is taken on its domain.
Definition: CpModel.pb.cs:7433
Define the strategy to follow when the solver needs to take a new decision.
Definition: CpModel.pb.cs:7129
pbc::RepeatedField< int > Variables
The variables to be considered for the next decision.
Definition: CpModel.pb.cs:7184
The constraint target = vars[index].
Definition: CpModel.pb.cs:1600
pbc::RepeatedField< int > Vars
Definition: CpModel.pb.cs:1673
Holds a integer variable with a discrete domain.
Definition: IntegerExpressions.cs:706
int GetIndex()
Returns the index of the variable in the underlying CpModelProto.
Definition: IntegerExpressions.cs:734
int Index
Returns the index of the variable in the underlying CpModelProto.
Definition: IntegerExpressions.cs:741
The two arrays of variable each represent a function, the second is the inverse of the first: f_direc...
Definition: CpModel.pb.cs:4031
pbc::RepeatedField< int > FDirect
Definition: CpModel.pb.cs:4079
pbc::RepeatedField< global::Google.OrTools.Sat.LinearExpressionProto > Exprs
Definition: CpModel.pb.cs:1004
global::Google.OrTools.Sat.LinearExpressionProto Target
Definition: CpModel.pb.cs:990
The linear sum vars[i] * coeffs[i] must fall in the given domain.
Definition: CpModel.pb.cs:1357
pbc::RepeatedField< int > Vars
Definition: CpModel.pb.cs:1406
pbc::RepeatedField< long > Domain
Definition: CpModel.pb.cs:1431
Holds a linear expression: sum (ai * xi) + b.
Definition: IntegerExpressions.cs:108
static LinearExpr Constant(long value)
Creates a constant expression.
Definition: IntegerExpressions.cs:211
static LinearExpr Sum(IEnumerable< LinearExpr > exprs)
Creates Sum(exprs).
Definition: IntegerExpressions.cs:110
Some constraints supports linear expression instead of just using a reference to a variable.
Definition: CpModel.pb.cs:699
pbc::RepeatedField< int > Vars
Definition: CpModel.pb.cs:748
pbc::RepeatedField< long > Coeffs
Definition: CpModel.pb.cs:759
Specialized multiple circuit constraint.
Definition: Constraints.cs:119
The boxes defined by [start_x, end_x) * [start_y, end_y) cannot overlap.
Definition: CpModel.pb.cs:2349
Specialized NoOverlap2D constraint.
Definition: Constraints.cs:407
All the intervals (index of IntervalConstraintProto) must be disjoint.
Definition: CpModel.pb.cs:2164
pbc::RepeatedField< int > Intervals
Definition: CpModel.pb.cs:2211
This message encodes a partial (or full) assignment of the variables of a CpModelProto.
Definition: CpModel.pb.cs:7724
pbc::RepeatedField< long > Values
Definition: CpModel.pb.cs:7783
pbc::RepeatedField< int > Vars
Definition: CpModel.pb.cs:7772
Maintain a reservoir level within bounds.
Definition: CpModel.pb.cs:2878
Specialized reservoir constraint.
Definition: Constraints.cs:307
The "VRP" (Vehicle Routing Problem) constraint.
Definition: CpModel.pb.cs:3461
The values of the n-tuple formed by the given variables can only be one of the listed n-tuples in val...
Definition: CpModel.pb.cs:3778
pbc::RepeatedField< int > Vars
Definition: CpModel.pb.cs:3827
bool Negated
If true, the meaning is "negated", that is we forbid any of the given tuple from a feasible assignmen...
Definition: CpModel.pb.cs:3851
Definition: util/Domain.cs:17
long[] FlattenedIntervals()
Definition: util/Domain.cs:84
Holds a Boolean variable or its negation.
Definition: IntegerExpressions.cs:26
Definition: CpModel.pb.cs:12
Definition: util/Domain.cs:11
Definition: IntArrayHelper.cs:15
Definition: IntArrayHelper.cs:15