Page 1 of 1

unhashable type: 'GamsSetRecord'

Posted: Sun Mar 28, 2021 6:37 am
by silence
Hi everyone,

I want use modelinstance to multiple optimize with a two-dimensional parameter and a one-dimensional parameters in python. When I try to follow the example transport7.py to updata the two-dimensional parameter,it comes the error:TypeError: unhashable type: 'GamsSetRecord'. I have already saved the two-dimensional parameter as a dictionary. The specific code is as follows, qta is the dict incluing the parameter,and the format is
{("key1","key2"):value}.

Code: Select all

        for j in gmodel.out_db["i"]:
            for k in gmodel.out_db["w"]:
                Qtable.clear()
                Qtable.add_record((j.key(0),k.key(0))).value = qta[(j,k)]
Where is my mistake and how do i modify the code?

Thanks
Best wishes

Re: unhashable type: 'GamsSetRecord'

Posted: Sun Mar 28, 2021 7:12 pm
by Clemens
Looks like you are trying to use your dictionary qta with GamsSetRecords instead of keys. So you most likely want to do qta[(j.key(0),k.key(0))] instead of qta[(j,k)]

Best,
Clemens

Re: unhashable type: 'GamsSetRecord'

Posted: Mon Mar 29, 2021 2:31 am
by silence
Hi, Clemens

Thank you for your answer, actually I want to use dictionary qta with GamsSetRecords instead of value. Maybe I did not understand the example, and did it wrong.May I know how to updata the multidimensional parameters ?

Thank you very much