Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <cp_sat_solver.h>
Public Member Functions | |
absl::StatusOr< SolveResultProto > | Solve (const SolveParametersProto ¶meters, const ModelSolveParametersProto &model_parameters, MessageCallback message_cb, const CallbackRegistrationProto &callback_registration, Callback cb, const SolveInterrupter *interrupter) override |
absl::StatusOr< bool > | Update (const ModelUpdateProto &model_update) override |
absl::StatusOr< ComputeInfeasibleSubsystemResultProto > | ComputeInfeasibleSubsystem (const SolveParametersProto ¶meters, MessageCallback message_cb, const SolveInterrupter *interrupter) override |
Public Member Functions inherited from operations_research::math_opt::SolverInterface | |
SolverInterface ()=default | |
SolverInterface (const SolverInterface &)=delete | |
SolverInterface & | operator= (const SolverInterface &)=delete |
virtual | ~SolverInterface ()=default |
Static Public Member Functions | |
static absl::StatusOr< std::unique_ptr< SolverInterface > > | New (const ModelProto &model, const InitArgs &init_args) |
Additional Inherited Members | |
Public Types inherited from operations_research::math_opt::SolverInterface | |
using | MessageCallback = std::function<void(const std::vector<std::string>&)> |
using | Callback |
using | Factory |
Definition at line 39 of file cp_sat_solver.h.
|
overridevirtual |
Computes a infeasible subsystem of the model (including all updates).
All input arguments are ensured (by solver.cc) to be valid. Furthermore, since all parameters are references or functions (which could be a lambda expression), the implementation should not keep a reference or copy of them, as they may become invalid reference after the invocation if this function.
The parameters message_cb
and interrupter
are optional. They are nullptr when not set.
When parameter message_cb
is not null the value of parameters.enable_output should be ignored the solver should behave as it is was false (i.e. not print anything).
When parameter message_cb
is not null and the underlying solver does not supports message callbacks, it should ignore it.
Implements operations_research::math_opt::SolverInterface.
Definition at line 529 of file cp_sat_solver.cc.
|
static |
Definition at line 321 of file cp_sat_solver.cc.
|
overridevirtual |
Solves the current model (included all updates).
All input arguments are ensured (by solver.cc) to be valid. Furthermore, since all parameters are references or functions (which could be a lambda expression), the implementation should not keep a reference or copy of them, as they may become invalid reference after the invocation if this function.
Parameters message_cb
, cb
and interrupter
are optional. They are nullptr when not set.
When parameter message_cb
is not null the value of parameters.enable_output should be ignored the solver should behave as it is was false (i.e. not print anything).
When parameter message_cb
is not null and the underlying solver does not supports message callbacks, it should ignore it.
Solvers should return a InvalidArgumentError when called with events on callback_registration that are not supported by the solver for the type of model being solved (for example MIP events if the model is an LP, or events that are not emitted by the solver). Solvers should use CheckRegisteredCallbackEvents() to implement that.
We need not check callback_registration.add_cuts, as cuts can only be added at event MIP_NODE which we have already validated is not supported.
Here we must make a copy since Solve() can be called multiple times with different parameters. Hence we can't move cp_sat_model
.
We need to chain the user interrupter through a local interrupter, because if we termiante early from a callback request, we don't want to incorrectly modify the input state.
Setup a callback on the user provided so that we interrupt the solver.
A previous callback failed.
Note cb_result.cuts and cb_result.suggested solutions are not supported by CP-SAT and we have validated they are empty.
CP-SAT returns "infeasible" for inverted bounds.
Implements operations_research::math_opt::SolverInterface.
Definition at line 336 of file cp_sat_solver.cc.
|
overridevirtual |
Updates the model to solve and returns true, or returns false if this update is not supported.
The implementation should assume the input ModelUpdate is valid and is free to assert if this is not the case.
Implements operations_research::math_opt::SolverInterface.
Definition at line 479 of file cp_sat_solver.cc.