# Broadcast operations with multiple DenseAxisArrays are not yet supported

**URL:** <https://discourse.julialang.org/t/broadcast-operations-with-multiple-denseaxisarrays-are-not-yet-supported/45133>\
**Category:** Optimization (Mathematical)\
**Created:** [August 18, 2020, 12:48am UTC](https://discourse.julialang.org/t/broadcast-operations-with-multiple-denseaxisarrays-are-not-yet-supported/45133 "2020-08-18T00:48:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zlq178](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zlq178/32/17952_2.png) [@zlq178](https://discourse.julialang.org/u/zlq178)\
**Post date:** [August 18, 2020, 12:48am UTC](https://discourse.julialang.org/t/broadcast-operations-with-multiple-denseaxisarrays-are-not-yet-supported/45133/1 "2020-08-18T00:48:54Z")

</div>

```julia
using JuMP,Gurobi
 n=4
 a=[0;0;50;50]
 b=[0;0;351;389]
 c=[0;0;44.4;40.6]
model=Model(Gurobi.Optimizer)
@variable(model, P[1:n,1])#julia中创建一个全参数决策变量的方式
f=@expression(model,a'*(P.*P)+b'*P+sum(c))
@objective(model,min,f)

```

Errors:

 ![e1e94256395bccd09c6edbe3e9cb7c0b132246e9](https://global.discourse-cdn.com/julialang/original/3X/c/e/cecb1b72ade3439364ec895cd1901fb022aa310a.png)  
How can I solve this problem?

---

<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:** [August 18, 2020, 1:58am UTC](https://discourse.julialang.org/t/broadcast-operations-with-multiple-denseaxisarrays-are-not-yet-supported/45133/2 "2020-08-18T01:58:52Z")

</div>

The issue is `P .* P` when `P` is a `DenseAxisArray`.

Option one is to make the variable just a `Array`:

```julia
@variable(model, P[1:n])

```

Here is the documentation: [Variables · JuMP](https://jump.dev/JuMP.jl/v0.21.1/variables/#Variable-containers-1)

Option two is to write out the sum

```nohighlight
@expression(model, sum(a[i] * P[i]^2 for i = 1:n))

```

---

<div class="post-metadata">

**Author:** ![zlq178](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zlq178/32/17952_2.png) [@zlq178](https://discourse.julialang.org/u/zlq178)\
**Post date:** [August 18, 2020, 2:43am UTC](https://discourse.julialang.org/t/broadcast-operations-with-multiple-denseaxisarrays-are-not-yet-supported/45133/3 "2020-08-18T02:43:13Z")

</div>

I get it. Thank you very much.
