-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrossoverhybridcq.m
55 lines (51 loc) · 1.89 KB
/
crossoverhybridcq.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%Author: Zsolt T. Kosztyán Ph.D habil., University of Pannonia,
%Faculty of Economics, Department of Quantitative Methods
%----------------
%Crossover function for HCTQCTPs and Pareto-Optimal Resource Allocation
%----------------
%Standard output:
%xoverKids=Set of the result of the recombination
%----------------
%Standard inputs:
%parents=Set of chromosomes of parents
%options=Set of GA options not used
%GenomeLength=The size of the chromosomes
%FitnessFcn,unused=Fitness function, unused = not used parameters
%thisPopulation=Set of the population
%----------------
%Usage:
%xoverKids = crossoverhybridcq(parents,options,GenomeLength,FitnessFcn,...
%unused,thisPopulation)
%----------------
%Example:
%This is not executed as a stand-alone fuinction. Instead of specifying
%global values this function is cannot be run.
function xoverKids = crossoverhybridcq(parents,options,GenomeLength,...
FitnessFcn,unused,thisPopulation)
nKids = length(parents)/2;
% Allocate space for the kids
xoverKids = zeros(nKids,GenomeLength);
% To move through the parents twice as fast as the kids are
% being produced, a separate index for the parents is needed
index = 1;
% for each kid...
for i=1:nKids
% get parents
r1 = parents(index);
index = index + 1;
r2 = parents(index);
index = index + 1;
% Decoding parents' chromosomes, which contains results of the
% deciosions of uncertain tasks/dependencies (DSM) and completion modes
% (MODES=T)
PSM1=updatepemc(thisPopulation(r1,:));
DSM1=PSM1(:,1:size(PSM1,1));
MODES1=PSM1(:,end);
PSM2=updatepemc(thisPopulation(r2,:));
DSM2=PSM2(:,1:size(PSM2,1));
MODES2=PSM2(:,end);
% Randomly select half of the genes from each parent
% This loop may seem like brute force, but it is twice as fast as the
% vectorized version, because it does no allocation.
xoverKids(i,:)=crossdsmcq(DSM1,MODES1,DSM2,MODES2);
end