How to use genetic algorithm to minimize an objective function having 7 variables?
古いコメントを表示
%% Objective function
s30min=((P1(x)-P1)/P1)^2 + ((P2(x)-P2)/P2)^2 + ((P3(x)-P3)/P3)^2 + ....+((Pn(x)-Pn)/Pn)^2 %(Lets say there is n number of terms in the objective function)
In the objective function, P1, P2, P3,.....Pn are known observed values.
n=24
P1(x), P2(x), P3(x),.....Pn(x) are the functions of x, where x=[x1,x2,x3,x4,x5,x6,x7];
I want to find the values in x when the value of s30min is minimum.
%%Minimization using GlobalSearch algorithm
lb=[1.0 0.0 0.0 0.0 0.0 0.0 1.0];
ub=[100 500 500 500 500 500 1.0];
problem = createOptimProblem('fmincon','objective',@s30min,...
'x0',[1.0001 0.0001 0.0001 0.0001 0.0001 0.0001 1.0],'lb',lb,'ub',ub,...
'options',optimoptions(@fmincon,'Algorithm','interior-point','Display','off'));
gs = GlobalSearch('Display','off');
[x,fval] = run(gs,problem);
%% After minimization minimum function value=0.1781
%%Minimization using genetic algorithm
nvars=7;
lb=[1.0 0.0 0.0 0.0 0.0 0.0 1.0];
ub=[100 500 500 500 500 500 1.0];
ObjectiveFunction = @s30min;
[x,fval] = ga(ObjectiveFunction,nvars,[],[],[],[],lb,ub);
%% After minimization minimum function value=0.64
At first, I used GlobalSearch algorithm and got the minimum function value 0.1781. Later, I used genetic algorithm for the same problem. Actually, I am trying to get minimum function value closer to 0.1781 using genetic algorithm. Is there any way to get minimum function value closer to 0.1781 using genetic algorithm? I found GlobalSearch function faster than ga function. Is it possible to make genetic algorithm faster? I ran GlobalSearch algorithm almost 100 times and I found minimum function value 0.1781 nearly 10 times. ga is a stochastic algorithm and giving different function value at each time. There are other solvers as well. I am confused which solver I should use for my objective function. I really don't know whether my function is smooth or nonsmooth. Any advice would be highly appreciated.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Genetic Algorithm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!