Fval Output by ga does not match output of fitness function evaluated at the respective x vector

1 回表示 (過去 30 日間)
Hello all,
I have been using ga to minimize a fitness function of mine, but have recently come across some issues concerning the output. After running for several hours (the fitness function is quite dense), the ga outputs an x vector along with an fval, which is supposed to be the fitness function evaluated at this x value. However, when I take the x-vector and input it into the fitness function manually, it returns a value different from the fval.
My ga setup is the following:
%Contraints and function
rng default
FitFcn = @FullDevice;
nvars = 3;
lb = [1,20,5];
ub = [5,100,10];
IntCon = [1];
%optomization algorithm
[x,fval,exitflag] = ga(FitFcn,nvars,[],[],[],[],lb,ub,[],IntCon,[])
As an example, on my most recent optimization, the x and fval output were the following
x =
3.0000 20.0000 5.0333
fval =
-199.1417
But,
> FullDevice([3 20 5.0333])
ans =
-189.8933
Any thoughts as to why this is happening? Thanks!

採用された回答

Stephan
Stephan 2019 年 6 月 13 日
編集済み: Stephan 2019 年 6 月 13 日
you problably are are victim of rounding errors. try:
FullDevice(x)
to use the exact results of x as input for your Fitness function.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Optimization Toolbox についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by