'''
This is just used to generate random scenarios and initialize damage files

'''
import numpy as np
import matplotlib.pyplot as plt
import itertools
import pandas as pd
import random

main_dir = "C:/Users/ht20/Documents/GitHub/NIST_testbeds/Seaside/Node_arc_info/"
arc_data = pd.read_csv(main_dir+'WaterArcs.csv')
node_data = pd.read_csv(main_dir+'WaterNodes.csv')
net_num = 1
num_samples = 100
p = .1

node_samples = []
for index, row in node_data.iterrows():
    node_samples.append('('+str(row['ID'])+','+str(net_num)+')')
samples = np.random.choice([0, 1], size=(len(node_samples), num_samples), p=[p, 1-p])
node_samples=np.vstack([node_samples,samples.T]).T

arc_samples = []
for index, row in arc_data.iterrows():
    s_node = int(row['Start Node'])
    e_node = int(row['End Node'])
    arc_samples.append('(('+str(s_node)+','+str(net_num)+'),('+str(e_node)+','+str(net_num)+'))')
samples = np.random.choice([0, 1], size=(len(arc_samples), num_samples), p=[p, 1-p])
arc_samples=np.vstack([arc_samples,samples.T]).T

# node_samples = node_samples.T
# arc_samples = arc_samples.T   

# ax=plt.imshow(node_samples)      
# plt.xlabel('scenario')
# plt.ylabel('element')  
# plt.xlim(0,500)

# import seaborn as sns
# sns.set(context='notebook',style='darkgrid')
# plt.rc('text', usetex=True)
# plt.rc('font', **{'family': 'serif', 'serif': ['Computer Modern']})
# f,ax=plt.subplots(3,1,sharex=True,gridspec_kw={'height_ratios': [2,2,2.6]})
# folder='C:/Users/ht20\Documents/GitHub/td-DINDP/data/random_disruption_shelby/'
# node_data=np.genfromtxt(folder+'Initial_node.csv',delimiter=',')
# arc_data=np.genfromtxt(folder+'Initial_links.csv',delimiter=',')

# sns.heatmap(node_data[:,2:432], xticklabels=25, yticklabels=False,ax=ax[1], cbar=False,  cmap="YlGnBu")
# ax[1].set_ylabel('Nodes')
# sns.heatmap(arc_data[:,4:434], xticklabels=25, yticklabels=False,ax=ax[2], cbar=False,  cmap="YlGnBu")
# ax[2].set_xlabel('Disruption Scenario')
# ax[2].set_ylabel('Arcs')
# data=np.vstack((node_data[:,2:432],arc_data[:,4:434]))
# means=1-data.mean(axis=0)
# sns.lineplot(x=range(0,430),y=means,ax=ax[0],lw=1)
# ax[0].set_ylabel(r'\% Damaged')
# plt.xlim(50,551)
# # plt.savefig('Disruption_scenarios.png',dpi=600,bbox_inches='tight')
'''
This is just used to generate random scenarios and initialize damage files

'''
import numpy as np
import matplotlib.pyplot as plt
import itertools
import pandas as pd
import random

main_dir = "C:/Users/ht20/Documents/GitHub/NIST_testbeds/Seaside/Node_arc_info/"
arc_data = pd.read_csv(main_dir+'WaterArcs.csv')
node_data = pd.read_csv(main_dir+'WaterNodes.csv')
net_num = 1
num_samples = 100
p = .1

node_samples = []
for index, row in node_data.iterrows():
    node_samples.append('('+str(row['ID'])+','+str(net_num)+')')
samples = np.random.choice([0, 1], size=(len(node_samples), num_samples), p=[p, 1-p])
node_samples=np.vstack([node_samples,samples.T]).T

arc_samples = []
for index, row in arc_data.iterrows():
    s_node = int(row['Start Node'])
    e_node = int(row['End Node'])
    arc_samples.append('(('+str(s_node)+','+str(net_num)+'),('+str(e_node)+','+str(net_num)+'))')
samples = np.random.choice([0, 1], size=(len(arc_samples), num_samples), p=[p, 1-p])
arc_samples=np.vstack([arc_samples,samples.T]).T

# node_samples = node_samples.T
# arc_samples = arc_samples.T   

# ax=plt.imshow(node_samples)      
# plt.xlabel('scenario')
# plt.ylabel('element')  
# plt.xlim(0,500)

# import seaborn as sns
# sns.set(context='notebook',style='darkgrid')
# plt.rc('text', usetex=True)
# plt.rc('font', **{'family': 'serif', 'serif': ['Computer Modern']})
# f,ax=plt.subplots(3,1,sharex=True,gridspec_kw={'height_ratios': [2,2,2.6]})
# folder='C:/Users/ht20\Documents/GitHub/td-DINDP/data/random_disruption_shelby/'
# node_data=np.genfromtxt(folder+'Initial_node.csv',delimiter=',')
# arc_data=np.genfromtxt(folder+'Initial_links.csv',delimiter=',')

# sns.heatmap(node_data[:,2:432], xticklabels=25, yticklabels=False,ax=ax[1], cbar=False,  cmap="YlGnBu")
# ax[1].set_ylabel('Nodes')
# sns.heatmap(arc_data[:,4:434], xticklabels=25, yticklabels=False,ax=ax[2], cbar=False,  cmap="YlGnBu")
# ax[2].set_xlabel('Disruption Scenario')
# ax[2].set_ylabel('Arcs')
# data=np.vstack((node_data[:,2:432],arc_data[:,4:434]))
# means=1-data.mean(axis=0)
# sns.lineplot(x=range(0,430),y=means,ax=ax[0],lw=1)
# ax[0].set_ylabel(r'\% Damaged')
# plt.xlim(50,551)
# # plt.savefig('Disruption_scenarios.png',dpi=600,bbox_inches='tight')
This is just used to generate random scenarios and initialize damage files # node_samples = node_samples.T # arc_samples = arc_samples.T # ax=plt.imshow(node_samples) # plt.xlabel('scenario') # plt.ylabel('element') # plt.xlim(0,500) # import seaborn as sns # sns.set(context='notebook',style='darkgrid') # plt.rc('text', usetex=True) # plt.rc('font', **{'family': 'serif', 'serif': ['Computer Modern']}) # f,ax=plt.subplots(3,1,sharex=True,gridspec_kw={'height_ratios': [2,2,2.6]}) # folder='C:/Users/ht20\Documents/GitHub/td-DINDP/data/random_disruption_shelby/' # node_data=np.genfromtxt(folder+'Initial_node.csv',delimiter=',') # arc_data=np.genfromtxt(folder+'Initial_links.csv',delimiter=',') # sns.heatmap(node_data[:,2:432], xticklabels=25, yticklabels=False,ax=ax[1], cbar=False,  cmap="YlGnBu") # ax[1].set_ylabel('Nodes') # sns.heatmap(arc_data[:,4:434], xticklabels=25, yticklabels=False,ax=ax[2], cbar=False,  cmap="YlGnBu") # ax[2].set_xlabel('Disruption Scenario') # ax[2].set_ylabel('Arcs') # data=np.vstack((node_data[:,2:432],arc_data[:,4:434])) # means=1-data.mean(axis=0) # sns.lineplot(x=range(0,430),y=means,ax=ax[0],lw=1) # ax[0].set_ylabel(r'\% Damaged') # plt.xlim(50,551) # # plt.savefig('Disruption_scenarios.png',dpi=600,bbox_inches='tight')