5. conv_opt package¶
5.1. Subpackages¶
- 5.1.1. conv_opt.solver package
- 5.1.1.1. Submodules
- 5.1.1.2. conv_opt.solver.cbc module
- 5.1.1.3. conv_opt.solver.cplex module
- 5.1.1.4. conv_opt.solver.cvxopt module
- 5.1.1.5. conv_opt.solver.cvxpy module
- 5.1.1.6. conv_opt.solver.cylp module
- 5.1.1.7. conv_opt.solver.glpk module
- 5.1.1.8. conv_opt.solver.gurobi module
- 5.1.1.9. conv_opt.solver.minos module
- 5.1.1.10. conv_opt.solver.mosek module
- 5.1.1.11. conv_opt.solver.optlang module
- 5.1.1.12. conv_opt.solver.quadprog module
- 5.1.1.13. conv_opt.solver.scipy module
- 5.1.1.14. conv_opt.solver.soplex module
- 5.1.1.15. conv_opt.solver.xpress module
- 5.1.1.16. Module contents
5.2. Submodules¶
5.3. conv_opt._version module¶
5.4. conv_opt.core module¶
Module for solving linear and quadratic optimization problems using multiple open-source and commercials solvers.
- Author
Jonathan Karr <jonrkarr@gmail.com>
- Date
2017-11-14
- Copyright
2017, Karr Lab
- License
MIT
-
class
conv_opt.core.
Constraint
(terms=None, name='', lower_bound=None, upper_bound=None)[source]¶ Bases:
object
A constraint
-
class
conv_opt.core.
LinearTerm
(variable, coefficient)[source]¶ Bases:
conv_opt.core.Term
Linear term (of an objective or contraint)
-
class
conv_opt.core.
Model
(name='', variables=None, objective_direction=<ObjectiveDirection.min: 1>, objective_terms=None, constraints=None)[source]¶ Bases:
object
A mathematical model
-
objective_terms
[source]¶ the elements of the objective, \(c\) and \(Q\)
- Type
list
ofLinearTerm
-
constraints
[source]¶ the constraints, \(A\) and \(b\)
- Type
list
ofLinearTerm
-
convert
(options=None)[source]¶ Generate a data structure for the model for another package
- Parameters
options (
SolveOptions
, optional) – options- Returns
model in a data structure for another package
- Return type
object
- Raises
ConvOptError – if the solver is not supported
-
export
(filename, format=None, solver=None)[source]¶ Export a model to a file in one of these support formats
alp: model with generic names in lp format, where the variable names are annotated to indicate the type and bounds of each variable
cbf
dpe: dual perturbed model
dua: dual
jtask: Jtask format
lp
mps
opf
ppe: perturbed model
rew: model with generic names in mps format
rlp: model with generic names in lp format
sav
task: Task format
xml: OSiL
- Parameters
filename (
str
) – path to save modelformat (
str
, optional) – export format; if the format is not provided, the format is inferred from the filenamesolver (
Solver
, optional) – desired solver to do the exporting; if none, a supported solver will be found
- Raises
ConvOptError – if the format is not supported
-
solve
(options=None)[source]¶ Solve the model
- Parameters
options (
SolveOptions
, optional) – options- Returns
result
- Return type
- Raises
ConvOptError – if the solver is not supported
-
-
class
conv_opt.core.
ObjectiveDirection
[source]¶ Bases:
enum.Enum
Direction to solve a mathematical model
-
class
conv_opt.core.
QuadraticTerm
(variable_1, variable_2, coefficient)[source]¶ Bases:
conv_opt.core.Term
Quadtratic term (of an objective or contraint)
-
class
conv_opt.core.
Result
(status_code, status_message, value, primals, reduced_costs, duals)[source]¶ Bases:
object
The result of solving a mathematical model
-
class
conv_opt.core.
SolveOptions
(solver=<Solver.cplex: 1>, tune=False, presolve=<Presolve.off: 2>, precision=64, round_results_to_bounds=True, verbosity=<Verbosity.off: 0>, solver_options=None)[source]¶ Bases:
object
Options for
Model.solve
-
class
conv_opt.core.
SolverModel
(model, options=None)[source]¶ Bases:
object
A solver
-
get_model
()[source]¶ Get the model in the raw format of the solver. This is useful for acessing specific properties and methods of the solver.
- Returns
the model in the format of the solver
- Return type
object
-
abstract
get_stats
()[source]¶ Get diagnostic information about the model
- Returns
diagnostic information about the model
- Return type
object
-
-
class
conv_opt.core.
StatusCode
[source]¶ Bases:
enum.Enum
Status code for the result of solving a mathematical model
-
class
conv_opt.core.
Variable
(name='', type=<VariableType.continuous: 1>, lower_bound=None, upper_bound=None)[source]¶ Bases:
object
A variable