ARIOPsiModel#

class ARIOPsiModel(pym_mrio, *, 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, psi_param=0.8, inventory_restoration_tau=60)[source]#

Bases: ARIOBaseModel

Methods

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

An ARIO model with some additional features.

calc_inventory_constraints(production)

Compute inventory constraints (with psi parameter, for the non psi version, 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

Returns the entire intermediate demand matrix (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

Return the possible "arbitrary" production capacity lost vector if it was set.

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

Returns current stock of destroyed capital

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

rebuild_prod_house

rebuild_prod_indus

rebuild_prod_tot

psi

float: Value of the psi parameter.

restoration_tau

numpy.ndarray of int: Array of size \(n\) setting for each inputs its characteristic restoration time \(\tau_{\textrm{INV}}\) in n_temporal_units_by_step.

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.

psi#

float: Value of the psi parameter. (see Model description).

restoration_tau#

numpy.ndarray of int: Array of size \(n\) setting for each inputs its characteristic restoration time \(\tau_{\textrm{INV}}\) in n_temporal_units_by_step. (see Model description).

property inventory_constraints_opt#

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

calc_orders()#

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()#

Computes and updates the overproduction vector.

See Overproduction module

distribute_production(general_distribution_scheme='proportional')#

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

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 final_demand#

Returns the entire intermediate demand matrix (orders)

property final_demand_tot#

Returns the total final demand addressed to each industry

property intermediate_demand#

Returns the entire intermediate demand matrix (orders)

property intermediate_demand_tot#

Returns the total intermediate demand addressed to each industry

property inventory_constraints_act#

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

property prod_cap_delta_arbitrary#

Return the possible “arbitrary” production capacity lost vector if it was set.

Returns:
npt.NDArray

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

capacity lost arbitrarily (ie exogenous).
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_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 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 production_opt#

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

property productive_capital_lost#

Returns current stock of destroyed capital

Returns:
npt.NDArray

An array of same shape as math:iox, containing the “stock”

of capital currently destroyed for each industry.
property rebuild_demand#

Returns the entire intermediate demand matrix (orders)

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_demand_tot#

Returns the total rebuild demand addressed to each industry

property rebuild_prod#
write_index(index_file)#

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.

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_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.

calc_production(current_temporal_unit)[source]#

Computes and updates actual production. The difference with ARIOBaseModel is in the way inventory constraints are computed. See Production module.

Parameters:
current_temporal_unitint

current step number

calc_inventory_constraints(production)[source]#

Compute inventory constraints (with psi parameter, for the non psi version, see calc_inventory_constraints())

Parameters:
productionnp.ndarray

The production vector to consider.

Returns:
np.ndarray

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

for the duration goal (inv_duration) times the psi parameter.
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.