Genetic algorithm with solution of pde toolbox
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 youHi 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 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 genetic algorithm, pde toolbox, transient heat transfer, matlab, partial differential equation toolbox, global optimization toolbox MATLAB Answers — New Questions