MATLAB Program for De
MATLAB Program for De
constraint: 0 ≤ x ≤ 5
• Steps:
1-initialize parameters
• 2-Mutation to get donor=x1+F(x2-x3)
3-Crossover to get trial vector
4- make sure that 0 ≤ trial values ≤ 5
5-Selection between trial and parent
6- find the best solution that gives the best minimum value
• ind=(randperm(n1,3)) ; 1 4 3
• trial =3.5163
• Note: donor=x1+F*(x2-x3) ; 3.5163
Prof. Ali Awad 6
• %Make sure the values of the trial vector are between
ub and lb
•
•
• if fitness_trial< fitness_parent
• %comparison between fitness value of trial and parent put the least one as best
fit
• p(i,:)= trial;
• best_fit(i) = fitness_trial; 0.5618
• else
• p(i,:)= parent; p(1,1)= 0.5618
• best_fit(i)= fitness_parent;
• end
•
• end % for i
Prof. Ali Awad 8
• %select the minimum fitness value and its
corresponding solution(best solution) from the
population list
• [min_value,ind]=min(best_fit);
•
• best_sol=p(ind,:);
•
• best_value
• best_sol