C++ Reference: class CpModelBuilder

This documentation is automatically generated.

Method
AddAbsEquality

Return type: Constraint

Arguments: IntVar target, IntVar var

Adds target == abs(var).

AddAllDifferent

Return type: Constraint

Arguments: absl::Span<const IntVar> vars

this constraint forces all variables to have different values.

AddAllowedAssignments

Return type: TableConstraint

Arguments: absl::Span<const IntVar> vars

AddAssumption

Return type: void

Arguments: BoolVar lit

Adds a literal to the model as assumptions.

AddAssumptions

Return type: void

Arguments: absl::Span<const BoolVar> literals

Adds multiple literals to the model as assumptions.

AddAutomaton

Return type: AutomatonConstraint

Arguments: absl::Span<const IntVar> transition_variables, int starting_state, absl::Span<const int> final_states

AddBoolAnd

Return type: Constraint

Arguments: absl::Span<const BoolVar> literals

Adds the constraint that all literals must be true.

AddBoolOr

Return type: Constraint

Arguments: absl::Span<const BoolVar> literals

Adds the constraint that at least one of the literals must be true.

AddBoolXor

Return type: Constraint

Arguments: absl::Span<const BoolVar> literals

Adds the constraint that a odd number of literal is true.

AddCircuitConstraint

Return type: CircuitConstraint

AddCumulative

Return type: CumulativeConstraint

Arguments: IntVar capacity

AddDecisionStrategy

Return type: void

Arguments: absl::Span<const IntVar> variables, DecisionStrategyProto::VariableSelectionStrategy var_strategy, DecisionStrategyProto::DomainReductionStrategy domain_strategy

Adds a decision strategy on a list of integer variables.

AddDecisionStrategy

Return type: void

Arguments: absl::Span<const BoolVar> variables, DecisionStrategyProto::VariableSelectionStrategy var_strategy, DecisionStrategyProto::DomainReductionStrategy domain_strategy

Adds a decision strategy on a list of boolean variables.

AddDivisionEquality

Return type: Constraint

Arguments: IntVar target, IntVar numerator, IntVar denominator

Adds target = num / denom (integer division rounded towards 0).

AddElement

Return type: Constraint

Arguments: IntVar index, absl::Span<const int64_t> values, IntVar target

Adds the element constraint: values[index] == target

AddEquality

Return type: Constraint

Arguments: const LinearExpr& left, const LinearExpr& right

Adds left == right.

AddForbiddenAssignments

Return type: TableConstraint

Arguments: absl::Span<const IntVar> vars

AddGreaterOrEqual

Return type: Constraint

Arguments: const LinearExpr& left, const LinearExpr& right

Adds left >= right.

AddGreaterThan

Return type: Constraint

Arguments: const LinearExpr& left, const LinearExpr& right

Adds left > right.

AddHint

Return type: void

Arguments: IntVar var, int64_t value

Adds hinting to a variable.

AddImplication

Return type: Constraint

Arguments: BoolVar a, BoolVar b

Adds a => b.

AddInverseConstraint

Return type: Constraint

Arguments: absl::Span<const IntVar> variables, absl::Span<const IntVar> inverse_variables

AddLessOrEqual

Return type: Constraint

Arguments: const LinearExpr& left, const LinearExpr& right

Adds left <= right.

AddLessThan

Return type: Constraint

Arguments: const LinearExpr& left, const LinearExpr& right

Adds left < right.

AddLinearConstraint

Return type: Constraint

Arguments: const LinearExpr& expr, const Domain& domain

Adds expr in domain.

AddLinMaxEquality

Return type: Constraint

Arguments: const LinearExpr& target, absl::Span<const LinearExpr> exprs

Adds target == max(exprs).

AddLinMinEquality

Return type: Constraint

Arguments: const LinearExpr& target, absl::Span<const LinearExpr> exprs

Adds target == min(exprs).

AddMaxEquality

Return type: Constraint

Arguments: IntVar target, absl::Span<const IntVar> vars

Adds target == max(vars).

AddMinEquality

Return type: Constraint

Arguments: IntVar target, absl::Span<const IntVar> vars

Adds target == min(vars).

AddModuloEquality

Return type: Constraint

Arguments: IntVar target, IntVar var, IntVar mod

Adds target = var % mod.

AddMultipleCircuitConstraint

Return type: MultipleCircuitConstraint

AddNoOverlap

Return type: Constraint

Arguments: absl::Span<const IntervalVar> vars

AddNoOverlap2D

Return type: NoOverlap2DConstraint

AddNotEqual

Return type: Constraint

Arguments: const LinearExpr& left, const LinearExpr& right

Adds left != right.

AddProductEquality

Return type: Constraint

Arguments: IntVar target, absl::Span<const IntVar> vars

Adds target == prod(vars).

AddReservoirConstraint

Return type: ReservoirConstraint

Arguments: int64_t min_level, int64_t max_level

AddVariableElement

Return type: Constraint

Arguments: IntVar index, absl::Span<const IntVar> variables, IntVar target

Adds the element constraint: variables[index] == target

Build

Return type: const CpModelProto&

ClearAssumptions

Return type: void

Remove all assumptions from the model.

ClearHints

Return type: void

Remove all hints.

CopyFrom

Return type: void

Arguments: const CpModelProto& model_proto

Replace the current model with the one from the given proto.

FalseVar

Return type: BoolVar

Creates an always false Boolean variable.

GetBoolVarFromProtoIndex

Return type: BoolVar

Arguments: int index

Returns the Boolean variable from its index in the proto.

GetIntervalVarFromProtoIndex

Return type: IntervalVar

Arguments: int index

Returns the interval variable from its index in the proto.

GetIntVarFromProtoIndex

Return type: IntVar

Arguments: int index

Returns the integer variable from its index in the proto.

Maximize

Return type: void

Arguments: const LinearExpr& expr

Adds a linear maximization objective.

Minimize

Return type: void

Arguments: const LinearExpr& expr

Adds a linear minimization objective.

MutableProto

Return type: CpModelProto*

NewBoolVar

Return type: BoolVar

Creates a Boolean variable.

NewConstant

Return type: IntVar

Arguments: int64_t value

Creates a constant variable.

NewIntervalVar

Return type: IntervalVar

Arguments: IntVar start, IntVar size, IntVar end

Creates an interval variable.

NewIntVar

Return type: IntVar

Arguments: const Domain& domain

Creates an integer variable with the given domain.

NewOptionalIntervalVar

Return type: IntervalVar

Arguments: IntVar start, IntVar size, IntVar end, BoolVar presence

Creates an optional interval variable.

Proto

Return type: const CpModelProto&

ScaleObjectiveBy

Return type: void

Arguments: double scaling

TrueVar

Return type: BoolVar

Creates an always true Boolean variable.