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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.