Restarting Model from Midpoint
To avoid restarting from scratch when work is needed downstream of a specific calibration stage, the model uses a checkpoint system.
At key points in RunModel.bat, the database state is saved (via BreakPoint or SaveDatabase). To resume from any of these checkpoints, a copy of RunModel.bat is made, the database for that checkpoint is restored (UnZip), and the steps prior to that checkpoint are skipped.
|
|
🛈 |
A mid-run restart bat file can itself be run in either Fast or Debug mode by passing the appropriate argument — the DebugFlag is respected throughout RunModel.bat. |
Procedure: Restarting from a Checkpoint
If you make a change to a Julia script file that is called from RunModel.bat, you can restart a run at the last checkpoint saved before the revised file is called.
Follow these steps to create a bat file that resumes the model run from a specific checkpoint.
Step 1 - Identify the checkpoint in RunModel.bat to restart.
If you made changes to any files called in RunModel.bat, identify where the file is called. Then move upwards in the file to locate the nearest "rem Call UnZip DB SceName".
|
|
🕮 |
Example Let's say you changed the file, PlantCharacteristics_Storage.jl and want to run the model starting at the last saved checkpoint before that file is called: Locate where PlantCharacteristics_Storage.jl is called in RunModel.bat and identify the closest call to unzip a database (rem Call Unzip DB).
In this example, "rem Call UnZip DB Calib" is the previous checkpoint saved before a call is made to PlantCharacteristics_Storage.jl. |
Step 2 — Verify the checkpoint database exists
Before creating a restart script, confirm that the checkpoint database was actually saved by a previous run. Checkpoint databases are stored as zip archives in the 2020Model directory. The file naming convention follows:
database_<CheckpointName>.zip
For example, for the Calib checkpoint:
database_Calib.zip
|
|
🛈 |
If the checkpoint zip does not exist, you must run up to that point first. Use RunAll_Debug.bat to produce Debug-only checkpoints such as Process2, CalibPrice, CalibRes, etc. |
Step 3 — Copy RunModel.bat
Create a copy of RunModel.bat with a descriptive name, for example:
RunFrom_Calib.bat
Do not edit the original RunModel.bat. The copy is your working file.
Step 4 — Uncomment the UnZip line for your checkpoint
Inside RunModel.bat, each checkpoint has a commented-out UnZip line near the BreakPoint call. Find the commented line for your target checkpoint and remove the rem prefix. For example, for Calib, find:
|
rem Call UnZip DB Calib |
and change it to:
|
Call UnZip DB Calib |
|
|
🛈 |
The UnZip call restores the saved database state for that checkpoint. Without this step, the model will run against whatever database is currently present, which will produce incorrect results. |
Step 5 — Delete all lines before unzipping the checkpoint database
Delete (or comment out) every line that executes before your checkpoint. The goal is to skip all the work that was already completed and saved into the checkpoint database.
Step 6 — Run the new bat file
Run your new bat file (in this example the batch file is: RunFrom_Calib4.bat) from the 2020Model directory, passing the desired mode flag.
Make the call to your new batch file either 1) directly from the terminal or 2) from a second batch file that makes the following call:
|
Call RunFrom_Calib4 Fast |
or for debug mode with intermediate outputs:
|
Call RunFrom_Calib4 Debug |
Notes and Cautions
- Debug-only checkpoints — Checkpoints marked Debug in the table above are only saved when RunAll_Debug.bat (or RunModel Debug) was used for the original run. If you ran in Fast mode, these intermediate databases will not exist.
- Never modify the original RunModel.bat — Always work from a named copy. This ensures the full pipeline bat files (RunAll, RunAll_Debug) continue to function correctly.
- TOM data — TOM input data processing (TOM_Outputs_from_TOM_to_CSV, RunDataReader TOM, CheckTOMDrivers, etc.) is performed in RunAll before RunModel is called. Restarting from any checkpoint within RunModel assumes TOM data is already loaded into the Process database and does not re-process TOM files.
- StartBase is not a BreakPoint checkpoint — StartBase is created via Call Zip Results rather than the BreakPoint mechanism and is stored as StartBase\database. To restart from StartBase (re-running only the scenario runs), reference StartBase\database directly rather than using an UnZip DB call.
- CalibInd and Calib are always saved in both modes — The BreakPoint calls for CalibInd and Calib are not conditional on the DebugFlag, so these checkpoints are always available regardless of whether the original run used Fast or Debug mode.