Ignore:
Timestamp:
Apr 2, 2008, 2:32:58 PM (16 years ago)
Author:
gah
Message:

added global pgapack_abort flag to plugin and abort operation to optimizer

Location:
trunk/optimizer/src/pgapack/pgapack
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/optimizer/src/pgapack/pgapack/source/parallel.c

    r816 r986  
    6969
    7070#include "pgapack.h"
     71#include <setjmp.h>
     72
     73extern jmp_buf pgapack_jmpbuf;
     74extern int *pgapack_abortPtr;
    7175
    7276#define DEBUG_EVAL 0
     
    111115
    112116    PGAEvaluate(ctx, PGA_OLDPOP, f, comm);
     117       
    113118    if (rank == 0)
    114119        PGAFitness(ctx, PGA_OLDPOP);
     
    192197                PGASetEvaluation (ctx, p-1, pop, e);
    193198            }
    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            }
    196204            if (!PGAGetEvaluationUpToDateFlag(ctx, p, pop)) {
    197205                e = (*f)(ctx, p, pop);
    198206                PGASetEvaluation(ctx, p, pop, e);
    199             }
     207            }
     208        }
    200209    }
    201210    PGADebugExited("PGAEvaluateSeq");
     
    485494        PGAEvaluateSlave(ctx, pop, f, comm);
    486495    }
    487 
    488496    PGADebugExited("PGAEvaluate");
    489497}
  • trunk/optimizer/src/pgapack/pgapack/source/pga.c

    r816 r986  
    7171
    7272#include "pgapack.h"
     73#include <setjmp.h>
     74
     75jmp_buf pgapack_jmpbuf;
    7376
    7477/*U****************************************************************************
     
    112115     ndemes = PGAGetNumDemes    (ctx);
    113116
     117    if (setjmp(pgapack_jmpbuf)) {
     118        return;                 /* PGA pack was aborted. */
     119    }
    114120     /**********************************************************************/
    115121     /*              Global model, one island, one deme                    */
    116122     /**********************************************************************/
    117      if     ( (npops == 1) && (ndemes == 1) ) {
    118 
     123     if ( (npops == 1) && (ndemes == 1) ) {
    119124         PGARunGM(ctx, evaluate, comm);
    120125     }
  • trunk/optimizer/src/pgapack/pgapack/source/stop.c

    r816 r986  
    7171
    7272#include "pgapack.h"
     73
     74int *pgapack_abortPtr = NULL;
    7375
    7476/*U****************************************************************************
     
    377379    PGADebugExited("PGASetMaxSimilarityValue");
    378380}
     381
     382void PGASetAbortVar(int *abortPtr)
     383{
     384    pgapack_abortPtr = abortPtr;
     385}
Note: See TracChangeset for help on using the changeset viewer.