Depending on the optimization method you select, analytical first- and second-order derivatives are computed automatically. Derivatives can still be supplied using the DER.parm syntax. These DER.parm derivatives are not verified by the differentiator. If any needed derivatives are not supplied, they are computed and added to the programming statements. To view the computed derivatives, use the LISTDER or LIST option.
The following model is solved using Newton’s method. Analytical first- and second-order derivatives are automatically computed. The compiled program code is shown in Figure 67.6.
proc nlin data=Enzyme method=newton list; parms x1=4 x2=2; model Velocity = x1 * exp (x2 * Concentration); run;
Figure 67.6: Model and Derivative Code Output
Listing of Compiled Program Code | ||
---|---|---|
Stmt | Line:Col | Statement as Parsed |
1 | 1593:4 | MODEL.Velocity = x1 * EXP(x2 * Concentration); |
1 | 1593:4 | @MODEL.Velocity/@x1 = EXP(x2 * Concentration); |
1 | 1593:4 | @MODEL.Velocity/@x2 = x1 * Concentration * EXP(x2 * Concentration); |
1 | 1593:4 | @@MODEL.Velocity/@x1/@x2 = Concentration * EXP(x2 * Concentration); |
1 | 1593:4 | @@MODEL.Velocity/@x2/@x1 = Concentration * EXP(x2 * Concentration); |
1 | 1593:4 | @@MODEL.Velocity/@x2/@x2 = x1 * Concentration * Concentration * EXP(x2 * Concentration); |
Note that all the derivatives require the evaluation of EXP(X2 * Concentration
). The actual machine-level code is displayed if you specify the LISTCODE option, as in the following statements:
proc nlin data=Enzyme method=newton listcode; parms x1=4 x2=2; model Velocity = x1 * exp (x2 * Concentration); run;
Note that, in the generated code, only one exponentiation is performed (Figure 67.7). The generated code reuses previous operations to be more efficient.
Figure 67.7: LISTCODE Output
Code Listing | ||
---|---|---|
1 Stmt MODEL | line 1600 column 4. (1) arg=MODEL.Velocity argsave=MODEL.Velocity | |
Source Text: | model Velocity = x1 * exp (x2 * Concentration); | |
Oper * | at 1600:34 (30,0,2). | * : _temp1 <- x2 Concentration |
Oper EXP | at 1600:30 (103,0,1). | EXP : _temp2 <- _temp1 |
Oper * | at 1600:24 (30,0,2). | * : MODEL.Velocity <- x1 _temp2 |
Oper eeocf | at 1600:24 (18,0,1). | eeocf : _DER_ <- _DER_ |
Oper = | at 1600:24 (1,0,1). | = : @MODEL.Velocity/@x1 <- _temp2 |
Oper * | at 1600:30 (30,0,2). | * : @1dt1_1 <- Concentration _temp2 |
Oper * | at 1600:24 (30,0,2). | * : @MODEL.Velocity/@x2 <- x1 @1dt1_1 |
Oper = | at 1600:24 (1,0,1). | = : @@MODEL.Velocity/@x1/@x2 <- @1dt1_1 |
Oper = | at 1600:24 (1,0,1). | = : @@MODEL.Velocity/@x2/@x1 <- @1dt1_1 |
Oper * | at 1600:30 (30,0,2). | * : @2dt1_1 <- Concentration @1dt1_1 |
Oper * | at 1600:24 (30,0,2). | * : @@MODEL.Velocity/@x2/@x2 <- x1 @2dt1_1 |