Skip to content

How to Run the Model

Practical reference for running TargetEcon 2026 in GAMS.


Prerequisites

  • GAMS installed with a valid MIP solver license (CPLEX recommended; GUROBI also works)
  • All .inc data files present in the same directory as the main .gms file
  • The VP2 GDX file: VP2_OCT2021_Raphael_collective_measures.gdx in the same directory
  • The P transport matrix CSV files: p_transp_matrix_NEW.csv and p_transp_matrix_k.csv

Key solver settings (top of .gms)

option iterlim  = 999999999;  // effectively unlimited iterations
option reslim   = 36000;      // 10-hour time limit
option optcr    = 0.001;      // 0.1% optimality gap tolerance
option threads  = 0;          // use all available CPU threads
option solvelink = 2;
option profile  = 9;

The optcr = 0.001 means the solver stops when it finds a solution within 0.1% of the proven optimum. For large runs, loosening this (e.g. to 0.01) can dramatically reduce solve time at small cost in solution quality.


Scenario configuration

Before running, set the scenario scalars:

Scalar var_N /1/;   // 1 = N targets active, 0 = off
Scalar var_B /0/;   // biodiversity (not yet implemented)
Scalar var_C /0/;   // climate (not yet implemented)
Scalar var_P /1/;   // 1 = P targets active, 0 = off

To deactivate Tripartite Agreement constraints, comment out or set to 0:

* Lavbund_eq, Afforestation_eq, Wetland_eq, MW_eq, LRH_eq, SA_eq

To lock out specific measures:

x.UP(i,"CCS") = 0;    // deactivate CCS nationwide
v_w.UP(w,"ochre") = 0; // deactivate ochre traps


Solve command

Model catchment /all/;
catchment.OptFile = 1;           // reads solver options from cplex.opt (or gurobi.opt)
solve catchment using mip minimizing yy;

The model minimizes yy (total cost + penalties for unmet targets).


Output

The model produces a .lst file with solution details. Key solution values to examine: - y.l — total annual cost (DKK/yr) - x.l(i,j) — binary field-measure decisions - kr.l(k) — N reduction achieved per coastal catchment (tons N/yr) - exceed.l(k) — unmet N target per catchment (should be 0 if feasible) - P_Red_aft_ret.l(lakecatch) — P reduction achieved per lake catchment - exceed_p.l(lakecatch) — unmet P target (should be 0) - Total_cost_k.l(k) — cost by coastal catchment

For detailed results, the reporting section of the full .gms file (removed in the _without_reporting version) writes GDX and/or Excel outputs via put files.


Typical solve times

To be filled as scenarios are run. Expected ranges based on model size: - N-only, no tripartite: fast (minutes to ~1 hour) - N+P with tripartite: longer (hours — P module adds many binary variables via stream measures) - Full model with tight optcr: potentially many hours


Common issues

Issue Likely cause Fix
exceed(k) > 0 for some catchments N target infeasible — not enough potential Check N_Targets(k) vs available PotV in that catchment
exceed_p > 0 for some lake catchments P target infeasible Check P_targets vs P_Effects_Total availability
Solve time excessive Too many binary variables Loosen optcr, or restrict measure sets
Memory error Too many active sets Use $offlisting / $onlisting to suppress output
GDX file not found VP2 GDX missing Ensure VP2_OCT2021_Raphael_collective_measures.gdx is in run directory

File checklist before running

  • [ ] TargetEcon 2026.gms (main model)
  • [ ] All .inc files listed in data/inc_files_overview.md
  • [ ] VP2_OCT2021_Raphael_collective_measures.gdx
  • [ ] p_transp_matrix_NEW.csv
  • [ ] p_transp_matrix_k.csv
  • [ ] differentiation_effects.inc
  • [ ] Solver option file (cplex.opt or equivalent)