can linprog handle discrete variables

3 views (last 30 days)
allen
allen on 12 Apr 2011
Edited: Bruno Luong on 6 Oct 2020
Let’s say we have x1 and x2 with a linear objective function and linear constraints. Both x1 and x2 are vectors. All variables in x1 are continuous, so there’s no problem. However, each variable in the set x2 is either 0, or a positive number if it’s in the region [L, U], where U>L>>0. Can Matlab's optimization toolbox handle this? Thanks!
  1 Comment
Bruno Luong
Bruno Luong on 6 Oct 2020
Edited: Bruno Luong on 6 Oct 2020
How large is x2?
If it's not (<10) you can solve 2 ^card(x2) continuous LP problems by seeting a subset of x2 as 0s, then select the best solution.

Sign in to comment.

Answers (2)

John D'Errico
John D'Errico on 6 Oct 2020
linprog has NO ability to handle discrete variables. intlinprog, (introduced after this question was asked) can do so, in theory. However, intlinprog cannot handle the discontigous parameter space as you describe it. That would leave you needing a tool like GA (from the global optimization toolbox), which can handle such a problem.

Bruno Luong
Bruno Luong on 6 Oct 2020
Edited: Bruno Luong on 6 Oct 2020
You might try to use INTLINPROG by introducing (integer) slag variables b2 has the same size as x2 but values in {0,1}.
Then add the linear constraints
b2*L <= x2 <= b2*U

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!