NLOPT中的全局优化算法

时间:2016-06-05 18:06:03

标签: optimization global nlopt

我遇到了在NLopt软件中实现的全局优化算法很少的问题。特别是,ESCH(进化算法)在我的情况下不能正常工作,能量函数被称为大量迭代,能量不会改变。这就是我的代码调用函数的方式

    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");
     }

这是能量函数调用:

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 

其他算法效果更好 - 如ISRES(改进随机排序演化策略)和带局部变异的受控随机搜索(CRS)。

任何提示/想法?

0 个答案:

没有答案