Matlab's MultiStart runs fine, but GlobalSearch bugs out

조회 수: 3 (최근 30일)
Anthony
Anthony 2013년 7월 3일
I'm trying to run a global optimization in Matlab using the global optimization toolbox. I am using the fmincon local optimizer as an input. I am able to successfully run the fmincon local optimizer, as well as the MultiStart global optimizer with this problem. However, when I try to set it up as a GlobalSearch, I get an error message.
Below is the code I am trying to use for the GlobalSearch:
%the functions is f(w) rather than f(x)
%constraints:
A = [1,0,0; 0,1,0; 0,0,1];
b = [.80, .80, .80];
Aeq = [1 1 1];
beq = 1;
lb = .10 * [1 1 1];
ub = .8 * [1 1 1];
w = [weight1, weight2, weight3];
wstart = randn(3,1);
options = optimset('Algorithm','interior-point');
% function handle for the objective function (note that variables
% aa through hh are additional parameters that the solver does not modify):
h = @(w)Difference_in_Returns(w(1),w(2),w(3), aa, bb, cc, dd, ee, ff, gg, hh);
% problem structure:
problem = createOptimProblem('fmincon','x0',wstart,'objective',h,'Aineq',A,...'
'bineq',b,'Aeq',Aeq,'beq',beq,'options',options,'lb',lb,'ub',ub);
gs = GlobalSearch;
run(gs,problem)
When I try to run this, Matlab bugs out and prints:
Error using -
Matrix dimensions must agree.
Error in C:\Program Files\MATLAB\R2012a\toolbox\globaloptim\globaloptim\private\
globalsearchnlp.p>i_calcConstrViolation (line 593)
Error in C:\Program Files\MATLAB\R2012a\toolbox\globaloptim\globaloptim\private\
globalsearchnlp.p>i_calcPenalty (line 627)
Error in C:\Program Files\MATLAB\R2012a\toolbox\globaloptim\globaloptim\private\
globalsearchnlp.p>globalsearchnlp (line 343)
Error in GlobalSearch/run (line 330)
[x,fval,exitflag,output] = ...
Error in Optimization_Setup (line 62)
run(gs,problem)
I believe the problem is outlined by the lines:
Error using -
Matrix dimensions must agree.
Error in GlobalSearch/run (line 330)
[x,fval,exitflag,output] = ...
Any tips are highly appreciated. Please let me know if you have any questions.

채택된 답변

Shashank Prasanna
Shashank Prasanna 2013년 7월 3일
Can you confirm that the objective function: h does not return Inf or NaN during its evaluations for all w?
Also in MultiStart how many runs are you specifying?
>> [x,f] = run(ms,problem,k)
Does it fail if you make k large?
  댓글 수: 2
Anthony
Anthony 2013년 7월 3일
편집: Anthony 2013년 7월 3일
Thank you for your response.
Is there a way to verify whether an Inf or NaN for the objective function is the source of the problem (in other words: could I find out what value for w GlobalSearch is trying to use right before the error)? I would be very surprised if the function returned either of those values though...
I run MultiStart with 500 randomly generated start points. This takes about 4 minutes to run. How large should I be trying?
Shashank Prasanna
Shashank Prasanna 2013년 7월 3일
You must know if the objective function has a possibility of returning an inf or a nan. If not you can always check of the output using isinf and isnan functions.
In order to obtain intermediate values you can use outputfcn:
The only reason I mentioned that you use a large enough start points is to verify if MultiStart would fail if it stepped on that special case that is making globalsearch fail.
One last point:
You have redundant constraints:
A = [1,0,0; 0,1,0; 0,0,1];
b = [.80, .80, .80];
is basically: x_i < 0.8 for i = 1,2,3
lb = .10 * [1 1 1];
ub = .8 * [1 1 1];
is basically: 0.1 < x_i < 0.8 for i = 1,2,3
Just use the bound constraints. Don't use both.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Global or Multiple Starting Point Search에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by