GAMS Transfer ConstContainer stores (multiple) symbols (read-only) More...

Inheritance diagram for ConstContainer:
BaseContainer

GAMS Transfer ConstContainer stores (multiple) symbols (read-only)

A GAMS GDX file is a collection of GAMS symbols (e.g. variables or parameters), each holding multiple symbol records. In GAMS Transfer the Container is the main object that holds different symbols and allows to read and write those to GDX. See Container for more information.

In contrast to the Container, a ConstContainer cannot be modified after creation. This allows using operations that result in better runtime performance. Hence, if performance is key, consider using ConstContainer over Container. However, a ConstContainer supports less features. Further differences are:

  • ConstContainer does not support writing.
  • Symbols in a ConstContainer are structs, not objects.
  • number_records in a ConstContainer symbol represents the number of GDX records in a read GDX file, not the records currently stored. This then also applies to sizes. This allows to read a GDX file without records and inspect symbol sizes and sparsity etc.
  • Domains are linked by name, not by reference in a symbol.
  • UELs in a ConstContainer symbol are stored as a field in the struct or within the categorical array. Methods like getUELs as in the Symbol class do not exist.

Indexed Mode:

There are two different modes GAMSTransfer can be used in: indexed or default.

  • In default mode the main characteristic of a symbol is its domain that defines the symbol dimension and its dependencies. A size of symbol is here given by the number of records of the domain sets of each dimension. In default mode all GAMS symbol types can be used.
  • In indexed mode, there are no domain sets, but sizes (the shape of a symbol) can be set explicitly. Furthermore, there are no UELs and only GAMS Parameters are allowed to be used in indexed mode.

The mode is defined when creating a container and can't be changed thereafter. See Indexed GDX for more information.

Example:

c = ConstContainer('path/to/file.gdx');
c = ConstContainer('indexed', true, 'gams_dir', 'C:\GAMS');
Advanced Users Only:

Creation of categorical arrays can be a bottleneck. Reading performance can be increased for a ConstContainer (not Container) when disabling them:

c = ConstContainer('path/to/file.gdx', 'features', struct('categorical', false));

Domain entries are numerical codes of UELs (see also Unique Elements (UELs)) and can be looked up in the uels field of a symbol.

See also
Container

Public Member Functions

function ConstContainer (in varargin)
 Constructs a GAMSTransfer Container. More...
 
function equals (in obj, in container)
 Checks equivalence with other container. More...
 
function read (in obj, in varargin)
 Reads symbols from GDX file (current symbols will be lost). More...
 
- Public Member Functions inherited from BaseContainer
function BaseContainer (in gams_dir, in indexed, in features)
 Constructs a GAMSTransfer BaseContainer.
 
function hasSymbols (in obj, in names)
 Checks if symbol exists in container (case insensitive) More...
 
function getSymbolNames (in obj, in names)
 Get symbol names by names (case insensitive) More...
 
function listSymbols (in obj, in varargin)
 Lists all symbols in container. More...
 
function listSets (in obj, in varargin)
 Lists all sets in container. More...
 
function listParameters (in obj, in varargin)
 Lists all parameters in container. More...
 
function listVariables (in obj, in varargin)
 Lists all variables in container. More...
 
function listEquations (in obj, in varargin)
 Lists all equations in container. More...
 
function listAliases (in obj, in varargin)
 Lists all aliases in container. More...
 
function describeSets (in obj, in varargin)
 Returns an overview over all sets in container. More...
 
function describeParameters (in obj, in varargin)
 Returns an overview over all parameters in container. More...
 
function describeVariables (in obj, in varargin)
 Returns an overview over all variables in container. More...
 
function describeEquations (in obj, in varargin)
 Returns an overview over all equations in container. More...
 
function describeAliases (in obj, in varargin)
 Returns an overview over all aliases in container. More...
 
function isValid (in obj, in varargin)
 Checks correctness of all symbols. More...
 

Public Attributes

Property modified
 Flag to indicate modification. More...
 

Additional Inherited Members

- Protected Attributes inherited from BaseContainer
Property gams_dir
 GAMS system directory.
 
Property indexed
 Flag for indexed mode.
 
Property data
 GAMS (GDX) symbols.
 

Constructor & Destructor Documentation

◆ ConstContainer()

function ConstContainer ( in  varargin)

Constructs a GAMSTransfer Container.

Optional Arguments:

  1. filename (string): Path to GDX file to be read (no records will be read)

Parameter Arguments:

  • gams_dir (string): Path to GAMS system directory. Default is determined from PATH environment variable
  • indexed (logical): Specifies if container is used in indexed of default mode, see above.

Example:

c = ConstContainer('path/to/file.gdx');
c = ConstContainer('indexed', true, 'gams_dir', 'C:\GAMS');
See also
Container

Member Function Documentation

◆ equals()

function equals ( in  obj,
in  container 
)

Checks equivalence with other container.

Required Arguments:

  1. container (any): Other Container

◆ read()

function read ( in  obj,
in  varargin 
)

Reads symbols from GDX file (current symbols will be lost).

See Reading From GDX for more information.

Required Arguments:

  1. filename (string): Path to GDX file to be read

Parameter Arguments:

  • symbols (cell): List of symbols to be read. All if empty. Case doesn't matter. Default is {}.
  • format (string): Records format symbols should be stored in. Default is table.
  • records (logical): Enables reading of records. Default is true.
  • values (cell): Subset of {"level", "marginal", "lower", "upper", "scale"} that defines what value fields should be read. Default is all.

Example:

c = Container();
c.read('path/to/file.gdx');
c.read('path/to/file.gdx', 'format', 'dense_matrix');
c.read('path/to/file.gdx', 'symbols', {'x', 'z'}, 'format', 'struct', 'values', {'level'});
See also
RecordsFormat

Member Data Documentation

◆ modified

Property modified

Flag to indicate modification.

If the container or any symbol within has been modified since last reset of flag (false), this flag will be true. Resetting will also reset symbol flag.

function ConstContainer(in varargin)
Constructs a GAMSTransfer Container.