link a custom creation function
1 次查看(过去 30 天)
显示 更早的评论
Hello,
i am using optimization toolbox and i want to link m.file that contains my initial population matrix .
% Input Data
M= 1;
I=2;
J = 9;
P_Prop_left = [3200,2690,4500,2900,2300,2000,1000,500,0];
P_EL = [2190,3100,4100,900,2000,2300,125.5,2125.57,82.19];
P_EL_Max = max(P_EL);
P_Prop_max = max(P_Prop_left);
nvars = 30
% Initial values functions
P_mcr_m_Target_initial = (max(P_Prop_left)*1.2) ./ (M.* ones(1,M))
P_mcr_i_Target_initial = (P_EL_Max * 1.1) ./ (I .* ones(1,I))
Ld_left_initial = ( P_Prop_left + (0.5 .* P_EL)) ./ P_mcr_m_Target_initial';
Ld_left_initial (Ld_left_initial > 0.9) = 0.85
Ld_left_initial (Ld_left_initial < 0.25) = 0 % make it Like a constraint later on
Ld_left_initial = reshape (Ld_left_initial', 1, M*J)
P_BTot_initial= P_mcr_m_Target_initial' * Ld_left_initial
PTI_initial = P_Prop_left - ( P_mcr_m_Target_initial * Ld_left_initial) ;
PTO_initial = -1 .* PTI_initial;
PTO_initial(PTO_initial<0) = 0
PTI_initial(PTI_initial<0) = 0
LF_initial = (P_EL - 2 .* PTO_initial + 2 .* PTI_initial ) ./ (I .* P_mcr_i_Target_initial')
LF_initial = reshape( LF_initial', 1, I*J)
% IP Initial Population matrix of size 1x NoOfVariables
IP = [P_mcr_m_Target_initial, P_mcr_i_Target_initial, Ld_left_initial, LF_initial]
my m file returns a matrix of size 1x nvars.
Q1: can i consider this matrix as initial population matrix?
in my understanding, this creates only one individual of the whole population, which may be not enoght. if yes,
Q2: how i create a whole population close to the values returned by the IP .
Q3: and what the differnece between using Initial Population matrix and create a custom population creation function
i suppose to use uniform creation function , or constraint dependant creation function, and use the IP matrix on (initial population) cell on the optimization toolbox
0 个评论
采纳的回答
Abdolkarim Mohammadi
2020-9-24
编辑:Abdolkarim Mohammadi
2020-9-25
1) "If you have a partial initial population, meaning fewer than PopulationSize rows, then the genetic algorithm calls CreationFcn to generate the remaining individuals."
https://www.mathworks.com/help/gads/genetic-algorithm-options.html#f14223 (Population options)
2) You can do it by repeating your individual to make it a matrix, and then add a noise to the elements.
InitialPopulationMatrix = repmat(IP, [PopulationSize,1]);
InitialPopulationMatrix(2:end,:) = InitialPopulationMatrix(2:end,:) + a*randn(PopulationSize-1,nvars);
Where a is the standrad deviation of the random Normal numbers to be added as noise. However, an initial population with low diversity (high similarity between the individuals, low a) increases the chance of ga() getting stuck in local minimum. Initial population should cover the whole landscape, and not concentrating in a small portion of it.
3) ga() calls the creation function to create the intial population matrix. If you provide no initial population, the creation function creates all of the initial population. if you provide an initial population matrix with fewer individuals, ga() will create the rest to have exactly an initial population with PopulationSize individuals. If you provide all of the individuals, creation function does nothing.
4 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!