Package 'gamstransfer'

Title: A Data Interface Between 'GAMS' and R
Description: Read, analyze, modify, and write 'GAMS' (General Algebraic Modeling System) data. The main focus of 'gamstransfer' is the highly efficient transfer of data with 'GAMS' <https://www.gams.com/>, while keeping these operations as simple as possible for the user. The transfer of data usually takes place via an intermediate GDX (GAMS Data Exchange) file. Additionally, 'gamstransfer' provides utility functions to get an overview of 'GAMS' data and to check its validity.
Authors: Atharv Bhosekar [aut, cre], GAMS Development Corp. [cph, fnd], GAMS Software GmbH [cph, fnd]
Maintainer: Atharv Bhosekar <[email protected]>
License: MIT + file LICENSE
Version: 3.0.4
Built: 2024-11-24 06:54:08 UTC
Source: CRAN

Help Index


Symbol Abstract Class

Description

An abstract symbol class from which the classes Set, Parameter, Variable, and Equation are inherited. Please visit https://transfer-r.readthedocs.io/en/latest/ for detailed documentation of this package.


Alias Class

Description

A class for Alias objects. Please visit https://transfer-r.readthedocs.io/en/latest/ for detailed documentation of this package.

Examples

# create a container
m <- Container$new()
# add a set
i <- Set$new(m, "i")
# add an alias to the set "i"
ii <- Alias$new(m, "ii", i)

Container Class

Description

The main object class within GAMS Transfer is called Container. The Container is the vessel that allows symbols to be linked together (through their domain definitions), it enables implicit set definitions, it enables structural manipulations of the data (matrix generation), and it allows the user to perform different read/write operations. Please visit https://transfer-r.readthedocs.io/en/latest/ for detailed documentation of this package.

Create a new container simply by initializing an object.

Arguments

loadFrom

optional argument to point to the GDX file being read into the Container

Fields

data

is a named list containing all symbol data

Examples

m <- Container$new()
i <- m$addSet("i")
j <- m$addSet("j")
all_symbols <- m$listSymbols()
set_description <- m$describeSets()
# create a container and read the file trnsport.gdx
m = Container$new(system.file("extdata", "trnsport.gdx", package = "gamstransfer"))
# access symbol named "x" from the container
x = m["x"]
# list all symbols
all_symbols = m$listSymbols()
# list all sets
all_sets = m$listSets()
# check if the container contains symbol named "i"
has_i = m$hasSymbols("i")
# get a summary of the description of all sets in the Container
set_description = m$describeSets()

DomainViolation Class

Description

Contains information about the domain violation for a symbol. Please visit https://transfer-r.readthedocs.io/en/latest/ for detailed documentation of this package.

Fields

symbol

symbol name

dimension

dimension in which domain violation is present

domain

domain name

violations

vector of violations

Examples

m <- Container$new()
i <- Set$new(m, "i", records = paste0("i", 1:5))
p <- Parameter$new(m, "p", i, records = data.frame(i = c("i1", "i3", "i6"), value = c(1, 5, 7)))
dv <- p$getDomainViolations()[[1]]
sym_dv <- dv$symbol
dim_dv <- dv$dimension
domain_dv <- dv$domain
violation_dv <- dv$violations

Equation Class

Description

A class for Equation objects. This class inherits from an abstract symbol class.The documentation for methods common to all symbols can be accessed via help(.Symbol). Please visit https://transfer-r.readthedocs.io/en/latest/ for detailed documentation of this package.

Examples

# create a container
m <- Container$new()
# add a Variable
e <- Equation$new(m, "v", type = "eq")
# access records
e_recs <- e$records

Parameter Class

Description

A class for Parameter objects. This class inherits from an abstract Symbol class.The documentation for methods common to all symbols can be accessed via help(.Symbol). Please visit https://transfer-r.readthedocs.io/en/latest/ for detailed documentation of this package.

Examples

# create a container
m <- Container$new()
# add a Parameter
p <- Parameter$new(m, "p")
# access records
p_recs <- p$records

readGDX

Description

read a GDX file to a list without creating symbol or container objects

Usage

readGDX(loadFrom, symbols = NULL, records = TRUE)

Arguments

loadFrom

name of the GDX file being read (string)

symbols

optional argument - vector of strings containing the symbol names to be read

records

optional logical argument - TRUE (default) to read the symbol records, FALSE to only read the meta data. Please visit https://transfer-r.readthedocs.io/en/latest/ for detailed documentation of this package.

Examples

read_list <- readGDX(system.file("extdata", "trnsport.gdx", package = "gamstransfer"))

Set Class

Description

A class for Set objects. This class inherits from an abstract Symbol class. The documentation for methods common to all symbols can be accessed via help(.Symbol). Please visit https://transfer-r.readthedocs.io/en/latest/ for detailed documentation of this package.

Examples

# create a container
m <- Container$new()
# add a set
i <- Set$new(m, "i")
# access records
i_recs <- i$records

SpecialValues list object

Description

This list contains GAMS special values and helper functions to check if a given value is a GAMS special value. Please visit https://transfer-r.readthedocs.io/en/latest/ for detailed documentation of this package.

Usage

SpecialValues

Format

An object of class list of length 10.

Examples

# check the value of GAMS special value NA
NA_val <- SpecialValues[["NA"]]
# check the value of GAMS special value EPS
EPS_val <- SpecialValues[["EPS"]]
# check if a value is GAMS special value `NA`
isNA_check <- SpecialValues$isNA(0)

UniverseAlias Class

Description

A class for Alias objects that are aliased to the Universe set. Please visit https://transfer-r.readthedocs.io/en/latest/ for detailed documentation of this package.

#' @examples # create a container m = Container$new() # add a UniverseAlias u = UniverseAlias$new(m, "u")


Variable Class

Description

A class for Variable objects. This class inherits from an abstract Symbol class. Please visit https://transfer-r.readthedocs.io/en/latest/ for detailed documentation of this package.

Examples

# create a container
m <- Container$new()
# add a Variable
v <- Variable$new(m, "v")
# access records
v_recs <- v$records

writeGDX

Description

write a GDX file from a list containing symbol data and metadata

Usage

writeGDX(
  writeList,
  writeTo,
  symbols = NULL,
  compress = FALSE,
  uelPriority = NULL,
  mode = NULL
)

Arguments

writeList

list containing symbol data and metadata

writeTo

name of the output GDX file

symbols

optional argument - vector of strings containing the symbol names to be read

compress

optional logical argument. TRUE to produce a compressed GDX file

uelPriority

Specify the priority UELs

mode

optional string argument to specify the write mode ("string", "mapped"). Please visit https://transfer-r.readthedocs.io/en/latest/ for detailed documentation of this package.

Examples

writeGDX(list(), tempfile(fileext = ".gdx"))