import joblib import streamlit as st import matplotlib.pyplot as plt import pandas as pd import plotly.express as px import numpy as np from geneticalgorithm import geneticalgorithm as ga st.title('Indoor temperature') model=joblib.load('temperature.json') st.sidebar.title('Inputs:') st.sidebar.header('Dimention') i1=st.sidebar.slider('Outdoor wind speed',value=10,min_value=1,max_value=20) i2=st.sidebar.slider('Outdoor wind direction',value=24) i3=st.sidebar.slider('Radiation') i4=st.sidebar.slider( 'Humidity',value=10) i5=st.sidebar.slider('Outdoor Drybulb temperature',value=10) i6=st.sidebar.radio('Window opening1',[0,1]) i7=st.sidebar.radio('Window opening2',[0,1]) i8=st.sidebar.slider('luminance',value=10) i9=st.sidebar.slider('T',value=10) st.sidebar.markdown("gas=1,propain=2,wood=3") i10=st.sidebar.selectbox("f_t1",[1,2,3]) if i10=="gas": i10=1 elif i10=="propain": i10=2 elif i10=="wood": i10=3 elif i10=="electricity": i10=5 else: i10=4 st.header(i10) p=model.predict([[i1,i2,i3,i4,i5,i6,i7,i8,i9]]) output=[p[0][0],p[0][1],p[0][2]] st.write(output) df=pd.DataFrame(output,columns=['Temperature'],index=['15th','30th','45th']) plot=pd.DataFrame({'Time':[15,30,45],'T':output}) #graph fig=px.line(plot,x='Time',y='T') st.plotly_chart(fig) st.write(df) #optimization def f(X): t= abs(22.5 - model.predict([[i1,i2,i3,i4,i5,X[0],X[1],i8,i9]])[0][0]) return t button1=st.button('TAP to Suggestion!!') if button1: varbound=np.array([[0,1]]*2) with st.spinner('Wait for optimizing ...'): optimization=ga(function=f,dimension=2,variable_type='int',variable_boundaries=varbound) optimization.run() 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])) 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)) st.success(r)