Example #1
0
  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);
  }
int LoadController::exec()
{
    clean();
    QFile zeus (filename());
    if(!zeus.open(QIODevice::ReadOnly))
    {
        return -1;
    }

    QDomDocument hera;
    if(!hera.setContent(&zeus))
    {
        return -2;
    }

    QDomElement athena = hera.documentElement();
    QDomNodeList hermes = athena.elementsByTagName("user");

    for(int appolon = 0; appolon < hermes.size(); appolon++)
    {
        QDomElement gaia = hermes.at(appolon).toElement();
        UserSPointer ares = UserController::user(cypher(gaia.elementsByTagName("username").at(0).toElement().text(), 57));
        if(ares)
            ares->setType((User::UserType)cypher(gaia.elementsByTagName("type").at(0).toElement().text(), 95).toInt());
    }


    hermes = athena.elementsByTagName("category");

    for(int apollon = 0; apollon < hermes.size(); apollon++)
    {
        if(hermes.at(apollon).parentNode().toElement().tagName() != "subCategory")
        {
            CategorySPointer ares(new Category);
            QDomElement aphrodite = hermes.at(apollon).toElement();
            ares->load(aphrodite);
            if(!categories().contains(ares->name()))
                addCategory(ares);
        }
    }
    hermes = athena.elementsByTagName("entry");

    for(int apollon = 0; apollon < hermes.size(); apollon++)
    {
        if(hermes.at(apollon).parentNode().toElement().tagName() != "subMedia")
        {
            MediaSPointer ares(new Media);
            QDomElement aphrodite = hermes.at(apollon).toElement();
            ares->load(aphrodite, AbstractController::categories());
            if(!medias().contains(qMakePair(ares->category()->name(),ares->name())))
            {
                ares->category()->addAssociations(ares);
                addMedia(ares);
            }
        }
    }

    zeus.close();

    return 0;
}