Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::math_opt::HighsSolver Class Reference

#include <highs_solver.h>

Inheritance diagram for operations_research::math_opt::HighsSolver:
operations_research::math_opt::SolverInterface

Public Member Functions

absl::StatusOr< SolveResultProto > Solve (const SolveParametersProto &parameters, 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 &parameters, MessageCallback message_cb, const SolveInterrupter *interrupter) override
 
- Public Member Functions inherited from operations_research::math_opt::SolverInterface
 SolverInterface ()=default
 
 SolverInterface (const SolverInterface &)=delete
 
SolverInterfaceoperator= (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
 

Detailed Description

Definition at line 41 of file highs_solver.h.

Member Function Documentation

◆ ComputeInfeasibleSubsystem()

absl::StatusOr< ComputeInfeasibleSubsystemResultProto > operations_research::math_opt::HighsSolver::ComputeInfeasibleSubsystem ( const SolveParametersProto & parameters,
MessageCallback message_cb,
const SolveInterrupter * interrupter )
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 1009 of file highs_solver.cc.

◆ New()

absl::StatusOr< std::unique_ptr< SolverInterface > > operations_research::math_opt::HighsSolver::New ( const ModelProto & model,
const InitArgs & init_args )
static
Note
HiGHS issues a warning if lp.integrality_ is nonempty but all variables are continuous. It would be nice to disable this warning, as we should always just set this, otherwise incrementalism is just more complicated.

See https://github.com/ERGO-Code/HiGHS/blob/master/src/lp_data/HighsLpUtils.cpp#L535

If the bounds are crossed, we give an error at solve time (unless they are uncrossed before the solve begins). Passing crossed bounds to HiGHS here causes Highs:passModel() below to fail, but we don't want to fail in New(). So we pass dummy values instead temporarily.

Todo
(b/271595607): once HiGHS is updated, check if the unrounded bounds cross instead.
Todo
(b/271595607): once HiGHS is updated, pass the original bound, not the rounded bound.

See comment above for the case when a variable lb > ub, we need to avoid an immediate error in New().

Disable output immediately, calling passModel() below will generate output otherwise.

Definition at line 787 of file highs_solver.cc.

◆ Solve()

absl::StatusOr< SolveResultProto > operations_research::math_opt::HighsSolver::Solve ( const SolveParametersProto & parameters,
const ModelSolveParametersProto & model_parameters,
MessageCallback message_cb,
const CallbackRegistrationProto & callback_registration,
Callback cb,
const SolveInterrupter * interrupter )
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.

Todo
(b/271595607): delete this code once we upgrade HiGHS, if HiGHS does return a proper infeasibility status for models with empty integer bounds.

As of March 6th, 2023, this code never returns an error (see the HiGHS source). If we really want to be able to recover from errors, more care is needed, as we need to prevent HiGHS from invoking the user callback after this function, since it will not be alive (e.g. wrap the user callback in a new callback that is guarded by an atomic bool that we disable here). Further, to propagate this error, we need a class instead of absl::Cleanup.

Note
lp_.integrality_ may be empty if the problem is an LP.

When the model is empty, highs_->getInfo() is invalid, so we bail out.

Implements operations_research::math_opt::SolverInterface.

Definition at line 906 of file highs_solver.cc.

◆ Update()

absl::StatusOr< bool > operations_research::math_opt::HighsSolver::Update ( const ModelUpdateProto & model_update)
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 1004 of file highs_solver.cc.


The documentation for this class was generated from the following files: