I'm having trouble defining my optimization problem in MATLAB.
I'm trying to express 7 binary decision variables. but the sum of the first 3 binary decsion varibles cannot be greater than1, and the sum of the last 4 binary decision variables cannot be greater than 1.
A = [1,1,1,0,0,0,0;...
0,0,0,1,1,1,1];
b = [1;1];
% objective function
f = [0.1, 0.5, 0.2, 0.2, -2.0, 0.2, 0.6];
lb = zeros(7,1);
ub = ones(7,1); % Enforce all of the decision variables to be binary
intcon = []; % all of my variables are binary, so I assume this should be blank.
x = intlinprog(f,intcon,A,b,lb,ub);
I want to Enforce all of the decision variables to be binary, so I included these lines:
lb = zeros(7,1);
ub = ones(7,1); % Enforce all of the decision variables to be binary
intcon = []; % all of my variables are binary, so I assume this should be blank.
Also, I have no equality constraints, so I did not include Aeq and beq in the problem above. but when I try to run the solver without those parameters likex = intlinprog(f,intcon,A,b,lb,ub); it tells me
Error using intlinprog (line 123)
The number of columns in Aeq must be the same as the number of elements of f.
But if I do not have any equality constraints, how am I supposed to define this?
Here is the documentation: https://www.mathworks.com/help/optim/ug/intlinprog.html#bts3gkc-2
The example at the top of the page shows that it can call x = intlinprog(f,intcon,A,b) without using Aeq and beq, so I know it is possible.
thanks.