%%use:   >> matlabpool open 2
matlabpool open 2                   % only at start
% matlabpool close                  % at end
%% Solving an optimization problem
%% Setup
% constr1:  -a <= x(4) -x(3) <= a;
A=[0 0 -1 1; 0 0 1 -1]; b=[0.55; 0.55];
Aeq = []; beq =[];
lb=[0; 0;   -0.55; -0.55];
ub=[1200; 1200;   0.55; 0.55];
x0=zeros(4,1);

ExpObjFun = @myExpObj;
NonlinconstraintsFun = @myExpNLCon;

%% Boring SERIAL Soluton Method
  % Solve problem using fmincon without fmincon without parallel computing

options=optimset('Display','iter','Algorithm','active-set'); %first try
%options = optimset(options,'UseParallel','Always'); % second parallel try

tic

x=fmincon(ExpObjFun,x0,A,b,Aeq,beq,lb,ub,...
     NonlinconstraintsFun,options);

tBasee = toc               % to time first try
%tParallel = toc             % to time second parallel try
%[tBasee tParallel]



%matlabpool close
