Sleipnir Python API
Loading...
Searching...
No Matches
jormungandr.optimization.OptimizationProblem Class Reference

Public Member Functions

None __init__ (self)
 
Variable decision_variable (self)
 
VariableMatrix decision_variable (self, int rows, int cols=1)
 
VariableMatrix symmetric_decision_variable (self, int rows)
 
None minimize (self, Variable cost)
 
None minimize (self, VariableMatrix cost)
 
None minimize (self, float cost)
 
None maximize (self, Variable objective)
 
None maximize (self, VariableMatrix objective)
 
None maximize (self, float objective)
 
None subject_to (self, EqualityConstraints constraint)
 
None subject_to (self, InequalityConstraints constraint)
 
SolverStatus solve (self, **kwargs)
 
None callback (self, Callable[[SolverIterationInfo], bool] callback)
 

Detailed Description

This class allows the user to pose a constrained nonlinear
optimization problem in natural mathematical notation and solve it.

This class supports problems of the form: @verbatim minₓ f(x) subject
to cₑ(x) = 0 cᵢ(x) ≥ 0 @endverbatim

where f(x) is the scalar cost function, x is the vector of decision
variables (variables the solver can tweak to minimize the cost
function), cᵢ(x) are the inequality constraints, and cₑ(x) are the
equality constraints. Constraints are equations or inequalities of the
decision variables that constrain what values the solver is allowed to
use when searching for an optimal solution.

The nice thing about this class is users don't have to put their
system in the form shown above manually; they can write it in natural
mathematical form and it'll be converted for them.

Constructor & Destructor Documentation

◆ __init__()

None jormungandr.optimization.OptimizationProblem.__init__ (   self)
Construct the optimization problem.

Member Function Documentation

◆ callback()

None jormungandr.optimization.OptimizationProblem.callback (   self,
Callable[[SolverIterationInfo], bool]  callback 
)
Sets a callback to be called at each solver iteration.

The callback for this overload should return bool.

Parameter ``callback``:
    The callback. Returning true from the callback causes the solver
    to exit early with the solution it has so far.

◆ decision_variable() [1/2]

Variable jormungandr.optimization.OptimizationProblem.decision_variable (   self)
Create a decision variable in the optimization problem.

◆ decision_variable() [2/2]

VariableMatrix jormungandr.optimization.OptimizationProblem.decision_variable (   self,
int  rows,
int   cols = 1 
)
Create a matrix of decision variables in the optimization problem.

Parameter ``rows``:
    Number of matrix rows.

Parameter ``cols``:
    Number of matrix columns.

◆ maximize() [1/3]

None jormungandr.optimization.OptimizationProblem.maximize (   self,
float  objective 
)

◆ maximize() [2/3]

None jormungandr.optimization.OptimizationProblem.maximize (   self,
Variable  objective 
)
Tells the solver to maximize the output of the given objective
function.

Note that this is optional. If only constraints are specified, the
solver will find the closest solution to the initial conditions that's
in the feasible set.

Parameter ``objective``:
    The objective function to maximize.

◆ maximize() [3/3]

None jormungandr.optimization.OptimizationProblem.maximize (   self,
VariableMatrix  objective 
)

◆ minimize() [1/3]

None jormungandr.optimization.OptimizationProblem.minimize (   self,
float  cost 
)

◆ minimize() [2/3]

None jormungandr.optimization.OptimizationProblem.minimize (   self,
Variable  cost 
)
Tells the solver to minimize the output of the given cost function.

Note that this is optional. If only constraints are specified, the
solver will find the closest solution to the initial conditions that's
in the feasible set.

Parameter ``cost``:
    The cost function to minimize.

◆ minimize() [3/3]

None jormungandr.optimization.OptimizationProblem.minimize (   self,
VariableMatrix  cost 
)

◆ solve()

SolverStatus jormungandr.optimization.OptimizationProblem.solve (   self,
**  kwargs 
)
Solve the optimization problem. The solution will be stored in the
original variables used to construct the problem.

Parameter ``tolerance``:
    The solver will stop once the error is below this tolerance.
    (default: 1e-8)

Parameter ``max_iterations``:
    The maximum number of solver iterations before returning a solution.
    (default: 5000)

Parameter ``acceptable_tolerance``:
    The solver will stop once the error is below this tolerance for
    `acceptable_iterations` iterations. This is useful in cases where the
    solver might not be able to achieve the desired level of accuracy due to
    floating-point round-off.
    (default: 1e-6)

Parameter ``max_acceptable_iterations``:
    The solver will stop once the error is below `acceptable_tolerance` for
    this many iterations.
    (default: 15)

Parameter ``timeout``:
    The maximum elapsed wall clock time before returning a solution.
    (default: infinity)

Parameter ``feasible_ipm``:
    Enables the feasible interior-point method. When the inequality
    constraints are all feasible, step sizes are reduced when necessary to
    prevent them becoming infeasible again. This is useful when parts of the
    problem are ill-conditioned in infeasible regions (e.g., square root of a
    negative value). This can slow or prevent progress toward a solution
    though, so only enable it if necessary.
    (default: False)

Parameter ``diagnostics``:
    Enables diagnostic prints.
    (default: False)

Parameter ``spy``:
    Enables writing sparsity patterns of H, Aₑ, and Aᵢ to files named H.spy,
    A_e.spy, and A_i.spy respectively during solve.

    Use tools/spy.py to plot them.
    (default: False)

◆ subject_to() [1/2]

None jormungandr.optimization.OptimizationProblem.subject_to (   self,
EqualityConstraints  constraint 
)
Tells the solver to solve the problem while satisfying the given
equality constraint.

Parameter ``constraint``:
    The constraint to satisfy.

◆ subject_to() [2/2]

None jormungandr.optimization.OptimizationProblem.subject_to (   self,
InequalityConstraints  constraint 
)
Tells the solver to solve the problem while satisfying the given
inequality constraint.

Parameter ``constraint``:
    The constraint to satisfy.

◆ symmetric_decision_variable()

VariableMatrix jormungandr.optimization.OptimizationProblem.symmetric_decision_variable (   self,
int  rows 
)
Create a symmetric matrix of decision variables in the optimization
problem.

Variable instances are reused across the diagonal, which helps reduce
problem dimensionality.

Parameter ``rows``:
    Number of matrix rows.

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