Returns f and g for the optim function.
[f,g,ind]=uncprb_optimfun(x,ind,nprob,n,m)
a n-by-1 matrix of doubles, the point where to compute f and g
a n-by-1 matrix of doubles, integer value, a flag indicating what to compute or print
a 1-by-1 matrix of doubles, integer value, the problem number
a 1-by-1 matrix of doubles, integer value, the number of variables, i.e. the size of x
a 1-by-1 matrix of doubles, integer value, the number of functions, i.e. the size of fvec
a 1-by-1 matrix of doubles, the function value
a n-by-1 matrix of doubles, the gradient
This function is designed to be used to make the optim solver optimize the problem #nprob. Indeed, the header of the uncprb_optimfun function is the one required by the optim function.
// Check wrapper on problem #1 nprob = 1; [n,m,x0]=uncprb_getinitf(nprob); [f0,g0,ind]=uncprb_optimfun(x0,4,nprob,n,m); // f0 : 24.2 // g0 : [-215.6 -88] // Make optim optimize the problem #1 nprob = 1; [n,m,x0]=uncprb_getinitf(nprob) [fopt,xopt,gopt]=optim(list(uncprb_optimfun,nprob,n,m),x0,"gc") // Make optim optimize the problem #1 // Get the number of iterations, function and gradient evaluations nprob = 1; [n,m,x0]=uncprb_getinitf(nprob); uncprb_optiminit(); [fopt,xopt,gopt]=optim(list(uncprb_optimfun,nprob,n,m),x0) [foptE,xoptE] = uncprb_getopt(nprob,n,m) goptE = uncprb_getgrdfcn(n,m,xoptE,nprob) funeval = uncprb_optimget() | ![]() | ![]() |