Hello Erik and Ravi, I am curious if Erick or Ravi have a solution to Erick's question.
I have a similar problem. I wish to use auglag to solve a nonlinear optimization problem. The cost function, grad function, and constraints are all function of some parameters that are dependent upon the system I wish to analyze. For any given system, these parameters are fixed, e.g. x,y,z are parameters that are problem or system dependent. The variable f is a vector that I wish to find such that my cost function is maximized or minimized. I have used auglag without any issues as follows. At first, I called auglag without trying to provide arguments for x,y,z, but rather only the initial parameter fo. My functions (fn, gr, hin, heq, etc) were all defined in the format of: foo<-function(f){ # code... } The parameters x,z,z were obtained from what I understand to be the global environment. I was NOT calling 'auglag' from a function, but simply from the command line in 'Rkward'. In other words, parameters x,y,z were calculated outside of any functions but were utilized in the function fn,gr,hin,heq,etc. Now, I have constructed a function, foobar, that utilizes inputs a,b,c that are used to calculate parameters x,y,z. And within foobar, I attempt to call 'auglag' to find an optimum solution. For example: foobar<-function(a,b,c){ # code to calculate x,y,z as function of a,b,c ans<-auglag(par=fo,fn=foo1,gr=foo2,hin=foo3,heq=foo4) return(ans) } However, auglag appears to utilize x,y,z from the global environment rather than my local variables x,y,z inside foobar. I have attempted to construct functions fn,gr,hin,heq,... by several ways without success. For example foo<-function(f,x,y,z){code...}, ans<-auglag(par=fo,fn=foo1,gr=foo2,hin=foo3,heq=foo4), or ans<-auglag(par=c(fo,x,y,z),fn=foo1(,gr=foo2,hin=foo3,heq=foo4) and I tried foo<-function(f,...){code...}, ans<-auglag(par=fo,fn=foo1,gr=foo2,hin=foo3,heq=foo4), or foo<-function(f,...){code...}, ans<-auglag(par=c(fo,x,y,z),fn=foo1(,gr=foo2,hin=foo3,heq=foo4) All failed. Is it simply not feasible to use 'auglag' in this manner? Or, have I missed how to pass arguments to auglag, which in turn can pass these arguments to fn,gr,hin,heq,... Any help would be greatly appreciated. Regards, Tim -- View this message in context: http://r.789695.n4.nabble.com/Trouble-with-Optimization-in-Alabama-Package-tp2548801p3610402.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.