Commit 8922ffad authored by Erkka Rinne's avatar Erkka Rinne
Browse files

Can set input and output dirs using command line parameters

Use --input_dir=<path> and --output_dir=<path>. Defaults are ./input and ./output, respectively.
parent b341698f
......@@ -50,6 +50,12 @@ GAMS command line arguments
Switch model features on/off. See file inc/setting_sets.gms for available
features.
--input_dir=<path>
Directory to read input from. Defaults to './input'.
--output_dir=<path>
Directory to write output to. Defaults to './output'.
References
----------
......@@ -60,6 +66,12 @@ References
==========================================================================
$offtext
* Default values for input and output dir
$if not set input_dir $setglobal input_dir 'input'
$if not set output_dir $setglobal output_dir 'output'
* Make sure output dir exists
$if not dexist %output_dir% $call 'mkdir %output_dir%'
* Activate end of line comments and set comment character to '//'
$oneolcom
......@@ -67,10 +79,10 @@ $eolcom //
$onempty // Allow empty data definitions
* Output file streams
files log /''/, gdx, f_info /'output\info.txt'/;
files log /''/, gdx, f_info /'%output_dir%\info.txt'/;
* Include options file to control the solver
$include 'input\1_options.gms';
$include '%input_dir%\1_options.gms';
* === Definitions, sets, parameters and input data=============================
......@@ -83,14 +95,14 @@ $include 'inc\1e_inputs.gms' // Load input data
* === Variables and equations =================================================
$include 'inc\2a_variables.gms' // Define variables for the models
$include 'inc\2b_eqDeclarations.gms' // Equation declarations
$ifthen exist 'input\2c_alternative_objective.gms' // Objective function - either the default or an alternative from input files
$$include 'input\2c_alternative_objective.gms';
$ifthen exist '%input_dir%\2c_alternative_objective.gms' // Objective function - either the default or an alternative from input files
$$include '%input_dir%\2c_alternative_objective.gms';
$else
$$include 'inc\2c_objective.gms'
$endif
$include 'inc\2d_constraints.gms' // Define constraint equations for the models
$ifthen exist 'input/2e_additional_constraints.gms'
$$include 'input/2e_additional_constraints.gms' // Define additional constraints from the input data
$ifthen exist '%input_dir%/2e_additional_constraints.gms'
$$include '%input_dir%/2e_additional_constraints.gms' // Define additional constraints from the input data
$endif
......@@ -100,7 +112,7 @@ $include 'defModels\building.gms'
$include 'defModels\invest.gms'
// Load model input parameters
$include 'input\modelsInit.gms'
$include '%input_dir%\modelsInit.gms'
* === Simulation ==============================================================
......@@ -117,7 +129,7 @@ $iftheni.dummy not %dummy% == 'yes'
$endif.dummy
$iftheni.debug '%debug%' == 'yes'
putclose gdx;
put_utility 'gdxout' / 'output\' mSolve.tl:0 '-' tSolve.tl:0 '.gdx';
put_utility 'gdxout' / '%output_dir%\' mSolve.tl:0 '-' tSolve.tl:0 '.gdx';
execute_unload
$$include defOutput\debugSymbols.inc
;
......@@ -125,24 +137,24 @@ $endif.debug
if(execError, put log "!!! Errors encountered: " execError:0:0);
);
$if exist 'input\3z_modelsClose.gms' $include 'input\3z_modelsClose.gms';
$if exist '%input_dir%\3z_modelsClose.gms' $include '%input_dir%\3z_modelsClose.gms';
* === Output ==================================================================
$echon "'version' " > 'version'
$call 'git describe --dirty=+ --always >> version'
$ifi not %dummy% == 'yes'
$ifi not %dummy% == 'yes'
$include 'inc\4b_outputInvariant.gms'
$include 'inc\4c_outputQuickFile.gms'
* Post-process results
$if exist 'input\4d_postProcess.gms' $include 'input\4d_postProcess.gms'
$if exist '%input_dir%\4d_postProcess.gms' $include '%input_dir%\4d_postProcess.gms'
execute_unload 'output\results.gdx',
execute_unload '%output_dir%\results.gdx',
$$include 'defOutput\resultSymbols.inc'
;
*$ifi '%debug%' == 'yes' execute_unload 'output\debug.gdx';
execute_unload 'output\debug.gdx';
execute_unload '%output_dir%\debug.gdx';
if(errorcount > 0, abort errorcount);
* === THE END =================================================================
......@@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
### Added
- New model setting `dataLength` to set the length of time series data before it is
recycled. Warn if this is not defined and automatically calculated from data.
- Command line arguments '--input_dir=<path>' and '--ouput_dir=<path' to set
input and output directories, respectively.
### Changed
- Automatic calculation of parameter `dt_circular` takes into account time steps
......
......@@ -71,7 +71,7 @@ Model building /
* q_energyShareMax
* q_energyShareMin
$ifthen exist 'input/building_additional_constraints.gms'
$$include 'input/building_additional_constraints.gms' // Declare additional constraints from the input data
$ifthen exist '%input_dir%/building_additional_constraints.gms'
$$include '%input_dir%/building_additional_constraints.gms' // Declare additional constraints from the input data
$endif
/;
......@@ -73,7 +73,7 @@ Model invest /
q_energyShareMax
q_energyShareMin
$ifthen exist 'input/invest_additional_constraints.gms'
$$include 'input/invest_additional_constraints.gms' // Declare additional constraints from the input data
$ifthen exist '%input_dir%/invest_additional_constraints.gms'
$$include '%input_dir%/invest_additional_constraints.gms' // Declare additional constraints from the input data
$endif
/;
......@@ -73,8 +73,8 @@ Model schedule /
* q_energyShareMax
* q_energyShareMin
$ifthen exist 'input/schedule_additional_constraints.gms'
$$include 'input/schedule_additional_constraints.gms' // Declare additional constraints from the input data
$ifthen exist '%input_dir%/schedule_additional_constraints.gms'
$$include '%input_dir%/schedule_additional_constraints.gms' // Declare additional constraints from the input data
$endif
/;
......@@ -80,7 +80,7 @@ Sets
restypeReleasedForRealization(restype) "Reserve types that are released for the realized time intervals"
* --- Sets to define time, forecasts and samples ------------------------------
$$include 'input/timeAndSamples.inc'
$$include '%input_dir%/timeAndSamples.inc'
m(mType) "model(s) in use"
t_full(t) "Full set of time steps in the current model"
t_current(t) "Set of time steps within the current solve horizon"
......
......@@ -19,7 +19,7 @@ $offtext
* --- Load Input Data ---------------------------------------------------------
* =============================================================================
$gdxin 'input/inputData.gdx'
$gdxin '%input_dir%/inputData.gdx'
$loaddc grid
$loaddc node
$loaddc flow
......@@ -67,22 +67,12 @@ $loaddc p_groupPolicy3D
$loaddc gnss_bound
$gdxin
$ifthen exist 'input/includeInputData_ext.inc'
$$include 'input/includeInputData_ext.inc'
$ifthen exist '%input_dir%/includeInputData_ext.inc'
$$include '%input_dir%/includeInputData_ext.inc'
$endif
$ontext
* Load stochastic scenarios
$batinclude 'inc/gdxload_fluctuation.inc' wind
$batinclude 'inc/gdxload_fluctuation.inc' solar
$ifthen exist 'input/scenarios_hydro.gdx'
$$gdxin 'input/scenarios_hydro.gdx'
$endif
$gdxin
$offtext
$ifthen exist 'input/changes.inc'
$$include 'input/changes.inc'
$ifthen exist '%input_dir%/changes.inc'
$$include '%input_dir%/changes.inc'
$endif
......
......@@ -1864,6 +1864,6 @@ q_energyShareMin(group)${ p_groupPolicy(group, 'energyShareMin')
;
$ifthen exist 'input/additional_constraints.inc'
$$include 'input/additional_constraints.inc'
$ifthen exist '%input_dir%/additional_constraints.inc'
$$include '%input_dir%/additional_constraints.inc'
$endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment