63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
import numpy as np
|
|
import json
|
|
import matplotlib.pyplot as plt
|
|
|
|
colorList = json.load(open('color/config.json','r'))["color_pool"]
|
|
|
|
psgRange=np.arange(1e6,5e6,1e5)
|
|
|
|
prediction = 2433827
|
|
taxShift=0.03
|
|
torShift=1-0.054
|
|
curTaxationRate=1.0
|
|
temp1 = np.log(prediction/(torShift**(curTaxationRate/taxShift)))
|
|
temp2 = np.log(torShift)
|
|
def tax(x):
|
|
return taxShift*(np.log(x)-temp1)/temp2
|
|
def predictTotalPassengers(taxationRate):
|
|
return (prediction/(torShift**(curTaxationRate/taxShift)))*(torShift**(taxationRate/taxShift))
|
|
RNGk = 37.648854
|
|
RNGb = 59397421.185785
|
|
temp3=(curTaxationRate*(RNGk*(predictTotalPassengers(curTaxationRate))+RNGb))
|
|
def f1(x):
|
|
return 5*((tax(x))*(RNGk*x+RNGb) / temp3 -1)+1
|
|
|
|
C2=1
|
|
Cb2=1e8
|
|
def f2(x):
|
|
return 1 - C2*x/Cb2 - 0.2
|
|
|
|
C3=1
|
|
Cb3=4e8
|
|
def f3(x):
|
|
return 1 - C3*x/Cb3
|
|
|
|
influenceFactor = np.array([0.21061,0.54848,0.24091])
|
|
def f(x):
|
|
return f1(x)*influenceFactor[0] + f2(x)*influenceFactor[1] + f3(x)*influenceFactor[2]
|
|
|
|
|
|
from scipy.optimize import minimize_scalar
|
|
|
|
result = minimize_scalar(lambda x: -f(x),bounds=(np.min(psgRange),np.max(psgRange)),method='bounded')
|
|
print(result)
|
|
|
|
for i in range(10):
|
|
C3=i*5
|
|
plt.plot(psgRange,f(psgRange),label='result, C3=%d'%C3,color=colorList[i])
|
|
# plt.plot(psgRange,f1(psgRange),label='Ieco',color=colorList[1])
|
|
# plt.plot(psgRange,f2(psgRange),label='Ienv',color=colorList[2])
|
|
# plt.plot(psgRange,f3(psgRange),label='Isoc',color=colorList[3])
|
|
result = minimize_scalar(lambda x: -f(x),bounds=(np.min(psgRange),np.max(psgRange)),method='bounded')
|
|
plt.plot(result.x,f(result.x),'o',color=colorList[i])
|
|
print(result.x,tax(result.x),f(result.x))
|
|
|
|
plt.xlabel('total passengers')
|
|
plt.ylabel('Optimized objective function')
|
|
plt.legend(fontsize=8)
|
|
plt.savefig('result/O-ser1.png',dpi=1024,)
|
|
plt.show()
|
|
|
|
print("Optimal total passengers:",result.x)
|
|
print("Optimal taxation rate:",tax(result.x))
|
|
print("Score",f(result.x)) |