Changeset 1271


Ignore:
Timestamp:
Feb 3, 2009 3:41:13 PM (15 years ago)
Author:
liveletlive
Message:

Changes made to API and pgapack for addition of new stoppage criteria. TIMEElapsed criteria is not yet added.

Location:
trunk/packages/optimizer/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/optimizer/src/pgapack/pgapack/source/create.c

    r816 r1271  
    233233     */
    234234    ctx->ga.PopSize            = PGA_UNINITIALIZED_INT;
     235    ctx->ga.TgtFitnessVal          = PGA_UNINITIALIZED_DOUBLE;
     236    ctx->ga.FitnessTol             = 0;
     237    ctx->ga.TgtFitnessVar          = PGA_UNINITIALIZED_DOUBLE;
     238    ctx->ga.VarTol                         = 0;
     239    ctx->ga.TgtElapsedTime         = PGA_UNINITIALIZED_DOUBLE;
    235240    ctx->ga.StoppingRule       = PGA_STOP_MAXITER;
    236241    ctx->ga.MaxIter            = PGA_UNINITIALIZED_INT;
  • trunk/packages/optimizer/src/pgapack/pgapack/source/cross.c

    r1202 r1271  
    267267        case PGA_CROSSOVER_UNIFORM:
    268268        case PGA_CROSSOVER_SBX:
     269        case PGA_CROSSOVER_TRIANGULAR:
    269270            ctx->ga.CrossoverType = crossover_type;
    270271            break;
  • trunk/packages/optimizer/src/pgapack/pgapack/source/debug.c

    r816 r1271  
    295295        { "PGASetMaxNoChangeValue",         395 },
    296296        { "PGASetMaxSimilarityValue",       396 },
     297        { "PGASetTgtFitnessVal",                        398 },
     298        { "PGASetFitnessTol",                           399 },
     299        { "PGASetTgtFitnessVariance",           400 },
     300        { "PGASetVarTol",                                       401 },
     301        { "PGASetTgtElapsedTime",                       402 },
    297302        { "PGADone",                        397 },
    298303
  • trunk/packages/optimizer/src/pgapack/pgapack/source/parallel.c

    r1202 r1271  
    7070#include "pgapack.h"
    7171#include <setjmp.h>
     72#include <time.h>
    7273
    7374extern jmp_buf pgapack_jmpbuf;
     
    125126
    126127    while (!PGADone(ctx, comm)) {
    127         if (rank == 0) {
    128             Restarted = PGA_FALSE;
    129             if (PGARestartCondition(ctx)) {
    130                         Restarted = PGA_TRUE;
    131                         PGARestart(ctx, PGA_OLDPOP, PGA_NEWPOP);
    132             } else {
    133                         PGASelect(ctx, PGA_OLDPOP);
    134                         CreateNewGeneration(ctx, PGA_OLDPOP, PGA_NEWPOP);
    135             }
    136         }
    137         MPI_Bcast(&Restarted, 1, MPI_INT, 0, comm);
    138 
    139         PGAEvaluate(ctx, PGA_NEWPOP, f, comm);
    140         if (rank == 0)
    141             PGAFitness(ctx, PGA_NEWPOP);
    142 
    143         /*  If the GA wasn't restarted, update the generation and print
    144          *  stuff.  We do this because a restart is NOT counted as a
    145          *  complete generation.
    146         */
    147         if (!Restarted) {
    148             PGAUpdateGeneration(ctx, comm);
    149             if (rank == 0)
    150                 PGAPrintReport(ctx, stdout, PGA_OLDPOP);
    151         }
     128                if (rank == 0) {
     129                    Restarted = PGA_FALSE;
     130                    if (PGARestartCondition(ctx)) {
     131                                Restarted = PGA_TRUE;
     132                                PGARestart(ctx, PGA_OLDPOP, PGA_NEWPOP);
     133                    } else {
     134                                PGASelect(ctx, PGA_OLDPOP);
     135                                CreateNewGeneration(ctx, PGA_OLDPOP, PGA_NEWPOP);
     136                    }
     137                }
     138                MPI_Bcast(&Restarted, 1, MPI_INT, 0, comm);
     139       
     140                PGAEvaluate(ctx, PGA_NEWPOP, f, comm);
     141                if (rank == 0)
     142                    PGAFitness(ctx, PGA_NEWPOP);
     143       
     144                /*  If the GA wasn't restarted, update the generation and print
     145                 *  stuff.  We do this because a restart is NOT counted as a
     146                 *  complete generation.
     147                */
     148                if (!Restarted) {
     149                    PGAUpdateGeneration(ctx, comm);
     150                    if (rank == 0)
     151                        PGAPrintReport(ctx, stdout, PGA_OLDPOP);
     152                }
    152153    }
    153154
  • trunk/packages/optimizer/src/pgapack/pgapack/source/report.c

    r816 r1271  
    561561     else
    562562         fprintf( fp,"Off\n");
    563 
     563         
     564     fprintf(fp, "        Stop: Average Fitness                  : ");
     565     if ((ctx->ga.StoppingRule & PGA_STOP_AV_FITNESS) == PGA_STOP_AV_FITNESS){
     566         fprintf(fp,"On\n");
     567         fprintf(fp,"The target average fitness is %lf and tolerance is %lf\n", ctx->ga.TgtFitnessVal, ctx->ga.FitnessTol);
     568     }else{
     569         fprintf(fp,"Off\n");
     570     }         
     571
     572         fprintf(fp, "    Stop: Best Fitness                     : ");
     573     if ((ctx->ga.StoppingRule & PGA_STOP_BEST_FITNESS) == PGA_STOP_BEST_FITNESS){
     574         fprintf(fp,"On\n");
     575         fprintf(fp,"The target best fitness is %lf and tolerance is %lf\n", ctx->ga.TgtFitnessVal, ctx->ga.FitnessTol);
     576     }else{
     577         fprintf(fp,"Off\n");
     578     }
     579     
     580     fprintf(fp, "        Stop: Fitness Variance                         : ");
     581     if ((ctx->ga.StoppingRule & PGA_STOP_VARIANCE) == PGA_STOP_VARIANCE){
     582         fprintf(fp,"On\n");
     583         fprintf(fp,"The target variance is %lf and tolerance is %lf\n", ctx->ga.TgtFitnessVar, ctx->ga.VarTol);
     584     }else{
     585         fprintf(fp,"Off\n");
     586     }
     587     
     588     fprintf(fp, "        Stop: Time Elapsed                     : ");
     589     if ((ctx->ga.StoppingRule & PGA_STOP_TIMEELAPSED) == PGA_STOP_TIMEELAPSED){
     590         fprintf(fp,"On\n");
     591         fprintf(fp,"The max time for execution is %lf minutes\n", ctx->ga.TgtElapsedTime);
     592     }else{
     593         fprintf(fp,"Off\n");
     594     }
    564595
    565596     fprintf(fp, "        Percent Similarity         : ");
  • trunk/packages/optimizer/src/pgapack/pgapack/source/stop.c

    r986 r1271  
    105105
    106106    if (rank == 0) {
    107         if (ctx->fops.StopCond)
    108             done = (*ctx->fops.StopCond)(&ctx);
    109         else if (ctx->cops.StopCond)
    110             done = (*ctx->cops.StopCond)(ctx);
    111         else
    112             done = PGACheckStoppingConditions(ctx);
     107                if (ctx->fops.StopCond)
     108                    done = (*ctx->fops.StopCond)(&ctx);
     109                else if (ctx->cops.StopCond)
     110                    done = (*ctx->cops.StopCond)(ctx);
     111                else
     112                    done = PGACheckStoppingConditions(ctx);
    113113    }
    114114
     
    144144{
    145145    int done = PGA_FALSE;
     146    double diff;
    146147
    147148    PGADebugEntered("PGACheckStoppingConditions");
     
    158159        (ctx->ga.PercentSame >= ctx->ga.MaxSimilarity))
    159160        done |= PGA_TRUE;
     161       
     162        if(((ctx->ga.StoppingRule & PGA_STOP_AV_FITNESS) == PGA_STOP_AV_FITNESS)){
     163                if(ctx->ga.TgtFitnessVal == PGA_UNINITIALIZED_DOUBLE){
     164                        fprintf(stderr,"Uninitialized Value 'Target Average'");
     165                        done |= PGA_TRUE;
     166                }else{
     167                        diff = ((ctx->ga.TgtFitnessVal - ctx->rep.Average)/(ctx->ga.TgtFitnessVal))*100;
     168                        if(fabs(diff) <= ctx->ga.FitnessTol){
     169                                done |= PGA_TRUE;
     170                        }
     171                }
     172        }
     173       
     174        if(((ctx->ga.StoppingRule & PGA_STOP_BEST_FITNESS) == PGA_STOP_BEST_FITNESS)){
     175                if(ctx->ga.TgtFitnessVal == PGA_UNINITIALIZED_DOUBLE){
     176                        fprintf(stderr,"Uninitialized Value 'Target Best Fitness'");
     177                        done |= PGA_TRUE;
     178                }else{
     179                        diff =(((double)ctx->ga.TgtFitnessVal -(double)ctx->rep.Best)/((double)ctx->ga.TgtFitnessVal))*100;
     180                        if(fabs(diff) <= ctx->ga.FitnessTol){
     181                                done |= PGA_TRUE;
     182                        }
     183                }
     184        }
     185       
     186        if(((ctx->ga.StoppingRule & PGA_STOP_VARIANCE) == PGA_STOP_VARIANCE)){
     187                if(ctx->ga.TgtFitnessVar == PGA_UNINITIALIZED_DOUBLE){
     188                        fprintf(stderr,"Uninitialized Value 'Target Fitness Variance'");
     189                        done |= PGA_TRUE;
     190                }else{
     191                        diff =(((double)ctx->ga.TgtFitnessVar -(double)ctx->rep.Variance)/((double)ctx->ga.TgtFitnessVar))*100;
     192                        if(fabs(diff) <= ctx->ga.VarTol){
     193                                done |= PGA_TRUE;
     194                        }
     195                }
     196        }
     197       
     198        if(((ctx->ga.StoppingRule & PGA_STOP_TIMEELAPSED) == PGA_STOP_TIMEELAPSED)){
     199                //TODO :GTG Add code for setting initial time and current time and comparing
     200                done |= PGA_TRUE;
     201        }
    160202
    161203    PGADebugExited("PGACheckStoppingConditions");
     
    195237    switch (stoprule) {
    196238        case PGA_STOP_MAXITER  :
    197         case PGA_STOP_NOCHANGE :
     239    case PGA_STOP_NOCHANGE :
    198240        case PGA_STOP_TOOSIMILAR :
     241        case PGA_STOP_AV_FITNESS :
     242        case PGA_STOP_BEST_FITNESS :
     243        case PGA_STOP_VARIANCE :
     244        case PGA_STOP_TIMEELAPSED :
    199245            ctx->ga.StoppingRule |= stoprule;
    200246            break;
     
    384430    pgapack_abortPtr = abortPtr;
    385431}
     432
     433
     434/*U****************************************************************************
     435   PGASetTgtFitnessVal
     436
     437   Category: Initialization
     438
     439   Inputs:
     440      ctx         - context variable
     441      tgt_fitness_val - tgt fitness required for stopping. either target average or best fitness depending
     442                                on stoppage criteria.
     443                                Requires setting fitness tolerance using PGASetFitnessTol in order to specify
     444                                what % difeerence between current and target fitness is acceptable.
     445
     446   Outputs:
     447      None
     448
     449   Example:
     450      PGAContext *ctx;
     451      :
     452      PGASetTgtFitnessVal(ctx,0);
     453
     454****************************************************************************U*/
     455void PGASetTgtFitnessVal(PGAContext *ctx, double tgt_fitness_val){
     456        PGADebugEntered("PGASetTgtFitnessVal");
     457    PGAFailIfSetUp("PGASetTgtFitnessVal");
     458        ctx->ga.TgtFitnessVal = tgt_fitness_val;
     459        PGADebugExited("PGASetTgtFitnessVal");
     460}
     461
     462/*U****************************************************************************
     463   PGASetFitnessTol
     464
     465   Category: Initialization
     466
     467   Inputs:
     468      ctx - context variable
     469      fitness_tol - tolerance between current pop fitness (avg or best, depending on stoppage criteria)
     470                target fitness set using PGASetTgtFitnessVal. once this tolerance is achieved, the GA can be stopped.
     471
     472   Outputs:
     473      None
     474
     475   Example:
     476      PGAContext *ctx;
     477      :
     478      PGASetFitnessTol(ctx,0);
     479
     480****************************************************************************U*/
     481void PGASetFitnessTol(PGAContext *ctx,double fitness_tol){
     482        PGADebugEntered("PGASetFitnessTol");
     483    PGAFailIfSetUp("PGASetFitnessTol");
     484        ctx->ga.FitnessTol = fitness_tol;
     485        PGADebugExited("PGASetFitnessTol");
     486}
     487
     488
     489/*U****************************************************************************
     490   PGASetTgtFitnessVariance
     491
     492   Category: Initialization
     493
     494   Inputs:
     495      ctx - context variable
     496      tgt_fitness_var - tgt fitness variance required for stopping.
     497                                Requires setting fitness variance tolerance using PGASetVarTol in order to specify
     498                                what % difeerence between current and target fitness variance is acceptable.
     499   Outputs:
     500      None
     501
     502   Example:
     503      PGAContext *ctx;
     504      :
     505      PGASetTgtFitnessVariance(ctx,0);
     506
     507****************************************************************************U*/
     508void PGASetTgtFitnessVariance(PGAContext *ctx,double tgt_fitness_var){
     509        PGADebugEntered("PGASetTgtFitnessVariance");
     510    PGAFailIfSetUp("PGASetTgtFitnessVariance");
     511        ctx->ga.TgtFitnessVar = tgt_fitness_var;
     512        PGADebugExited("PGASetTgtFitnessVariance");
     513}
     514
     515/*U****************************************************************************
     516   PGASetVarTol
     517
     518   Category: Initialization
     519
     520   Inputs:
     521      ctx - context variable
     522      var_tol - tolerance between current pop fitness variance and target fitness set using PGASetTgtFitnessVariance.
     523                        Once this tolerance is achieved, the GA can be stopped.
     524   Outputs:
     525      None
     526
     527   Example:
     528      PGAContext *ctx;
     529      :
     530      PGASetVarTol(ctx,0);
     531
     532****************************************************************************U*/
     533void PGASetVarTol(PGAContext *ctx,double var_tol){
     534        PGADebugEntered("PGASetVarTol");
     535    PGAFailIfSetUp("PGASetVarTol");
     536        ctx->ga.VarTol = var_tol;
     537        PGADebugExited("PGASetVarTol");
     538}
     539
     540/*U****************************************************************************
     541   PGASetTgtElapsedTime
     542
     543   Category: Initialization
     544
     545   Inputs:
     546      ctx - context variable
     547      tgt_elapsed_time - stop the GA if stoppage criteria is PGA_STOP_TIMEELAPSED
     548                                         and time between start of execution and end of current evaluation
     549                                         is equal to tgt_elapsed_time.
     550   Outputs:
     551      None
     552
     553   Example:
     554      PGAContext *ctx;
     555      :
     556      PGASetTgtElapsedTime(ctx,0);
     557
     558****************************************************************************U*/
     559void PGASetTgtElapsedTime(PGAContext *ctx,double tgt_elapsed_time){
     560        PGADebugEntered("PGASetTgtElapsedTime");
     561    PGAFailIfSetUp("PGASetTgtElapsedTime");
     562        ctx->ga.TgtElapsedTime = tgt_elapsed_time;
     563        PGADebugExited("PGASetTgtElapsedTime");
     564}
  • trunk/packages/optimizer/src/pgapack/pgapack/source/utility.c

    r816 r1271  
    477477
    478478/*I****************************************************************************
    479    PGAUpdateAverage - Updates the average fitness statistic for reporting.
     479   PGAUpdateAverage - Updates the average and variance fitness statistic for reporting.
    480480
    481481   Inputs:
     
    491491{
    492492    double ThisGensTotal = 0;
     493    double ThisGensIndivSquareTotal = 0;
     494    double fitness, average, variance;
    493495    int p;
    494496
     
    500502                     "date:", PGA_FATAL, PGA_INT, (void *) &p);
    501503
    502     for (p = 0; p < ctx->ga.PopSize; p++)
    503         ThisGensTotal += PGAGetEvaluation(ctx, p, pop);
    504    
    505     ctx->rep.Average = ThisGensTotal / (double)ctx->ga.PopSize;
     504    for (p = 0; p < ctx->ga.PopSize; p++){
     505                fitness = PGAGetEvaluation(ctx, p, pop);       
     506                ThisGensTotal += fitness;
     507                ThisGensIndivSquareTotal += fitness*fitness;
     508    }
     509    average = ThisGensTotal / (double)ctx->ga.PopSize;
     510    ctx->rep.Average = average;
     511    variance = ThisGensIndivSquareTotal / (double)ctx->ga.PopSize;
     512    ctx->rep.Variance = (ThisGensIndivSquareTotal - average*average);
    506513   
    507514    PGADebugExited("PGAUpdateAverage");
  • trunk/packages/optimizer/src/plugin_pgapack.c

    r1202 r1271  
    2222    int popSize;         /* population size <=> PGASetPopSize() */
    2323    int popRepl;         /* replacement <=> PGASetPopReplacementType() */
    24     int numReplPerPop;    /* number of new strings created per population, the rest are the best strings from the previous population*/
     24    int numReplPerPop;   /* number of new strings created per population, the rest are the best strings from the previous population*/
     25    double tgtFitness;   /* target fitness for stoppage --either best or average*/
     26    double fitnessTol;   /* %diff betn tgt fit. and current population fit. -- best or avg*/
     27    double tgtVariance;  /* target fitness variance*/
     28    double varianceTol;  /* tolerance : %diff betn tgt and current pop. fitness variance*/
     29    double tgtElapsedTime;   /* target stoppage time from start of execution*/
    2530    int stpcriteria;     /*stoppage criteria <=> PGASetStoppingRuleType()*/
    2631    int randnumseed;  /*Random Number Seed <=> PGASetRandomSeed()*/
    27     double mutnrate;     /*Mutation Rate <=> PGASetMutationProb()*/
     32    double mutnrate;     /*Mutation Rate <=> PGASetMutatuionProb()*/
    2833    double mutnValue;     /*use this value while mutating*/
    2934    double crossovrate;  /*Crossover Rate <=> PGASetCrossoverProb();*/
    30     int crossovtype;    /*Crossover Type <=> UNIFORM/SBX (SBX Defined from Deb and Kumar 1995)*/
     35    int crossovtype;    /*Crossover Type <=> UNIFORM/SBX/TRIANGULAR (SBX Defined from Deb and Kumar 1995)*/
    3136    int allowdup;        /*Allow duplicate strings in the population or not*/
    3237    int mutnandcrossover;/*By default strings that do not undergo crossover undergo mutation, this option allows strings to crossover and be mutated*/
     
    7883  {"-crossovtype",&RpOption_CrossovType,Rp_Offset(PgapackData,crossovtype)},
    7984  {"-randnumseed",RP_OPTION_INT,Rp_Offset(PgapackData,randnumseed)},
     85  {"-tgtFitness",RP_OPTION_DOUBLE,Rp_Offset(PgapackData,tgtFitness)},
     86  {"-fitnessTol",RP_OPTION_DOUBLE,Rp_Offset(PgapackData,fitnessTol)},
     87  {"-tgtVariance",RP_OPTION_DOUBLE,Rp_Offset(PgapackData,tgtVariance)},
     88  {"-varianceTol",RP_OPTION_DOUBLE,Rp_Offset(PgapackData,varianceTol)},
     89  {"-tgtElapsedTime",RP_OPTION_DOUBLE,Rp_Offset(PgapackData,tgtElapsedTime)},
    8090  {"-stpcriteria",&RpOption_StpCriteria,Rp_Offset(PgapackData,stpcriteria)},
    8191  {"-allowdup",RP_OPTION_BOOLEAN,Rp_Offset(PgapackData,allowdup)},
     
    129139    dataPtr->mutnValue = 0.01;/*value of this number will be changed by plus/minus hundredth of its current value*/
    130140    dataPtr->randnumseed = 1; /*should be a number greater than one, PGAPack requires it*/
     141    dataPtr->tgtFitness = PGA_UNINITIALIZED_DOUBLE; 
     142    dataPtr->fitnessTol = PGA_UNINITIALIZED_DOUBLE;  /*by default stop only if desired fitness is exactly achieved*/
     143    dataPtr->tgtVariance = PGA_UNINITIALIZED_DOUBLE;
     144    dataPtr->varianceTol = PGA_UNINITIALIZED_DOUBLE; /* by default stop only if desired variance is exactly achieved*/
     145    dataPtr->tgtElapsedTime = PGA_UNINITIALIZED_DOUBLE; /* stop if 100 minutes have elapsed since start of optim run*/
    131146    dataPtr->stpcriteria = PGA_STOP_NOCHANGE;
    132147    dataPtr->allowdup = PGA_FALSE; /*Do not allow duplicate strings by default*/
     
    170185    PGASetPopSize(ctx, dataPtr->popSize);
    171186    PGASetPopReplaceType(ctx, dataPtr->popRepl);
     187    PGASetTgtFitnessVal(ctx,dataPtr->tgtFitness);
     188    PGASetFitnessTol(ctx,dataPtr->fitnessTol);
     189    PGASetTgtFitnessVariance(ctx,dataPtr->tgtVariance);
     190    PGASetVarTol(ctx,dataPtr->varianceTol);
     191    PGASetTgtElapsedTime(ctx,dataPtr->tgtElapsedTime);
    172192    PGASetStoppingRuleType(ctx, dataPtr->stpcriteria);
    173193    PGASetMutationProb(ctx,dataPtr->mutnrate);
     
    477497    PgapackData *dataPtr;
    478498    /*declare variables for SBX*/
    479     double ui,beta,eta,powVal;
     499    double ui,beta,eta = 1.5,powVal;
     500    double slope = 3,xi;
    480501
    481502    envPtr = PgapGetEnvForContext(ctx);
     
    502523                                case RP_OPTIMPARAM_NUMBER:
    503524                                        ui = PGARandom01(ctx,0);
    504                                         eta = 1.5;/*We can adjust eta later....keeping it 1.5 for now*/
    505525                                        powVal = 1/(eta+1);
    506526                                        if(ui<=0.5){
     
    516536                        }
    517537                        break;
     538                       
     539                       
     540                        case PGA_CROSSOVER_TRIANGULAR:
     541                        xi = 1/sqrt(slope);
     542                        switch(parent1[n].type){
     543                                case RP_OPTIMPARAM_NUMBER:
     544                                        ui = PGARandom01(ctx,0);
     545                                       
     546                                        if(ui<=0.5){
     547                                                beta = sqrt(2*ui/slope);
     548                                                }else{
     549                                                beta = 2*xi-sqrt(2*(1-ui)/slope);
     550                                                }
     551                                        child1[n].value.dval = beta + (parent1[n].value.dval - xi) ;
     552                                        child2[n].value.dval = beta + (parent2[n].value.dval - xi) ;
     553                                        break;
     554                                default:
     555                                        panic("Bad Optim Param Type in PgapCrossover()");
     556                        }
     557                        break;
     558                       
     559                       
    518560                default:
    519561                        panic("bad parameter type in PgapCrossover()");
     
    743785        *ptr = PGA_CROSSOVER_SBX;
    744786    }
     787    else if (strcmp(val,"triangular")== 0 ){
     788        *ptr = PGA_CROSSOVER_TRIANGULAR;
     789    }
    745790    else {
    746791        Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
     
    766811        Tcl_SetResult(interp, "sbx", TCL_STATIC);
    767812        break;
     813    case PGA_CROSSOVER_TRIANGULAR:
     814        Tcl_SetResult(interp,"triangular",TCL_STATIC);
     815        break;   
    768816    default:
    769817        Tcl_SetResult(interp, "???", TCL_STATIC);
     
    833881
    834882/*
    835  * ======================================================================
    836  *  OPTION:  -stpcriteria <=> PGA_STOP_MAXITER / PGA_STOP_NOCHANGE / PGA_STOP_TOOSIMILAR
    837  * ======================================================================
     883 * ==================================================================================================================
     884 *  OPTION:  -stpcriteria <=> PGA_STOP_MAXITER / PGA_STOP_NOCHANGE / PGA_STOP_TOOSIMILAR /
     885 *      PGA_STOP_AV_FITNESS / PGA_STOP_BEST_FITNESS / PGA_STOP_VARIANCE / PGA_STOP_TIMEELAPSED
     886 * ==================================================================================================================
    838887 */
    839888int
     
    855904        *ptr = PGA_STOP_TOOSIMILAR;
    856905    }
     906    else if (strcmp(val,"avfitness") == 0){
     907        *ptr = PGA_STOP_AV_FITNESS;
     908    }
     909    else if (strcmp(val,"bestfitness") == 0){
     910        *ptr = PGA_STOP_BEST_FITNESS;
     911    }
     912    else if (strcmp(val,"varoffitness") == 0){
     913        *ptr = PGA_STOP_VARIANCE;
     914    }
     915    else if (strcmp(val,"timeelapsed") == 0){
     916        *ptr = PGA_STOP_TIMEELAPSED;
     917    }
     918   
    857919    else {
    858920        Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
    859             "bad value \"", val, "\": should be maxiter, nochange or toosimilar",
     921            "bad value \"", val, "\": should be one of the following: maxiter, nochange, toosimilar, avfitness, bestfitness, varoffitness or timeelapsed",
    860922            (char*)NULL);
    861923        return TCL_ERROR;
     
    881943        Tcl_SetResult(interp, "toosimilar", TCL_STATIC);
    882944        break;
     945    case PGA_STOP_AV_FITNESS:
     946        Tcl_SetResult(interp, "avfitness", TCL_STATIC);
     947        break;
     948    case PGA_STOP_BEST_FITNESS:
     949        Tcl_SetResult(interp, "bestfitness", TCL_STATIC);
     950        break;
     951    case PGA_STOP_VARIANCE:
     952        Tcl_SetResult(interp, "varoffitness", TCL_STATIC);
     953        break;
     954    case PGA_STOP_TIMEELAPSED:
     955        Tcl_SetResult(interp, "timeelapsed", TCL_STATIC);
     956        break;       
    883957    default:
    884958        Tcl_SetResult(interp, "???", TCL_STATIC);
Note: See TracChangeset for help on using the changeset viewer.