Hi Yvus,

On 07/16/2013 02:39 PM, Yvus wrote:
Dear mates,

Brief description of the problem I solve:
The goal is to find a feasible point for an optimization problem I want to
solve using the LD_SLSQP algorithm. In order to feed the optimization
problem I look for a feasible point using the LN_NELDERMEAD algorithm
(algorithm A). The idea is to set the optimization (minimization) function
to be the norm of the equality constraints (or the sum of the absolute
values) of the initial optimization problem. Then, use those values as
starting point for the optimization problem (algorithm B). This ensures that
the starting point is a feasible point!

The difficulty is that the feasible region seems very small and only very
rarely, with luck, I find a feasible point. Thus I thought I could loop
through the acceptable values defined by the lower and upper bounds to find
a feasible point.

The Problem: inside the loop, I often get a generic failure after a while as
result of the A algorithm. And once the algorithm gives a generic failure it
keeps giving generic failure for the rest of the loop. See below for the
code of the loop.

The questions: is it a memory problem? should I destroy some stuff before
continuing in the loop? is there a possibility to use a global optimization
problem which is not using differentiation?

The Code:
x[5]=(ub[5]-lb[5])/2+lb[5];
x[6]=(ub[6]-lb[6])/2+lb[6];
int nit=5;
for (int i=0; i<nit; ++i) {
     for (int j=0; j<nit; ++j) {
         for (int k=0; k<nit; ++k) {
             for (int l=0; l<nit; ++l) {
                 for (int ll=0; ll<nit; ++ll) {

             x[0]=(ub[0]-lb[0])*i/nit+lb[0]+1;
             x[1]=(ub[1]-lb[1])*j/nit+lb[1];
             x[2]=(ub[2]-lb[2])*k/nit+lb[2];
             x[3]=(ub[3]-lb[3])*l/nit+lb[3];
             x[4]=(ub[4]-lb[4])*ll/nit+lb[4];

         logDebug << "------------------- initial guess -------------------"
<< std::endl;

         nlopt::opt optInit(nlopt::LN_NELDERMEAD, 7);

         my_constraint_data dataInit[1]={-1,tws,twa,NULL};
         optInit.set_lower_bounds(lb);
         optInit.set_upper_bounds(ub);
         optInit.set_min_objective(constraintE, dataInit);
         optInit.set_xtol_rel(1e-4);
         optInit.set_stopval(1e0);

         try {
             nlopt::result resultInit = optInit.optimize(x, minf);

             logDebug << "initial guess exit flag = " << resultInit << 
std::endl;
             my_constraint_data dataInit_bis[1] = {-1,tws,twa,NULL};
             logDebug << "equality constraints (should be zero) = " <<
constraintE(x,grad,dataInit_bis) << std::endl;

         } catch (std::runtime_error) {

Could you output the what() member of this exception? It would give a hint at where this error is coming from.

Like this:

[...]
} catch (std::runtime_error e) {
  logDebug << "Generic failure: " << e.what() << std::endl;
}

Best,
Julius

             err = -1;
             logDebug << "Generic failure." << std::endl;
         } catch (std::invalid_argument) {
             err = -1;
             logDebug << "Invalid arguments (e.g. lower bounds are bigger
than upper bounds, an unknown algorithm was specified, etcetera)." << std::endl;
         } catch (std::bad_alloc) {
             err = -1;
             logDebug << "Ran out of memory (a memory allocation failed)." <<
std::endl;
         } catch (...) {
             err = -1;
             logDebug << "catched undefined exceptions!" << std::endl;
         }

                 }
             }
         }
     }
}


Thanks for your time,
Yvus


_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss



--
Dipl.-Inform. Julius Ziegler <[email protected]>

Institut für Mess- und Regelungstechnik
Karlsruher Institut für Technologie

Department of Measurement and Control
Karlsruhe Institute of Technology

Engler-Bunte-Ring 21
76131 Karlsruhe

Tel. +49 721 608 47146


_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss

Reply via email to