3

I have a problem in the following type:

$$\sum_{i∈I}{\max_{j∈J}c_{ij}\cdot x_{j}}$$

For each objective, in a set of $x$ variables, the goal is to select the one with the highest cost coefficient. After obtaining their objective values, we sum them up. Is there any simple way to write this in CPLEX? In minimax or maximax adding a dummy variable would be the way but it does not work in this case as we sum the objectives of multiple problems. However, defining $i$ many problems, solving them seperately and summing their values would be too time consuming. Is there any fast way to do this?

  • 1
    Are the $x$ variables binary, integer, continuous or what? Are there any constraints on the $x$ variables? – prubin Feb 11 '23 at 23:08
  • $x$are binary, single constraint is $\sum x_j=1$ for each problem such that we select a single $x$ with the highest cost coefficient. $x$ could be relaxed to be continuous variable as well. The problem can be thought as $max {c_{11}x_{1}, c_{12}x_{2}, c_{13}x_{3}... c_{1j}x_{j}}+max {c_{21}x_{1}, c_{22}x_{2}, c_{23}x_{3}... c_{2j}x_{j}}+...+max {c_{i1}x_{1}, c_{i2}x_{2}, c_{i3}x_{3}... c_{ij}x_{j}}$ –  Feb 12 '23 at 09:51
  • 2
    If $x_j$ can vary according to $i$, you should instead call it $x_{ij}$. – RobPratt Feb 12 '23 at 15:38

3 Answers3

3

It sounds like you want to maximize $$\sum_i \sum_j c_{ij} x_{ij}$$ subject to \begin{align} \sum_j x_{ij} &=1 &&\text{for all $i$} \\ x_{ij} &\in\{0,1\} &&\text{for all $i$ and $j$} \end{align} The optimal objective value is clearly $\sum_i \max_j c_{ij}$, so you don’t really need to call a solver. If you need to set $x_{ij}=1$ for exactly one largest $c_{ij}$ for each $i$, you can do that with a simple loop over $j$ for each $i$, again without calling a solver. If you insist on calling a solver and don’t want to decompose by $i$, just solve the one big problem directly. There is no need to introduce auxiliary variables or big-M constraints.

RobPratt
  • 32,006
  • 1
  • 44
  • 84
1

Wouldn't know exactly in CPLEX but referring to this answer one way is to define $\theta_i$ and binary variables $z \in \{0,1\}^{I\times J}$as

$ c_{ij}x_j \le \theta_i \le c_{ij}x_ j + M(1-z_{ij}) \ \ \forall j \ \ \forall i$
$ \sum_j z_{ij} = 1 \ \ \forall i$

Then sum up $\sum_i \theta_i$

If $x_j$ is already binary and to be used to indicate the max coefficient then referring to 2nd answer here
Define $\theta_i$ as
$c_{ij}\le \theta_i \le c_{ij} + M(1-x_{ij})\ \ \forall j$
$\sum_j x_{ij}=1 \ \ \forall i $
Then sum up $\sum_i \theta_i$

Sutanu Majumdar
  • 3,461
  • 1
  • 2
  • 11
0

We can use the following identity:

$$\sum_{i \in I}{\max_{j \in J}c_{ij}\cdot x_{j}} = \max_{j_1,\dots,j_{|I|} \in J} \sum_{i \in I} c_{i j_i} \cdot x_{j_i} = \max_{j_1,\dots,j_{|I|} \in J} c_{1 j_1} x_{j_1} + \dots + c_{k j_{|I|}} x_{j_{|I|}}$$

One way to encode this as integer linear programming is to express each $j_i$ as a one-hot vector, e.g., $j_i=1$ corresponds to $(1,0,0,\dots,0)$, $j_i=2$ corresponds to $(0,1,0,\dots,0)$, etc. If we expand that out, we build a matrix $M$ with $|I|$ columns and $|J|$ rows, where $M_{uv}=1$ iff $j_u=v$. Then the objective function becomes

$$\max_M \sum_{u,v} M_{uv} c_{uv} x_v,$$

where the maximization is taken over all zero-or-one matrices $M$ such that $\sum_v M_{uv}=1$ for all $u$.

D.W.
  • 230
  • 1
  • 10