e04kd {NAGFWrappers} | R Documentation |

e04kd is a comprehensive modified Newton algorithm for finding:

- an unconstrained minimum of a function of several variables;

- a minimum of a function of several variables subject to fixed upper and/or lower bounds on the variables.

First derivatives are required. The function is intended for functions which have continuous first and second derivatives (although it will usually work even if the derivatives have occasional discontinuities).

e04kd(funct, monit, eta, ibound, bl, bu, x, lh, iw, w, n=nrow(bl), iprint=1, maxcal=50, xtol=0.0, delta=0.0, stepmx=100000.0)

`funct` |
void function funct must evaluate the function |

`monit` |
void function If |

`eta` |
double Every iteration of e04kd involves a linear minimization (i.e., minimization
of |

`ibound` |
integer Indicates whether the problem is unconstrained or bounded. If there are bounds on the variables, ibound can be used to indicate whether the facility for dealing with bounds of special forms is to be used. It must be set to one of the following values: ibound = 0: If the variables are bounded and you are
supplying all the ibound = 1: If the problem is unconstrained. ibound = 2: If the variables are bounded, but all the
bounds are of the form ibound = 3: If all the variables are bounded, and ibound = 4: If the problem is unconstrained. (The |

`bl` |
double array The fixed lower bounds |

`bu` |
double array The fixed upper bounds |

`x` |
double array x(j) must be set to a guess at the |

`lh` |
integer |

`iw` |
integer array |

`w` |
double array |

`n` |
integer: The number |

`iprint` |
integer: The frequency with which monit is to be called. iprint > 0: monit is called once every iprint iterations and just before exit from e04kd. iprint = 0: monit is just called at the final point. iprint < 0: monit is not called at all. |

`maxcal` |
integer: The maximum permitted number of evaluations of |

`xtol` |
double: The accuracy in |

`delta` |
double: The differencing interval to be used for approximating the second derivatives
of |

`stepmx` |
double: An estimate of the Euclidean distance between the solution and the starting point supplied by you. (For maximum efficiency a slight overestimate is preferable.) |

R interface to the NAG Fortran routine E04KDF.

`bl` |
double array The lower bounds actually used by e04kd, e.g., If |

`bu` |
double array The upper bounds actually used by e04kd, e.g., if |

`x` |
double array The final point |

`hesl` |
double array During the determination of a direction |

`hesd` |
double array During the determination of a direction |

`istate` |
integer array Information about which variables are currently on their bounds and which
are free. If - equal to - equal to - equal to - positive, |

`f` |
double The function value at the final point given in x. |

`g` |
double array The first derivative vector corresponding to the final point given in x. The components of g corresponding to free variables should normally be close to zero. |

NAG

http://www.nag.co.uk/numeric/FL/nagdoc_fl23/pdf/E04/e04kdf.pdf

e04kd_funct = function(iflag, n, xc, fc, gc) { gc <- as.matrix(mat.or.vec(n, 1)) fc <- 0 if (iflag != 1) { fc <- (xc[1] + 10 * xc[2])^2 + 5 * (xc[3] - xc[4])^2 + (xc[2] - 2 * xc[3])^4 + 10 * (xc[1] - xc[4])^4 } gc[1] <- 2 * (xc[1] + 10 * xc[2]) + 40 * (xc[1] - xc[4])^3 gc[2] <- 20 * (xc[1] + 10 * xc[2]) + 4 * (xc[2] - 2 * xc[3])^3 gc[3] <- 10 * (xc[3] - xc[4]) - 8 * (xc[2] - 2 * xc[3])^3 gc[4] <- 10 * (xc[4] - xc[3]) - 40 * (xc[1] - xc[4])^3 list(IFLAG = iflag, FC = fc, GC = as.matrix(gc)) } e04kd_monit = function(n, xc, fc, gc, istate, gpjnrm, cond, posdef, niter, nf) { sprintf("\n Itn Fn evals Fn value Norm of proj gradient\n", "\n") sprintf(" %3d %5d %20.4f %20.4f\n", niter, nf, fc, gpjnrm, "\n") sprintf("\n J XJ GJ Status\n", "\n") for (j in c(1:n)) { isj <- istate[j] if (isj > 0) { sprintf("%2d %16.4f%20.4f %s\n", j, xc, j, gc, j, " Free", "\n") } else if (isj == -1) { } else if (isj == -2) { } else if (isj == -3) { } } if (cond != 0) { if (cond > 1e+06) { sprintf("\nEstimated condition number of projected Hessian is more than 1.0e+6\n", "\n") } else { sprintf("\nEstimated condition number of projected Hessian = %10.2f\n", cond, "\n") } if (!posdef) { sprintf("\nProjected Hessian matrix is not positive definite\n", "\n") } } list() } eta <- 0.5 ibound <- 0 bl <- matrix(c(1, -2, -1e+06, 1), nrow = 4, ncol = 1, byrow = TRUE) bu <- matrix(c(3, 0, 1e+06, 3), nrow = 4, ncol = 1, byrow = TRUE) x <- matrix(c(3, -1, 0, 1), nrow = 4, ncol = 1, byrow = TRUE) lh <- 6 iw <- matrix(c(0, 0), nrow = 2, ncol = 1, byrow = TRUE) w <- as.matrix(mat.or.vec(34, 1)) e04kd(e04kd_funct, e04kd_monit, eta, ibound, bl, bu, x, lh, iw, w)

[Package *NAGFWrappers* version 24.0 Index]