Ignore:
Timestamp:
Jun 26, 2008, 7:46:14 PM (16 years ago)
Author:
liveletlive
Message:

Added changes to accomodate gaussian profiles and random number distribution selection on a per gene basis.
also changed the mutation to a per gene based mutation if specified.

File:
1 edited

Legend:

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

    r1062 r1070  
    4747 * ----------------------------------------------------------------------
    4848 */
     49 
     50RpCustomTclOptionGet RpOption_GetRandDist;
     51RpCustomTclOptionParse RpOption_ParseRandDist;
     52RpTclOptionType RpOption_RandDist = {
     53        "pga_randdist", RpOption_ParseRandDist,RpOption_GetRandDist,NULL
     54};
    4955RpTclOption rpOptimNumberOpts[] = {
    5056  {"-min", RP_OPTION_DOUBLE, Rp_Offset(RpOptimParamNumber,min)},
    5157  {"-max", RP_OPTION_DOUBLE, Rp_Offset(RpOptimParamNumber,max)},
     58  {"-mutnrate",RP_OPTION_DOUBLE, Rp_Offset(RpOptimParamNumber,mutnrate)},
     59  {"-randdist",&RpOption_RandDist,Rp_Offset(RpOptimParamNumber,randdist)},
     60  {"-strictmin",RP_OPTION_BOOLEAN,Rp_Offset(RpOptimParamNumber,strictmin)},
     61  {"-strictmax",RP_OPTION_BOOLEAN,Rp_Offset(RpOptimParamNumber,strictmax)},
     62  {"-stddev",RP_OPTION_DOUBLE,Rp_Offset(RpOptimParamNumber,stddev)},
     63  {"-mean",RP_OPTION_DOUBLE,Rp_Offset(RpOptimParamNumber,mean)},
    5264  {NULL, NULL, 0}
    5365};
     
    884896    return result;
    885897}
     898
     899/*
     900 * ======================================================================
     901 *  OPTION:  -randdist <=> RAND_NUMBER_DIST_GAUSSIAN / RAND_NUMBER_DIST_UNIFORM
     902 * ======================================================================
     903 */
     904int
     905RpOption_ParseRandDist(interp, valObj, cdata, offset)
     906    Tcl_Interp *interp;  /* interpreter handling this request */
     907    Tcl_Obj *valObj;     /* set option to this new value */
     908    ClientData cdata;    /* save in this data structure */
     909    int offset;          /* save at this offset in cdata */
     910{
     911    int *ptr = (int*)(cdata+offset);
     912    char *val = Tcl_GetStringFromObj(valObj, (int*)NULL);
     913    if (strcmp(val,"gaussian") == 0) {
     914        *ptr = RAND_NUMBER_DIST_GAUSSIAN;
     915    }
     916    else if (strcmp(val,"uniform") == 0) {
     917        *ptr = RAND_NUMBER_DIST_UNIFORM;
     918    }
     919    else {
     920        Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
     921            "bad value \"", val, "\": should be gaussian or uniform",
     922            (char*)NULL);
     923        return TCL_ERROR;
     924    }
     925    return TCL_OK;
     926}
     927
     928int
     929RpOption_GetRandDist(interp, cdata, offset)
     930    Tcl_Interp *interp;  /* interpreter handling this request */
     931    ClientData cdata;    /* get from this data structure */
     932    int offset;          /* get from this offset in cdata */
     933{
     934    int *ptr = (int*)(cdata+offset);
     935    switch (*ptr) {
     936    case RAND_NUMBER_DIST_GAUSSIAN:
     937        Tcl_SetResult(interp, "gaussian", TCL_STATIC);
     938        break;
     939    case RAND_NUMBER_DIST_UNIFORM:
     940        Tcl_SetResult(interp, "uniform", TCL_STATIC);
     941        break;
     942    default:
     943        Tcl_SetResult(interp, "???", TCL_STATIC);
     944        break;
     945    }
     946    return TCL_OK;
     947}
Note: See TracChangeset for help on using the changeset viewer.