Skip to content

Issue with slicers/References of unindexed components #859

Open
@andrewlee94

Description

@andrewlee94

If you create a slicer/Reference of an unindexed component (e.g. you were unsure if it was indexed or not), the resulting Reference is indexed by [None]. This means that when working with the new Reference the [None] index needs to be included, whilst working with the original component does not (i.e. the Reference has a different index to the thing it points to).

See example below:

m = ConcreteModel()
m.v = Var()

m.r = Reference(m.v[...])

m.r.display()

>>>> r : Size=1, Index=r_index
    Key  : Lower : Value : Upper : Fixed : Stale : Domain
    None :  None :  None :  None : False :  True :  Reals

m.r = 1

>>>> ValueError: Cannot set the value for the indexed component 'r' without specifying an index value.
	For example, model.r[i] = value

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions