Objective Function Minimum Value Problem - Genetic Algorithm
1 回表示 (過去 30 日間)
古いコメントを表示
I used genetic algorithm to optimize model parameters. Results of running my code are:
Optimization terminated: minimum fitness limit reached.
x =
-143.0421 5.4032 -36.7178 -15.9012 17.7426 -44.5850
fval =
-Inf
As can be seen result gives six parameters. However, value of objective function at minimum has no sense. If that is supposed to be minus infinity, how can that even represent a minimum of any function, not to mention that my objective function can't have negative values.
Here is main code:
clc
clear all
global x1e x2e x3e x1r x2r x3r alfa12 alfa13 alfa23
%LLE podatci - ekstrakcija aromata smjesom TTEG i vode - 6 komponenata (heptan) na 60°C
%eksperimentalni podatci - ekstrakt
x1e = [0.0140 0.0175 0.0163 0.0188 0.0181 0.0227 0.0228 0.0214 0.0191 0.0208];
x2e = [0.0729 0.0696 0.106 0.1041 0.1107 0.0931 0.0732 0.0739 0.113 0.069];
x3e = 1 - x1e - x2e;
%eksperimentalni podatci - rafinat
x1r = [0.689 0.6289 0.485 0.4727 0.4332 0.6831 0.6967 0.6553 0.4507 0.6139];
x2r = [0.275 0.2855 0.4418 0.3501 0.4056 0.313 0.2716 0.271 0.4436 0.253];
x3r = 1 - x1r - x2r;
%Optimizacija NRTL parametara - Metoda Sorensena i Arlta
%1. stupanj optimizacije - opis fazne ravnoteze - geneticki algoritam
%parametri neslucajnosti
alfa12 = 0.3;
alfa13 = 0.3;
alfa23 = 0.2;
rng default
%definiranje strukture problema
OF_A = @(x) OF_2_6H_60C(x);
problem.fitnessfcn = OF_A;
problem.nvars = 6;
problem.options = optimoptions('ga');
[x,fval] = ga(problem)
Here is objective function:
function [OF2] = OF_2_6H_60C(x)
global x1e x2e x3e x1r x2r x3r alfa12 alfa13 alfa23
G12 = exp(-alfa12*x(1));
G13 = exp(-alfa13*x(2));
G21 = exp(-alfa12*x(3));
G23 = exp(-alfa23*x(4));
G31 = exp(-alfa13*x(5));
G32 = exp(-alfa23*x(6));
A1e = (x2e.*x(3)*G21 + x3e.*x(5)*G31)./(x1e + x2e.*G21 + x3e.*G31) + (x1e./(x1e + x2e.*G21 + x3e.*G31)).*(-(x2e.*x(3)*G21 + x3e.*x(5)*G31)./(x1e + x2e.*G21 + x3e.*G31)) + (x2e.*G12./(x1e.*G12 + x2e + x3e.*G32)).*(x(3) - (x1e.*x(1)*G12 + x3e.*x(6)*G32)./(x1e.*G12 + x2e + x3e.*G32)) + (x3e.*G13./(x1e.*G13 + x2e.*G23 + x3e)).*(x(5) - (x1e.*x(2)*G13 + x2e.*x(4)*G23)./(x1e.*G13 + x2e.*G23 + x3e));
gamma1e = exp(A1e);
A2e = (x1e.*x(1)*G12 + x3e.*x(6)*G32)./(x1e.*G12 + x2e + x3e.*G32) + (x1e.*G21./(x1e + x2e.*G21 + x3e.*G31)).*(x(1) - (x2e.*x(3)*G21 + x3e.*x(5)*G31)./(x1e + x2e.*G21 + x3e.*G31)) + (x2e./(x1e.*G12 + x2e + x3e.*G32)).*(-(x1e.*x(1)*G12 + x3e.*x(6)*G32)./(x1e.*G12 + x2e + x3e.*G32)) + (x3e.*G23./(x1e.*G13 + x2e.*G23 + x3e)).*(x(6) - (x1e.*x(2)*G13 + x2e.*x(4)*G23)./(x1e.*G13 + x2e.*G23 + x3e));
gamma2e = exp(A2e);
A3e = (x1e.*x(2)*G13 + x2e.*x(4)*G23)./(x1e.*G13 + x2e.*G23 + x3e) + ((x1e.*G21./(x1e + x2e.*G21 + x3e.*G31)).*(x(2) - (x2e.*x(3)*G21 + x3e.*x(5)*G31)./(x1e + x2e.*G21 + x3e.*G31))) + ((x2e.*G32./(x1e.*G12 + x2e + x3e.*G32)).*(x(4) - (x1e.*x(1)*G12)./(x1e.*G12 + x2e + x3e.*G32))) + ((x3e./(x1e.*G13 + x2e.*G23 + x3e)).*(-(x1e.*x(2)*G13 + x2e.*x(4)*G23)./(x1e.*G13 + x2e.*G23 + x3e)));
gamma3e = exp(A3e);
A1r = (x2r.*x(3)*G21 + x3r.*x(5)*G31)./(x1r + x2r.*G21 + x3r.*G31) + ((x1r./(x1r + x2r.*G21 + x3r.*G31)).*(-(x2r.*x(3)*G21 + x3e.*x(5)*G31)./(x1r + x2r.*G21 + x3r.*G31))) + ((x2r.*G12)./(x1r.*G12 + x2r + x3e.*G32)).*(x(3) - ((x1r.*x(1)*G12 + x3r.*x(6)*G32)./(x1r.*G12 + x2r + x3r.*G32))) + ((x3r.*G13./(x1r.*G13 + x3r)).*(x(5) - (x1r.*x(2)*G13 + x2r.*x(4)*G23)./(x1r.*G13 + x2r.*G23 + x3r)));
gamma1r = exp(A1r);
A2r = (x1r.*x(1)*G12 + x3r.*x(6)*G32)./(x1r.*G12 + x2r + x3r.*G32) + ((x1r.*G21./(x1r + x2r.*G21 + x3r.*G32)).*(x(1) - (x2r.*x(3).*G21 + x3r.*x(5)*G31)./(x1r + x2r.*G21 + x3r.*G31))) + ((x2r./(x1r.*G12 + x2r + x3r.*G32)).*(-(x1r.*x(1)*G12 + x3r.*x(6)*G32)./(x1r.*G12 + x2r + x3r.*G32))) + ((x3r.*G23./(x1r.*G13 + x2r.*G23 + x3r)).*(x(6) - (x1r.*x(2)*G13 + x2r.*x(4)*G23 + x3r)./(x1r.*G13 + x2r.*G23 + x3r)));
gamma2r = exp(A2r);
A3r = (x1r.*x(2)*G13 + x2r.*x(4)*G23)./(x1r.*G13 + x2r.*G23 + x3r) + ((x1r.*G31./(x1r + x2r.*G21 + x3r.*G31)).*(x(2) - (x2r.*x(3)*G21 + x3r.*x(5)*G31)./(x1r + x2r.*G21 + x3r.*G31))) + ((x2r.*G32./(x1r.*G12 + x2r + x3r.*G32)).*(x(4) - (x1r.*x(1)*G12)./(x1r.*G12 + x2r + x3r.*G32))) + ((x3r./(x1r.*G13 + x2r.*G23 + x3r)).*(-(x1r.*x(2)*G13 + x2r.*x(4)*G23)./(x1r.*G13 + x2r.*G23 + x3r)));
gamma3r = exp(A3r);
for i = 1:10
A(i)=((x1e(i)*gamma1e(i) - x1r(i)*gamma1r(i))/(x1e(i)*gamma1e(i) + x1r(i)*gamma1r(i))^2) + ((x2e(i)*gamma2e(i) - x2r(i)*gamma2r(i))/(x2e(i)*gamma2e(i) + x2r(i)*gamma2r(i))^2) + ((x3e(i)*gamma3e(i) - x3r(i)*gamma3r(i))/(x3e(i)*gamma3e(i) + x3r(i).*gamma3r(i))^2);
end
OF2 = sum(A,'all');
end
Long expressions such as A1e, A2e, A3e etc. are only vectors of 1x10 as x1e, x2e, x3e etc. also are.
I initially thought there is something wrong with these long expressions as mistakes can easily be made there, but I can't find any. Any ideas?
5 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Genetic Algorithm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!