#include <optistack.hpp>
Definition at line 521 of file optistack.hpp.
Public Member Functions | |
OptiAdvanced (const Opti &x) | |
~OptiAdvanced () | |
Destructor. More... | |
Function | casadi_solver () const |
Get the underlying CasADi solver of the Opti stack. More... | |
bool | is_parametric (const MX &expr) const |
return true if expression is only dependant on Opti parameters, not variables More... | |
MetaCon | canon_expr (const MX &expr) const |
Interpret an expression (for internal use only) More... | |
MetaVar | get_meta (const MX &m) const |
Get meta-data of symbol (for internal use only) More... | |
MetaCon | get_meta_con (const MX &m) const |
Get meta-data of symbol (for internal use only) More... | |
void | set_meta (const MX &m, const MetaVar &meta) |
Set meta-data of an expression. More... | |
void | set_meta_con (const MX &m, const MetaCon &meta) |
Set meta-data of an expression. More... | |
void | assert_active_symbol (const MX &m) const |
std::vector< MX > | active_symvar (VariableType type) const |
std::vector< DM > | active_values (VariableType type) const |
MX | x_lookup (casadi_index i) const |
MX | g_lookup (casadi_index i) const |
std::string | x_describe (casadi_index i) const |
std::string | g_describe (casadi_index i) const |
std::string | describe (const MX &x, casadi_index indent=0) const |
void | show_infeasibilities (double tol=0) const |
void | solve_prepare () |
DMDict | solve_actual (const DMDict &args) |
DMDict | arg () const |
void | res (const DMDict &res) |
DMDict | res () const |
std::vector< MX > | constraints () const |
MX | objective () const |
OptiAdvanced | baked_copy () const |
void | assert_empty () const |
void | bake () |
Fix the structure of the optimization problem. More... | |
void | mark_problem_dirty (bool flag=true) |
bool | problem_dirty () const |
void | mark_solver_dirty (bool flag=true) |
bool | solver_dirty () const |
void | mark_solved (bool flag=true) |
bool | solved () const |
void | assert_solved () const |
void | assert_baked () const |
casadi_int | instance_number () const |
MX | variable (casadi_int n=1, casadi_int m=1, const std::string &attribute="full") |
Create a decision variable (symbol) More... | |
MX | parameter (casadi_int n=1, casadi_int m=1, const std::string &attribute="full") |
Create a parameter (symbol); fixed during optimization. More... | |
void | minimize (const MX &f) |
Set objective. More... | |
void | subject_to () |
Clear constraints. More... | |
void | solver (const std::string &solver, const Dict &plugin_options=Dict(), const Dict &solver_options=Dict()) |
Set a solver. More... | |
OptiSol | solve () |
Crunch the numbers; solve the problem. More... | |
OptiSol | solve_limited () |
Crunch the numbers; solve the problem. More... | |
Dict | stats () const |
Get statistics. More... | |
std::string | return_status () const |
Get return status of solver. More... | |
std::vector< MX > | initial () const |
get assignment expressions for initial values More... | |
std::vector< MX > | value_variables () const |
get assignment expressions for latest values More... | |
std::vector< MX > | value_parameters () const |
MX | dual (const MX &m) const |
get the dual variable More... | |
casadi_int | nx () const |
Number of (scalarised) decision variables. More... | |
casadi_int | np () const |
Number of (scalarised) parameters. More... | |
casadi_int | ng () const |
Number of (scalarised) constraints. More... | |
MX | x () const |
Get all (scalarised) decision variables as a symbolic column vector. More... | |
MX | p () const |
Get all (scalarised) parameters as a symbolic column vector. More... | |
MX | g () const |
Get all (scalarised) constraint expressions as a column vector. More... | |
MX | f () const |
Get objective expression. More... | |
MX | lbg () const |
Get all (scalarised) bounds on constraints as a column vector. More... | |
MX | ubg () const |
MX | lam_g () const |
Get all (scalarised) dual variables as a symbolic column vector. More... | |
OptiAdvanced | debug () const |
Get a copy with advanced functionality. More... | |
OptiAdvanced | advanced () const |
Get a copy with advanced functionality. More... | |
Opti | copy () const |
Get a copy of the. More... | |
void | update_user_dict (const MX &m, const Dict &meta) |
add user data More... | |
void | update_user_dict (const std::vector< MX > &m, const Dict &meta) |
Dict | user_dict (const MX &m) const |
Get user data. More... | |
std::string | type_name () const |
Readable name of the class. More... | |
void | disp (std::ostream &stream, bool more=false) const |
Print representation. More... | |
std::string | get_str (bool more=false) const |
Get string representation. More... | |
std::string | class_name () const |
Get class name. More... | |
bool | is_null () const |
Is a null pointer? More... | |
casadi_int | __hash__ () const |
Returns a number that is unique for a given Node. More... | |
std::vector< MX > | symvar () const |
Get symbols present in expression. More... | |
std::vector< MX > | symvar (const MX &expr) const |
Get symbols present in expression. More... | |
std::vector< MX > | symvar (const MX &expr, VariableType type) const |
Get symbols present in expression. More... | |
void | subject_to (const MX &g) |
Add constraints. More... | |
void | subject_to (const std::vector< MX > &g) |
Add constraints. More... | |
void | set_initial (const MX &x, const DM &v) |
void | set_initial (const std::vector< MX > &assignments) |
void | set_value (const MX &x, const DM &v) |
Set value of parameter. More... | |
void | set_value (const std::vector< MX > &assignments) |
Set value of parameter. More... | |
void | set_domain (const MX &x, const std::string &domain) |
Set domain of a decision variable. More... | |
native_DM | value (const MX &x, const std::vector< MX > &values=std::vector< MX >()) const |
native_DM | value (const DM &x, const std::vector< MX > &values=std::vector< MX >()) const |
native_DM | value (const SX &x, const std::vector< MX > &values=std::vector< MX >()) const |
Function | to_function (const std::string &name, const std::vector< MX > &args, const std::vector< MX > &res, const Dict &opts=Dict()) |
Create a CasADi Function from the Opti solver. More... | |
Function | to_function (const std::string &name, const std::vector< MX > &args, const std::vector< MX > &res, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts=Dict()) |
Create a CasADi Function from the Opti solver. More... | |
Function | to_function (const std::string &name, const std::map< std::string, MX > &dict, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts=Dict()) |
Create a CasADi Function from the Opti solver. More... | |
void | callback_class (OptiCallback *callback) |
Helper methods for callback() More... | |
void | callback_class () |
Helper methods for callback() More... | |
Static Public Member Functions | |
static MX | bounded (const MX &lb, const MX &expr, const MX &ub) |
Construct a double inequality. More... | |
Public Attributes | |
bool | problem_dirty_ |
bool | solver_dirty_ |
bool | solved_ |
Protected Member Functions | |
OptiAdvanced () | |
Friends | |
class | InternalOptiCallback |
casadi::OptiAdvanced::OptiAdvanced | ( | const Opti & | x | ) |
|
inline |
Extra doc: https://github.com/casadi/casadi/wiki/L_1t
Definition at line 530 of file optistack.hpp.
|
inlineprotected |
Definition at line 615 of file optistack.hpp.
|
inherited |
If the Object does not point to any node, "0" is returned.
Extra doc: https://github.com/casadi/casadi/wiki/L_av
std::vector<MX> casadi::OptiAdvanced::active_symvar | ( | VariableType | type | ) | const |
std::vector<DM> casadi::OptiAdvanced::active_values | ( | VariableType | type | ) | const |
|
inherited |
You get access to more methods, but you have no guarantees about API stability
The copy is effectively a deep copy: Updating the state of the copy does not update the original.
Extra doc: https://github.com/casadi/casadi/wiki/L_1m
DMDict casadi::OptiAdvanced::arg | ( | ) | const |
void casadi::OptiAdvanced::assert_active_symbol | ( | const MX & | m | ) | const |
void casadi::OptiAdvanced::assert_baked | ( | ) | const |
void casadi::OptiAdvanced::assert_empty | ( | ) | const |
void casadi::OptiAdvanced::assert_solved | ( | ) | const |
void casadi::OptiAdvanced::bake | ( | ) |
OptiAdvanced casadi::OptiAdvanced::baked_copy | ( | ) | const |
|
inlinestaticinherited |
Constructs: lb(p) <= g(x,p) <= ub(p)
Python prohibits such syntax directly
Extra doc: https://github.com/casadi/casadi/wiki/L_1k
Definition at line 368 of file optistack.hpp.
|
inherited |
Do not use directly.
Extra doc: https://github.com/casadi/casadi/wiki/L_1p
|
inherited |
Do not use directly.
Extra doc: https://github.com/casadi/casadi/wiki/L_1p
Function casadi::OptiAdvanced::casadi_solver | ( | ) | const |
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_au
std::vector<MX> casadi::OptiAdvanced::constraints | ( | ) | const |
|
inherited |
The copy is effectively a deep copy: Updating the state of the copy does not update the original.
Extra doc: https://github.com/casadi/casadi/wiki/L_1n
|
inherited |
You get access to more methods, but you have no guarantees about API stability
The copy is effectively a deep copy: Updating the state of the copy does not update the original.
Extra doc: https://github.com/casadi/casadi/wiki/L_1l
std::string casadi::OptiAdvanced::describe | ( | const MX & | x, |
casadi_index | indent = 0 |
||
) | const |
|
inherited |
m must be a constraint expression. The returned value is still a symbolic expression. Use value
on it to obtain the numerical value.
Extra doc: https://github.com/casadi/casadi/wiki/L_1h
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_26e
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_26d
std::string casadi::OptiAdvanced::g_describe | ( | casadi_index | i | ) | const |
MX casadi::OptiAdvanced::g_lookup | ( | casadi_index | i | ) | const |
|
inherited |
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_266
casadi_int casadi::OptiAdvanced::instance_number | ( | ) | const |
|
inherited |
bool casadi::OptiAdvanced::is_parametric | ( | const MX & | expr | ) | const |
|
inherited |
Useful for obtaining the Lagrange Hessian:
* sol.value(hessian(opti.f+opti.lam_g'*opti.g,opti.x)) % MATLAB * sol.value(hessian(opti.f+dot(opti.lam_g,opti.g),opti.x)[0]) # Python *
Extra doc: https://github.com/casadi/casadi/wiki/L_1i
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_26f
void casadi::OptiAdvanced::mark_problem_dirty | ( | bool | flag = true | ) |
void casadi::OptiAdvanced::mark_solved | ( | bool | flag = true | ) |
void casadi::OptiAdvanced::mark_solver_dirty | ( | bool | flag = true | ) |
|
inherited |
Objective must be a scalar. Default objective: 0 When method is called multiple times, the last call takes effect
Extra doc: https://github.com/casadi/casadi/wiki/L_1a
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_26a
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_269
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_268
MX casadi::OptiAdvanced::objective | ( | ) | const |
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_26c
|
inherited |
The order of creation does not matter. It is not required for parameter to actualy appear in the optimization problem. Parameters that do appear, must be given a value before the problem can be solved.
[in] | n | number of rows (default 1) |
[in] | m | number of columnss (default 1) |
[in] | attribute | 'full' (default) or 'symmetric' |
Extra doc: https://github.com/casadi/casadi/wiki/L_19
bool casadi::OptiAdvanced::problem_dirty | ( | ) | const |
DMDict casadi::OptiAdvanced::res | ( | ) | const |
void casadi::OptiAdvanced::res | ( | const DMDict & | res | ) |
|
inherited |
passed as-is from nlpsol
No stability can be guaranteed about this part of the API
Extra doc: https://github.com/casadi/casadi/wiki/L_1g
|
inherited |
[in] | x | decision variable |
[in] | type | 'real', 'integer' (default: real) |
* opti.set_domain(x, "real") * opti.set_domain(x, "integer") *
Extra doc: https://github.com/casadi/casadi/wiki/L_27t
Set initial guess for decision variables
* opti.set_initial(x, 2) * opti.set_initial(10*x(1), 2) *
|
inherited |
Set initial guess for decision variables
* opti.set_initial(x, 2) * opti.set_initial(10*x(1), 2) *
Each parameter must be given a value before 'solve' can be called
Extra doc: https://github.com/casadi/casadi/wiki/L_1d
|
inherited |
Each parameter must be given a value before 'solve' can be called
Extra doc: https://github.com/casadi/casadi/wiki/L_1d
void casadi::OptiAdvanced::show_infeasibilities | ( | double | tol = 0 | ) | const |
|
inherited |
|
inherited |
Allows the solver to return without error when an iteration or time limit is reached
Extra doc: https://github.com/casadi/casadi/wiki/L_1e
void casadi::OptiAdvanced::solve_prepare | ( | ) |
bool casadi::OptiAdvanced::solved | ( | ) | const |
|
inherited |
[in] | solver | any of the nlpsol plugins can be used here In practice, not all nlpsol plugins may be supported yet |
[in] | options | passed on to nlpsol plugin No stability can be guaranteed about this part of the API |
[in] | options | to be passed to nlpsol solver No stability can be guaranteed about this part of the API |
Extra doc: https://github.com/casadi/casadi/wiki/L_1c
bool casadi::OptiAdvanced::solver_dirty | ( | ) | const |
|
inherited |
nlpsol stats are passed as-is. No stability can be guaranteed about this part of the API
Extra doc: https://github.com/casadi/casadi/wiki/L_1f
|
inherited |
|
inherited |
Examples:
* \begin{itemize} * opti.subject_to( sqrt(x+y) >= 1); * opti.subject_to( sqrt(x+y) > 1)}: same as above * opti.subject_to( 1<= sqrt(x+y) )}: same as above * opti.subject_to( 5*x+y==1 )}: equality * * Python * opti.subject_to([x*y>=1,x==3]) * opti.subject_to(opti.bounded(0,x,1)) * * MATLAB * opti.subject_to({x*y>=1,x==3}) * opti.subject_to( 0<=x<=1 ) *
Related functionalities:
opti.debug.show_infeasibilities() may be used to inspect which constraints are violated
Extra doc: https://github.com/casadi/casadi/wiki/L_1b
|
inherited |
Examples:
* \begin{itemize} * opti.subject_to( sqrt(x+y) >= 1); * opti.subject_to( sqrt(x+y) > 1)}: same as above * opti.subject_to( 1<= sqrt(x+y) )}: same as above * opti.subject_to( 5*x+y==1 )}: equality * * Python * opti.subject_to([x*y>=1,x==3]) * opti.subject_to(opti.bounded(0,x,1)) * * MATLAB * opti.subject_to({x*y>=1,x==3}) * opti.subject_to( 0<=x<=1 ) *
Related functionalities:
opti.debug.show_infeasibilities() may be used to inspect which constraints are violated
Extra doc: https://github.com/casadi/casadi/wiki/L_1b
std::vector<MX> casadi::OptiAdvanced::symvar | ( | ) | const |
Returned vector is ordered according to the order of variable()/parameter() calls used to create the variables
Extra doc: https://github.com/casadi/casadi/wiki/L_1u
Returned vector is ordered according to the order of variable()/parameter() calls used to create the variables
Extra doc: https://github.com/casadi/casadi/wiki/L_1u
std::vector<MX> casadi::OptiAdvanced::symvar | ( | const MX & | expr, |
VariableType | type | ||
) | const |
Returned vector is ordered according to the order of variable()/parameter() calls used to create the variables
Extra doc: https://github.com/casadi/casadi/wiki/L_1u
|
inherited |
[in] | name | Name of the resulting CasADi Function |
[in] | args | List of parameters and decision/dual variables (which can be given an initial guess) with the resulting Function |
[in] | res | List of expressions that will get evaluated at the optimal solution |
[in] | opts | Standard CasADi Funcion options |
Extra doc: https://github.com/casadi/casadi/wiki/L_1j
|
inherited |
[in] | name | Name of the resulting CasADi Function |
[in] | args | List of parameters and decision/dual variables (which can be given an initial guess) with the resulting Function |
[in] | res | List of expressions that will get evaluated at the optimal solution |
[in] | opts | Standard CasADi Funcion options |
Extra doc: https://github.com/casadi/casadi/wiki/L_1j
|
inherited |
[in] | name | Name of the resulting CasADi Function |
[in] | args | List of parameters and decision/dual variables (which can be given an initial guess) with the resulting Function |
[in] | res | List of expressions that will get evaluated at the optimal solution |
[in] | opts | Standard CasADi Funcion options |
Extra doc: https://github.com/casadi/casadi/wiki/L_1j
|
inlineinherited |
Definition at line 411 of file optistack.hpp.
|
inherited |
Add arbitrary data in the form of a dictionary to symbols or constraints
Extra doc: https://github.com/casadi/casadi/wiki/L_1o
|
inherited |
Obtain value of expression at the current value
In regular mode, teh current value is the converged solution In debug mode, the value can be non-converged
[in] | values | Optional assignment expressions (e.g. x==3) to overrule the current value |
|
inherited |
Obtain value of expression at the current value
In regular mode, teh current value is the converged solution In debug mode, the value can be non-converged
[in] | values | Optional assignment expressions (e.g. x==3) to overrule the current value |
|
inherited |
Obtain value of expression at the current value
In regular mode, teh current value is the converged solution In debug mode, the value can be non-converged
[in] | values | Optional assignment expressions (e.g. x==3) to overrule the current value |
|
inherited |
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_267
|
inherited |
The order of creation matters. The order will be reflected in the optimization problem. It is not required for decision variables to actualy appear in the optimization problem.
[in] | n | number of rows (default 1) |
[in] | m | number of columnss (default 1) |
[in] | attribute | 'full' (default) or 'symmetric' |
Extra doc: https://github.com/casadi/casadi/wiki/L_18
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_26b
std::string casadi::OptiAdvanced::x_describe | ( | casadi_index | i | ) | const |
MX casadi::OptiAdvanced::x_lookup | ( | casadi_index | i | ) | const |
|
friend |
Definition at line 522 of file optistack.hpp.
bool casadi::OptiAdvanced::problem_dirty_ |
Definition at line 597 of file optistack.hpp.
bool casadi::OptiAdvanced::solved_ |
Definition at line 605 of file optistack.hpp.
bool casadi::OptiAdvanced::solver_dirty_ |
Definition at line 601 of file optistack.hpp.