How can I force solutions to be integer for a non linear problem?

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)

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

Please what do you mean by "integer constraints"? Thank you.
"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() ?
Thank you. I am looking at ga() and particleswarm() now. I don't think quadprog() is suitable for my case. I don't have the same form of the objective function that quadprog() requires, unless there is a something I don't understand.
Do you have known covariance between the values? For example could you assume 0 covariance?
No I don't. What could we infer from that otherwise?
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.
Oh ok. It could have simplified it to have the term factor to 1/2 if I got it. Unfortunately I don't have known covariance between the values. I am thinking about changing the objective function by getting rid of the square to have an objective function with absolute value which is still non linear. However I think there is a way to linearize that objective and use the intlinprog solver for MILP to have the binary integers as solutions that I expect to have. Please what do you think this alternative? Does it make sense to you? Is it possible to linearize a function like that and get results from intlinprog?
Any comment for this comment please?
"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.
Ok Thank you.
Going to review it before sending it to you.

Sign in to comment.

1 Comment

I already had a look on that. Thanks Torsten.
The problems are first it just takes up to around 30 integer variables (I have more than that) and secondly it looks like the development language is a bit different than Matlab. I don't really have time for that.
Best, Loic

Sign in to comment.

Asked:

on 8 Feb 2017

Commented:

on 14 Feb 2017

Community Treasure Hunt

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

Start Hunting!