unhashable type: 'GamsSetRecord'

Questions on using the GAMS APIs (Python, .NET, etc.)
Post Reply
silence
User
User
Posts: 19
Joined: 4 years ago

unhashable type: 'GamsSetRecord'

Post 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
User avatar
Clemens
Posts: 57
Joined: 7 years ago

Re: unhashable type: 'GamsSetRecord'

Post 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
silence
User
User
Posts: 19
Joined: 4 years ago

Re: unhashable type: 'GamsSetRecord'

Post 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
Post Reply