Search code examples
rminimizationinteger-programming

Mixed Integer Linear Programming in R


I'm looking to solve problems of the form in R:

enter image description here

where

enter image description here

and

enter image description here

is an indicator function that equals 1 if the argument (.) is true and zero otherwise.

I've looked into packages lpSolve, Rcplex, and crs but I couldn't quite grasp how I would place my problem into the functions offered by those packages. I don't really know how I would incorporate my indicator functions in the objective. I thought about making my controls the binary W's themselves but then I would have to provide the lambdas (weights), however, my interest is finding the optimal combination of lambdas, and not the W's.


Solution

  • You basically want

    z<=r => w=1
    

    This can be written as

    w=0 => z>r
    

    or

    z >= r + 0.001 - M*w
    

    where M is a large enough constant (but preferably not too large). Some solvers like Cplex and Gurobi have indicator constraints: this way the last implication can be expressed directly without resorting to a big-M formulation.