Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
americocunhajr authored Sep 17, 2024
1 parent b816214 commit 65d76d8
Show file tree
Hide file tree
Showing 22 changed files with 2,704 additions and 60 deletions.
29 changes: 22 additions & 7 deletions CROSS-OPT-1.0/Main_Truss10_MassMin_FrequencyBounds_BoxPlot.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
% Americo Cunha Jr
%
% Originally programmed in: Jun 25, 2024
% Last updated in: Aug 22, 2024
% Last updated in: Sep 15, 2024
% -----------------------------------------------------------------
%  Mass minimization with frequency constraints for a 10 bars
% truss structure. Box plot calculation for CE, GA and SQP.
Expand Down Expand Up @@ -65,8 +65,8 @@
MyTruss.Ndofs = 2*MyTruss.Nnodes; % # of DoFs

% objective and constraint functions
fun = @(x)TrussMass (x,MyTruss);
nonlcon = @(x)TrussFrequencyBounds(x,MyTruss);
fun = @(x)TrussMass10 (x,MyTruss);
nonlcon = @(x)TrussFrequencyBounds10(x,MyTruss);

% number of variables
Nvars = 10;
Expand All @@ -80,7 +80,7 @@
sigma0 = 5*(ub-lb);

% number of box plot samples
Nbp = 5;
Nbp = 64;

% boxplot for CE
% ------------------------------------------------------------------
Expand Down Expand Up @@ -176,10 +176,10 @@
% optional parameters
opt = optimoptions('fmincon','Display','off','Algorithm','sqp');

% random initial guess
x0 = lb + (ub-lb).*rand(1,Nvars);

while t < Nbp
% random initial guess
x0 = lb + (ub-lb).*rand(1,Nvars);

% SPQ solver
[Xopt,Fopt,ExitFlag,SQPstr] = fmincon(fun,x0,[],[],[],[],lb,ub,nonlcon,opt);

Expand All @@ -199,6 +199,21 @@
% ------------------------------------------------------------------


% save simulation results
% -----------------------------------------------------------
tic
disp(' ')
disp(' --- saving simulation results --- ');
disp(' ');
disp(' ... ');
disp(' ');

save('Truss10_MassMin_FrequencyBounds_BoxPlot.mat');

toc
% -----------------------------------------------------------


% post processing
% ------------------------------------------------------------------
disp(' ')
Expand Down
4 changes: 2 additions & 2 deletions CROSS-OPT-1.0/Main_Truss10_MassMin_FrequencyBounds_CE.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
MyTruss.Ndofs = 2*MyTruss.Nnodes; % # of DoFs

% objective and constraint functions
fun = @(x)TrussMass (x,MyTruss);
nonlcon = @(x)TrussFrequencyBounds(x,MyTruss);
fun = @(x)TrussMass10 (x,MyTruss);
nonlcon = @(x)TrussFrequencyBounds10(x,MyTruss);

% number of variables
Nvars = 10;
Expand Down
4 changes: 2 additions & 2 deletions CROSS-OPT-1.0/Main_Truss10_MassMin_FrequencyBounds_GA.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
MyTruss.Ndofs = 2*MyTruss.Nnodes; % # of DoFs

% objective and constraint functions
fun = @(x)TrussMass (x,MyTruss);
nonlcon = @(x)TrussFrequencyBounds(x,MyTruss);
fun = @(x)TrussMass10 (x,MyTruss);
nonlcon = @(x)TrussFrequencyBounds10(x,MyTruss);

% number of variables
Nvars = 10;
Expand Down
4 changes: 2 additions & 2 deletions CROSS-OPT-1.0/Main_Truss10_MassMin_FrequencyBounds_SQP.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
MyTruss.Ndofs = 2*MyTruss.Nnodes; % # of DoFs

% objective and constraint functions
fun = @(x)TrussMass (x,MyTruss);
nonlcon = @(x)TrussFrequencyBounds(x,MyTruss);
fun = @(x)TrussMass10 (x,MyTruss);
nonlcon = @(x)TrussFrequencyBounds10(x,MyTruss);

% number of variables
Nvars = 10;
Expand Down
31 changes: 23 additions & 8 deletions CROSS-OPT-1.0/Main_Truss10_MassMin_YieldStress_BoxPlot.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
MyTruss.Ndofs = 2*MyTruss.Nnodes; % # of DoFs

% objective and constraint functions
fun = @(x)TrussMass (x,MyTruss);
fun = @(x)TrussMass10 (x,MyTruss);
nonlcon = @(x)TrussYieldStress(x,MyTruss);

% number of variables
Expand All @@ -88,7 +88,7 @@
sigma0 = 5*(ub-lb);

% number of box plot samples
Nbp = 125;
Nbp = 64;

% boxplot for CE
% ------------------------------------------------------------------
Expand Down Expand Up @@ -184,16 +184,16 @@
% optional parameters
opt = optimoptions('fmincon','Display','off','Algorithm','sqp');

% random initial guess
x0 = lb + (ub-lb).*rand(1,Nvars);

while t < Nbp
% random initial guess
x0 = lb + (ub-lb).*rand(1,Nvars);

% SPQ solver
[Xopt,Fopt,ExitFlag,SQPstr] = fmincon(fun,x0,[],[],[],[],lb,ub,nonlcon,opt);

% update solver running counter
Nrun_SQP = Nrun_SQP + 1;

% check constraint violation
if max(nonlcon(Xopt)) <= opt.TolCon
t = t + 1;
Expand All @@ -207,6 +207,21 @@
% ------------------------------------------------------------------


% save simulation results
% ------------------------------------------------------------------
tic
disp(' ')
disp(' --- saving simulation results --- ');
disp(' ');
disp(' ... ');
disp(' ');

save('Truss10_MassMin_YieldStress_BoxPlot.mat');

toc
% ------------------------------------------------------------------


% post processing
% ------------------------------------------------------------------
disp(' ')
Expand All @@ -218,7 +233,7 @@
figure
x = [Fopt_SQP Fopt_GA Fopt_CE];
boxplot(x,'Notch','off','Labels',{'SQP','GA','CE'});
ylabel('Truss Mass (kg)','FontSize',20,'FontName', 'Helvetica')
ylabel('Truss Mass (kg)','FontSize',20,'FontName', 'Helvetica')
title("Number samples: " + Nbp, 'FontSize',20,'FontName', 'Helvetica')
set(gca, 'FontName', 'Helvetica');
set(gca, 'FontSize', 18);
Expand Down
2 changes: 1 addition & 1 deletion CROSS-OPT-1.0/Main_Truss10_MassMin_YieldStress_CE.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
MyTruss.Ndofs = 2*MyTruss.Nnodes; % # of DoFs

% objective and constraint functions
fun = @(x)TrussMass (x,MyTruss);
fun = @(x)TrussMass10 (x,MyTruss);
nonlcon = @(x)TrussYieldStress(x,MyTruss);

% number of variables
Expand Down
2 changes: 1 addition & 1 deletion CROSS-OPT-1.0/Main_Truss10_MassMin_YieldStress_GA.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
MyTruss.Ndofs = 2*MyTruss.Nnodes; % # of DoFs

% objective and constraint functions
fun = @(x)TrussMass (x,MyTruss);
fun = @(x)TrussMass10 (x,MyTruss);
nonlcon = @(x)TrussYieldStress(x,MyTruss);

% number of variables
Expand Down
2 changes: 1 addition & 1 deletion CROSS-OPT-1.0/Main_Truss10_MassMin_YieldStress_SQP.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
MyTruss.Ndofs = 2*MyTruss.Nnodes; % # of DoFs

% objective and constraint functions
fun = @(x)TrussMass (x,MyTruss);
fun = @(x)TrussMass10 (x,MyTruss);
nonlcon = @(x)TrussYieldStress(x,MyTruss);

% number of variables
Expand Down
Loading

0 comments on commit 65d76d8

Please sign in to comment.