Last active
April 6, 2022 15:40
-
-
Save dmitriykuptsov/cc43071387e8b15dcc749b3b972e1e80 to your computer and use it in GitHub Desktop.
Revisions
-
dmitriykuptsov renamed this gist
Apr 6, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dmitriykuptsov renamed this gist
Apr 6, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dmitriykuptsov revised this gist
Apr 6, 2022 . 2 changed files with 136 additions and 76 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,76 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,136 @@ ECW<-c(3:300) N<-c(2:12) OECW=c() for(n in N) { S=1540 ts<-28*10^-6+254*10^-6+10*10^-6+30*10^-6 tc=28*10^-6+254*10^-6+10*10^-6 tn<-9*10^-6 pt=2/(ECW+1) pn=(1-pt)^n ps=n*pt*(1-pt)^(n-1) pc=1-ps-pn fp=(S*ps)/(ps*ts+pc*tc+pn*tn) #plot(ECW, fp, type="line", col="red") i=which.max(fp) #print(paste("OPTIMIZED VALUE FOR THE ECW: ", n, ECW[i])) OECW<-c(OECW, ECW[i]) } N<-c(2:12) r=seq(1.0, 3, 0.0001) s=1 e=length(r) m=floor(length(r)/2.0) CWmin=16 i=1 epsilon = 0.01; or = c() for(n in N) { ECW = OECW[i] i = i + 1 s=1 e=length(r) m=floor(length(r)/2.0) pt=2/(ECW+1) pn=(1-pt)^n ps=n*pt*(1-pt)^(n-1) pc=1-ps-pn CWmin=16 k=7 diff = 1; while(diff > epsilon) { ra=r[s] rb=r[e] rm=r[m] #print(ra) #print(rb) #print(rm) a=(ECW+0.5)*2/CWmin*(1-pc^k)/(1-pc) fra=ra^k-a*ra-a*pc-pc^k frb=rb^k-a*rb-a*pc-pc^k frm=rm^k-a*rm-a*pc-pc^k fr=r^k-a*r-a*pc-pc^k if(frm <= 0 & frb > 0) { s = m } else if (frm > 0 & fra <= 0) { e = m } else { break; } diff = abs(ra-rb); m=floor((s+e)/2.0) } print(paste("OPTIMIZED VALUE FOR THE BACKOFF FACTOR: ", ECW, ra)) or = c(or, ra) } plot N<-c(2:12) r=seq(1.0, 3, 0.001) s=1 e=length(r) m=floor(length(r)/2.0) CWmin=16 i=1 epsilon = 0.01; or = c() for(n in N) { ECW = OECW[i] i = i + 1 s=1 e=length(r) m=floor(length(r)/2.0) pt=2/(ECW+1) pn=(1-pt)^n ps=n*pt*(1-pt)^(n-1) pc=1-ps-pn CWmin=16 k=7 diff = 1; while(diff > epsilon) { ra=r[s] rb=r[e] rm=r[m] fr = (ECW + 1/(2*(2-pc)))*((2*(2-pc)*(1-pc^k))/(1-pc)) - CWmin*(pc^k*r^k-1)/(pc*r-1) + (r^(k-1)*CWmin-1)*(pc^k-1) fra = (ECW + 1/(2*(2-pc)))*((2*(2-pc)*(1-pc^k))/(1-pc)) - CWmin*(pc^k*ra^k-1)/(pc*ra-1) + (ra^(k-1)*CWmin-1)*(pc^k-1) frb = (ECW + 1/(2*(2-pc)))*((2*(2-pc)*(1-pc^k))/(1-pc)) - CWmin*(pc^k*rb^k-1)/(pc*rb-1) + (rb^(k-1)*CWmin-1)*(pc^k-1) frm = (ECW + 1/(2*(2-pc)))*((2*(2-pc)*(1-pc^k))/(1-pc)) - CWmin*(pc^k*rm^k-1)/(pc*rm-1) + (rm^(k-1)*CWmin-1)*(pc^k-1) if(frm >= 0 & frb < 0) { s = m } else if (frm < 0 & fra >= 0) { e = m } else { break; } diff = abs(ra-rb); m=floor((s+e)/2.0) } #print(fr) #print(ra) #plot(r, fr) print(paste("OPTIMIZED VALUE FOR THE BACKOFF FACTOR: ", ECW, ra)) or = c(or, ra) } -
dmitriykuptsov created this gist
Apr 6, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,76 @@ ECW<-c(3:300) N<-c(2:12) OECW=c() for(n in N) { S=1540 ts<-28*10^-6+254*10^-6+10*10^-6+30*10^-6 tc=28*10^-6+254*10^-6+10*10^-6 tn<-9*10^-6 pt=2/(ECW+1) pn=(1-pt)^n ps=n*pt*(1-pt)^(n-1) pc=1-ps-pn fp=(S*ps)/(ps*ts+pc*tc+pn*tn) #plot(ECW, fp, type="line", col="red") i=which.max(fp) #print(paste("OPTIMIZED VALUE FOR THE ECW: ", n, ECW[i])) OECW<-c(OECW, ECW[i]) } N<-c(2:12) r=seq(1.0, 3, 0.0001) s=1 e=length(r) m=floor(length(r)/2.0) CWmin=16 i=1 epsilon = 0.01; for(n in N) { ECW = OECW[i] i = i + 1 s=1 e=length(r) m=floor(length(r)/2.0) pt=2/(ECW+1) pn=(1-pt)^n ps=n*pt*(1-pt)^(n-1) pc=1-ps-pn CWmin=16 k=7 diff = 1; while(diff > epsilon) { ra=r[s] rb=r[e] rm=r[m] #print(ra) #print(rb) #print(rm) a=(ECW+0.5)*2/CWmin*(1-pc^k)/(1-pc) fra=ra^k-a*ra-a*pc-pc^k frb=rb^k-a*rb-a*pc-pc^k frm=rm^k-a*rm-a*pc-pc^k fr=r^k-a*r-a*pc-pc^k if(frm <= 0 & frb > 0) { s = m } else if (frm > 0 & fra <= 0) { e = m } else { break; } diff = abs(ra-rb); m=floor((s+e)/2.0) } print(paste("OPTIMIZED VALUE FOR THE BACKOFF FACTOR: ", ECW, ra)) }