How can I resolve the "not enough input arguments" error message for the optimization solver?
Afficher commentaires plus anciens
Hello, I am a graduate student doing extra practice with optimizations outside of the classroom with the MATLAB R2018b version. The problem is a simple classic based around the optimization of a two bar truss system. I created the following objective function:
%x(1) represents height and x(2) represents diameter
function f = objectivefunc(x)
density = 0.3;
thickness = 0.15;
base = 60;
force = 66;
modulus = 3.00E4;
f = density*2*pi*x(2)*thickness*length; %Weight Equation
end
I then created the following constraint function:
function [c, ceg] = Constraintfunc(x)
% nonlinear inequality constraints
density = 0.3;
thickness = 0.15;
base = 60;
force = 66;
length = sqrt((base/2)^2 + x(1).^2);
modulus = 3.00E4;
c = (force*length) / (2*thickness*pi*x(2)*x(1)) - 100;
((force*length) / (2*thickness*pi*x(2)*x(1))) - (pi^2*modulus*(x(2))^2+(thickness^2)) / (8*(length)^2);
(force*length^3) / (2*thickness*pi*x(2)*(x(1))^2*modulus) - 0.25;
%nonlinear equality constraints
ceq = [];
end
I define the starting "x" as [30,3] and specify test upper and lower bounds as [50,10] and [5,1] respectively. Upon trying to use the optimization solver I get the error message "Not enough input arguments." I fixed a previous error where I was trying to pass two variables into the solver and thought that would resolve it, but I am still unfortunately stuck. Any help or clarity would be greatly appreciated.
2 commentaires
Matt J
le 1 Sep 2021
You need to show us the code where you invoked the solver.
Alan Weiss
le 2 Sep 2021
Please show your function call such as
[x,fval] = fmincon(@objectivefunc,x0,A,b,Aeq,beq,lb,ub,@Constraintfunc)
and the complete error message, everything in red, copy-pasted.
Alan Weiss
MATLAB mathematical toolbox documentation
Réponses (0)
Catégories
En savoir plus sur Get Started with Optimization Toolbox 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!