Genetic algorithm using objects
3 views (last 30 days)
Show older comments
Hi guys,
I am trying to run Genetic algorithm. I could run it with single object but I want to give multiple objects as input. Does anyone have any idea how could i do that.
classdef clGAalgorithm
properties
% clSystem = 'path \ path'
% GOSET = 'path \ path'
% PATH = 'path \ path'
% PMD = 'path \ path'
rp_lvl = 0;
ev_pp = true;
ev_npg = 12;
gd
end
methods (Static)
function [object, fP, GAS, bi, bf] = GA1 (objDS, objT) % set up GA
ngen = 2000;
npop = 2000;
object = gapdefault (2.0, npop, ngen);
% GAP.rp_lvl = 0;
% GAP.ev_pp = true;
% GAP.ev_npg = 12;
% gene description
% min max chrm chrm par
% val val type id # description
object.gd = [1 6 1 1; ... % 1 mc - material code for core
1e-4 1.5e + 0 3 1; ... % 2 lcc - length of core center (m)
1e-6 5e-2 3 1; ... % 3 rc - core radius (m)
1e-4 0.5e + 0 3 1; ... % 4 wcec - width of core center (m)
% 1e-3 1e + 0 3 1; ...% 5 wcb - width of core base (m)
1 2 1 1; ... % 5 mp - material code for prim.
1 200 3 1; ... % 6 Npclstr des. Prim turns per coil% 5-1000
max (objDS.insclp, objDS.inscls) 0.2 3 1];
if objDS.Wm ~ = 1
disp ( 'Winding Model is false. Choose 1 for Litz Wire or 2 for Foil Winding in D.wm in fixed parameters! Litz Wire is chosen as default!' );
end
% fixed parameters for Litz Wire Model:
objDS.Wm = 1;
objDS.tpins = 30e-6; % primary conductor insulation thickness (m)
objDS.kpb = 1.2; % primary winding build factor
objDS.ksb = 1.2; % secondary winding build factor
objDS.tsins = 30e-6; % secondary cond. insulation thickness (m)
objDS.kbdmnr = 10; % minimum req. bend radious ratio
alphapu = 3; % maximum allowed aspect ratio for primary litz wire
alphasu = 3; % maximum allowed aspect ratio for secondary litz wire
% Design Space for Litz Wire Model:
object.gd = [object.gd;
0.1 10 3 1; ... % 8 rpdw - prim. coil aspect ratio
1e-6 0.3e-2 3 1; ... % 9 aptstr- des. Area prim. cond. (m ^ 2)
100 40,000 1 1; ... % 10 Npprstr des. Prim. cond. in par. 1-5
1 / alphapu alphapu 3 1]; ... % 11 alphapu-primary litz wire aspect ratio
if objDS.Tm == 2
object.gd = [object.gd;
1 2 1 1; ... % 12 ms - material code for sec.
Rpsmn Rpsmx 2 1; ... % 13 Rpsstr des. Prim. to sec. turns
1e-6 0.3e-2 3 1; ... % 14 aststr- des. Area sec. Cond (m ^ 2)
100 40,000 1 1; ... % 15 Nsprstr des. Sec. Cond. in par. 1-5
0.1 10 3 1; ... % 16 rsdw - sec. Coil aspect ratio
1 / alphasu alphasu 3 1]; ... % 17 alphasu- secondary litz wire aspect ratio
end
% conduct optimization
[fP, GAS, bi, bf] = gaoptimize (@ cloptim1.CTT_fit_Litz1, object, objDS);
% save the results
if objDS.MatCore == 1
save resultsSteelLitz
elseif objDS.MatCore == 2
save resultsFerriteLitz
elseif objDS.MatCore == 3
save resultsNanoLitz
else
disp ( 'No such material catalog for core' );
end
end
The object objDS which is given as input is working but i also want to give objects like objCore, objW, objT as inputs in addition to that. Since gaoptimize supports single input i think it supports in that way. but i also want to include other objects. Can give me some idea.
Thank you
1 Comment
Walter Roberson
on 7 Sep 2020
You appear to be using GOSET to define gaoptimize().
Your ability to pass other kinds of objects is going to depend upon that code.
Unless, that is, you want to pass those in as extra parameters, in which case see
Answers (0)
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!