Ignore:
Timestamp:
Sep 15, 2008 6:54:01 AM (14 years ago)
Author:
liveletlive
Message:

tweaked the configuration code for number parameters.
added code required to include units of a number parameter.

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

Legend:

Unmodified
Added
Removed
  • trunk/packages/optimizer/src/plugin_pgapack.c

    r1070 r1154  
    293293                if(numPtr->randdist == RAND_NUMBER_DIST_UNIFORM){
    294294                        dval = PGARandom01(ctx,0);
    295                         newParamPtr[n].value.dval =
    296                     (numPtr->max - numPtr->min)*dval + numPtr->min;
     295                        newParamPtr[n].value.dval = (numPtr->max - numPtr->min)*dval + numPtr->min;
    297296                }else if(numPtr->randdist == RAND_NUMBER_DIST_GAUSSIAN){
    298297                                dval = PGARandomGaussian(ctx,numPtr->mean,numPtr->stddev);
     
    892891{
    893892        int i;
    894         printf("\nSetting sample value.......................\n");
     893        //printf("\nSetting sample value.......................\n");
    895894        if(chrom!=NULL && (&table)!=NULL){
    896895                (table.no_of_samples_evaled)+=1;
     
    910909                                        if(i==0){
    911910                                                table.data[i][(table.no_of_samples_evaled)-1] = fitness;
    912                                                 printf("\nSample Number %d:- Fitness: %lf\t",table.no_of_samples_evaled,fitness);
     911                                                //printf("\nSample Number %d:- Fitness: %lf\t",table.no_of_samples_evaled,fitness);
    913912                                        }else{
    914913                                                table.data[i][(table.no_of_samples_evaled)-1] = chrom[i-1].value.dval;
    915                                                 printf("Param %d %lf\t",i,table.data[i][(table.no_of_samples_evaled)-1]);
     914                                                //printf("Param %d %lf\t",i,table.data[i][(table.no_of_samples_evaled)-1]);
    916915                                        }
    917916                }
  • trunk/packages/optimizer/src/rp_optimizer.c

    r1070 r1154  
    118118    numPtr->stddev = 1;
    119119    numPtr->mean = 0;
    120     numPtr->strictmax = 0; /*no strict truncation by default*/
    121     numPtr->strictmax = 0; /*no strict maximum truncation by default*/
    122 
     120    numPtr->strictmax = 0; /*no strictmax truncation by default*/
     121    numPtr->strictmin = 0; /*no strict minimum truncation by default*/
     122        numPtr->units = ""; /* Blank Units by default*/
    123123    RpOptimAddParam(envPtr, (RpOptimParam*)numPtr);
    124124
  • trunk/packages/optimizer/src/rp_optimizer.h

    r1070 r1154  
    112112    double stddev;                                      /* std deviaton for gaussian profile*/
    113113    double mean;                                        /* mean for gaussian profile*/
     114    char *units;
    114115} RpOptimParamNumber;
    115116
  • trunk/packages/optimizer/src/rp_optimizer_tcl.c

    r1070 r1154  
    6262  {"-stddev",RP_OPTION_DOUBLE,Rp_Offset(RpOptimParamNumber,stddev)},
    6363  {"-mean",RP_OPTION_DOUBLE,Rp_Offset(RpOptimParamNumber,mean)},
     64  {"-units",RP_OPTION_STRING,Rp_Offset(RpOptimParamNumber,units)},
    6465  {NULL, NULL, 0}
    6566};
     
    767768    Tcl_Obj *dataPtr;
    768769    Tcl_DString buffer;
     770    RpOptimParamNumber *numPtr;
     771    char dvalBuffer[50];
    769772
    770773    /*
     
    785788        switch (values[n].type) {
    786789        case RP_OPTIMPARAM_NUMBER:
    787             objv[2*n+3] = Tcl_NewDoubleObj(values[n].value.dval);
     790                numPtr = (RpOptimParamNumber*)envPtr->paramList[n];
     791                status = sprintf(dvalBuffer,"%lf%s",values[n].value.dval,numPtr->units);
     792                if(status<0){
     793                        panic("Could not convert number into number+units format");
     794                }
     795            objv[2*n+3] = Tcl_NewStringObj(dvalBuffer,-1);
    788796            Tcl_IncrRefCount(objv[2*n+3]);
    789797            break;
     
    847855                if (status != TCL_OK) {
    848856                    result = RP_OPTIM_FAILURE;
    849                     fprintf(stderr, "== UNEXPECTED ERROR while extracting output value:%s\n", Tcl_GetStringResult(interp));
     857                    fprintf(stderr, "==UNEXPECTED ERROR while extracting output value:%s\n", Tcl_GetStringResult(interp));
    850858                } else if (Tcl_GetDoubleFromObj(interp,
    851859                      Tcl_GetObjResult(interp), fitnessPtr) != TCL_OK) {
    852860                    result = RP_OPTIM_FAILURE;
    853                     fprintf(stderr, "== ERROR while extracting output value:%s\n", Tcl_GetStringResult(interp));
     861                    fprintf(stderr, "==ERROR while extracting output value:%s\n", Tcl_GetStringResult(interp));
    854862                }
    855863                for (n=0; n < 3; n++) {
Note: See TracChangeset for help on using the changeset viewer.