Error for multiple Constraints with fmincon
1 view (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!