function [X,FVAL]=RunGa(Xobs,Yobs,Zobs,Uxoss,Uyoss,Uzoss,ForwardModel,RangeParameters,MaxGenerations,PopulationSize,ni) % Inversion algorithm % Range of values of the parameters that define the source Nvar=length(RangeParameters); % number of the parameters to invert lb=RangeParameters(1,:); ub=RangeParameters(2,:); % options = optimoptions('ga','UseParallel', true,'PlotFcn','gaplotbestf','MaxGenerations',MaxGenerations,'PopulationSize',PopulationSize); options = optimoptions('ga','UseParallel', true,'MaxGenerations',MaxGenerations,'PopulationSize',PopulationSize); [X,FVAL,EXITFLAG] = ga(@(x)objfuncGA(x,Xobs,Yobs,Zobs,Uxoss,Uyoss,Uzoss,ForwardModel,ni),Nvar,[],[],[],[],lb',ub',[],options);