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 | 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) |
Function Documentation
◆ CpModelStats()
std::string CpModelStats | ( | const CpModelProto & | model | ) |
Returns a string with some statistics on the given CpModelProto.
◆ CpSolverResponseStats()
std::string 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.
◆ NewFeasibleSolutionObserver()
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){...}));.
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 *)> NewSatParameters | ( | const SatParameters & | parameters | ) |
◆ NewSatParameters() [2/2]
std::function< SatParameters(Model *)> 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 & operator<< | ( | std::ostream & | os, |
const BoolVar & | var | ||
) |
◆ operator<<() [2/3]
std::ostream & operator<< | ( | std::ostream & | os, |
const IntervalVar & | var | ||
) |
◆ operator<<() [3/3]
std::ostream & operator<< | ( | std::ostream & | os, |
const IntVar & | var | ||
) |
◆ SetSynchronizationFunction()
void 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 SolutionBooleanValue | ( | const CpSolverResponse & | r, |
BoolVar | x | ||
) |
Evaluates the value of a Boolean literal in a solver response.
◆ SolutionIntegerMax()
int64 SolutionIntegerMax | ( | const CpSolverResponse & | r, |
IntVar | x | ||
) |
Returns the max of an integer variable in a solution.
◆ SolutionIntegerMin()
int64 SolutionIntegerMin | ( | const CpSolverResponse & | r, |
IntVar | x | ||
) |
Returns the min of an integer variable in a solution.
◆ SolutionIntegerValue()
int64 SolutionIntegerValue | ( | const CpSolverResponse & | r, |
const LinearExpr & | expr | ||
) |
Evaluates the value of an linear expression in a solver response.
◆ Solve()
CpSolverResponse Solve | ( | const CpModelProto & | model_proto | ) |
Solves the given CpModelProto and returns an instance of CpSolverResponse.
◆ SolveCpModel()
CpSolverResponse 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 SolveWithParameters | ( | const CpModelProto & | model_proto, |
const SatParameters & | params | ||
) |
Solves the given CpModelProto with the given parameters.
◆ SolveWithParameters() [2/2]
CpSolverResponse 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.