我正在尝试使用全局优化工具箱在Matlab中运行全局优化。我使用fmincon
本地优化器作为输入。我能够成功运行fmincon
本地优化器以及此问题的MultiStart
全局优化器。但是,当我尝试将其设置为GlobalSearch
时,我收到一条错误消息。
以下是我尝试用于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)
当我尝试运行时,Matlab会出错并打印出来:
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)
我认为问题的概述是:
Error using -
Matrix dimensions must agree.
Error in GlobalSearch/run (line 330)
[x,fval,exitflag,output] = ...
任何提示都非常感谢。如果您有任何问题,请与我们联系。