# Silly question regarding vectorized syntax \[JUMP\]

**URL:** https://discourse.julialang.org/t/silly-question-regarding-vectorized-syntax-jump/62853
**Category:** Optimization (Mathematical)
**Tags:** question, jump
**Created:** [June 13, 2021, 11:44pm UTC](https://discourse.julialang.org/t/silly-question-regarding-vectorized-syntax-jump/62853 "2021-06-13T23:44:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jameli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jameli/32/26066_2.png) [@Jameli](https://discourse.julialang.org/u/Jameli)
#### Post date: [June 13, 2021, 11:44pm UTC](https://discourse.julialang.org/t/silly-question-regarding-vectorized-syntax-jump/62853/1 "2021-06-13T23:44:45Z")

</div>

Hello everyone!

I’m having some trouble with some basic concepts about vectorized syntax.

My data were structured this way (just to show that everything is in matrix form):

```julia
 U = [ ATumor zeros(tr, tr) zeros(tr, gr) zeros(tr, rr);
        -ATumor -I zeros(tr, gr) zeros(tr, rr);
         ACritical zeros(gr, tr) -I zeros(gr, rr);
         ARegular zeros(rr, tr) zeros(rr, gr) -I ]
  u = [TUB; -TLB; CUB; RUB]
  lb = [zeros(tc); zeros(tr); -CUB; zeros(rr)]
  ub = [Inf * ones(tc); TLB; Inf * ones(gr); Inf * ones(rr)]
  c = [zeros(tc,1); omega * ones(tr); ones(gr); ones(rr)] 

```

And the commands that I tried with JuMP were:

```julia
model = Model(CPLEX.Optimizer)
@variable(model, x[1:size_p], lower_bound = lb, upper_bound = ub)
@constraint(model, U * x .<= u)
@objective(model, Min, c' * x)

```

But I got the following error message `"Cannot `convert` an object of type Array{Float64,1} to an object of type Float64"` at the line with “@variable”

As far as I know, this is happening because JuMP is not seeing my variable as a vector. What is the appropriate syntax for that?

Thanks in advance!

---

<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: [June 14, 2021, 12:07am UTC](https://discourse.julialang.org/t/silly-question-regarding-vectorized-syntax-jump/62853/2 "2021-06-14T00:07:11Z")

</div>

> [@Jameli](#):
>
> `@variable(model, x[1:size_p], lower_bound = lb, upper_bound = ub)`

The syntax is

```Julia
@variable(model, x[i=1:size_p], lower_bound = lb[i], upper_bound = ub[i])

```

There is an open issue to improve the error message: [Better error messages for vector variable bounds · Issue #2056 · jump-dev/JuMP.jl · GitHub](https://github.com/jump-dev/JuMP.jl/issues/2056)

---

<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: [June 14, 2021, 12:16am UTC](https://discourse.julialang.org/t/silly-question-regarding-vectorized-syntax-jump/62853/3 "2021-06-14T00:16:08Z")

</div>

Your model might be more readable if you wrote it out in blocks, instead of one giant matrix:

```nohighlight
model = Model(CPLEX.Optimizer)
@variables(model, begin
          0 <= x1[i=1:tc]
          0 <= x2[i=1:tr] <= -CUB[i]
    -CUB[i] <= x3[i=1:gr]
          0 <= x4[i=1:rr]
end)
@constraints(model, begin
       ATumor * x1 .<= TUB
       ATumor * x1 .>= TLB .- x2
    ACritical * x1 .<= CUB .+ x3
     ARegular * x1 .<= RUB .+ x4
end)
@objective(model, Min, omega * sum(x2) + sum(x3) + sum(x4))

```
