Error for multiple Constraints with fmincon
조회 수: 4 (최근 30일)
이전 댓글 표시
Hey everybody.
I encountered a problem and can't figure out a solution or even the exact reason for it.
I'm setting up a optimization using fmincon. I want to have one equality and one inequality constraints. I had it already working and made some changes to the constraints. Now I can't make it work again.
these are my constraints:
%Constraint function
function [c,ceq] = conRT(in, V, depl, Fsum, Screws, Z, A_BT, C_Stern, h_B)
myHoltropObject=Holtrop(V, depl, Fsum, Screws, Z, A_BT, C_Stern, h_B);
Lwl = in(1);
B = in(2);
T = in(3);
C_B = myHoltropObject.calcC_B(in);
GM = myHoltropObject.calcGM(in);
deplVorh = Lwl*B*T*C_B;
ceq = depl-deplVorh;
c = GM - 0.4; %<-- without this constraint everything is working fine.
end
here is how I call the constraints:
constraintA = @(in) conRT(in, V, depl, Fsum, Screws, Z, A_BT, C_Stern, h_B);
problem = createOptimProblem('fmincon', ...
'objective',objectiveA, ...
'x0',x0, ...
'lb',lb, ...
'ub',ub, ...
'nonlcon', constraintA, ...
'options',options);
I get this Error:

I know what this Error means. But I just can't get my head around why it suddenly popped up after it already worked. And also I don't know where I created that error.
Any advice will be geratly appreciated!
댓글 수: 2
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Least Squares에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!