Error setting parameter value: Index .. is not valid for array Param ..

690 views
Skip to first unread message

Saamrat Kasina

unread,
Mar 25, 2017, 6:23:55 PM3/25/17
to pyomo...@googlegroups.com
Hi all,

I am trying to understand a Pyomo error and would appreciate some advice. As a small example, this is what I am trying to do:

model.B = Set()
model.H = Set()
model.IncidenceMatrix = Param(model.B, model.H, default=0.0)   #IncidenceMatrix is just a mapping b/w B and H. 1 indicates mapping. 

In the datafile, I write:

param IncidenceMatrix :=
'w'       '30067'    1
'x'       '30056'     1
'y'       '30089'     1....

While reading in the data, Pyomo's error resembles this -> "ERROR: Constructing component 'GenIncidenceMatrix' from data={('x', 30056): 1, ('y', 30089): 1, .......} failed:
RuntimeError: Failed to set value for param=IncidenceMatrix, index=('x', 30056), value=1.
source error message="Error setting parameter value: Index '('x', 30056)' is not valid for array Param 'IncidenceMatrix'"

The actual datasets I am using are much larger (attached is the actual console output), but the gist of what I'm trying to do is the same. Can someone try and explain what this error means and where to start troubleshooting. Thanks!
a.txt

David Woodruff

unread,
Mar 25, 2017, 8:49:11 PM3/25/17
to pyomo...@googlegroups.com
The following data file works:

set B := w x y ;
set H := 30067 30056 30089 ;


param IncidenceMatrix :=
w       30067    1
x       30056     1
y       30089     1 ;

You don't need quotes for the set elemens as indexes and
I am pretty sure that implicit definitions of sets in the data file is not supported by Pyomo.

On Sat, Mar 25, 2017 at 3:14 PM, Saamrat Kasina <k.sa...@gmail.com> wrote:
Hi all,

I am trying to understand a Pyomo error and would appreciate some advice. As a small example, this is what I am trying to do:

model.B = Set()
model.H = Set()
model.IncidenceMatrix = Param(model.B, model.H, default=0.0)   #IncidenceMatrix is just a mapping b/w B and H. 1 indicates mapping. 

In the datafile, I write:

param IncidenceMatrix :=
'w'       '30067'    1
'x'       '30056'     1
'y'       '30089'     1....

While reading in the data, Pyomo's error resembles this -> "ERROR: Constructing component 'GenIncidenceMatrix' from data={('x', 30056): 1, ('y', 30089): 1, .......} failed:
RuntimeError: Failed to set value for param=IncidenceMatrix, index=('x', 30056), value=1.
source error message="Error setting parameter value: Index '('x', 30056)' is not valid for array Param 'IncidenceMatrix'"

The actual datasets I am using are much larger, but the gist of what I'm trying to do is the same. Can someone try and explain what this error means and where to start troubleshooting. Thanks!

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Saamrat Kasina

unread,
Mar 26, 2017, 10:09:41 PM3/26/17
to Pyomo Forum, dlwoo...@ucdavis.edu
Hi Dr. Woodruff,

I do declare the sets before hand in the datafile (no implicit definitions) which is why I am stumped as to why this is happening. 

On a related note about what you said about not needing quotes for indices - in the above example, can data for set H be all numbers that that must be treated as strings? For example, in a network, if there are 100 nodes which are predefined as '1', '2' . etc and there is no meaning to these numbers. 

I am assuming Pyomo is treating Set H as numbers. Can I explicitly define a set with domain 'String'? (All declarations in the documentation are related to numbers or boolean). Thank you. 

To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages