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

#include <parameters.h>

Public Member Functions

SolveParametersProto Proto () const
 

Static Public Member Functions

static absl::StatusOr< SolveParametersFromProto (const SolveParametersProto &proto)
 

Public Attributes

bool enable_output = false
 
absl::Duration time_limit = absl::InfiniteDuration()
 
std::optional< int64_t > iteration_limit
 
std::optional< int64_t > node_limit
 
std::optional< double > cutoff_limit
 
std::optional< double > objective_limit
 
std::optional< double > best_bound_limit
 
std::optional< int32_t > solution_limit
 
std::optional< int32_t > threads
 If unset, use the solver default. If set, it must be >= 1.
 
std::optional< int32_t > random_seed
 
std::optional< double > absolute_gap_tolerance
 
std::optional< double > relative_gap_tolerance
 
std::optional< int32_t > solution_pool_size
 
std::optional< LPAlgorithmlp_algorithm
 
std::optional< Emphasispresolve
 
std::optional< Emphasiscuts
 
std::optional< Emphasisheuristics
 
std::optional< Emphasisscaling
 
GScipParameters gscip
 
GurobiParameters gurobi
 
glop::GlopParameters glop
 
sat::SatParameters cp_sat
 
pdlp::PrimalDualHybridGradientParams pdlp
 
GlpkParameters glpk
 
HighsOptionsProto highs
 

Detailed Description

Parameters to control a single solve.

Contains both parameters common to all solvers, e.g. time_limit, and parameters for a specific solver, e.g. gscip. If a value is set in both common and solver specific fields, the solver specific setting is used.

The common parameters that are optional and unset indicate that the solver default is used.

Solver specific parameters for solvers other than the one in use are ignored.

Parameters that depends on the model (e.g. branching priority is set for each variable) are passed in ModelSolveParametersProto.

Definition at line 265 of file parameters.h.

Member Function Documentation

◆ FromProto()

absl::StatusOr< SolveParameters > operations_research::math_opt::SolveParameters::FromProto ( const SolveParametersProto & proto)
static

Definition at line 270 of file parameters.cc.

◆ Proto()

SolveParametersProto operations_research::math_opt::SolveParameters::Proto ( ) const

Definition at line 215 of file parameters.cc.

Member Data Documentation

◆ absolute_gap_tolerance

std::optional<double> operations_research::math_opt::SolveParameters::absolute_gap_tolerance

An absolute optimality tolerance (primarily) for MIP solvers.

The absolute GAP is the absolute value of the difference between:

  • the objective value of the best feasible solution found,
  • the dual bound produced by the search. The solver can stop once the absolute GAP is at most absolute_gap_tolerance (when set), and return TerminationReason::kOptimal.

Must be >= 0 if set.

See also relative_gap_tolerance.

Definition at line 360 of file parameters.h.

◆ best_bound_limit

std::optional<double> operations_research::math_opt::SolveParameters::best_bound_limit

The solver stops early as soon as it proves the best bound is at least this good, with termination reason kFeasible or kNoSolutionFound and limit kObjective.

See the user guide for a comparison with cutoff_limit.

Definition at line 317 of file parameters.h.

◆ cp_sat

sat::SatParameters operations_research::math_opt::SolveParameters::cp_sat

Definition at line 418 of file parameters.h.

◆ cutoff_limit

std::optional<double> operations_research::math_opt::SolveParameters::cutoff_limit

The solver stops early if it can prove there are no primal solutions at least as good as cutoff.

On an early stop, the solver returns termination reason kNoSolutionFound and with limit kCutoff and is not required to give any extra solution information. Has no effect on the return value if there is no early stop.

It is recommended that you use a tolerance if you want solutions with objective exactly equal to cutoff to be returned.

See the user guide for more details and a comparison with best_bound_limit.

Definition at line 306 of file parameters.h.

◆ cuts

std::optional<Emphasis> operations_research::math_opt::SolveParameters::cuts

Effort on getting a stronger LP relaxation (MIP only) or the solver default effort level if unset.

Note
disabling cuts may prevent callbacks from having a chance to add cuts at MIP_NODE, this behavior is solver specific.

Definition at line 404 of file parameters.h.

◆ enable_output

bool operations_research::math_opt::SolveParameters::enable_output = false

Enables printing the solver implementation traces. These traces are sent to the standard output stream.

Note
if the user registers a message callback, then this parameter value is ignored and no traces are printed.

Definition at line 271 of file parameters.h.

◆ glop

glop::GlopParameters operations_research::math_opt::SolveParameters::glop

Definition at line 417 of file parameters.h.

◆ glpk

GlpkParameters operations_research::math_opt::SolveParameters::glpk

Definition at line 421 of file parameters.h.

◆ gscip

GScipParameters operations_research::math_opt::SolveParameters::gscip

Definition at line 415 of file parameters.h.

◆ gurobi

GurobiParameters operations_research::math_opt::SolveParameters::gurobi

Definition at line 416 of file parameters.h.

◆ heuristics

std::optional<Emphasis> operations_research::math_opt::SolveParameters::heuristics

Effort in finding feasible solutions beyond those encountered in the complete search procedure (MIP only), or the solver default effort level if unset.

Definition at line 409 of file parameters.h.

◆ highs

HighsOptionsProto operations_research::math_opt::SolveParameters::highs

Definition at line 422 of file parameters.h.

◆ iteration_limit

std::optional<int64_t> operations_research::math_opt::SolveParameters::iteration_limit

Limit on the iterations of the underlying algorithm (e.g. simplex pivots). The specific behavior is dependent on the solver and algorithm used, but often can give a deterministic solve limit (further configuration may be needed, e.g. one thread).

Typically supported by LP, QP, and MIP solvers, but for MIP solvers see also node_limit.

Definition at line 286 of file parameters.h.

◆ lp_algorithm

std::optional<LPAlgorithm> operations_research::math_opt::SolveParameters::lp_algorithm

The algorithm for solving a linear program. If nullopt, use the solver default algorithm.

For problems that are not linear programs but where linear programming is a subroutine, solvers may use this value. E.g. MIP solvers will typically use this for the root LP solve only (and use dual simplex otherwise).

Definition at line 393 of file parameters.h.

◆ node_limit

std::optional<int64_t> operations_research::math_opt::SolveParameters::node_limit

Limit on the number of subproblems solved in enumerative search (e.g. branch and bound). For many solvers this can be used to deterministically limit computation (further configuration may be needed, e.g. one thread).

Typically for MIP solvers, see also iteration_limit.

Definition at line 293 of file parameters.h.

◆ objective_limit

std::optional<double> operations_research::math_opt::SolveParameters::objective_limit

The solver stops early as soon as it finds a solution at least this good, with termination reason kFeasible and limit kObjective.

Definition at line 310 of file parameters.h.

◆ pdlp

pdlp::PrimalDualHybridGradientParams operations_research::math_opt::SolveParameters::pdlp

Definition at line 419 of file parameters.h.

◆ presolve

std::optional<Emphasis> operations_research::math_opt::SolveParameters::presolve

Effort on simplifying the problem before starting the main algorithm, or the solver default effort level if unset.

Definition at line 397 of file parameters.h.

◆ random_seed

std::optional<int32_t> operations_research::math_opt::SolveParameters::random_seed

Seed for the pseudo-random number generator in the underlying solver. Note that all solvers use pseudo-random numbers to select things such as perturbation in the LP algorithm, for tie-break-up rules, and for heuristic fixings. Varying this can have a noticeable impact on solver behavior.

Although all solvers have a concept of seeds, note that valid values depend on the actual solver.

  • Gurobi: [0:GRB_MAXINT] (which as of Gurobi 9.0 is 2x10^9).
  • GSCIP: [0:2147483647] (which is MAX_INT or kint32max or 2^31-1).
  • GLOP: [0:2147483647] (same as above) In all cases, the solver will receive a value equal to: MAX(0, MIN(MAX_VALID_VALUE_FOR_SOLVER, random_seed)).

Definition at line 347 of file parameters.h.

◆ relative_gap_tolerance

std::optional<double> operations_research::math_opt::SolveParameters::relative_gap_tolerance

A relative optimality tolerance (primarily) for MIP solvers.

The relative GAP is a normalized version of the absolute GAP (defined on absolute_gap_tolerance), where the normalization is solver-dependent, e.g. the absolute GAP divided by the objective value of the best feasible solution found.

The solver can stop once the relative GAP is at most relative_gap_tolerance (when set), and return TerminationReason::kOptimal.

Must be >= 0 if set.

See also absolute_gap_tolerance.

Definition at line 375 of file parameters.h.

◆ scaling

std::optional<Emphasis> operations_research::math_opt::SolveParameters::scaling

Effort in rescaling the problem to improve numerical stability, or the solver default effort level if unset.

Definition at line 413 of file parameters.h.

◆ solution_limit

std::optional<int32_t> operations_research::math_opt::SolveParameters::solution_limit

The solver stops early after finding this many feasible solutions, with termination reason kFeasible and limit kSolution. Must be greater than zero if set. It is often used to get the solver to stop on the first feasible solution found. Note that there is no guarantee on the objective value for any of the returned solutions.

Solvers will typically not return more solutions than the solution limit, but this is not enforced by MathOpt, see also b/214041169.

Currently supported for Gurobi and SCIP, and for CP-SAT only with value 1.

Definition at line 329 of file parameters.h.

◆ solution_pool_size

std::optional<int32_t> operations_research::math_opt::SolveParameters::solution_pool_size

Maintain up to solution_pool_size solutions while searching. The solution pool generally has two functions: (1) For solvers that can return more than one solution, this limits how many solutions will be returned. (2) Some solvers may run heuristics using solutions from the solution pool, so changing this value may affect the algorithm's path. To force the solver to fill the solution pool, e.g. with the n best solutions, requires further, solver specific configuration.

Definition at line 385 of file parameters.h.

◆ threads

std::optional<int32_t> operations_research::math_opt::SolveParameters::threads

If unset, use the solver default. If set, it must be >= 1.

Definition at line 332 of file parameters.h.

◆ time_limit

absl::Duration operations_research::math_opt::SolveParameters::time_limit = absl::InfiniteDuration()

Maximum time a solver should spend on the problem.

This value is not a hard limit, solve time may slightly exceed this value. Always passed to the underlying solver, the solver default is not used.

Definition at line 277 of file parameters.h.


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