Loading...
Searching...
No Matches
domain_checking.py File Reference

Enforcing referential integrity also known in the GAMS lingo as domain checking is an essential and important part of GAMS. More...

Go to the source code of this file.

Variables

sys domain_checking.sys_dir = sys.argv[1] if len(sys.argv) > 1 else None
 
GamsWorkspace domain_checking.ws = GamsWorkspace(system_directory=sys_dir)
 
list domain_checking.plants = ["Seattle", "San-Diego"]
 
list domain_checking.markets = ["New-York", "Chicago", "Topeka"]
 
dict domain_checking.capacity = {"Seattle": 350.0, "San-Diego": 600.0}
 
dict domain_checking.demand = {"New-York": 325.0, "Chicago": 300.0, "Topeka": 275.0}
 
dict domain_checking.distance
 
GamsWorkspace domain_checking.db = ws.add_database()
 
GamsWorkspace domain_checking.i = db.add_set("i", 1, "canning plants")
 
GamsSet domain_checking.j = GamsSet(db, "j", 1, "markets")
 
GamsWorkspace domain_checking.a = db.add_parameter_dc("a", [i], "capacity at plant")
 
 domain_checking.value
 
GamsWorkspace domain_checking.b = db.add_parameter_dc("b", ["j"], "demand at market j in cases")
 
GamsWorkspace domain_checking.d = db.add_parameter_dc("d", [i, j], "distance in thousands of miles")
 
int domain_checking.dv_count = 0
 
 domain_checking.end
 
 domain_checking.vi
 
 domain_checking.try :
 
 domain_checking.except :
 
 domain_checking.suppress_auto_domain_checking
 
 domain_checking.else :
 
GamsWorkspace domain_checking.db2 = ws.add_database_from_gdx("test.gdx")
 
GamsWorkspace domain_checking.d2 = db2["d"]
 
GamsWorkspace domain_checking.j_alias
 
GamsWorkspace domain_checking.ii = j_alias.out_db["ii"]
 
GamsWorkspace domain_checking.test_db = ws.add_database()
 
GamsWorkspace domain_checking.test_set = test_db.add_set("test", 1)
 
 domain_checking.text
 

Detailed Description

Enforcing referential integrity also known in the GAMS lingo as domain checking is an essential and important part of GAMS.

The control API does a delayed domain checking of symbols. So you can add records to a domain controlled parameter (e.g. p(i)) even though the GamsSet i does not contain the label (yet). The user can trigger an explicit check of the referential integrity by calling the GamsDatabase.check_domains (or GamsSymbol.check_domains) method. The control API provides methods to access the records that violate the referential integrity (see GamsDatabaseDomainViolation for details). Domain checking is implicitly done when the GamsDatabase is exported to a GDX file via the GamsDatabase.export method or for databases provided in the GamsJob.run method. The implicit domain check can be suppressed (and left to GAMS when importing data) via the GamsDatabase.suppress_auto_domain_checking property. This example demonstrates how to trigger domain checking and how to access the records that violate the referential integrity.

Definition in file domain_checking.py.