Skip to content

sei-international/leap-weap-integration

Repository files navigation

Integrating LEAP, WEAP, and AMES

The scripts in this repository implement the integration between LEAP/NEMO, WEAP, and AMES for the USAID WAVE Central Asia project. The integration script, which is written in Python, executes each program iteratively until convergence. Both LEAP and WEAP require Windows to run, and the full integration can consume substantial computer resources. The computer on which this script is run should have a reasonably fast processor and, more important, ample RAM and disk drive space.

Installation

In addition to the integration script itself, it is necessary to install Python, LEAP (with NEMO), WEAP, AMES, and Microsoft Excel. It is also recommended to install the Notepad++ text editor, for reasons explained below.

Installing Python

Download and install the latest Python 3 release.

  • Look for the "Windows installer", and select either 32-bit or 64-bit, depending on your computer hardware.
  • When you run the installer, make sure to check "Add python.exe to PATH".
  • After installing, open a Windows command prompt and run the following command:
     pip install pywin32 psutil PyYaml numpy pandas XlsxWriter
    

Installing NEMO, LEAP, WEAP, and AMES

For LEAP and WEAP, a license is required. Go to the LEAP and WEAP websites to obtain licenses. You may be eligible for a free or reduced-cost license. Use the contact information on the websites for more information.

Both NEMO and AMES are written in Julia. They are open-source programs and do not require licenses. NEMO will install a copy of Julia, so it is convenient to install NEMO before AMES.

To set up the full system:

  1. Go to the WEAP download page, log in, download WEAP, and install it;
  2. Go to the LEAP download page, log in, download LEAP and NEMO, and install both of them;
  3. Go to the AMES installation page and follow the instructions.

If the AMES installation gives an error relating to Julia's CSV package or Parsers.Options, revert to version 0.10.4 of the CSV package:

  1. Open a Julia prompt;
  2. Press the ] key to start the package manager;
  3. Type add CSV@0.10.4 and press enter to install version 0.10.4.

Installing Excel

Install Excel in the usual way. Then it is recommended to disable Excel's AutoRecover feature, as it can cause problems when restarting Excel after a crash of the integration program. To do this in Excel for Microsoft 365 (Version 2403 from April 2024), open Excel, choose File -> Options -> Save, and clear the checkbox for "Save AutoRecover information".

Installing the integration program

The integration program, with configuration scripts and translations, is available as a ZIP file. It is included as part of a release of the integration software on this site. Download the most recent ZIP file and unzip it in a convenient location on your computer.

Note that the integration program requires the Julia ArgParse package. You must add it manually:

  1. Open a Julia prompt;
  2. Press the ] key to start the package manager;
  3. Type add ArgParse and press enter.

Loading the models

Find the most recent LEAP and WEAP models. These will be made available separately -- for example, via Dropbox. They should have .leap and .weap extensions. Open the files by double-clicking on them, and they will be added to the areas available inside LEAP and WEAP. Then enable scripts in LEAP by going to Settings -> Scripts and choosing to run all scripts without approval. This is necessary because the integration program dynamically adds a script to the LEAP model to improve the robustness of LEAP's interactions with Excel.

The most recent AMES files will also be available separately. These are in the form of folders, such as "KAZ_Macro". To use the integration program out of the box, do the following:

  1. Find where the LEAP Areas folder is located (its "parent" folder) -- this will usually be your Documents folder;
  2. In the LEAP Areas parent folder (e.g., Documents), create a new folder called WAVE_Macro.
  3. Copy all of the AMES models into that folder.

If you prefer a different folder name, you will need to change the name in the config.yml configuration file for the integration script.

Running the integration program

  1. Navigate to the folder where you have installed the integration program.
  2. Open the scenarios.yml file and confirm that the WEAP and LEAP scenarios are properly mapped one to the other. (It is convenient to view the file in Notepad++ because it color-codes the text to make it easier to read.)
  3. Open the config.yml file and confirm that the correct LEAP and WEAP Areas are listed.
  4. Start LEAP and then
  5. Open the most recent WAVE LEAP area;
  6. Select the scenarios that you wish to run;
  7. Select the end year for the run.
  8. Start WEAP and open the most recent WAVE WEAP area.
  9. If available, double-click on the wave_integration.exe file or open a terminal window and run the file from there
    • change directory to leap-weap-integration folder
    • .\run.bat

The integration program will generate a log file. The log file will have the time stamp and end in .log. (E.g., wave_integration_2023-06-24UTC15_02_54.log.) The progress of the program can be monitored by watching the log file. There are at least two ways to do that:

  • Open the log file in Notepad++ and click the "eye" icon (the Monitoring (tail -f) command);
  • Open a Windows PowerShell window and run Get-Content logfilename.log -Wait, where logfilename.log is the name of the log file.