Loading...
Searching...
No Matches
Examples List
Here are the examples with brief descriptions:
[detail level 123]
 NAlias
 CAliasThe Object-oriented API does not have the concept of a GAMS alias. An alias cannot be entered into a GAMSDatabase by API methods. Nevertheless, if the GAMSDatabase is loaded from a GDX container (e.g. the GAMSJob.OutDB), the database can contain aliases. Such an alias can be retrieved as a GAMSSet and consists of the elements of the aliased set. The method to find out if a GAMSSet in a GAMSDatabase is indeed an alias is to check if the symbol name is different from the lookup name (i.e. bool isAlias = db.GetSet("ii").Name != "ii"). This example model goes through the logic of how aliases are handled in the Object-oriented API
 NBendersDecomposition2StageSP
 CBenders2StageThis example demonstrates a sequential implementation of a simple Benders decomposition method for a stochastic linear program. The underlying model implements a simple distribution system with stochastic demand data. The master and the subproblems are implemented with the GAMSModelInstance object which allows resolving the model with modified input without regenerating the model. A GAMSModelInstance has a fixed model rim, so this provides a challenge for Benders master problem because every iteration adds new constraints (the Benders cuts) to the master. We get around this limitation of GAMSModelInstance by initializing the GAMSModelInstance of the master with a fixed number of empty (i.e. non-binding) placeholders constraints and during the run of the algorithm turn these placeholder constraints into valid Benders cuts
 CBenders2StageMTThis example demonstrates a parallel implementation of a simple Benders decomposition method for a stochastic linear program. The underlying model implements a simple distribution system with stochastic demand data. This parallel version extends the Benders2Stage example by solving the independent subproblems in parallel. For that we need to instantiate a separate GAMSModelInstance for each parallel worker. We use the efficient GAMSModelInstance.copyModelInstance method to accomplish this in the most effective way. The number of demand scenarios can be larger than the number of parallel workers. The distribution of work is handled through a work queue. The parallel execution of the subproblems is done in separate threads (the MT in the name of the example stands for Multi Threading), so there is very little overhead from disk activity
 NClad
 CCladThis example demonstrates how to implement a complex termination criterion for a difficult MIP using GAMS/Cplex. We would like to achieve a globally optimal solution (relative gap 0%) but if solution time becomes larger than n1 seconds, we can compromise for a 10% gap, and if this is not achieved after n2 seconds, we compromise for a 20% gap, and again if this is not accomplished in n3 seconds we take whatever the solver has done so far and terminate the solve. This is implemented by executing GAMSJob.run in an independent thread and providing new tolerances for the relative gap in the main thread by supplying new GAMS/Cplex option files and triggers the processing of the new tolerance option by GAMS/Cplex through the GAMSJob.Interrupt method
 NCutstock
 CCutstockThis example implements a column generation approach to solve the cutting stock problem. In this example, the column generation approach has been entirely implemented in the program using GAMSJob for the master and GAMSModelInstance for the pricing problem. GAMS is used to build the master and pricing problems. The logic of the column generation method is in the application program
 CSimpleCutstockThis example implements a column generation approach to solve the cutting stock problem. In this program, the column generation scheme has been implemented in GAMS. Moreover the GAMS model with the input and output data has been wrapped in a class that separates all interaction with GAMS from the driving application
 NCutStockGUI
 CCutWidthsControl
 CForm1This example allows to either load data from a database or to enter data manually. A cutting stock problem is solved by using both the GAMSJob and the GAMSModelInstance class in order to implement a decomposition approach. See also GMSCutStock Example
 NDemo1GUI
 CForm1For this farming model, the input data can be entered directly into several tables. The GAMS model itself is executed by using one single GAMSJob instance. Results are displayed in different charts and tables
 NDomainChecking
 CDomainCheckingEnforcing referential integrity also known in the GAMS lingo as domain checking is an essential and important part of GAMS. The Object- oriented 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.CheckDomains (or GAMSSymbol.CheckDomains) method. The Object- oriented 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.SuppressAutoDomainChecking property. This example demonstrates how to trigger domain checking and how to access the records that violate the referential integrity
 NGamsApiTests
 CHouseKeeper
 CProgramThis example contains all the unit tests we run on the .Net Object- oriented API
 CTestGAMSDatabase
 CTestGAMSIterator
 CTestGAMSJob
 CTestGAMSModelInstance
 CTestGAMSOptions
 CTestGAMSPerformance
 CTestGAMSSymbol
 CTestGAMSSymbolRecord
 CTestGAMSWorkspace
 CTestGAMSWorkspaceInfo
 NGAMSClient
 CGAMSClientClassThis example demonstrates how to implement a simple GAMS Server. The example has two parts: GAMSServer and GAMSClient. The example is configured to run the client and server on the same machine, but can easily be altered to run on different machines. Both client and server need access to the GAMSRemoteClass that implements the server. The method to communicate is very simple. The client sets up the ingredients for a GAMSJob (model text, GDX input, parameters) and sends them serialized (via a byte representation of the GDX and parameter file) to the server. The server recreates the GAMS objects from the serialized representations, runs the model, and ships GAMSJob.OutDB serialized back to the client for further processing
 NGAMSRemoteObject
 CGAMSRemoteClassThis example demonstrates how to implement a simple GAMS Server. The example has two parts: GAMSServer and GAMSClient. The example is configured to run the client and server on the same machine, but can easily be altered to run on different machines. Both client and server need access to the GAMSRemoteClass that implements the server. The method to communicate is very simple. The client sets up the ingredients for a GAMSJob (model text, GDX input, parameters) and sends them serialized (via a byte representation of the GDX and parameter file) to the server. The server recreates the GAMS objects from the serialized representations, runs the model, and ships GAMSJob.OutDB serialized back to the client for further processing
 NGAMSServer
 CGAMSServerClass
 NInterrupt
 CInterruptCtrl-C in a regular console application results in the interrupt of the entire job. GAMS users are used to the fact that Ctrl-C interrupts a solve but then continues with the execution of the remaining GAMS job. The example demonstrates how to alter some console properties to get this behavior of Ctrl-C
 NInterruptGui
 CForm1This small example demonstrates how to run a GAMS model in a graphical user interface. This has all rudimentary features we know from the GAMS IDE: starting a job, capture the GAMS log in a window, and providing a button to interrupt. The underlying mechanism to interrupt the job is similar to the Interrupt.Interrupt example (GAMSJob.Interrupt), but the trigger mechanism is very different
 CTextBoxBaseWriter
 NMarkowitz
 CForm1This is a small graphical program that plots the efficient frontier of Markowitz' portfolio selection problem with the two objectives return and risk. The example utilizes the GAMSModelInstance class to solve the parameterized objective max lambda*return - (1-lambda)*risk in the most efficient way
 NMessageReceiverWindow
 CForm1The little example demonstrates how to implement a custom visual log. From GAMS one can send messages to the form started by this program via the put_utility "winmsg". The form also understands some commands (a message that starts with @) to save the content of the form, to put the content into the clipboard, or to terminate the program. The MessageReceiverWindow is also distributed as an executable in the GAMS system directory ready to be used. The model mrw01 in the GAMS Test Library demonstrates the use of the program
 CCOPYDATASTRUCT
 NSpecialValues
 CSpecialValuesThis example shows how special values of the programming language (e.g. infinity) percolate down to GAMS. Infinity and NaN (not a number) are well defined. The GAMS Undefined and EPS need special considerations
 NTransportGUI
 CForm1In this example a series of transportation problems is solved using GAMSModelInstance. Data can be entered into tables or can be loaded from a database. When data is entered into a table, related tables are updated automatically. Results are shown in tables and a bar chart. See also Transport Model Sequence Example
 NTransportSeq
 COptimizer
 CTransportWrapper class for GAMS trnsport model
 CTransport1This is the 1st model in a series of tutorial examples. Here we show:

  • How to run a GAMSJob from file
  • How to specify the solver
  • How to run a job with a solver option file
  • How to capture the log output of a GamsJob
 CTransport10This is the 10th model in a series of tutorial examples. Here we show:

  • How to fill a GAMSDatabase by reading from MS Excel
 CTransport11This is the 11th model in a series of tutorial examples. Here we show:

  • How to create and use a save/restart file
 CTransport12This is the 12th model in a series of tutorial examples. Here we show:

  • How to implement a GUSS approach using the GAMS API
 CTransport13This is the 13th model in a series of tutorial examples. Here we show:

  • How to run a GAMSJob using a wrapper class to package a particular GAMS model
 CTransport14This is the 14th model in a series of tutorial examples. Here we show:

  • How to run multiple GAMSJobs in parallel each using different scenario data
 CTransport2This is the 2nd model in a series of tutorial examples. Here we show:

  • How to use include files to separate model and data
 CTransport3This is the 3rd model in a series of tutorial examples. Here we show:

  • How to read data from string and export to GDX
  • How to run a job using data from GDX
  • How to run a job using implicit database communication
 CTransport4This is the 4th model in a series of tutorial examples. Here we show:

  • How to define data using C# data structures
  • How to prepare a GAMSDatabase from C# data structures
 CTransport5This is the 5th model in a series of tutorial examples. Here we show:

  • How to initialize a GAMSCheckpoint by running a GAMSJob
  • How to initialize a GAMSJob from a GAMSCheckpoint
 CTransport6This is the 6th model in a series of tutorial examples. Here we show:

  • How to run multiple GAMSJobs in parallel using a GAMSCheckpoint
 CTransport7This is the 7th model in a series of tutorial examples. Here we show:

  • How to create a GAMSModelInstance from a GAMSCheckpoint
  • How to modify a parameter of a GAMSModelInstance using GAMSModifier
  • How to modify a variable of a GAMSModelInstance using GAMSModifier
 CTransport8This is the 8th model in a series of tutorial examples. Here we show:

  • How to use a queue to solve multiple GAMSModelInstances in parallel
 CTransport9This is the 9th model in a series of tutorial examples. Here we show:

  • How to fill a GAMSDatabase by reading from MS Access
 CTransportEngineThis is an example how to run a GAMSJob on GAMS Engine using the run_engine method:

  • How to send along additional model files(besides the main file) How to provide additional Engine options How to use checkpoints with run_engine How to interrupt a GAMSJob running on GAMS Engine
 CTransportGDXThis example shows the use of the GAMSDatabase class for reading and writing GDX files. In particular this example shows:

  • How to fill a GAMSDatabase from C# data structures and export it to a GDX file
  • How to import a GDX file as a GAMSDatabase
 NTsp
 CTspThis example demonstrates how to use a GAMSModelInstance to implement the subtour elimination algorithm for the Traveling Salesman Problem (TSP) problem. Similar to Benders2Stage example, we have a placeholder for the subtour elimination constraint that gets generated in each iteration of the algorithm. In contrast to the Benders example, here we regenerate the GAMSModelInstance if the original number of placeholders was not big enough. We continue this process until all subtours are eliminated
 NWarehouse
 CWarehouseThis example demonstrates how to solve a simple GAMS model to assign stores to warehouses for different data sets in parallel. The model has been parameterized. The data can be derived from a few numbers namely the number of warehouses, stores, and some fixed cost scalar. The results of the model are written into a single result database that is protected across the parallel threads via a mutex