JuliaOpt/JuMP.jl — pull request #142 by IainNZ (2014-03-20 02:45:09+00:00)
Title: Clamp floats to ints

A proposal, with two different stages:

```julia
using JuMP

m = Model()

@defVar(m, 0 <= foo[i=1:3] <= i)
@defVar(m, bar >= 2.0)
@defVar(m, MILES <= 6.3)

@setObjective(m, Max, sum{2^i * foo[i], i=1:3})
@addConstraint(m, MILES + bar + foo[1] <= 3.0)
addConstraint(m, 3.0*bar*bar + 1.57*bar*foo[2] >= 2.0)

println(m)
```

## Original
```
Max 2.0 foo[1] + 4.0 foo[2] + 8.0 foo[3]
Subject to
1.0 MILES + 1.0 bar + 1.0 foo[1] <= 3.0
3.0*bar^2 + 1.57 foo[2]*bar - 2.0 >= 0
0.0 ≤ foo[1] ≤ 1.0
0.0 ≤ foo[2] ≤ 2.0
0.0 ≤ foo[3] ≤ 3.0
bar ≥ 2.0
MILES ≤ 6.3
```

## Phase 1 - clamp to ints if possible
```
Max 2 foo[1] + 4 foo[2] + 8 foo[3]
Subject to
1 MILES + 1 bar + 1 foo[1] <= 3
1.57 foo[2]*bar + 3 bar² - 2 >= 0
0 ≤ foo[1] ≤ 1
0 ≤ foo[2] ≤ 2
0 ≤ foo[3] ≤ 3
bar ≥ 2
MILES ≤ 6.3
```

## Phase 2 - 1 to nothing
```
Max 2 foo[1] + 4 foo[2] + 8 foo[3]
Subject to
MILES + bar + foo[1] <= 3
1.57 foo[2]*bar + 3 bar² - 2 >= 0
0 ≤ foo[1] ≤ 1
0 ≤ foo[2] ≤ 2
0 ≤ foo[3] ≤ 3
bar ≥ 2
MILES ≤ 6.3
```