Exemplo n.º 1
0
  void WorhpInternal::passOptions() {
     
     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:
          if (hasSetOption(name)) WorhpSetBoolParam(&worhp_p_, name, getOption(name));
          break;
        case WORHP_DOUBLE_T:
          if (hasSetOption(name)) WorhpSetDoubleParam(&worhp_p_, name, getOption(name));
          break;
        case WORHP_INT_T:
          if (hasSetOption(name)) WorhpSetIntParam(&worhp_p_, name, getOption(name));
          break;
        default:
          break;// do nothing
      }
    } 
  
    if (hasSetOption("qp_ipBarrier")) worhp_p_.qp.ipBarrier = getOption("qp_ipBarrier");
    if (hasSetOption("qp_ipComTol")) worhp_p_.qp.ipComTol = getOption("qp_ipComTol");
    if (hasSetOption("qp_ipFracBound")) worhp_p_.qp.ipFracBound = getOption("qp_ipFracBound");
    if (hasSetOption("qp_ipLsMethod")) worhp_p_.qp.ipLsMethod = getOptionEnumValue("qp_ipLsMethod");
    if (hasSetOption("qp_ipMinAlpha")) worhp_p_.qp.ipMinAlpha = getOption("qp_ipMinAlpha");
    if (hasSetOption("qp_ipTryRelax")) worhp_p_.qp.ipTryRelax = getOption("qp_ipTryRelax");
    if (hasSetOption("qp_ipRelaxDiv")) worhp_p_.qp.ipRelaxDiv = getOption("qp_ipRelaxDiv");
    if (hasSetOption("qp_ipRelaxMult")) worhp_p_.qp.ipRelaxMult = getOption("qp_ipRelaxMult");
    if (hasSetOption("qp_ipRelaxMax")) worhp_p_.qp.ipRelaxMax = getOption("qp_ipRelaxMax");
    if (hasSetOption("qp_ipRelaxMin")) worhp_p_.qp.ipRelaxMin = getOption("qp_ipRelaxMin");
    if (hasSetOption("qp_ipResTol")) worhp_p_.qp.ipResTol = getOption("qp_ipResTol");
    if (hasSetOption("qp_lsItMaxIter")) worhp_p_.qp.lsItMaxIter = getOption("qp_lsItMaxIter");
    if (hasSetOption("qp_lsItMethod")) worhp_p_.qp.lsItMethod = getOptionEnumValue("qp_lsItMethod");
    if (hasSetOption("qp_lsItPrecondMethod")) worhp_p_.qp.lsItPrecondMethod = getOptionEnumValue("qp_lsItPrecondMethod");
    if (hasSetOption("qp_lsRefineMaxIter")) worhp_p_.qp.lsRefineMaxIter = getOption("qp_lsRefineMaxIter");
    if (hasSetOption("qp_lsScale")) worhp_p_.qp.lsScale = getOption("qp_lsScale");
    if (hasSetOption("qp_lsTrySimple")) worhp_p_.qp.lsTrySimple = getOption("qp_lsTrySimple");
    if (hasSetOption("qp_lsTol")) worhp_p_.qp.lsTol = getOption("qp_lsTol");
    if (hasSetOption("qp_maxIter")) worhp_p_.qp.maxIter = getOption("qp_maxIter");
    if (hasSetOption("qp_method")) worhp_p_.qp.method = getOptionEnumValue("qp_method");
    if (hasSetOption("qp_nsnBeta")) worhp_p_.qp.nsnBeta = getOption("qp_nsnBeta");
    if (hasSetOption("qp_nsnGradStep")) worhp_p_.qp.nsnGradStep = getOption("qp_nsnGradStep");
    if (hasSetOption("qp_nsnKKT")) worhp_p_.qp.nsnKKT = getOption("qp_nsnKKT");
    if (hasSetOption("qp_nsnLsMethod")) worhp_p_.qp.nsnLsMethod = getOptionEnumValue("qp_nsnLsMethod");
    if (hasSetOption("qp_nsnMinAlpha")) worhp_p_.qp.nsnMinAlpha = getOption("qp_nsnMinAlpha");
    if (hasSetOption("qp_nsnSigma")) worhp_p_.qp.nsnSigma = getOption("qp_nsnSigma");
    if (hasSetOption("qp_printLevel")) worhp_p_.qp.printLevel = getOptionEnumValue("qp_printLevel");
    if (hasSetOption("qp_scaleIntern")) worhp_p_.qp.scaleIntern = getOption("qp_scaleIntern");
    if (hasSetOption("qp_strict")) worhp_p_.qp.strict = getOption("qp_strict");  

    // Mark the parameters as set
    worhp_p_.initialised = true;
  }
Exemplo n.º 2
0
  int WorhpInterface::init_mem(void* mem) const {
    if (Nlpsol::init_mem(mem)) return 1;
    auto m = static_cast<WorhpMemory*>(mem);

    SetWorhpPrint(&worhp_disp);

    WorhpPreInit(&m->worhp_o, &m->worhp_w, &m->worhp_p, &m->worhp_c);
    m->worhp_o.initialised = false;
    m->worhp_w.initialised = false;
    m->worhp_p.initialised = false;
    m->worhp_c.initialised = false;

    // Initialize parameters to default values
    int status;
    InitParams(&status, &m->worhp_p);
    casadi_assert(status==0, "Problem in Worhp InitParams. Status: " + str(status));


    // Pass boolean parameters
    for (auto&& op : bool_opts_) {
      casadi_assert(
        WorhpSetBoolParam(&m->worhp_p, op.first.c_str(), op.second),
        "Problem setting boolean Worhp parameter " + op.first);
    }

    // Pass double parameters
    for (auto&& op : double_opts_) {
      casadi_assert(
        WorhpSetDoubleParam(&m->worhp_p, op.first.c_str(), op.second),
        "Problem setting double Worhp parameter " + op.first);
    }

    // Pass integer parameters
    for (auto&& op : int_opts_) {
      casadi_assert(
        WorhpSetIntParam(&m->worhp_p, op.first.c_str(), op.second),
        "Problem setting integer Worhp parameter " + op.first);
    }

    // Pass qp parameters
    for (auto&& op : qp_opts_) {
      if (op.first=="ipBarrier") {
        m->worhp_p.qp.ipBarrier = op.second;
      } else if (op.first=="ipComTol") {
        m->worhp_p.qp.ipComTol = op.second;
      } else if (op.first=="ipFracBound") {
        m->worhp_p.qp.ipFracBound = op.second;
      } else if (op.first=="ipMinAlpha") {
        m->worhp_p.qp.ipMinAlpha = op.second;
      } else if (op.first=="ipRelaxDiv") {
        m->worhp_p.qp.ipRelaxDiv = op.second;
      } else if (op.first=="ipRelaxMax") {
        m->worhp_p.qp.ipRelaxMax = op.second;
      } else if (op.first=="ipRelaxMin") {
        m->worhp_p.qp.ipRelaxMin = op.second;
      } else if (op.first=="ipRelaxMult") {
        m->worhp_p.qp.ipRelaxMult = op.second;
      } else if (op.first=="ipResTol") {
        m->worhp_p.qp.ipResTol = op.second;
      } else if (op.first=="lsTol") {
        m->worhp_p.qp.lsTol = op.second;
      } else if (op.first=="nsnBeta") {
        m->worhp_p.qp.nsnBeta = op.second;
      } else if (op.first=="nsnKKT") {
        m->worhp_p.qp.nsnKKT = op.second;
      } else if (op.first=="nsnMinAlpha") {
        m->worhp_p.qp.nsnMinAlpha = op.second;
      } else if (op.first=="nsnSigma") {
        m->worhp_p.qp.nsnSigma = op.second;
      } else if (op.first=="ipLsMethod") {
        m->worhp_p.qp.ipLsMethod = op.second;
      } else if (op.first=="lsItMaxIter") {
        m->worhp_p.qp.lsItMaxIter = op.second;
      } else if (op.first=="lsItMethod") {
        m->worhp_p.qp.lsItMethod = op.second;
      } else if (op.first=="lsItPrecondMethod") {
        m->worhp_p.qp.lsItPrecondMethod = op.second;
      } else if (op.first=="lsRefineMaxIter") {
        m->worhp_p.qp.lsRefineMaxIter = op.second;
      } else if (op.first=="maxIter") {
        m->worhp_p.qp.maxIter = op.second;
      } else if (op.first=="method") {
        m->worhp_p.qp.method = op.second;
      } else if (op.first=="nsnLsMethod") {
        m->worhp_p.qp.nsnLsMethod = op.second;
      } else if (op.first=="printLevel") {
        m->worhp_p.qp.printLevel = op.second;
      } else if (op.first=="ipTryRelax") {
        m->worhp_p.qp.ipTryRelax = op.second;
      } else if (op.first=="lsScale") {
        m->worhp_p.qp.lsScale = op.second;
      } else if (op.first=="lsTrySimple") {
        m->worhp_p.qp.lsTrySimple = op.second;
      } else if (op.first=="nsnGradStep") {
        m->worhp_p.qp.nsnGradStep = op.second;
      } else if (op.first=="scaleIntern") {
        m->worhp_p.qp.scaleIntern = op.second;
      } else if (op.first=="strict") {
        m->worhp_p.qp.strict = op.second;
      } else {
        casadi_error("No such Worhp option: qp." + op.first);
      }
    }

    // Mark the parameters as set
    m->worhp_p.initialised = true;
    m->init_ = false;

    return 0;
  }