DO WHILE
DOWHILE may be used in all blocks of abbreviated code:
|
|
DOWHILE blocks allow loops in abbreviated code. Previously, they were permitted only in initialization-finalization, simulation, data aver- age, and expectation blocks. See the separate descriptions of these blocks. With NONMEM 7.3, DOWHILE may also be used in data-analytic blocks (i.e., in code that is executed at ICALL=2).
When it is used in data-anlytic code, DOWHILE must be used with a looping variable. Such a variable meets three criteria:
- It is declared as such, e.g. $ABBR DECLARE DOWHILE ILOOP
- It is given a value in the statement immediately before DOWHILE
- It is given a value in the statement immediately before ENDDO.
Usually, the looping variable will be tested in the condition, but this is not necessary.
- DOWHILE blocks may be nested.
- DOWHILE blocks may not include IF/THEN/ENDIF blocks. Only single-statement IF statements are permitted. E.g., IF (condition) statement
-
Subscripted variables may be used within the block. These are variables that have been declared arrays using the $ABBR statement, or subscripted reserved variables such as THETA. Subscripts may be integer expressions using declared integer variables and integer values. E.g.
1 2 3 4 5 6 7 8 9$ABBR DECLARE X(10) $ABBR DECLARE DOWHILE ILOOP ... $PK ILOOP=1 DOWHILE (condition) X(ILOOP)=THETA(ILOOP+1) ILOOP=ILOOP+1 ENDDO -
A DOWHILE loop may compute recursive random variables. These are variables that are modified recursively in a dowhile block and which have eta derivatives. For example,
1 2 3 4 5 6 7TERM=THETA(1)*EXP(ETA(1)) SUM=0 ILOOP=1 DO WHILE(ILOOP<=IMAX) SUM=SUM+TERM ILOOP=ILOOP+1 ENDDO - The DOWHILE recursive variable must be initialized to a non-random variable outside the loop and must appear on both sides of the equal sign only once within the DOWHILE loop: V= … V …
-
The syntax is limited, for example the following are not permitted:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16ILOOP=1 DO WHILE(ILOOP<=IMAX) IF (ILOOP == 1) SUM=0 ; initialization within the loop SUM=SUM+TERM ILOOP=ILOOP+1 ENDDO ILOOP=1 DO WHILE(ILOOP<=IMAX) IF (ILOOP == 1) THEN SUM=0 ; initialization within the loop ELSE ; else statement SUM=SUM+TERM ENDIF ILOOP=ILOOP+1 ENDDO - The looping variable ILOOP may also be set and tested and incremented with different integers than shown. EXAMPLES: Several examples are present in the examples directory: Auto-correlation (See ar1mod.ctl) Auto-correlation with Simulation (See ar1newsim.ctl). Dose Superposition (See sumdosetn.ctl) Summing elements of THETA (See superid3_6.ctl)