How to use cln method in fMBT

Best Python code snippet using fMBT_python

results.py

Source:results.py Github

copy

Full Screen

...10 'K1': s*s/fact(5)/fact(4),11 'K2': t*t/fact(5)/fact(4),12 'K3': s*(3*s*s-2*s*t+t*t)/fact(5)/fact(4)/fact(3)/9,13 'K4': t*(3*t*t-2*s*t+s*s)/fact(5)/fact(4)/fact(3)/9,14 'L1': (s**3*cln(-210))/fact(6)/fact(5)/fact(4)/fact(3),15 'L2': (t**3*cln(-210))/fact(6)/fact(5)/fact(4)/fact(3),16 'L3': (s**4*cln(-430)/21+s**3*t*cln(4)/9-s**2*t**2*cln(1)/18)/fact(6)/fact(5)/fact(4)/fact(3), #correct17 'L4': (-s**2*t**2*cln(1)/18+s*t**3*cln(4)/9+t**4*cln(-430)/21)/fact(6)/fact(5)/fact(4)/fact(3),18 'L5': (s**4*cln(-20)/3+s**3*t*cln(8)/9-s**2*t**2*cln(1)/9)/fact(6)/fact(5)/fact(4)/fact(3), #correct19 'L6': (-s**2*t**2*cln(1)/9+s*t**3*cln(8)/9)/fact(6)/fact(5)/fact(4)/fact(3),20 'L7': (-cln(45)/14*s**5+s**4*t*(cln(18)/7)+s**3*t**2*cln(-27)/14+s*s*t**3*(cln(9)/7)+s*t**4*cln(-9)/14)/fact(6)/fact(5)/fact(4)/fact(3),21 'L8': (s*t**4*(cln(18)/7)+s**2*t**3*cln(-27)/14+s**3*t**2*(cln(9)/7)+t*s**4*cln(-9)/14-cln(45)/14*t**5)/fact(6)/fact(5)/fact(4)/fact(3), #corect22 'L9': (s**5*cln(-15)/28+s**4*t*cln(25)/7/9+s**3*t**2*cln(-65)/7/4/9+s**2*t**3*cln(5)/42+s*t**4*(-cln(1)/28))/fact(6)/fact(5)/fact(4)/fact(3), #correct23 'L10': (s**4*t*(-cln(1)/28)+s**3*t**2*cln(5)/42 + s**2*t**3*cln(-65)/7/4/9+t**4*s*cln(25)/7/9+t**5*cln(-15)/28)/fact(6)/fact(5)/fact(4)/fact(3),24 'L11': cln(0),25 'L12': cln(0),26 'L13': cln(0),27 'L14': cln(0),28 'L15': cln(0),29 }30print res_d8_kazakov31#D8_s_s_s_1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:s|0|t|0|s|0|t/1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:s|0|t|0|s|0|t_0_V7_E-2.run.res.1M:result = 0.00034717706155927514732#D8_s_s_t_1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:s|0|t|0|s|0|t/1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:s|0|t|0|s|0|t_0_V7_E-2.run.res.1M:result = -7.71577109669606447e-0533#D8_1|234||||:0|0_0_0||||:s|0|s|t|t/1|234||||:0|0_0_0||||:s|0|s|t|t_0_V3_E0.run.res.1M:result = 0.16666638078993067934#D8_s_1|234|3|45|||:0|0_0_0|0|0_0|||:s|0|t|0|t|s/1|234|3|45|||:0|0_0_0|0|0_0|||:s|0|t|0|t|s_0_V5_E-1.run.res.1M:result = -0.013886323804284202535#D8_s_s_1|234|345|5|5|6||:0|0_0_0|0_0_0|0|0|0||:s|0|0|t|t|0|s/1|234|345|5|5|6||:0|0_0_0|0_0_0|0|0|0||:s|0|0|t|t|0|s_0_V7_E-2.run.res.1M:result = 0.0020336130469667495936#D8_s_t_t_1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:s|0|t|0|s|0|t/1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:s|0|t|0|s|0|t_0_V7_E-2.run.res.1M:result = 3.85783339864735573e-0537#D8_s_t_1|234|345|5|5|6||:0|0_0_0|0_0_0|0|0|0||:s|0|0|t|t|0|s/1|234|345|5|5|6||:0|0_0_0|0_0_0|0|0|0||:s|0|0|t|t|0|s_0_V7_E-2.run.res.1M:result = 1.15723241185716754e-0638# D8_1|234||||:0|0_0_0||||:s|0|s|t|t/1|234||||:0|0_0_0||||:s|0|s|t|t_0_V3_E0.run.res.10000000:result = 0.16666680164104566439# D8_1|234||||:0|0_0_0||||:s|0|s|t|t/1|234||||:0|0_0_0||||:s|0|s|t|t_0_V3_E0.run.res.100000000:result = 0.16666673725766045840# D8_s_1|234|3|45|||:0|0_0_0|0|0_0|||:s|0|t|0|t|s/1|234|3|45|||:0|0_0_0|0|0_0|||:s|0|t|0|t|s_0_V5_E-1.run.res.100000000:result = -0.006944439500525969841# D8_s_s_1|234|345|5|5|6||:0|0_0_0|0_0_0|0|0|0||:s|0|0|t|t|0|s/1|234|345|5|5|6||:0|0_0_0|0_0_0|0|0|0||:s|0|0|t|t|0|s_0_V7_E-2.run.res.100000000:result = 0.00034722242744591606942# D8_s_s_s_1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:s|0|t|0|s|0|t/1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:s|0|t|0|s|0|t_0_V7_E-2.run.res.100000000:result = 1.92902197684449618e-0543# D8_s_s_t_1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:s|0|t|0|s|0|t/1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:s|0|t|0|s|0|t_0_V7_E-2.run.res.100000000:result = -1.28600777698412859e-0544# D8_s_s_t_1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:t|0|s|0|t|0|s/1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:t|0|s|0|t|0|s_0_V7_E-2.run.res.100000000:result = 6.43009917744553122e-0645# D8_s_t_t_1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:s|0|t|0|s|0|t/1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:s|0|t|0|s|0|t_0_V7_E-2.run.res.100000000:result = 6.4300638832171996e-0646# D8_s_t_t_1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:t|0|s|0|t|0|s/1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:t|0|s|0|t|0|s_0_V7_E-2.run.res.100000000:result = -1.28601020109254184e-0547# D8_t_1|234|3|45|||:0|0_0_0|0|0_0|||:t|0|s|0|s|t/1|234|3|45|||:0|0_0_0|0|0_0|||:t|0|s|0|s|t_0_V5_E-1.run.res.100000000:result = -0.0069444411682917294948# D8_t_t_1|234|345|5|5|6||:0|0_0_0|0_0_0|0|0|0||:t|0|0|s|s|0|t/1|234|345|5|5|6||:0|0_0_0|0_0_0|0|0|0||:t|0|0|s|s|0|t_0_V7_E-2.run.res.100000000:result = 0.00034722050463016244449# D8_t_t_t_1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:t|0|s|0|t|0|s/1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:t|0|s|0|t|0|s_0_V7_E-2.run.res.100000000:result = 1.92901204043652127e-0550res_d8_mk = {'I1': 0.166666380789930679, # D8_1|234||||:0|0_0_0||||:s|0|s|t|t51 'J1': -0.0069444395005259698*s + 0*t, # D8_s_1|234|3|45|||:0|0_0_0|0|0_0|||:s|0|t|0|t|s52 'J2': -0.00694444116829172949*t + 0*s, # D8_t_1|234|3|45|||:0|0_0_0|0|0_0|||:t|0|s|0|s|t53 'K1': s**2*0.000347222427445916069, # D8_s_t_1|234|345|5|5|6||:0|0_0_0|0_0_0|0|0|0||:s|0|0|t|t|0|s54 'K2': t**2*0.000347220504630162444, # D8_s_t_1|234|345|5|5|6||:0|0_0_0|0_0_0|0|0|0||:t|0|0|s|s|0|t55 'K3': s**3*1.92902197684449618e-05+s**2*t*(-1.28600777698412859e-05)+s*t**2*6.4300638832171996e-06+t**3*0, # D8_s_s_s_1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:s|0|t|0|s|0|t56 'K4': s**3*0+s**2*t*(6.43009917744553122e-06)+s*t**2*(-1.28601020109254184e-05)+t**3*1.92901204043652127e-05, # D8_t_t_t_1|23456|3|45|5|6||:0|0_0_1_0_0|0|0_0|0|0||:t|0|s|0|t|0|s57 'L1': s**3*(-1.68785995602744613e-05),58 'L2': t**3*(-1.68778695435609865e-05),59 'L3': s**4*(-1.64567102125066986e-06)+s**3*t*(3.57204561294340108e-08)+s*s*t*t*(-4.46518959518477966e-09), #correct s*s*t*t60 'L4': s*s*t*t*(-4.46518959518477966e-09)+s*t**3*(3.57204561294340108e-08)+t**4*(-1.64567102125066986e-06),61 'L5': s**4*(-2.75253142702371203e-07 -1.42726868721902996e-07 -3.44893147619749901e-08-8.33243335550604943e-08)+s**3*t*(7.14458251862796748e-08)+s*s*t*t*(-8.93056087494089887e-09), #correct s*s*t*t62 'L6': s*s*t*t*(-8.93056087494089887e-09)+s*t**3*(7.14458251862796748e-08)+t**4*(-2.75253142702371203e-07 -1.42726868721902996e-07 -3.44893147619749901e-08-8.33243335550604943e-08),63 'L7': s**5*(-2.58350887957834037e-07)+s**4*t*(2.06686192690137045e-07)+s**3*t**2*(-1.55011566907761635e-07)+s**2*t**3*(1.03337882470582075e-07)+s*t**4*(-5.16715122528733594e-08),64 'L8': s**4*t*(-5.16715122528733594e-08)+s**3*t**2*(1.03337882470582075e-07)+s**2*t**3*(-1.55011566907761635e-07)+s**1*t**4*(2.06686192690137045e-07)+t**5*(-2.58350887957834037e-07), #correct t^565 'L9': s*t**4*(-2.87039517787842645e-09)+s**2*t**3*(9.56890571755092227e-09)+s**3*t**2*(-2.07308801741647146e-08)+s**4*t*(2.55016905933046112e-08+4.50545680076137807e-09+1.88880929057826021e-09)+s**5*(-2.60895992478026868e-08-7.03329483134756389e-10-1.62670686265519564e-08), #correct s*s*t*t66 'L10': s**4*t*(-2.87039517787842645e-09)+s**3*t**2*(9.56890571755092227e-09)+s**2*t**3*(-2.07308801741647146e-08)+t**4*s*(2.55016905933046112e-08+4.50545680076137807e-09+1.88880929057826021e-09)+t**5*(-2.60895992478026868e-08-7.03329483134756389e-10-1.62670686265519564e-08),67 'L11': cln(0),68 'L12': cln(0),69 'L13': cln(0),70 'L14': cln(0),71 'L15': cln(0),72 }73for i in sorted(res_d8_mk.keys()):74 print i, "\t", (res_d8_kazakov[i].expand()).evalf() if i in res_d8_kazakov else None, "\n\t", res_d8_mk[i], \75 "\ndelta =", ((res_d8_kazakov[i].expand()).evalf()-res_d8_mk[i]).expand() if i in res_d8_kazakov else None76 print i, "\t", (res_d8_kazakov[i])*fact(6)*fact(5)*fact(4)*fact(3)77 print78sys.exit()79print80print81print "D=6"82print83res_d6_kazakov = {'K3': cln(1)/6,84 'K4': cln(1)/6,85 'L1': cln(0),86 'L2': cln(0),87 'L3': cln(1)/48,88 'L4': cln(1)/48,89 'L5': cln(1)/24,90 'L6': cln(1)/24,91 'L7': cln(0),92 'L8': cln(0),93 'L9': (t-s)/3/48,94 'L10': (s-t)/3/48,95 'L11': cln(0),96 'L12': cln(0),97 'L13': cln(0),98 'L14': cln(0),99 'L15': cln(0),100 }101# D6_1|234|34567|5|6|67|7||:0|0_0_0|0_0_0_0_1|0|0|0_0|0||:s|0|0|t|t|0|0|s/1|234|34567|5|6|67|7||:0|0_0_0|0_0_0_0_1|0|0|0_0|0||:s|0|0|t|t|0|0|s_0_V11_E-1.run.res.10000000:result = 0.0208328082549803541102# D6_1|23456|34|45|567|6|||:0|0_0_1_0_0|0_0|0_0|0_0_0|0|||:t|0|s|0|0|0|s|t/1|23456|34|45|567|6|||:0|0_0_1_0_0|0_0|0_0|0_0_0|0|||:t|0|s|0|0|0|s|t_0_V11_E-1.run.res.10000000:result = 0.0416652289605569243103# D6_s_1|23456|3|4567|57|7|7||:0|0_0_0_0_1|0|0_1_0_0|0_0|0|0||:s|0|t|0|0|t|s|0/1|23456|3|4567|57|7|7||:0|0_0_0_0_1|0|0_1_0_0|0_0|0|0||:s|0|t|0|0|t|s|0_0_V11_E-1.run.res.10000000:result = -0.00694435447490225188104# D6_s_1|23456|3|4567|57|7|7||:0|0_0_0_0_1|0|0_1_0_0|0_0|0|0||:t|0|s|0|0|s|t|0/1|23456|3|4567|57|7|7||:0|0_0_0_0_1|0|0_1_0_0|0_0|0|0||:t|0|s|0|0|s|t|0_0_V11_E-1.run.res.10000000:result = 0.00694435967527374902105# D6_t_1|23456|3|4567|57|7|7||:0|0_0_0_0_1|0|0_1_0_0|0_0|0|0||:s|0|t|0|0|t|s|0/1|23456|3|4567|57|7|7||:0|0_0_0_0_1|0|0_1_0_0|0_0|0|0||:s|0|t|0|0|t|s|0_0_V11_E-1.run.res.10000000:result = 0.00694430532353083625106# D6_t_1|23456|3|4567|57|7|7||:0|0_0_0_0_1|0|0_1_0_0|0_0|0|0||:t|0|s|0|0|s|t|0/1|23456|3|4567|57|7|7||:0|0_0_0_0_1|0|0_1_0_0|0_0|0|0||:t|0|s|0|0|s|t|0_0_V11_E-1.run.res.10000000:result = -0.00694409525342296833107res_d6_mk = {'K3': 0.166672811495946843,108 'K4': 0.166630234959756984,109 'L1': cln(0),110 'L2': cln(0),111 'L3': 0.0208328082549803541,112 'L4': cln(1)/48,113 'L5': 0.0416652289605569243,114 'L6': cln(1)/24,115 'L7': 0.,116 'L8': 0.,117 'L9': -0.00694435447490225188*s+0.006944359675273749026*t,118 'L10': 0.00694430532353083625*s+(-0.00694409525342296833)*t,119 'L11': cln(0),120 'L12': cln(0),121 'L13': cln(0),122 'L14': cln(0),123 'L15': cln(0),124 }125for i in sorted(res_d6_kazakov.keys()):126 print i,"\t", (res_d6_kazakov[i].expand()).evalf(),"\n\t",res_d6_mk[i],"\ndelta =", ((res_d6_kazakov[i].expand()).evalf()-res_d6_mk[i]).expand()...

Full Screen

Full Screen

refined_md.py

Source:refined_md.py Github

copy

Full Screen

1from utility import *2import matplotlib.pyplot as plt3from numpy import linspace4from scipy.integrate import odeint5class Model():6 def __init__(7 self, init_paras, max_t, max_ite, title8 ):9 self.init_paras = init_paras10 self.max_t = max_t11 self.max_ite = max_ite12 self.title = title13 # initial species counts and sojourn times14 self.initital_conditions = {15 "p_s": [self.init_paras['p_s']],16 "p_cln": [self.init_paras['p_cln']],17 "h_s": [self.init_paras['h_s']],18 "h_cln": [self.init_paras['h_cln']],19 "nur_s": [self.init_paras['nur_s']],20 "nur_cln": [self.init_paras['nur_cln']],21 "time": [0.0],22 }23 # propensity functions24 self.propensities = {25 # patient gets colonized through contacts from HCWs26 0: lambda d: self.init_paras['r_hcw_p'] * d["p_s"][-1] * d["h_cln"][-1] / self.init_paras['N_h'],27 # patient gets colonized through contacts from nurses28 1: lambda d: self.init_paras['r_nur_p'] * d["p_s"][-1] * d["nur_cln"][-1] / self.init_paras['N_nur'],29 # HCW gets colonized30 2: lambda d: self.init_paras['r_p_hcw']* d["h_s"][-1] * d["p_cln"][-1] / self.init_paras['N_h'],31 # colonized HCW washes hands to eliminate pathogen32 3: lambda d: self.init_paras['r_hw_hcw'] * d["h_cln"][-1],33 # Nurse gets colonized34 4: lambda d: self.init_paras['r_p_nur']* d["nur_s"][-1] * d["p_cln"][-1] / self.init_paras['N_nur'],35 # colonized Nurse washes hands to eliminate pathogen36 5: lambda d: self.init_paras['r_hw_nur'] * d["nur_cln"][-1],37 # colonized patient is detected38 6: lambda d: self.init_paras['r_det'] * d["p_cln"][-1],39 # patient is regularly removed from the ward40 7: lambda d: self.init_paras['r_rm'] * d["p_cln"][-1],41 # Proportion of admissions already colonized42 8: lambda d: self.init_paras['pro_cln'] * (self.init_paras['r_rm'] * (d["p_s"][-1] + d["p_cln"][-1] +43 self.init_paras['r_det'] * d["p_cln"][-1]) + self.init_paras['r_det'] * d["p_cln"][-1]),44 }45 # change in species for each propensity46 self.stoichiometry = {47 0: {"p_s": -1, "p_cln": 1, "h_s": 0, "h_cln": 0, "nur_s":0, "nur_cln":0 },48 1: {"p_s": -1, "p_cln": 1, "h_s": 0, "h_cln": 0, "nur_s":0, "nur_cln":0 },49 2: {"p_s": 0, "p_cln": 0, "h_s": -1, "h_cln": 1, "nur_s":0, "nur_cln":0 },50 3: {"p_s": 0, "p_cln": 0, "h_s": 1, "h_cln": -1, "nur_s":0, "nur_cln":0 },51 4: {"p_s": 0, "p_cln": 0, "h_s": 0, "h_cln": 0, "nur_s":-1, "nur_cln":1 },52 5: {"p_s": 0, "p_cln": 0, "h_s": 0, "h_cln": 0, "nur_s":1, "nur_cln":-1},53 6: {"p_s": 1, "p_cln": -1, "h_s": 0, "h_cln": 0, "nur_s":0, "nur_cln":0 },54 7: {"p_s": 1, "p_cln": -1, "h_s": 0, "h_cln": 0, "nur_s":0, "nur_cln":0 },55 8: {"p_s": -1, "p_cln": 1, "h_s": 0, "h_cln": 0, "nur_s":0, "nur_cln":0 }56 }57 def __call__(self, plot = True,save = True):58 plt.figure(figsize=(10,10), dpi=500)59 fig = plt.gcf()60 fig.suptitle(self.title, fontsize=16)61 axes_p_cln = plt.subplot(311)62 axes_p_cln.set_ylabel("number of infected patients")63 axes_p_cln.set_xlabel('$t$')64 axes_p_cln.set_xlim([0, self.max_t])65 axes_p_cln.set_ylim([0, self.init_paras['N_p']])66 axes_hcw_cln = plt.subplot(312)67 axes_hcw_cln.set_ylabel("number of colonized HCWs")68 axes_hcw_cln.set_xlabel('$t$')69 axes_hcw_cln.set_xlim([0, self.max_t])70 axes_hcw_cln.set_ylim([0, self.init_paras['N_h']])71 axes_nur_cln = plt.subplot(313)72 axes_nur_cln.set_ylabel("number of colonized nurses")73 axes_nur_cln.set_xlabel('$t$')74 axes_nur_cln.set_xlim([0, self.max_t])75 axes_nur_cln.set_ylim([0, self.init_paras['N_nur']])76 # instantiate the epidemic SSA model container77 epidemic = SSAModel(78 self.initital_conditions,79 self.propensities,80 self.stoichiometry81 )82 # instantiate the SSA container with model83 epidemic_generator = SSA(epidemic, self.max_t)84 # simulate and plot 30 trajectories85 trajectories = 086 for trajectory in epidemic_generator.direct():87 axes_p_cln.step(trajectory["time"], trajectory["p_cln"], color="orange")88 axes_hcw_cln.step(trajectory["time"], trajectory["h_cln"], color="orange")89 axes_nur_cln.step(trajectory["time"], trajectory["nur_cln"], color="orange")90 trajectories += 191 if trajectories == self.max_ite:92 break93 # numerical solution using an ordinary differential equation solversir94 t = linspace(0, self.max_t, num=self.max_t*10)95 y0 = (self.init_paras['p_s'], self.init_paras['p_cln'],96 self.init_paras['h_s'], self.init_paras['h_cln'],97 self.init_paras['nur_s'], self.init_paras['nur_cln'])98 solution = odeint(self.differential_SIR, y0, t,99 args=(self.init_paras['r_hcw_p'], self.init_paras['r_p_hcw'],100 self.init_paras['r_hw_hcw'],101 self.init_paras['r_nur_p'], self.init_paras['r_p_nur'],102 self.init_paras['r_hw_nur'],103 self.init_paras['r_det'],104 self.init_paras['r_rm'], self.init_paras['pro_cln']))105 solution = [[row[i] for row in solution] for i in range(6)]106 # plot numerical solution107 axes_p_cln.plot(t, solution[1], color="black")108 axes_hcw_cln.plot(t, solution[3], color="black")109 axes_nur_cln.plot(t, solution[5], color="black")110 fig = plt.gcf()111 if plot:112 plt.show()113 if save:114 fig.savefig(self.title+'.png', dpi=800)115 def differential_SIR(self, n, t, r_hcw_p, r_p_hcw, r_hw_hcw, r_nur_p, r_p_nur, r_hw_nur, r_det, r_rm, pro_cln):116 dps_dt = -pro_cln * (r_rm * (n[0] + n[1]) + r_det * n[1]) \117 - r_nur_p * n[0] * n[5] / self.init_paras['N_nur'] \118 - r_hcw_p * n[0] * n[3] / self.init_paras['N_h'] + (r_det+r_rm) * n[1]119 dpc_dt = pro_cln * (r_rm * (n[0] + n[1]) + r_det * n[1]) \120 + r_nur_p * n[0] * n[5] / self.init_paras['N_nur'] \121 + r_hcw_p * n[0] * n[3] / self.init_paras['N_h'] - (r_det+r_rm) * n[1]122 dhs_dt = -r_p_hcw * n[2] * n[1] / self.init_paras['N_h'] + r_hw_hcw * n[3]123 dhc_dt = r_p_hcw * n[2] * n[1] / self.init_paras['N_h'] - r_hw_hcw * n[3]124 dnurs_dt = -r_p_nur * n[4] * n[1] / self.init_paras['N_nur'] + r_hw_nur * n[5]125 dnurc_dt = r_p_nur * n[4] * n[1] / self.init_paras['N_nur'] - r_hw_nur * n[5]...

Full Screen

Full Screen

hardcoded.py

Source:hardcoded.py Github

copy

Full Screen

...4import graph_util_ms5import graph_state6import graphine7from rggraphenv.symbolic_functions import cln, log, p8ln43 = log(cln(4)/cln(3))9ONE_LOOP = dict()10from rggraphenv import symbolic_functions11ONE_LOOP[graph_util_ms.from_str("e11|e|:00_aA_aA|00|::::").to_graph_state()] = {"iw": {-1: cln(1)/cln(4)}, "p2": {-1: -cln(1)/cln(8)}, "tau": {-1: -cln(1)/cln(2)}}12ONE_LOOP[graph_util_ms.from_str("e12|e2|e|:00_Aa_aA|00_aA|00|::::").to_graph_state()] = {"log": {-1: cln(1)/cln(4)}}13assert len(ONE_LOOP) == 214TWO_LOOPS = dict()15# TWO_LOOPS[graph_util_ms.from_str("e12|e3|e4|44||:00_Aa_aA|00_aA|00_Aa|aA_aA||::::").to_graph_state()] = {"log": {-2: cln(1)/cln(64), -1: -cln(3)/cln(32)-ln43/cln(64)}}16# TWO_LOOPS[graph_util_ms.from_str("e12|e3|e4|44||:00_aA_aA|00_Aa|00_aA|Aa_Aa||::::").to_graph_state()] = {"log": {-2: cln(3)/cln(128), -1: -cln(3)*ln43/cln(128)-cln(1)/cln(32)}}17# TWO_LOOPS[graph_util_ms.from_str("e12|e3|e4|44||:00_Aa_Aa|00_Aa|00_aA|Aa_Aa||::::").to_graph_state()] = {"log": {-2: cln(3)/cln(128), -1: -cln(3)*ln43/cln(128)-cln(1)/cln(32)}}18TWO_LOOPS[graph_util_ms.from_str("e12|e3|e4|44||:00_Aa_aA|00_aA|00_Aa|aA_aA||::::").to_graph_state()] = {"log": {-2: cln(1)/cln(64), -1: -cln(1)/cln(32)-ln43/cln(64)}}19TWO_LOOPS[graph_util_ms.from_str("e12|e3|e4|44||:00_aA_aA|00_Aa|00_aA|Aa_Aa||::::").to_graph_state()] = {"log": {-2: cln(3)/cln(128), -1: -cln(3)*ln43/cln(128)}}20TWO_LOOPS[graph_util_ms.from_str("e12|e3|e4|44||:00_Aa_Aa|00_Aa|00_aA|Aa_Aa||::::").to_graph_state()] = {"log": {-2: cln(3)/cln(128), -1: -cln(3)*ln43/cln(128)}}21TWO_LOOPS[graph_util_ms.from_str("e12|34|34|e|e|:00_aA_aA|aA_aA|aA_aA|00|00|::::").to_graph_state()] = {"log": {-1: ln43*cln(3)/cln(8)}}22# delete23# TWO_LOOPS[graph_util_ms.from_str("e12|34|34|e|e|:00_Aa_Aa|Aa_Aa|Aa_Aa|00|00|::::").to_graph_state()] = {"log": {-1: ln43*cln(3)/cln(8)}}24TWO_LOOPS[graph_util_ms.from_str("e12|34|34|e|e|:00_aA_aA|aA_aA|Aa_aA|00|00|::::").to_graph_state()] = {"log": {-1: ln43/cln(8)}}25TWO_LOOPS[graph_util_ms.from_str("e12|e3|34|4|e|:00_aA_aA|00_aA|aA_aA|aA|00|::::").to_graph_state()] = {"log": {-2: -cln(1)/cln(32), -1: (cln(1)+ln43)/cln(32)}}26TWO_LOOPS[graph_util_ms.from_str("e12|e3|34|4|e|:00_Aa_Aa|00_Aa|Aa_Aa|Aa|00|::::").to_graph_state()] = {"log": {-2: -cln(1)/cln(32), -1: (cln(1)+ln43)/cln(32)}}27TWO_LOOPS[graph_util_ms.from_str("e12|e3|34|4|e|:00_aA_aA|00_aA|Aa_aA|aA|00|::::").to_graph_state()] = {"log": {-2: -cln(1)/cln(32), -1: (cln(1)-3*ln43)/cln(32)}}28TWO_LOOPS[graph_util_ms.from_str("e12|e3|34|4|e|:00_Aa_Aa|00_Aa|aA_Aa|Aa|00|::::").to_graph_state()] = {"log": {-2: -cln(1)/cln(32), -1: (cln(1)-3*ln43)/cln(32)}}29# delete30# TWO_LOOPS[graph_util_ms.from_str("e12|e3|34|4|e|:00_aA_aA|00_Aa|aA_aA|Aa|00|::::").to_graph_state()] = {"log": {-2: -cln(1)/cln(32), -1: (ln43-cln(1))/cln(32)}}31TWO_LOOPS[graph_util_ms.from_str("e12|e3|34|4|e|:00_Aa_Aa|00_aA|Aa_Aa|aA|00|::::").to_graph_state()] = {"log": {-2: -cln(1)/cln(32), -1: (ln43-cln(1))/cln(32)}}32# delete33# TWO_LOOPS[graph_util_ms.from_str("e12|e3|34|4|e|:00_aA_aA|00_Aa|aA_aA|aA|00|::::").to_graph_state()] = {"log": {-2: -cln(1)/cln(32), -1: (cln(1)-3*ln43)/cln(32)}}34TWO_LOOPS[graph_util_ms.from_str("e12|e3|34|4|e|:00_Aa_Aa|00_aA|Aa_Aa|Aa|00|::::").to_graph_state()] = {"log": {-2: -cln(1)/cln(32), -1: (cln(1)-3*ln43)/cln(32)}}35# assert len(TWO_LOOPS) == 936# TWO_LOOPS[graph_util_ms.from_str("e12|23|3|e|:00_aA_aA|aA_aA|aA|00|::::").to_graph_state()] = {"iw": {-2: -cln(1)/cln(16), -1: (cln(1)-ln43)/cln(16)},37# "p2": {-2: cln(1)/cln(32), -1: -cln(7)/cln(192)+ln43/cln(16)},38# "tau": {-1: cln(1)/cln(8), -2: cln(1)/cln(8)}}39TWO_LOOPS[graph_util_ms.from_str("e12|23|3|e|:00_aA_aA|aA_aA|aA|00|::::").to_graph_state()] = {"iw": {-2: -cln(1)/cln(16), -1: (cln(1)-ln43)/cln(16)},40 "p2": {-2: cln(1)/cln(32), -1: -cln(7)/cln(192)+ln43/cln(16)},41 "tau": {-1: -cln(1)/cln(8), -2: cln(1)/cln(8)}}42# TWO_LOOPS[graph_util_ms.from_str("e12|e3|33||:00_aA_aA|00_Aa|aA_aA||::::").to_graph_state()] = {"iw": {-2: cln(1)/cln(64), -1: -cln(3)/cln(32)-ln43/cln(64)},43# "p2": {-2: -cln(3)/cln(256), -1: cln(3)*ln43/cln(256)+cln(67)/cln(1536)},44# "tau": {-1: -cln(1)/cln(8)}}45TWO_LOOPS[graph_util_ms.from_str("e12|e3|33||:00_aA_aA|00_Aa|aA_aA||::::").to_graph_state()] = {"iw": {-2: cln(1)/cln(64), -1: -cln(1)/cln(32)-ln43/cln(64)},46 "p2": {-2: -cln(3)/cln(256), -1: cln(3)*ln43/cln(256)+cln(19)/cln(1536)},47 "tau": {-1: cln(3)/cln(32)}}48# # assert len(TWO_LOOPS) == 1149# a = TWO_LOOPS[graph_util_ms.from_str("e12|23|3|e|:00_aA_aA|aA_aA|aA|00|::::").to_graph_state()]["p2"][-1]50# b = TWO_LOOPS[graph_util_ms.from_str("e12|e3|33||:00_aA_aA|00_Aa|aA_aA||::::").to_graph_state()]["p2"][-1]/251# print a+b52# exit(1)53def kr1(graph, operation):54 graph = graphine.Graph(map(lambda e: e.copy(fields=graph_state.Fields("00")) if e.is_external() else e, graph))55 if graph.loops_count == 1:56 return ONE_LOOP[graph.to_graph_state()][operation]57 elif graph.loops_count == 2:58 return TWO_LOOPS[graph.to_graph_state()][operation]59 assert False60def kr1_eps(graph, operation):61 result = symbolic_functions.CLN_ZERO...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful