# How to formulate a complex JuMP variable array

**URL:** https://discourse.julialang.org/t/how-to-formulate-a-complex-jump-variable-array/24222
**Category:** General Usage
**Tags:** jump, optimization
**Created:** [May 14, 2019, 11:01pm UTC](https://discourse.julialang.org/t/how-to-formulate-a-complex-jump-variable-array/24222 "2019-05-14T23:01:00Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [May 15, 2019, 1:39am UTC](https://discourse.julialang.org/t/how-to-formulate-a-complex-jump-variable-array/24222/2 "2019-05-15T01:39:09Z")

</div>

Please search discourse for existing issues. This question has been asked.

> [@How Define a Complex JuMP Variable](https://discourse.julialang.org/t/how-define-a-complex-jump-variable/14362):
>
> How can this be done? I remember there was a Complex128 syntax or something, but i couldn’t find how to use it in a JuMP variable. Here’s my problem, assume i already have the values of Rf, Xlf and Xcf: Nt = 2; hmax = 5; @variable(m, y5[i = 1:Nt,h = 3:2:hmax]) @NLconstraint(m , con8[i = 1:Nt, h = 3:2:hmax], y5[i,h] == 1/(Rf[i]+im\*(h\*Xlf[i]-Xcf[i]/h))) I got this error: ERROR: LoadError: InexactError() Stacktrace: [1] convert at .\complex.jl:31 [inlined] [2] push!(::Array{Float64,1}, ::Comp…

JuMP cannot handle complex variables. You need to add two variables: one for the real and one for the imaginary part.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-formulate-a-complex-jump-variable-array/24222)._
