vtra.mria package¶
Submodules¶
vtra.mria.disruption module¶
Create disruption files to be used in the MRIA loss estimations.
-
create_disruption
(input_file, output_dir, min_rice=True, single_point=True)[source]¶ Create disruption file for the economic analysis.
The input for this disruption file is the outcome of the flow analysis. This function translate the failure in transport flows into impacts to the economic sectors.
Parameters: - input_file (str) – name of the path to a flow failure scenario file
- output_dir (str) – name for output directory for mapper file.
- min_rice (bool, optional) – determine whether you want to use the minimal rice value or the maximum rice value from the flow analysis. This MUST match the value used when creating the MRIO table. The default is True.
- single_point (bool, optional) – determine whether you are converting a single-point or multi-point failure analaysis to a disruption file. The default is True.
Returns: Dictionary of all unique failure events, in terms of percentage disruption per sector in each directly affected region due to the flow failure.
Return type: event_dict
-
df_com_to_ind
(comm_des, min_rice=True)[source]¶ Convert the national Origin-Destination matrix from goods to sectors.
Parameters: - comm_dess – national Origin-Destination matrix, showing origin and destination of goods.
- min_rice (bool) – determine whether to use the minimal rice value or the maximum rice value from the flow analysis. This MUST match the value used when creating the MRIO table. The default is True.
Returns: a Pandas dataframe of the national OD matrix on a sector level.
Return type: df_od_ind
vtra.mria.model module¶
MRIA Model
Purpose¶
The Multiregional Impact Assessment (MRIA) Model allows for estimating a new post-disaster economic situation in equilibrium, given a set of disruptions.
References
- Koks, E. E., & Thissen, M. (2016). A multiregional impact assessment model for disaster analysis. Economic Systems Research, 28(4), 429-449.
-
class
MRIA_IO
(name, list_regions, list_sectors, list_fd_cats=[])[source]¶ Bases:
object
MRIA_IO sets up the modelling framework.
In this class we define the type of model, sets, set up the core variables and specify the constraints and objectives for different model setups.
-
name
¶ name of the model
Type: string
-
m
¶ model instance
Type: Pyomo.ConcreteModel
-
baseline_data
(Table, disr_dict_sup, disr_dict_fd)[source]¶ Set up all the baseline variables for the MRIA model
Parameters: - Table – the io_basic class object
- disr_dict_sup – dictionary containing the reduction in production capacity
- disr_dict_fd – dictionary containing the disruptions in final demand
- all required parameters and variables for the MRIA_IO class and the MRIA (Set) –
- model. –
-
create_A_mat
(A_mat_in)[source]¶ Creation of the A-matrix for the optimization model.
Parameters: A_mat_in – A-matrix dictionary from the io_basic class object
-
create_DisImp
(disr_dict, Regmaxcap=0.98)[source]¶ Create disaster import variable.
Parameters: - disr_dict – dictionary containing the reduction in production capacity
- Regmaxcap – maximum regional capacity. The default value is set to 0.98
- self.DisImp - Pyomo Variable instance for disaster imports (Set) –
-
create_ExpImp
(ExpROW, ImpROW)[source]¶ Specify export and import to the rest of the world
Parameters: - ExpROW – Exports to the Rest of the World dictionary from the io_basic class object
- ImpROW – Imports from the Rest of the World dictionary from the io_basic class object
- self.ExpROW - Pyomo Parameter instance for the Exports to the Rest of the World (Create) –
- self.ImpROW - Pyomo Parameter instance for the Imports from the Rest of the World (and) –
-
create_FD
(FinalD, disr_dict_fd)[source]¶ Specify Final Demand and Local Final Demand.
Parameters: - FinalD – Final Demand dictionary from the io_basic class object
- disr_dict_fd – dictionary containing the disruptions in final demand
- self.ttfd - Pyomo Parameter instance for the total final demand (Create) –
- self.fd - Pyomo Parameter instance for the final demand (and) –
Estimate Import shares and Import share DisImp
Create self.ImportShare - Pyomo Parameter instance for the total import shares
-
create_LFD
(FinalD)[source]¶ Specify local final demand
Parameters: - FinalD – Final Demand dictionary from the io_basic class object
- self.lfd - Pyomo Parameter instance for the local final demand (Create) –
-
create_Rat
(FinalD=None, Z_matrix=None)[source]¶ Create rationing variable
Parameters: - FinalD – Final Demand dictionary from the io_basic class object
- Z_matrix – Z-matrix dictionary from the io_basic class object
- self.Rat - Pyomo Variable instance for rationing (Set) –
-
create_Ratmarg
(Table)[source]¶ Estimate the marginal values of the rationing variable
Parameters: - Table – the io_basic class object
- self.Ratmarg - Pyomo Parameter instance for the marginal value of rationing (Set) –
-
create_Rdem
()[source]¶ Create reconstruction demand variable.
Create self.Rdem - Pyomo Parameter instance for the total reconstruction demand
-
create_TotExp
()[source]¶ Estimate Total Export
Create self.TotExp - Pyomo Parameter instance for the total export
-
create_TotImp
()[source]¶ Estimate Total Import
Create self.TotExp - Pyomo Parameter instance for the total import
-
create_Trade
(FinalD, Z_matrix=None)[source]¶ Create Trade Matrix
Parameters: - FinalD – Final Demand dictionary from the io_basic class object
- Z_matrix – Z-matrix dictionary from the io_basic class object
- self.trade - Pyomo Parameter instance for the trade matrix between regions (Create) –
-
create_VA
(ValueA)[source]¶ Specify Value Added
Parameters: - ValueA – Value Added dictionary from the io_basic class object
- self.ValueA - Pyomo Parameter instance for the total Value Added (Create) –
-
create_X
(disr_dict, Regmaxcap=0.98, A_matrix_ini=None, Z_matrix=None, FinalD=None, Xbase=None, fd=None, ExpROW=None)[source]¶ Create the total production X variable
Parameters: - disr_dict – dictionary containing the reduction in production capacity
- Regmaxcap – maximum regional capacity. The default value is set to 0.98
- A_matrix_ini – A-matrix dictionary from the io_basic class object
- Z_matrix – Z-matrix dictionary from the io_basic class object
- FinalD – Final Demand dictionary from the io_basic class object
- Xbase – Total Production X parameter from the MRIA class object
- fd – Final Demand parameter from the MRIA class object
- ExpROW – Export to the Rest of the World parameter from the MRIA class object
- self.X_up - Pyomo Variable instance of total production X (Create) –
-
create_X_up
(disr_dict, Regmaxcap=0.98)[source]¶ Specify upper bound of total production X.
Parameters:
-
create_Xbase
(Z_matrix, disr_dict, FinalD=None)[source]¶ Specify Baseline value of total production X
Parameters: - Z_matrix – Z-matrix dictionary from the io_basic class object
- disr_dict – dictionary containing the reduction in production capacity
- FinalD – Final Demand dictionary from the io_basic class object
- self.X_up - Pyomo Parameter instance for the Baseline value of total production X (Create) –
-
create_Z_mat
()[source]¶ Specify Trade between regions
Create self.Z_matrix - Pyomo Parameter instance for the total trade matrix
-
create_demand
()[source]¶ Specify demand function
Create self.Demand - Pyomo Variable instance for total demand
-
create_sets
(FD_SET=None, VA_SET=None)[source]¶ Create of the various sets, allowing for specification of set inputs.
Parameters:
-
impact_data
(Table, disr_dict_sup, disr_dict_fd, Regmaxcap=0.98)[source]¶ Create additional parameters and variables required for impact analysis
Parameters: - Table – the io_basic class object
- disr_dict_sup – dictionary containing the reduction in production capacity
- disr_dict_fd – dictionary containing the disruptions in final demand
- Regmaxcap – maximum regional capacity. The default value is set to 0.98
- all additional parameters and variables required for the MRIA_IO class and the (Set) –
- model to do an impact analysis. (**MRIA**) –
-
run_basemodel
(solver=None)[source]¶ Run the baseline model of the MRIA model.
This should return the baseline situation (i.e. no changes between input matrix and output matrix).
Parameters: - solver (str) – Specify the solver to be used with Pyomo. The Default value is set to None. If set to None, the ipopt solver will be used
- out the output of an optimized MRIA_IO class and the MRIA model (Write) –
-
run_impactmodel
(solver=None, output=None, tol=1e-06, DisWeight=1.75, RatWeight=2)[source]¶ Run the MRIA model with disruptions. This will return an economy with a new equilibrium, based on the new production and demand values.
Parameters: - solver – Specify the solver to be used with Pyomo. The Default value is set to None. If set to None, the ipopt solver will be used
- output – Specify whether you want the solver to print its progress.The default value is set to None
- tol – the tolerance value that determines whether the outcome of the model is feasible. The default value is set to 1e-6
- DisWeight – the weight that determines the penalty set to let the model allow for additional imports. A higher penalty value will result in less imports. The default value is set to 1.75
- RatWeight – the weight that determines the penalty set to let the model allow to ration goods. A higher penalty value will result in less rationing. The default value is set to 2
- write out the output of an optimized MRIA_IO class and MRIA model (Optionally) –
-
vtra.mria.ratmarg module¶
Create output file for gams and run a quick gams module to estimate marginal values of rationing demand
-
load_db_IO
(table_in)[source]¶ Load the Input-Output data from the io_basic Class object and converts it to a GAMS .gdx file.
Write out .gdx file of the IO data
Parameters: table_in – io_basic class object, containing all IO data
-
ratmarg_IO
(table_in)[source]¶ Estimate marginal values of the rationing variable in GAMS. GAMS is required, as the marginal values of a variable are not returned in the free python solvers.
- Parameters
- table_in - io_basic class object, containing all IO data
- Outputs
- pandas DataFrame with the marginal values of the rationing variable
vtra.mria.run_mria module¶
Run the MRIA Model for a given set of disruptions.
vtra.mria.table module¶
Create the economic tables required to run the MRIA model.
-
class
io_basic
(name, filepath, list_regions)[source]¶ Bases:
object
io_basic is used to set up the table.
-
load_all_data
()[source]¶ Load all data for the io_basic class.
- Parameters
- self - io_basic class object
- Output
- self.FD_data - pandas Dataframe of Final Demand in the io_basic class
- self.T_data - pandas Dataframe of Z matrix in the io_basic class
- self.VA_data - pandas Dataframe of Value Added in the io_basic class
- self.ImpROW_data - pandas Dataframe of import from the Rest of the World in the io_basic class
- self.ExpROW_data - pandas Dataframe of exports to the Rest of The World in the io_basic class
-
load_labels
()[source]¶ Load all labels for the io_basic class.
- Parameters
- self - io_basic class object
- Output
- self.FD_labels - labels for Final Demand columns in the io_basic class
- self.FD_cat - labels for Final Demand categories in the io_basic class
- self.Exp_labels - labels for Export columns in the io_basic class
- self.T_labels - region and sector labels for Z-matrix in the io_basic class
- self.VA_labels - labels for Value Added in the io_basic class
- self.sectors - labels for the sectors in the io_basic class
-
prep_data
()[source]¶ Transform the dataframes into dictionaries, ready to be used in the MRIA_IO class instance.
- Parameters
- self - io_basic class object
- Output
- self.FinalD - dictionary of Final Demand in the io_basic class
- self.A_matrix - dictionary of A matrix in the io_basic class
- self.Z_matrix - dictionary of Z matrix in the io_basic class
- self.ValueA - dictionary of Value Added in the io_basic class
- self.ImpROW - dictionary of import from the Rest of the World in the io_basic class
- self.ExpROW - dictionary of exports to the Rest of The World in the io_basic class
-