This repository contains a concise implementation of a 2-Region Armington Trade Model solved as a Mixed Complementarity Problem (MCP) using the GAMSPy framework and the PATH solver.
The model simulates trade flows between two regions (e.g., R1 and R2) based on the Armington assumption, where goods are differentiated by their place of origin.
Key Features:
- Market Structure: Perfect competition.
- Preferences: Constant Elasticity of Substitution (CES) utility.
-
Trade Costs: "Iceberg" transport costs (
$\tau \ge 1$ ). - Solver: Solved as an MCP (Mixed Complementarity Problem) to handle equilibrium conditions and lower bounds robustly.
The notebook includes detailed equations for:
- Bilateral Prices with Iceberg Costs.
- CES Price Indices.
- Iso-elastic Demand Functions.
- Market Clearing Conditions.
Prototype of Trade model.ipynb: The main Jupyter Notebook containing the math model, code, and visualization logic.output_csv/: Directory where simulation results are saved.requirements.txt: List of Python dependencies.
The model currently implements two distinct scenarios for comparison:
- Symmetric World: Identical demand elasticities and production capabilities for both regions.
- Constant Friction: Trade costs remain low and constant over time.
- Purpose: Validates the model logic (results should be symmetric).
- Demand Shock: Region 2 (representing EU) has different demand elasticities compared to R1 (China).
- Rising Costs: Trade costs from R1 to R2 increase over time (simulating tariffs or shipping disruptions).
- Supply Constraint: R2 has a capped supply capacity.
- Purpose: Analyzes how trade shares and price indices react to structural shocks.
Ensure you have Python installed. It is recommended to use a virtual environment.
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/simple-armington-gamspy.git cd simple-armington-gamspy -
Install dependencies:
pip install -r requirements.txt
Note: The
gamspypackage includes a community license that allows solving small-sized models (like this one) for free without a separate GAMS license.
Open the Jupyter Notebook:
jupyter notebook "Prototype of Trade model.ipynb"