Error for multiple Constraints with fmincon

1 回表示 (過去 30 日間)
Leon Stolp
Leon Stolp 2020 年 5 月 14 日
コメント済み: Leon Stolp 2020 年 5 月 15 日
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 Center および File ExchangeSolver 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