# Assigning JuMP VariableRef to an array position

**URL:** <https://discourse.julialang.org/t/assigning-jump-variableref-to-an-array-position/26216>\
**Category:** Optimization (Mathematical)\
**Created:** [July 10, 2019, 11:37am UTC](https://discourse.julialang.org/t/assigning-jump-variableref-to-an-array-position/26216 "2019-07-10T11:37:43Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![MuadhF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/muadhf/32/20389_2.png) [@MuadhF](https://discourse.julialang.org/u/MuadhF)\
**Post date:** [July 10, 2019, 3:52pm UTC](https://discourse.julialang.org/t/assigning-jump-variableref-to-an-array-position/26216/3 "2019-07-10T15:52:06Z")

</div>

Oh okay, but I have a small issue now.

```julia
@variable(m, delta0)

amort = delta0/T

bal = Vector{JuMP.VariableRef}(undef, 100)

bal[1] = delta0
for i = 2:100
	bal[i] = bal[i-1] - amort
end

```

I can now assign a decision variable to the first array position `bal[1]`, but for the following positions from [2] onwards, I need to deduct a certain value `amort`. But I get an error `MethodError: Cannot convert an object of type GenericAffExpr{Float64,VariableRef} to an object of type VariableRef`  
So I asked about this in a previous post and someone advised to use regular `zeros` array, and that allowed me to subtract `amort` from `bal[1]`. So I have this dilemma, where I need a JuMP array for decision variable storage, but also need the properties of a zeros array, and am not sure what to do.  
If someone can please help, it would be greatly appreciated. This is the link to my other related question: [https://discourse.julialang.org/t/for-loop-error/26210/7](https://discourse.julialang.org/t/for-loop-error/26210/7)

Thanks!

---

_[View the full topic](https://discourse.julialang.org/t/assigning-jump-variableref-to-an-array-position/26216)._
