-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* French INRETS VD function First implementation of the French INRETS Volume Delay function. Beta is not used but kept for better consistancy across VD functions. * BPR2 implementation First implementation of BPR2 Volume Delay function. This doubles beta above capacity so that fewer vehicles are affected when capacity is exceeded. Double Beta insteed of using a Beta' allow to use only 2 parameters as for other VD functions. Integration into QGIS GUI is also easier
- Loading branch information
Showing
10 changed files
with
294 additions
and
59 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from libc.math cimport pow | ||
from cython.parallel import prange | ||
|
||
def bpr2(congested_times, link_flows, capacity, fftime, alpha, beta, cores): | ||
cdef int c = cores | ||
|
||
cdef double [:] congested_view = congested_times | ||
cdef double [:] link_flows_view = link_flows | ||
cdef double [:] capacity_view = capacity | ||
cdef double [:] fftime_view = fftime | ||
cdef double [:] alpha_view = alpha | ||
cdef double [:] beta_view = beta | ||
|
||
bpr2_cython(congested_view, link_flows_view, capacity_view, fftime_view, alpha_view, beta_view, c) | ||
|
||
def delta_bpr2(dbpr2, link_flows, capacity, fftime, alpha, beta, cores): | ||
cdef int c = cores | ||
|
||
cdef double [:] dbpr2_view = dbpr2 | ||
cdef double [:] link_flows_view = link_flows | ||
cdef double [:] capacity_view = capacity | ||
cdef double [:] fftime_view = fftime | ||
cdef double [:] alpha_view = alpha | ||
cdef double [:] beta_view = beta | ||
|
||
dbpr2_cython(dbpr2_view, link_flows_view, capacity_view, fftime_view, alpha_view, beta_view, c) | ||
|
||
@cython.wraparound(False) | ||
@cython.embedsignature(True) | ||
@cython.boundscheck(False) | ||
cpdef void bpr2_cython(double[:] congested_time, | ||
double[:] link_flows, | ||
double [:] capacity, | ||
double [:] fftime, | ||
double[:] alpha, | ||
double [:] beta, | ||
int cores): | ||
cdef long long i | ||
cdef long long l = congested_time.shape[0] | ||
|
||
for i in prange(l, nogil=True, num_threads=cores): | ||
if link_flows[i] > 0: | ||
if link_flows[i] > capacity[i]: | ||
congested_time[i] = fftime[i] * (1 + alpha[i] * ( | ||
pow(link_flows[i] / capacity[i], 2*beta[i]))) | ||
else: | ||
congested_time[i] = fftime[i] * (1 + alpha[i] * ( | ||
pow(link_flows[i] / capacity[i], beta[i]))) | ||
else: | ||
congested_time[i] = fftime[i] | ||
|
||
@cython.wraparound(False) | ||
@cython.embedsignature(True) | ||
@cython.boundscheck(False) | ||
cpdef void dbpr2_cython(double[:] deltaresult, | ||
double[:] link_flows, | ||
double [:] capacity, | ||
double [:] fftime, | ||
double[:] alpha, | ||
double [:] beta, | ||
int cores): | ||
cdef long long i | ||
cdef long long l = deltaresult.shape[0] | ||
|
||
for i in prange(l, nogil=True, num_threads=cores): | ||
if link_flows[i] > 0: | ||
if link_flows[i] > capacity[i]: | ||
deltaresult[i] = fftime[i] * (alpha[i] * 2 * beta[i] * ( | ||
pow(link_flows[i] / capacity[i], (2*beta[i])-1))) / ( | ||
capacity[i]) | ||
else: | ||
deltaresult[i] = fftime[i] * (alpha[i] * beta[i] * ( | ||
pow(link_flows[i] / capacity[i], beta[i]-1))) / capacity[i] | ||
else: | ||
deltaresult[i] = fftime[i] |
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
from libc.math cimport pow | ||
from cython.parallel import prange | ||
|
||
def inrets(congested_times, link_flows, capacity, fftime, alpha, beta, cores): | ||
cdef int c = cores | ||
|
||
cdef double [:] congested_view = congested_times | ||
cdef double [:] link_flows_view = link_flows | ||
cdef double [:] capacity_view = capacity | ||
cdef double [:] fftime_view = fftime | ||
cdef double [:] alpha_view = alpha | ||
cdef double [:] beta_view = beta | ||
|
||
inrets_cython(congested_view, link_flows_view, capacity_view, fftime_view, alpha_view, beta_view, c) | ||
|
||
def delta_inrets(dbpr, link_flows, capacity, fftime, alpha, beta, cores): | ||
cdef int c = cores | ||
|
||
cdef double [:] dbpr_view = dbpr | ||
cdef double [:] link_flows_view = link_flows | ||
cdef double [:] capacity_view = capacity | ||
cdef double [:] fftime_view = fftime | ||
cdef double [:] alpha_view = alpha | ||
cdef double [:] beta_view = beta | ||
|
||
dinrets_cython(dbpr_view, link_flows_view, capacity_view, fftime_view, alpha_view, beta_view, c) | ||
|
||
@cython.wraparound(False) | ||
@cython.embedsignature(True) | ||
@cython.boundscheck(False) | ||
cpdef void inrets_cython(double[:] congested_time, | ||
double[:] link_flows, | ||
double [:] capacity, | ||
double [:] fftime, | ||
double[:] alpha, | ||
double [:] beta, | ||
int cores): | ||
cdef long long i | ||
cdef long long l = congested_time.shape[0] | ||
|
||
for i in prange(l, nogil=True, num_threads=cores): | ||
if link_flows[i] > 0: | ||
if link_flows[i] > capacity[i]: | ||
congested_time[i] = fftime[i] * ( | ||
(1.1 - alpha[i])/0.1) * ( | ||
pow(link_flows[i] / capacity[i],2) ) | ||
else: | ||
congested_time[i] = fftime[i] * ( | ||
1.1 - (alpha[i]*(link_flows[i] / capacity[i]))) / ( | ||
1.1 - (link_flows[i] / capacity[i]) ) | ||
else: | ||
congested_time[i] = fftime[i] | ||
|
||
@cython.wraparound(False) | ||
@cython.embedsignature(True) | ||
@cython.boundscheck(False) | ||
cpdef void dinrets_cython(double[:] deltaresult, | ||
double[:] link_flows, | ||
double [:] capacity, | ||
double [:] fftime, | ||
double[:] alpha, | ||
double [:] beta, | ||
int cores): | ||
cdef long long i | ||
cdef long long l = deltaresult.shape[0] | ||
|
||
for i in prange(l, nogil=True, num_threads=cores): | ||
if link_flows[i] > 0: | ||
if link_flows[i] > capacity[i]: | ||
deltaresult[i] = fftime[i] * ( | ||
(-20)*(alpha[i]-1.1)*link_flows[i]) / ( | ||
pow(capacity[i],2)) | ||
else: | ||
deltaresult[i] = fftime[i] * ( | ||
(-110)*(alpha[i]-1)*capacity[i]) / ( | ||
pow((11*capacity[i])-(10*link_flows[i]),2)) | ||
|
||
else: | ||
deltaresult[i] = fftime[i] |
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Oops, something went wrong.