Alias#
Adding Alias Records#
The linked structure of Aliases offers some unique opportunities to access
some of the setter functionality of the parent set. Specifically, GAMS
Transfer allows the user to change the domain, description, dimension,
and records of the underlying parent set as a shorthand notation.
We can see this behavior if we look at a modified Example #1 from
adding set records.
Example - Creating set records through an alias link#
library(gamstransfer)
m <- Container$new()
i <- Set$new(m, "i")
ip <- Alias$new(m, "ip", i)
ip$description <- "adding new descriptive set text"
ip$domain <- c("*", "*")
ij <- list(paste0("i", 1:3), paste0("j", 1:3))
ip_recs <- rev(expand.grid(rev(ij)))
colnames(ip_recs) <- c("i", "j")
ip$setRecords(ip_recs)
> i$domain
[1] "*" "*"
> i$records
i j
1 i1 j1
2 i1 j2
3 i1 j3
4 i2 j1
5 i2 j2
6 i2 j3
7 i3 j1
8 i3 j2
9 i3 j3
Note
An alias $isValid()=TRUE when the underlying parent set
is also valid. If the parent set is removed from the Container
the alias will no longer be valid.
Note
One can also use the generateRecords() method to automatically populate randomly generated symbol records in the standard format.