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

#include <gscip_solver.h>

Inheritance diagram for operations_research::math_opt::GScipSolver:
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)
 
static absl::StatusOr< GScipParameters > MergeParameters (const SolveParametersProto &solve_parameters)
 

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 51 of file gscip_solver.h.

Member Function Documentation

◆ ComputeInfeasibleSubsystem()

absl::StatusOr< ComputeInfeasibleSubsystemResultProto > operations_research::math_opt::GScipSolver::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 1353 of file gscip_solver.cc.

◆ MergeParameters()

absl::StatusOr< GScipParameters > operations_research::math_opt::GScipSolver::MergeParameters ( const SolveParametersProto & solve_parameters)
static

Returns the merged parameters and a list of warnings for unsupported parameters.

First build the result by translating common parameters to a GScipParameters, and then merging with user provided gscip_parameters. This results in user provided solver specific parameters overwriting common parameters should there be any conflict.

By default SCIP catches Ctrl-C but we don't want this behavior when the users uses SCIP through MathOpt.

GScip has also GScipSetOutputEnabled() but this changes the log level. Setting silence_output sets the quiet field on the default message handler of SCIP which removes the output. Here it is important to use this rather than changing the log level so that if the user provides a MessageCallback function they do get some messages even when enable_output is false.

We must set limits/maxsol (the internal solution pool) and limits/maxorigsol (the number solutions to attempt to transform back to the user.

Note
As of SCIP 8, limits/maxsol defaults to 100.

As SCIP is configured in ortools, this is an error, since we are not connected to any LP solver that runs barrier.

Definition at line 624 of file gscip_solver.cc.

◆ New()

absl::StatusOr< std::unique_ptr< SolverInterface > > operations_research::math_opt::GScipSolver::New ( const ModelProto & model,
const InitArgs & init_args )
static

Definition at line 986 of file gscip_solver.cc.

◆ Solve()

absl::StatusOr< SolveResultProto > operations_research::math_opt::GScipSolver::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.

Note
we must meet the invariant on GScipSolverConstraintData, that when user_callback != nullptr, all fields are filled in.
it is critical that this constraint is added after all other constraints, as otherwise, due to what appears to be a bug in SCIP, we may run our callback before checking all the constraints in the model, see https://listserv.zib.de/pipermail/scip/2023-November/004785.html.

SCIP returns "infeasible" when the model contain invalid bounds.

Flush the potential last unfinished line.

Reset solve-specific model parameters so that they do not leak into the next solve. Note that 0 is the default branching priority.

Implements operations_research::math_opt::SolverInterface.

Definition at line 1011 of file gscip_solver.cc.

◆ Update()

absl::StatusOr< bool > operations_research::math_opt::GScipSolver::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.

As of 2022-09-12 we do not support quadratic objective updates. Therefore, if we already have a quadratic objective stored, we reject any update that changes the objective sense (which would break the epi-/hypo-graph formulation) or changes any quadratic objective coefficients.

New variables' coefficient is set when the variables are added below.

Here the model_update.linear_constraint_matrix_updates is split into three sub-matrix:

existing new
columns columns
/ | \
existing | 1 | 2 |
rows | | |
|---------+---------|
new | |
rows | 3 |
\ /

The coefficients of sub-matrix 1 are set by UpdateLinearConstraints(), the ones of sub-matrix 2 by AddVariables() and the ones of the sub-matrix 3 by AddLinearConstraints(). The rationale here is that SCIPchgCoefLinear() has a complexity of O(non_zeros). Thus it is inefficient and can lead to O(n^2) behaviors if it was used for new rows or for new columns. For new rows it is more efficient to pass all the variables coefficients at once when building the constraints. For new columns and existing rows, since we can assume there is no existing coefficient, we can use SCIPaddCoefLinear() which is O(1). This leads to only use SCIPchgCoefLinear() for changing the coefficients of existing rows and columns.

Todo
(b/215722113): maybe we could use SCIPaddCoefLinear() for sub-matrix 1.

Add new variables.

Update linear constraints properties and sub-matrix 1.

Update the sub-matrix 2.

See above why we use AddLinearConstraintCoef().

Add the new constraints and sets sub-matrix 3.

Quadratic constraint updates.

Indicator constraint updates.

SOS1 constraint updates.

SOS2 constraint updates.

Implements operations_research::math_opt::SolverInterface.

Definition at line 1175 of file gscip_solver.cc.


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