Validate CGE-Core Against the Official GAMS stdcge Model#

This guide reproduces the official Hosoe–Gasawa–Hashimoto standard CGE model in GAMS and compares it with CGE-Core.

The purpose is not merely to confirm that CGE-Core runs. The purpose is to check whether an independent implementation and solver reproduce the same benchmark and counterfactual results:

  • Reference implementation: official GAMS Model Library stdcge.gms

  • Reference solver: CONOPT

  • CGE-Core implementation: Pyomo

  • CGE-Core solver: IPOPT

Using a different modeling system and solver makes this a stronger validation than testing CGE-Core against itself.


1. What this validation checks#

The official GAMS run solves two states:

  1. the calibrated benchmark equilibrium;

  2. the counterfactual equilibrium after abolishing import tariffs.

The results can be compared with CGE-Core for:

  • benchmark utility;

  • counterfactual utility;

  • household demand;

  • factor allocation;

  • prices;

  • production, imports, and exports;

  • taxes and savings;

  • percentage changes;

  • Hicksian equivalent variation.

This validation is specific to the small standard CGE model from Hosoe, Gasawa, and Hashimoto. It does not by itself validate every possible model or dataset that could be used with CGE-Core.


2. Prerequisites#

You need:

  • a local clone of CGE-core;

  • GAMS installed;

  • a GAMS license that can solve the small stdcge model;

  • CONOPT available in the GAMS installation.

The detailed walkthrough below uses Windows and VS Code. Linux and macOS users can use an ordinary terminal and the equivalent commands in the next section. The GAMS demo license is sufficient for this small model.

Linux and macOS command equivalents#

The GAMS commands themselves are platform-neutral:

gamslib stdcge
gams stdcge.gms nlp=conopt o=stdcge_reference.lst \
  lo=4 lf=stdcge_reference.log
echo $?
cat listA1.csv

Record the source checksum with:

sha256sum stdcge.gms > stdcge_source_sha256.txt  # Linux
shasum -a 256 stdcge.gms > stdcge_source_sha256.txt  # macOS

Run these commands from validation/gams/stdcge, just as in the Windows walkthrough. The expected model results and comparison procedure are the same.


3. Open the repository in VS Code#

Open the local repository folder:

C:\Users\<YOUR NAME>\Documents\GitHub\CGE-core

Open a VS Code terminal:

Terminal → New Terminal

Return to the repository root if necessary:

cd /d "C:\Users\<YOUR NAME>\Documents\GitHub\CGE-core"

Example:

cd /d "C:\Users\James Matthew\Documents\GitHub\CGE-core"

4. Make GAMS available in the terminal#

Check whether Windows can find GAMS:

where gams

A successful result looks like:

C:\GAMS\54\gams.exe

If GAMS is installed but not on PATH#

Find the directory containing gams.exe. For example:

C:\GAMS\54

Temporarily add it to the current terminal:

set "PATH=C:\GAMS\54;%PATH%"

Verify:

where gams

This temporary change lasts only until the terminal is closed.

Permanent option#

Add the GAMS directory, such as C:\GAMS\54, to the Windows User Path:

  1. Open the Windows Start menu.

  2. Search for environment variables.

  3. Open Edit the system environment variables.

  4. Click Environment Variables.

  5. Under User variables, select Path.

  6. Click Edit.

  7. Click New.

  8. Add the GAMS directory.

  9. Confirm all dialogs.

  10. Restart VS Code.

Do not add the full gams.exe filename. Add only its containing directory.


5. Create a validation workspace#

From the repository root, run:

if not exist validation\gams\stdcge mkdir validation\gams\stdcge

Enter the folder:

cd validation\gams\stdcge

The terminal path should now end with:

CGE-core\validation\gams\stdcge>

6. Retrieve the official GAMS model#

Copy the official stdcge model from the installed GAMS Model Library:

gamslib stdcge

Confirm that the source file appeared:

dir

You should see:

stdcge.gms

Do not edit this file before validation. It is the independent reference implementation.


7. Record the exact source-file fingerprint#

Create a SHA-256 checksum:

certutil -hashfile stdcge.gms SHA256 > stdcge_source_sha256.txt

This records exactly which version of stdcge.gms was used.

The file created is:

stdcge_source_sha256.txt

8. Run the official model with CONOPT#

Run:

gams stdcge.gms nlp=conopt o=stdcge_reference.lst lo=4 lf=stdcge_reference.log

Meaning:

  • gams stdcge.gms runs the official model;

  • nlp=conopt explicitly selects CONOPT;

  • o=stdcge_reference.lst saves the full GAMS listing;

  • lo=4 displays progress and writes a log;

  • lf=stdcge_reference.log names the log file.

A successful run should contain:

*** Status: Normal completion

The model should solve twice:

  1. benchmark equilibrium;

  2. tariff-abolition counterfactual.


9. Check the process return code#

Immediately after the GAMS command, run:

echo %ERRORLEVEL%

Expected:

0

A nonzero value means the GAMS job did not finish normally and the listing and log should be inspected before comparing results.


10. Check the generated files#

Run:

dir

Expected files include:

listA1.csv
stdcge.gms
stdcge_reference.log
stdcge_reference.lst
stdcge_source_sha256.txt

The exact file sizes vary by GAMS version.


11. Inspect the compact GAMS output#

Display the CSV written by the official model:

type listA1.csv

A verified GAMS 54.2.1 / CONOPT 4.39.1 run produced:

"This is an example of usage of the Put command."

"dXp(i)"
"BRD",1.96
"MLK",2.51

"dTd",0.05

"F(h,j)"
"","BRD","MLK"
"CAP",20.43,29.57
"LAB",15.33,24.67

"beta(h,j)"
"","BRD","MLK"
"CAP",0.57,0.55
"LAB",0.43,0.45

These are rounded values written by the official GAMS model.


12. Compare with CGE-Core#

From the repository root, activate the CGE-Core environment if necessary:

conda activate cgecore

Run the Python implementation:

python -m cge_core.examples.stdcge

The verified CGE-Core/IPOPT run produced:

Objective values#

State

GAMS/CONOPT

CGE-Core/IPOPT

Benchmark utility

25.5084900125

25.508490012515818

Tariff-abolition utility

26.0926343813

26.092634381199485

The differences are approximately (10^{-10}) or smaller, which is consistent with normal floating-point and solver-tolerance differences.

Values written to listA1.csv#

Quantity

GAMS

CGE-Core

Comparison

dXp(BRD)

1.96%

1.960958%

same after rounding

dXp(MLK)

2.51%

2.509951%

same after rounding

dTd

0.05%

0.049350%

same after rounding

F(CAP,BRD)

20.43

20.426005

same after rounding

F(CAP,MLK)

29.57

29.573995

same after rounding

F(LAB,BRD)

15.33

15.333112

same after rounding

F(LAB,MLK)

24.67

24.666888

same after rounding

This confirms that the independent Pyomo/IPOPT implementation reproduces the official GAMS/CONOPT solution for these reported results.


13. Inspect the full listing#

Open this file in VS Code:

validation/gams/stdcge/stdcge_reference.lst

Useful searches:

MODEL STATUS
PARAMETER EV
PARAMETER dZ
PARAMETER dXp
PARAMETER dM
PARAMETER dE

You can also extract sections from the terminal.

Equivalent variation#

powershell -Command "Select-String -Path 'stdcge_reference.lst' -Pattern 'PARAMETER EV' -Context 0,4"

Selected percentage-change tables#

powershell -Command "Select-String -Path 'stdcge_reference.lst' -Pattern 'PARAMETER dZ|PARAMETER dXp|PARAMETER dM|PARAMETER dE' -Context 0,5"

The CGE-Core tariff-abolition example reports Hicksian equivalent variation of approximately:

EV = +1.1450

Confirm the corresponding value in the GAMS listing before recording it as a completed comparison.


14. Interpretation#

A successful comparison establishes more than successful execution.

The two systems differ in both implementation and nonlinear solver:

Official reference: GAMS + CONOPT
CGE-Core:          Pyomo + IPOPT

Agreement in the benchmark and tariff counterfactual therefore provides strong evidence that:

  • the SAM was interpreted correctly;

  • calibration formulas were ported correctly;

  • the model equations are solving to the same equilibrium;

  • the closure and numeraire are consistent with the reference model;

  • the tariff shock is applied correctly;

  • reported differences and percentages are correct.

It is still possible for untested features or other datasets to contain errors. This validation should therefore be described as replication of the official Hosoe standard-model benchmark and tariff experiment, not universal proof of correctness.



16. Suggested .gitignore entries#

Add these only if they match the repository’s intended validation workflow:

# GAMS-generated validation outputs
validation/gams/**/225a/
validation/gams/**/*.log
validation/gams/**/*.lst

# GAMS licenses must never be committed
**/gamslice.txt

Do not ignore the checksum or compact expected-results files if they are intended to be part of the permanent validation record.


17. Official references#


18. Reproduction record from 2 August 2026#

The validation documented here was performed with:

Operating system: Windows x86-64
GAMS:            54.2.1
CONOPT:          4.39.1
Python:          3.11.15
Pyomo:           6.10.1
IPOPT:           3.14.19
CGE-Core:        0.3.0

Observed GAMS model dimensions:

49 constraints
49 variables
179 Jacobian elements in the benchmark solve
175 Jacobian elements after the tariff shock

Observed completion status:

*** Status: Normal completion
ERRORLEVEL = 0