From: <kin...@us...> - 2010-11-15 15:36:42
|
Revision: 4696 http://teem.svn.sourceforge.net/teem/?rev=4696&view=rev Author: kindlmann Date: 2010-11-15 15:36:35 +0000 (Mon, 15 Nov 2010) Log Message: ----------- added pullCount handling, so that major events can be counted, and clarified logic of ignoreImage when learning energy Modified Paths: -------------- teem/trunk/src/pull/actionPull.c teem/trunk/src/pull/constraints.c teem/trunk/src/pull/contextPull.c teem/trunk/src/pull/enumsPull.c teem/trunk/src/pull/pointPull.c teem/trunk/src/pull/popcntl.c teem/trunk/src/pull/pull.h Modified: teem/trunk/src/pull/actionPull.c =================================================================== --- teem/trunk/src/pull/actionPull.c 2010-10-21 13:55:08 UTC (rev 4695) +++ teem/trunk/src/pull/actionPull.c 2010-11-15 15:36:35 UTC (rev 4696) @@ -691,13 +691,21 @@ ELL_4V_SET(egradIm, 0, 0, 0, 0); ELL_4V_SET(egradPt, 0, 0, 0, 0); - if (!ignoreImage && task->pctx->sysParm.alpha < 1.0) { + if (!( ignoreImage || 1.0 == task->pctx->sysParm.alpha )) { enrIm = _energyFromImage(task, point, egrad ? egradIm : NULL); + task->pctx->count[pullCountEnergyFromImage] += 1; + if (egrad) { + task->pctx->count[pullCountForceFromImage] += 1; + } } else { enrIm = 0; } if (task->pctx->sysParm.alpha > 0.0) { enrPt = _pullEnergyFromPoints(task, bin, point, egrad ? egradPt : NULL); + task->pctx->count[pullCountEnergyFromPoints] += 1; + if (egrad) { + task->pctx->count[pullCountForceFromPoints] += 1; + } } else { enrPt = 0; } @@ -776,6 +784,7 @@ double energyOld, energyNew, egrad[4], force[4], posOld[4]; int stepBad, giveUp, hailMary; + task->pctx->count[pullCountDescent] += 1; if (!point->stepEnergy) { fprintf(stderr, "\n\n\n%s: whoa, point %u step is zero!!\n\n\n\n", me, point->idtag); @@ -887,6 +896,7 @@ point->pos[3], task->pctx->bboxMax[3]); } + task->pctx->count[pullCountTestStep] += 1; _pullPointHistAdd(point, pullCondEnergyTry); if (task->pctx->constraint) { if (_pullConstraintSatisfy(task, point, &constrFail)) { @@ -1017,13 +1027,15 @@ switch (task->processMode) { case pullProcessModeDescent: E = _pullPointProcessDescent(task, bin, point, - AIR_FALSE /* ignoreImage */); + !task->pctx->haveScale /* ignoreImage */); break; case pullProcessModeNeighLearn: E = _pullPointProcessNeighLearn(task, bin, point); break; case pullProcessModeAdding: - E = _pullPointProcessAdding(task, bin, point); + if (!task->pctx->flag.noAdd) { + E = _pullPointProcessAdding(task, bin, point); + } break; case pullProcessModeNixing: E = _pullPointProcessNixing(task, bin, point); Modified: teem/trunk/src/pull/constraints.c =================================================================== --- teem/trunk/src/pull/constraints.c 2010-10-21 13:55:08 UTC (rev 4695) +++ teem/trunk/src/pull/constraints.c 2010-11-15 15:36:35 UTC (rev 4696) @@ -558,6 +558,7 @@ me, point->idtag, point->pos[0], point->pos[1], point->pos[2], stepMax, iterMax); */ + task->pctx->count[pullCountConstraintSatisfy] += 1; switch (task->pctx->constraint) { case pullInfoHeightLaplacian: /* zero-crossing edges */ if (constraintSatLapl(task, point, stepMax/4, 4*iterMax, constrFailP)) { Modified: teem/trunk/src/pull/contextPull.c =================================================================== --- teem/trunk/src/pull/contextPull.c 2010-10-21 13:55:08 UTC (rev 4695) +++ teem/trunk/src/pull/contextPull.c 2010-11-15 15:36:35 UTC (rev 4696) @@ -96,6 +96,9 @@ pctx->stuckNum = 0; pctx->pointNum = 0; pctx->iter = 0; + for (ii=pullCountUnknown; ii<pullCountLast; ii++) { + pctx->count[ii] = 0; + } return pctx; } Modified: teem/trunk/src/pull/enumsPull.c =================================================================== --- teem/trunk/src/pull/enumsPull.c 2010-10-21 13:55:08 UTC (rev 4695) +++ teem/trunk/src/pull/enumsPull.c 2010-11-15 15:36:35 UTC (rev 4696) @@ -220,3 +220,35 @@ const airEnum *const pullProcessMode = &_pullProcessMode; +/* --------------------------------------------------------- */ + +const char * +_pullCountStr[] = { + "(unknown_countable)", + "descent", + "teststep", + "enrg(img)", + "frc(img)", + "enrg(pts)", + "frc(pts)", + "probe", + "constr", + "adding", + "nixing", + "pts stuck", + "pts", + "CC", + "iter" +}; + +const airEnum +_pullCount = { + "countable", + PULL_COUNT_MAX, + _pullCountStr, NULL, + NULL, NULL, NULL, + AIR_FALSE +}; +const airEnum *const +pullCount = &_pullCount; + Modified: teem/trunk/src/pull/pointPull.c =================================================================== --- teem/trunk/src/pull/pointPull.c 2010-10-21 13:55:08 UTC (rev 4695) +++ teem/trunk/src/pull/pointPull.c 2010-11-15 15:36:35 UTC (rev 4696) @@ -357,6 +357,7 @@ printf("%s: hello; probing %u volumes\n", me, task->pctx->volNum); } edge = AIR_FALSE; + task->pctx->count[pullCountProbe] += 1; for (ii=0; ii<task->pctx->volNum; ii++) { pullVolume *vol; vol = task->vol[ii]; @@ -1103,7 +1104,8 @@ for (pointIdx=0; pointIdx<bin->pointNum; pointIdx++) { point = bin->point[pointIdx]; point->energy = _pullPointEnergyTotal(pctx->task[0], bin, point, - AIR_FALSE, /* ignoreImage */ + /* ignoreImage */ + !pctx->haveScale, point->force); } } Modified: teem/trunk/src/pull/popcntl.c =================================================================== --- teem/trunk/src/pull/popcntl.c 2010-10-21 13:55:08 UTC (rev 4695) +++ teem/trunk/src/pull/popcntl.c 2010-11-15 15:36:35 UTC (rev 4696) @@ -65,10 +65,7 @@ pullPoint *newpnt; int E; - /* HEY this is probably not the best place for this */ - if (task->pctx->flag.noAdd) { - return 0; - } + task->pctx->count[pullCountAdding] += 1; if (point->neighPointNum && task->pctx->targetDim && task->pctx->flag.popCntlEnoughTest) { @@ -198,7 +195,10 @@ for (iter=0; iter<task->pctx->iterParm.addDescent; iter++) { double diff[4]; if (!E) E |= _pullPointProcessDescent(task, bin, newpnt, - AIR_FALSE /* ignoreImage */); + /* ignoreImage; actually it is + this use which motivated the + creation of ignoreImage */ + AIR_TRUE); if (newpnt->status & PULL_STATUS_STUCK_BIT) { if (task->pctx->verbose > 2) { printf("%s: possible newpnt %u stuck @ iter %u; nope\n", me, @@ -317,6 +317,8 @@ _pullPointProcessNixing(pullTask *task, pullBin *bin, pullPoint *point) { double enrWith, enrWithout, fracNixed; + task->pctx->count[pullCountNixing] += 1; + /* if there's a live thresh, do we meet it? */ if (task->pctx->ispec[pullInfoLiveThresh] && 0 > _pullPointScalar(task->pctx, point, pullInfoLiveThresh, Modified: teem/trunk/src/pull/pull.h =================================================================== --- teem/trunk/src/pull/pull.h 2010-10-21 13:55:08 UTC (rev 4695) +++ teem/trunk/src/pull/pull.h 2010-11-15 15:36:35 UTC (rev 4696) @@ -266,6 +266,30 @@ }; #define PULL_SOURCE_MAX 2 +/* +** the different kinds of computations and entitis that one could +** book-keeping and optimization purposes +*/ +enum { + pullCountUnknown, /* 0 */ + pullCountDescent, /* 1 */ + pullCountTestStep, /* 2 */ + pullCountEnergyFromImage, /* 3 */ + pullCountForceFromImage, /* 4 */ + pullCountEnergyFromPoints, /* 5 */ + pullCountForceFromPoints, /* 6 */ + pullCountProbe, /* 7 */ + pullCountConstraintSatisfy, /* 8 */ + pullCountAdding, /* 9 */ + pullCountNixing, /* 10 */ + pullCountPointsStuck, /* 11 */ + pullCountPoints, /* 12 */ + pullCountCC, /* 13 */ + pullCountIteration, /* 14 */ + pullCountLast +}; +#define PULL_COUNT_MAX 14 + /* ** Defines how par-particle information can be learned. This is ** typically via measurements in the image by gage, but other sources @@ -856,7 +880,9 @@ stuckNum, /* # stuck particles in last iter */ pointNum, /* total # particles */ CCNum, /* # connected components */ - iter; /* how many iterations were needed */ + iter, /* how many iterations were needed */ + /* HEY: this should really be per-task, to be thread-safe!! */ + count[PULL_COUNT_MAX+1]; /* all possible kinds of counts */ } pullContext; /* defaultsPull.c */ @@ -950,6 +976,7 @@ PULL_EXPORT const airEnum *const pullSource; PULL_EXPORT const airEnum *const pullProp; PULL_EXPORT const airEnum *const pullProcessMode; +PULL_EXPORT const airEnum *const pullCount; /* infoPull.c */ PULL_EXPORT unsigned int pullPropLen(int prop); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |