0

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.

1
  • 1
    You might want to fix your description, since what you have is not a linear program. And if all your variables are binary, then they all need to be listed in the integer constraint. Otherwise it will optimize a linear program, where each of the variables takes on any real value on the closed interval [0, 1]. Commented Mar 12, 2018 at 2:15

1 Answer 1

1

You cannot omit Aeq and Beq if you specify the lower-bound and upper-bound constraints, because this function uses positional parameters.

However, you can pass empty matrices, resulting in zero equality constraints:

x = intlinprog(f,intcon,A,b,[],[],lb,ub);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.