-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.py
195 lines (175 loc) · 5.53 KB
/
functions.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# @file : functions.py
# @created : 18-Nov-2019
#
"""
"""
# Functions to deal and handle the list of items
# import importlib
# import item
# importlib.reload(item)
from src.crops import *
from src.animal_food import *
from src.animals import *
from src.honey_extractor import *
from src.fish import *
from src.duck_salon import *
from src.sugar_mill import *
from src.dairy import *
from src.bakery import *
from src.popcorn_pot import *
from src.sauce_maker import *
from src.bbq_grill import *
from src.pie_oven import *
from src.loom import *
from src.sewing_machine import *
from src.mine import *
from src.pie_oven import *
from src.cake_oven import *
from src.smelter import *
from src.juice_press import *
from src.jam_maker import *
from src.jeweler import *
from src.candy_machine import *
from src.coffee_kiosk import *
from src.ice_cream_maker import *
from src.pasta_maker import *
from src.soup_kitchen import *
from src.candle_maker import *
from src.flower_shop import *
from src.sushi_bar import *
from src.salad_bar import *
from src.sandwich_bar import *
from src.smoothie_mixer import *
from src.smoothie_mixer import *
from src.smoothie_mixer import *
from src.smoothie_mixer import *
from src.smoothie_mixer import *
from src.smoothie_mixer import *
from src.wok_kitchen import *
from src.hat_maker import *
from src.pasta_kitchen import *
from src.hot_dog_stand import *
from src.donut_maker import *
from src.taco_kitchen import *
from src.tea_stand import *
from src.fondue_pot import *
from src.bath_kiosk import *
from src.deep_fryer import *
from src.preservation_station import *
from src.fudge_shop import *
from src.yogurt_maker import *
from src.stew_pot import *
from src.cupcake_maker import *
from src.waffle_maker import *
from src.omelet_station import *
from src.porridge_bar import *
from src.pottery_studio import *
from src.milkshake_bar import *
from src.essential_oils_lab import *
from src.perfumerie import *
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
print('# of item in list_items {:2d}'.format(len(list_items)))
def list_places():
places = []
for item in list_items:
places.append(item.production_place)
unique_places = set(places)
return unique_places
def list_products_at(place):
items = []
number = 1
for item in list_items:
if place == item.production_place:
items.append(item)
return items
def plot_time_vs_profit_at(place):
time_and_profit_df = pd.DataFrame(
columns=['production_time', 'profit', 'item_name', 'price_sell']
)
number = 1
for item in list_items:
if place == item.production_place:
print(
'{:d} ---> {:20s} {:20f} {:20f}'.format(
number,
item.name,
item.get_production_time(),
item.get_profit(),
)
)
time_and_profit_df = time_and_profit_df.append(
{
'production_time': item.get_production_time(),
'profit': item.get_profit(),
'item_name': item.name,
'price_sell': item.price_sell,
'profit_per_hour': item.get_profit()
/ item.get_production_time(),
'prod_cost': item.get_production_price(),
},
ignore_index=True,
)
number += 1
# plt.plot(arr_time_and_profit[:, 0], arr_time_and_profit[:, 1], 'bo', markersize=5)
# plt.scatter(arr_time_and_profit[:, 0], arr_time_and_profit[:, 1])
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(15, 10))
axis = ax.scatter(
time_and_profit_df['prod_cost'],
time_and_profit_df['profit'],
c=time_and_profit_df['production_time'],
cmap='viridis',
)
cmap = fig.colorbar(axis, ax=ax)
cmap.set_label('production time (h)')
# Label each point in scatter plot
for index, row in time_and_profit_df.iterrows():
ax.annotate(
'{:s} \n {:.2f}'.format(row['item_name'], row['profit_per_hour']),
xy=(row['prod_cost'], row['profit']), # Label's position
xytext=(0, 10),
textcoords='offset points', # Label offset from the plotted point
ha='center', # alignment
va='bottom',
)
ax.set_title(place, color='blue')
ax.set_xlabel('production cost')
ax.set_ylabel('Profit')
return fig
# plt.show()
def generate_df():
df_items = pd.DataFrame(
columns=[
'production_time',
'profit',
'item_name',
'price_sell',
'profit_per_hour',
'prod_cost',
'place',
]
)
for item in list_items:
tmp_df = pd.DataFrame.from_records(
[
{
'production_time': item.get_production_time(),
'profit': item.get_profit(),
'item_name': item.name,
'price_sell': item.price_sell,
'profit_per_hour': item.get_profit()
/ item.get_production_time(),
'prod_cost': item.get_production_price(),
'place': item.production_place,
}
]
)
df_items = pd.concat([df_items, tmp_df], ignore_index=True)
return df_items
def get_object(name):
for item in list_items:
if item.name == name:
return item