/**@ probzeros.p **/ void /*PROCEDURE*/ probzeros() /*COMPILED*/ /*VAR*/{ real p; integer itype, jtype; fprintf (eout," PROB (ZERO cells)\n"); fprintf (eout," At time %2.4f\n", timevec [nt]); if ( ntypes > 1) { for (itype = 1; itype <= (int)ntypes; itype ++) { wvec [itype] = ONE; svec [itype] = ZERO; } fprintf (eout,"[probzeros] nt1 %d",nt); p = jointpgf (svec, nt, nconds); fprintf (eout," pr {total = 0} %12f\n", p); } for (itype = 1; itype <= (int)ntypes; itype ++) { for (jtype = 1; jtype <= (int)ntypes; jtype ++) { wvec [jtype] = ZERO; svec [jtype] = ONE; } wvec [itype] = ONE; svec [itype] = ZERO; fprintf (eout,"[probzeros] nt2 %d",nt); p = jointpgf (svec, nt, nconds); fprintf (eout,"pr {# of type "); typestring ( cellname (itype)); fprintf (eout," = 0} %12f\n", p); } }
bool FUNCPCCELLID::execute(void) { bool result= false; VMPTR<TES3CELLMASTER*> pcellmaster(machine); VMPTR<TES3CELLMASTER> cellmaster(machine); VMPTR<TES3CELL> cell(machine); VMPTR<TES3IDSTRING> cellname(machine); const char* cellid= "Wilderness"; try { pcellmaster= (TES3CELLMASTER**)reltolinear(MASTERCELL_IMAGE); cellmaster= *pcellmaster; cell= cellmaster->interiorcell; if(!cell) { VMPTR<TES3CELLPTR> cellptr(machine); cellptr= cellmaster->exteriorcells[CENTRE]; cell= cellptr->first; } if(cell) { cellname= (VPIDSTRING)cell->cellname; if(cellname) cellid=(const char*)cellname->id; } cellid= strings.add(cellid); // LOG::log("%s = PCCELLID()\n",cellid); result= machine.push((VMREGTYPE)cellid); } catch(...) { cLog::mLogMessage("PCCELLID() exception\n"); result= false; } return result; }
static void run_tests_innerL() { TNoDefaults nd; auto_ptr<CApp_context> c(CApp_context::NewL(true, _L("locatest"))); auto_ptr<CBaActiveScheduler> sched(new (ELeave) CBaActiveScheduler); CActiveScheduler::Install(sched.get()); c->SetDataDir(_L("c:\\system\\data\\context\\"), false); c->SetSettings(CBlackBoardSettings::NewL(*c, nd, KCLSettingsTuple)); auto_ptr<CBBDataFactory> f(CBBDataFactory::NewL()); c->SetBBDataFactory(f.get()); auto_ptr<CBBSession> sess(CBBSession::NewL(*c, f.get())); c->SetBBSession(sess.get()); c->SetActiveErrorReporter(output); auto_ptr<CPresenceMaintainer> pmp(CPresenceMaintainer::NewL(*c, 0, 0, 0, 0)); CPresenceMaintainerImpl* pm=(CPresenceMaintainerImpl*)pmp.get(); _LIT(cn, "cellname"); TBBLongString cellname(_L("cell1"), cn); CBBSensorEvent e(cn, KCellNameTuple, f.get()); e.iData.SetOwnsValue(EFalse); e.iData.SetValue(&cellname); e.iStamp=TTime(100); pm->NewSensorEventL(KCellNameTuple, KNullDesC, e); TInt isactive=0; if (pm->iNonsignificantTimer->IsActive()) isactive=1; TEST_EQUALS( 1, isactive, _L("nonsig1") ); { TBBBaseInfo b; b.iCurrent.iEntered=TTime(100); b.iCurrent.iLeft=TTime(0); b.iCurrent.iBaseName=_L("cell2"); e.iData.SetValue(&b); pm->NewSensorEventL(KBaseTuple, KNullDesC, e); if (pm->iNonsignificantTimer->IsActive()) isactive=1; else isactive=0; TEST_EQUALS( 0, isactive, _L("nonsig2") ); } cellname()=_L("cell3"); e.iStamp=TTime(100); e.iData.SetValue(&cellname); pm->NewSensorEventL(KCellNameTuple, KNullDesC, e); if (pm->iNonsignificantTimer->IsActive()) isactive=1; else isactive=0; TEST_EQUALS( 0, isactive, _L("nonsig3") ); cellname()=_L("cell4"); e.iStamp=TTime(110); e.iData.SetValue(&cellname); pm->NewSensorEventL(KCellNameTuple, KNullDesC, e); if (pm->iNonsignificantTimer->IsActive()) isactive=1; else isactive=0; TEST_EQUALS( 0, isactive, _L("nonsig4") ); { TBBBaseInfo b; b.iCurrent.iEntered=TTime(100); b.iCurrent.iLeft=TTime(110); b.iCurrent.iBaseName=_L("cell2"); e.iData.SetValue(&b); pm->NewSensorEventL(KBaseTuple, KNullDesC, e); if (pm->iNonsignificantTimer->IsActive()) isactive=1; else isactive=0; TEST_EQUALS( 0, isactive, _L("nonsig5") ); } cellname()=_L("cell3"); e.iStamp=TTime(120); e.iData.SetValue(&cellname); pm->NewSensorEventL(KCellNameTuple, KNullDesC, e); if (pm->iNonsignificantTimer->IsActive()) isactive=1; else isactive=1; TEST_EQUALS( 1, isactive, _L("nonsig6") ); }
void cellp( double delta_t) #endif { int itype,iindex, cn,ismax=False; int cells_survived = 0; int PrintLoopVar=PrintGap; double bigEndT, jjj; int snow; double TotalCells; int SendCellCountOneTime; char stemp[255]; int ksumlevel; int GiveTimeCount; int envnowl = 0; extern void release_mem(); extern double rand01(int), ranmarm(int); #ifdef TEST time_t stime; #endif #ifndef DLL FILE *out;/* the pointer to s2.out, the interface file to Java */ #endif #ifdef TESTMPI extern int nrepetitions; #endif if (Cured == False) { SendCellCountOneTime = True; } else { SendCellCountOneTime = False; } /*_ASSERT(0);*/ /* This func call inits the nexttoxtime variable*/ Tblength = (long) (ntypes/Class[0].no_levels); InitNextToxTime(); SetBBForPatient(); snow = 0; if ((GiveTimeCount = 48 - (ntypes * 3)) < 0) GiveTimeCount = 0; /* Changes: 12 September 1996 * while((timevec[itime] <= StartT) && (itime <= nallts)) itime++; * <= changed to < . This ensures that itime is no increased when timevec[itime] = startT */ /* added by Qinshou 10/25/96 for test suites */ #ifdef TEST /* construct output file name */ if ( nrepetitions == 1 ) { if (numTest <= 9 ) sprintf(outName,"%s0%1d.%d.%d.0%d.out",outName,numTest,nrepetitions,(int)EndT,(int)(delta_t*1000)); else sprintf(outName,"%s%2d.%d.%d.0%d.out",outName,numTest,nrepetitions,(int)EndT,(int)(delta_t*1000)); out = fopen(outName,"w"); } else out = fopen(outName,"a"); if ( out==NULL ) { printf("Error opening %s\n",outName); Memory=False; return; } if ( nrepetitions ==1 ) printvalue(out); #endif t=StartT; UpdateTime = 0.0; cellpitime = 2; nowenv = 0; if (KineticsModel == IsGompertz ) { for ( iindex=1; iindex<=active_ntypes;iindex++) { /* Number_of_Gomp_Classes includes gomp class for whole body */ for ( cn=0; cn <Number_of_Gomp_Classes; cn++ ) { if ( LookUp[iindex].mark != NEG ) { ksumlevel = SumGompLevel(cn,iindex); if ( IsGompSumOverFlow(ksumlevel,cn)) { Memory = False; return; } NGomp(cn,ksumlevel) += CN[iindex]; /* GompRuleIndex=0 is for whole body */ } } /* micro class add VE and CA cells */ cn = Number_of_Gomp_Classes; ksumlevel = SumGompLevel(cn,iindex); if ( (iindex > pre_ntypes ) && IsGompSumOverFlow(ksumlevel,cn)){ Memory = false; return; } NGomp(cn,ksumlevel) += CN[iindex]; } } while((timevec[cellpitime] > t) && (timevec[cellpitime] < t + delta_t) && (cellpitime <= nallts)) cellpitime++; /* For each sample, the cell population is got at time EndT. */ bigEndT = EndT + delta_t / 2; while ( t < bigEndT ) { /*for speed sake, only update cell counts if patient isn't cured*/ if (Cured != True) { if (NextPBin(&envnowl) == False ) { release_mem(SIM); Memory=False; #ifdef DLL MessageBox(NULL,"Sorry. The total number of cell types has exceeded the memory limits, Please reduce the number of levels or number of classes. Try again.","treat.dll",MB_ICONEXCLAMATION | MB_OK); #else printf("Sorry. The total number of cell types has exceeded the memory limits\n"); #endif return; } if ((t >= timevec[cellpitime] ) && ( timevec[cellpitime] < t+delta_t) && (cellpitime <= nallts)) { for ( itype = 1; itype <= active_ntypes; itype++ ) { if ( timesurv(cellpitime,itype,envnowl) < 1.0 ) { jjj = timesurv(cellpitime,itype,envnowl); nDescOfItype(itype) = grand_b_n( CN[itype], timesurv(cellpitime,itype,envnowl) ) - CN[itype]; if (Update_CN_NGomp(itype,envnowl)== false ){ release_mem(SIM); Memory=False; #ifdef DLL MessageBox(NULL,"Sorry. The total number of cell types has exceeded the memory limits, Please reduce the number of levels or number of classes. Try again.","treat.dll",MB_ICONEXCLAMATION | MB_OK); #else printf("Sorry. The total number of cell types has exceeded the memory limits\n"); #endif return ; } //should send treatment event right here //also, send plot update event } } if (CheckForTreatment()) PlotHandler(); CheckForTox(); cellpitime++; } } /* check for any toxicity events */ /*#ifdef DLL*/ CheckForTox(); /* call here for CheckBBRules */ CheckBBRules(); ResetBBEveryDeltaT(); //do this in case the enviroment was changed by a rule. envnowl = nowenv; // CheckForTreatment(); if ((HasGuaranteeTimeChecked == False) && (nconds >0)) { CheckGuaranteeTime(); } if ( TrialSim == False || TSFirstTreatmentHappened == True ) check_events(); /*#endif */ if (( t >= BeginPlotTime) && (t <= EndPlotTime)) { if ( PrintLoopVar == PrintGap) { if (nrepetitions == 1) { if (Cured != True) { /*#ifdef DLL */ //AddToCellQ(); PlotHandler(); #ifdef DLL if (SleepTime != 0) { if (SleepTime != -1) Sleep(SleepTime); else while(SleepTime == -1) Sleep(0); } #endif /*#else*/ #ifdef TEST /* fprintf(out,"%5.3e",t);*/ fprintf(out,"%5.3e [%d]",t, active_ntypes); #endif for (itype = 1; itype <= active_ntypes; itype++ ) { #ifdef TEST /* fprintf(out," %5.2e",CN[itype]); */ fprintf(out," %5.2e (%d,%s)",CN[itype],LookUp[itype].LookUpId,cellname(itype)); fflush(out); #endif } #ifdef TEST fprintf(out,"\n"); #endif /*#endif*/ }/* close cured */ if ((Cured == True) && (SendCellCountOneTime == True)) { // AddToCellQ(); PlotHandler(); SendCellCountOneTime = False; } } /* close nrepetions */ PrintLoopVar = 1; }/* printloopvar */ else PrintLoopVar++; }/*begin and end plot time */ /*#ifdef DLL*/ /* if (nrepetitions == 1) { if (snow++ == GiveTimeCount) { snow = 0; Sleep(0); } } */ /* check to see if patient has died, if so end simulation */ if ((Dead == True) || (EndSim == True)) { release_mem(SIM); return; } /* #endif */ #ifdef TEST if ( nrepetitions == 1 ) { if (( t >= 5.0 && t < 5.0 + delta_t ) || ( t >= 10.0 && t < 10.0 + delta_t ) || ( t >= 15.0 && t < 15.0 + delta_t ) || ( t >= 20.0 && t < 20.0 + delta_t ) || ( t >= 25.0 && t < 25.0 + delta_t ) || ( t >= 30.0 && t < 30.0 + delta_t ) || ( t >= 31.0 && t < 31.0 + delta_t ) || ( t >= 32.0 && t < 32.0 + delta_t ) || ( t >= 33.0 && t < 33.0 + delta_t ) || ( t >= 34.0 && t < 34.0 + delta_t ) || ( t >= 35.0 && t < 35.0 + delta_t ) || ( t >= 36.0 && t < 36.0 + delta_t ) || ( t >= 37.0 && t < 37.0 + delta_t ) || ( t >= 38.0 && t < 38.0 + delta_t ) || ( t >= 39.0 && t < 39.0 + delta_t ) || ( t >= 40.0 && t < 40.0 + delta_t ) || ( t >= 41.0 && t < 41.0 + delta_t ) || ( t >= 42.0 && t < 42.0 + delta_t ) || ( t >= 43.0 && t < 43.0 + delta_t ) || ( t >= 44.0 && t < 44.0 + delta_t ) || ( t >= 45.0 && t < 45.0 + delta_t )) { printf("At time %lf cell types = %d systime %d\n",t,active_ntypes,time(&stime)-saitime); } } #endif t = t+delta_t; } #ifdef TEST if ((GuaranteeReset == false) && ( nrepetitions > 1 )) { if ( ntypes > 10 ) { for (iindex =1;iindex<= active_ntypes;iindex++) fprintf(out,"%e ",CN[iindex]); fprintf(out,"\n"); } else { /* for pgf test, get rearranged output including zero cell counts */ for (iindex =1;iindex<= active_ntypes;iindex++) { itype = iindex-1; do { itype++; if ((int)LookUp[iindex].LookUpId == itype ) fprintf(out,"%e ",CN[itype]); else fprintf(out,"%e ",ZERO); } while ((int)LookUp[iindex].LookUpId != itype); } for (iindex = LookUp[active_ntypes].LookUpId+1;iindex<=(int)ntypes ;iindex++) fprintf(out,"%e ",ZERO); fprintf(out,"\n"); } } fclose(out); #endif /*#ifdef DLL*/ /* if patient didn't die and has cells less than diagnosis, then NED event */ if (GuaranteeReset == False) { TotalCells = AllCells(); sprintf(stemp,"%e",TotalCells); /* if(TotalCells < diagnosis_threshold)*/ if (DiagnosedNow == False ) { /*if patient didn't die and has cells less than diagnosis, // then an end of followup with NED event */ AddToEventQ((t-delta_t),EFUNEDEVENT,stemp,".","."); } else { /* Patient didn't die, and had a diagnosable tumor // so add an end of follow up event with tumor */ AddToEventQ((t - delta_t),EFUTUMEVENT,stemp,".","."); } /*//if a CR or PR is pending, but the simulation ended before it couldn't //be checked after the TumorExamInterval is up, post it now.*/ if (CompleteResponse.checked == True) AddToEventQ(CompleteResponse.time,CREVENT,".",".","."); else if (PartialResponse.checked == True) AddToEventQ(PartialResponse.time,RESPONSEEVENT,".",".","."); } /* // else // AddToEventQ((t - delta_t),NORESPONSEEVENT,".",".",".");*/ /*#endif */ SimRunning = False; release_mem(SIM); return; }