Ignore:
Timestamp:
Jun 24, 2008, 6:13:41 PM (16 years ago)
Author:
liveletlive
Message:

Committing changes related to command <name> samples ?number?

File:
1 edited

Legend:

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

    r986 r1062  
    7171
    7272extern int pgapack_abort;
     73extern void PGARuntimeDataTableInit();
     74extern void PGARuntimeDataTableDeInit();
     75extern void GetSampleInformation();
    7376
    7477int
     
    224227    toolDataPtr->updateCmdPtr = NULL;
    225228    envPtr->toolData = (ClientData)toolDataPtr;
    226 
    227229    Tcl_CreateObjCommand(interp, name, RpOptimInstanceCmd,
    228230        (ClientData)envPtr, (Tcl_CmdDeleteProc*)RpOptimCmdDelete);
    229 
    230231    Tcl_SetResult(interp, name, TCL_VOLATILE);
    231232    return TCL_OK;
     
    250251    ClientData paramdata;
    251252
     253    PGARuntimeDataTableDeInit();/*Free space allocated to data table here*/
    252254    if (envPtr->toolData) {
    253255        toolDataPtr = (RpOptimToolData*)envPtr->toolData;
     
    290292 *                     ?-updatecommand <varName>?
    291293 *      <name> using
     294 *      <name> samples ?number?
    292295 *
    293296 *  The "add" command is used to add various parameter types to the
    294297 *  optimizer context.  The "perform" command kicks off an optimization
    295  *  run.
     298 *  run. The "samples" command displays sample info during an optimization run.
    296299 * ------------------------------------------------------------------------
    297300 */
     
    313316    RpTclOption *optSpecPtr;
    314317    Tcl_Obj *rval, *rrval, *toolPtr, *updateCmdPtr;
    315 
     318   
    316319    if (objc < 2) {
    317320        Tcl_WrongNumArgs(interp, 1, objv, "option ?args...?");
     
    580583        /* no -updatecommand by default */
    581584        updateCmdPtr = NULL;
    582 
     585               
     586                PGARuntimeDataTableInit(envPtr);/*Initialize Data table here....*/
     587               
    583588        n = 2;
    584589        while (n < objc) {
     
    632637            toolDataPtr->updateCmdPtr = updateCmdPtr;
    633638        }
    634 
     639               
    635640        /* call the main optimization routine here */
    636641        status = (*envPtr->pluginDefn->runProc)(envPtr,
    637642            RpOptimizerPerformInTcl, fitnessExpr);
    638 
    639         fprintf(stderr, ">>>status=%d\n", status);
     643               
     644                fprintf(stderr, ">>>status=%d\n", status);
    640645
    641646        Tcl_DecrRefCount(toolPtr);
     
    682687        return TCL_OK;
    683688    }
     689   
     690    else if(*option == 's' && strcmp(option,"samples") == 0){
     691        int sampleNumber = -1; /*initing sampnum to -1, use it when no sample number is specified*/
     692        char *sampleDataBuffer;
     693        if(objc>3){
     694                Tcl_WrongNumArgs(interp, 2, objv, "?sampleNumber?");
     695            return TCL_ERROR;
     696        }
     697       
     698        if(objc == 3){
     699                if(Tcl_GetIntFromObj(interp,objv[2],&sampleNumber) != TCL_OK){
     700                        return TCL_ERROR;
     701                }
     702                sampleDataBuffer = malloc(sizeof(char)*SINGLE_SAMPLE_DATA_BUFFER_DEFAULT_SIZE);
     703        }else{
     704                sampleDataBuffer = malloc(sizeof(char)*50);
     705        }
     706       
     707        if(sampleDataBuffer == NULL){
     708                panic("Error: Could not allocate memory for sample data buffer.");
     709        }
     710        GetSampleInformation(sampleDataBuffer,sampleNumber);
     711                fprintf(stdout,sampleDataBuffer);/**TODO GTG check if this should be fprintf or something else*/
     712                free(sampleDataBuffer);
     713        return TCL_OK;
     714       
     715    }
    684716
    685717    else {
    686718        Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
    687719            "bad option \"", option, "\": should be add, configure, "
    688             "get, perform, using", (char*)NULL);
     720            "get, perform, using, samples", (char*)NULL);
    689721        return TCL_ERROR;
    690722    }
Note: See TracChangeset for help on using the changeset viewer.