File: leaving.cc

package info (click to toggle)
simrisc 16.05.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,568 kB
  • sloc: cpp: 6,877; fortran: 665; makefile: 112; ansic: 112; sh: 107
file content (52 lines) | stat: -rw-r--r-- 1,681 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#define XERR
#include "loop.ih"

    // true: the case has died or detected a tumor

bool Loop::leaving(double screeningAge)
{
    bool before1stRound = screeningAge == d_firstRoundAge;

    // A1:
    if (not d_tumor.at(screeningAge))       // no tumor yet at this age
        return 
            d_naturalDeathAge <= screeningAge ?     // case dies naturally
                left(before1stRound ? NATURAL_PRE : NATURAL_DURING, d_deathAge)
            :
                false;                      // nothing happened: perform
                                            // the screening

    // A2: there is a tumor at 'screeningAge'

    if (    // A3
        d_naturalDeathAge < screeningAge and 
        not d_tumor.selfDetectBefore(d_naturalDeathAge)
    )
    {
        d_tumor.characteristicsAt(d_naturalDeathAge);
        d_deathAge = d_naturalDeathAge;
        bool died = d_naturalDeathAge < d_tumor.onset();
        return left(
                    before1stRound ? 
                            died ? NATURAL_PRE    : UNDETECTED_PRE 
                        : 
                            died ? NATURAL_DURING : UNDETECTED_DURING, 
                    d_naturalDeathAge);
    }

    // A4
    if (d_tumor.selfDetectBefore(screeningAge))     // self-detectable?
    {   
        d_tumor.characteristicsAt(d_tumor.selfDetectAge());

        d_tumor.setDeathAge();
        d_caseCost += treatmentCosts(d_tumor.selfDetectAge());

        return before1stRound ?
                    left(SELF_PRE, min(d_naturalDeathAge, d_tumor.deathAge()))
                :
                    intervalCancer();
    }

    return false;                       // perform the screening
}