필터 지우기
필터 지우기

Genetic algorithm with solution of pde toolbox

조회 수: 5 (최근 30일)
현준
현준 2024년 6월 7일
답변: UDAYA PEDDIRAJU 2024년 6월 10일
Hi I'm on project that find optimal parameter about transient heat transfer problem. (find optimal values that minimize temperature fluctuation)
I have problem about exceed maximum array size (about 1800GB) while solving ga problem
I defined a design domain contains multiple values (i.e. length, geometry properties, etc) and FEA using pde toolbox has finished
the last task what i have to do is find optimal values with solution of FEA using ga function and my pseudo code about FEA is here:
function [result, model] = Heattransfer(L1, t1, t2, t3, length_fin, num_fins, shelltype, shellmat, intermed, time)
thermalmodel = createpde('thermal', 'transient');
tlist = 0:1:time*60*60;
% Skip code about geometries, BC, IC
result = solve(thermalmodel, tlist);
model = thermalmodel;
end
L1, t1, t2, t3, length_fin is about geometry parameters that is noninteger values (because it is length)
num_fins, shelltype, shellmat, intermed is also about geometry parameters that is interger values (because it is about number or material type, i implemented that decide material type, geometry type by select number like if shellmat == 1, steel / elseif shellmat == 2, polymer)
and code about ga is as below:
function value = ObjectiveFcn(a, time)
L1 = a(1);
t1 = a(2);
t2 = a(3);
t3 = a(4);
length_fin = a(5);
num_fins = a(6);
shelltype = a(7);
shellmat = a(8);
intermed = a(9);
result = Heattransfer(L1, t1, t2, t3, length_fin, num_fins, shelltype, shellmat, intermed, time);
T = result.Temperature;
std_dev = std(T, 0, 1);
value = mean(std_dev);
end
function [c, ceq] = Constraints(b)
L1 = b(1);
t1 = b(2);
t2 = b(3);
t3 = b(4);
length_fin = b(5);
c1 = L1 + t1 + t2 + t3 - 0.3; % 0.3 is total length of control volume
c2 = length_fin - t1;
c3 = length_fin - t3;
c = [c1; c2; c3];
ceq = [];
end
% a = [L1, t1, t2, t3, length_fin, num_fins, shelltype, shellmat, intermed]
lb = [0, 0, 0, 0, 0, 1, 1, 1, 1];
ub = [0.3, 0.01, 0.02, 0.01, 0.01, 374, 2, 3, 2];
intvar = [6, 7, 8, 9];
ObjectivefunWithTime = @(a) Objectivefun(a, time);
ConstraintsFcn = @(b) Constraints(b);
options = optimoptions('ga', 'Display', 'iter', 'PopulationSize', 10,...
'MaxGenerations', 20, 'CrossoverFraction', 0.8, 'UseParallel', true);
[x_opt, fval] = ga(ObjectivefunWithTime, 9, [], [], [], [], lb, ub, ConstraintsFcn, intvar, options);
time is not design variable so I excepted it from objective function
In ub (upper bound), I actually want to set value for t1, t2, t3, length_fin as 0.3 to find optimal value widely (under Constraints) but when i set values like that, it results error for invalid geometry (conflicted in pde toolbox code) so I defined arbiturary values.
What should I do for achieve my goal? (find optimal value)
I'm sorry for messy code
If anyone knows about this, please comment.
Thank you

답변 (1개)

UDAYA PEDDIRAJU
UDAYA PEDDIRAJU 2024년 6월 10일
Hi 현준,
Your GA and PDE Toolbox approach for heat transfer optimization is promising! The high memory usage might be due to the FEA computations within the objective function. Here are some ways to address this:
Reduce FEA Cost:
  • Simplify the "Heattransfer" function (coarser mesh, simpler BCs).
  • Parallelize "ObjectiveFcn" if your environment supports it.
Rescale Design Variables:
  • Set "ub" for geometric parameters within a valid range.
  • Transform them in "ObjectiveFcn" to satisfy the total length constraint (0.3 in your case). Here's an example for t1:
t1_scaled = a(2) * 0.2; % Adjust factor based on valid range for t1
Apply similar transformations for t2, t3, and length_fin. Ensure the total scaled length doesn't exceed 0.3. Penalize invalid solutions with inf in "ObjectiveFcn".
Experiment:
  • Start with a smaller GA population and adjust parameters (PopulationSize, MaxGenerations, etc.).
This approach should help you find optimal parameters while reducing memory usage.

카테고리

Help CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by