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

readGDX() returns alias, not set #7

Open
0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q opened this issue Feb 27, 2024 · 2 comments
Open

readGDX() returns alias, not set #7

0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q opened this issue Feb 27, 2024 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q
Copy link
Member

gdx/R/readGDX.R

Line 221 in 6a32a33

tmp2 <- rgdx(path.expand(gdx),l,squeeze=FALSE,followAlias=FALSE)

What is the rationale for this? Sets and their aliases are used transparently in GAMS, why not here?

@tscheypidi
Copy link
Member

sorry, what is your problem here?

@0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q
Copy link
Member Author

In GAMS there is no difference in using a set, or an alias for a set.

Set foo / 1 * 2 /;

alias(foo, bar);

display foo, bar;

execute_unload "foobar.gdx", foo, bar;

It says that it is an alias, but displays the values all the same.

----      5 SET foo  
1,    2
----      5 SET bar  Aliased with foo
1,    2

But reading an alias with readGDX() does not return the values of the set:

> str(readGDX('foobar.gdx', 'foo'))
 chr [1:2] "1" "2"
 - attr(*, "gdxdata")=List of 5
  ..$ name   : chr "foo"
  ..$ type   : chr "set"
  ..$ form   : chr "sparse"
  ..$ domains: chr "*"
  ..$ domInfo: chr "none"
 - attr(*, "description")= chr ""

> str(readGDX('foobar.gdx', 'bar'))
List of 3
 $ name    : chr "bar"
 $ type    : chr "alias"
 $ aliasFor: chr "foo"

So users cannot simply look up (something that looks like) a set in GAMS (say in the definition of an equation) and use that with readGDX(). They have to first check if that is an alias.
Since this is an deliberate choice (followAlias = FALSE is not the default), I wonder why that is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants