maximizing a function with a nonlinear constraint using fmincon
Mostra commenti meno recenti
Dear all,
I have a function 'fun' which I want to maximize with respect to four unknowns: x(1) x(2) x(3) and x(4)
under the constraint
exp(x(2))+exp(x(3))<0.99
So, I set up something like that
function [c,ceq] = mycon(x)
c= exp(x(2))+exp(x(3))-0.99;
ceq=[];
end
x0=[a ;b c; d] % the initial value
options=optimset( 'display','off'); % mainly use this
[xx,fval,exitflag,output,lambda,grad,HH]=fmincon('fun',x0,...
[],[],[],[],[],[],@mycon, options);
But I get this warning
Error using mycon
Too many input arguments.
Error in fmincon (line 622)
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});
Error in dokimi_3 (line 96)
[xx,fval,exitflag,output,lambda,grad,HH]=fmincon('fun',x0,...
Caused by:
Failure in initial nonlinear constraint function evaluation. FMINCON cannot continue.
Any ideas what is wrong?
Thank you
3 Commenti
ektor
il 21 Gen 2018
Walter Roberson
il 21 Gen 2018
Is it possible that in your actual code that you passed something to fmincon after the options argument?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Write Constraints in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!