0
$\begingroup$

I have two vectors, one contains a series of integer values, the other contains a set of binary values.

Vector 1; integer values

Vector 2; binary values

In an integer programming formulation, how do I correctly represent the sum of the binary rows (which represent a value in Vector 1), where the Value in the binary vector is 1?

Example:

Vector 1:

2 4 5 2 5
7 3 1 2 3

Vector 2:

1 0 1 0 1
1 0 1 1 1

So the sum or row 1 in Vector 2 is 12, the sum of row 2 is 13. I need to represent this somehow but I'm not entirely sure how.

  • 0
    Do you have an example of what you mean? I'm not quite understanding what you want done, and I may have an answer if more details are given.2017-01-11
  • 0
    Thanks @SeanRoberson, I've updated the question. Apologies if this is vague, it really isn't my realm.2017-01-11

2 Answers 2

1

Let's call the ranges as follows: the first row of vector 1 will be A1:A5, the second row B1:B5, the first row of vector 2 C1:C5, and the second row D1:D5. The use of SUMPRODUCT is easy. Just use =SUMPRODUCT(A1:A5, C1:C5), similarly for the other one.

  • 0
    I've used SUMPRODUCT in my solution. I'm attempting to represent this in a formulation though.2017-01-11
  • 0
    Indicator functions may be useful then. $\chi_S (x)$ returns 1 is $x \in S$, zero otherwise. I don't know what sort of formulation you want.2017-01-11
0

I can suggest a MIP formulation. Let $x_i$ be the vector of binary variables (i.e. $x_i \in \{0,1\}$), and let $y_i \in \{0,\dots,U_i\}$ be your integer variable. Basically you want: $$\begin{align} &z_i = y_i \cdot y_i\\ &v = \sum_i z_i\end{align}$$ The product $z_i=y_i\cdot x_i$ is nonlinear but this can be linearized as follows: $$\begin{align} &0 \le z_i \le U_i x_i\\ &y_i-(1-x_i)U_i \le z_i \le y_i \end{align}$$