# A problem with JuMP variable defined

**URL:** <https://discourse.julialang.org/t/a-problem-with-jump-variable-defined/79365>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [April 12, 2022, 3:59am UTC](https://discourse.julialang.org/t/a-problem-with-jump-variable-defined/79365 "2022-04-12T03:59:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahon](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mahon](https://discourse.julialang.org/u/mahon)\
**Post date:** [April 12, 2022, 3:59am UTC](https://discourse.julialang.org/t/a-problem-with-jump-variable-defined/79365/1 "2022-04-12T03:59:58Z")

</div>

![image](https://global.discourse-cdn.com/julialang/original/3X/e/5/e5f650b120383449e17902d3b178240cba7d02f1.png)

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/d/3db4de1823313d32f39f8bbe15a96ea3e381a55e.png)  
i want constraint my variable Pg , how can i do?

---

<div class="post-metadata">

**Author:** ![hdavid16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hdavid16/32/11531_2.png) [@hdavid16](https://discourse.julialang.org/u/hdavid16)\
**Post date:** [April 12, 2022, 4:22am UTC](https://discourse.julialang.org/t/a-problem-with-jump-variable-defined/79365/2 "2022-04-12T04:22:54Z")

</div>

You currently can’t do this. You need to use indexed definitions or set the bounds after creating the variable

[https://github.com/jump-dev/JuMP.jl/issues/2944](https://github.com/jump-dev/JuMP.jl/issues/2944)

---

<div class="post-metadata">

**Author:** ![ccoffrin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ccoffrin/32/400_2.png) [@ccoffrin](https://discourse.julialang.org/u/ccoffrin)\
**Post date:** [April 13, 2022, 6:06pm UTC](https://discourse.julialang.org/t/a-problem-with-jump-variable-defined/79365/4 "2022-04-13T18:06:46Z")

</div>

Side note: It looks like you are developing an AC OPF model. These reference implementations may be of interest,

[https://github.com/lanl-ansi/PowerModelsAnnex.jl/tree/master/src/model](https://github.com/lanl-ansi/PowerModelsAnnex.jl/tree/master/src/model)

[https://github.com/lanl-ansi/rosetta-opf](https://github.com/lanl-ansi/rosetta-opf)
