Take as an example a vector `v`

which is of type Boolean and has **n** elements. Based on this vector we build a variable array `x`

of the same length of `v`

, but from which only the indices corresponding with the non-zero elements of `v`

are effectively variables.

With JuMP we could do something like this:

```
v = Bool[1, 1, 1, 0, 0, 1]
n = size(v,1)
@variable(model, x[i=1:n; v[i] != 0])
```

The problem for me with the interaction of this variable `x`

in the model building. If we wanted to create the following objective function:

```
c = [1, 2, 3, 4, 5, 6]
@objective(model, min, c'*x)
```

Throws the following: **ERROR: DimensionMismatch(â€śfirst array has length 6 which does not match the length of the second, 4.â€ť)**

I would have expected for the variable to behave like a sparse array, with the â€śnon-variableâ€ť entries of `x`

as zeros. But `x[4]`

doesnâ€™t exist instead of being 0.

Is there any workaround to fill the empty entries with zeros? I would like to avoid for-loops, since the model Iâ€™m trying to build is already clearly written in Matrix-vector form (and is much more complex than the example).

Thank you