model1-version1-complete
This commit is contained in:
parent
e261b9e981
commit
fe228a1b93
13
AHPMethod.py
Normal file
13
AHPMethod.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from AHP import AHP
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
criteria=np.array([
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[]
|
||||||
|
])
|
||||||
|
|
||||||
|
max_eigen,CR,criteria_eigen=AHP(criteria,np.array([[0]])).cal_weights(criteria)
|
||||||
|
|
||||||
|
print()
|
||||||
|
print(max_eigen,CR,criteria_eigen)
|
||||||
25
get-nonrestrict-tourists.py
Normal file
25
get-nonrestrict-tourists.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import csv
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
data={}
|
||||||
|
with open('data/passenger.csv', 'r', encoding='utf-8') as f:
|
||||||
|
reader = csv.reader(f)
|
||||||
|
next(reader) # skip header row
|
||||||
|
for row in reader:
|
||||||
|
data[int(row[0])] = np.sum(np.array(row[1:4], dtype=int))
|
||||||
|
|
||||||
|
dataList = []
|
||||||
|
for i in range(2015,2020):
|
||||||
|
# print(data[i]/data[i-1])
|
||||||
|
dataList.append(data[i]/data[i-1])
|
||||||
|
# print(data[2023]/data[2022])
|
||||||
|
dataList.append(data[2023]/data[2022])
|
||||||
|
|
||||||
|
dataList = np.array(dataList)
|
||||||
|
avgGrowth = np.mean(dataList)
|
||||||
|
|
||||||
|
prediction = data[2023]*((avgGrowth)**(2025-2023))
|
||||||
|
print("predicting 2025 total passengers when maintaining current taxation rate:",prediction)
|
||||||
|
|
||||||
|
def predictTotalPassengers(taxationRate):
|
||||||
|
return (prediction/(0.946**(1.09/0.1)))*(0.946**(taxationRate/0.1))
|
||||||
@ -12,7 +12,7 @@ p2=25
|
|||||||
p3=25
|
p3=25
|
||||||
cp=500
|
cp=500
|
||||||
c=15
|
c=15
|
||||||
cmax=8000/0.2
|
cmax=400
|
||||||
cb=200
|
cb=200
|
||||||
m=0.01
|
m=0.01
|
||||||
r=0.85
|
r=0.85
|
||||||
@ -50,4 +50,10 @@ plt.xlabel('x')
|
|||||||
plt.ylabel('f(x)')
|
plt.ylabel('f(x)')
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.savefig('result/optimized1.png')
|
plt.savefig('result/optimized1.png')
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
from scipy.optimize import minimize
|
||||||
|
|
||||||
|
res = minimize(lambda x: -f(x), 0.2)
|
||||||
|
print(res)
|
||||||
|
print(res.x,f(res.x))
|
||||||
64
optimizerIeco.py
Normal file
64
optimizerIeco.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
import csv
|
||||||
|
import numpy as np
|
||||||
|
import json
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
colorList = json.load(open('color/config.json','r'))["color"]
|
||||||
|
|
||||||
|
data={}
|
||||||
|
with open('data/passenger.csv', 'r', encoding='utf-8') as f:
|
||||||
|
reader = csv.reader(f)
|
||||||
|
next(reader) # skip header row
|
||||||
|
for row in reader:
|
||||||
|
data[int(row[0])] = np.sum(np.array(row[1:4], dtype=int))
|
||||||
|
|
||||||
|
dataList = []
|
||||||
|
for i in range(2015,2020):
|
||||||
|
# print(data[i]/data[i-1])
|
||||||
|
dataList.append(data[i]/data[i-1])
|
||||||
|
# print(data[2023]/data[2022])
|
||||||
|
dataList.append(data[2023]/data[2022])
|
||||||
|
|
||||||
|
dataList = np.array(dataList)
|
||||||
|
avgGrowth = np.mean(dataList)
|
||||||
|
|
||||||
|
prediction = data[2023]*((avgGrowth)**(2025-2023))
|
||||||
|
print("predicting 2025 total passengers when maintaining current taxation rate:",prediction)
|
||||||
|
|
||||||
|
taxShift=0.03
|
||||||
|
torShift=1-0.054
|
||||||
|
curTaxationRate=1.0
|
||||||
|
|
||||||
|
def predictTotalPassengers(taxationRate):
|
||||||
|
return (prediction/(torShift**(curTaxationRate/taxShift)))*(torShift**(taxationRate/taxShift))
|
||||||
|
|
||||||
|
temp1 = np.log(prediction/(torShift**(curTaxationRate/taxShift)))
|
||||||
|
temp2 = np.log(torShift)
|
||||||
|
|
||||||
|
def tax(x):
|
||||||
|
return taxShift*(np.log(x)-temp1)/temp2
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
psgRange = predictTotalPassengers(np.arange(0.6,1.4,0.01))
|
||||||
|
|
||||||
|
|
||||||
|
from scipy.optimize import minimize_scalar
|
||||||
|
|
||||||
|
result = minimize_scalar(lambda x: -f1(x),bounds=(np.min(psgRange),np.max(psgRange)),method='bounded')
|
||||||
|
print(result)
|
||||||
|
|
||||||
|
plt.plot(psgRange,f1(psgRange),label='Ieco',color=colorList[0])
|
||||||
|
plt.plot(psgRange,tax(psgRange),label='tax(x)',color=colorList[1])
|
||||||
|
plt.xlabel('total passengers')
|
||||||
|
plt.ylabel('Ieco / taxation rate')
|
||||||
|
plt.plot(predictTotalPassengers(1),1,'o',label='maintain taxation rate',color=colorList[2])
|
||||||
|
plt.plot(result.x,f1(result.x),'o',label='optimal for Ieco',color=colorList[3])
|
||||||
|
plt.legend()
|
||||||
|
plt.savefig('result/taxation-and-f1.png')
|
||||||
|
plt.show()
|
||||||
19
optimizerIenv.py
Normal file
19
optimizerIenv.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
C=1
|
||||||
|
Cb=1e7
|
||||||
|
|
||||||
|
def f2(x):
|
||||||
|
return 1 - C*x/Cb
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import json
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
colorList = json.load(open('color/config.json','r'))["color"]
|
||||||
|
|
||||||
|
plt.plot(np.arange(1e6,5e6,1e5),f2(np.arange(1e6,5e6,1e5)),label='Ienv',color=colorList[0])
|
||||||
|
plt.xlabel('total passengers')
|
||||||
|
plt.ylabel('Ienv')
|
||||||
|
plt.legend()
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
19
optimizerIsoc.py
Normal file
19
optimizerIsoc.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
C=1
|
||||||
|
Cb=1e7
|
||||||
|
|
||||||
|
def f3(x):
|
||||||
|
return 1 - C*x/Cb
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import json
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
colorList = json.load(open('color/config.json','r'))["color"]
|
||||||
|
|
||||||
|
plt.plot(np.arange(1e6,5e6,1e5),f3(np.arange(1e6,5e6,1e5)),label='Isoc',color=colorList[0])
|
||||||
|
plt.xlabel('total passengers')
|
||||||
|
plt.ylabel('Isoc')
|
||||||
|
plt.legend()
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
59
optimizerO.py
Normal file
59
optimizerO.py
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import numpy as np
|
||||||
|
import json
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
colorList = json.load(open('color/config.json','r'))["color"]
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
plt.plot(psgRange,f(psgRange),label='result',color=colorList[0])
|
||||||
|
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])
|
||||||
|
plt.plot(result.x,f(result.x),'o',label='optimal',color=colorList[4])
|
||||||
|
|
||||||
|
plt.xlabel('total passengers')
|
||||||
|
plt.ylabel('Optimized objective function')
|
||||||
|
plt.legend()
|
||||||
|
plt.savefig('result/O.png')
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
print("Optimal total passengers:",result.x)
|
||||||
|
print("Optimal taxation rate:",tax(result.x))
|
||||||
|
print("Score",f(result.x))
|
||||||
47
passenger-and-locals-relation.py
Normal file
47
passenger-and-locals-relation.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import json
|
||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
colorList = json.load(open('color/config.json','r'))["color"]
|
||||||
|
|
||||||
|
import csv
|
||||||
|
|
||||||
|
data_pasg = {}
|
||||||
|
data_temp = {}
|
||||||
|
|
||||||
|
with open('data/passenger.csv', 'r') as f:
|
||||||
|
reader = csv.reader(f)
|
||||||
|
header = next(reader)
|
||||||
|
data = [row for row in reader]
|
||||||
|
|
||||||
|
data = np.array(data).astype(float).T
|
||||||
|
data[0]=data[0].astype(int)
|
||||||
|
|
||||||
|
xList=data[1]+data[2]+data[3]
|
||||||
|
yList=np.full(np.shape(data[6])[0],0)
|
||||||
|
for i in range(1,np.shape(data[6])[0]):
|
||||||
|
yList[i]=data[6][i]-data[6][i-1]
|
||||||
|
|
||||||
|
|
||||||
|
print(yList)
|
||||||
|
|
||||||
|
plt.scatter(xList[1:],yList[1:],color=colorList[0])
|
||||||
|
|
||||||
|
from scipy.optimize import curve_fit
|
||||||
|
def linear(x,k,b):
|
||||||
|
return k*x+b
|
||||||
|
valk,valb = curve_fit(linear,xList,yList)[0]
|
||||||
|
residuals = yList - linear(xList,valk,valb)
|
||||||
|
ss_res = np.sum(residuals**2)
|
||||||
|
ss_tot = np.sum((yList-np.mean(yList))**2)
|
||||||
|
r_squared = 1 - (ss_res / ss_tot)
|
||||||
|
print("R-squared:", r_squared)
|
||||||
|
|
||||||
|
plt.plot(np.arange(0,2.5e6,1e5),linear(np.arange(0,2.5e6,1e5),valk,valb),color=colorList[1])
|
||||||
|
|
||||||
|
plt.xlabel('Passenger')
|
||||||
|
plt.ylabel('Local Population Decline')
|
||||||
|
plt.title('Relation between Passenger and Local Population Decline')
|
||||||
|
plt.text( 60000, 110, "k = %f\nb = %f\nR^2 = %f"%(valk,valb,r_squared),color=colorList[1])
|
||||||
|
plt.savefig('result/passenger-and-locals-relation.png')
|
||||||
|
plt.show()
|
||||||
@ -42,5 +42,5 @@ plt.xlabel('Total Passengers')
|
|||||||
plt.ylabel('Total Revenue')
|
plt.ylabel('Total Revenue')
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.title('Passenger-Revenue Relation')
|
plt.title('Passenger-Revenue Relation')
|
||||||
plt.savefig('result/passenger-and-revenue-relation.png')
|
plt.savefig('result/passenger-and-revenue-relation.png',dpi=1024)
|
||||||
plt.show()
|
plt.show()
|
||||||
@ -30,5 +30,5 @@ ax2.plot(data[0],data[5], label=header[5], color=colorList[4])
|
|||||||
ax2.set_ylabel('Revenue')
|
ax2.set_ylabel('Revenue')
|
||||||
plt.legend(loc='upper right')
|
plt.legend(loc='upper right')
|
||||||
plt.title('Passenger and Revenue Yearly')
|
plt.title('Passenger and Revenue Yearly')
|
||||||
plt.savefig('result/passenger-and-revenue.png')
|
plt.savefig('result/passenger-and-revenue.png',dpi=1024)
|
||||||
plt.show()
|
plt.show()
|
||||||
Reference in New Issue
Block a user