function f = genetic_operator(parent_chromosome,M,V,mu,mum,Xmax,Xmin);
%% function f = genetic_operator(parent_chromosome, M, V, mu, mum, l_limit, u_limit)
%
% This function is utilized to produce offsprings from parent chromosomes.
% The genetic operators corssover and mutation which are carried out with
% slight modifications from the original design. For more information read
% the document enclosed.
%
% parent_chromosome - the set of selected chromosomes.
% M - number of objective functions
% V - number of decision varaiables
% mu - distribution index for crossover (read the enlcosed pdf file)
% mum - distribution index for mutation (read the enclosed pdf file)
% l_limit - a vector of lower limit for the corresponding decsion variables
% u_limit - a vector of upper limit for the corresponding decsion variables
%
% The genetic operation is performed only on the decision variables, that
% is the first V elements in the chromosome vector.
% Copyright (c) 2009, Aravind Seshadri
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are
% met:
%
% * Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
% * Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in
% the documentation and/or other materials provided with the distribution
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.
[N,m] = size(parent_chromosome);
clear m
p = 1;
% Flags used to set if crossover and mutation were actually performed.
was_crossover = 0;
was_mutation = 0;
for i = 1 : N
% With 90 % probability perform crossover
if rand(1) < 0.9
% Initialize the children to be null vector.
child_1 = [];
child_2 = [];
% Select the first parent
parent_1 = round(N*rand(1));
if parent_1 < 1
parent_1 = 1;
end
% Select the second parent
parent_2 = round(N*rand(1));
if parent_2 < 1
parent_2 = 1;
end
% Make sure both the parents are not the same.
while isequal(parent_chromosome(parent_1,:),parent_chromosome(parent_2,:))
parent_2 = round(N*rand(1));
if parent_2 < 1
parent_2 = 1;
end
end
% Get the chromosome information for each randomnly selected
% parents
parent_1 = parent_chromosome(parent_1,:);
parent_2 = parent_chromosome(parent_2,:);
% Perform corssover for each decision variable in the chromosome.
for j = 1 : V
% SBX (Simulated Binary Crossover).
% For more information about SBX refer the enclosed pdf file.
% Generate a random number
u(j) = rand(1);
if u(j) <= 0.5
bq(j) = (2*u(j))^(1/(mu+1));
else
bq(j) = (1/(2*(1 - u(j))))^(1/(mu+1));
end
% Generate the jth element of first child
child_1(j) = ...
0.5*(((1 + bq(j))*parent_1(j)) + (1 - bq(j))*parent_2(j));
% Generate the jth element of second child
child_2(j) = ...
0.5*(((1 - bq(j))*parent_1(j)) + (1 + bq(j))*parent_2(j));
% Make sure that the generated element is within the specified
% decision space else set it to the appropriate extrema.
%********************************************************
%% 控制变量约束
if child_1(j) >Xmax
child_1(j) = Xmax;
elseif child_1(j) < Xmin
child_1(j) = Xmin;
end
%**************************************************************
%% 控制变量约束
if child_2(j) >Xmax
child_2(j) = Xmax;
elseif child_2(j) < Xmin
child_2(j) = Xmin;
end
%**************************************************************
end
% Evaluate the objective function for the offsprings and as before
% concatenate the offspring chromosome with objective value.
child_1(:,V + 1: M + V) = mokuaihanshu(child_1,V,M);
child_2(:,V + 1: M + V) = mokuaihanshu(child_2,V,M);
% Set the crossover flag. When crossover is performed two children
% are generate, while when mutation is performed only only child is
% generated.
was_crossover = 1;
was_mutation = 0;
% With 10 % probability perform mutation. Mutation is based on
% polynomial mutation.
else
% Select at random the parent.
parent_3 = round(N*rand(1));
if parent_3 < 1
parent_3 = 1;
end
% Get the chromosome information for the randomnly selected parent.
child_3 = parent_chromosome(parent_3,:);
% Perform mutation on eact element of the selected parent.
for j = 1 : V
r(j) = rand(1);
if r(j) < 0.5
delta(j) = (2*r(j))^(1/(mum+1)) - 1;
else
delta(j) = 1 - (2*(1 - r(j)))^(1/(mum+1));
end
% Generate the corresponding child element.
child_3(j) = child_3(j) + delta(j);
% Make sure that the generated element is within the decision
% space.
%****************************************
%% 控制变量约束
if child_3(j) >Xmax
child_3(j) = Xmax;
elseif child_3(j) < Xmin
child_3(j) = Xmin;
end
%****************************************
end
% Evaluate the objective function for the offspring and as before
% concatenate the offspring chromosome with objective value.
child_3(:,V + 1: M + V) = mokuaihanshu(child_3,V,M);
% Set the mutation flag
was_mutation = 1;
was_crossover = 0;
end
% Keep proper count and appropriately fill the child variable with all
% the generated children for the particular generation.
if was_crossover
child(p,:) = child_1;
child(p+1,:) = child_2;
was_cossover = 0;
p = p + 2;
elseif was_mutation
child(p,:) = child_3(1,1 : M + V);
was_mutation = 0;
p = p + 1;
end
end
f = child;
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
matlab程序 使用粒子群算法对电力节点进行选址定容 采用粒子群算法的方式进行了电力系统潮流计算以降低电网的网络损耗。 关键词:热电联产系统;综合能源系统;多能流;定容选址;优化配置;粒子群算法。 适合粒子群算法及综合能源系统领域研究的同学 可以为相关领域研究的同学提供参考,以供学习。
资源推荐
资源详情
资源评论
收起资源包目录
多目标粒子群在分布式的选址定容.zip (11个子文件)
多目标粒子群在分布式的选址定容
initial.m 473B
mokuaihanshu.m 58B
main.m 3KB
non_domination_sort_mod.m 7KB
tournament_selection.m 5KB
gbest_fitness.m 677B
genetic_operator.m 7KB
update_v.m 364B
replace_chromosome.m 4KB
pf.m 5KB
fitness.m 968B
共 11 条
- 1
资源评论
- zhangxianhui012024-04-25资源质量不错,和资源描述一致,内容详细,对我很有用。
素馨堂
- 粉丝: 98
- 资源: 32
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功