How can I force solutions to be integer for a non linear problem?
Show older comments
Hi. I am currently working on a project that requires me to minimize the variance of some variables. The objective is to find the best configuration where the variance is minimal. As the project consists in resource allocation, I would like at the end to have the results variables that are binary integers, equal either to zone (if there is an allocation) or zero (otherwise). The objective therefore is non linear. However the constraints that I have are linear. The problem seems then to be a NLP problem with only binary integers as solutions. We can assume that it is a MINLP. I am using the solver fmincon of the optimization toolbox to solve it with lb=0 and up=1. But some of the solutions are real and not integer. Please is there anything to do to force the solver to give only binary solutions? If no, how can I handle that?
Answers (2)
Walter Roberson
on 8 Feb 2017
0 votes
No, fmincon cannot be made to use integer constraints.
It is sort of possible to use patternnet for integer constraints.
ga and particleswarm can use integer constraints.
10 Comments
Loic Biakeu
on 8 Feb 2017
Walter Roberson
on 8 Feb 2017
"binary integers", restricted to 1 and 0, are a special case of restricting to integer values. Restricting to integer values is known as "integer constraints".
ga() and particleswarm can be restricted to integers (and so to binary). fmincon() cannot be restricted to integers (and so cannot be restricted to binary).
You mention that you need to minimize the variance of some variables. I wonder if you could program that using quadprog() ?
Loic Biakeu
on 9 Feb 2017
Walter Roberson
on 9 Feb 2017
Do you have known covariance between the values? For example could you assume 0 covariance?
Loic Biakeu
on 10 Feb 2017
Walter Roberson
on 10 Feb 2017
Variance involves sum of squares of the values together with sum of products of the variable pairs. When covariance of the variables is 0, then the products of the pairs can be modeled as 0 for the variance formula, if I understand correctly. That would leave sum of squares, and that might be what you get from the first term of the quadprog() formula.
Loic Biakeu
on 10 Feb 2017
Loic Biakeu
on 13 Feb 2017
Walter Roberson
on 13 Feb 2017
"Does it make sense to you?"
No. I cannot think of any way to linearize that.
However, if you could post some sample data, and post code that you might use with fmincon "if only fmincon could declare a variable to be integer-valued", then I could have a look to see if anything came to mind.
Loic Biakeu
on 14 Feb 2017
Torsten
on 8 Feb 2017
Edited: Walter Roberson
on 8 Feb 2017
0 votes
Maybe
https://de.mathworks.com/matlabcentral/fileexchange/35720-minlp--mixed-integer-nonlinear-programming
is of help.
Best wishes
Torsten.
1 Comment
Loic Biakeu
on 8 Feb 2017
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!