e04lb {NAGFWrappers} | R Documentation |

e04lb 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 and second 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).

e04lb(funct, hess, monit, ibound, bl, bu, x, lh, iw, w, n=nrow(bl), iprint=1, maxcal=50, eta=if(n ==1) 0.0 else 0.9, xtol=0.0, stepmx=100000.0 )

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

`hess` |
void function h must calculate the second derivatives of |

`monit` |
void function If |

`ibound` |
integer Specifies 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 e04lb. 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 |

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

`xtol` |
double: The accuracy in |

`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 E04LBF.

`bl` |
double array The lower bounds actually used by e04lb, e.g., if |

`bu` |
double array The upper bounds actually used by e04lb, 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/e04lbf.pdf

e04lb_funct = function(iflag, n, xc, fc, gc) { gc <- as.matrix(mat.or.vec(n, 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)) } e04lb_hess = function(iflag, n, xc, fhesl, lh, fhesd) { fhesl <- as.matrix(mat.or.vec(lh, 1)) fhesd[1] <- 2 + 120 * (xc[1] - xc[4])^2 fhesd[2] <- 200 + 12 * (xc[2] - 2 * xc[3])^2 fhesd[3] <- 10 + 48 * (xc[2] - 2 * xc[3])^2 fhesd[4] <- 10 + 120 * (xc[1] - xc[4])^2 fhesl[1] <- 20 fhesl[2] <- 0 fhesl[3] <- -24 * (xc[2] - 2 * xc[3])^2 fhesl[4] <- -120 * (xc[1] - xc[4])^2 fhesl[5] <- 0 fhesl[6] <- -10 list(IFLAG = iflag, FHESL = as.matrix(fhesl), FHESD = as.matrix(fhesd)) } e04lb_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() } 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)) e04lb(e04lb_funct, e04lb_hess, e04lb_monit, ibound, bl, bu, x, lh, iw, w)

[Package *NAGFWrappers* version 24.0 Index]