# How to formulate variance minimization as a mixed integer quadratic program

I have a mixed integer quadratic problem and my objective function is as follows

$$\arg \min \operatorname{Var}(f(x),g(x)) + \operatorname{Var}(c(x),d(x)) + \cdots$$

where $f$, $g$, $c$ $d$ are linear functions and $Var$ indicates variance and $x$ is a vector of 3000 binary variables.

If I want to solve the problem with mixed integer quadratic solver in gurobi I have to define it in the following form:

$$\ x^T Q x + q^T x$$

as the problem is defined in a high level format and there are large set of variables and coefficients , I have no idea how to extract $Q$ and $q$

• Is this question related to the others you have written lately? – nicoguaro Aug 31 '15 at 19:15
• yes it is ! I'm looking into different toolboxes and different methods of modeling the problem – sarah daneshvar Aug 31 '15 at 23:31
• You should notice that most of them are not complete questions. Instead of posting several questions please take the time to describe each question. Pay attention to comments and improve the text, otherwise is difficult for people to help you. – nicoguaro Aug 31 '15 at 23:34
• Also, instead of writing multiple similar question, it might be better to ask a single "high-level" question about the problem you want to solve, where you describe the problem and what you need in a solution in detail. – Christian Clason Sep 1 '15 at 10:10

As answered elsewhere, for MATLAB you have things like CVX and YALMIP. In YALMIP, you would solve using something like (assuming you have defined function f and g)

x = binvar(n,1);
objective = var(f(x),g(x)) + ...
optimize([],objective)


A suitable solver will be called (if f and g are linear operators it is a MIQP and if Gurobi is installed and visible on path it will be used)

If you simply want to export the numerical data ($Q$ etc), you could do

export([],objective,sdpsettings('solver','gurobi'))


Note though, a MIQP with 3000 variables can easily be completely intractable for any solver.