Iteration limit / evaluation limit problem with GlobalSearch
Show older comments
I have the following. My problem works fine for up to n=20, then for greater n i get error for max iterations or max evaluation. How can I fix the code so I can compute for higher n? I have already tried with including the parameter 'MaxEvaluation' inside optimoptions, but I cant make it work. I atleast want to compute high n's enough so I can get an ouput less than 5. I'd appreciate any help.
n=20;
B=50;
H=30;
lb=zeros(2*n+1,1);
ub=zeros(2*n+1,1);
for i=1:n
ub(2*i-1)=B;
ub(2*i)=H;
end
ub(2*n+1)=sqrt(B^2+H^2);
X0=rand(2*n+1,1);
for i=1:n
X0(2*i-1)=B*X0(2*i-1);
X0(2*i)=H*X0(2*i);
end
X0(2*n+1)=0;
%X0(2*n+1)=sqrt(min(-minDistances(X0)));
fun=@(X)-X(end)^2;
opts=optimoptions('fmincon','Algorithm','interior-point');
%fun=@funWithGrad;
%opts=optimoptions('fmincon','Algorithm','interior-point','GradObj','on');
problem=createOptimProblem('fmincon','objective',fun,'x0',X0,...
'lb',lb,'ub',ub,'nonlcon',@minDistances,'options',opts);
X=run(GlobalSearch,problem);
disp(X(end));
figure('DefaultAxesFontSize',18);
plot(X(1:2:2*n),X(2:2:2*n),'k.','MarkerSize',20);
viscircles([X(1:2:2*n),X(2:2:2*n)],X(end)/2*ones(n,1),'LineStyle','--');
axis([0 B 0 H]);
title(['Arrangement of ',num2str(n),' tables in the blue hall']);
Accepted Answer
More Answers (0)
Categories
Find more on Global or Multiple Starting Point Search in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!