INDP optimization modules¶
- indp.apply_recovery(N, indp_results, t)¶
This function applies the restoration decisions (solution of INDP) to a gurobi model by changing the state of repaired elements to functional
- Parameters
N (
InfrastructureNetwork
) – The model of the interdependent network.indp_results (INDPResults) – A
INDPResults
object containing the optimal restoration decisions..t (int) – The time step to which the results should apply.
- Returns
- Return type
None.
- indp.collect_results(m, controlled_layers, T, n_hat, n_hat_prime, a_hat_prime, S, coloc=True)¶
This function computes the results (actions and costs) of the optimal results and write them to a
INDPResults
object.- Parameters
m (gurobi.Model) – The object containing the solved optimization problem.
controlled_layers (list) – Layer IDs that can be recovered in this optimization.
T (int) – Number of time steps in the optimization (T=1 for iINDP, and T>=1 for td-INDP).
n_hat (list) – List of Damaged nodes in whole network.
n_hat_prime (list) – List of damaged nodes in controlled network.
a_hat_prime (list) – List of damaged arcs in controlled network.
S (list) – List of geographical sites.
coloc (bool, optional) – If false, exclude geographical interdependency from the results. . The default is True.
- Returns
indp_results (INDPResults)
A
INDPResults
object containing the optimal restoration decisions.
- indp.collect_solution_pool(m, T, n_hat_prime, a_hat_prime)¶
This function collect the result (list of repaired nodes and arcs) for all feasible solutions in the solution pool
- Parameters
m (gurobi.Model) – The object containing the solved optimization problem.
T (int) – Number of time steps in the optimization (T=1 for iINDP, and T>=1 for td-INDP).
n_hat_prime (list) – List of damaged nodes in controlled network.
a_hat_prime (list) – List of damaged arcs in controlled network.
- Returns
sol_pool_results (dict)
A dictionary containing one dictionary per solution that contain list of repaired node and arcs in the solution.
- indp.create_functionality_matrix(N, T, layers, actions, strategy_type='OPTIMISTIC')¶
Creates a functionality map for input into the functionality parameter in the indp function.
- Parameters
N (
InfrastructureNetwork
) – An InfrastructureNetwork instance .T (int) – Number of time steps to optimize over.
layers (list) – Layer IDs of N included in the optimization..
actions (list) – An array of actions from a previous optimization. Likely taken from an INDPResults variable ‘indp_result[t][‘actions’]’..
strategy_type (str, optional) – If no actions are provided, assigns a default functionality. Options are: “OPTIMISTIC”, “PESSIMISTIC” or “REALISTIC”. The default is “OPTIMISTIC”.
- Returns
functionality (dict)
A functionality dictionary used for input into indp.
- indp.get_resource_suffix(params)¶
This function generates the part of suffix of result folders that pertains to resource cap(s).
- Parameters
params (dict) – Parameters that are needed to run the indp optimization.
- Returns
out_dir_suffix_res (str)
The part of suffix of result folders that pertains to resource cap(s).
- indp.indp(N, v_r, T=1, layers=None, controlled_layers=None, functionality=None, forced_actions=False, fixed_nodes=None, print_cmd=True, time_limit=None, co_location=True, solution_pool=None)¶
INDP optimization problem. It also solves td-INDP if T > 1.
- Parameters
N (
InfrastructureNetwork
) – An InfrastructureNetwork instance.v_r (dict) – Dictionary of the number of resources of different types in the analysis. If the value is a scale for a type, it shows the total number of resources of that type for all layers . If the value is a list for a type, it shows the total number of resources of that type given to each layer.
T (int, optional) – Number of time steps to optimize over. T=1 shows an iINDP analysis and T>1 shows a td-INDP. The default is 1.
layers (list, optional) – Layer IDs in N included in the optimization.
controlled_layers (list, optional) – Layer IDs that can be recovered in this optimization. Used for decentralized optimization. The default is None.
functionality (dict, optional) – Dictionary of nodes to functionality values for non-controlled nodes. Used for decentralized optimization. The default is None.
forced_actions (bool, optional) – If true, it forces the optimizer to repair at least one element. The default is False.
fixed_nodes (dict, optional) – It fixes the functionality of given elements to a given value. The default is None.
print_cmd (bool, optional) – If true, analysis information is written to the console. The default is True.
time_limit (int, optional) – Time limit for the optimizer to stop. The default is None.
co_location (bool, optional) – If false, exclude geographical interdependency from the optimization. The default is True.
solution_pool (int, optional) – The number of solutions that should be retrieved from the optimizer in addition to the optimal one. The default is None.
- Returns
list
A list of the form
[m, results]
for a successful optimization where m is the Gurobi optimization model and – results is aINDPResults
object generated usingcollect_results()
. Ifsolution_pool
is set to a number, the function returns[m, results, sol_pool_results]
where sol_pool_results is dictionary of solution that should be retrieved from the optimizer in addition to the optimal one collected usingcollect_solution_pool()
.
- indp.initialize_network(base_dir='../data/INDP_7-20-2015/', external_interdependency_dir=None, sim_number=1, cost_scale=1, magnitude=6, sample=0, v=3, infrastructure_data=True, topology='Random', extra_commodity=None)¶
Initializes an
InfrastructureNetwork
object from Shelby County data or synthetic networks.- Parameters
base_dir (str, optional) – Base directory of Shelby County data or synthetic networks. The default is “../data/INDP_7-20-2015/”.
external_interdependency_dir (str, optional) – Directory of external interdependencies for Shelby County data. The default is None.
sim_number (int, optional) – Which simulation number to use as input. The default is 1.
cost_scale (float, optional) – Scales the cost to improve efficiency. The default is 1.
magnitude (int, optional) – Magnitude parameter of the initial disruption. The default is 6.
sample (int, optional) – Sample number parameter of the initial disruption. The default is 0.
v (int, list, optional) – Number of available resources or resource cap. The default is 3.
infrastructure_data (bool, optional) – If the data are for infrastructure. It should be set to False if a synthetic network is being analyzed. The default is True.
topology (str, optional) – Topology of the synthetic network that is being analyzed. The default is ‘Random’.
extra_commodity (dict, optional) – Dictionary of commodities other than the default one for each layer of the network. The default is ‘None’, which means that there is only one commodity per layer.
- Returns
interdep_net (
InfrastructureNetwork
) – The object containing the network data.v_temp (int, list) – Number of available resources or resource cap. Used for synthetic networks where each sample network has a different resource cap.
layers_temp (list) – List of layers in the analysis. Used for synthetic networks where each sample network has different layers.
- indp.initialize_sample_network(layers=None)¶
This function generate the sample toy example with either 2 or 3 layers.
- Parameters
layers (list) – List of layers in the toy example that can be [1, 2] or [1, 2, 3]. The default is None, which sets layers to [1, 2].
- Returns
interdependent_net (InfrastructureNetwork)
A
InfrastructureNetwork
object containing the interdependent network and all the – attributes of its nodes and arcs.
- indp.plot_indp_sample(params, folder_suffix='', suffix='')¶
This function plots the toy example in all time steps of the restoration, and saves plots to file.
- Parameters
params (dict) – Parameters that are needed to run the indp optimization.
folder_suffix (str) – The suffix that should be added to the target folder. The default is ‘’.
suffix (str) – The suffix that should be added to plots when saved. The default is ‘’.
- Returns
- Return type
None.
- indp.run_indp(params, layers=None, controlled_layers=None, functionality=None, T=1, save=True, suffix='', forced_actions=False, save_model=False, print_cmd_line=True, co_location=True)¶
This function runs iINDP (T=1) or td-INDP for a given number of time steps and input parameters
- Parameters
params (dict) – Parameters that are needed to run the indp optimization.
layers (list) – List of layers in the interdependent network. The default is ‘None’, which sets the list to [1, 2, 3].
controlled_layers (list) – List of layers that are included in the analysis. The default is ‘None’, which sets the list equal to layers.
functionality (dict) – This dictionary is used to assign functionality values elements in the network before the analysis starts. The default is ‘None’.
T (int, optional) – Number of time steps to optimize over. T=1 shows an iINDP analysis and T>1 shows a td-INDP. The default is 1.
save (bool) – If the results should be saved to file. The default is True.
suffix (str) – The suffix that should be added to the output files when saved. The default is ‘’.
forced_actions (bool) – If True, the optimizer is forced to repair at least one element in each time step. The default is False.
save_model (bool) – If the gurobi optimization model should be saved to file. The default is False.
print_cmd_line (bool) – If full information about the analysis should be written to the console. The default is True.
co_location (bool) – If co-location and geographical interdependency should be considered in the analysis. The default is True.
- Returns
indp_results (INDPResults)
A
INDPResults
object containing the optimal restoration decisions.
- indp.save_indp_model_to_file(model, out_model_dir, t, l=0, suffix='')¶
This function saves gurobi optimization model to file.
- Parameters
model (gurobipy.Model) – Gurobi optimization model
out_model_dir (str) – Directory to which the models should be written
t (int) – The time step corresponding to the model
l (int) – The layer number corresponding to the model. The default is 0, which means the model include all layers in the analysis
suffix (str) – The suffix that should be added to files when saved. The default is ‘’.
- Returns
- Return type
None.
- indp.time_resource_usage_curves(base_dir, damage_dir, sample_num)¶
This module calculates the repair time for nodes and arcs for the current scenario based on their damage state, and writes them to the input files of INDP. Currently, it is only compatible with NIST testbeds.
Todo
The calculated repair time and costs are written to node and arc info input files. It makes it impossible to run the analyses in parallel because there might be a conflict between two processes. Consider correcting this.
- Parameters
base_dir (dir) – The address of the folder where the basic network information (topology, parameters, etc.) are stored.
damage_dir (dir) – the address of the folder where the damage information are stored.
sample_num (int) – The sample number of the damage scenarios for which the repair data are calculated.
- Returns
- Return type
None.