How to write matlab code for following equation using multiobjective genetic algorithm and get the minimized value of 'd' as output ?

2 views (last 30 days)
Using multiobjective optimization solve this function with following:
The initial population is stated as follows:
I am facing problem in executing codes for this question, I have coded as follows:
I made a filness function "fitfu2" as
function y = fitfu2(N)
%N = 12; % element numbers
j = sqrt(-1);
AF = zeros(1,360);
deg2rad=zeros(1,360);
for theta = 60:360
deg2rad(theta) = (theta*pi)/180;
for k = 1:N-1
for d = 0:0.5:0.5*k
for n=1:N-1
AF(theta) = AF(theta) + exp(j*n*2*pi*d*(cos(deg2rad(theta))));
end
AF(theta)=1+AF(theta);
end
end
end
y = abs(AF(theta));
and then I used following codes to use multiobjective genetic optimization toolbox
N=12; % Number of elements
FitnessFunction = @(d) fitfu2(N);
NumberOfVariables = 11;
options = gaoptimset('PopulationSize',20);
[x,f] = gamultiobj(FitnessFunction,NumberOfVariables,[],[],[],[],2,10,options);
This is executing but I am confused about how to get desired output and I am not getting minimized value of 'd'.
Actually I want to Optimize this function taking 'd' as a parameter means to minimize the function as well as minimize 'd' and give the minimized value of 'd' at each iteration as optput.
If there is any Error or wrong coding ,Please Rectify and send me back the rectified codes that will execute and give me desired result.

Accepted Answer

Walter Roberson
Walter Roberson on 26 Aug 2015
As best I can tell with that notation, you would loop over all the theta, minimizing for each one. However, there is no point doing multiobjective optimization since there is only one objective. Perhaps the intention is to define an objective for each theta and to minimize simultaneously, but if so then the problem statement needs to be clarified.
The problem statement talks about initial excitation amplitudes and initial phase excitations, but offers no information as to when those might be altered.
For any one theta,
lambda = rand(); %give it an appropriate value
beta = rand(); %give it an appropriate value
alpha = ones(N-1, 1);
phi = zeros(N-1, 1);
d0 = (1:N-1) * lambda/2;
NumberOfVariables = 11;
options = gaoptimset('PopulationSize',20);
FitnessFunction = @(d) fitfu2(d, N, alpha, beta, phi, theta);
[x,f] = gamultiobj(FitnessFunction,NumberOfVariables,[],[],[],[],2,10,options);
and
function y = fitfu2(d, N, alpha, beta, phi, theta)
j = sqrt(-1);
costheta = cos(theta);
AF = sum(alpha .* exp(j * (beta .* d .* costheta + phi));
y = abs(AF);

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!