Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can a set be indexed by another indexed set? #256

Closed
DIUANA opened this issue Jan 23, 2020 · 2 comments
Closed

Can a set be indexed by another indexed set? #256

DIUANA opened this issue Jan 23, 2020 · 2 comments
Assignees
Labels
question Explaining features/usage; no code change needed

Comments

@DIUANA
Copy link

DIUANA commented Jan 23, 2020

It is not possible to initialize a set that depends on previous initialized set that is indexed by an existing set.
Example:

scenario.init_set('a', idx_sets='technology')
scenario.init_set( "b", [ 'type_tec_land', 'a' ] )

This returns:
at.ac.iiasa.ixmp.exceptions.IxException: There exists no index set 'a'!

Is there another way to do that?

P.S.: Maybe it is more an ixmp issue. In that case I can close this one and open an issue there.

@khaeru khaeru transferred this issue from iiasa/message_ix Jan 24, 2020
@khaeru khaeru added the question Explaining features/usage; no code change needed label Jan 24, 2020
@khaeru
Copy link
Member

khaeru commented Jan 24, 2020

I've transferred this to ixmp!

You're correct; this is not part of the data model. Either a set is a "simple" or "index" set (1-dimensional, not indexed by any other set) or it is complex (N-dimensional, with each dimension indexed by a simple set). Set a in your example is a hybrid.

A historical note: this distinction follows the data model of GAMS, since the first version of ixmp was tied to GAMS (we are working to relax this; see #78). But other software uses a similar distinction: see coordinates in xarray.

The solution in this case is:

scenario.init_set('a', idx_sets='technology')
scenario.init_set('b', [ 'type_tec_land', 'technology' ])

…and then use your own code to maintain the desired relationship between a and b.

Finally, there is one small issue here that is similar to #85: you should get a ValueError: indexed set 'a' cannot be an index of new set 'b' instead of the Java exception that is particular to the JDBCBackend. I will close this issue anyway, and make a note there to fix the two together.

@khaeru khaeru closed this as completed Jan 24, 2020
@khaeru khaeru changed the title set initialization Can a set be indexed by another indexed set? Jan 24, 2020
@khaeru khaeru self-assigned this Jan 24, 2020
@DIUANA
Copy link
Author

DIUANA commented Jan 24, 2020

Thanks Paul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Explaining features/usage; no code change needed
Projects
None yet
Development

No branches or pull requests

2 participants