14#ifndef OR_TOOLS_MATH_OPT_CORE_SOLVER_INTERFACE_H_
15#define OR_TOOLS_MATH_OPT_CORE_SOLVER_INTERFACE_H_
22#include "absl/base/attributes.h"
23#include "absl/container/flat_hash_map.h"
24#include "absl/status/statusor.h"
25#include "absl/strings/string_view.h"
26#include "absl/synchronization/mutex.h"
27#include "ortools/math_opt/callback.pb.h"
29#include "ortools/math_opt/infeasible_subsystem.pb.h"
30#include "ortools/math_opt/model.pb.h"
31#include "ortools/math_opt/model_parameters.pb.h"
32#include "ortools/math_opt/model_update.pb.h"
33#include "ortools/math_opt/parameters.pb.h"
34#include "ortools/math_opt/result.pb.h"
76 using Callback = std::function<absl::StatusOr<CallbackResultProto>(
77 const CallbackDataProto&)>;
89 std::function<absl::StatusOr<std::unique_ptr<SolverInterface>>(
120 virtual absl::StatusOr<SolveResultProto>
Solve(
122 const ModelSolveParametersProto& model_parameters,
124 const CallbackRegistrationProto& callback_registration,
Callback cb,
132 virtual absl::StatusOr<bool>
Update(
const ModelUpdateProto& model_update) = 0;
151 virtual absl::StatusOr<ComputeInfeasibleSubsystemResultProto>
173 absl::StatusOr<std::unique_ptr<SolverInterface>>
Create(
174 SolverTypeProto solver_type,
const ModelProto&
model,
189 mutable absl::Mutex mutex_;
190 absl::flat_hash_map<SolverTypeProto, SolverInterface::Factory>
204#define MATH_OPT_REGISTER_SOLVER(solver_type, solver_factory) \
206 const void* const kRegisterSolver ABSL_ATTRIBUTE_UNUSED = [] { \
207 AllSolversRegistry::Instance()->Register(solver_type, solver_factory); \
bool IsRegistered(SolverTypeProto solver_type) const
Whether a solver type is supported.
AllSolversRegistry & operator=(const AllSolversRegistry &)=delete
std::vector< SolverTypeProto > RegisteredSolvers() const
List all supported solver types.
void Register(SolverTypeProto solver_type, SolverInterface::Factory factory)
static AllSolversRegistry * Instance()
std::string RegisteredSolversToString() const
Returns a human-readable list of supported solver types.
absl::StatusOr< std::unique_ptr< SolverInterface > > Create(SolverTypeProto solver_type, const ModelProto &model, const SolverInterface::InitArgs &init_args) const
AllSolversRegistry(const AllSolversRegistry &)=delete
SolverInterface(const SolverInterface &)=delete
std::function< void(const std::vector< std::string > &)> MessageCallback
SolverInterface()=default
virtual absl::StatusOr< bool > Update(const ModelUpdateProto &model_update)=0
std::function< absl::StatusOr< CallbackResultProto >( const CallbackDataProto &)> Callback
virtual absl::StatusOr< SolveResultProto > Solve(const SolveParametersProto ¶meters, const ModelSolveParametersProto &model_parameters, MessageCallback message_cb, const CallbackRegistrationProto &callback_registration, Callback cb, const SolveInterrupter *interrupter)=0
virtual ~SolverInterface()=default
SolverInterface & operator=(const SolverInterface &)=delete
std::function< absl::StatusOr< std::unique_ptr< SolverInterface > >( const ModelProto &model, const InitArgs &init_args)> Factory
virtual absl::StatusOr< ComputeInfeasibleSubsystemResultProto > ComputeInfeasibleSubsystem(const SolveParametersProto ¶meters, MessageCallback message_cb, const SolveInterrupter *interrupter)=0
In SWIG mode, we don't want anything besides these top-level includes.
Initialization arguments.
SolverInitializerProto streamable
const NonStreamableSolverInitArguments * non_streamable