Error in Genetic Algorithm: Input arguments to function include colon operator. To input the colon character, use ':' instead.
Afficher commentaires plus anciens
I'm trying to run GA for a structural problem and I'm ending up with the error:
"Input arguments to function include colon operator. To input the colon character, use ':' instead."
I'm not able to find where the problem is. This is my code:
function C = fitnessmin(x)
%%constatns
q = 33e4;
H = 5;
g = 9.8;
L = 30;
DI = 2700;
DS = 2700;
ES = 70e9;
FSIbeam = 270e6;
FSSupport = 170e6;
cIbeam = 2.05;
cSupport = 2.05;
%%Mass
%%Ibeams
MIbeam = (2*x(1)*x(3) + (x(2) - 2*x(3))*x(3))*L*DI*x(6);
%%Support
MSupport = x(4)*x(5)*H*DS;
%%function
C = cIbeam*MIbeam + cSupport*MSupport;
end
function [c, ceq] = constraintmin(x)
%%constatns
L = 30;
q = 33e4;
H = 5;
g = 9.8;
DI = 2700;
DS = 2700;
ES = 70e9;
FSIbeam = 270e6;
FSSupport = 170e6;
%%Mass
%%Ibeams
MIbeam = (2*x(1)*x(3) + (x(2) - 2*x(3))*x(3))*L*DI*x(6);
%%Support
MSupport = x(4)*x(5)*H*DS;
%%Equations
MOIIbeam = (((x(2) - 2*x(3))^3)*x(3)/12) + 2*(((x(3)^3)/12) + x(3)*x(1)*((x(2)/2) - (x(3)/2))^2);
SIbeam = (q*((L/2)^2) + MIbeam*(L/4)*g)*(x(2)/2)/(8*MOIIbeam*x(6));
SSIbeam = (MIbeam*g + q*L)/(4*x(6)*(2*x(1)*x(3)) + (x(2) - 2*x(3))*x(3));
Pcrit = (pi*pi)*ES*min(((x(4)^3)*x(5)/12), (x(4)*(x(5)^3)/12));
Papplied = MIbeam*g + q*L/(2);
SSupport = Papplied/(x(4)*x(5))
%%Function
c = [SIbeam - FSIbeam; SSIbeam - FSIbeam; Papplied - Pcrit; SSupport - FSSupport];
ceq = [];
end
clear
clc
objectivefunction = @fitnessmin;
nvars = 6;
lb = [0 0 0 0 0 1];
ub = [1 1 1 1 1 4];
constraintfunction = @constraintmin;
[x,fval] = ga(objectivefunction, nvars, [], [], [], [], lb, ub, [], constraintfunction)
Any help is appreciated. Thanks!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Genetic Algorithm dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!