0

我正在尝试使用全局优化工具箱在 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] = ...

任何提示都受到高度赞赏。请让我知道,如果你有任何问题。

4

0 回答 0