Dear NLopt developers/user community,
Thank you for this excellent library, I enjoyed a lot using it. However, I
have a question - some of the global optimization method do not work in my
case. In fact, I have no problems with NLOPT_AUGLAG_EQ, NLOPT_AUGLAG,
NLOPT_GN_ISRES, NLOPT_GN_CRS2_LM. Other methods like DIRECT, ESCH, MLSL do
not work in my case - the energy function is calculated, but the algorithm
somehow is not converged. Below is the example of my code:

void OPTIMIZESTRUCTURENLOPT (Conformer **conformer,
    long int NBONDS, Fragment *fragments,
    long int NATOMS, long int ITER, double TESTSIZE) {

    //  printf("Start of opt\n");
    long int i1, j, ii;
    nlopt_opt opt;
    opt = nlopt_create(NLOPT_GN_ESCH, NBONDS);
    nlopt_set_min_objective(opt, ENERGYNLOPT, (void *) (*conformer));
    nlopt_set_xtol_rel(opt, 1e-3);

    // the initial guess
    (**conformer).IT=0;
    double *x = malloc(NBONDS*sizeof(double)); //   [NBONDS];
    double *dx = malloc(NBONDS*sizeof(double)); //[NBONDS];
    double *lb = malloc(NBONDS*sizeof(double));
    double *ub = malloc(NBONDS*sizeof(double));
    for (i1=0;i1<NBONDS;i1++) {
        x[i1] = (**conformer).angles[i1];
        dx[i1] = 0.1;
        lb[i1] = -360;
        ub[i1] = 360;
    }
    nlopt_set_initial_step(opt, dx);
    nlopt_set_lower_bounds(opt, lb);
    nlopt_set_upper_bounds(opt, ub);
   //   printf ("Start: ");
    for (i1=0;i1<NBONDS;i1++) {
    //      printf ("%f ", x[i1]);
    }
    //  printf ("\n");

    //////////////////////////////////////////////

    nlopt_opt opt_loc;
    opt_loc = nlopt_create(NLOPT_LN_PRAXIS, NBONDS);
    nlopt_set_local_optimizer(opt, opt_loc);
    nlopt_set_xtol_rel(opt_loc, 1e-5);
    nlopt_set_ftol_rel(opt_loc, 1e-5);

    double minf; // the energy function value
    if (nlopt_optimize(opt, x, &minf) < 0) {
        printf ("nlopt failed!\n");
     }
    else {
        printf ("found minimum after (%li) iterations = %0.010g\n",
     (**conformer).IT, minf);
        for (i1=0;i1<NBONDS;i1++) {
    //          printf ("%f ", x[i1]);
        }
    //      printf ("\n");
     }

And this is the energy function calls:
Iter: 10047 E = -1629.325853 Iter: 10048 E = -1629.325853 Iter: 10049 E =
-1629.325853 Iter: 10050 E = -1629.325853 Iter: 10051 E = -1628.944283
Iter: 10052 E = -1629.325853 Iter: 10053 E = -1629.325853 Iter: 10054 E =
-1628.997908 Iter: 10055 E = -1629.325853 Iter: 10056 E = -1629.325853
Iter: 10057 E = -1629.325853 Iter: 10058 E = -1629.325853 Iter: 10059 E =
-1629.325853 Iter: 10060 E = -1629.325853 Iter: 10061 E = -1629.325853
Iter: 10062 E = -1629.325853 Iter: 10063 E = -1629.325853 Iter: 10064 E =
-1629.325853 Iter: 10065 E = -1629.325853 Iter: 10066 E = -1629.325853
Iter: 10067 E = -1629.325853 Iter: 10068 E = -1629.325853 Iter: 10069 E =
-1629.325853 Iter: 10070 E = -1628.745543 Iter: 10071 E = -1629.325853
Iter: 10072 E = -1629.325853 Iter: 10073 E = -1629.325853 Iter: 10074 E =
-1629.325853 Iter: 10075 E = -1629.325853 Iter: 10076 E = -1629.325853
Iter: 10077 E = -1628.540874 Iter: 10078 E = -1629.325853 Iter: 10079 E =
-1629.325853 Iter: 10080 E = -1629.325853

Also, I observe the memory leak when trying to run direct - the memory just
growing up when the calculation is done.

May be I have forgotten to specify something? Sorry if the question is too
primitive, I am mainly a chemist by my background.

With kind regards,
Yury

PS - I also posted this question on stack overflow -
http://stackoverflow.com/questions/37645139/global-optimization-algorithms-in-nlopt
_______________________________________________
NLopt-discuss mailing list
NLopt-discuss@ab-initio.mit.edu
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss

Reply via email to