Loading...
Searching...
No Matches
com.gams.api.GAMSDatabase Class Reference

Inherits AbstractGAMSDatabase< GAMSSymbol<?> >.

Public Member Functions

String getName ()
 Get GAMSDatabase name.
 
void export ()
 Write database into a GDX file.
 
void export (String filePath)
 Write database into a GDX file.
 
GAMSEquation addEquation (String identifier, int dimension, GAMSGlobals.EquType equType)
 Add equation symbol to database.
 
GAMSEquation addEquation (String identifier, int dimension, GAMSGlobals.EquType equType, String explanatoryText)
 Add equation symbol to database.
 
GAMSEquation addEquation (String identifier, GAMSGlobals.EquType equType, String explanatoryText, Object ... domains)
 Add equation symbol to database with domain information.
 
GAMSSet addSet (String identifier, int dimension)
 Add set symbol to database.
 
GAMSSet addSet (String identifier, int dimension, GAMSGlobals.SetType setType)
 Add set symbol to database.
 
GAMSSet addSet (String identifier, int dimension, String explanatoryText)
 Add set symbol to database.
 
GAMSSet addSet (String identifier, int dimension, GAMSGlobals.SetType setType, String explanatoryText)
 Add set symbol to database.
 
GAMSSet addSet (String identifier, String explanatoryText, Object ... domains)
 Add set symbol to database with domain information.
 
GAMSSet addSet (String identifier, GAMSGlobals.SetType setType, String explanatoryText, Object ... domains)
 Add set symbol to database with domain information.
 
GAMSParameter addParameter (String identifier, int dimension)
 Add parameter symbol to database.
 
GAMSParameter addParameter (String identifier, int dimension, String explanatoryText)
 Add parameter symbol to database.
 
GAMSParameter addParameter (String identifier, String explanatoryText, Object ... domains)
 Add parameter symbol to database with domain information.
 
GAMSVariable addVariable (String identifier, int dimension, GAMSGlobals.VarType varType)
 Add variable symbol to database.
 
GAMSVariable addVariable (String identifier, int dimension, GAMSGlobals.VarType varType, String explanatoryText)
 Add variable symbol to database.
 
GAMSVariable addVariable (String identifier, GAMSGlobals.VarType varType, String explanatoryText, Object ... domains)
 Add variable symbol to database with domain information.
 
GAMSSymbol<?> getSymbol (String identifier)
 Get GAMSSymbol<T extends GAMSSymbolRecord> by name.
 
GAMSEquation getEquation (String identifier)
 Get GAMSEquation by name.
 
GAMSParameter getParameter (String identifier)
 Get GAMSParameter by name.
 
GAMSSet getSet (String identifier)
 Get GAMSSet by name.
 
GAMSVariable getVariable (String identifier)
 Get GAMSVariable by name.
 
boolean isAutoDomainCheckingSuppressed ()
 Determine whether domain checking will be called when export GAMSDatabase.
 
void suppressAutoDomainChecking (boolean value)
 Controls whether domain checking will be called when export GAMSDatabase.
 
int getNumberOfSymbols ()
 Get the number of symbols in GAMSDatabase.
 
void clear ()
 Clear all symbol records in the database.
 
boolean checkDomains ()
 Check all GAMSSymbol<T extends GAMSSymbolRecord> instances in the database if all their records are within the specified domain of the symbol.
 
List< GAMSDatabaseDomainViolationgetDatabaseDomainViolations (int maxViolation, int maxViolationPerSymbol)
 Check all GAMSSymbol<T extends GAMSSymbolRecord> instances in the database if all their records are within the specified domain of the symbol.
 
Iterator< GAMSSymbol<?> > iterator ()
 Returns an iterator over a set of elements of type T.
 
boolean isDisposed ()
 Inquire if this database has already been disposed.
 
void dispose ()
 Release external resources hold by non-java library.
 

Protected Member Functions

void finalize () throws Throwable
 Release resources used by non-java library.
 

Detailed Description

An instance of GAMSDatabase communicates data between the Java world and the GAMS world. A GAMSDatabase consists of a collection of symbols that allows to iterate conveniently through the symbols in a GAMSDatabase. The symbol types available for a GAMSDatabase correspond to the symbols types known from the GAMS language (Set, Parameter, Variable, and Equation) are represented in Java by a derived class (correspondingly GAMSSet, GAMSParameter, GAMSVariable, and GAMSEquation) of GAMSSymbol class. Besides the type, a GAMSSymbol has a name (this has to match the name inside the GAMS model), a dimension (currently up to 20, see also GAMSGlobals.MAXDIM) and explanatory text.

Variables and equations also have a subtype: e.g. Binary, Positive, etc. for variables (see GAMSGlobals.VarType) and e.g. E, G etc. for equations (see GAMSGlobals.EquType).

A GAMSDatabase can be created empty, or initialized from existing GDX files or from another GAMSDatabase (copy). Symbols can be added at any time (e.g. with GAMSDatabase.addParameter(String, int) method), but once a symbol is part of a GAMSDatabase, it cannot be removed. Only its associated data (GAMSSymbolRecord) can be purged (see GAMSSymbol<T extends GAMSSymbolRecord>.clear() method) or individually removed (with GAMSSymbol<T extends GAMSSymbolRecord>.deleteRecord() method). A symbol with name "*" is reserved as a special symbol of type GAMSSet representing universe set. Individual data elements are accessed record by record. A record is identified by the keys (a vector of strings). The record data varies by symbol type. For example, a parameter record has a Value property, a variable has the properties Level, Lower, Upper, Marginal, and Scale. Adding a record with keys that already exist results in an exception. Similar, the unsuccessful search for a record also results in an exception.

GAMSSymbol implements the Java java.lang.Iterable interface to conveniently iterate through the records of a symbol. There are also sliced access methods to symbol records that allow to iterate through all records with a fixed index at some positions. GAMSDatabase instances can be exported as GDX files for permanent storage. They also manage external resources and need to be properly disposed before the Java garbage collector reclaims the instance (see GAMSDatabase.dispose()).

GAMSJob.OutDB() and GAMSModelInstance.SyncDB() provide instances of GAMSDatabase to communicate results from a GAMS run or a solve. These databases should only be used in the context of the base object (GAMSJob or GAMSModelInstance). If a copy of such a database is required the GAMSDatabase constructor that initializes a GAMSDatabase from another database should be used. For instance:

   GAMSDatabase db = GAMSJob.OutDB();
   GAMSDatabase newdb = workspace.addDatabase(db);

GAMSDatabase instances often provide the input data for a GAMSJob. Such instances are listed in the run methods in GAMSJob, e.g., GAMSJob.run(). Inside the GAMS model source the GAMSDatabase is accessible through a GDX file. The GAMS model source requires a particular file name to connect to the proper GDX file (e.g. $GDXIN filename). A GAMSDatabase can be created with a given name which can be then used inside the model, for instance

   GAMSDatabase db = workspace.addDatabase("SupplyData");

and then inside the GAMS model source:

$GDXIN SupplyData 

or an automatically generated name can be used. This name can be passed down to the GAMS model by using the Defines list of a GAMSOptions instance:

   GAMSDatabase db = workspace.addDatabase();
   GAMSOptions opt = workspace.addOptions();
   opt.defines("SupplyDataFileName",db.getName());
   ...
   gamsjob.run(opt, db);

Inside the GAMS model source the name is accessed as follows:

   $GDXIN %SupplyDataFileName%

One has to act with some caution when it comes to ordered sets which e.g. allow lag and lead. By not enforcing the "domain checking" for the GAMSDatabase class we have aggravated the potential problems for ordered sets. For GAMS, the labels of set elements are just strings, so the order of a set is determined by the appearance of its elements. For example, if one has 'set k / 2,3,4,1,5 /', the order of k is exactly given by this sequence. So the lag (k-1) of k=4 is 3 and the lead (k+1) of k=4 is 1.

GAMS performs arithmetic with an extended number range. GAMS has special values for infinity (+INF, -INF), epsilon (EPS), not available (NA), and undefined (UNDEF). When GAMS evaluates expressions with these special values, the calculating engine ensures the correctness of the result (e.g. 5*eps=eps or 5+eps=5). The GAMS model CRAZY in the GAMS Model Library documents the results of the arithmetic operations with respect to special values.

In the GAMS Java API we map the IEEE standard values for +/-infinity (Double.POSITIVE_INFINITY and Double.NEGATIVE_INFINITY) and NA (Double.NaN) to the corresponding GAMS values. The special value for UNDEF gets unfiltered through the GAMS Java API. The internal double value of UNDEF is 1.0E300 (or better use GAMSGlobals.SpecialValues.UNDEFINED_VALUE).

Special attention needs to be given to the value of 0. Since GAMS is a sparse system it does not store (parameter) records with a true 0. If a record with numerical value of 0 is needed, EPS can help. For example:

  set j /1*10 /;
  parameter b(j);
  b(j) = 1; b('5') = 0;
  scalar s,c;
  s = sum(j, b(j));
  c = card(b);
  display s,c;

will result in

 ----      3 PARAMETER s                    =        9.000
             PARAMETER c                    =        9.000

but

  b(j) = 1; b('5') = EPS;

will result in

 ----      3 PARAMETER s                    =        9.000
             PARAMETER c                    =       10.000

What are the consequences for the GAMS Java API? If we read parameter b in case of b('5')=0, the GAMSDatabase will not have a record for b('5'). In case of b('5')=EPS, the GAMSDatabase will have a record with GAMSGlobals.SpecialValues.EPS value 4.94066E-324 (see also GAMSGlobals.SpecialValues.EPS). Unlike the IEEE values (e.g. Duble.POSITIVE_INFINITY), arithmetic operations in Java will modify the EPS value (e.g. 5*Double.POSITIVE_INFINITY==Double.POSITIVE_INFINITY but 5*4.94066E-324 != 4.94066E-324). The same rules apply for preparing input data for GAMS in a GAMSDatabase. If a value of 4.94066E-324 is written, GAMS will see the special value EPS (see GAMSGlobals.SpecialValues). The value used for EPS can be reset using GAMSWorkspace.setMyEPS(double). All other small values (including 0) will be communicated unfiltered to GAMS. As mentioned before, zeros will not be entered as data records in GAMS. The compiler control $on/offEPS can help to automatically map zeros to EPS.

There is one oddity concerning values smaller than 1e-250 on GAMS input. Consider the following example:

  GAMSParameter b = db.addParameter("b",1,"");
  for(int i=1; i < 11; i++)
     b.addRecord( String.valueOf(i) ).setValue( 1 );
  b.findRecord("5").setValue( 1E-251 );
  job.run(db);

with GAMS code:

  $load j b
  scalar card_b;
  card_b = card(b);
  display card_b;
  b(j) = 2*b(j);
  card_b = card(b);
  display card_b;

A record with values smaller than 1E-250 exists on input in GAMS, but as soon as the record gets updated by GAMS and is still smaller than 1E-250, the record gets removed.

The ordering of a set in GAMS can be non-intuitive: Consider "set i /5/, j /1*5/;". Elements '5' gets internal number 1, '1' get 2, '2' gets 3 and so on. The last element of j '5' has already the internal number 1. The sequence of internal numbers in j is not ascending and hence GAMS considers set j as not sorted, i.e. one can't use the ord() function nor the lag or lead (-,–,+,++) operators. If 'j' would have been defined before 'i' in this example, the 'set not ordered' problem would have been avoided.

Please note that the GAMSDatabase actually does not implement a relational model for database management. It should be seen as a data storage or data container.

See also
GAMSDatabaseIterator
GAMSEquation
GAMSGlobals
GAMSGlobals.SpecialValues
GAMSJob
GAMSSymbol
GAMSOptions
GAMSParameter
GAMSSet
GAMSVariable
GAMSWorkspace
GAMSWorkspace.addDatabase()
GAMSWorkspace.addDatabase(String)
GAMSWorkspace.addDatabase(GAMSDatabase, String)
GAMSWorkspace.addDatabaseFromGDX(String)
GAMSWorkspace.addDatabaseFromGDX(String)

Member Function Documentation

◆ addEquation() [1/3]

GAMSEquation com.gams.api.GAMSDatabase.addEquation ( String  identifier,
GAMSGlobals.EquType  equType,
String  explanatoryText,
Object ...  domains 
)

Add equation symbol to database with domain information.

Note that a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set.

Parameters
identifierEquation name
equTypeGAMSGlobals.EquType equation subtype (E: Equal, G: Greater or Equal than Inequality, L: Less or Equal than Inequality, N: Non-binding equation, X: External equaion, C: Cone Equation)
explanatoryTextExplanatory text of equation
domainsArbitrary arguments of Equation domains
Returns
Reference to a GAMSEquation instance
Exceptions
GAMSExceptionIf either GAMSSet instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.
See also
GAMSGlobals.EquType

◆ addEquation() [2/3]

GAMSEquation com.gams.api.GAMSDatabase.addEquation ( String  identifier,
int  dimension,
GAMSGlobals.EquType  equType 
)

Add equation symbol to database.

Note that a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set.

Parameters
identifierEquation name
dimensionEquation dimension
equTypeGAMSGlobals.EquType equation subtype (E: Equal, G: Greater or Equal than Inequality, L: Less or Equal than Inequality, N: Non-binding equation, X: External equaion, C: Cone Equation)
Returns
Reference to a GAMSEquation instance
Exceptions
GAMSExceptionIf either GAMSSet instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.
See also
GAMSGlobals.EquType

◆ addEquation() [3/3]

GAMSEquation com.gams.api.GAMSDatabase.addEquation ( String  identifier,
int  dimension,
GAMSGlobals.EquType  equType,
String  explanatoryText 
)

Add equation symbol to database.

Note that a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set.

Parameters
identifierEquation name
dimensionEquation dimension
equTypeGAMSGlobals.EquType equation subtype (E: Equal, G: Greater or Equal than Inequality, L: Less or Equal than Inequality, N: Non-binding equation, X: External equaion, C: Cone Equation)
explanatoryTextExplanatory text of equation
Returns
Reference to a GAMSEquation instance
Exceptions
GAMSExceptionIf either GAMSSet instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.
See also
GAMSGlobals.EquType

◆ addParameter() [1/3]

GAMSParameter com.gams.api.GAMSDatabase.addParameter ( String  identifier,
int  dimension 
)

Add parameter symbol to database.


Note that a scalar is a parameter symbol with 0 dimension and a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set.

Parameters
identifierParameter name
dimensionParameter dimension
Returns
Reference to a GAMSEquation instance
Exceptions
GAMSExceptionIf either GAMSParameter instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed, therefore resources are no longer available.

◆ addParameter() [2/3]

GAMSParameter com.gams.api.GAMSDatabase.addParameter ( String  identifier,
int  dimension,
String  explanatoryText 
)

Add parameter symbol to database.

Note that a scalar is a parameter symbol with 0 dimension and a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set.

Parameters
identifierParameter name
dimensionParameter dimension
explanatoryTextExplanatory text of parameter
Returns
Reference to a GAMSEquation instance
Exceptions
GAMSExceptionIf either GAMSParameter instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed, therefore resources are no longer available.

◆ addParameter() [3/3]

GAMSParameter com.gams.api.GAMSDatabase.addParameter ( String  identifier,
String  explanatoryText,
Object ...  domains 
)

Add parameter symbol to database with domain information.

Note that a scalar is a parameter symbol with 0 dimension and a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set.

Parameters
identifierParameter name
explanatoryTextExplanatory text of parameter
domainsArbitrary arguments of Parameter domains
Returns
Reference to a GAMSEquation instance
Exceptions
GAMSExceptionIf either GAMSParameter instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed, therefore resources are no longer available.

◆ addSet() [1/6]

GAMSSet com.gams.api.GAMSDatabase.addSet ( String  identifier,
GAMSGlobals.SetType  setType,
String  explanatoryText,
Object ...  domains 
)

Add set symbol to database with domain information.

Note that a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set.

Parameters
identifierSet name
setTypeGAMSGlobals.SetType set subtype
explanatoryTextExplanatory text of set
domainsArbitrary arguments of Set domains
Returns
Reference to a GAMSSet instance
Exceptions
GAMSExceptionIf either GAMSSet instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.

◆ addSet() [2/6]

GAMSSet com.gams.api.GAMSDatabase.addSet ( String  identifier,
int  dimension 
)

Add set symbol to database.

Note that a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set. Set is of multi set type by default.

Parameters
identifierSet name
dimensionSet dimension
Returns
Reference to a GAMSSet instance
Exceptions
GAMSExceptionIf either GAMSSet instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.

◆ addSet() [3/6]

GAMSSet com.gams.api.GAMSDatabase.addSet ( String  identifier,
int  dimension,
GAMSGlobals.SetType  setType 
)

Add set symbol to database.

Note that a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set.

Parameters
identifierSet name
dimensionSet dimension
setTypeGAMSGlobals.SetType set subtype
Returns
Reference to a GAMSSet instance
Exceptions
GAMSExceptionIf either GAMSSet instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.

◆ addSet() [4/6]

GAMSSet com.gams.api.GAMSDatabase.addSet ( String  identifier,
int  dimension,
GAMSGlobals.SetType  setType,
String  explanatoryText 
)

Add set symbol to database.

Note that a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set.

Parameters
identifierSet name
dimensionSet dimension
setTypeGAMSGlobals.SetType set subtype
explanatoryTextexplanatory text of set
Returns
Reference to a GAMSSet instance
Exceptions
GAMSExceptionIf either GAMSSet instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.

◆ addSet() [5/6]

GAMSSet com.gams.api.GAMSDatabase.addSet ( String  identifier,
int  dimension,
String  explanatoryText 
)

Add set symbol to database.

Note that a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set. Set is of multi set type by default.

Parameters
identifierSet name
dimensionSet dimension
explanatoryTextexplanatory text of set
Returns
Reference to a GAMSSet instance
Exceptions
GAMSExceptionIf either GAMSSet instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.

◆ addSet() [6/6]

GAMSSet com.gams.api.GAMSDatabase.addSet ( String  identifier,
String  explanatoryText,
Object ...  domains 
)

Add set symbol to database with domain information.

Note that a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set. Set is of multi set type by default.

Parameters
identifierSet name
explanatoryTextExplanatory text of set
domainsArbitrary arguments of Set domains
Returns
Reference to a GAMSSet instance
Exceptions
GAMSExceptionIf either GAMSSet instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.

◆ addVariable() [1/3]

GAMSVariable com.gams.api.GAMSDatabase.addVariable ( String  identifier,
GAMSGlobals.VarType  varType,
String  explanatoryText,
Object ...  domains 
)

Add variable symbol to database with domain information.

Note that a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set.

Parameters
identifierVariable name
varTypeGAMSGlobals.VarType variable subtype (BINARY, INTEGER, POSITIVE, NEGATIVE, FREE, SOS1, SOS2, SEMICONT, SEMIINT)
explanatoryTextExplanatory text to variable
domainsArbitrary arguments of Variable domains
Returns
Reference to a GAMSVariable instance
Exceptions
GAMSExceptionIf either GAMSVariable instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.
See also
GAMSGlobals.VarType

◆ addVariable() [2/3]

GAMSVariable com.gams.api.GAMSDatabase.addVariable ( String  identifier,
int  dimension,
GAMSGlobals.VarType  varType 
)

Add variable symbol to database.

Note that a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set.

Parameters
identifierVariable name
dimensionVariable dimension
varTypeGAMSGlobals.VarType variable subtype (BINARY, INTEGER, POSITIVE, NEGATIVE, FREE, SOS1, SOS2, SEMICONT, SEMIINT)
Returns
Reference to a GAMSVariable instance
Exceptions
GAMSExceptionIf either GAMSVariable instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.
See also
GAMSGlobals.VarType

◆ addVariable() [3/3]

GAMSVariable com.gams.api.GAMSDatabase.addVariable ( String  identifier,
int  dimension,
GAMSGlobals.VarType  varType,
String  explanatoryText 
)

Add variable symbol to database.

Note that a symbol with name "*" could not be added to the database as it is reserved as a special symbol of type GAMSSet representing universe set.

Parameters
identifierVariable name
dimensionVariable dimension
varTypeGAMSGlobals.VarType variable subtype (BINARY, INTEGER, POSITIVE, NEGATIVE, FREE, SOS1, SOS2, SEMICONT, SEMIINT)
explanatoryTextExplanatory text to variable
Returns
Reference to a GAMSVariable instance
Exceptions
GAMSExceptionIf either GAMSVariable instance could not be successfully added to the database, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.
See also
GAMSGlobals.VarType

◆ checkDomains()

boolean com.gams.api.GAMSDatabase.checkDomains ( )

Check all GAMSSymbol<T extends GAMSSymbolRecord> instances in the database if all their records are within the specified domain of the symbol.

Returns
true if every symbol does not contain a domain violation, false otherwise.
See also
GAMSDatabase.getDatabaseDomainViolations(int, int)
GAMSSymbol.checkDomains()
GAMSSymbol.getSymbolDomainViolations(int)

◆ clear()

void com.gams.api.GAMSDatabase.clear ( )

Clear all symbol records in the database.

The number of symbols in the database remains the same.

Exceptions
GAMSExceptionIf either there is a GAMSSymbol that could not be cleared, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.

◆ dispose()

void com.gams.api.GAMSDatabase.dispose ( )

Release external resources hold by non-java library.

A subsequent call on the object after disposed potentially causes an unexpected error or exception.

Call this method either when the object is no longer needed and/or when resource management is a critical issue in the application.

◆ export() [1/2]

void com.gams.api.GAMSDatabase.export ( )

Write database into a GDX file.

The file is written to the working directory using the name of the database.

Exceptions
GAMSExceptionIf this GAMSDatabase instance has already been disposed therefore resources are no longer available.

◆ export() [2/2]

void com.gams.api.GAMSDatabase.export ( String  filePath)

Write database into a GDX file.

Parameters
filePathThe path used to write the GDX file. A relative path is relative to the GAMS working directory. If not present or null given, the file is written to the working directory using the name of the database.
Exceptions
GAMSExceptionIf this GAMSDatabase instance has already been disposed therefore resources are no longer available or there is an error writing a gdx file.

◆ finalize()

void com.gams.api.GAMSDatabase.finalize ( ) throws Throwable
protected

Release resources used by non-java library.

◆ getDatabaseDomainViolations()

List< GAMSDatabaseDomainViolation > com.gams.api.GAMSDatabase.getDatabaseDomainViolations ( int  maxViolation,
int  maxViolationPerSymbol 
)

Check all GAMSSymbol<T extends GAMSSymbolRecord> instances in the database if all their records are within the specified domain of the symbol.

It returns a list of GAMSDatabaseDomainViolation instances containing a domain violation information for problematic symbols in a GAMSDatabase instance. Each GAMSDatabaseDomainViolation instance contains information of which GAMSSymbol instance whose domain is violated and a list of GAMSDatabaseDomainViolation instances containing all domain violation records of the GAMSSymbol instance.

Parameters
maxViolationThe maximum number of domain violation records which should be stored (0 for no limit)
maxViolationPerSymbolThe maximum number of domain violations records which should be stored per Symbol (0 for no limit)
Returns
a list of GAMSDatabaseDomainViolation containing a domain violation information for each symbol in a GAMSDatabase instance.
Exceptions
GAMSExceptionif there is an error checking domain violations
See also
GAMSDatabase.checkDomains()
GAMSSymbol.checkDomains()
GAMSSymbol.getSymbolDomainViolations(int)

◆ getEquation()

GAMSEquation com.gams.api.GAMSDatabase.getEquation ( String  identifier)

Get GAMSEquation by name.

Parameters
identifierName of the equation to retrieve
Returns
Reference to a GAMSEquation instance
Exceptions
GAMSExceptionIf either a GAMSEquation with the given name could not be found in GAMSDatabase, or this GAMSDatabase instance has already been disposed, therefore resources are no longer available.

◆ getName()

String com.gams.api.GAMSDatabase.getName ( )

Get GAMSDatabase name.

Returns
name of GAMSDatabase instance

◆ getNumberOfSymbols()

int com.gams.api.GAMSDatabase.getNumberOfSymbols ( )

Get the number of symbols in GAMSDatabase.

Note that a symbol with name "*" is not included when counting the number of symbols as it is reserved as a special symbol of type GAMSSet representing universe set.

Returns
the number of GAMSSymbols
Exceptions
GAMSExceptionIf this GAMSDatabase instance has already been disposed therefore resources are no longer available or there is an error getting the number of symbols.

◆ getParameter()

GAMSParameter com.gams.api.GAMSDatabase.getParameter ( String  identifier)

Get GAMSParameter by name.

Parameters
identifierName of the parameter to retrieve
Returns
Reference to a GAMSParameter instance
Exceptions
GAMSExceptionIf either a GAMSParameter with the given name could not be found in GAMSDatabase, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.

◆ getSet()

GAMSSet com.gams.api.GAMSDatabase.getSet ( String  identifier)

Get GAMSSet by name.

Parameters
identifierName of the set to retrieve
Returns
Reference to a GAMSSet instance
Exceptions
GAMSExceptionIf either a GAMSSet with the given name could not be found in GAMSDatabase, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.

◆ getSymbol()

GAMSSymbol<?> com.gams.api.GAMSDatabase.getSymbol ( String  identifier)

Get GAMSSymbol<T extends GAMSSymbolRecord> by name.

Parameters
identifierName of the symbol to retrieve
Returns
Reference a GAMSSymbol instance
Exceptions
GAMSExceptionIf either a GAMSSymbol with the given name could not be found in GAMSDatabase, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.
See also
GAMSSymbol<T extends GAMSSymbolRecord>

◆ getVariable()

GAMSVariable com.gams.api.GAMSDatabase.getVariable ( String  identifier)

Get GAMSVariable by name.

Parameters
identifierName of the variable to retrieve
Returns
reference to a GAMSVariable instance
Exceptions
GAMSExceptionIf either a GAMSVariable with the given name could not be found in GAMSDatabase, or this GAMSDatabase instance has already been disposed therefore resources are no longer available.

◆ isAutoDomainCheckingSuppressed()

boolean com.gams.api.GAMSDatabase.isAutoDomainCheckingSuppressed ( )

Determine whether domain checking will be called when export GAMSDatabase.

Returns
true, if domain checking will not be called, false otherwise.

◆ isDisposed()

boolean com.gams.api.GAMSDatabase.isDisposed ( )

Inquire if this database has already been disposed.

Returns
true if disposed, false otherwise

◆ iterator()

Iterator< GAMSSymbol<?> > com.gams.api.GAMSDatabase.iterator ( )

Returns an iterator over a set of elements of type T.

Returns
an iterator over a set of elements of type T.
Exceptions
GAMSExceptionIf this GAMSDatabase instance has already been disposed therefore resources are no longer available.

◆ suppressAutoDomainChecking()

void com.gams.api.GAMSDatabase.suppressAutoDomainChecking ( boolean  value)

Controls whether domain checking will be called when export GAMSDatabase.

Parameters
valuetrue, if domain checking will not be called, false otherwise.