% Main function of the algorithm

function [realbsf_value, realbsf, npoints] = GRBFNoptimization(Fconfig);

warning off all

global Dim
global Return_to_domain
global regr

eval(Fconfig)

RBFNinit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% MAIN CYCLE
while (realbsf_value > opt+Prec)&&(npoints<1000)
% while (realbsf_value > opt+Prec)&&(istep<nsteps)
%while (istep<nsteps)
    RBFNcreate
    [ga_value, ga_solution] = GRADEplusCERAFoptimization('Aconfig');
    RBFNupdate
end

output = sprintf('%s.out', Name );
f = fopen(output,'a');
fprintf( f, '%d %g', npoints, realbsf_value );
for i = 1:Dim fprintf( f, ' %g', realbsf(i) ); end
fprintf( f, '\n' );
fclose( f );

%% author: Anicka Kucerova, Czech Technical University in Prague
%% version 0.0.2
%% 17 Sep 2013