C++ Reference
C++ Reference: CP-SAT
Classes | |
class | AutomatonConstraint |
Specialized automaton constraint. More... | |
class | BoolVar |
A Boolean variable. More... | |
class | CircuitConstraint |
Specialized circuit constraint. More... | |
class | Constraint |
A constraint. More... | |
class | CpModelBuilder |
Wrapper class around the cp_model proto. More... | |
class | CumulativeConstraint |
Specialized cumulative constraint. More... | |
class | IntervalVar |
Represents a Interval variable. More... | |
class | IntVar |
An integer variable. More... | |
class | LinearExpr |
A dedicated container for linear expressions. More... | |
class | Model |
Class that owns everything related to a particular optimization model. More... | |
class | MultipleCircuitConstraint |
Specialized circuit constraint. More... | |
class | NoOverlap2DConstraint |
Specialized no_overlap2D constraint. More... | |
class | PROTOBUF_FINAL |
class | ReservoirConstraint |
Specialized reservoir constraint. More... | |
class | TableConstraint |
Specialized assignment constraint. More... | |
Functions | |
std::ostream & | operator<< (std::ostream &os, const BoolVar &var) |
BoolVar | Not (BoolVar x) |
A convenient wrapper so we can write Not(x) instead of x.Not() which is sometimes clearer. More... | |
std::ostream & | operator<< (std::ostream &os, const IntVar &var) |
std::ostream & | operator<< (std::ostream &os, const IntervalVar &var) |
int64 | SolutionIntegerValue (const CpSolverResponse &r, const LinearExpr &expr) |
Evaluates the value of an linear expression in a solver response. More... | |
int64 | SolutionIntegerMin (const CpSolverResponse &r, IntVar x) |
Returns the min of an integer variable in a solution. More... | |
int64 | SolutionIntegerMax (const CpSolverResponse &r, IntVar x) |
Returns the max of an integer variable in a solution. More... | |
bool | SolutionBooleanValue (const CpSolverResponse &r, BoolVar x) |
Evaluates the value of a Boolean literal in a solver response. More... | |
CpSolverResponse | Solve (const CpModelProto &model_proto) |
Solves the given CpModelProto and returns an instance of CpSolverResponse. More... | |
CpSolverResponse | SolveWithParameters (const CpModelProto &model_proto, const SatParameters ¶ms) |
Solves the given CpModelProto with the given parameters. More... | |
std::string | CpModelStats (const CpModelProto &model) |
Returns a string with some statistics on the given CpModelProto. More... | |
std::string | CpSolverResponseStats (const CpSolverResponse &response, bool has_objective=true) |
Returns a string with some statistics on the solver response. More... | |
CpSolverResponse | SolveCpModel (const CpModelProto &model_proto, Model *model) |
Solves the given CpModelProto. More... | |
CpSolverResponse | SolveWithParameters (const CpModelProto &model_proto, const std::string ¶ms) |
Solves the given CpModelProto with the given sat parameters as string in JSon format, and returns an instance of CpSolverResponse. More... | |
std::function< void(Model *)> | NewFeasibleSolutionObserver (const std::function< void(const CpSolverResponse &response)> &observer) |
Creates a solution observer with the model with model.Add(NewFeasibleSolutionObserver([](response){...}));. More... | |
void | SetSynchronizationFunction (std::function< CpSolverResponse()> f, Model *model) |
If set, the underlying solver will call this function regularly in a deterministic way. More... | |
std::function< SatParameters(Model *)> | NewSatParameters (const std::string ¶ms) |
Creates parameters for the solver, which you can add to the model with. More... | |
std::function< SatParameters(Model *)> | NewSatParameters (const SatParameters ¶meters) |
bool | DecisionStrategyProto_VariableSelectionStrategy_IsValid (int value) |
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor * | DecisionStrategyProto_VariableSelectionStrategy_descriptor () |
template<typename T > | |
const std::string & | DecisionStrategyProto_VariableSelectionStrategy_Name (T enum_t_value) |
bool | DecisionStrategyProto_VariableSelectionStrategy_Parse (const std::string &name, DecisionStrategyProto_VariableSelectionStrategy *value) |
bool | DecisionStrategyProto_DomainReductionStrategy_IsValid (int value) |
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor * | DecisionStrategyProto_DomainReductionStrategy_descriptor () |
template<typename T > | |
const std::string & | DecisionStrategyProto_DomainReductionStrategy_Name (T enum_t_value) |
bool | DecisionStrategyProto_DomainReductionStrategy_Parse (const std::string &name, DecisionStrategyProto_DomainReductionStrategy *value) |
bool | CpSolverStatus_IsValid (int value) |
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor * | CpSolverStatus_descriptor () |
template<typename T > | |
const std::string & | CpSolverStatus_Name (T enum_t_value) |
bool | CpSolverStatus_Parse (const std::string &name, CpSolverStatus *value) |
Enumeration Type Documentation
◆ CpSolverStatus
enum CpSolverStatus : int |
Enumerator | |
---|---|
UNKNOWN | |
MODEL_INVALID | |
FEASIBLE | |
INFEASIBLE | |
OPTIMAL | |
CpSolverStatus_INT_MIN_SENTINEL_DO_NOT_USE_ | |
CpSolverStatus_INT_MAX_SENTINEL_DO_NOT_USE_ |
Definition at line 227 of file cp_model.pb.h.
◆ DecisionStrategyProto_DomainReductionStrategy
Definition at line 199 of file cp_model.pb.h.
◆ DecisionStrategyProto_VariableSelectionStrategy
Definition at line 171 of file cp_model.pb.h.
Function Documentation
◆ CpModelStats()
std::string operations_research::sat::CpModelStats | ( | const CpModelProto & | model | ) |
Returns a string with some statistics on the given CpModelProto.
◆ CpSolverResponseStats()
std::string operations_research::sat::CpSolverResponseStats | ( | const CpSolverResponse & | response, |
bool | has_objective = true |
||
) |
Returns a string with some statistics on the solver response.
If the second argument is false, we will just display NA for the objective value instead of zero. It is not really needed but it makes things a bit clearer to see that there is no objective.
◆ CpSolverStatus_descriptor()
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* operations_research::sat::CpSolverStatus_descriptor | ( | ) |
◆ CpSolverStatus_IsValid()
bool operations_research::sat::CpSolverStatus_IsValid | ( | int | value | ) |
◆ CpSolverStatus_Name()
|
inline |
Definition at line 243 of file cp_model.pb.h.
◆ CpSolverStatus_Parse()
|
inline |
Definition at line 250 of file cp_model.pb.h.
◆ DecisionStrategyProto_DomainReductionStrategy_descriptor()
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* operations_research::sat::DecisionStrategyProto_DomainReductionStrategy_descriptor | ( | ) |
◆ DecisionStrategyProto_DomainReductionStrategy_IsValid()
bool operations_research::sat::DecisionStrategyProto_DomainReductionStrategy_IsValid | ( | int | value | ) |
◆ DecisionStrategyProto_DomainReductionStrategy_Name()
|
inline |
Definition at line 215 of file cp_model.pb.h.
◆ DecisionStrategyProto_DomainReductionStrategy_Parse()
|
inline |
Definition at line 222 of file cp_model.pb.h.
◆ DecisionStrategyProto_VariableSelectionStrategy_descriptor()
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* operations_research::sat::DecisionStrategyProto_VariableSelectionStrategy_descriptor | ( | ) |
◆ DecisionStrategyProto_VariableSelectionStrategy_IsValid()
bool operations_research::sat::DecisionStrategyProto_VariableSelectionStrategy_IsValid | ( | int | value | ) |
◆ DecisionStrategyProto_VariableSelectionStrategy_Name()
|
inline |
Definition at line 187 of file cp_model.pb.h.
◆ DecisionStrategyProto_VariableSelectionStrategy_Parse()
|
inline |
Definition at line 194 of file cp_model.pb.h.
◆ NewFeasibleSolutionObserver()
std::function<void(Model*)> operations_research::sat::NewFeasibleSolutionObserver | ( | const std::function< void(const CpSolverResponse &response)> & | observer | ) |
Creates a solution observer with the model with model.Add(NewFeasibleSolutionObserver([](response){...}));.
The given function will be called on each improving feasible solution found during the search. For a non-optimization problem, if the option to find all solution was set, then this will be called on each new solution.
◆ NewSatParameters() [1/2]
std::function<SatParameters(Model*)> operations_research::sat::NewSatParameters | ( | const SatParameters & | parameters | ) |
◆ NewSatParameters() [2/2]
std::function<SatParameters(Model*)> operations_research::sat::NewSatParameters | ( | const std::string & | params | ) |
Creates parameters for the solver, which you can add to the model with.
before calling SolveCpModel()
.
◆ Not()
A convenient wrapper so we can write Not(x) instead of x.Not() which is sometimes clearer.
◆ operator<<() [1/3]
std::ostream& operations_research::sat::operator<< | ( | std::ostream & | os, |
const BoolVar & | var | ||
) |
◆ operator<<() [2/3]
std::ostream& operations_research::sat::operator<< | ( | std::ostream & | os, |
const IntervalVar & | var | ||
) |
◆ operator<<() [3/3]
std::ostream& operations_research::sat::operator<< | ( | std::ostream & | os, |
const IntVar & | var | ||
) |
◆ SetSynchronizationFunction()
void operations_research::sat::SetSynchronizationFunction | ( | std::function< CpSolverResponse()> | f, |
Model * | model | ||
) |
If set, the underlying solver will call this function regularly in a deterministic way.
It will then wait until this function returns with the current best information about the current problem.
This is meant to be used in a multi-threaded environment with many parallel solving process. If the returned current "best" response only uses information derived at a lower deterministic time (possibly with offset) than the deterministic time of the current thread, the whole process can be made deterministic.
◆ SolutionBooleanValue()
bool operations_research::sat::SolutionBooleanValue | ( | const CpSolverResponse & | r, |
BoolVar | x | ||
) |
Evaluates the value of a Boolean literal in a solver response.
◆ SolutionIntegerMax()
int64 operations_research::sat::SolutionIntegerMax | ( | const CpSolverResponse & | r, |
IntVar | x | ||
) |
Returns the max of an integer variable in a solution.
◆ SolutionIntegerMin()
int64 operations_research::sat::SolutionIntegerMin | ( | const CpSolverResponse & | r, |
IntVar | x | ||
) |
Returns the min of an integer variable in a solution.
◆ SolutionIntegerValue()
int64 operations_research::sat::SolutionIntegerValue | ( | const CpSolverResponse & | r, |
const LinearExpr & | expr | ||
) |
Evaluates the value of an linear expression in a solver response.
◆ Solve()
CpSolverResponse operations_research::sat::Solve | ( | const CpModelProto & | model_proto | ) |
Solves the given CpModelProto and returns an instance of CpSolverResponse.
◆ SolveCpModel()
CpSolverResponse operations_research::sat::SolveCpModel | ( | const CpModelProto & | model_proto, |
Model * | model | ||
) |
Solves the given CpModelProto.
This advanced API accept a Model* which allows to access more adavanced features by configuring some classes in the Model before solve.
For instance:
- model->Add(NewSatParameters(parameters_as_string_or_proto));
- model->GetOrCreate<TimeLimit>()->RegisterExternalBooleanAsLimit(&stop);
- model->Add(NewFeasibleSolutionObserver(observer));
◆ SolveWithParameters() [1/2]
CpSolverResponse operations_research::sat::SolveWithParameters | ( | const CpModelProto & | model_proto, |
const SatParameters & | params | ||
) |
Solves the given CpModelProto with the given parameters.
◆ SolveWithParameters() [2/2]
CpSolverResponse operations_research::sat::SolveWithParameters | ( | const CpModelProto & | model_proto, |
const std::string & | params | ||
) |
Solves the given CpModelProto with the given sat parameters as string in JSon format, and returns an instance of CpSolverResponse.
Variable Documentation
◆ _AllDifferentConstraintProto_default_instance_
AllDifferentConstraintProtoDefaultTypeInternal _AllDifferentConstraintProto_default_instance_ |
◆ _AutomatonConstraintProto_default_instance_
AutomatonConstraintProtoDefaultTypeInternal _AutomatonConstraintProto_default_instance_ |
◆ _BoolArgumentProto_default_instance_
BoolArgumentProtoDefaultTypeInternal _BoolArgumentProto_default_instance_ |
◆ _BooleanAssignment_default_instance_
BooleanAssignmentDefaultTypeInternal _BooleanAssignment_default_instance_ |
◆ _CircuitConstraintProto_default_instance_
CircuitConstraintProtoDefaultTypeInternal _CircuitConstraintProto_default_instance_ |
◆ _CircuitCoveringConstraintProto_default_instance_
CircuitCoveringConstraintProtoDefaultTypeInternal _CircuitCoveringConstraintProto_default_instance_ |
◆ _ConstraintProto_default_instance_
ConstraintProtoDefaultTypeInternal _ConstraintProto_default_instance_ |
◆ _CpModelProto_default_instance_
CpModelProtoDefaultTypeInternal _CpModelProto_default_instance_ |
◆ _CpObjectiveProto_default_instance_
CpObjectiveProtoDefaultTypeInternal _CpObjectiveProto_default_instance_ |
◆ _CpSolverResponse_default_instance_
CpSolverResponseDefaultTypeInternal _CpSolverResponse_default_instance_ |
◆ _CumulativeConstraintProto_default_instance_
CumulativeConstraintProtoDefaultTypeInternal _CumulativeConstraintProto_default_instance_ |
◆ _DecisionStrategyProto_AffineTransformation_default_instance_
DecisionStrategyProto_AffineTransformationDefaultTypeInternal _DecisionStrategyProto_AffineTransformation_default_instance_ |
◆ _DecisionStrategyProto_default_instance_
DecisionStrategyProtoDefaultTypeInternal _DecisionStrategyProto_default_instance_ |
◆ _ElementConstraintProto_default_instance_
ElementConstraintProtoDefaultTypeInternal _ElementConstraintProto_default_instance_ |
◆ _IntegerArgumentProto_default_instance_
IntegerArgumentProtoDefaultTypeInternal _IntegerArgumentProto_default_instance_ |
◆ _IntegerVariableProto_default_instance_
IntegerVariableProtoDefaultTypeInternal _IntegerVariableProto_default_instance_ |
◆ _IntervalConstraintProto_default_instance_
IntervalConstraintProtoDefaultTypeInternal _IntervalConstraintProto_default_instance_ |
◆ _InverseConstraintProto_default_instance_
InverseConstraintProtoDefaultTypeInternal _InverseConstraintProto_default_instance_ |
◆ _LinearArgumentProto_default_instance_
LinearArgumentProtoDefaultTypeInternal _LinearArgumentProto_default_instance_ |
◆ _LinearBooleanConstraint_default_instance_
LinearBooleanConstraintDefaultTypeInternal _LinearBooleanConstraint_default_instance_ |
◆ _LinearBooleanProblem_default_instance_
LinearBooleanProblemDefaultTypeInternal _LinearBooleanProblem_default_instance_ |
◆ _LinearConstraintProto_default_instance_
LinearConstraintProtoDefaultTypeInternal _LinearConstraintProto_default_instance_ |
◆ _LinearExpressionProto_default_instance_
LinearExpressionProtoDefaultTypeInternal _LinearExpressionProto_default_instance_ |
◆ _LinearObjective_default_instance_
LinearObjectiveDefaultTypeInternal _LinearObjective_default_instance_ |
◆ _NoOverlap2DConstraintProto_default_instance_
NoOverlap2DConstraintProtoDefaultTypeInternal _NoOverlap2DConstraintProto_default_instance_ |
◆ _NoOverlapConstraintProto_default_instance_
NoOverlapConstraintProtoDefaultTypeInternal _NoOverlapConstraintProto_default_instance_ |
◆ _PartialVariableAssignment_default_instance_
PartialVariableAssignmentDefaultTypeInternal _PartialVariableAssignment_default_instance_ |
◆ _ReservoirConstraintProto_default_instance_
ReservoirConstraintProtoDefaultTypeInternal _ReservoirConstraintProto_default_instance_ |
◆ _RoutesConstraintProto_default_instance_
RoutesConstraintProtoDefaultTypeInternal _RoutesConstraintProto_default_instance_ |
◆ _TableConstraintProto_default_instance_
TableConstraintProtoDefaultTypeInternal _TableConstraintProto_default_instance_ |
◆ CpSolverStatus_ARRAYSIZE
|
constexpr |
Definition at line 239 of file cp_model.pb.h.
◆ CpSolverStatus_MAX
|
constexpr |
Definition at line 238 of file cp_model.pb.h.
◆ CpSolverStatus_MIN
|
constexpr |
Definition at line 237 of file cp_model.pb.h.
◆ DecisionStrategyProto_DomainReductionStrategy_DomainReductionStrategy_ARRAYSIZE
|
constexpr |
Definition at line 211 of file cp_model.pb.h.
◆ DecisionStrategyProto_DomainReductionStrategy_DomainReductionStrategy_MAX
|
constexpr |
Definition at line 210 of file cp_model.pb.h.
◆ DecisionStrategyProto_DomainReductionStrategy_DomainReductionStrategy_MIN
|
constexpr |
Definition at line 209 of file cp_model.pb.h.
◆ DecisionStrategyProto_VariableSelectionStrategy_VariableSelectionStrategy_ARRAYSIZE
|
constexpr |
Definition at line 183 of file cp_model.pb.h.
◆ DecisionStrategyProto_VariableSelectionStrategy_VariableSelectionStrategy_MAX
|
constexpr |
Definition at line 182 of file cp_model.pb.h.
◆ DecisionStrategyProto_VariableSelectionStrategy_VariableSelectionStrategy_MIN
|
constexpr |
Definition at line 181 of file cp_model.pb.h.