Prev: plotting question
Next: pid tuning
From: MZ AM on 5 May 2010 12:50 Hi, Should a nonlinear constraint function of an optimization function, such as fmincon, have only one input argument. I ran into an error as I was trying to add more input arguments in the "confun" function in the first example of http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brn4nh7.html Of course I made some changes in all the functions in this example to correctly implement the other input arguments. Any opinion is appreciated. Thanks
From: Steven Lord on 5 May 2010 12:57 "MZ AM" <mazamin(a)yahoo.com> wrote in message news:hrs7ke$8sv$1(a)fred.mathworks.com... > Hi, > > Should a nonlinear constraint function of an optimization function, such > as fmincon, have only one input argument. That depends -- what does the help and/or documentation for the function indicate the signature of the nonlinear constraint function should be? For FMINCON: http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/fmincon.html "[Nonlcon is the] function that computes the nonlinear inequality constraints c(x)? 0 and the nonlinear equality constraints ceq(x) = 0. nonlcon accepts a vector x and returns the two vectors c and ceq." That indicates that yes, the nonlinear constraint function should accept one input argument, the vector x, and return two outputs. > I ran into an error as I was trying to add more input arguments in the > "confun" function in the first example of > > http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brn4nh7.html > > Of course I made some changes in all the functions in this example to > correctly implement the other input arguments. > > Any opinion is appreciated. Use the technique described here: http://www.mathworks.com/support/solutions/en/data/1-19HM6/index.html?solution=1-19HM6 -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Alan Weiss on 5 May 2010 12:57 On 5/5/2010 12:50 PM, MZ AM wrote: > Hi, > > Should a nonlinear constraint function of an optimization function, such > as fmincon, have only one input argument. I ran into an error as I was > trying to add more input arguments in the "confun" function in the first > example of > > http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brn4nh7.html > > Of course I made some changes in all the functions in this example to > correctly implement the other input arguments. > > Any opinion is appreciated. > > Thanks If your question was "Should the input argument x be the same for the objective function and the nonlinear constraint functions" then the answer is yes. Optimization functions expect your current point x to be the same for both constraints and objective. You can pass extra parameters if you like to either constraints or the objective function: http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html Alan Weiss MATLAB mathematical toolbox documentation
|
Pages: 1 Prev: plotting question Next: pid tuning |