arnikdehnavi commited on
Commit
5637c56
1 Parent(s): 88abea4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +80 -45
app.py CHANGED
@@ -1,47 +1,82 @@
 
1
  import streamlit as st
2
- from OpenGL.GL import *
3
- from OpenGL.GLU import *
4
- from PyQt5.QtWidgets import QApplication
5
- import sys
6
-
7
- class Cube:
8
- def __init__(self):
9
- self.vertices = ((1.0,-1,-1),(1,1,-1),(-1,1,-1),(-1,-1,-1),(1,-1,1),(1,1,1),(-1,-1,1),(-1,1,1))
10
- self.edges = ((0,1),(0,3),(0,4),(1,2),(1,5),(2,3),(2,6),(3,7),(4,5),(4,7),(5,6),(6,7))
11
-
12
- def draw(self):
13
- glBegin(GL_LINES)
14
- for edge in self.edges:
15
- for vertex in edge:
16
- glVertex3fv(self.vertices[vertex])
17
- glEnd()
18
-
19
- def main():
20
- app = QApplication(sys.argv)
21
- cube = Cube()
22
-
23
- st.set_option('dephrecation.showPyplotGlobalUse', False)
24
- st.title("3D Cube")
25
-
26
- # Create an OpenGL context
27
- gl_viewport = st_gl(GLsizei(st._get_metric_impl("devicePixelRatio") * 600), GLsizei(st._get_metric_impl("devicePixelRatio") * 600))
28
- st_gl_make_current(gl_viewport)
29
-
30
- # Set up projection
31
- gluPerspective(45, 1, 0.1, 50.0)
32
- glTranslatef(0.0, 0.0, -5.0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
- # Draw the cube
35
- glEnable(GL_DEPTH_TEST)
36
- while True:
37
- for event in QApplication.instance().flushEvents():
38
- if event.type() == QEvent.Close:
39
- sys.exit()
40
-
41
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
42
- cube.draw()
43
- glRotatef(1, 1, 1, 1)
44
- st_gl_swap(gl_viewport)
45
-
46
- if __name__ == '__main__':
47
- main()
 
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
+