<jupyter_start><jupyter_text>Worst Case Scenario  Import Dependencies<jupyter_code>import time
import pandas as pd
import matplotlib.pyplot as plt
import pygraphviz
import subprocess
import sys
sys.path.append('../../../source/ServerlessAppPerfCostMdlOpt')
import networkx as nx
import warnings
warnings.filterwarnings("ignore")
from ServerlessAppWorkflow import ServerlessAppWorkflow
from AppGenerator import AppGenerator
from PerfOpt import PerfOpt<jupyter_output><empty_output><jupyter_text>Generate and Solve Worst Case Workflows<jupyter_code># Generate workflow PNG
import subprocess
generator = AppGenerator()
App27_G = generator.cycles_workflow_generator(27)
nx.nx_agraph.write_dot(App27_G,'App27_G.dot')
f = open("App27_G.png", "w")
subprocess.run(["dot", "-n", "-Tpng", "App27_G.dot"],stdout=f)
G=generator.cycles_workflow_generator(27)
V=len(G.nodes)
E=len(G.edges)
print("Number of vertices V=: {}".format(V))
print("Number of edges E=: {}".format(E))
App = ServerlessAppWorkflow(G=G.copy(), delayType='None')
start_timestamp = time.time()
App.update_NE()
Appcost = App.get_avg_cost()
App.get_simple_dag()
Apprt = App.get_avg_rt()
end_timestamp = time.time()
ET=(end_timestamp-start_timestamp)*1000
print("Average End-to-end Response Time Reported by Model: {}".format(Apprt))
print("Average Cost per 1 Million Executions Reported by Model: {}".format(Appcost))
print("Elapsed Time: {}".format(ET))
def cycles_workflow_solver(max_node_num):
    data = pd.DataFrame(columns=['n','V','E', 'ET'])
    generator = AppGenerator()
    for i in range(1, max_node_num+1):
        G=generator.cycles_workflow_generator(i)
        V=len(G.nodes)
        E=len(G.edges)
        App = ServerlessAppWorkflow(G=G.copy(), delayType='None')
        start_timestamp = time.time()
        App.update_NE()
        Appcost = App.get_avg_cost()
        App.get_simple_dag()
        App.get_avg_rt()
        end_timestamp = time.time()
        ET=(end_timestamp-start_timestamp)*1000
        data = data.append(pd.Series({'n':i,'V':V,'E':E,'ET':ET}),ignore_index=True)
        data.to_csv("results.csv", index=False)
cycles_workflow_solver(128)
results = pd.read_csv('results.csv')
results.columns = ['Number of Functions', 'Number of Vertices', 'Number of Edges', 'Elapsed Time for Modeling in ms']
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
    print(results)<jupyter_output>Number of Functions  Number of Vertices  Number of Edges  \
0                    1.0                 3.0              3.0   
1                    2.0                 4.0              6.0   
2                    3.0                 5.0             10.0   
3                    4.0                 6.0             15.0   
4                    5.0                 7.0             21.0   
5                    6.0                 8.0             28.0   
6                    7.0                 9.0             36.0   
7                    8.0                10.0             45.0   
8                    9.0                11.0             55.0   
9                   10.0                12.0             66.0   
10                  11.0                13.0             78.0   
11                  12.0                14.0             91.0   
12                  13.0                15.0            105.0   
13                  14.0                16.0            120.0   
14                  15.0 [...]
{'fraction_non_alphanumeric': 0.11405055849500294, 'fraction_numerical': 0.047325102880658436, 'mean_word_length': 1.8668913226621735, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 23, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '625372', 'license': 'MIT', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1045, 'n_words': 233, 'path': 'evaluations/model/WorstCaseScenario/WorstCaseScenario.ipynb', 'repo_name': 'pacslab/SLApp-PerfCost-MdlOpt', 'size': '3402'}