25 #ifndef CASADI_OPTISTACK_HPP
26 #define CASADI_OPTISTACK_HPP
28 #include "function.hpp"
29 #include "callback.hpp"
89 :
public SWIG_IF_ELSE(PrintableCommon, Printable<Opti>),
91 friend class InternalOptiCallback;
99 Opti(
const std::string& problem_type=
"nlp");
112 MX variable(casadi_int n=1, casadi_int m=1,
const std::string& attribute=
"full");
125 MX parameter(casadi_int n=1, casadi_int m=1,
const std::string& attribute=
"full");
284 casadi_int
nx()
const;
289 casadi_int
np()
const;
294 casadi_int
ng()
const;
344 const std::vector<MX>& args,
const std::vector<MX>& res,
348 const std::vector<MX>& args,
const std::vector<MX>& res,
349 const std::vector<std::string>& name_in,
350 const std::vector<std::string>& name_out,
354 const std::map<std::string, MX>& dict,
355 const std::vector<std::string>& name_in,
356 const std::vector<std::string>& name_out,
368 static MX bounded(
const MX& lb,
const MX& expr,
const MX& ub) {
return (lb<=expr)<= ub; }
414 void disp(std::ostream& stream,
bool more=
false)
const;
513 casadi_error(
"Callback objects cannot be copied");
515 virtual void call(casadi_int i) {
516 uout() <<
"This is a simple callback at iteration" << i << std::endl;
522 friend class InternalOptiCallback;
576 std::string
describe(
const MX& x, casadi_index indent=0)
const;
628 class CASADI_EXPORT
OptiSol :
public SWIG_IF_ELSE(PrintableCommon, Printable<OptiAdvanced>) {
632 void disp(std::ostream& stream,
bool more=
false)
const;
Sparse matrix class. SX and DM are specializations.
void mark_problem_dirty(bool flag=true)
void mark_solver_dirty(bool flag=true)
void show_infeasibilities(double tol=0) const
MX x_lookup(casadi_index i) const
bool problem_dirty() const
std::string g_describe(casadi_index i) const
std::vector< MX > symvar(const MX &expr) const
Get symbols present in expression.
std::vector< MX > constraints() const
DMDict solve_actual(const DMDict &args)
void bake()
Fix the structure of the optimization problem.
std::vector< MX > active_symvar(VariableType type) const
MX g_lookup(casadi_index i) const
OptiAdvanced(const Opti &x)
bool solver_dirty() const
void set_meta_con(const MX &m, const MetaCon &meta)
Set meta-data of an expression.
MetaCon canon_expr(const MX &expr) const
Interpret an expression (for internal use only)
std::vector< MX > symvar() const
Get symbols present in expression.
Function casadi_solver() const
Get the underlying CasADi solver of the Opti stack.
void res(const DMDict &res)
std::vector< MX > symvar(const MX &expr, VariableType type) const
Get symbols present in expression.
void assert_baked() const
void assert_empty() const
void mark_solved(bool flag=true)
OptiAdvanced baked_copy() const
bool is_parametric(const MX &expr) const
return true if expression is only dependant on Opti parameters, not variables
std::string x_describe(casadi_index i) const
std::vector< DM > active_values(VariableType type) const
void assert_active_symbol(const MX &m) const
void assert_solved() const
~OptiAdvanced()
Destructor.
std::string describe(const MX &x, casadi_index indent=0) const
void set_meta(const MX &m, const MetaVar &meta)
Set meta-data of an expression.
MetaVar get_meta(const MX &m) const
Get meta-data of symbol (for internal use only)
MetaCon get_meta_con(const MX &m) const
Get meta-data of symbol (for internal use only)
casadi_int instance_number() const
virtual void call(casadi_int i)
OptiCallback(const OptiCallback &obj)
A simplified interface for NLP modeling/solving.
A simplified interface for NLP modeling/solving.
std::string get_str(bool more=false) const
std::vector< MX > value_parameters() const
void disp(std::ostream &stream, bool more=false) const
native_DM value(const DM &x, const std::vector< MX > &values=std::vector< MX >()) const
std::string type_name() const
Dict stats() const
Get statistics.
native_DM value(const MX &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
std::vector< MX > value_variables() const
get assignment expressions for the optimal solution
OptiSol(const Opti &opti)
A simplified interface for NLP modeling/solving.
native_DM value(const MX &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
std::vector< MX > value_variables() const
get assignment expressions for latest values
void set_domain(const MX &x, const std::string &domain)
Set domain of a decision variable.
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.
native_DM value(const DM &x, const std::vector< MX > &values=std::vector< MX >()) const
void subject_to()
Clear constraints.
static MX bounded(const MX &lb, const MX &expr, const MX &ub)
Construct a double inequality.
casadi_int ng() const
Number of (scalarised) constraints.
void callback_class(OptiCallback *callback)
Helper methods for callback()
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.
casadi_int np() const
Number of (scalarised) parameters.
void set_initial(const std::vector< MX > &assignments)
Dict stats() const
Get statistics.
void disp(std::ostream &stream, bool more=false) const
Print representation.
MX lbg() const
Get all (scalarised) bounds on constraints as a column vector.
std::string return_status() const
Get return status of solver.
casadi_int nx() const
Number of (scalarised) decision variables.
Opti(const std::string &problem_type="nlp")
Create Opti Context.
std::string get_str(bool more=false) const
Get string representation.
OptiAdvanced debug() const
Get a copy with advanced functionality.
MX variable(casadi_int n=1, casadi_int m=1, const std::string &attribute="full")
Create a decision variable (symbol)
MX f() const
Get objective expression.
OptiAdvanced advanced() const
Get a copy with advanced functionality.
Opti copy() const
Get a copy of the.
Dict user_dict(const MX &m) const
Get user data.
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.
std::vector< MX > initial() const
get assignment expressions for initial values
MX parameter(casadi_int n=1, casadi_int m=1, const std::string &attribute="full")
Create a parameter (symbol); fixed during optimization.
void set_value(const MX &x, const DM &v)
Set value of parameter.
void callback_class()
Helper methods for callback()
void subject_to(const MX &g)
Add constraints.
MX p() const
Get all (scalarised) parameters as a symbolic column vector.
void solver(const std::string &solver, const Dict &plugin_options=Dict(), const Dict &solver_options=Dict())
Set a solver.
std::vector< MX > value_parameters() const
MX dual(const MX &m) const
get the dual variable
void set_initial(const MX &x, const DM &v)
void update_user_dict(const MX &m, const Dict &meta)
add user data
OptiSol solve()
Crunch the numbers; solve the problem.
void minimize(const MX &f)
Set objective.
void set_value(const std::vector< MX > &assignments)
Set value of parameter.
void subject_to(const std::vector< MX > &g)
Add constraints.
MX lam_g() const
Get all (scalarised) dual variables as a symbolic column vector.
MX x() const
Get all (scalarised) decision variables as a symbolic column vector.
void update_user_dict(const std::vector< MX > &m, const Dict &meta)
std::string type_name() const
Readable name of the class.
OptiSol solve_limited()
Crunch the numbers; solve the problem.
MX g() const
Get all (scalarised) constraint expressions as a column vector.
SharedObject implements a reference counting framework similar for efficient and.
CASADI_EXPORT std::ostream & uout()
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
@ OPTI_GENERIC_INEQUALITY
std::map< std::string, DM > DMDict