StabilizedQpToQp::StabilizedQpToQp(const std::vector<Sparsity> &st)
     : StabilizedQpSolverInternal(st) {
   addOption("qp_solver",         OT_STRING,   GenericType(),
             "The QP solver used to solve the stabilized QPs.");
   addOption("qp_solver_options", OT_DICTIONARY, GenericType(),
             "Options to be passed to the QP solver instance");
 }
DirectSingleShootingInternal::DirectSingleShootingInternal(const FX& ffcn, const FX& mfcn, const FX& cfcn, const FX& rfcn) : OCPSolverInternal(ffcn, mfcn, cfcn, rfcn){
  addOption("parallelization", OT_STRING, GenericType(), "Passed on to CasADi::Parallelizer");
  addOption("nlp_solver",               OT_NLPSOLVER,  GenericType(), "An NLPSolver creator function");
  addOption("nlp_solver_options",       OT_DICTIONARY, GenericType(), "Options to be passed to the NLP Solver");
  addOption("integrator",               OT_INTEGRATOR, GenericType(), "An integrator creator function");
  addOption("integrator_options",       OT_DICTIONARY, GenericType(), "Options to be passed to the integrator");
}
DirectCollocationInternal::DirectCollocationInternal(const FX& ffcn, const FX& mfcn, const FX& cfcn, const FX& rfcn) : OCPSolverInternal(ffcn, mfcn, cfcn, rfcn){
  addOption("nlp_solver",               	OT_NLPSOLVER,  GenericType(), "An NLPSolver creator function");
  addOption("nlp_solver_options",       	OT_DICTIONARY, GenericType(), "Options to be passed to the NLP Solver");
  addOption("interpolation_order",          OT_INTEGER,  3,  "Order of the interpolating polynomials");
  addOption("collocation_scheme",           OT_STRING,  "radau",  "Collocation scheme","radau|legendre");
  casadi_warning("CasADi::DirectCollocation is still experimental");
}
 ImplicitFixedStepIntegratorInternal::ImplicitFixedStepIntegratorInternal(const Function& f,
                                                                          const Function& g)
     : FixedStepIntegratorInternal(f, g) {
   addOption("implicit_solver",               OT_STRING,  GenericType(),
             "An implicit function solver");
   addOption("implicit_solver_options",       OT_DICTIONARY, GenericType(),
             "Options to be passed to the NLP Solver");
 }
  QCQPQPInternal::QCQPQPInternal(const std::vector<Sparsity> &st) : QpSolverInternal(st) {

    addOption("qcqp_solver",       OT_STRING, GenericType(),
              "The QcqpSolver used to solve the QPs.");
    addOption("qcqp_solver_options",       OT_DICTIONARY, GenericType(),
              "Options to be passed to the QCQPSOlver");

  }
  DpleToDle::DpleToDle(
         const DleStructure& st, const std::vector<int> &Hs) : DleInternal(st, Hs) {

    // set default options
    setOption("name", "unnamed_dple_to_dle"); // name of the function

    addOption("dple_solver",            OT_STRING, GenericType(),
              "User-defined DPLE solver class.");
    addOption("dple",    OT_DICT,   GenericType(),
              "Options to be passed to the DPLE solver.");

  }
  SimpleIndefDpleInternal::SimpleIndefDpleInternal(
      const DpleStructure& st,
      const std::vector< std::vector<int> > &Hs) : DpleInternal(st, Hs) {

    // set default options
    setOption("name", "unnamed_simple_indef_dple_solver"); // name of the function

    addOption("linear_solver",            OT_STRING, GenericType(),
              "User-defined linear solver class. Needed for sensitivities.");
    addOption("linear_solver_options",    OT_DICTIONARY,   GenericType(),
              "Options to be passed to the linear solver.");

  }
DirectMultipleShootingInternal::DirectMultipleShootingInternal(const Function& ffcn,
                                                               const Function& mfcn,
                                                               const Function& cfcn,
                                                               const Function& rfcn) :
    OCPSolverInternal(ffcn, mfcn, cfcn, rfcn) {
  addOption("parallelization", OT_STRING, GenericType(), "Passed on to casadi::Parallelizer");
  addOption("nlp_solver",               OT_STRING,  GenericType(),
            "An NlpSolver creator function");
  addOption("nlp_solver_options",       OT_DICTIONARY, GenericType(),
            "Options to be passed to the NLP Solver");
  addOption("integrator",               OT_STRING, GenericType(),
            "An integrator creator function");
  addOption("integrator_options",       OT_DICTIONARY, GenericType(),
            "Options to be passed to the integrator");
}
 ImplicitFunctionInternal::ImplicitFunctionInternal(const Function& f, const Function& jac,
                                                    const LinearSolver& linsol) : f_(f), jac_(jac),
                                                                                  linsol_(linsol) {
   addOption("linear_solver",            OT_STRING, GenericType(),
             "User-defined linear solver class. Needed for sensitivities.");
   addOption("linear_solver_options",    OT_DICTIONARY,   GenericType(),
             "Options to be passed to the linear solver.");
   addOption("constraints",              OT_INTEGERVECTOR, GenericType(),
             "Constrain the unknowns. 0 (default): no constraint on ui, "
             "1: ui >= 0.0, -1: ui <= 0.0, 2: ui > 0.0, -2: ui < 0.0.");
   addOption("implicit_input",           OT_INTEGER,      0,
             "Index of the input that corresponds to the actual root-finding");
   addOption("implicit_output",          OT_INTEGER,      0,
             "Index of the output that corresponds to the actual root-finding");
 }
  SimpleIndefDleInternal::SimpleIndefDleInternal(
      const DleStructure& st, const std::vector<int> &Hs) : DleInternal(st,Hs) {

    // set default options
    setOption("name", "unnamed_simple_indef_dle_solver"); // name of the function

    addOption("compressed_solve",         OT_BOOLEAN, true,
              "When a system with sparse rhs arises, compress to"
              "a smaller system with dense rhs.");
    addOption("linear_solver",            OT_STRING, GenericType(),
              "User-defined linear solver class. Needed for sensitivities.");
    addOption("linear_solver_options",    OT_DICT,   GenericType(),
              "Options to be passed to the linear solver.");

  }
Exemple #11
0
 ShellCompiler::ShellCompiler(const std::string& name) :
   CompilerInternal(name) {
   addOption("compiler", OT_STRING, "gcc", "Compiler command");
   addOption("compiler_setup", OT_STRING, "-fPIC -shared", "Compiler setup command");
   addOption("flags", OT_STRINGVECTOR, GenericType(),
     "Compile flags for the JIT compiler. Default: None");
 }
GenericType OptionsFunctionalityNode::getOption(const string &name) const{

  // Locate the option
  Dictionary::const_iterator it = dictionary_.find(name);

  // Check if found
  if(it == dictionary_.end()){
    stringstream ss;
    if (allowed_options.find(name)!=allowed_options.end()) {
      ss << "Option: '" << name << "' has not been set." << endl;
      printOption(name,ss);
    } else {
      ss << "Option: '" << name << "' does not exist." << endl << endl;
      std::vector<std::string> suggestions;
      getBestMatches(name,suggestions,5);
      ss << "Did you mean one of the following?" << endl;
      for (int i=0;i<suggestions.size();++i)
        printOption(suggestions[i],ss);
      ss << "Use printOptions() to get a full list of options." << endl;
    }
    casadi_error(ss.str());
  }
  
  // Return the option
  return GenericType(it->second);
}
  // Constructor
  SocpSolverInternal::SocpSolverInternal(const std::vector<Sparsity> &st) : st_(st) {
    addOption("ni", OT_INTEGERVECTOR, GenericType(),
              "Provide the size of each SOC constraint. Must sum up to N.");
    addOption("print_problem", OT_BOOLEAN, false, "Print out problem statement for debugging.");

    input_.scheme = SCHEME_SOCPInput;
    output_.scheme = SCHEME_SOCPOutput;

  }
  SimulatorInternal::SimulatorInternal(const Integrator& integrator,
                                       const Function& output_fcn,
                                       const vector<double>& grid) :
      integrator_(integrator), output_fcn_(output_fcn), grid_(grid) {
    setOption("name", "unnamed simulator");
    addOption("monitor",      OT_STRINGVECTOR, GenericType(),  "", "initial|step", true);

    input_.scheme = SCHEME_IntegratorInput;
  }
Exemple #15
0
void ConversionDiagnoseInfTgt(  // DIAGNOSE TARGET CONVERSION
    void )
{
    if( cnv_type_tgt != NULL ) {
        if( NULL == GenericType( cnv_type_tgt ) ) {
            infMsgType( INF_TGT_CNV_TYPE, cnv_type_tgt );
        }
    }
    ConversionInfDisable();
}
Exemple #16
0
SQPInternal::SQPInternal(const FX& F, const FX& G, const FX& H, const FX& J) : NLPSolverInternal(F,G,H,J){
  casadi_warning("The SQP method is under development");
  addOption("qp_solver",         OT_QPSOLVER,   GenericType(),    "The QP solver to be used by the SQP method");
  addOption("qp_solver_options", OT_DICTIONARY, GenericType(),    "Options to be passed to the QP solver");
  addOption("hessian_approximation", OT_STRING, "limited-memory", "limited-memory|exact");
  addOption("maxiter",           OT_INTEGER,      50,             "Maximum number of SQP iterations");
  addOption("maxiter_ls",        OT_INTEGER,       3,             "Maximum number of linesearch iterations");
  addOption("tol_pr",            OT_REAL,       1e-6,             "Stopping criterion for primal infeasibility");
  addOption("tol_du",            OT_REAL,       1e-6,             "Stopping criterion for dual infeasability");
  addOption("c1",                OT_REAL,       1E-4,             "Armijo condition, coefficient of decrease in merit");
  addOption("beta",              OT_REAL,       0.8,              "Line-search parameter, restoration factor of stepsize");
  addOption("merit_memory",      OT_INTEGER,      4,              "Size of memory to store history of merit function values");
  addOption("lbfgs_memory",      OT_INTEGER,     10,              "Size of L-BFGS memory.");
  addOption("regularize",        OT_BOOLEAN,  false,              "Automatic regularization of Lagrange Hessian.");
  addOption("print_header",      OT_BOOLEAN,   true,              "Print the header with problem statistics");
  
  // Monitors
  addOption("monitor",      OT_STRINGVECTOR, GenericType(),  "", "eval_f|eval_g|eval_jac_g|eval_grad_f|eval_h|qp|dx", true);
}
Exemple #17
0
  Newton::Newton(const Function& f) : ImplicitFunctionInternal(f) {
    addOption("abstol",                      OT_REAL, 1e-12,
              "Stopping criterion tolerance on max(|F|)");
    addOption("abstolStep",                  OT_REAL, 1e-12,
              "Stopping criterion tolerance on step size");
    addOption("max_iter",  OT_INTEGER, 1000,
              "Maximum number of Newton iterations to perform before returning.");
    addOption("monitor",   OT_STRINGVECTOR, GenericType(),  "", "step|stepsize|J|F|normF", true);

    addOption("print_iteration", OT_BOOLEAN, false,
              "Print information about each iteration");
  }
LiftedSQPInternal::LiftedSQPInternal(const Function& F, const Function& G) : NlpSolverInternal(Function(),F,G){
  casadi_warning("casadi::LiftedSQP has been replaced by casadi::SCPgen. This class will be deleted.");
  addOption("qp_solver",         OT_QPSOLVER,   GenericType(), "The QP solver to be used by the SQP method");
  addOption("qp_solver_options", OT_DICTIONARY, GenericType(), "Options to be passed to the QP solver");
  addOption("max_iter",           OT_INTEGER,    100,           "Maximum number of SQP iterations");
  addOption("max_iter_ls",        OT_INTEGER,    100,           "Maximum number of linesearch iterations");
  addOption("toldx",             OT_REAL   ,    1e-12,         "Stopping criterion for the stepsize");
  addOption("tolgl",             OT_REAL   ,    1e-12,         "Stopping criterion for the Lagrangian gradient");
  addOption("sigma",             OT_REAL   ,    1.0,           "Linesearch parameter");
  addOption("rho",               OT_REAL   ,    0.5,           "Linesearch parameter");
  addOption("mu_safety",         OT_REAL   ,    1.1,           "Safety factor for linesearch mu");
  addOption("eta",               OT_REAL   ,    0.0001,        "Linesearch parameter: See Nocedal 3.4");
  addOption("tau",               OT_REAL   ,    0.2,           "Linesearch parameter");
  addOption("hessian_approximation", OT_STRING, "BFGS",        "BFGS|exact");
  addOption("num_lifted",        OT_INTEGER,   0,              "Number of variables to lift");
  
  // Monitors
  addOption("monitor",      OT_STRINGVECTOR, GenericType(),  "", "eval_f|eval_g|eval_jac_g|eval_grad_f|eval_h|qp", true);
  
  // Set default options
  setOption("generate_jacobian", false);
}
Exemple #19
0
  Sqpmethod::Sqpmethod(const Function& nlp) : NlpSolverInternal(nlp) {
    casadi_warning("The SQP method is under development");
    addOption("qp_solver",         OT_STRING,   GenericType(),
              "The QP solver to be used by the SQP method");
    addOption("qp_solver_options", OT_DICT, GenericType(),
              "Options to be passed to the QP solver");
    addOption("hessian_approximation", OT_STRING, "exact",
              "limited-memory|exact");
    addOption("max_iter",           OT_INTEGER,      50,
              "Maximum number of SQP iterations");
    addOption("max_iter_ls",        OT_INTEGER,       3,
              "Maximum number of linesearch iterations");
    addOption("tol_pr",            OT_REAL,       1e-6,
              "Stopping criterion for primal infeasibility");
    addOption("tol_du",            OT_REAL,       1e-6,
              "Stopping criterion for dual infeasability");
    addOption("c1",                OT_REAL,       1E-4,
              "Armijo condition, coefficient of decrease in merit");
    addOption("beta",              OT_REAL,       0.8,
              "Line-search parameter, restoration factor of stepsize");
    addOption("merit_memory",      OT_INTEGER,      4,
              "Size of memory to store history of merit function values");
    addOption("lbfgs_memory",      OT_INTEGER,     10,
              "Size of L-BFGS memory.");
    addOption("regularize",        OT_BOOLEAN,  false,
              "Automatic regularization of Lagrange Hessian.");
    addOption("print_header",      OT_BOOLEAN,   true,
              "Print the header with problem statistics");
    addOption("min_step_size",     OT_REAL,   1e-10,
              "The size (inf-norm) of the step size should not become smaller than this.");

    // Monitors
    addOption("monitor",      OT_STRINGVECTOR, GenericType(),  "",
              "eval_f|eval_g|eval_jac_g|eval_grad_f|eval_h|qp|dx|bfgs", true);
    addOption("print_time",         OT_BOOLEAN,       true,
              "Print information about execution time");
  }
CollocationIntegratorInternal::CollocationIntegratorInternal(const FX& f, const FX& g) : IntegratorInternal(f,g){
  addOption("number_of_finite_elements",     OT_INTEGER,  20, "Number of finite elements");
  addOption("interpolation_order",           OT_INTEGER,  3,  "Order of the interpolating polynomials");
  addOption("collocation_scheme",            OT_STRING,  "radau",  "Collocation scheme","radau|legendre");
  addOption("implicit_solver",               OT_IMPLICITFUNCTION,  GenericType(), "An implicit function solver");
  addOption("implicit_solver_options",       OT_DICTIONARY, GenericType(), "Options to be passed to the NLP Solver");
  addOption("expand_f",                      OT_BOOLEAN,  false, "Expand the ODE/DAE residual function in an SX graph");
  addOption("expand_q",                      OT_BOOLEAN,  false, "Expand the quadrature function in an SX graph");
  addOption("hotstart",                      OT_BOOLEAN,  true, "Initialize the trajectory at the previous solution");
  addOption("quadrature_solver",             OT_LINEARSOLVER,  GenericType(), "An linear solver to solver the quadrature equations");
  addOption("quadrature_solver_options",     OT_DICTIONARY, GenericType(), "Options to be passed to the quadrature solver");
  addOption("startup_integrator",            OT_INTEGRATOR,  GenericType(), "An ODE/DAE integrator that can be used to generate a startup trajectory");
  addOption("startup_integrator_options",    OT_DICTIONARY, GenericType(), "Options to be passed to the startup integrator");
  setOption("name","unnamed_collocation_integrator");
}
                               const std::vector<std::string> &dictionary,
                               std::vector<std::string> &suggestions, int amount = 5);

  /** \brief Get th ebest suggestions of option names
  */
  double getBestMatches(const std::string & name, std::vector<std::string> &suggestions,
                        int amount = 5) const;


  /** \brief A distance metric between two words */
  static double wordDistance(const std::string &a, const std::string &b);


  void addOption(
    const std::string &str, const opt_type& type,
    const GenericType &def_val=GenericType(), const std::string& desc="n/a",
    const std::vector<GenericType> &allowed_vals = std::vector<GenericType>(),
    bool inherit = false, std::vector<int> enum_values= std::vector<int>(),
    std::vector<std::string> enum_descr= std::vector<std::string>());
  /** \brief Add an option
  *
  *  allowed_vals can take multiple forms:
  *    "foo|bar"   ->   specifies that the values "foo" and "bar" are allowed
  *    "foo:5|bar:6" -> specifies that the values "foo" and "bar" are allowed and map
  *                     to 5 and 6 respectively
  *    "foo:5:description_foo|bar:6:description_bar|" -> same as above, but specifies documentation
  *
  **/
  void addOption(const std::string &str, const opt_type& type, const GenericType &def_val,
                 const std::string& desc, const std::string &allowed_vals, bool inherit = false);
 SDPSDQPInternal::SDPSDQPInternal(const std::vector<Sparsity> &st) : SdqpSolverInternal(st) {
   addOption("sdp_solver",            OT_STRING, GenericType(),
             "The SdpSolver used to solve the SDQPs.");
   addOption("sdp_solver_options",    OT_DICTIONARY, GenericType(),
             "Options to be passed to the SDPSOlver");
 }
GenericType OptionsFunctionalityNode::getOptionDefault(const std::string &name) const {
  assert_exists(name);
  Dictionary::const_iterator it = defaults_.find(name);
  if (it!=defaults_.end()) return it->second;
  return GenericType();
}
ImplicitFunctionInternal::ImplicitFunctionInternal(const FX& f, int nrhs) : f_(f), nrhs_(nrhs){
  addOption("linear_solver",    OT_LINEARSOLVER, GenericType(), "User-defined linear solver class. Needed for sensitivities.");
  addOption("linear_solver_options",    OT_DICTIONARY, GenericType(), "Options to be passed to the linear solver.");
}
  // Constructor
  StabilizedQpSolverInternal::
  StabilizedQpSolverInternal(const std::map<std::string, Sparsity> &st) {
    st_.resize(QP_STRUCT_NUM);
    for (std::map<std::string, Sparsity>::const_iterator i=st.begin(); i!=st.end(); ++i) {
      if (i->first=="a") {
        st_[QP_STRUCT_A]=i->second;
      } else if (i->first=="h") {
        st_[QP_STRUCT_H]=i->second;
      } else {
        casadi_error("Unrecognized field in QP structure: " << i->first);
      }
    }

    // Get structure
    const Sparsity& A = st_[QP_STRUCT_A];
    const Sparsity& H = st_[QP_STRUCT_H];

    // Dimensions
    n_ = H.size2();
    nc_ = A.isNull() ? 0 : A.size1();

    addOption("defaults_recipes",    OT_STRINGVECTOR, GenericType(), "",
                                                       "qp", true);

    // Check consistency
    casadi_assert_message(A.isNull() || A.size2()==n_,
      "Got incompatible dimensions.   min          x'Hx + G'x s.t.   LBA <= Ax <= UBA :"
       << std::endl <<
      "H: " << H.dimString() << " - A: " << A.dimString() << std::endl <<
      "We need: H.size2()==A.size2()" << std::endl);

    casadi_assert_message(H.issymmetric(),
      "Got incompatible dimensions.   min          x'Hx + G'x" << std::endl <<
      "H: " << H.dimString() <<
      "We need H square & symmetric" << std::endl);

    // IO sparsities
    Sparsity x_sparsity = Sparsity::dense(n_, 1);
    Sparsity a_sparsity = Sparsity::dense(nc_, 1);

    // Input arguments
    ibuf_.resize(STABILIZED_QP_SOLVER_NUM_IN);
    input(STABILIZED_QP_SOLVER_X0)  =  DMatrix::zeros(x_sparsity);
    input(STABILIZED_QP_SOLVER_H)   =  DMatrix::zeros(H);
    input(STABILIZED_QP_SOLVER_G)   =  DMatrix::zeros(x_sparsity);
    input(STABILIZED_QP_SOLVER_A)   =  DMatrix::zeros(A);
    input(STABILIZED_QP_SOLVER_LBA) = -DMatrix::inf(a_sparsity);
    input(STABILIZED_QP_SOLVER_UBA) =  DMatrix::inf(a_sparsity);
    input(STABILIZED_QP_SOLVER_LBX) = -DMatrix::inf(x_sparsity);
    input(STABILIZED_QP_SOLVER_UBX) =  DMatrix::inf(x_sparsity);
    input(STABILIZED_QP_SOLVER_MUR) =  0.0;
    input(STABILIZED_QP_SOLVER_MUE) =  DMatrix::zeros(a_sparsity);
    input(STABILIZED_QP_SOLVER_MU)  =  DMatrix::zeros(a_sparsity);

    // Output arguments
    obuf_.resize(QP_SOLVER_NUM_OUT);
    output(QP_SOLVER_X)             =  DMatrix::zeros(x_sparsity);
    output(QP_SOLVER_COST)          =  0.0;
    output(QP_SOLVER_LAM_X)         =  DMatrix::zeros(x_sparsity);
    output(QP_SOLVER_LAM_A)         =  DMatrix::zeros(a_sparsity);

    // IO scheme
    ischeme_ = IOScheme(SCHEME_StabilizedQpSolverInput);
    oscheme_ = IOScheme(SCHEME_QpSolverOutput);
  }
  WorhpInternal::WorhpInternal(const Function& nlp) : NLPSolverInternal(nlp){

    // Monitors
    addOption("monitor",            OT_STRINGVECTOR,  GenericType(),  "Monitor functions", "eval_f|eval_g|eval_jac_g|eval_grad_f|eval_h", true);
    addOption("print_time",         OT_BOOLEAN,       true,           "Print information about execution time");
  
    int status;
    InitParams(&status, &worhp_p_);
  
    std::stringstream ss;
    ss << "Armijo recovery strategies. Vector of size " << NAres;
  
    std::vector<int> ares(NAres);
    std::copy(worhp_p_.Ares,worhp_p_.Ares+NAres,ares.begin());
    addOption("Ares",OT_INTEGERVECTOR,ares,ss.str());
    
    for (int i=0;i<WorhpGetParamCount();++i) {
      WorhpType type = WorhpGetParamType(i+1);
      const char* name = WorhpGetParamName(i+1);
      if (strcmp(name,"Ares")==0) continue;
      switch(type) {
        case WORHP_BOOL_T:
          bool default_bool;
          WorhpGetBoolParam(&worhp_p_, name, &default_bool);
          addOption(WorhpGetParamName(i+1),OT_BOOLEAN,default_bool,WorhpGetParamDescription(i+1));
          break;
        case WORHP_DOUBLE_T:
          double default_double;
          WorhpGetDoubleParam(&worhp_p_, name, &default_double);
          addOption(WorhpGetParamName(i+1),OT_REAL,default_double,WorhpGetParamDescription(i+1));
          break;
        case WORHP_INT_T:
          int default_int;
          WorhpGetIntParam(&worhp_p_, name, &default_int);
          addOption(WorhpGetParamName(i+1),OT_INTEGER,default_int,WorhpGetParamDescription(i+1));
          break;
        default:
          break;// do nothing
      }
    } 
    
    addOption("qp_ipBarrier",OT_REAL,worhp_p_.qp.ipBarrier,"IP barrier parameter.");
    addOption("qp_ipComTol",OT_REAL,worhp_p_.qp.ipComTol,"IP complementarity tolerance.");
    addOption("qp_ipFracBound",OT_REAL,worhp_p_.qp.ipFracBound,"IP fraction-to-the-boundary parameter.");
    addOption("qp_ipLsMethod",OT_STRING,GenericType(),"Select the direct linear solver used by the IP method.","LAPACK::0|MA57: only available if provided by the user:1|SuperLU::2|PARDISO: only available if provided by the user, subject to license availability:3|MUMPS: currently Linux platforms only:5|WSMP: subject to license availability:6|MA86: experimental, only available if provided by the user:7|MA97:experimental, only available if provided by the user:8");
    setOptionByEnumValue("qp_ipLsMethod",worhp_p_.qp.ipLsMethod);
    addOption("qp_ipMinAlpha",OT_REAL,worhp_p_.qp.ipMinAlpha,"IP line search minimum step size.");
    addOption("qp_ipTryRelax",OT_BOOLEAN,worhp_p_.qp.ipTryRelax,"Enable relaxation strategy when encountering an error.");
    addOption("qp_ipRelaxDiv",OT_REAL,worhp_p_.qp.ipRelaxDiv,"The relaxation term is divided by this value if successful.");
    addOption("qp_ipRelaxMult",OT_REAL,worhp_p_.qp.ipRelaxMult,"The relaxation term is multiplied by this value if unsuccessful.");
    addOption("qp_ipRelaxMax",OT_REAL,worhp_p_.qp.ipRelaxMax,"Maximum relaxation value.");
    addOption("qp_ipRelaxMin",OT_REAL,worhp_p_.qp.ipRelaxMin,"Mimimum relaxation value.");
    addOption("qp_ipResTol",OT_REAL,worhp_p_.qp.ipResTol,"IP residuals tolerance.");
    addOption("qp_lsItMaxIter",OT_INTEGER,worhp_p_.qp.lsItMaxIter,"Maximum number of iterations of the iterative linear solvers.");
    addOption("qp_lsItMethod",OT_STRING,GenericType(),"Select the iterative linear solver.","none:Deactivate; use a direct linear solver.:0|CGNR::1|CGNE::2|CGS::3|BiCGSTAB::4");
    setOptionByEnumValue("qp_lsItMethod",worhp_p_.qp.lsItMethod);
    addOption("qp_lsItPrecondMethod",OT_STRING,GenericType(),"Select preconditioner for the iterative linear solver.","none:No preconditioner.:0|static:Static preconditioner (KKT-matrix with constant lower-right block).:1|full:Full KKT-matrix.:2");
    setOptionByEnumValue("qp_lsItPrecondMethod",worhp_p_.qp.lsItPrecondMethod);
    addOption("qp_lsRefineMaxIter",OT_INTEGER,worhp_p_.qp.lsRefineMaxIter,"Maximum number of iterative refinement steps of the direct linear solvers.");
    addOption("qp_lsScale",OT_BOOLEAN,worhp_p_.qp.lsScale,"Enables scaling on linear solver level.");
    addOption("qp_lsTrySimple",OT_BOOLEAN,worhp_p_.qp.lsTrySimple,"Some matrices can be solved without calling a linear equation solver.Currently only diagonal matrices are supported. Non-diagonal matrices will besolved with the chosen linear equation solver.");
    addOption("qp_lsTol",OT_REAL,worhp_p_.qp.lsTol,"Tolerance for the linear solver.");
    addOption("qp_maxIter",OT_INTEGER,worhp_p_.qp.maxIter,"Imposes an upper limit on the number of minor solver iterations, i.e. for thequadratic subproblem solver. If the limit is reached before convergence,WORHP will activate QP recovery strategies to prevent a solver breakdown.");
    addOption("qp_method",OT_STRING,GenericType(),"Select the solution method used by the QP solver.","ip:Interior-Point method.:1|nsn:Nonsmooth-Newton method.:2|automatic: Prefer IP and fall back to NSN on error.:12");
    setOptionByEnumValue("qp_method",worhp_p_.qp.method);
    addOption("qp_nsnBeta",OT_REAL,worhp_p_.qp.nsnBeta,"NSN stepsize decrease factor.");
    addOption("qp_nsnGradStep",OT_BOOLEAN,worhp_p_.qp.nsnGradStep,"Enable gradient steps in the NSN method.");
    addOption("qp_nsnKKT",OT_REAL,worhp_p_.qp.nsnKKT,"NSN KKT tolerance.");
    addOption("qp_nsnLsMethod",OT_STRING,GenericType(),"Select the direct linear solver used by the NSN method.","SuperLU::2|MA48: only available if provided by the user:4");
    setOptionByEnumValue("qp_nsnLsMethod",worhp_p_.qp.nsnLsMethod);
    addOption("qp_nsnMinAlpha",OT_REAL,worhp_p_.qp.nsnMinAlpha,"NSN line search minimum step size.");
    addOption("qp_nsnSigma",OT_REAL,worhp_p_.qp.nsnSigma,"NSN line search slope parameter.");
    addOption("qp_printLevel",OT_STRING,GenericType(),"Controls the amount of QP solver output.","none:No output.:0|warn:Print warnings and errors.:1|iterations:Print iterations.:2");
    setOptionByEnumValue("qp_printLevel",worhp_p_.qp.printLevel);
    addOption("qp_scaleIntern",OT_BOOLEAN,worhp_p_.qp.scaleIntern,"Enable scaling on QP level.");
    addOption("qp_strict",OT_BOOLEAN,worhp_p_.qp.strict,"Use strict termination criteria in IP method.");
  
    worhp_o_.initialised = false;
    worhp_w_.initialised = false;
    worhp_p_.initialised = false;
    worhp_c_.initialised = false;
  
    // WORKAROUND: Bug in scaling, set to false by default // FIXME
    setOption("ScaledObj",false);

    // WORKAROUND: Why is this needed? // FIXME
    setOption("ScaleConIter",true);
  }
Exemple #27
0
GslInternal::GslInternal(const Function& f, const Function& q) : IntegratorInternal(f,q){
  is_init = false;
  addOption("monitor",      OT_STRINGVECTOR, GenericType(),  "", "reset", true);
  std::cout << "Warning: GslIntegrator is highly experimental" << std::endl;
}
  QpoasesInterface::QpoasesInterface(const std::vector<Sparsity>& st) : QpSolverInternal(st) {
    addOption("nWSR",                   OT_INTEGER,     GenericType(),
              "The maximum number of working set recalculations to be performed during "
              "the initial homotopy. Default is 5(nx + nc)");
    addOption("CPUtime",                OT_REAL,        GenericType(),
              "The maximum allowed CPU time in seconds for the whole initialisation"
              " (and the actually required one on output). Disabled if unset.");

    // Temporary object
    qpOASES::Options ops;
    ops.setToDefault();

    addOption("printLevel",             OT_STRING,  PrintLevel_to_string(ops.printLevel),
              "Defines the amount of text output during QP solution, "
              "see Section 5.7", "none|low|medium|high");
    addOption("enableRamping",          OT_BOOLEAN, BooleanType_to_bool(ops.enableRamping),
              "Enables ramping.");
    addOption("enableFarBounds",        OT_BOOLEAN, BooleanType_to_bool(ops.enableFarBounds),
              "Enables the use of  far bounds.");
    addOption("enableFlippingBounds",   OT_BOOLEAN, BooleanType_to_bool(ops.enableFlippingBounds),
              "Enables the use of  flipping bounds.");
    addOption("enableRegularisation",   OT_BOOLEAN, BooleanType_to_bool(ops.enableRegularisation),
              "Enables automatic  Hessian regularisation.");
    addOption("enableFullLITests",      OT_BOOLEAN, BooleanType_to_bool(ops.enableFullLITests),
              "Enables condition-hardened  (but more expensive) LI test.");
    addOption("enableNZCTests",         OT_BOOLEAN, BooleanType_to_bool(ops.enableNZCTests),
              "Enables nonzero curvature  tests.");
    addOption("enableDriftCorrection",  OT_INTEGER, static_cast<int>(ops.enableDriftCorrection),
              "Specifies the frequency of drift corrections: 0: turns them off.");
    addOption("enableCholeskyRefactorisation", OT_INTEGER,
              static_cast<int>(ops.enableCholeskyRefactorisation),
              "Specifies the frequency of a full re-factorisation of projected "
              "Hessian matrix: 0: turns them off,  1: uses them at each iteration etc.");
    addOption("enableEqualities",       OT_BOOLEAN, BooleanType_to_bool(ops.enableEqualities),
              "Specifies whether equalities should be treated  as always active "
              "(True) or not (False)");
    addOption("terminationTolerance",   OT_REAL, static_cast<double>(ops.terminationTolerance),
              "Relative termination tolerance to stop homotopy.");
    addOption("boundTolerance",         OT_REAL, static_cast<double>(ops.boundTolerance),
              "If upper and lower bounds differ less than this tolerance, they are regarded "
              "equal, i.e. as  equality constraint.");
    addOption("boundRelaxation",        OT_REAL, static_cast<double>(ops.boundRelaxation),
              "Initial relaxation of bounds to start homotopy  and initial value for far bounds.");
    addOption("epsNum",                 OT_REAL, static_cast<double>(ops.epsNum),
              "Numerator tolerance for ratio tests.");
    addOption("epsDen",                 OT_REAL, static_cast<double>(ops.epsDen),
              "Denominator tolerance for ratio tests.");
    addOption("maxPrimalJump",          OT_REAL, static_cast<double>(ops.maxPrimalJump),
              "Maximum allowed jump in primal variables in  nonzero curvature tests.");
    addOption("maxDualJump",            OT_REAL, static_cast<double>(ops.maxDualJump),
              "Maximum allowed jump in dual variables in  linear independence tests.");
    addOption("initialRamping",         OT_REAL, static_cast<double>(ops.initialRamping),
              "Start value for ramping strategy.");
    addOption("finalRamping",           OT_REAL, static_cast<double>(ops.finalRamping),
              "Final value for ramping strategy.");
    addOption("initialFarBounds",       OT_REAL, static_cast<double>(ops.initialFarBounds),
              "Initial size for far bounds.");
    addOption("growFarBounds",          OT_REAL, static_cast<double>(ops.growFarBounds),
              "Factor to grow far bounds.");
    addOption("initialStatusBounds", OT_STRING, SubjectToStatus_to_string(ops.initialStatusBounds),
              "Initial status of bounds at first iteration.",
              "inactive::all bounds inactive|lower::all bounds active at their "
              "lower bound|upper::all bounds active at their upper bound");
    addOption("epsFlipping",            OT_REAL, static_cast<double>(ops.epsFlipping),
              "Tolerance of squared Cholesky diagonal factor  which triggers flipping bound.");
    addOption("numRegularisationSteps", OT_INTEGER, static_cast<int>(ops.numRegularisationSteps),
              "Maximum number of successive regularisation steps.");
    addOption("epsRegularisation",      OT_REAL, static_cast<double>(ops.epsRegularisation),
              "Scaling factor of identity matrix used for  Hessian regularisation.");
    addOption("numRefinementSteps",     OT_INTEGER, static_cast<int>(ops.numRefinementSteps),
              "Maximum number of iterative refinement steps.");
    addOption("epsIterRef",             OT_REAL, static_cast<double>(ops.epsIterRef),
              "Early termination tolerance for iterative  refinement.");
    addOption("epsLITests",             OT_REAL, static_cast<double>(ops.epsLITests),
              "Tolerance for linear independence tests.");
    addOption("epsNZCTests",            OT_REAL, static_cast<double>(ops.epsNZCTests),
              "Tolerance for nonzero curvature tests.");

    called_once_ = false;
    qp_ = 0;
  }
  IpoptInternal::IpoptInternal(const Function& nlp) : NLPSolverInternal(nlp){
    addOption("pass_nonlinear_variables", OT_BOOLEAN, false);
    addOption("print_time",               OT_BOOLEAN, true, "print information about execution time");
  
    // Monitors
    addOption("monitor",                  OT_STRINGVECTOR, GenericType(),  "", "eval_f|eval_g|eval_jac_g|eval_grad_f|eval_h", true);

    // For passing metadata to IPOPT
    addOption("var_string_md",            OT_DICTIONARY, GenericType(), "String metadata (a dictionary with lists of strings) about variables to be passed to IPOPT");
    addOption("var_integer_md",           OT_DICTIONARY, GenericType(), "Integer metadata (a dictionary with lists of integers) about variables to be passed to IPOPT");
    addOption("var_numeric_md",           OT_DICTIONARY, GenericType(), "Numeric metadata (a dictionary with lists of reals) about variables to be passed to IPOPT");
    addOption("con_string_md",            OT_DICTIONARY, GenericType(), "String metadata (a dictionary with lists of strings) about constraints to be passed to IPOPT");
    addOption("con_integer_md",           OT_DICTIONARY, GenericType(), "Integer metadata (a dictionary with lists of integers) about constraints to be passed to IPOPT");
    addOption("con_numeric_md",           OT_DICTIONARY, GenericType(), "Numeric metadata (a dictionary with lists of reals) about constraints to be passed to IPOPT");
  
    // Set pointers to zero
    app_ = 0;
    userclass_ = 0;
#ifdef WITH_SIPOPT
    app_sens_ = 0;
#endif // WITH_SIPOPT

    // Start an application (temporarily)
    Ipopt::IpoptApplication temp_app;

    // Start a sensitivity application (temporarily)
#ifdef WITH_SIPOPT
    Ipopt::SensApplication temp_sens_app(temp_app.Jnlst(),temp_app.Options(),temp_app.RegOptions());
  
    // Register sIPOPT options
    Ipopt::RegisterOptions_sIPOPT(temp_app.RegOptions());
    temp_app.Options()->SetRegisteredOptions(temp_app.RegOptions());
#endif // WITH_SIPOPT
  
    // Get all options available in (s)IPOPT
    map<string, Ipopt::SmartPtr<Ipopt::RegisteredOption> > regops = temp_app.RegOptions()->RegisteredOptionsList();
    for(map<string, Ipopt::SmartPtr<Ipopt::RegisteredOption> >::const_iterator it=regops.begin(); it!=regops.end(); ++it){
      // Option identifier
      string opt_name = it->first;
    
      // Short description goes here, even though we do have a longer description
      string opt_desc = it->second->ShortDescription() + " (see IPOPT documentation)";
    
      // Get the type
      Ipopt::RegisteredOptionType ipopt_type = it->second->Type();
      opt_type casadi_type;
    
      // Map Ipopt option category to a CasADi options type
      switch(ipopt_type){
      case Ipopt::OT_Number:    casadi_type = OT_REAL;          break;
      case Ipopt::OT_Integer:   casadi_type = OT_INTEGER;       break;
      case Ipopt::OT_String:    casadi_type = OT_STRING;        break;
      case Ipopt::OT_Unknown:   continue; // NOTE: No mechanism to handle OT_Unknown options
      default:                  continue; // NOTE: Unknown Ipopt options category
      }
    
      addOption(opt_name, casadi_type, GenericType(), opt_desc);
    
      // Set default values of IPOPT options 
      if (casadi_type == OT_REAL) {
        setDefault(opt_name,it->second->DefaultNumber());
      } else if (casadi_type == OT_INTEGER) {
        setDefault(opt_name,it->second->DefaultInteger());
      } else if (casadi_type == OT_STRING) {
        setDefault(opt_name,it->second->DefaultString());
      };
    
      // Save to map containing IPOPT specific options
      ops_[opt_name] = casadi_type;
    }
  }