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 18, 2024
1 parent cdd8e1b commit bb003f9
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 51 deletions.
50 changes: 33 additions & 17 deletions CROSS-OPT-1.0/Main_Truss10_MassMin_FrequencyBounds_BoxPlot.m
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,37 @@
disp(' ------------------- ')
disp(' ')

figure
x = [Fopt_SQP Fopt_GA Fopt_CE];
boxplot(x,'Notch','off','Labels',{'SQP','GA','CE'});
ylabel('Truss Mass (kg)','FontSize',20,'FontName', 'Helvetica')
title("Number samples: " + Nbp, 'FontSize',20,'FontName', 'Helvetica')
set(gca, 'FontName', 'Helvetica');
set(gca, 'FontSize', 18);
box on

figure
x = [Fcount_SQP Fcount_GA Fcount_CE];
boxplot(x,'Notch','off','Labels',{'SQP','GA','CE'});
ylabel('Function Evaluations','FontSize',20,'FontName', 'Helvetica')
title("Number samples: " + Nbp, 'FontSize',20,'FontName', 'Helvetica')
set(gca, 'FontName', 'Helvetica');
set(gca, 'FontSize', 18);
box on
% ..........................................................
graphobj1.gname = 'Truss10_MassMin_FrequencyBounds_BoxPlot_Fopt';
graphobj1.gtitle = 'Objetive Function';
graphobj1.xmin = 'auto';
graphobj1.xmax = 'auto';
graphobj1.ymin = 'auto';
graphobj1.ymax = 'auto';
graphobj1.xlab = [];
graphobj1.ylab = 'Truss Mass (kg)';
graphobj1.leg1 = 'CE';
graphobj1.leg2 = 'GA';
graphobj1.leg3 = 'SQP';
graphobj1.print = 'yes';
graphobj1.close = 'no';
Fig1 = PlotBoxComparison(Fopt_CE,Fopt_GA,Fopt_SQP,graphobj1);
% ..........................................................

% ..........................................................
graphobj2.gname = 'Truss10_MassMin_FrequencyBounds_BoxPlot_Fcount';
graphobj2.gtitle = 'Computational Cost';
graphobj2.xmin = 'auto';
graphobj2.xmax = 'auto';
graphobj2.ymin = 'auto';
graphobj2.ymax = 'auto';
graphobj2.xlab = [];
graphobj2.ylab = 'Function Evaluations';
graphobj2.leg1 = 'CE';
graphobj2.leg2 = 'GA';
graphobj2.leg3 = 'SQP';
graphobj2.print = 'yes';
graphobj2.close = 'no';
Fig2 = PlotBoxComparison(Fcount_CE,Fcount_GA,Fcount_SQP,graphobj2);
% ..........................................................
% ------------------------------------------------------------------
51 changes: 34 additions & 17 deletions CROSS-OPT-1.0/Main_Truss10_MassMin_YieldStress_BoxPlot.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,21 +230,38 @@
disp(' ------------------- ')
disp(' ')

figure
x = [Fopt_SQP Fopt_GA Fopt_CE];
boxplot(x,'Notch','off','Labels',{'SQP','GA','CE'});
ylabel('Truss Mass (kg)','FontSize',20,'FontName', 'Helvetica')
title("Number samples: " + Nbp, 'FontSize',20,'FontName', 'Helvetica')
set(gca, 'FontName', 'Helvetica');
set(gca, 'FontSize', 18);
box on

figure
x = [Fcount_SQP Fcount_GA Fcount_CE];
boxplot(x,'Notch','off','Labels',{'SQP','GA','CE'});
ylabel('Function Evaluations','FontSize',20,'FontName', 'Helvetica')
title("Number samples: " + Nbp, 'FontSize',20,'FontName', 'Helvetica')
set(gca, 'FontName', 'Helvetica');
set(gca, 'FontSize', 18);
box on
% ..........................................................
graphobj1.gname = 'Truss10_MassMin_YieldStress_BoxPlot_Fopt';
graphobj1.gtitle = 'Objetive Function';
graphobj1.xmin = 'auto';
graphobj1.xmax = 'auto';
graphobj1.ymin = 'auto';
graphobj1.ymax = 'auto';
graphobj1.xlab = [];
graphobj1.ylab = 'Truss Mass (kg)';
graphobj1.leg1 = 'CE';
graphobj1.leg2 = 'GA';
graphobj1.leg3 = 'SQP';
graphobj1.print = 'yes';
graphobj1.close = 'no';
Fig1 = PlotBoxComparison(Fopt_CE,Fopt_GA,Fopt_SQP,graphobj1);
% ..........................................................

% ..........................................................
graphobj2.gname = 'Truss10_MassMin_YieldStress_BoxPlot_Fcount';
graphobj2.gtitle = 'Computational Cost';
graphobj2.xmin = 'auto';
graphobj2.xmax = 'auto';
graphobj2.ymin = 'auto';
graphobj2.ymax = 'auto';
graphobj2.xlab = [];
graphobj2.ylab = 'Function Evaluations';
graphobj2.leg1 = 'CE';
graphobj2.leg2 = 'GA';
graphobj2.leg3 = 'SQP';
graphobj2.print = 'yes';
graphobj2.close = 'no';
Fig2 = PlotBoxComparison(Fcount_CE,Fcount_GA,Fcount_SQP,graphobj2);
% ..........................................................

% ------------------------------------------------------------------
50 changes: 33 additions & 17 deletions CROSS-OPT-1.0/Main_Truss37_MassMin_FrequencyBounds_BoxPlot.m
Original file line number Diff line number Diff line change
Expand Up @@ -281,21 +281,37 @@
disp(' ------------------- ')
disp(' ')

figure
x = [Fopt_SQP Fopt_GA Fopt_CE];
boxplot(x,'Notch','off','Labels',{'SQP','GA','CE'});
ylabel('Truss Mass (kg)','FontSize',20,'FontName', 'Helvetica')
title("Number samples: " + Nbp, 'FontSize',20,'FontName', 'Helvetica')
set(gca, 'FontName', 'Helvetica');
set(gca, 'FontSize', 18);
box on

figure
x = [Fcount_SQP Fcount_GA Fcount_CE];
boxplot(x,'Notch','off','Labels',{'SQP','GA','CE'});
ylabel('Function Evaluations','FontSize',20,'FontName', 'Helvetica')
title("Number samples: " + Nbp, 'FontSize',20,'FontName', 'Helvetica')
set(gca, 'FontName', 'Helvetica');
set(gca, 'FontSize', 18);
box on
% ..........................................................
graphobj1.gname = 'Truss37_MassMin_FrequencyBounds_BoxPlot_Fopt';
graphobj1.gtitle = 'Objetive Function';
graphobj1.xmin = 'auto';
graphobj1.xmax = 'auto';
graphobj1.ymin = 'auto';
graphobj1.ymax = 'auto';
graphobj1.xlab = [];
graphobj1.ylab = 'Truss Mass (kg)';
graphobj1.leg1 = 'CE';
graphobj1.leg2 = 'GA';
graphobj1.leg3 = 'SQP';
graphobj1.print = 'yes';
graphobj1.close = 'no';
Fig1 = PlotBoxComparison(Fopt_CE,Fopt_GA,Fopt_SQP,graphobj1);
% ..........................................................

% ..........................................................
graphobj2.gname = 'Truss37_MassMin_FrequencyBounds_BoxPlot_Fcount';
graphobj2.gtitle = 'Computational Cost';
graphobj2.xmin = 'auto';
graphobj2.xmax = 'auto';
graphobj2.ymin = 'auto';
graphobj2.ymax = 'auto';
graphobj2.xlab = [];
graphobj2.ylab = 'Function Evaluations';
graphobj2.leg1 = 'CE';
graphobj2.leg2 = 'GA';
graphobj2.leg3 = 'SQP';
graphobj2.print = 'yes';
graphobj2.close = 'no';
Fig2 = PlotBoxComparison(Fcount_CE,Fcount_GA,Fcount_SQP,graphobj2);
% ..........................................................
% ------------------------------------------------------------------
99 changes: 99 additions & 0 deletions CROSS-OPT-1.0/PlotBoxComparison.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
% -----------------------------------------------------------------
% PlotBoxComparison.m
% -----------------------------------------------------------------
% programmers: Marcos Vinicius Issa
% Anderson Pereira
% Americo Cunha Jr
%
% Originally programmed in: Sep 18, 2024
% Last updated in: Sep 18, 2024
% -----------------------------------------------------------------
% This function plots a boxplot comparison of truss mass results
% from different optimization methods.
%
% Input:
% x1 - results series 1
% x2 - results series 2
% x3 - results series 3
% graphobj - struct containing graph configuration parameters
%
% Output:
% fig - handle to the created figure
% -----------------------------------------------------------------

function fig = PlotBoxComparison(x1,x2,x3,graphobj)

% Check number of arguments
if nargin < 4
error('Too few inputs.');
elseif nargin > 4
error('Too many inputs.');
end

% Ensure all input vectors are row vectors
if ~iscolumn(x1)
x1 = x1';
end
if ~iscolumn(x2)
x2 = x2';
end
if ~iscolumn(x3)
x3 = x3';
end

% Prepare the data for the boxplot
x = [x1 x2 x3];

% Create figure
fig = figure('Name', graphobj.gname, 'NumberTitle', 'off');

% Create the boxplot
boxplot(x,'Notch','off',...
'Labels',{graphobj.leg1,graphobj.leg2,graphobj.leg3});

% Set font and box
set(gcf,'color','white');
set(gca,'position',[0.2 0.2 0.7 0.7]);
set(gca,'Box','on');
set(gca,'TickDir','out','TickLength',[.02 .02]);
set(gca,'XMinorTick','off','YMinorTick','off');
set(gca,'XGrid','off','YGrid','off');
set(gca,'XColor',[.3 .3 .3],'YColor',[.3 .3 .3]);
set(gca,'FontName','Helvetica');
set(gca,'FontSize',18);
box on;
%grid on;

% Set axis limits
if ( strcmp(graphobj.xmin,'auto') || strcmp(graphobj.xmax,'auto') )
xlim('auto');
else
xlim([graphobj.xmin graphobj.xmax]);
end

if ( strcmp(graphobj.ymin,'auto') || strcmp(graphobj.ymax,'auto') )
ylim('auto');
else
ylim([graphobj.ymin graphobj.ymax]);
end

% Set labels
xlabel(graphobj.xlab, 'FontSize', 20, 'FontName', 'Helvetica');
ylabel(graphobj.ylab, 'FontSize', 20, 'FontName', 'Helvetica');

% Set the title
title(graphobj.gtitle, 'FontSize', 24, 'FontName', 'Helvetica');

% Save the plot if required
if strcmp(graphobj.print, 'yes')
print('-depsc2', [graphobj.gname, '.eps']);
print('-dpng', [graphobj.gname, '.png']);
end

% Close the figure if requested
if strcmp(graphobj.close, 'yes')
close(fig);
end

end
% -----------------------------------------------------------------

0 comments on commit bb003f9

Please sign in to comment.