0

我正在尝试使用 Koert Kuipers 的 matlab 代码进行分支和绑定:BNB20。我不断得到

' Error using mofitness (line 4)
Not enough input arguments.'

'Error in bnbmo (line 37)
[errmsg,Z,X,t,c,fail]=...'

这是主代码下方带有 mofitness 功能的主脚本:

%% GAMULTIOBJ with integer constraints
%
% BRANCH-AND-BOUND BMB20
%% Data import
workbookFile = 'Book1.xlsx';
sheetName = 'Aeq';
range = 'B4:WC111';
Aeqdata = Aeqimport(workbookFile, sheetName, range);
beqsheet = 'beq';
startRow = 1;
endRow = 108;
beqdata = beqimport(workbookFile, beqsheet,startRow, endRow); 

%% Problem setup
P1 = 2; % the weight applied to hard constraints
P2 = 0.2; % the weight applied to soft constraints
fun = @mofitness;  % Function handle to the fitness function
numberOfVariables = 600;   % Number of decision variables

x0 = zeros(600,1);
xstatus(1:600) = 1; % 0 for continuous, 1 for integer, 2 for fixed

% Constraints
A = [];
B = [];
Aeq = Aeqdata;
Beq = beqdata;

nonlcon = @nonlconmo;

% Bound Constraints
xlb = zeros(1,numberOfVariables);       % Lower bound
xub = ones(1,numberOfVariables);         % Upper bound

%% Solve the problem with integer constraints
[errmsg,Z,X,t,c,fail]=...
    BNB20(fun,x0,xstatus,xlb,xub,A,B,Aeq,Beq,nonlcon,0,[],P2,P1)

功能适应性:

function mo = mofitness(x,P2,P1);
P2 = 0.2;
P1 = 2;
mo = P2*(sum(x(11:10:521)) -P1) + P2*(sum(x(12:10:522)) -P1)+ P2*(sum(x(13:10:523)) -P1)...
+ P2*(sum(x(14:10:524)) -P1)+ P2*(sum(x(15:10:525)) -P1)+ P2*(sum(x(16:10:526)) -P1)...
+ P2*(sum(x(17:10:527)) -P1)+ P2*(sum(x(18:10:528)) -P1)+ P2*(sum(x(19:10:529)) -P1)...
+ P2*(sum(x(20:10:530)) -P1);
end

希望有人可以帮助我,谢谢。

4

0 回答 0