I am trying to use Koert Kuipers' matlab code for branch and bound: BNB20. I keep getting
' Error using mofitness (line 4)
Not enough input arguments.'
'Error in bnbmo (line 37)
[errmsg,Z,X,t,c,fail]=...'
Here is the main script with the mofitness function below the main code:
%% 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 mofitness:
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
Hope someone can help me, thanks.