Spaces:
Sleeping
Sleeping
arnikdehnavi
commited on
Commit
•
5637c56
1
Parent(s):
88abea4
Update app.py
Browse files
app.py
CHANGED
@@ -1,47 +1,82 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
import
|
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 |
-
|
|
|
1 |
+
import joblib
|
2 |
import streamlit as st
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
import pandas as pd
|
5 |
+
import plotly.express as px
|
6 |
+
import numpy as np
|
7 |
+
from geneticalgorithm import geneticalgorithm as ga
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
st.title('Indoor temperature')
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
model=joblib.load('temperature.json')
|
17 |
+
st.sidebar.title('Inputs:')
|
18 |
+
st.sidebar.header('Dimention')
|
19 |
+
|
20 |
+
i1=st.sidebar.slider('Outdoor wind speed',value=10,min_value=1,max_value=20)
|
21 |
+
i2=st.sidebar.slider('Outdoor wind direction',value=24)
|
22 |
+
i3=st.sidebar.slider('Radiation')
|
23 |
+
i4=st.sidebar.slider( 'Humidity',value=10)
|
24 |
+
i5=st.sidebar.slider('Outdoor Drybulb temperature',value=10)
|
25 |
+
i6=st.sidebar.radio('Window opening1',[0,1])
|
26 |
+
i7=st.sidebar.radio('Window opening2',[0,1])
|
27 |
+
i8=st.sidebar.slider('luminance',value=10)
|
28 |
+
i9=st.sidebar.slider('T',value=10)
|
29 |
+
st.sidebar.markdown("gas=1,propain=2,wood=3")
|
30 |
+
i10=st.sidebar.selectbox("f_t1",[1,2,3])
|
31 |
+
if i10=="gas":
|
32 |
+
i10=1
|
33 |
+
elif i10=="propain":
|
34 |
+
i10=2
|
35 |
+
elif i10=="wood":
|
36 |
+
i10=3
|
37 |
+
elif i10=="electricity":
|
38 |
+
i10=5
|
39 |
+
else:
|
40 |
+
i10=4
|
41 |
+
st.header(i10)
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
p=model.predict([[i1,i2,i3,i4,i5,i6,i7,i8,i9]])
|
48 |
+
|
49 |
+
output=[p[0][0],p[0][1],p[0][2]]
|
50 |
+
|
51 |
+
st.write(output)
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
|
56 |
+
df=pd.DataFrame(output,columns=['Temperature'],index=['15th','30th','45th'])
|
57 |
+
plot=pd.DataFrame({'Time':[15,30,45],'T':output})
|
58 |
+
#graph
|
59 |
+
fig=px.line(plot,x='Time',y='T')
|
60 |
+
|
61 |
+
st.plotly_chart(fig)
|
62 |
+
st.write(df)
|
63 |
+
|
64 |
+
|
65 |
+
#optimization
|
66 |
+
def f(X):
|
67 |
+
t= abs(22.5 - model.predict([[i1,i2,i3,i4,i5,X[0],X[1],i8,i9]])[0][0])
|
68 |
|
69 |
+
return t
|
70 |
+
|
71 |
+
|
72 |
+
button1=st.button('TAP to Suggestion!!')
|
73 |
+
if button1:
|
74 |
+
varbound=np.array([[0,1]]*2)
|
75 |
+
with st.spinner('Wait for optimizing ...'):
|
76 |
+
optimization=ga(function=f,dimension=2,variable_type='int',variable_boundaries=varbound)
|
77 |
+
optimization.run()
|
78 |
+
st.write ('for next 15th minutes to reach thermal comfort Opening situation of the first window is '+str(optimization.best_variable[0])+' and Opening situation of the second window is '+str(optimization.best_variable[1]))
|
79 |
+
r="optimized indoor temperature {}".format(round(model.predict([[i1,i2,i3,i4,i5,optimization.best_variable[0],optimization.best_variable[1],i8,i9]])[0][0],1))
|
80 |
+
st.success(r)
|
81 |
+
|
82 |
+
|