Skip to content

philouhawi/Prototype-Trade-Model

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Two-Region Armington Trade Model with GAMSPy

Python GAMSPy

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.


📖 Model Overview

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:

  1. Bilateral Prices with Iceberg Costs.
  2. CES Price Indices.
  3. Iso-elastic Demand Functions.
  4. Market Clearing Conditions.

📂 Repository Structure

  • 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.

🧪 Scenarios

The model currently implements two distinct scenarios for comparison:

1. Baseline Scenario

  • 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).

2. China-EU Counterfactual (Asymmetric)

  • 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.

🚀 Getting Started

Prerequisites

Ensure you have Python installed. It is recommended to use a virtual environment.

Installation

  1. Clone the repository:

    git clone https://github.com/YOUR_USERNAME/simple-armington-gamspy.git
    cd simple-armington-gamspy
  2. Install dependencies:

    pip install -r requirements.txt

    Note: The gamspy package includes a community license that allows solving small-sized models (like this one) for free without a separate GAMS license.

Running the Model

Open the Jupyter Notebook:

jupyter notebook "Prototype of Trade model.ipynb"

About

This is the prototype for the trade model.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Jupyter Notebook 100.0%