# Update a vector with "update\_param!"

**URL:** <https://forum.mimiframework.org/t/update-a-vector-with-update-param/116>\
**Category:** Uncategorized\
**Created:** [April 18, 2020, 12:17am UTC](https://forum.mimiframework.org/t/update-a-vector-with-update-param/116 "2020-04-18T00:17:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![KGregory](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/kgregory/32/32_2.png) [@KGregory](https://forum.mimiframework.org/u/KGregory)\
**Post date:** [April 18, 2020, 12:17am UTC](https://forum.mimiframework.org/t/update-a-vector-with-update-param/116/1 "2020-04-18T00:17:52Z")

</div>

Tutorial 2 of the Mimi.jl shows how to update a single value parameter with “update\_param!”. Is it possible to use this function, or another function to update a vector array, such as “update\_param!(m, :agcbm[1], 0.11)”, where agcbm is a 16 element vector? This expression gives error; “MethodError: no method matching getindex(::Symbol, ::Int64)”

---

<div class="post-metadata">

**Author:** ![lrennels](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/lrennels/32/6_2.png) [@lrennels](https://forum.mimiframework.org/u/lrennels)\
**Post date:** [April 22, 2020, 9:18pm UTC](https://forum.mimiframework.org/t/update-a-vector-with-update-param/116/2 "2020-04-22T21:18:46Z")

</div>

@KGregory I believe your problem here is that you are trying to index into `:agcbm`, which is not permitted within this function. If you want to update the vector array, you will need to replace the entire array, i.e. `update_param!(m, :agcbm, new_array]` where the `new_array` is a 16 element vector as well. Does that make sense for your use case? Of course, your new array might just be a replica of the original one used in `set_param!` with the first value modified. I assume you can access that original vector from the original `set_param!` function, or pulling the values out of the already run model?

---

<div class="post-metadata">

**Author:** ![KGregory](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/kgregory/32/32_2.png) [@KGregory](https://forum.mimiframework.org/u/KGregory)\
**Post date:** [April 23, 2020, 8:22pm UTC](https://forum.mimiframework.org/t/update-a-vector-with-update-param/116/3 "2020-04-23T20:22:11Z")

</div>

Thank you for your reply. `agcbm` is a random 16-element (RV), so update\_param! only updates the default best estimates of agcbm for the 16 regions, correct? I created an AGcbm\_new vector with all values larger than agcbm by 30% by;  
AGcbm\_new = AGcbm .\* 1.3  
update\_param!(m, :agcbm, AGcbm\_new)  
run(m)  
for j = 1:16  
AGcbm[j] = m[:impactagriculture, :agcbm][j]  
end  
println(AGcbm)

which returns 16 values of 30% more than the original values. However, If a ran a Monte Carlo simulation the model would use the original RV, correct?

---

<div class="post-metadata">

**Author:** ![ckingdon95](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/ckingdon95/32/15_2.png) [@ckingdon95](https://forum.mimiframework.org/u/ckingdon95)\
**Post date:** [April 23, 2020, 11:09pm UTC](https://forum.mimiframework.org/t/update-a-vector-with-update-param/116/4 "2020-04-23T23:09:17Z")

</div>

Yes that’s correct, the `update_param!` function only updates the values in the “deterministic” version of the model, but then when you run the Monte Carlo simulation it will sample from its original random variables and will override whatever values are set in the single model.
