Google OR-Tools v9.12
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
ortools.math_opt.python.parameters.SolveParameters Class Reference

Public Member Functions

math_opt_parameters_pb2.SolveParametersProto to_proto (self)
 

Static Public Attributes

Optional time_limit = None
 
Optional iteration_limit = None
 
Optional node_limit = None
 
Optional cutoff_limit = None
 
Optional objective_limit = None
 
Optional best_bound_limit = None
 
Optional solution_limit = None
 
bool enable_output = False
 
Optional threads = None
 
Optional random_seed = None
 
Optional absolute_gap_tolerance = None
 
Optional relative_gap_tolerance = None
 
Optional solution_pool_size = None
 
Optional lp_algorithm = None
 
Optional presolve = None
 
Optional cuts = None
 
Optional heuristics = None
 
Optional scaling = None
 
gscip_pb2 gscip
 
GurobiParameters gurobi = dataclasses.field(default_factory=GurobiParameters)
 
glop_parameters_pb2 glop
 
sat_parameters_pb2 cp_sat
 
pdlp_solvers_pb2 pdlp
 
osqp_pb2 osqp
 
GlpkParameters glpk = dataclasses.field(default_factory=GlpkParameters)
 
highs_pb2 highs
 

Detailed Description

Parameters to control a single solve.

If a value is set in both common and solver specific field (e.g. gscip), the
solver specific setting 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 ModelSolveParameters.

See solve() and IncrementalSolver.solve() in solve.py for more details.

Attributes:
time_limit: The maximum time a solver should spend on the problem, or if
  None, then the time limit is infinite. This value is not a hard limit,
  solve time may slightly exceed this value. This parameter is always passed
  to the underlying solver, the solver default is not used.
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.
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.
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
  TerminationReason.NO_SOLUTION_FOUND and with Limit.CUTOFF 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.
objective_limit: The solver stops early as soon as it finds a solution at
  least this good, with TerminationReason.FEASIBLE and Limit.OBJECTIVE.
best_bound_limit: The solver stops early as soon as it proves the best bound
  is at least this good, with TerminationReason of FEASIBLE or
  NO_SOLUTION_FOUND and Limit.OBJECTIVE. See the user guide for more details
  and a comparison with cutoff_limit.
solution_limit: The solver stops early after finding this many feasible
  solutions, with TerminationReason.FEASIBLE and Limit.SOLUTION. Must be
  greater than zero if set. It is often used 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.
enable_output: If the solver should print out its log messages.
threads: An integer >= 1, how many threads to use when solving.
random_seed: Seed for the pseudo-random number generator in the underlying
  solver. 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)).
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.OPTIMAL.
  Must be >= 0 if set. See also relative_gap_tolerance.
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.OPTIMAL. Must be >= 0 if set. See also
  absolute_gap_tolerance.
solution_pool_size: Maintain up to `solution_pool_size` solutions while
  searching. The solution pool generally has two functions:
    * For solvers that can return more than one solution, this limits how
      many solutions will be returned.
    * 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.
lp_algorithm: The algorithm for solving a linear program. If UNSPECIFIED,
  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).
presolve: Effort on simplifying the problem before starting the main
  algorithm (e.g. simplex).
cuts: Effort on getting a stronger LP relaxation (MIP only). Note that in
  some solvers, disabling cuts may prevent callbacks from having a chance to
  add cuts at MIP_NODE.
heuristics: Effort in finding feasible solutions beyond those encountered in
  the complete search procedure.
scaling: Effort in rescaling the problem to improve numerical stability.
gscip: GSCIP specific solve parameters.
gurobi: Gurobi specific solve parameters.
glop: Glop specific solve parameters.
cp_sat: CP-SAT specific solve parameters.
pdlp: PDLP specific solve parameters.
osqp: OSQP specific solve parameters. Users should prefer the generic
  MathOpt parameters over OSQP-level parameters, when available: - Prefer
  SolveParameters.enable_output to OsqpSettingsProto.verbose. - Prefer
  SolveParameters.time_limit to OsqpSettingsProto.time_limit. - Prefer
  SolveParameters.iteration_limit to OsqpSettingsProto.iteration_limit. - If
  a less granular configuration is acceptable, prefer
  SolveParameters.scaling to OsqpSettingsProto.
glpk: GLPK specific solve parameters.
highs: HiGHS specific solve parameters.

Definition at line 269 of file parameters.py.

Member Function Documentation

◆ to_proto()

math_opt_parameters_pb2.SolveParametersProto ortools.math_opt.python.parameters.SolveParameters.to_proto ( self)
Returns a protocol buffer equivalent to this.

Definition at line 418 of file parameters.py.

Member Data Documentation

◆ absolute_gap_tolerance

Optional ortools.math_opt.python.parameters.SolveParameters.absolute_gap_tolerance = None
static

Definition at line 389 of file parameters.py.

◆ best_bound_limit

Optional ortools.math_opt.python.parameters.SolveParameters.best_bound_limit = None
static

Definition at line 384 of file parameters.py.

◆ cp_sat

sat_parameters_pb2 ortools.math_opt.python.parameters.SolveParameters.cp_sat
static
Initial value:
= dataclasses.field(
default_factory=sat_parameters_pb2.SatParameters
)

Definition at line 404 of file parameters.py.

◆ cutoff_limit

Optional ortools.math_opt.python.parameters.SolveParameters.cutoff_limit = None
static

Definition at line 382 of file parameters.py.

◆ cuts

Optional ortools.math_opt.python.parameters.SolveParameters.cuts = None
static

Definition at line 394 of file parameters.py.

◆ enable_output

bool ortools.math_opt.python.parameters.SolveParameters.enable_output = False
static

Definition at line 386 of file parameters.py.

◆ glop

glop_parameters_pb2 ortools.math_opt.python.parameters.SolveParameters.glop
static
Initial value:
= dataclasses.field(
default_factory=glop_parameters_pb2.GlopParameters
)

Definition at line 401 of file parameters.py.

◆ glpk

GlpkParameters ortools.math_opt.python.parameters.SolveParameters.glpk = dataclasses.field(default_factory=GlpkParameters)
static

Definition at line 413 of file parameters.py.

◆ gscip

gscip_pb2 ortools.math_opt.python.parameters.SolveParameters.gscip
static
Initial value:
= dataclasses.field(
default_factory=gscip_pb2.GScipParameters
)

Definition at line 397 of file parameters.py.

◆ gurobi

GurobiParameters ortools.math_opt.python.parameters.SolveParameters.gurobi = dataclasses.field(default_factory=GurobiParameters)
static

Definition at line 400 of file parameters.py.

◆ heuristics

Optional ortools.math_opt.python.parameters.SolveParameters.heuristics = None
static

Definition at line 395 of file parameters.py.

◆ highs

highs_pb2 ortools.math_opt.python.parameters.SolveParameters.highs
static
Initial value:
= dataclasses.field(
default_factory=highs_pb2.HighsOptionsProto
)

Definition at line 414 of file parameters.py.

◆ iteration_limit

Optional ortools.math_opt.python.parameters.SolveParameters.iteration_limit = None
static

Definition at line 380 of file parameters.py.

◆ lp_algorithm

Optional ortools.math_opt.python.parameters.SolveParameters.lp_algorithm = None
static

Definition at line 392 of file parameters.py.

◆ node_limit

Optional ortools.math_opt.python.parameters.SolveParameters.node_limit = None
static

Definition at line 381 of file parameters.py.

◆ objective_limit

Optional ortools.math_opt.python.parameters.SolveParameters.objective_limit = None
static

Definition at line 383 of file parameters.py.

◆ osqp

osqp_pb2 ortools.math_opt.python.parameters.SolveParameters.osqp
static
Initial value:
= dataclasses.field(
default_factory=osqp_pb2.OsqpSettingsProto
)

Definition at line 410 of file parameters.py.

◆ pdlp

pdlp_solvers_pb2 ortools.math_opt.python.parameters.SolveParameters.pdlp
static
Initial value:
= dataclasses.field(
default_factory=pdlp_solvers_pb2.PrimalDualHybridGradientParams
)

Definition at line 407 of file parameters.py.

◆ presolve

Optional ortools.math_opt.python.parameters.SolveParameters.presolve = None
static

Definition at line 393 of file parameters.py.

◆ random_seed

Optional ortools.math_opt.python.parameters.SolveParameters.random_seed = None
static

Definition at line 388 of file parameters.py.

◆ relative_gap_tolerance

Optional ortools.math_opt.python.parameters.SolveParameters.relative_gap_tolerance = None
static

Definition at line 390 of file parameters.py.

◆ scaling

Optional ortools.math_opt.python.parameters.SolveParameters.scaling = None
static

Definition at line 396 of file parameters.py.

◆ solution_limit

Optional ortools.math_opt.python.parameters.SolveParameters.solution_limit = None
static

Definition at line 385 of file parameters.py.

◆ solution_pool_size

Optional ortools.math_opt.python.parameters.SolveParameters.solution_pool_size = None
static

Definition at line 391 of file parameters.py.

◆ threads

Optional ortools.math_opt.python.parameters.SolveParameters.threads = None
static

Definition at line 387 of file parameters.py.

◆ time_limit

ortools.math_opt.python.parameters.SolveParameters.time_limit = None
static

Definition at line 379 of file parameters.py.


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