フィルターのクリア

Optimization with 3 variables- how to find the values of each variable to minimize mass?

6 ビュー (過去 30 日間)
Din N
Din N 2023 年 3 月 14 日
回答済み: Amith 2024 年 8 月 20 日 6:15
I have an infrastructure where a metal sheet must be produced. An excavator, an electrolysis reactor, and a 3D printer must be used.
All this has to be performed in 3650 days. So, I am trying to kind of optimize it and find how many excavators, reactors, and 3D printers will give the smallest mass but will also be able to get the job done in 3650 days. I am not sure if and how a code can be written for that. Any help would be appreciated.
days_req=3650; %
m_sheet=linspace(100,10000,200); % mass of a metal sheet
% excavator
n_excav=1:1:200; % number of excavators
m_excav=67; % mass of each excavator
m_tot_excav=n_RASSORs*m_RASSOR; % mass for n excavators
excav_cap=n_excav*6536; % kg/day
days_excav=ceil(m_sheet./excav_cap./n_excav); % days to excavate
% electrolysis reactor
n_react=1:1:200; % number of reactors
m_react=2000; % mass of each reactor
m_tot_react=n_react*m_react; % mass for n reactors
prod_rate_react=7*24; % kg/day of regolith
days_react=ceil(m_sheet./prod_rate_react./n_react); % days to process m_sheet
% printer
n_printer=1:1:200; % number of printers
m_printer=3500; % mass of each printer
m_tot_printer=n_printer*m_printer; % mass for n printers
deposition_rate=n_printer*14.4; % kg/day
days_print=ceil(m_sheet./deposition_rate./n_printer); % days to print

回答 (1 件)

Amith
Amith 2024 年 8 月 20 日 6:15
Hi Din,
To solve this problem, we need to find the optimal number of excavators, reactors, and 3D printers that will complete the task in 3650 days while minimizing the total mass of the equipment. We can approach this by iterating over possible combinations of excavators, reactors, and printers and calculating the total mass and days required for each combination. Then, we select the combination that meets the time constraint and has the smallest mass.
Here's a MATLAB script that does this:
% Define constants
days_req = 3650;
m_sheet = linspace(100, 10000, 200); % mass of a metal sheet
% Excavator
m_excav = 67; % mass of each excavator
excav_cap_per_excavator = 6536; % kg/day
% Electrolysis reactor
m_react = 2000; % mass of each reactor
prod_rate_react_per_reactor = 7 * 24; % kg/day
% Printer
m_printer = 3500; % mass of each printer
deposition_rate_per_printer = 14.4; % kg/day
% Initialize variables to store the optimal solution
min_mass = inf;
optimal_combination = [];
% Iterate over possible numbers of excavators, reactors, and printers
for n_excav = 1:200
for n_react = 1:200
for n_printer = 1:200
% Calculate days required for each process
days_excav = ceil(m_sheet ./ (n_excav * excav_cap_per_excavator));
days_react = ceil(m_sheet ./ (n_react * prod_rate_react_per_reactor));
days_print = ceil(m_sheet ./ (n_printer * deposition_rate_per_printer));
% Find the maximum days required for any sheet
max_days = max([days_excav; days_react; days_print], [], 1);
% Check if the maximum days is within the allowed days
if all(max_days <= days_req)
% Calculate total mass
total_mass = n_excav * m_excav + n_react * m_react + n_printer * m_printer;
% Check if this is the minimum mass found so far
if total_mass < min_mass
min_mass = total_mass;
optimal_combination = [n_excav, n_react, n_printer];
end
end
end
end
end
% Display the optimal combination and minimum mass
fprintf('Optimal number of excavators: %d\n', optimal_combination(1));
fprintf('Optimal number of reactors: %d\n', optimal_combination(2));
fprintf('Optimal number of printers: %d\n', optimal_combination(3));
fprintf('Minimum total mass: %.2f kg\n', min_mass);
Explanation for the above code:
  • Iterate over combinations: We loop through possible numbers of excavators, reactors, and printers (from 1 to 200).
  • Calculate days required: For each combination, calculate the number of days required for each process.
  • Check feasibility: Ensure that the maximum number of days required for any sheet is within the allowed 3650 days.
  • Calculate total mass: Compute the total mass for the current combination.
  • Track optimal solution: Update the optimal solution if the current combination has a lower total mass.
This script should help you figure out the optimal

カテゴリ

Help Center および File ExchangeLeast Squares についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by