Adding the number of unique decision variables in the objective function.

174 Views Asked by At

In a linear program formulation, my objective function requires to add the number of unique decision variable it took. (in my original problem, unique decision variable may reduce cost).

Let's say I have 3 decision variables $x_1, x_2, x_3$. They are all integers and between 1 to 5.

The objective function will be:

$$ min\ ax_1+bx_2+cx_3 + D $$

Here I need this term $D$ to add the number of unique decision variable. For example, if we are checking $3,5,4$ as $x_1, x_2, x_3$ then $D = 3$. However for $3,4,4$, $D$ will be 2.

Is there any way I can incorporate this in my objective function?

1

There are 1 best solutions below

3
On BEST ANSWER

For $i\in\{1,2,3\}$ and $j\in\{1,\dots,5\}$, let binary variable $y_{i,j}$ indicate whether $x_i=j$. For $j \in \{1,\dots,5\}$, let binary variable $z_j$ indicate whether $x_i=j$ for some $i$. The problem is to minimize $$a x_1 + b x_2 + c x_3 + \sum_{j=1}^5 z_j$$ subject to linear constraints \begin{align} \sum_j y_{i,j} &= 1 &&\text{for all $i$} \\ \sum_j j y_{i,j} &= x_i &&\text{for all $i$} \\ y_{i,j} &\le z_j &&\text{for all $i$ and $j$} \end{align}