[Tutor] Error: 'IndexedVar' object is not callable

Alan Gauld alan.gauld at yahoo.co.uk
Sat Sep 10 16:11:43 EDT 2016


On 10/09/16 17:23, Pooja Bhalode wrote:

> I am trying to run Pyomo environment in Python on sublime text editor.

OK, For the pyomo stuff you should ask on the pyomo support site
(or I notice they do staxck overflow too)

> Python version of 2.7.11. I am running the code in sublime itself.

You maybe should try running it outside Sublime, it may give you more
useful error messages.

> Code:
> 
> m.z = ContinuousSet(bounds = (0,10))
> m.t = ContinuousSet(bounds = (0,10))
> where all the variables that I am defining, are varying along the z and t
> direction.

Most of that is mreaningless to us because we don;t know pyomo.
I'd never even heard of it until you said.

> Variables:
> m.C = Var(m.z,m.t)
> m.Cair = Var(m.z,m.t)
> m.masswater = Var(m.z,m.t)
> m.massair = Param(initialize = 1833.50)

Again that is all very pyomo specific. Its hard to comment
without knowing pyomo.


> After this, when I define the equations,
> 
> def _calculations(m,i,j):
> if i == 0 or i == 1 or j == 0:
> return Constraint.Skip
> 
> return m.wateraccumulated(j) == 916.50 - (m.C(i,j)*46*28/(28*18*1.205 +
> m.C(i,j) * 46*28))*2750

What happens if you do:

m.C = Var(m.z,m.t)
print m.C
print m.C(i,j)


> It tells me that TypeError: 'IndexedVar' object is not callable for m.C
> itself. I think the syntax is correct but I am not able to figure out why
> the variable is not callable.

Its not clear where the error is occurring, are you sure
that's all the error message says?? Usually there is a
whole heap of stuff about where the call happened
and its context.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list