# Declaring large number of variables in JuMP

**URL:** <https://discourse.julialang.org/t/declaring-large-number-of-variables-in-jump/105214>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [October 20, 2023, 4:56am UTC](https://discourse.julialang.org/t/declaring-large-number-of-variables-in-jump/105214 "2023-10-20T04:56:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josa9321](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josa9321/32/12170_2.png) [@Josa9321](https://discourse.julialang.org/u/Josa9321)\
**Post date:** [October 20, 2023, 4:56am UTC](https://discourse.julialang.org/t/declaring-large-number-of-variables-in-jump/105214/1 "2023-10-20T04:56:01Z")

</div>

Hi people,

Is it expected for this code to utilize such a significant amount of memory, given the following Julia code that defines variables within a JuMP optimization model?

```julia
using JuMP, CPLEX
m = Model(CPLEX.Optimizer)
@variable(m, x[1:1000, 1:1000, 1:6, 1:60])

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/7/a719a710e53c28a3e5daf324db24dc8fb199a92c.png)

Is there anything that I could do to try to solve this version of the problem with this amount of variables?

---

<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:** [October 20, 2023, 5:41am UTC](https://discourse.julialang.org/t/declaring-large-number-of-variables-in-jump/105214/2 "2023-10-20T05:41:48Z")

</div>

So this has `6 * 60 * 1000^2 = 360,000,000` i.e. 3.6 x 10^8 variables (and this even without constraints!).

To quote Oscar:

> [@Largest number of variables that SCS.jl can handle](https://discourse.julialang.org/t/largest-number-of-variables-that-scs-jl-can-handle/100929/11):
>
> As a general rule of thumb, I tend to think of problems with \<10^4 variables as easy, 10^5 as getting a bit hard, 10^6 as hard, and 10^7 as very hard. 10^8 as nigh impossible.
> 
> Why is the problem so large? What are you modeling? Have you looked at ways to simplify the problem?

> [@Josa9321](#):
>
> Is there anything that I could do to try to solve this version of the problem with this amount of variables?

There is not much to say without a model formulation (and unlikely to be solvable without a commercial solver and a lot more RAM in your machine.)
