Is the objective smooth (continuous and differentiable)? If it's not, that could be the reason why fminsearch works better - unlike fminsearch, fmincon is meant for smooth problems.
Lukas Barchewitz wrote: > Thanks John! > > I made it run and introduced your help. Unfortunately, fmincon is not > converging at the same x when using instead fminsearch where an > unconstrained problem can be introduded. There is a clear optimum if I > introduce the first paramter (parable), so I used fmincon to assess the > quality of the fmincon and introduce more variables, which will lead to > a real optimization problem because there is no obvious maximum for the > function. The function is highly non-linear and cannot be shown in one > line only. > > Why are results from fmincon and fminsearch not the same? > > I tried to introduce one more varibles to fmincon > > by x0=[0.7, 15]; > lb=[0.4; 10]; > ub=[0.8; 25]; is this right when I try to > > set 0.4<x(1)<0.8 and 10<x(2)<25? Yes, that's right.
> > and the x-vector is practically not moving from the starting conditions > (I have tried is, for different starting conditions) If I check it by > hand by changing the first variable and then the ohter I can find an > optimum at x(1)=0.67 and x(2)=25; > > what's wrong? > > Thanks > Lukas > > John D'Errico schrieb: > >> In article <email@example.com>, >> Lukas Barchewitz <firstname.lastname@example.org> wrote: >> >> >>> Hi! >>> >>> I have got a nonlinear function to be minimized. It works all well >>> with the fminsearch function but fmincon does not converge at the >>> same x value and I cannot introduce my options into the command line. >>> At this point I want to try it with one variable where 0.4<x<0.8 to >>> the function etaisopt, where x is constrained. >>> >>> A=[-1; 1]; >>> b=[0.4; 0.8]; >>> >>> A=; >>> b=[0.75]; >>> >>> x0=0.7; >>> Aeq=; >>> beq=; >>> lb=; >>> ub=; >>> nonlcon=; >>> options = >>> optimset('Display','iter','MaxFunEvals',50,'MaxIter',20,'MaxSQPiter',10,'GradO >>> >>> bj','on'); >>> [x,fval,exitflag,output,lambda,grad] = >>> fmincon(@etaisopt,x0,A,b,Aeq,beq,lb,ub,nonlcon,options) >>> >>> It does not work prompting >>> ??? Error using ==> fmincon >>> FMINCON cannot continue because user supplied objective function >>> failed with the following error: >>> One or more output arguments not assigned during call to >>> 'C:\Dokumente und Einstellungen\barchewitz\Eigene >>> Dateien\MatLab\Kennfeldregression\K29\etaisopt.m (etaisopt)'. >>> >>> Error in ==> etaisoptscript at 20 >>> [x,fval] = fmincon(@etaisopt,x0,A,b,Aeq,beq,lb,ub,nonlcon,options) >>> >>> what has not been assigned?? >>> I would like to use fmincon because I want introduce 4 more variables >>> which are constrained. >>> >>> Who can help >>> Lukas >> >> >> >> You don't include the call to etaisopt, so its hard to >> tell what is wrong. Apparently you have not defined >> the output argument to etaisopt. >> >> I will comment that if you have only bound constraints, >> then you do not need to use A and B, which allow for >> general inequality constraints. You only need to use >> LB and UB. An advantage of use of the explicit bound >> constraints in LB and UB is the largescale optimizer >> now becomes an alternative. >> >> I'll also note that a single parameter optimization with >> bound constraints will be better handled by fminbnd. It >> sounds like you will be adding unknowns, so fmincon is >> necessary then. >> >> HTH, >> John D'Errico >> >> >