I need a name for this optimization code. Also who can help me plot a pareto front with this code or at specify which objective function i can use for the pareto.

1 view (last 30 days)
clc
faces = load("buildings.dat");
rays = load("SunRays.dat");
% to get the optimum number of panels on facades
[ntotal,wtotal,htotal] = CountPanels(faces);
% to get the optimum numbr of panel width &heights per facades
n = zeros(44,1); % 44 facades in total and 1 dimension
w = zeros(44,1);
h = zeros(44,1);
for i = 1: 44
[n(i,1),w(i,1),h(i,1)] = CountPanels(faces(i,:));
end
% Getting the efficiency of solar panels for time period 1(1.8hrs)
for i = 1:44
for j = 1: n(i,1)
eff1(i,j) = panelEfficiency(i,j,faces,rays(1,:));
end
end
%Getting the efficiency of solar panels for time period 1(2.2hrs)
for i = 1:44
for j = 1: n(i,1)
eff2(i,j) = panelEfficiency(i,j,faces,rays(2,:));
end
end
% Getting the efficiency of solar panels for time period 1(2.5hrs)
for i = 1:44
for j = 1: n(i,1)
eff3(i,j) = panelEfficiency(i,j,faces,rays(3,:));
end
end
%Getting the efficiency of solar panels for time period 1(1.5hrs)
for i = 1:44
for j = 1: n(i,1)
eff4(i,j) = panelEfficiency(i,j,faces,rays(4,:));
end
end
% optimum power output per placement of panel
P = zeros(44,120);
for i = 1:44
for j = 1:120
P(i,j) = 300*eff1(i,j)*1.8 + 300*eff2(i,j)*2.5 + 300*eff3(i,j)*2.2 ...
+ 300*eff4(i,j)*1.5;
end
end
% my optimization Procedures
% to get optimum performance
maxP = max(P, [], 'all');
% Get maximum efficiencies for each time period
maxEff1 = max(eff1,[],'all');
maxEff2 = max(eff2,[],'all');
maxEff3 = max(eff3,[],'all');
maxEff4 = max(eff4,[],'all');
% maximum efficiency(overall)
maxEff = max([maxEff1 maxEff2 maxEff3 maxEff4]);
%get maximum performance values for each facade
PMaxValues = max(P')';
% Generate the average
WeightedP = P./PMaxValues;
% get only the best placements for each row
for i=1:size(WeightedP,1)
for j = 1:size(WeightedP,2)
if (WeightedP(i,j) ~= 1)
WeightedP(i,j) = 0;
end
end
end
% Multiply by the performance vector
OptimumWeights = WeightedP .* P;
%----Optional --------------
% Let us set a performance benchmark for each solar panel of 900
% for i=1:size(WeightedP,1)
% for j = 1:size(WeightedP,2)
% if (OptimumWeights(i,j) < 700)
% OptimumWeights(i,j) = 0;
% end
% end
% end
% -----------------------------
% get the count of our remaining installations
count = 0;
for i=1:size(WeightedP,1)
for j = 1:size(WeightedP,2)
if (OptimumWeights(i,j) > 0)
count = count + 1;
end
end
end
% assuming i want to install at most 2,000 solar panels
% remove all minimums until we get to the top 2000 positions
% add a second constraint with respect to cost
% assuming i want to get a cost of not more than 1,000,000 USD
Cost = 0; % Initial Cost of zero
while count > 2000 || Cost > 1000000
un = min(OptimumWeights(OptimumWeights>0)); % Represents the smallest value in the matrix
for i=1:size(WeightedP,1)
for j = 1:size(WeightedP,2)
if (OptimumWeights(i,j) == un)
OptimumWeights(i,j) = 0;
end
end
end
count = 0;
for i=1:size(WeightedP,1)
%for i = 1:size(weightedP,1)
for j = 1:size(WeightedP,2)
if (OptimumWeights(i,j) > 0)
count = count + 1;
end
end
end
Cost = 800 * count;
end
% Compute the Energy Output of the installation
EnergyOutput = sum(OptimumWeights,"all");
% Compute installation cost
Cost = 800 * count;
% ---Generate text file report ----------
strOutput = "";
for i=1:size(WeightedP,1)
for j = 1:size(WeightedP,2)
if (OptimumWeights(i,j) > 0)
strOutput = append(strOutput, num2str(j), ",");
else
continue
end
end
strOutput = append(strOutput,newline);
end
fid = fopen('finalsolution.txt','wt');
fprintf(fid, strOutput);
fclose(fid);

Answers (1)

Umang Pandey
Umang Pandey on 23 Jan 2024
Hi Chukwuemeka,
As per my understanding, you want to find appropriate objective functions which you can optimize based on provided code and obtain a pareto front.
For obtaining a pareto front, the nature of the objectives must be conflicting, i.e., achieving one goal impedes or contradicts the attainment of another. In the context of your code, following can be considered as potential objective functions -
  • Maximizing Energy Output
  • Minimizing Cost
Since, you have 2 objectives to optimize, this problem falls under the category of “Multi-Objective Optimization”.
You can refer to the following MathWorks discovery page for more information on this -
As for obtaining a Pareto Front, refer to the following MATLAB example by running the following command in your MATLAB Command Window
openExample('globaloptim/ParetoFrontForMultiobjectiveOptimizationProblemBasedExample')
Hope this helps!
Best,
Umang

Tags

Community Treasure Hunt

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

Start Hunting!