Different Output value of Functions
function f_value = test_function(Solution)
% Beale function test functions
Implementation 1
x=Solution(1);
y=Solution(2);
f_value = (1.5- x+ x*y)^2 + (2.25 – x + x*y^2)^2 + (2.625 -x + x*y^2)^2;
% Optimal at f(3,0.5) = 0
%% Implementation 2
% x1 = Solution(1);
% x2 = Solution(2);
%
% term1 = (1.5 – x1 + x1*x2)^2;
% term2 = (2.25 – x1 + x1*x2^2)^2;
% term3 = (2.625 – x1 + x1*x2^3)^2;
%
% f_value = term1 + term2 + term3;
end
Hi, I have a test function for testing my optimization algorithm. These two implementations are same but they are generating different f_value for the same solution value. For example. for Solution [-3.3381,0.1668], Implementation1 generates f_value of 82.9832 whereas Imp2 generates 83.8981. I am unable to find the reason. This small difference is making huge difference and with imp1. Optimization algorithm doesnot converge to global solution. However, with imp2 it converges to global solution. Any help would be appreciated.function f_value = test_function(Solution)
% Beale function test functions
Implementation 1
x=Solution(1);
y=Solution(2);
f_value = (1.5- x+ x*y)^2 + (2.25 – x + x*y^2)^2 + (2.625 -x + x*y^2)^2;
% Optimal at f(3,0.5) = 0
%% Implementation 2
% x1 = Solution(1);
% x2 = Solution(2);
%
% term1 = (1.5 – x1 + x1*x2)^2;
% term2 = (2.25 – x1 + x1*x2^2)^2;
% term3 = (2.625 – x1 + x1*x2^3)^2;
%
% f_value = term1 + term2 + term3;
end
Hi, I have a test function for testing my optimization algorithm. These two implementations are same but they are generating different f_value for the same solution value. For example. for Solution [-3.3381,0.1668], Implementation1 generates f_value of 82.9832 whereas Imp2 generates 83.8981. I am unable to find the reason. This small difference is making huge difference and with imp1. Optimization algorithm doesnot converge to global solution. However, with imp2 it converges to global solution. Any help would be appreciated. function f_value = test_function(Solution)
% Beale function test functions
Implementation 1
x=Solution(1);
y=Solution(2);
f_value = (1.5- x+ x*y)^2 + (2.25 – x + x*y^2)^2 + (2.625 -x + x*y^2)^2;
% Optimal at f(3,0.5) = 0
%% Implementation 2
% x1 = Solution(1);
% x2 = Solution(2);
%
% term1 = (1.5 – x1 + x1*x2)^2;
% term2 = (2.25 – x1 + x1*x2^2)^2;
% term3 = (2.625 – x1 + x1*x2^3)^2;
%
% f_value = term1 + term2 + term3;
end
Hi, I have a test function for testing my optimization algorithm. These two implementations are same but they are generating different f_value for the same solution value. For example. for Solution [-3.3381,0.1668], Implementation1 generates f_value of 82.9832 whereas Imp2 generates 83.8981. I am unable to find the reason. This small difference is making huge difference and with imp1. Optimization algorithm doesnot converge to global solution. However, with imp2 it converges to global solution. Any help would be appreciated. function value, different output MATLAB Answers — New Questions