Changeset 1062 for trunk/packages/optimizer/src/rp_optimizer_tcl.c
- Timestamp:
- Jun 24, 2008, 6:13:41 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/optimizer/src/rp_optimizer_tcl.c
r986 r1062 71 71 72 72 extern int pgapack_abort; 73 extern void PGARuntimeDataTableInit(); 74 extern void PGARuntimeDataTableDeInit(); 75 extern void GetSampleInformation(); 73 76 74 77 int … … 224 227 toolDataPtr->updateCmdPtr = NULL; 225 228 envPtr->toolData = (ClientData)toolDataPtr; 226 227 229 Tcl_CreateObjCommand(interp, name, RpOptimInstanceCmd, 228 230 (ClientData)envPtr, (Tcl_CmdDeleteProc*)RpOptimCmdDelete); 229 230 231 Tcl_SetResult(interp, name, TCL_VOLATILE); 231 232 return TCL_OK; … … 250 251 ClientData paramdata; 251 252 253 PGARuntimeDataTableDeInit();/*Free space allocated to data table here*/ 252 254 if (envPtr->toolData) { 253 255 toolDataPtr = (RpOptimToolData*)envPtr->toolData; … … 290 292 * ?-updatecommand <varName>? 291 293 * <name> using 294 * <name> samples ?number? 292 295 * 293 296 * The "add" command is used to add various parameter types to the 294 297 * optimizer context. The "perform" command kicks off an optimization 295 * run. 298 * run. The "samples" command displays sample info during an optimization run. 296 299 * ------------------------------------------------------------------------ 297 300 */ … … 313 316 RpTclOption *optSpecPtr; 314 317 Tcl_Obj *rval, *rrval, *toolPtr, *updateCmdPtr; 315 318 316 319 if (objc < 2) { 317 320 Tcl_WrongNumArgs(interp, 1, objv, "option ?args...?"); … … 580 583 /* no -updatecommand by default */ 581 584 updateCmdPtr = NULL; 582 585 586 PGARuntimeDataTableInit(envPtr);/*Initialize Data table here....*/ 587 583 588 n = 2; 584 589 while (n < objc) { … … 632 637 toolDataPtr->updateCmdPtr = updateCmdPtr; 633 638 } 634 639 635 640 /* call the main optimization routine here */ 636 641 status = (*envPtr->pluginDefn->runProc)(envPtr, 637 642 RpOptimizerPerformInTcl, fitnessExpr); 638 639 fprintf(stderr, ">>>status=%d\n", status);643 644 fprintf(stderr, ">>>status=%d\n", status); 640 645 641 646 Tcl_DecrRefCount(toolPtr); … … 682 687 return TCL_OK; 683 688 } 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 } 684 716 685 717 else { 686 718 Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), 687 719 "bad option \"", option, "\": should be add, configure, " 688 "get, perform, using ", (char*)NULL);720 "get, perform, using, samples", (char*)NULL); 689 721 return TCL_ERROR; 690 722 }
Note: See TracChangeset
for help on using the changeset viewer.