-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunStochastic.py
101 lines (62 loc) · 1.81 KB
/
runStochastic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import numpy as np;
import matplotlib.pyplot as plt;
from numpy.linalg import matrix_power;
from init.transitionMatrix import MATRIX;
from init.rents import RENTS, rents;
from init.colors import colors;
from init.costs import COSTS;
_positions = [0] * 40 * 3
_positions[0] = 1
POSITIONS = np.row_stack(_positions)
def projectRevenue(n):
history = []
total = COSTS / 3
propertyIndices = np.nonzero(np.array(rents * 3))
for t in range(n):
revenue = RENTS * matrix_power(MATRIX,t + 1) * POSITIONS
temp = total = total + revenue
summary = total.reshape(-1)
toArray = summary.tolist()[0]
filtered = np.array(toArray)[propertyIndices]
history.append(filtered)
history = np.matrix(history)
transposed = np.transpose(history)
return transposed
def mergeProfit(results):
results = np.asarray(results)
length = len(results) // 3
part1 = results[:length]
part2 = results[length:2 * length]
part3 = results[2 * length:]
merged = part1 + part2 + part3
brown = sum(merged[:2])
skyblue = sum(merged[2:5])
pink = sum(merged[5:8])
orange = sum(merged[8:11])
red = sum(merged[11:14])
yellow = sum(merged[14:17])
green = sum(merged[17:20])
blue = sum(merged[20:22])
summary = [
brown,
skyblue,
pink,
orange,
red,
yellow,
green,
blue
]
return np.matrix(summary)
def plotResults(results):
results = np.asarray(results)
#print(results)
turns = np.arange(1,250 + 1)
index = 0
for res in results:
plt.plot(turns,res, color = colors[index])
index += 1
plt.show()
results = projectRevenue(250)
results = mergeProfit(results)
plotResults(results)