function fun=DefineFunction(name,varargin)

%DefineFunction  Defining the problem by the function name and parameters
%
%PSOfun=DefinePSOFun(name,varargin)
%
% name: function name ('fun') or handle (@fun)
% varargin: as many additional parameters as needed
% fun.fun: handle to the function
% fun.param: cell array with all the additional params
%
% Examples: fun=DefinPSOFun('a'); --> function a without extra param
%           fun=DefinePSOFun(@b,1,[3,2,2],struct('a',1,'c',2) -->
%             function b with 3 extra param
%

% APRENDIZAJE AUTOMÁTICO (G. Pajares y J. M. de la Cruz, Eds.)
% Editorial: RA-MA
% Capítulo 7 y 8: Monte Carlo I y II
% Autores: Eva Besada-Portas, Sergey M. Plis

if ischar(name)
    eval(sprintf('fun.fun=@%s;',name));
elseif isa(name,'function_handle')
    fun.fun=name;
else 
    error('It is not a function');
end
if nargin==1
    fun.param={};
else
    fun.param=varargin;
end