how to minimize set of values with genetic algorithm
3 次查看(过去 30 天)
显示 更早的评论
function [z] = see(x1,x2,x3,x4,x5,d)
%optimization of okumura-hata model
x1=69.55;
x2=26.16;
x3=44.9;
x4=6.55;
x5=13.82;
d= 0.1:0.1:1;
z = x1 + x2*2.903+(x3-x4*1.477)*log10(d)-x5*1.477-(-9.1905e-04);
Good day, I'm trying to minimize the values for x1, x2,x3,x4, and x5 with genetic algorithm so that i can get reduced sets of values for Z.
how do i go about this? because it keeps giving me the same values.
Thanks.
0 个评论
采纳的回答
Stephan
2019-4-29
编辑:Stephan
2019-4-29
Hi,
you do not call ga here. Also your function would overwrite every input of x by the fixed values for x1...x5 inside your function - try this instead:
%% Optimization of okumura-hata model
% Values & Preallocation
d= 0.1:0.1:1;
x = zeros(1,5);
res = nan(numel(d),numel(x));
% Objective function
see = @(x,d) x(:,1) + x(:,2).*2.903+(x(:,3)-x(:,4).*1.477).*log10(d)...
-x(:,5).*1.477-(-9.1905e-04);
% Optimization options
opts = optimoptions(@ga, 'MaxGenerations', 10000, 'Vectorized', 'on',...
'Display', 'off');
% Calculate optimal x-values for each d-value in a loop
for k = 1:numel(d)
res(k,:) = ga(@(x)see(x,d(k)),numel(x),opts);
end
% Calculate minimized z-values
function_values = diag(see(res,d));
% Show results
res
function_values
in the variable res every line represents one value of d. The columns represent the x-values:
res =
1.0e+04 *
-2.5616 -5.0637 2.5757 -3.3401 3.1734
-2.6833 -5.2522 2.0992 -2.8011 3.4996
-2.8103 -5.3935 1.7644 -2.4866 3.5266
-2.9549 -5.4026 1.5468 -2.0186 3.6395
-2.8763 -5.5699 1.4268 -1.7981 3.6919
-2.9868 -5.5456 1.1051 -1.3898 3.7409
-2.8976 -5.5831 0.7727 -1.0403 3.7109
-3.0164 -5.4932 0.5235 -0.8457 3.7306
-2.9913 -5.6476 0.2559 -0.4003 3.7077
-3.0280 -5.6128 0.0108 -0.0606 3.6301
The resulting function values are:
function_values =
1.0e+05 *
-2.9458
-2.7458
-2.6519
-2.5816
-2.5728
-2.5311
-2.4944
-2.4645
-2.4901
-2.4683
Best regards
Stephan
12 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!