# Specifying datatype in JuMP expressions and constraints to save memory

**URL:** <https://discourse.julialang.org/t/specifying-datatype-in-jump-expressions-and-constraints-to-save-memory/66515>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [August 16, 2021, 9:40pm UTC](https://discourse.julialang.org/t/specifying-datatype-in-jump-expressions-and-constraints-to-save-memory/66515 "2021-08-16T21:40:24Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [August 26, 2021, 5:19am UTC](https://discourse.julialang.org/t/specifying-datatype-in-jump-expressions-and-constraints-to-save-memory/66515/12 "2021-08-26T05:19:55Z")

</div>

> [@anon94806364](#):
>
> hundreds of thousands of quadratic constraints

You may be able to reformulate as a linear program, or at least a linearly-constrained one. This may not help the memory by added even more objects, but it may help the solver.

Since `r_i_j` and `y_i_k` are binary variables, their product can be replaced with an additional variable and four sparse inequalities. This is the McCormick envelope, but enforcing binary variables means it is an exact reformulation (e.g. cf. [https://optimization.mccormick.northwestern.edu/index.php/McCormick\_envelopes](https://optimization.mccormick.northwestern.edu/index.php/McCormick_envelopes)).

Setting x = ry, with r and y binary variables, we can replace any instance of ry with x and add the following:

x \geq 0 \\ x \geq r + y -1 \\ x \leq r \\ x \leq y \\

> [@anon94806364](#):
>
> `sum(r_i_j[i, j] * y_i_k[i, k] * s_j_k[j, k] for j in 1:J) >= T1 * y_i_k[i, k]`

Also, I may be missing something, but could you not cancel or remove `y_i_k[i, k]` in the above constraint anyway since it does not depend on the index of summation?

---

_[View the full topic](https://discourse.julialang.org/t/specifying-datatype-in-jump-expressions-and-constraints-to-save-memory/66515)._
