List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Friends
casadi::OptiAdvanced Class Reference

#include <optistack.hpp>

Detailed Description

Definition at line 551 of file optistack.hpp.

Inheritance diagram for casadi::OptiAdvanced:
Inheritance graph
[legend]
Collaboration diagram for casadi::OptiAdvanced:
Collaboration graph
[legend]

Public Types

using internal_base_type = SharedObjectInternal
 
using base_type = SharedObject
 

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< MXactive_symvar (VariableType type) const
 
std::vector< DMactive_values (VariableType type) const
 
MX x_lookup (casadi_index i) const
 
MX g_lookup (casadi_index i) const
 
casadi_index g_index_reduce_g (casadi_index i) const
 
casadi_index g_index_reduce_x (casadi_index i) const
 
casadi_index g_index_unreduce_g (casadi_index i) const
 
std::string x_describe (casadi_index i, const Dict &opts=Dict()) const
 
std::string g_describe (casadi_index i, const Dict &opts=Dict()) const
 
std::string describe (const MX &x, casadi_index indent=0, const Dict &opts=Dict()) const
 
void show_infeasibilities (double tol=0, const Dict &opts=Dict()) const
 
void solve_prepare ()
 
DMDict solve_actual (const DMDict &args)
 
DMDict arg () const
 
void res (const DMDict &res)
 
DMDict res () const
 
std::vector< MXconstraints () 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 variable (const Sparsity &sp, const std::string &attribute="full")
 
MX variable (const MX &symbol, const std::string &attribute="full")
 
MX parameter (casadi_int n=1, casadi_int m=1, const std::string &attribute="full")
 Create a parameter (symbol); fixed during optimization. More...
 
MX parameter (const Sparsity &sp, const std::string &attribute="full")
 
MX parameter (const MX &symbol, const std::string &attribute="full")
 
void minimize (const MX &f, double linear_scale=1)
 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...
 
Dict stats () const
 Get statistics. More...
 
std::string return_status () const
 Get return status of solver. More...
 
std::vector< MXinitial () const
 get assignment expressions for initial values More...
 
std::vector< MXvalue_variables () const
 get assignment expressions for latest values More...
 
std::vector< MXvalue_parameters () const
 
Function scale_helper (const Function &h) const
 Scale a helper function constructed via opti.x, opti.g, ... More...
 
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
 
DM x_linear_scale () const
 
DM x_linear_scale_offset () const
 
DM g_linear_scale () const
 
double f_linear_scale () 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...
 
void print_ptr (std::ostream &stream=casadi::uout()) const
 
void own (SharedObjectInternal *node)
 
void assign (SharedObjectInternal *node)
 Assign the node to a node class pointer without reference counting. More...
 
SharedObjectInternalget () const
 Get a const pointer to the node. More...
 
casadi_int getCount () const
 Get the reference count. More...
 
void swap (GenericShared &other)
 Swap content with another instance. More...
 
std::string debug_repr () const
 
bool is_null () const
 Is a null pointer? More...
 
casadi_int __hash__ () const
 Returns a number that is unique for a given Node. More...
 
GenericWeakRef< SharedObject, SharedObjectInternal > * weak ()
 Get a weak reference to the object. More...
 
std::vector< MXsymvar () const
 Get symbols present in expression. More...
 
std::vector< MXsymvar (const MX &expr) const
 Get symbols present in expression. More...
 
std::vector< MXsymvar (const MX &expr, VariableType type) const
 Get symbols present in expression. More...
 
void subject_to (const MX &g, const Dict &options=Dict())
 Add constraints. More...
 
void subject_to (const std::vector< MX > &g, const Dict &options=Dict())
 Add constraints. More...
 
void subject_to (const MX &g, const DM &linear_scale, const Dict &options=Dict())
 Add constraints. More...
 
void subject_to (const std::vector< MX > &g, const DM &linear_scale, const Dict &options=Dict())
 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...
 
void set_linear_scale (const MX &x, const DM &scale, const DM &offset=0)
 Set scale of a decision variable. More...
 
OptiSol solve ()
 Crunch the numbers; solve the problem. More...
 
OptiSol solve_limited ()
 Crunch the numbers; solve the problem. 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
 Set domain of a decision variable. More...
 
native_DM value (const SX &x, const std::vector< MX > &values=std::vector< MX >()) const
 Set domain of a decision variable. More...
 
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...
 
OptiNodeoperator-> ()
 Access a member of the node. More...
 
const OptiNodeoperator-> () const
 Const access a member of the node. More...
 

Static Public Member Functions

static MX bounded (const MX &lb, const MX &expr, const MX &ub)
 Construct a double inequality. More...
 
static Opti create (OptiNode *node)
 

Public Attributes

bool problem_dirty_
 
bool solver_dirty_
 
bool solved_
 

Protected Member Functions

 OptiAdvanced ()
 
void count_up ()
 
void count_down ()
 

Friends

class InternalOptiCallback
 

Member Typedef Documentation

◆ base_type

Definition at line 103 of file shared_object.hpp.

◆ internal_base_type

Definition at line 102 of file shared_object.hpp.

Constructor & Destructor Documentation

◆ OptiAdvanced() [1/2]

casadi::OptiAdvanced::OptiAdvanced ( const Opti x)

Definition at line 83 of file optistack.cpp.

83  : Opti(rhs) {
84 }
Opti(const std::string &problem_type="nlp")
Create Opti Context.
Definition: optistack.cpp:47

◆ ~OptiAdvanced()

casadi::OptiAdvanced::~OptiAdvanced ( )
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1t

Definition at line 560 of file optistack.hpp.

560 {}

◆ OptiAdvanced() [2/2]

casadi::OptiAdvanced::OptiAdvanced ( )
inlineprotected

Definition at line 649 of file optistack.hpp.

649 {}

Member Function Documentation

◆ __hash__()

casadi_int casadi::GenericShared< SharedObject , SharedObjectInternal >::__hash__
inherited

If the Object does not point to any node, "0" is returned.

Extra doc: https://github.com/casadi/casadi/wiki/L_av

Definition at line 124 of file generic_shared_impl.hpp.

137  {
138  return reinterpret_cast<casadi_int>(get());
139  }

◆ active_symvar()

std::vector< MX > casadi::OptiAdvanced::active_symvar ( VariableType  type) const

Definition at line 589 of file optistack.cpp.

589  {
590  try {
591  return (*this)->active_symvar(type);
592  } catch(std::exception& e) {
593  THROW_ERROR("active_symvar", e.what());
594  }
595 }

Referenced by casadi::Opti::disp().

◆ active_values()

std::vector< DM > casadi::OptiAdvanced::active_values ( VariableType  type) const

Definition at line 597 of file optistack.cpp.

597  {
598  try {
599  return (*this)->active_values(type);
600  } catch(std::exception& e) {
601  THROW_ERROR("active_values", e.what());
602  }
603 }

◆ advanced()

OptiAdvanced casadi::Opti::advanced ( ) 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

Definition at line 850 of file optistack.cpp.

850  {
851  return copy();
852 }
Opti copy() const
Get a copy of the.
Definition: optistack.cpp:853

References casadi::Opti::copy().

◆ arg()

DMDict casadi::OptiAdvanced::arg ( ) const

Definition at line 690 of file optistack.cpp.

690  {
691  try {
692  return (*this)->arg();
693  } catch(std::exception& e) {
694  THROW_ERROR("arg", e.what());
695  }
696 }

◆ assert_active_symbol()

void casadi::OptiAdvanced::assert_active_symbol ( const MX m) const

Definition at line 581 of file optistack.cpp.

581  {
582  try {
583  (*this)->assert_active_symbol(m);
584  } catch(std::exception& e) {
585  THROW_ERROR("assert_active_symbol", e.what());
586  }
587 }

◆ assert_baked()

void casadi::OptiAdvanced::assert_baked ( ) const

Definition at line 839 of file optistack.cpp.

839  {
840  try {
841  (*this)->assert_baked();
842  } catch(std::exception& e) {
843  THROW_ERROR("assert_baked", e.what());
844  }
845 }

◆ assert_empty()

void casadi::OptiAdvanced::assert_empty ( ) const

Definition at line 734 of file optistack.cpp.

734  {
735  try {
736  return (*this)->assert_empty();
737  } catch(std::exception& e) {
738  THROW_ERROR("assert_empty", e.what());
739  }
740 }

◆ assert_solved()

void casadi::OptiAdvanced::assert_solved ( ) const

Definition at line 832 of file optistack.cpp.

832  {
833  try {
834  (*this)->assert_solved();
835  } catch(std::exception& e) {
836  THROW_ERROR("assert_solved", e.what());
837  }
838 }

◆ assign()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::assign ( Internal *  node)
inherited

improper use will cause memory leaks!

Extra doc: https://github.com/casadi/casadi/wiki/L_at

Definition at line 97 of file generic_shared_impl.hpp.

75  {
76  node = node_;
77  }

◆ bake()

void casadi::OptiAdvanced::bake ( )

Definition at line 778 of file optistack.cpp.

778  {
779  try {
780  (*this)->bake();
781  } catch(std::exception& e) {
782  THROW_ERROR("bake", e.what());
783  }
784 }

Referenced by casadi::OptiNode::baked_copy(), and casadi::Opti::disp().

◆ baked_copy()

OptiAdvanced casadi::OptiAdvanced::baked_copy ( ) const

Definition at line 726 of file optistack.cpp.

726  {
727  try {
728  return (*this)->baked_copy();
729  } catch(std::exception& e) {
730  THROW_ERROR("baked_copy", e.what());
731  }
732 }

References casadi::OptiNode::baked_copy().

◆ bounded()

static MX casadi::Opti::bounded ( const MX lb,
const MX expr,
const MX ub 
)
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 397 of file optistack.hpp.

397 { return (lb<=expr)<= ub; }

◆ callback_class() [1/2]

void casadi::Opti::callback_class ( )
inherited

Do not use directly.

Extra doc: https://github.com/casadi/casadi/wiki/L_1p

Definition at line 471 of file optistack.cpp.

471  {
472  try {
473  (*this)->callback_class();
474  } catch(std::exception& e) {
475  THROW_ERROR("callback_class", e.what());
476  }
477 }

Referenced by casadi::Opti::Opti().

◆ callback_class() [2/2]

void casadi::Opti::callback_class ( OptiCallback callback)
inherited

Do not use directly.

Extra doc: https://github.com/casadi/casadi/wiki/L_1p

Definition at line 463 of file optistack.cpp.

463  {
464  try {
465  (*this)->callback_class(callback);
466  } catch(std::exception& e) {
467  THROW_ERROR("callback_class", e.what());
468  }
469 }

◆ canon_expr()

MetaCon casadi::OptiAdvanced::canon_expr ( const MX expr) const

Definition at line 540 of file optistack.cpp.

540  {
541  try {
542  return (*this)->canon_expr(expr);
543  } catch(std::exception& e) {
544  THROW_ERROR("canon_expr", e.what());
545  }
546 }

◆ casadi_solver()

Function casadi::OptiAdvanced::casadi_solver ( ) const

Definition at line 500 of file optistack.cpp.

500  {
501  try {
502  return (*this)->casadi_solver();
503  } catch(std::exception& e) {
504  THROW_ERROR("casadi_solver", e.what());
505  }
506 }

◆ class_name()

std::string casadi::SharedObject::class_name ( ) const
inherited

◆ constraints()

std::vector< MX > casadi::OptiAdvanced::constraints ( ) const

Definition at line 715 of file optistack.cpp.

715  {
716  try {
717  return (*this)->constraints();
718  } catch(std::exception& e) {
719  THROW_ERROR("constraints", e.what());
720  }
721 }

◆ copy()

Opti casadi::Opti::copy ( ) 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

Definition at line 853 of file optistack.cpp.

853  {
854  return (*this)->copy();
855 }

References casadi::OptiNode::copy().

Referenced by casadi::Opti::advanced(), and casadi::Opti::debug().

◆ count_down()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::count_down
protectedinherited

Definition at line 134 of file generic_shared_impl.hpp.

42  {
43 #ifdef WITH_EXTRA_CHECKS
44  casadi_assert_dev(Function::call_depth_==0);
45 #endif // WITH_EXTRA_CHECKS
46  if (!node) return;
47  if (node->weak_ref_) {
48 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
49  auto mutex = node->weak_ref_->get_mutex();
50  // Avoid triggering a delete while a weak_ref.shared_if_alive is being called
51  std::lock_guard<std::mutex> lock(*mutex);
52  // Could it be that this mutex is destroyed when the lock goes out of scope?
53 #endif // CASADI_WITH_THREADSAFE_SYMBOLICS
54 
55  if (--static_cast<Internal*>(node)->count == 0) {
56  delete node;
57  node = nullptr;
58  }
59  } else {
60  if (--static_cast<Internal*>(node)->count == 0) {
61  delete node;
62  node = nullptr;
63  }
64  }
65  }

◆ count_up()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::count_up
protectedinherited

Definition at line 133 of file generic_shared_impl.hpp.

32  {
33 #ifdef WITH_EXTRA_CHECKS
34  casadi_assert_dev(Function::call_depth_==0);
35 #endif // WITH_EXTRA_CHECKS
36 
37  if (node) static_cast<Internal*>(node)->count++;
38 
39  }

◆ create()

Opti casadi::Opti::create ( OptiNode node)
staticinherited

Definition at line 86 of file optistack.cpp.

86  {
87  return Opti(node);
88 }

References casadi::Opti::Opti().

Referenced by casadi::OptiNode::copy().

◆ debug()

OptiAdvanced casadi::Opti::debug ( ) 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_1l

Definition at line 847 of file optistack.cpp.

847  {
848  return copy();
849 }

References casadi::Opti::copy().

Referenced by casadi::Opti::disp().

◆ debug_repr()

std::string casadi::GenericShared< SharedObject , SharedObjectInternal >::debug_repr
inherited

Definition at line 113 of file generic_shared_impl.hpp.

80  {
81  if (node) {
82  return node->debug_repr(node);
83  } else {
84  return "NULL";
85  }
86  }
std::string debug_repr(const Internal *) const

◆ describe()

std::string casadi::OptiAdvanced::describe ( const MX x,
casadi_index  indent = 0,
const Dict opts = Dict() 
) const

Definition at line 659 of file optistack.cpp.

659  {
660  try {
661  return (*this)->describe(x, indent, opts);
662  } catch(std::exception& e) {
663  THROW_ERROR("describe", e.what());
664  }
665 }
MX x() const
Get all (scalarised) decision variables as a symbolic column vector.
Definition: optistack.cpp:334

References casadi::Opti::x().

Referenced by casadi::OptiNode::describe().

◆ disp()

void casadi::Opti::disp ( std::ostream &  stream,
bool  more = false 
) const
inherited

Definition at line 750 of file optistack.cpp.

750  {
751  stream << "Opti {" << std::endl;
752  OptiAdvanced mycopy = debug();
753  stream << " instance #" << mycopy.instance_number() << std::endl;
754  if (mycopy.problem_dirty()) mycopy.bake();
755  stream << " #variables: " << mycopy.active_symvar(OPTI_VAR).size()
756  << " (nx = " << mycopy.nx() << ")" << std::endl;
757  stream << " #parameters: " << mycopy.active_symvar(OPTI_PAR).size()
758  << " (np = " << mycopy.np() << ")" << std::endl;
759  stream << " #constraints: " << mycopy.active_symvar(OPTI_DUAL_G).size()
760  << " (ng = " << mycopy.ng() << ")" << std::endl;
761  if (mycopy.solver_dirty()) {
762  stream << " CasADi solver needs updating." << std::endl;
763  } else {
764  stream << " CasADi solver allocated." << std::endl;
765  }
766  if (mycopy.solved()) {
767  stream << " CasADi solver was called: " << mycopy.return_status() << std::endl;
768  }
769  stream << "}";
770 }
OptiAdvanced debug() const
Get a copy with advanced functionality.
Definition: optistack.cpp:847
@ OPTI_VAR
Definition: optistack.hpp:496
@ OPTI_DUAL_G
Definition: optistack.hpp:498
@ OPTI_PAR
Definition: optistack.hpp:497

References active_symvar(), bake(), casadi::Opti::debug(), instance_number(), casadi::Opti::ng(), casadi::Opti::np(), casadi::Opti::nx(), casadi::OPTI_DUAL_G, casadi::OPTI_PAR, casadi::OPTI_VAR, problem_dirty(), casadi::Opti::return_status(), solved(), and solver_dirty().

Referenced by casadi::OptiSol::disp(), and casadi::Opti::get_str().

◆ dual()

MX casadi::Opti::dual ( const MX m) 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

Definition at line 302 of file optistack.cpp.

302  {
303  try {
304  return (*this)->dual(m);
305  } catch(std::exception& e) {
306  THROW_ERROR("dual", e.what());
307  }
308 }

◆ f()

MX casadi::Opti::f ( ) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_26e

Definition at line 358 of file optistack.cpp.

358  {
359  try {
360  return (*this)->f();
361  } catch(std::exception& e) {
362  THROW_ERROR("f", e.what());
363  }
364 }

Referenced by casadi::Opti::minimize(), and objective().

◆ f_linear_scale()

double casadi::Opti::f_linear_scale ( ) const
inherited

Definition at line 415 of file optistack.cpp.

415  {
416  try {
417  return (*this)->f_linear_scale();
418  } catch(std::exception& e) {
419  THROW_ERROR("f_linear_scale", e.what());
420  }
421 }

◆ g()

MX casadi::Opti::g ( ) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_26d

Definition at line 350 of file optistack.cpp.

350  {
351  try {
352  return (*this)->g();
353  } catch(std::exception& e) {
354  THROW_ERROR("g", e.what());
355  }
356 }

Referenced by casadi::Opti::subject_to().

◆ g_describe()

std::string casadi::OptiAdvanced::g_describe ( casadi_index  i,
const Dict opts = Dict() 
) const

Definition at line 652 of file optistack.cpp.

652  {
653  try {
654  return (*this)->g_describe(i, opts);
655  } catch(std::exception& e) {
656  THROW_ERROR("g_describe", e.what());
657  }
658 }

Referenced by casadi::OptiNode::g_describe().

◆ g_index_reduce_g()

casadi_int casadi::OptiAdvanced::g_index_reduce_g ( casadi_index  i) const

Definition at line 613 of file optistack.cpp.

613  {
614  try {
615  return (*this)->g_index_reduce_g(i);
616  } catch(std::exception& e) {
617  THROW_ERROR("g_index_reduce_g", e.what());
618  }
619 }

◆ g_index_reduce_x()

casadi_int casadi::OptiAdvanced::g_index_reduce_x ( casadi_index  i) const

Definition at line 621 of file optistack.cpp.

621  {
622  try {
623  return (*this)->g_index_reduce_x(i);
624  } catch(std::exception& e) {
625  THROW_ERROR("g_index_reduce_x", e.what());
626  }
627 }

◆ g_index_unreduce_g()

casadi_int casadi::OptiAdvanced::g_index_unreduce_g ( casadi_index  i) const

Definition at line 629 of file optistack.cpp.

629  {
630  try {
631  return (*this)->g_index_unreduce_g(i);
632  } catch(std::exception& e) {
633  THROW_ERROR("g_index_unreduce_g", e.what());
634  }
635 }

◆ g_linear_scale()

DM casadi::Opti::g_linear_scale ( ) const
inherited

Definition at line 407 of file optistack.cpp.

407  {
408  try {
409  return (*this)->g_linear_scale();
410  } catch(std::exception& e) {
411  THROW_ERROR("g_linear_scale", e.what());
412  }
413 }

◆ g_lookup()

MX casadi::OptiAdvanced::g_lookup ( casadi_index  i) const

Definition at line 637 of file optistack.cpp.

637  {
638  try {
639  return (*this)->g_lookup(i);
640  } catch(std::exception& e) {
641  THROW_ERROR("g_lookup", e.what());
642  }
643 }

Referenced by casadi::OptiNode::g_lookup().

◆ get()

Definition at line 100 of file generic_shared_impl.hpp.

104  {
105  return node;
106  }

◆ get_meta()

MetaVar casadi::OptiAdvanced::get_meta ( const MX m) const

Definition at line 548 of file optistack.cpp.

548  {
549  try {
550  return (*this)->get_meta(m);
551  } catch(std::exception& e) {
552  THROW_ERROR("get_meta", e.what());
553  }
554 }

◆ get_meta_con()

MetaCon casadi::OptiAdvanced::get_meta_con ( const MX m) const

Definition at line 556 of file optistack.cpp.

556  {
557  try {
558  return (*this)->get_meta_con(m);
559  } catch(std::exception& e) {
560  THROW_ERROR("get_meta_con", e.what());
561  }
562 }

◆ get_str()

std::string casadi::Opti::get_str ( bool  more = false) const
inherited

Definition at line 772 of file optistack.cpp.

772  {
773  std::stringstream ss;
774  disp(ss, more);
775  return ss.str();
776 }
void disp(std::ostream &stream, bool more=false) const
Print representation.
Definition: optistack.cpp:750

References casadi::Opti::disp().

Referenced by casadi::OptiSol::get_str().

◆ getCount()

casadi_int casadi::GenericShared< SharedObject , SharedObjectInternal >::getCount
inherited

Definition at line 103 of file generic_shared_impl.hpp.

127  {
128  return (*this)->getCount();
129  }

◆ initial()

std::vector< MX > casadi::Opti::initial ( ) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_266

Definition at line 278 of file optistack.cpp.

278  {
279  try {
280  return (*this)->initial();
281  } catch(std::exception& e) {
282  THROW_ERROR("initial", e.what());
283  }
284 }

◆ instance_number()

casadi_int casadi::OptiAdvanced::instance_number ( ) const

Definition at line 742 of file optistack.cpp.

742  {
743  try {
744  return (*this)->instance_number();
745  } catch(std::exception& e) {
746  THROW_ERROR("instance_number", e.what());
747  }
748 }

Referenced by casadi::Opti::disp().

◆ is_null()

Definition at line 117 of file generic_shared_impl.hpp.

109  {
110  return node==nullptr;
111  }

◆ is_parametric()

bool casadi::OptiAdvanced::is_parametric ( const MX expr) const

Definition at line 508 of file optistack.cpp.

508  {
509  try {
510  return (*this)->is_parametric(expr);
511  } catch(std::exception& e) {
512  THROW_ERROR("is_parametric", e.what());
513  }
514 }

◆ lam_g()

MX casadi::Opti::lam_g ( ) 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

Definition at line 383 of file optistack.cpp.

383  {
384  try {
385  return (*this)->lam_g();
386  } catch(std::exception& e) {
387  THROW_ERROR("lam_g", e.what());
388  }
389 }

◆ lbg()

MX casadi::Opti::lbg ( ) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_26f

Definition at line 366 of file optistack.cpp.

366  {
367  try {
368  return (*this)->lbg();
369  } catch(std::exception& e) {
370  THROW_ERROR("lbg", e.what());
371  }
372 }

◆ mark_problem_dirty()

void casadi::OptiAdvanced::mark_problem_dirty ( bool  flag = true)

Definition at line 786 of file optistack.cpp.

786  {
787  try {
788  (*this)->mark_problem_dirty(flag);
789  } catch(std::exception& e) {
790  THROW_ERROR("mark_problem_dirty", e.what());
791  }
792 }

◆ mark_solved()

void casadi::OptiAdvanced::mark_solved ( bool  flag = true)

Definition at line 816 of file optistack.cpp.

816  {
817  try {
818  (*this)->mark_solved(flag);
819  } catch(std::exception& e) {
820  THROW_ERROR("mark_solved", e.what());
821  }
822 }

◆ mark_solver_dirty()

void casadi::OptiAdvanced::mark_solver_dirty ( bool  flag = true)

Definition at line 801 of file optistack.cpp.

801  {
802  try {
803  (*this)->mark_solver_dirty(flag);
804  } catch(std::exception& e) {
805  THROW_ERROR("mark_solver_dirty", e.what());
806  }
807 }

◆ minimize()

void casadi::Opti::minimize ( const MX f,
double  linear_scale = 1 
)
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

Definition at line 114 of file optistack.cpp.

114  {
115  try {
116  (*this)->minimize(f, linear_scale);
117  } catch(std::exception& e) {
118  THROW_ERROR("minimize", e.what());
119  }
120 }
MX f() const
Get objective expression.
Definition: optistack.cpp:358

References casadi::Opti::f().

◆ ng()

casadi_int casadi::Opti::ng ( ) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_26a

Definition at line 326 of file optistack.cpp.

326  {
327  try {
328  return (*this)->ng();
329  } catch(std::exception& e) {
330  THROW_ERROR("ng", e.what());
331  }
332 }

Referenced by casadi::Opti::disp().

◆ np()

casadi_int casadi::Opti::np ( ) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_269

Definition at line 318 of file optistack.cpp.

318  {
319  try {
320  return (*this)->np();
321  } catch(std::exception& e) {
322  THROW_ERROR("nx", e.what());
323  }
324 }

Referenced by casadi::Opti::disp().

◆ nx()

casadi_int casadi::Opti::nx ( ) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_268

Definition at line 310 of file optistack.cpp.

310  {
311  try {
312  return (*this)->nx();
313  } catch(std::exception& e) {
314  THROW_ERROR("nx", e.what());
315  }
316 }

Referenced by casadi::Opti::disp().

◆ objective()

MX casadi::OptiAdvanced::objective ( ) const

Definition at line 722 of file optistack.cpp.

722  {
723  return f();
724 }

References casadi::Opti::f().

◆ operator->() [1/2]

OptiNode * casadi::Opti::operator-> ( )
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1r

Definition at line 38 of file optistack.cpp.

38  {
39  return static_cast<OptiNode*>(SharedObject::operator->());
40 }
SharedObjectInternal * operator->() const
Access a member function or object.

References casadi::GenericShared< SharedObject, SharedObjectInternal >::operator->().

◆ operator->() [2/2]

const OptiNode * casadi::Opti::operator-> ( ) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1s

Definition at line 42 of file optistack.cpp.

42  {
43  return static_cast<const OptiNode*>(SharedObject::operator->());
44 }

References casadi::GenericShared< SharedObject, SharedObjectInternal >::operator->().

◆ own()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::own ( Internal *  node)
inherited

Assign the node to a node class pointer (or null)

Definition at line 90 of file generic_shared_impl.hpp.

◆ p()

MX casadi::Opti::p ( ) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_26c

Definition at line 342 of file optistack.cpp.

342  {
343  try {
344  return (*this)->p();
345  } catch(std::exception& e) {
346  THROW_ERROR("p", e.what());
347  }
348 }

◆ parameter() [1/3]

MX casadi::Opti::parameter ( casadi_int  n = 1,
casadi_int  m = 1,
const std::string &  attribute = "full" 
)
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.

Parameters
[in]nnumber of rows (default 1)
[in]mnumber of columnss (default 1)
[in]attribute'full' (default) or 'symmetric'

Extra doc: https://github.com/casadi/casadi/wiki/L_19

Definition at line 90 of file optistack.cpp.

90  {
91  try {
92  return (*this)->parameter(n, m, attribute);
93  } catch(std::exception& e) {
94  THROW_ERROR("parameter", e.what());
95  }
96 }

◆ parameter() [2/3]

MX casadi::Opti::parameter ( const MX symbol,
const std::string &  attribute = "full" 
)
inherited

Definition at line 106 of file optistack.cpp.

106  {
107  try {
108  return (*this)->parameter(symbol, attribute);
109  } catch(std::exception& e) {
110  THROW_ERROR("parameter", e.what());
111  }
112 }

◆ parameter() [3/3]

MX casadi::Opti::parameter ( const Sparsity sp,
const std::string &  attribute = "full" 
)
inherited

Definition at line 98 of file optistack.cpp.

98  {
99  try {
100  return (*this)->parameter(sp, attribute);
101  } catch(std::exception& e) {
102  THROW_ERROR("parameter", e.what());
103  }
104 }

◆ print_ptr()

void casadi::SharedObject::print_ptr ( std::ostream &  stream = casadi::uout()) const
inherited

Print the pointer to the internal class

Definition at line 43 of file shared_object.cpp.

43  {
44  stream << get();
45  }
SharedObjectInternal * get() const
Get a const pointer to the node.

References casadi::GenericShared< SharedObject, SharedObjectInternal >::get().

◆ problem_dirty()

bool casadi::OptiAdvanced::problem_dirty ( ) const

Definition at line 793 of file optistack.cpp.

793  {
794  try {
795  return (*this)->problem_dirty();
796  } catch(std::exception& e) {
797  THROW_ERROR("problem_dirty", e.what());
798  }
799 }

Referenced by casadi::OptiNode::baked_copy(), and casadi::Opti::disp().

◆ res() [1/2]

DMDict casadi::OptiAdvanced::res ( ) const

Definition at line 707 of file optistack.cpp.

707  {
708  try {
709  return (*this)->res();
710  } catch(std::exception& e) {
711  THROW_ERROR("res", e.what());
712  }
713 }

Referenced by res().

◆ res() [2/2]

void casadi::OptiAdvanced::res ( const DMDict res)

Definition at line 699 of file optistack.cpp.

699  {
700  try {
701  return (*this)->res(res);
702  } catch(std::exception& e) {
703  THROW_ERROR("res", e.what());
704  }
705 }
DMDict res() const
Definition: optistack.cpp:707

References res().

◆ return_status()

std::string casadi::Opti::return_status ( ) const
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

Definition at line 270 of file optistack.cpp.

270  {
271  try {
272  return (*this)->return_status();
273  } catch(std::exception& e) {
274  THROW_ERROR("return_status", e.what());
275  }
276 }

Referenced by casadi::Opti::disp().

◆ scale_helper()

Function casadi::Opti::scale_helper ( const Function h) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_2ci

Definition at line 254 of file optistack.cpp.

254  {
255  try {
256  return (*this)->scale_helper(h);
257  } catch(std::exception& e) {
258  THROW_ERROR("scale_helper", e.what());
259  }
260 }

Referenced by casadi::OptiNode::scale_helper().

◆ set_domain()

void casadi::Opti::set_domain ( const MX x,
const std::string &  domain 
)
inherited
Parameters
[in]xdecision 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

Definition at line 189 of file optistack.cpp.

189  {
190  try {
191  (*this)->set_domain(x, domain);
192  } catch(std::exception& e) {
193  THROW_ERROR("set_domain", e.what());
194  }
195 }

References casadi::Opti::x().

◆ set_initial() [1/2]

void casadi::Opti::set_initial ( const MX x,
const DM v 
)
inherited

Set initial guess for decision variables

* opti.set_initial(x, 2)
* opti.set_initial(10*x(1), 2)
* 

Definition at line 165 of file optistack.cpp.

165  {
166  try {
167  (*this)->set_initial(x, v);
168  } catch(std::exception& e) {
169  THROW_ERROR("set_initial", e.what());
170  }
171 }

References casadi::Opti::x().

◆ set_initial() [2/2]

void casadi::Opti::set_initial ( const std::vector< MX > &  assignments)
inherited

Set initial guess for decision variables

* opti.set_initial(x, 2)
* opti.set_initial(10*x(1), 2)
* 

Definition at line 172 of file optistack.cpp.

172  {
173  try {
174  (*this)->set_initial(assignments);
175  } catch(std::exception& e) {
176  THROW_ERROR("set_initial", e.what());
177  }
178 }

◆ set_linear_scale()

void casadi::Opti::set_linear_scale ( const MX x,
const DM scale,
const DM offset = 0 
)
inherited

(x-offset)/scale will be used in the optimization problem

Parameters
[in]xdecision variable
[in]scalescaling value (default: 1)
[in]offsetscaling value (default: 0)
* opti.set_linear_scale(x, 20)
* opti.set_linear_scale(x, 20, 273.15)
* 

Extra doc: https://github.com/casadi/casadi/wiki/L_2bs

Definition at line 197 of file optistack.cpp.

197  {
198  try {
199  (*this)->set_linear_scale(x, scale, offset);
200  } catch(std::exception& e) {
201  THROW_ERROR("set_linear_scale", e.what());
202  }
203 }

References casadi::Opti::x().

◆ set_meta()

void casadi::OptiAdvanced::set_meta ( const MX m,
const MetaVar meta 
)

Definition at line 564 of file optistack.cpp.

564  {
565  try {
566  (*this)->set_meta(m, meta);
567  } catch(std::exception& e) {
568  THROW_ERROR("set_meta", e.what());
569  }
570 }

◆ set_meta_con()

void casadi::OptiAdvanced::set_meta_con ( const MX m,
const MetaCon meta 
)

Definition at line 572 of file optistack.cpp.

572  {
573  try {
574  return (*this)->set_meta_con(m, meta);
575  } catch(std::exception& e) {
576  THROW_ERROR("set_meta_con", e.what());
577  }
578 }

◆ set_value() [1/2]

void casadi::Opti::set_value ( const MX x,
const DM v 
)
inherited

Each parameter must be given a value before 'solve' can be called

Extra doc: https://github.com/casadi/casadi/wiki/L_1d

Definition at line 181 of file optistack.cpp.

181  {
182  try {
183  (*this)->set_value(x, v);
184  } catch(std::exception& e) {
185  THROW_ERROR("set_value", e.what());
186  }
187 }

References casadi::Opti::x().

◆ set_value() [2/2]

void casadi::Opti::set_value ( const std::vector< MX > &  assignments)
inherited

Each parameter must be given a value before 'solve' can be called

Extra doc: https://github.com/casadi/casadi/wiki/L_1d

Definition at line 205 of file optistack.cpp.

205  {
206  try {
207  (*this)->set_value(assignments);
208  } catch(std::exception& e) {
209  THROW_ERROR("set_value", e.what());
210  }
211 }

◆ show_infeasibilities()

void casadi::OptiAdvanced::show_infeasibilities ( double  tol = 0,
const Dict opts = Dict() 
) const

Definition at line 667 of file optistack.cpp.

667  {
668  try {
669  (*this)->show_infeasibilities(tol, opts);
670  } catch(std::exception& e) {
671  THROW_ERROR("show_infeasibilities", e.what());
672  }
673 }

◆ solve()

OptiSol casadi::Opti::solve ( )
inherited

Definition at line 213 of file optistack.cpp.

213  {
214  try {
215  return (*this)->solve(false);
216  } catch(std::exception& e) {
217  THROW_ERROR("solve", e.what());
218  }
219 }

◆ solve_actual()

DMDict casadi::OptiAdvanced::solve_actual ( const DMDict args)

Definition at line 682 of file optistack.cpp.

682  {
683  try {
684  return (*this)->solve_actual(args);
685  } catch(std::exception& e) {
686  THROW_ERROR("solve_actual", e.what());
687  }
688 }

◆ solve_limited()

OptiSol casadi::Opti::solve_limited ( )
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

Definition at line 221 of file optistack.cpp.

221  {
222  try {
223  return (*this)->solve(true);
224  } catch(std::exception& e) {
225  THROW_ERROR("solve", e.what());
226  }
227 }

◆ solve_prepare()

void casadi::OptiAdvanced::solve_prepare ( )

Definition at line 675 of file optistack.cpp.

675  {
676  try {
677  (*this)->solve_prepare();
678  } catch(std::exception& e) {
679  THROW_ERROR("solve_prepare", e.what());
680  }
681 }

◆ solved()

bool casadi::OptiAdvanced::solved ( ) const

Definition at line 824 of file optistack.cpp.

824  {
825  try {
826  return (*this)->solved();
827  } catch(std::exception& e) {
828  THROW_ERROR("solved", e.what());
829  }
830 }

Referenced by casadi::Opti::disp().

◆ solver()

void casadi::Opti::solver ( const std::string &  solver,
const Dict plugin_options = Dict(),
const Dict solver_options = Dict() 
)
inherited
Parameters
[in]solverany of the nlpsol plugins can be used here In practice, not all nlpsol plugins may be supported yet
[in]optionspassed on to nlpsol plugin No stability can be guaranteed about this part of the API
[in]optionsto 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

Definition at line 155 of file optistack.cpp.

157  {
158  try {
159  (*this)->solver(solver, plugin_options, solver_options);
160  } catch(std::exception& e) {
161  THROW_ERROR("solver", e.what());
162  }
163 }
void solver(const std::string &solver, const Dict &plugin_options=Dict(), const Dict &solver_options=Dict())
Set a solver.
Definition: optistack.cpp:155

◆ solver_dirty()

bool casadi::OptiAdvanced::solver_dirty ( ) const

Definition at line 808 of file optistack.cpp.

808  {
809  try {
810  return (*this)->solver_dirty();
811  } catch(std::exception& e) {
812  THROW_ERROR("solver_dirty", e.what());
813  }
814 }

Referenced by casadi::Opti::disp().

◆ stats()

Dict casadi::Opti::stats ( ) 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

Definition at line 262 of file optistack.cpp.

262  {
263  try {
264  return (*this)->stats();
265  } catch(std::exception& e) {
266  THROW_ERROR("stats", e.what());
267  }
268 }

Referenced by casadi::OptiSol::stats().

◆ subject_to() [1/5]

void casadi::Opti::subject_to ( )
inherited

Definition at line 146 of file optistack.cpp.

146  {
147  try {
148  (*this)->subject_to();
149  } catch(std::exception& e) {
150  THROW_ERROR("subject_to", e.what());
151  }
152 }

Referenced by casadi::Opti::subject_to().

◆ subject_to() [2/5]

void casadi::Opti::subject_to ( const MX g,
const Dict options = Dict() 
)
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.lbg,opti.g,opti.ubg represent the vector of flattened constraints
  • opti.debug.show_infeasibilities() may be used to inspect which constraints are violated

    Extra doc: https://github.com/casadi/casadi/wiki/L_1b

Definition at line 122 of file optistack.cpp.

122  {
123  try {
124  (*this)->subject_to(g, 1, options);
125  } catch(std::exception& e) {
126  THROW_ERROR("subject_to", e.what());
127  }
128 }
MX g() const
Get all (scalarised) constraint expressions as a column vector.
Definition: optistack.cpp:350

References casadi::Opti::g().

◆ subject_to() [3/5]

void casadi::Opti::subject_to ( const MX g,
const DM linear_scale,
const Dict options = Dict() 
)
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.lbg,opti.g,opti.ubg represent the vector of flattened constraints
  • opti.debug.show_infeasibilities() may be used to inspect which constraints are violated

    Extra doc: https://github.com/casadi/casadi/wiki/L_1b

Definition at line 134 of file optistack.cpp.

134  {
135  try {
136  (*this)->subject_to(g, linear_scale, options);
137  } catch(std::exception& e) {
138  THROW_ERROR("subject_to", e.what());
139  }
140 }

References casadi::Opti::g().

◆ subject_to() [4/5]

void casadi::Opti::subject_to ( const std::vector< MX > &  g,
const Dict options = Dict() 
)
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.lbg,opti.g,opti.ubg represent the vector of flattened constraints
  • opti.debug.show_infeasibilities() may be used to inspect which constraints are violated

    Extra doc: https://github.com/casadi/casadi/wiki/L_1b

Definition at line 130 of file optistack.cpp.

130  {
131  for (const auto& gs : g) subject_to(gs, 1, options);
132 }
void subject_to()
Clear constraints.
Definition: optistack.cpp:146

References casadi::Opti::g(), and casadi::Opti::subject_to().

◆ subject_to() [5/5]

void casadi::Opti::subject_to ( const std::vector< MX > &  g,
const DM linear_scale,
const Dict options = Dict() 
)
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.lbg,opti.g,opti.ubg represent the vector of flattened constraints
  • opti.debug.show_infeasibilities() may be used to inspect which constraints are violated

    Extra doc: https://github.com/casadi/casadi/wiki/L_1b

Definition at line 142 of file optistack.cpp.

142  {
143  for (const auto& gs : g) subject_to(gs, linear_scale, options);
144 }

References casadi::Opti::g(), and casadi::Opti::subject_to().

◆ swap()

Definition at line 106 of file generic_shared_impl.hpp.

120  {
121  GenericShared<Shared, Internal> temp = *this;
122  *this = other;
123  other = temp;
124  }

◆ symvar() [1/3]

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

Definition at line 516 of file optistack.cpp.

516  {
517  try {
518  return (*this)->symvar();
519  } catch(std::exception& e) {
520  THROW_ERROR("symvar", e.what());
521  }
522 }

◆ symvar() [2/3]

std::vector< MX > casadi::OptiAdvanced::symvar ( const MX expr) 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

Definition at line 524 of file optistack.cpp.

524  {
525  try {
526  return (*this)->symvar(expr);
527  } catch(std::exception& e) {
528  THROW_ERROR("symvar", e.what());
529  }
530 }

◆ symvar() [3/3]

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

Definition at line 532 of file optistack.cpp.

532  {
533  try {
534  return (*this)->symvar(expr, type);
535  } catch(std::exception& e) {
536  THROW_ERROR("symvar", e.what());
537  }
538 }

◆ to_function() [1/3]

Function casadi::Opti::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() 
)
inherited
Parameters
[in]nameName of the resulting CasADi Function
[in]argsList of parameters and decision/dual variables (which can be given an initial guess) with the resulting Function
[in]resList of expressions that will get evaluated at the optimal solution
[in]optsStandard CasADi Funcion options

Extra doc: https://github.com/casadi/casadi/wiki/L_1j

Definition at line 441 of file optistack.cpp.

445  {
446  std::vector<MX> ex_in(name_in.size()), ex_out(name_out.size());
447  for (auto&& i : dict) {
448  std::vector<std::string>::const_iterator it;
449  if ((it=find(name_in.begin(), name_in.end(), i.first))!=name_in.end()) {
450  // Input expression
451  ex_in[it-name_in.begin()] = i.second;
452  } else if ((it=find(name_out.begin(), name_out.end(), i.first))!=name_out.end()) {
453  // Output expression
454  ex_out[it-name_out.begin()] = i.second;
455  } else {
456  // Neither
457  casadi_error("Unknown dictionary entry: '" + i.first + "'");
458  }
459  }
460  return to_function(name, ex_in, ex_out, name_in, name_out, opts);
461 }
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.
Definition: optistack.cpp:435
std::vector< casadi_int > find(const std::vector< T > &v)
find nonzeros

References casadi::find(), and casadi::Opti::to_function().

◆ to_function() [2/3]

Function casadi::Opti::to_function ( const std::string &  name,
const std::vector< MX > &  args,
const std::vector< MX > &  res,
const Dict opts = Dict() 
)
inherited
Parameters
[in]nameName of the resulting CasADi Function
[in]argsList of parameters and decision/dual variables (which can be given an initial guess) with the resulting Function
[in]resList of expressions that will get evaluated at the optimal solution
[in]optsStandard CasADi Funcion options

Extra doc: https://github.com/casadi/casadi/wiki/L_1j

Definition at line 435 of file optistack.cpp.

437  {
438  return to_function(name, args, res, {}, {}, opts);
439 }

Referenced by casadi::Opti::to_function(), and casadi::OptiNode::to_function().

◆ to_function() [3/3]

Function casadi::Opti::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() 
)
inherited
Parameters
[in]nameName of the resulting CasADi Function
[in]argsList of parameters and decision/dual variables (which can be given an initial guess) with the resulting Function
[in]resList of expressions that will get evaluated at the optimal solution
[in]optsStandard CasADi Funcion options

Extra doc: https://github.com/casadi/casadi/wiki/L_1j

Definition at line 423 of file optistack.cpp.

427  {
428  try {
429  return (*this)->to_function(name, args, res, name_in, name_out, opts);
430  } catch(std::exception& e) {
431  THROW_ERROR("to_function", e.what());
432  }
433 }

◆ type_name()

std::string casadi::Opti::type_name ( ) const
inlineinherited

Definition at line 440 of file optistack.hpp.

440 { return "Opti"; }

◆ ubg()

MX casadi::Opti::ubg ( ) const
inherited

Definition at line 374 of file optistack.cpp.

374  {
375  try {
376  return (*this)->ubg();
377  } catch(std::exception& e) {
378  THROW_ERROR("ubg", e.what());
379  }
380 }

◆ update_user_dict() [1/2]

void casadi::Opti::update_user_dict ( const MX m,
const Dict meta 
)
inherited

Add arbitrary data in the form of a dictionary to symbols or constraints

Extra doc: https://github.com/casadi/casadi/wiki/L_1o

Definition at line 479 of file optistack.cpp.

479  {
480  try {
481  (*this)->update_user_dict(m, meta);
482  } catch(std::exception& e) {
483  THROW_ERROR("update_user_dict", e.what());
484  }
485 }

Referenced by casadi::Opti::update_user_dict().

◆ update_user_dict() [2/2]

void casadi::Opti::update_user_dict ( const std::vector< MX > &  m,
const Dict meta 
)
inherited

Definition at line 487 of file optistack.cpp.

487  {
488  for (const auto& m : ms)
489  update_user_dict(m, meta);
490 }
void update_user_dict(const MX &m, const Dict &meta)
add user data
Definition: optistack.cpp:479

References casadi::Opti::update_user_dict().

◆ user_dict()

Dict casadi::Opti::user_dict ( const MX m) const
inherited

Definition at line 492 of file optistack.cpp.

492  {
493  try {
494  return (*this)->user_dict(m);
495  } catch(std::exception& e) {
496  THROW_ERROR("user_dict", e.what());
497  }
498 }

◆ value() [1/3]

DM casadi::Opti::value ( const DM x,
const std::vector< MX > &  values = std::vector<MX>() 
) const
inherited
Parameters
[in]xdecision 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

Definition at line 238 of file optistack.cpp.

238  {
239  try {
240  return (*this)->value(x, values);
241  } catch(std::exception& e) {
242  THROW_ERROR("value", e.what());
243  }
244 }

References casadi::Opti::x().

◆ value() [2/3]

DM casadi::Opti::value ( const MX x,
const std::vector< MX > &  values = std::vector<MX>() 
) const
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

Parameters
[in]valuesOptional assignment expressions (e.g. x==3) to overrule the current value

Definition at line 229 of file optistack.cpp.

229  {
230  try {
231  return (*this)->value(x, values);
232  } catch(std::exception& e) {
233  THROW_ERROR("value", e.what());
234  }
235 }

References casadi::Opti::x().

Referenced by casadi::OptiSol::value().

◆ value() [3/3]

DM casadi::Opti::value ( const SX x,
const std::vector< MX > &  values = std::vector<MX>() 
) const
inherited
Parameters
[in]xdecision 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

Definition at line 246 of file optistack.cpp.

246  {
247  try {
248  return (*this)->value(x, values);
249  } catch(std::exception& e) {
250  THROW_ERROR("value", e.what());
251  }
252 }

References casadi::Opti::x().

◆ value_parameters()

std::vector< MX > casadi::Opti::value_parameters ( ) const
inherited

Definition at line 294 of file optistack.cpp.

294  {
295  try {
296  return (*this)->value_parameters();
297  } catch(std::exception& e) {
298  THROW_ERROR("value_parameters", e.what());
299  }
300 }

Referenced by casadi::OptiSol::value_parameters().

◆ value_variables()

std::vector< MX > casadi::Opti::value_variables ( ) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_267

Definition at line 286 of file optistack.cpp.

286  {
287  try {
288  return (*this)->value_variables();
289  } catch(std::exception& e) {
290  THROW_ERROR("value_variables", e.what());
291  }
292 }

Referenced by casadi::OptiSol::value_variables().

◆ variable() [1/3]

MX casadi::Opti::variable ( casadi_int  n = 1,
casadi_int  m = 1,
const std::string &  attribute = "full" 
)
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.

Parameters
[in]nnumber of rows (default 1)
[in]mnumber of columnss (default 1)
[in]attribute'full' (default) or 'symmetric'

Extra doc: https://github.com/casadi/casadi/wiki/L_18

Definition at line 51 of file optistack.cpp.

51  {
52  try {
53  return (*this)->variable(n, m, attribute);
54  } catch(std::exception& e) {
55  THROW_ERROR("variable", e.what());
56  }
57 }

◆ variable() [2/3]

MX casadi::Opti::variable ( const MX symbol,
const std::string &  attribute = "full" 
)
inherited

Definition at line 67 of file optistack.cpp.

67  {
68  try {
69  return (*this)->variable(symbol, attribute);
70  } catch(std::exception& e) {
71  THROW_ERROR("variable", e.what());
72  }
73 }

◆ variable() [3/3]

MX casadi::Opti::variable ( const Sparsity sp,
const std::string &  attribute = "full" 
)
inherited

Definition at line 59 of file optistack.cpp.

59  {
60  try {
61  return (*this)->variable(sp, attribute);
62  } catch(std::exception& e) {
63  THROW_ERROR("variable", e.what());
64  }
65 }

◆ weak()

Extra doc: https://github.com/casadi/casadi/wiki/L_aw

Definition at line 131 of file generic_shared_impl.hpp.

132  {
133  return (*this)->weak();
134  }

◆ x()

MX casadi::Opti::x ( ) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_26b

Definition at line 334 of file optistack.cpp.

334  {
335  try {
336  return (*this)->x();
337  } catch(std::exception& e) {
338  THROW_ERROR("x", e.what());
339  }
340 }

Referenced by describe(), casadi::Opti::set_domain(), casadi::Opti::set_initial(), casadi::Opti::set_linear_scale(), casadi::Opti::set_value(), and casadi::Opti::value().

◆ x_describe()

std::string casadi::OptiAdvanced::x_describe ( casadi_index  i,
const Dict opts = Dict() 
) const

Definition at line 645 of file optistack.cpp.

645  {
646  try {
647  return (*this)->x_describe(i, opts);
648  } catch(std::exception& e) {
649  THROW_ERROR("x_describe", e.what());
650  }
651 }

Referenced by casadi::OptiNode::x_describe().

◆ x_linear_scale()

DM casadi::Opti::x_linear_scale ( ) const
inherited

Definition at line 391 of file optistack.cpp.

391  {
392  try {
393  return (*this)->x_linear_scale();
394  } catch(std::exception& e) {
395  THROW_ERROR("x_linear_scale", e.what());
396  }
397 }

◆ x_linear_scale_offset()

DM casadi::Opti::x_linear_scale_offset ( ) const
inherited

Definition at line 399 of file optistack.cpp.

399  {
400  try {
401  return (*this)->x_linear_scale_offset();
402  } catch(std::exception& e) {
403  THROW_ERROR("x_linear_scale_offset", e.what());
404  }
405 }

◆ x_lookup()

MX casadi::OptiAdvanced::x_lookup ( casadi_index  i) const

Definition at line 605 of file optistack.cpp.

605  {
606  try {
607  return (*this)->x_lookup(i);
608  } catch(std::exception& e) {
609  THROW_ERROR("x_lookup", e.what());
610  }
611 }

Referenced by casadi::OptiNode::x_lookup().

Friends And Related Function Documentation

◆ InternalOptiCallback

friend class InternalOptiCallback
friend

Definition at line 552 of file optistack.hpp.

Member Data Documentation

◆ problem_dirty_

bool casadi::OptiAdvanced::problem_dirty_

Definition at line 631 of file optistack.hpp.

◆ solved_

bool casadi::OptiAdvanced::solved_

Definition at line 639 of file optistack.hpp.

◆ solver_dirty_

bool casadi::OptiAdvanced::solver_dirty_

Definition at line 635 of file optistack.hpp.


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