ARIOBaseModel#

class ARIOBaseModel(pym_mriot, *, order_type='alt', alpha_base=1.0, alpha_max=1.25, alpha_tau=365, rebuild_tau=60, main_inv_dur=90, monetary_factor=1000000, temporal_units_by_step=1, iotable_year_to_temporal_unit_factor=365, infinite_inventories_sect=None, inventory_dict=None, productive_capital_vector=None, productive_capital_to_VA_dict=None)[source]#

Bases: object

The core of an ARIO model. Handles the different arrays containing the mrio tables.

ARIOBaseModel wrap all the data and functions used in the core of the most basic version of the ARIO model (based on [Hallegatte, 2013] and [Guan et al., 2020]).

An ARIOBaseModel instance based is build on the given IOSystem. Most default parameters are the same as in [Hallegatte, 2013] and default order mechanisms comes from [Guan et al., 2020]. By default each industry capital stock is 4 times its value added ([Hallegatte, 2008]).

Parameters:
pym_mrioIOSystem

The IOSystem to base the model on.

order_typestr, default “alt”

The type of orders mechanism to use. Currently, can be “alt” or “noalt”. See Model description

alpha_basefloat, default 1.0

Base value of overproduction factor \(\alpha^{b}\) (Default to 1.0).

alpha_maxfloat, default 1.25

Maximum factor of overproduction \(\alpha^{\textrm{max}}\) (default should be 1.25).

alpha_tauint, default 365

Characteristic time of overproduction \(\tau_{\alpha}\) in n_temporal_units_by_step (default should be 365 days).

rebuild_tauint, default 60

Rebuilding characteristic time \(\tau_{\textrm{REBUILD}}\) (see Model description). Overwritten by per event value if it exists.

main_inv_durint, default 90

The default numbers of days for inputs inventory to use if it is not defined for an input.

monetary_factorint, default 10**6

Monetary unit factor (i.e. if the tables unit is 10^6 € instead of 1 €, it should be set to 10^6).

temporal_units_by_step: int, default 1

The number of temporal_units between each step. (Current version of the model showed inconsistencies with values other than 1).

iotable_year_to_temporal_unit_factorint, default 365

The (inverse of the) factor by which MRIO data should be multiplied in order to get “per temporal unit value”, assuming IO data is yearly.

infinite_inventories_sect: list, optional

List of inputs (sector) considered never constraining for production.

inventory_dict: dict, optional

Dictionary in the form input:initial_inventory_size, (where input is a sector, and initial_inventory_size is in “temporal_unit” (defaults to a day))

productive_capital_vector: ArrayLike, optional

Array of capital per industry if you need to give it exogenously.

productive_capital_to_VA_dict: dict, optional

Dictionary in the form sector:ratio. Where ratio is used to estimate capital stock based on the value added of the sector.

Notes

It is recommended to use productive_capital_to_VA_dict if you have a more precise estimation of the ratio of (Capital Stock / Value Added) per sectors than the default 4/1 ratio. You may also feed in directly a productive_capital_vector if you did your estimation before-hand. (This is especially useful if you have events based of an exposure layer for instance)

Regarding inventories, they default to 90 days for all inputs (ie sectors). You can set some inputs to be never constraining for production by listing them in infinite_inventories_sect or directly feed in a dictionary of the inventory duration for each input.

Methods

__init__(pym_mriot, *[, order_type, ...])

calc_inventory_constraints(production)

Compute inventory constraints (no psi parameter, for the psi version, the recommended one, see calc_inventory_constraints())

calc_matrix_stock_gap(matrix_stock_goal)

Computes and returns inputs stock gap matrix

calc_orders()

Computes and sets the orders (intermediate demand) for the next step.

calc_overproduction()

Computes and updates the overproduction vector.

calc_production(current_temporal_unit)

Computes and updates actual production.

distribute_production([...])

Production distribution module

rebuild_prod_house_event(ev_id)

rebuild_prod_indus_event(ev_id)

update_prod_delta()

write_index(index_file)

Write the indexes of the different dataframes of the model in a json file.

Attributes

entire_demand

Returns the entire demand matrix, including intermediate demand (orders), final demand, and possible rebuilding demand.

entire_demand_tot

Returns the entire demand matrix, including intermediate demand (orders), final demand, and possible rebuilding demand.

final_demand

Returns the entire intermediate demand matrix (orders)

final_demand_tot

Returns the total final demand addressed to each industry

intermediate_demand

numpy.ndarray of float: 2-dim square matrix array \(\ioorders\) of size \((n \times m, n \times m)\) representing the matrix of orders.

intermediate_demand_tot

Returns the total intermediate demand addressed to each industry

inventory_constraints_act

Computes and returns inventory constraints for "actual production" (see calc_inventory_constraints())

inventory_constraints_opt

Computes and returns inventory constraints for "optimal production" (see calc_inventory_constraints())

prod_cap_delta_arbitrary

numpy.ndarray of float: Array of size \(n \times m\) representing an arbitrary reduction of production capacity to each industry.

prod_cap_delta_productive_capital

Return the possible production capacity lost due to capital destroyed vector if it was set.

prod_cap_delta_tot

Computes and return total current production delta.

production_cap

Compute and update production capacity.

production_opt

Computes and returns "optimal production" \(\iox^{textrm{Opt}}\), as the per industry minimum between total demand and production capacity.

productive_capital_lost

numpy.ndarray of float: Array of size \(n \times m\) representing the estimated stock of capital currently destroyed for each industry.

rebuild_demand

Returns the entire intermediate demand matrix (orders)

rebuild_demand_house

Returns household rebuilding demand matrix.

rebuild_demand_house_tot

Returns total household rebuilding demand vector.

rebuild_demand_indus

Returns industrial rebuilding demand matrix.

rebuild_demand_indus_tot

Returns total industrial rebuilding demand vector.

rebuild_demand_tot

Returns the total rebuild demand addressed to each industry

rebuild_prod

numpy.ndarray of float: Array of size \(n \times m\) representing the remaining stock of rebuilding demand asked of each industry.

rebuild_prod_house

rebuild_prod_indus

rebuild_prod_tot

n_temporal_units_by_step

int, default 1: The number of temporal_units between each step.

iotable_year_to_temporal_unit_factor

int, default 365: The (inverse of the) factor by which MRIO data should be multiplied in order to get "per temporal unit value", assuming IO data is yearly.

rebuild_tau

int: Rebuilding characteristic time \(\tau_{\textrm{REBUILD}}\) (see Model description).

overprod_max

float: Maximum factor of overproduction \(\alpha^{\textrm{max}}\) (default should be 1.25).

overprod_tau

float: Characteristic time of overproduction \(\tau_{\alpha}\) in n_temporal_units_by_step (default should be 365 days).

overprod_base

float: Base value of overproduction factor \(\alpha^{b}\) (Default to 1.0).

Z_0

numpy.ndarray of float: 2-dim square matrix array \(\ioz\) of size \((n \times m, n \times m)\) representing the daily intermediate (transaction) matrix (see Initial state).

Z_C

numpy.ndarray of float: 2-dim matrix array \(\ioz^{\sectorsset}\) of size \((n, n \times m)\) representing the intermediate (transaction) matrix aggregated by inputs (see here).

Z_distrib

numpy.ndarray of float: math:ioz normalised by \(\ioz^{\sectorsset}\), i.e. representing for each input the share of the total ordered transiting from an industry to another (see here).

Y_C

numpy.ndarray of float: 2-dim matrix array \(\ioy^{\sectorsset}\) of size \((n, m \times \text{number of final demand categories})\) representing the final demand matrix aggregated by inputs (see here).

Y_distrib

numpy.ndarray of float: math:ioy normalised by \(\ioy^{\sectorsset}\), i.e. representing for each input the share of the total ordered transiting from an industry to final demand (see here).

Y_0

numpy.ndarray of float: 2-dim array \(\ioy\) of size \((n \times m, m \times \text{number of final demand categories})\) representing the daily final demand matrix.

X_0

numpy.ndarray of float: Array \(\iox(0)\) of size \(n \times m\) representing the initial daily gross production.

gva_df

pandas.DataFrame: Dataframe of the total GDP of each region of the model

VA_0

numpy.ndarray of float: Array \(\iov\) of size \(n \times m\) representing the total value added for each sectors.

tech_mat

numpy.ndarray of float: 2-dim array \(\ioa\) of size \((n \times m, n \times m)\) representing the technical coefficients matrix.

productive_capital

numpy.ndarray of float: Array of size \(n imes m\) representing the estimated stock of capital of each industry.

threshold_not_input

numpy.ndarray of float: 2-dim square matrix array of size \((n , n \times m)\) representing the threshold under which an input is not considered being an input (0.00001).

overprod

numpy.ndarray of float: Array of size \(n \times m\) representing the overproduction coefficients vector \(\mathbf{\alpha}(t)\).

inputs_stock

numpy.ndarray of float: 2-dim square matrix array \(\ioinv\) of size \((n \times m, n \times m)\) representing the stock of inputs (see Initial state).

production

numpy.ndarray of float: Array \(\iox(t)\) of size \(n \times m\) representing the current gross production.

in_shortage

Boolean stating if at least one industry is in shortage (i.e.) if at least one of its inputs inventory is low enough to reduce production.

had_shortage

Boolean stating if at least one industry was in shortage at some point.

final_demand_not_met

numpy.ndarray of float: Array of size \(n \times m\) representing the final demand that could not be met at current step for each industry.

n_temporal_units_by_step#

int, default 1: The number of temporal_units between each step. (Current version of the model was not tested with values other than 1).

iotable_year_to_temporal_unit_factor#

int, default 365: The (inverse of the) factor by which MRIO data should be multiplied in order to get “per temporal unit value”, assuming IO data is yearly.

rebuild_tau#

int: Rebuilding characteristic time \(\tau_{\textrm{REBUILD}}\) (see Model description).

overprod_max#

float: Maximum factor of overproduction \(\alpha^{\textrm{max}}\) (default should be 1.25).

overprod_tau#

float: Characteristic time of overproduction \(\tau_{\alpha}\) in n_temporal_units_by_step (default should be 365 days).

overprod_base#

float: Base value of overproduction factor \(\alpha^{b}\) (Default to 1.0).

Z_C#

numpy.ndarray of float: 2-dim matrix array \(\ioz^{\sectorsset}\) of size \((n, n \times m)\) representing the intermediate (transaction) matrix aggregated by inputs (see here).

Z_distrib#

numpy.ndarray of float: math:ioz normalised by \(\ioz^{\sectorsset}\), i.e. representing for each input the share of the total ordered transiting from an industry to another (see here).

Z_0#

numpy.ndarray of float: 2-dim square matrix array \(\ioz\) of size \((n \times m, n \times m)\) representing the daily intermediate (transaction) matrix (see Initial state).

Y_C#

numpy.ndarray of float: 2-dim matrix array \(\ioy^{\sectorsset}\) of size \((n, m \times \text{number of final demand categories})\) representing the final demand matrix aggregated by inputs (see here).

Y_distrib#

numpy.ndarray of float: math:ioy normalised by \(\ioy^{\sectorsset}\), i.e. representing for each input the share of the total ordered transiting from an industry to final demand (see here).

Y_0#

numpy.ndarray of float: 2-dim array \(\ioy\) of size \((n \times m, m \times \text{number of final demand categories})\) representing the daily final demand matrix.

X_0#

numpy.ndarray of float: Array \(\iox(0)\) of size \(n \times m\) representing the initial daily gross production.

gva_df#

pandas.DataFrame: Dataframe of the total GDP of each region of the model

VA_0#

numpy.ndarray of float: Array \(\iov\) of size \(n \times m\) representing the total value added for each sectors.

tech_mat#

numpy.ndarray of float: 2-dim array \(\ioa\) of size \((n \times m, n \times m)\) representing the technical coefficients matrix.

productive_capital#

numpy.ndarray of float: Array of size \(n imes m\) representing the estimated stock of capital of each industry.

threshold_not_input#

numpy.ndarray of float: 2-dim square matrix array of size \((n , n \times m)\) representing the threshold under which an input is not considered being an input (0.00001).

overprod#

numpy.ndarray of float: Array of size \(n \times m\) representing the overproduction coefficients vector \(\mathbf{\alpha}(t)\).

inputs_stock#

numpy.ndarray of float: 2-dim square matrix array \(\ioinv\) of size \((n \times m, n \times m)\) representing the stock of inputs (see Initial state).

production#

numpy.ndarray of float: Array \(\iox(t)\) of size \(n \times m\) representing the current gross production.

in_shortage#

Boolean stating if at least one industry is in shortage (i.e.) if at least one of its inputs inventory is low enough to reduce production.

had_shortage#

Boolean stating if at least one industry was in shortage at some point.

final_demand_not_met#

numpy.ndarray of float: Array of size \(n \times m\) representing the final demand that could not be met at current step for each industry.

property prod_cap_delta_tot#

Computes and return total current production delta.

Returns:
npt.NDArray

The total production delta (ie share of production capacity lost) for each industry.

property productive_capital_lost#

numpy.ndarray of float: Array of size \(n \times m\) representing the estimated stock of capital currently destroyed for each industry.

property prod_cap_delta_productive_capital#

Return the possible production capacity lost due to capital destroyed vector if it was set.

Returns:
npt.NDArray

An array of same shape as math:iox, stating the amount of production

capacity lost due to capital destroyed.
property prod_cap_delta_arbitrary#

numpy.ndarray of float: Array of size \(n \times m\) representing an arbitrary reduction of production capacity to each industry.

property production_cap#

Compute and update production capacity.

Compute and update production capacity from current total production delta and overproduction.

\[x^{Cap}_{f}(t) = \alpha_{f}(t) (1 - \Delta_{f}(t)) x_{f}(t)\]
Raises:
ValueError

Raised if any industry has negative production.

property entire_demand#

Returns the entire demand matrix, including intermediate demand (orders), final demand, and possible rebuilding demand.

property entire_demand_tot#

Returns the entire demand matrix, including intermediate demand (orders), final demand, and possible rebuilding demand.

property intermediate_demand#

numpy.ndarray of float: 2-dim square matrix array \(\ioorders\) of size \((n \times m, n \times m)\) representing the matrix of orders.

property intermediate_demand_tot#

Returns the total intermediate demand addressed to each industry

property final_demand#

Returns the entire intermediate demand matrix (orders)

property final_demand_tot#

Returns the total final demand addressed to each industry

property rebuild_demand#

Returns the entire intermediate demand matrix (orders)

property rebuild_demand_tot#

Returns the total rebuild demand addressed to each industry

property rebuild_demand_house#

Returns household rebuilding demand matrix.

Returns:
npt.NDArray

An array of same shape as math:ioy, containing the sum of all currently rebuildable final demand stock.

property rebuild_demand_house_tot#

Returns total household rebuilding demand vector.

Returns:
npt.NDArray

An array of same shape as math:iox, containing the sum of all currently rebuildable households demands.

property rebuild_demand_indus#

Returns industrial rebuilding demand matrix.

Returns:
npt.NDArray

An array of same shape as math:ioz, containing the sum of all currently rebuildable intermediate demand stock.

property rebuild_demand_indus_tot#

Returns total industrial rebuilding demand vector.

Returns:
npt.NDArray

An array of same shape as math:iox, containing the sum of all currently rebuildable intermediate demands.

property rebuild_prod#

numpy.ndarray of float: Array of size \(n \times m\) representing the remaining stock of rebuilding demand asked of each industry.

property production_opt#

Computes and returns “optimal production” \(\iox^{textrm{Opt}}\), as the per industry minimum between total demand and production capacity.

property inventory_constraints_opt#

Computes and returns inventory constraints for “optimal production” (see calc_inventory_constraints())

property inventory_constraints_act#

Computes and returns inventory constraints for “actual production” (see calc_inventory_constraints())

calc_production(current_temporal_unit)[source]#

Computes and updates actual production. See Production module.

  1. Computes production_opt and inventory_constraints

  2. If stocks do not meet inventory_constraints for any inputs, then decrease production accordingly.

Also warns in logs if such shortages happen.

Parameters:
current_temporal_unitint

current step number

calc_inventory_constraints(production)[source]#

Compute inventory constraints (no psi parameter, for the psi version, the recommended one, see calc_inventory_constraints())

See calc_production() for how inventory constraints are computed.

Parameters:
productionnpt.NDArray

The production vector to consider.

Returns:
npt.NDArray

For each input, for each industry, the size of the inventory required to produce at production level

for the duration goal (inv_duration).
distribute_production(general_distribution_scheme='proportional')[source]#

Production distribution module

  1. Computes rebuilding demand for each rebuildable events (applying the rebuild_tau characteristic time)

  2. Creates/Computes total demand matrix (Intermediate + Final + Rebuild)

  3. Assesses if total demand is greater than realized production, hence requiring rationing

  4. Distributes production proportionally to demand.

  5. Updates stocks matrix. (Only if np.allclose(stock_add, stock_use).all() is false)

  6. Computes final demand not met due to rationing and write it.

  7. Updates rebuilding demand for each event (by substracting distributed production)

Parameters:
rebuildable_events‘list[Event]’

List of rebuildable events

schemestr

Placeholder for future distribution scheme

Raises:
RuntimeError

If negative values are found in places there’s should not be any

NotImplementedError

If an attempt to run an unimplemented distribution scheme is tried

calc_matrix_stock_gap(matrix_stock_goal)[source]#

Computes and returns inputs stock gap matrix

The gap is simply the difference between the goal (given as argument) and the current stock.

Parameters:
matrix_stock_goalnpt.NDArray of float

The target inventories.

Returns:
npt.NDArray

The (only positive) gap between goal and current inventories.

Raises:
RuntimeError

If NaN are found in the result.

calc_orders()[source]#

Computes and sets the orders (intermediate demand) for the next step.

See Order module

Raises:
RuntimeError

If negative orders are found, which shouldn’t happen.

calc_overproduction()[source]#

Computes and updates the overproduction vector.

See Overproduction module

write_index(index_file)[source]#

Write the indexes of the different dataframes of the model in a json file.

In order to easily rebuild the dataframes from the ‘raw’ data, this method create a JSON file with all columns and indexes names, namely :

  • regions names

  • sectors names

  • final demand categories

  • number of regions, sectors and industries (regions * sectors)

Parameters:
index_filepathlib.Path

Path to the file to save the indexes.