Matlab's MultiStart runs fine, but GlobalSearch bugs out
1 view (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Shashank Prasanna
on 3 Jul 2013
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 Comments
Shashank Prasanna
on 3 Jul 2013
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.
More Answers (0)
See Also
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!