Optimisation problem not solving for maximum values

5 Ansichten (letzte 30 Tage)
Maximilian
Maximilian am 6 Okt. 2022
Bearbeitet: Matt J am 6 Okt. 2022
I have made the code shown below to find the maximum d/t and kl/r values possible within specific constraints given. I would expect that d would close to 1000 and t close to 35. However in the solution it is giving is d=2 and t=1. Any ideas how I can fix this? When giving these values it is also throwing up the message :
Solving problem using ga.
Optimization terminated: average change in the penalty fitness value less than options.FunctionTolerance
but constraints are not satisfied.
Any help would be greatly apreciated thank you.
%% Clear workspace
clear;
clc;
%% Input Variables
l=14830; % Member length (mm)
k=1; % Effective length factor
d0.d=1000; %initial guess
d0.t=30; %initial guess
%% Equations
prob = optimproblem('ObjectiveSense','maximize');
d = optimvar('d', 1,'Type','integer');
t = optimvar('t',1,'Type','integer');
%% Variables
din=d-(2*t); % Member inner diameter
a=3.1415/4 * ((d^2)-(din^2)); % Member cross sectional area
i=3.1415/64 * ((d^4)-(din^4)); % Member second moment of inertia
r=(a/i)^0.5; % Member radius of gyration
prob.Objective= (d/t) + ((k*l)/r);
%% Constraints
cons1 = d>=1;
cons2 = d<=3000;
cons3 = t>=1;
cons4 = t<=100;
cons5 = d/t<=30;
cons6 = d/t>=1;
cons7 = k*l/r<=40;
cons8 = k*l/r>=1;
prob.Constraints.cons1 = cons1;
prob.Constraints.cons2 = cons2;
prob.Constraints.cons3 = cons3;
prob.Constraints.cons4 = cons4;
prob.Constraints.cons5 = cons5;
prob.Constraints.cons6 = cons6;
prob.Constraints.cons7 = cons7;
prob.Constraints.cons8 = cons8;
show(prob)
sol = solve(prob,d0)
sol.d
sol.t

Antworten (1)

Matt J
Matt J am 6 Okt. 2022
Bearbeitet: Matt J am 6 Okt. 2022
We can easily do a discrete sweep over the allowable d and t values to see where the feasible region is, approximately. Based on the sweep below, it does not appear that there are any feasible (d,t) pairs.
l=14830; % Member length (mm)
k=1; % Effective length factor
[d,t]=meshgrid(1:0.5:3000,1:0.5:100);
din=d-(2*t); % Member inner diameter
a=3.1415/4 * ((d.^2)-(din.^2)); % Member cross sectional area
i=3.1415/64 * ((d.^4)-(din.^4)); % Member second moment of inertia
r=(a./i).^0.5; % Member radius of gyration
feas=true(size(d)); %feasibility map
expr=d./t;
feas( expr>30 | expr<1 | ~isfinite(expr) )=false;
expr=k*l./r;
feas( expr>40 | expr<1 | ~isfinite(expr) )=false;
[d,t]=find(feas) %search for feasible d,t
d = 0×1 empty double column vector t = 0×1 empty double column vector
  1 Kommentar
Maximilian
Maximilian am 6 Okt. 2022
Right ok thank you for your help. You are completely right. I have just found the mistake and it is in one of my variables. Sorry to have wasted your time. I really appreciate the help.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by