def greedy_hueristics(filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name, l_budget): # ----------------------------------------------------------------------------------------------------------------------------------- # Importing supporting methods # ----------------------------------------------------------------------------------------------------------------------------------- import cascade_algorithm import maptest_new_outage_list import cascade_algorithm_reduced_outages import time # ----------------------------------------------------------------------------------------------------------------------------------- # Initializing the method variables # ----------------------------------------------------------------------------------------------------------------------------------- tot_exe_time_start = time.time() # Starting the timer temp_max_loadloss = 0 worst_case_outage = [] # ----------------------------------------------------------------------------------------------------------------------------------- # Finding the maximum loadloss/damage causing transmission lines, also known as outages. # ----------------------------------------------------------------------------------------------------------------------------------- max_load_loss_outage, max_loadloss = cascade_algorithm.DSS_Python_Interface1( filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name) # Returns the maximum load loss causing contingency. Identifies the first transmission line to attack. # print max_load_loss_outage temp_max_loadloss = max_loadloss worst_case_outage = max_load_loss_outage for k in range( 0, (l_budget - 1)): # Loop runs for identifying the most damaging attack combination new_outage_list = maptest_new_outage_list.maptest14bus_test_system( comp_filename, start_range, contingency_range, max_load_loss_outage) # Returns the updated list of contingencies to be simulated based on the first identified maximum load loss causing outage. # print new_outage_list max_load_loss_outage, max_loadloss = cascade_algorithm_reduced_outages.DSS_Python_Interface1( filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name, new_outage_list) # Identifies the worst case load loss causing contingencies. # ----------------------------------------------------------------------------------------------------------------------------------- # Updating the solution # ----------------------------------------------------------------------------------------------------------------------------------- if ( max_loadloss > temp_max_loadloss ): # Checks if the current system damage is more than any previous damage temp_max_loadloss = max_loadloss worst_case_outage = max_load_loss_outage tot_exe_time_end = time.time() # Stop the timer tot_exe_time = (tot_exe_time_end - tot_exe_time_start ) # Compute the actual run time of the algorithm # ----------------------------------------------------------------------------------------------------------------------------------- # Prints the outputs on the console # ----------------------------------------------------------------------------------------------------------------------------------- print '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' print 'Worst case outage: %s' % worst_case_outage print 'Worst case loadloss: %s' % temp_max_loadloss print 'Total execution time in seconds: %s' % tot_exe_time print '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' return worst_case_outage, temp_max_loadloss
def greedy_hueristics(filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name, budget): import cascade_algorithm import maptest_new_outage_list import cascade_algorithm_reduced_outages import time tot_exe_time_start = time.time() temp_max_loadloss = 0 worst_case_outage = [] max_load_loss_outage, max_loadloss = cascade_algorithm.DSS_Python_Interface1( filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name) # print max_load_loss_outage temp_max_loadloss = max_loadloss worst_case_outage = max_load_loss_outage for k in range(0, (budget - 1)): new_outage_list = maptest_new_outage_list.maptest14bus_test_system( comp_filename, start_range, contingency_range, max_load_loss_outage) # print new_outage_list max_load_loss_outage, max_loadloss = cascade_algorithm_reduced_outages.DSS_Python_Interface1( filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name, new_outage_list) if (max_loadloss > temp_max_loadloss): temp_max_loadloss = max_loadloss worst_case_outage = max_load_loss_outage tot_exe_time_end = time.time() tot_exe_time = (tot_exe_time_end - tot_exe_time_start) print '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' print 'Worst case outage: %s' % worst_case_outage print 'Worst case loadloss: %s' % temp_max_loadloss print 'Total execution time in seconds: %s' % tot_exe_time print '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'
def greedy_hueristics(filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name, budget): # import maptest_testing import cascade_algorithm import maptest_new_outage_list import cascade_algorithm_reduced_outages temp_max_loadloss = 0; max_load_loss_outage, max_loadloss = cascade_algorithm.DSS_Python_Interface1(filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name); print max_load_loss_outage temp_max_loadloss = max_loadloss; for k in range(0, (budget-1)): new_outage_list = maptest_new_outage_list.maptest14bus_test_system(comp_filename, start_range, contingency_range, max_load_loss_outage); print new_outage_list max_load_loss_outage, max_loadloss = cascade_algorithm_reduced_outages.DSS_Python_Interface1(filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name, new_outage_list);
def greedy_hueristics(filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name, p_budget): import cascade_algorithm import maptest_new_outage_list import cascade_algorithm_reduced_outages import obtain_subs import time tot_exe_time_start = time.time() temp_max_loadloss = 0 worst_case_outage = [] worst_case_subs = {} loadloss_gain = 0 # checked for new oc max_load_loss_outage, max_loadloss = cascade_algorithm.DSS_Python_Interface1( filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name) # print max_load_loss_outage temp_max_loadloss = max_loadloss worst_case_outage = max_load_loss_outage for k in range(0, (p_budget - 1)): new_outage_list = maptest_new_outage_list.maptest14bus_test_system( comp_filename, start_range, contingency_range, max_load_loss_outage) # print new_outage_list max_load_loss_outage, max_loadloss = cascade_algorithm_reduced_outages.DSS_Python_Interface1( filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name, new_outage_list) if (max_loadloss >= temp_max_loadloss): temp_max_loadloss = max_loadloss worst_case_outage = max_load_loss_outage if ((loadloss_gain - temp_max_loadloss) == 0): break else: loadloss_gain = temp_max_loadloss worst_case_subs = obtain_subs.maptest14bus_test_system( comp_filename, start_range, contingency_range, worst_case_outage) tot_exe_time_end = time.time() tot_exe_time = (tot_exe_time_end - tot_exe_time_start) print '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' print 'Worst case outage: %s' % worst_case_outage print 'Worst case loadloss: %s' % temp_max_loadloss print 'Worst case substations to be attacked: %s' % worst_case_subs print 'Total execution time in seconds: %s' % tot_exe_time print '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' return (worst_case_subs, worst_case_outage, temp_max_loadloss)
def greedy_hueristics(filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name, l_budget): # Importing supporting methods a nd initializing method variables import cascade_algorithm import maptest_new_outage_list import cascade_algorithm_reduced_outages import time tot_exe_time_start = time.time() temp_max_loadloss = 0 worst_case_outage = [] # Identifying the maximum damage causing transmission line from the system model max_load_loss_outage, max_loadloss = cascade_algorithm.DSS_Python_Interface1( filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name) temp_max_loadloss = max_loadloss worst_case_outage = max_load_loss_outage # Iteratively identifying the next combination of transmission lines that maximize system damage based on budget constraints for k in range(0, (l_budget - 1)): # generating new attack space new_outage_list = maptest_new_outage_list.maptest14bus_test_system( comp_filename, start_range, contingency_range, max_load_loss_outage) # Identifying the new worst case attack max_load_loss_outage, max_loadloss = cascade_algorithm_reduced_outages.DSS_Python_Interface1( filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name, new_outage_list) # updating the solution if damage is maximized if (max_loadloss > temp_max_loadloss): temp_max_loadloss = max_loadloss worst_case_outage = max_load_loss_outage tot_exe_time_end = time.time() tot_exe_time = (tot_exe_time_end - tot_exe_time_start) # Outputing the details on the console print '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' print 'Worst case outage: %s' % worst_case_outage print 'Worst case loadloss: %s' % temp_max_loadloss print 'Total execution time in seconds: %s' % tot_exe_time print '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' return worst_case_outage, temp_max_loadloss
def greedy_hueristics(filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name, budget, PA_name_file): # Importing supporting methods and initializing method variables import cascade_algorithm import maptest_new_outage_list import cascade_algorithm_reduced_outages import protection_assembly_info import time tot_exe_time_start = time.time() temp_max_loadloss = 0 worst_case_outage = [] PA_names = [] max_load_loss_outage, max_loadloss = cascade_algorithm.DSS_Python_Interface1( filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name) # print max_load_loss_outage temp_max_loadloss = max_loadloss worst_case_outage = max_load_loss_outage for k in range(0, (budget - 1)): new_outage_list = maptest_new_outage_list.maptest14bus_test_system( comp_filename, start_range, contingency_range, max_load_loss_outage) # print new_outage_list max_load_loss_outage, max_loadloss = cascade_algorithm_reduced_outages.DSS_Python_Interface1( filepath, comp_filename, load_file_name, start_range, contingency_range, blackout_criterion, system_name, new_outage_list) if (max_loadloss > temp_max_loadloss): temp_max_loadloss = max_loadloss worst_case_outage = max_load_loss_outage PA_names = protection_assembly_info.protection_assembly_info( PA_name_file, worst_case_outage) tot_exe_time_end = time.time() tot_exe_time = (tot_exe_time_end - tot_exe_time_start) print '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' print 'Worst Case Outage: %s' % worst_case_outage print 'Worst Case Loadloss: %s' % temp_max_loadloss print 'Critical Protection Assemblies: %s' % PA_names print 'Total Execution Time In Seconds: %s' % tot_exe_time print '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'