define nonlcon in fmincon

조회 수: 48 (최근 30일)
Marc Laub
Marc Laub 2022년 5월 19일
편집: Catalytic 2022년 5월 19일
Hey,
I am trying to finc the minimum of a 4 variable equation using fmincon. Looking at the solution fmincon presents and saw that I gorgot to implement some nonlinear side conditions.
Normly those would be implemented via "nonlcon".
So I am not sure since I have noot found anything about tht in a documentary:
-how many nonlcon can I implement? Just 1? I would need 4...
- would those be implemented by
x = fmincon(@myfun,x0,A,b,Aeq,beq,lb,ub,@mycon1,@mycon2,..)
or like
x = fmincon(@myfun,x0,A,b,Aeq,beq,lb,ub,@mycon)
where @mycon is a normal function with 4 outputs like
function [c1,c2,c3,c4] = mycon(x)
c1 = nonlinearfunction1 % Compute nonlinear inequalities at x.
c2
c3
c4
end
Last but not least.
inequalities in the conditions have always the form <=. So if c1 needs to be c1>=0 at x i would just write it as
c1=(theoretical max of nonlinearfunction1)-nonlinearfunction1
?
Many thanks in advance and best regards

채택된 답변

Catalytic
Catalytic 2022년 5월 19일
편집: Catalytic 2022년 5월 19일
function [c, ceq] = mycon(x)
ceq=[];
c(1) = -nonlinearfunction1 % Compute nonlinear inequalities at x.
c(2)
c(3)
c(4)
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by