# Float64 and binary variables in constraints

**URL:** https://discourse.julialang.org/t/float64-and-binary-variables-in-constraints/11961
**Category:** Optimization (Mathematical)
**Created:** [June 26, 2018, 11:45am UTC](https://discourse.julialang.org/t/float64-and-binary-variables-in-constraints/11961 "2018-06-26T11:45:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mm0063](https://avatars.discourse-cdn.com/v4/letter/m/74df32/32.png) [@mm0063](https://discourse.julialang.org/u/mm0063)
#### Post date: [June 26, 2018, 11:45am UTC](https://discourse.julialang.org/t/float64-and-binary-variables-in-constraints/11961/1 "2018-06-26T11:45:34Z")

</div>

Hi all,

My problem formulation consists of float64 parameters and variables and binary variables:

using JuMP  
using Mosek

M = 1000.0;  
@variable(m, y\_connect2[t in ts, cg in cgs, lt in lts], Bin)  
@variable(m, x\_connect22[t in ts, cg in cgs, lt in lts] \>= 0.0)

These parameters and variables are used in following constraint:  
@constraint(m, aux\_connect5[t in ts, cg in cgs, lt in lts], 0.0 \<= x\_connect22[t,cg,lt] \<= M\*y\_connect2[t,cg,lt] )

Which results in following error  
In @constraint(m,aux\_connect5[t in ts, cg in cgs, lt in lts],0.0 \<= x\_connect22[t, cg, lt] \<= (Expr(:escape, :M)) \* (Expr(:escape, :(y\_connect2[t, cg, lt])))): Expected M \* y\_conne  
ct2[t, cg, lt] to be a Float64.

Does anyone have an idea about how this error can be solved?

Thanks in advance!

Best regards

---

<div class="post-metadata">

### Author: ![abelsiqueira](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abelsiqueira/32/47269_2.png) [@abelsiqueira](https://discourse.julialang.org/u/abelsiqueira)
#### Post date: [June 26, 2018, 11:55am UTC](https://discourse.julialang.org/t/float64-and-binary-variables-in-constraints/11961/2 "2018-06-26T11:55:44Z")

</div>

Try removing 0.0 \<= from the constraint.

---

<div class="post-metadata">

### Author: ![mm0063](https://avatars.discourse-cdn.com/v4/letter/m/74df32/32.png) [@mm0063](https://discourse.julialang.org/u/mm0063)
#### Post date: [June 27, 2018, 8:20am UTC](https://discourse.julialang.org/t/float64-and-binary-variables-in-constraints/11961/3 "2018-06-27T08:20:46Z")

</div>

Thank you very much!
