1

I have a linear optimization problem with integer variables of the form

minimize $a_1 x_1 + ... + a_n x_n$

under a set of constraints

  • Bounds for each variable $a_i \le constant_i$
  • Bounds for groups $ a_{j1} + ... + a_{jk} \le constant_j$

Which R package lpSolve solves nicely even though its quite large.

But now I realized I need to add a constant cost term to the cost-function for each $x_i$ which is non zero.

Question: Is there a trick to minimize a cost-function with terms of the form $a_1 x_1 + f(a_1) + ... + a_n x_n + f(a_n)$ where

$f(x)={0.1 \text{ if } x>0\text{, and }0\text{ otherwise}} $

as if it were truely linear?

Beginner
  • 347

1 Answers1

1

Introduce binaries $z_i$, add the constraints $a_i \leq constant_i z_i$, and add $0.1\sum z_i$ to the objective.

Johan Löfberg
  • 9,497
  • 1
  • 15
  • 15