// Learn more about F# at http://fsharp.net open System open NagLibrary let n: int = 4;; let nclin: int = 1;; let ncnln: int = 2;; let a = Array2D.create 1 4 1.0;; let bl = [| 1.0; 1.0; 1.0; 1.0; -1.0e25; -1.0e25; 25.0|];; let bu = [| 5.0; 5.0; 5.0; 5.0; 20.0;40.0; 1.0e25 |];; let x =[|1.0; 5.0; 5.0; 1.0|];; let c = Array.create ncnln 0.0;; let cjac = Array2D.create ncnln n 0.0;; let clamda = Array.create 7 0.0;; let objgrd = Array.create n 0.0;; let r = Array2D.create n n 0.0;; let work = Array.create nclin 0.0;; let istate = Array.create 7 0;; let ifail = ref 0;; let objf = ref 0.0;; let iter = ref 0;; let one: double = 1.00e0;; let two: double = 2.00e0;; let options = new E04.e04ucOptions(); options.Set("List");; options.Set("Print level = 10");; let objfunE04UCA = new E04.E04UC_OBJFUN(fun (mode:byref) (n) (x) (objf: byref) (objgrd) (nstate) -> if ((mode = 0) || (mode = 2)) then objf <- x.[0] * x.[3] * (x.[0] + x.[1] + x.[2]) + x.[2] if ((mode = 1) || (mode = 2) ) then objgrd.[0] <- x.[3] * (two * x.[0] + x.[1] + x.[2]) objgrd.[1] <- x.[0] * x.[3] objgrd.[2] <- x.[0] * x.[3] + one objgrd.[3] <- x.[0] * (x.[0] + x.[1] + x.[2]));; let confunE04UCA = new E04.E04UC_CONFUN(fun (mode:byref) (ncnln) (n) (needc) (x) (c) (cjac) (nstate) -> if (nstate = 1) then for j = 1 to n-1 do for i = 1 to ncnln-1 do cjac.[i - 1, j - 1] <- 0.0; done done if (needc.[0] > 0) then if (mode = 0 || mode = 2) then c.[0] <- x.[0]**2.0 + x.[1]**2.0 + x.[2]**2.0 + x.[3]**2.0 if (mode = 1 || mode = 2) then cjac.[0, 0] <- two * x.[0] cjac.[0, 1] <- two * x.[1] cjac.[0, 2] <- two * x.[2] cjac.[0, 3] <- two * x.[3] if (needc.[1] > 0) then if (mode = 0 || mode = 2) then c.[1] <- x.[0] * x.[1] * x.[2] * x.[3] if (mode = 1 || mode = 2) then cjac.[1, 0] <- x.[1] * x.[2] * x.[3] cjac.[1, 1] <- x.[0] * x.[2] * x.[3] cjac.[1, 2] <- x.[0] * x.[1] * x.[3] cjac.[1, 3] <- x.[0] * x.[1] * x.[2]);; E04.e04uc(n,nclin,ncnln, a, bl, bu, confunE04UCA, objfunE04UCA, iter, istate, c, cjac, clamda, objf , objgrd, r, x, options, ifail);;