Changeset 986
- Timestamp:
- Apr 2, 2008 2:32:58 PM (15 years ago)
- Location:
- trunk/optimizer/src
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/optimizer/src/Makefile.in
r951 r986 1 eMakefile.in --1 # Makefile.in -- 2 2 # 3 3 # This file is a Makefile for Sample TEA Extension. If it has the name -
trunk/optimizer/src/pgapack/pgapack/source/parallel.c
r816 r986 69 69 70 70 #include "pgapack.h" 71 #include <setjmp.h> 72 73 extern jmp_buf pgapack_jmpbuf; 74 extern int *pgapack_abortPtr; 71 75 72 76 #define DEBUG_EVAL 0 … … 111 115 112 116 PGAEvaluate(ctx, PGA_OLDPOP, f, comm); 117 113 118 if (rank == 0) 114 119 PGAFitness(ctx, PGA_OLDPOP); … … 192 197 PGASetEvaluation (ctx, p-1, pop, e); 193 198 } 194 } else { 195 for (p=0; p<ctx->ga.PopSize; p++) 199 } else { 200 for (p=0; p<ctx->ga.PopSize; p++) { 201 if ((pgapack_abortPtr != NULL) && (*pgapack_abortPtr == 1)) { 202 longjmp(pgapack_jmpbuf, 1); 203 } 196 204 if (!PGAGetEvaluationUpToDateFlag(ctx, p, pop)) { 197 205 e = (*f)(ctx, p, pop); 198 206 PGASetEvaluation(ctx, p, pop, e); 199 } 207 } 208 } 200 209 } 201 210 PGADebugExited("PGAEvaluateSeq"); … … 485 494 PGAEvaluateSlave(ctx, pop, f, comm); 486 495 } 487 488 496 PGADebugExited("PGAEvaluate"); 489 497 } -
trunk/optimizer/src/pgapack/pgapack/source/pga.c
r816 r986 71 71 72 72 #include "pgapack.h" 73 #include <setjmp.h> 74 75 jmp_buf pgapack_jmpbuf; 73 76 74 77 /*U**************************************************************************** … … 112 115 ndemes = PGAGetNumDemes (ctx); 113 116 117 if (setjmp(pgapack_jmpbuf)) { 118 return; /* PGA pack was aborted. */ 119 } 114 120 /**********************************************************************/ 115 121 /* Global model, one island, one deme */ 116 122 /**********************************************************************/ 117 if ( (npops == 1) && (ndemes == 1) ) { 118 123 if ( (npops == 1) && (ndemes == 1) ) { 119 124 PGARunGM(ctx, evaluate, comm); 120 125 } -
trunk/optimizer/src/pgapack/pgapack/source/stop.c
r816 r986 71 71 72 72 #include "pgapack.h" 73 74 int *pgapack_abortPtr = NULL; 73 75 74 76 /*U**************************************************************************** … … 377 379 PGADebugExited("PGASetMaxSimilarityValue"); 378 380 } 381 382 void PGASetAbortVar(int *abortPtr) 383 { 384 pgapack_abortPtr = abortPtr; 385 } -
trunk/optimizer/src/plugin_pgapack.c
r903 r986 79 79 dataPtr->popRepl = PGA_POPREPL_BEST; 80 80 dataPtr->popSize = 200; 81 82 81 return (ClientData)dataPtr; 83 82 } 83 84 int pgapack_abort = 0; 84 85 85 86 /* … … 103 104 /* fake it here by just saying something like "rappture" */ 104 105 int argc = 1; char *argv[] = {"rappture"}; 106 107 pgapack_abort = 0; /* FALSE */ 108 PGASetAbortVar(&pgapack_abort); 105 109 106 110 ctx = PGACreate(&argc, argv, PGA_DATATYPE_USER, envPtr->numParams, … … 143 147 PgapUnlinkContext2Env(ctx); 144 148 149 if (pgapack_abort) { 150 return RP_OPTIM_ABORTED; 151 } 145 152 return RP_OPTIM_SUCCESS; 146 153 } … … 172 179 status = (*envPtr->evalProc)(envPtr, paramPtr, envPtr->numParams, &fit); 173 180 181 if (pgapack_abort) { 182 fprintf(stderr, "==WARNING: run aborted!"); 183 return 0.0; 184 } 185 174 186 if (status != RP_OPTIM_SUCCESS) { 175 187 fprintf(stderr, "==WARNING: run failed!"); -
trunk/optimizer/src/rp_optimizer_tcl.c
r903 r986 15 15 */ 16 16 #include "rp_optimizer.h" 17 18 extern int pgapack_abort; 17 19 18 20 /* … … 67 69 __declspec( dllexport ) 68 70 #endif 71 72 extern int pgapack_abort; 69 73 70 74 int … … 362 366 return TCL_ERROR; 363 367 } 364 } 365 366 /* 367 * OPTION: get ?globPattern? ?-option? 368 */ 369 else if (*option == 'g' && strcmp(option,"get") == 0) { 368 } else if (*option == 'a' && strcmp(option,"abort") == 0) { 369 int value; 370 371 if (objc < 3) { 372 Tcl_WrongNumArgs(interp, 1, objv, "abort bool"); 373 return TCL_ERROR; 374 } 375 if (Tcl_GetBooleanFromObj(interp, objv[2], &value) != TCL_OK) { 376 return TCL_ERROR; 377 } 378 pgapack_abort = value; 379 return TCL_OK; 380 } else if (*option == 'g' && strcmp(option,"get") == 0) { 381 /* 382 * OPTION: get ?globPattern? ?-option? 383 */ 370 384 if (objc > 2) { 371 385 path = Tcl_GetStringFromObj(objv[2], (int*)NULL); … … 623 637 RpOptimizerPerformInTcl, fitnessExpr); 624 638 639 fprintf(stderr, ">>>status=%d\n", status); 640 625 641 Tcl_DecrRefCount(toolPtr); 626 642 if (updateCmdPtr) { … … 637 653 break; 638 654 case RP_OPTIM_ABORTED: 655 fprintf(stderr, "Got abort status=%d\n", status); 639 656 Tcl_SetResult(interp, "aborted", TCL_STATIC); 640 657 break; … … 824 841 status = Tcl_GlobalEval(toolDataPtr->interp, 825 842 Tcl_DStringValue(&buffer)); 826 827 843 if (status == TCL_ERROR) { 828 844 Tcl_BackgroundError(toolDataPtr->interp); 829 } 830 else if (status == TCL_BREAK || status == TCL_RETURN) { 831 result = RP_OPTIM_ABORTED; 832 } 845 } 833 846 Tcl_DStringFree(&buffer); 834 847 }
Note: See TracChangeset
for help on using the changeset viewer.