Error for multiple Constraints with fmincon

1 vue (au cours des 30 derniers jours)
Leon Stolp
Leon Stolp le 14 Mai 2020
Commenté : Leon Stolp le 15 Mai 2020
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 commentaires
Ameer Hamza
Ameer Hamza le 14 Mai 2020
Can you share other functions and variables necessary to run this code?
Leon Stolp
Leon Stolp le 15 Mai 2020
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!

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by