Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
ortools.math_opt.python.solve Namespace Reference

Classes

class  IncrementalSolver
 

Functions

result.SolveResult solve (model.Model opt_model, parameters.SolverType solver_type, *, Optional[parameters.SolveParameters] params=None, Optional[model_parameters.ModelSolveParameters] model_params=None, Optional[message_callback.SolveMessageCallback] msg_cb=None, Optional[callback.CallbackRegistration] callback_reg=None, Optional[SolveCallback] cb=None)
 
compute_infeasible_subsystem_result.ComputeInfeasibleSubsystemResult compute_infeasible_subsystem (model.Model opt_model, parameters.SolverType solver_type, *, Optional[parameters.SolveParameters] params=None, Optional[message_callback.SolveMessageCallback] msg_cb=None)
 
Exception _status_not_ok_to_exception (StatusNotOk err)
 

Variables

 SolveCallback = Callable[[callback.CallbackData], callback.CallbackResult]
 

Detailed Description

Solve optimization problems, as defined by Model in model.py.

Function Documentation

◆ _status_not_ok_to_exception()

Exception ortools.math_opt.python.solve._status_not_ok_to_exception ( StatusNotOk err)
protected
Converts a StatusNotOk to the best matching Python exception.

Args:
  err: The input errors.

Returns:
  The corresponding exception.

Definition at line 275 of file solve.py.

◆ compute_infeasible_subsystem()

compute_infeasible_subsystem_result.ComputeInfeasibleSubsystemResult ortools.math_opt.python.solve.compute_infeasible_subsystem ( model.Model opt_model,
parameters.SolverType solver_type,
* ,
Optional[parameters.SolveParameters] params = None,
Optional[message_callback.SolveMessageCallback] msg_cb = None )
Computes an infeasible subsystem of the input model.

Args:
  opt_model: The optimization model to check for infeasibility.
  solver_type: Which solver to use to compute the infeasible subsystem. As of
    August 2023, the only supported solver is Gurobi.
  params: Configuration of the underlying solver.
  msg_cb: A callback that gives back the underlying solver's logs by the line.

Returns:
  An `ComputeInfeasibleSubsystemResult` where `feasibility` indicates if the
  problem was proven infeasible.

Throws:
  RuntimeError: on invalid inputs or an internal solver error.

Definition at line 95 of file solve.py.

◆ solve()

result.SolveResult ortools.math_opt.python.solve.solve ( model.Model opt_model,
parameters.SolverType solver_type,
* ,
Optional[parameters.SolveParameters] params = None,
Optional[model_parameters.ModelSolveParameters] model_params = None,
Optional[message_callback.SolveMessageCallback] msg_cb = None,
Optional[callback.CallbackRegistration] callback_reg = None,
Optional[SolveCallback] cb = None )
Solves an optimization model.

Thread-safety: this function must not be called while modifying the Model
(adding variables...). Some solvers may add more restriction regarding
threading. Please see SolverType::XXX documentation for details.

Args:
  opt_model: The optimization model.
  solver_type: The underlying solver to use.
  params: Configuration of the underlying solver.
  model_params: Configuration of the solver that is model specific.
  msg_cb: A callback that gives back the underlying solver's logs by the line.
  callback_reg: Configures when the callback will be invoked (if provided) and
    what data will be collected to access in the callback.
  cb: A callback that will be called periodically as the solver runs.

Returns:
  A SolveResult containing the termination reason, solution(s) and stats.

Raises:
  RuntimeError: On a solve error.

Definition at line 34 of file solve.py.

Variable Documentation

◆ SolveCallback

ortools.math_opt.python.solve.SolveCallback = Callable[[callback.CallbackData], callback.CallbackResult]

Definition at line 31 of file solve.py.