代码拉取完成,页面将自动刷新
#%%
#coding:utf-8
# get od accessibility
import os,sys
sys.path.append(os.getcwd())
del os,sys
import pandas as pd
import numpy as np
from singue.bpr import bpr
from netop.epm_to_csr import epm_to_csr
#%% def cell
def od_acc(ueFlow,freeTime,capacity,epm,demand):
'''odAcc=od_acc(ueFlow,freeTime,capacity,epm,demand)
'''
if epm.shape[0]==1: # epm is []-like
odAcc=0
elif epm.shape[1]==0: # no path
odAcc=0
else:
cost=bpr(ueFlow,freeTime,capacity)
epmDense=epm.toarray()
pathCost=epmDense.T.dot(cost)
pathLn=np.log(pathCost)
pathProb=pathLn/np.sum(pathLn)
pathFlow=demand*pathProb
odAcc=demand/np.sum(pathFlow*pathCost)
return odAcc
#%% test cell
if __name__=='__main__':
# load data
ueflowfile=r'D:\Jobsplay\MyPython\netset\CQYuZhong\case8k\ueFlowRec_json.bz2'
ueFlowRec=pd.read_json(ueflowfile,orient='split')
edgefile=r'D:\Jobsplay\MyPython\netset\CQYuZhong\case8k\assi_edgesDf_json.bz2'
edgeDf=pd.read_json(edgefile,orient='split')
odfile=r'D:\Jobsplay\MyPython\netset\CQYuZhong\case8k\assi_odsDf8k_json.bz2'
odsDf=pd.read_json(odfile,orient='split')
# prep data
ueFlow=np.array(ueFlowRec['fineNet'])
freeTime=np.array(edgeDf['freeTime'])
capacity=np.array(edgeDf['capacity'])
epmDct=odsDf.loc[0,'epmDct']
epm=epm_to_csr(epmDct)
demand=odsDf.loc[0,'demand']
# def cell
odAcc=od_acc(ueFlow,freeTime,capacity,epm, demand)
# cost=bpr(ueFlow,freeTime,capacity)
# epmDense=epm.toarray()
# pathCost=epmDense.T.dot(cost)
# pathLn=np.log(pathCost)
# pathProb=pathLn/np.sum(pathLn)
# pathFlow=demand*pathProb
# odAcc=demand/np.sum(pathFlow*pathCost)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。