Set dimensions for shared parameter

Hi, there

I’m trying to add a new shared parameter for my modified Mimi-RICE model. I’ve read the how_to.md and the tutorial shows that if I want to set dimensions for the parameter, I need to write like this add_shared_param!(m, :shared_param, [1,2,3,4,5,6], dims = [:time]).

However, I don’t know how to add 2-dimensional shared parameter. I’ve tried several approaches such as dims = [time, regions] and dims = [:time, regions], but it doesn’t work for me. If anyone knows the solution to this problem, please don’t hesitate to help!

Hi @emilywen2001 could you post what your error message is? That would be helpful in diagnosing the problem. Looking at what you wrote, I think the issue might be that your data dimensions do not match the size of the values you enter, but again the error message would be really helpful to see here.


Here’s a simple example that works for my machine. I add a component with a Parameter my_param with two dimensions, time and regions, to my model and then add a shared Parameter my-shared_param. Finally I connect my_shared_param to my_param and run the model.

using Mimi

m = Model()

set_dimension!(m, :time, [2000, 2001, 2002])
set_dimension!(m, :regions, ["A", "B", "C"])

values = rand(3,3)

@defcomp my_comp begin
    my_param = Parameter(index = [time, regions])
end

add_shared_param!(m, :my_shared_param, values, dims = [:time, :regions])

add_comp!(m, my_comp)
connect_param!(m, :my_comp, :my_param, :my_shared_param)

run(m)

Hi @lrennels , I have tried your example and it works for me. Maybe I used the wrong way of declaring the dims value, thanks for your help!

@emilywen2001 glad to be of help!