Error for multiple Constraints with fmincon

1 次查看(过去 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 个评论
Ameer Hamza
Ameer Hamza 2020-5-14
Can you share other functions and variables necessary to run this code?
Leon Stolp
Leon Stolp 2020-5-15
I already worked this out. The Problem was that the variable "GM" is a talbe that uses integers but was given a decimal as a input.
Thanks for your Time, anyways!

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by