Spaces:
Runtime error
Runtime error
import streamlit as st | |
import plotly.graph_objects as go | |
import skfuzzy as fuzz | |
from skfuzzy import control as crt | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib as ml | |
import streamlit as st | |
import math | |
from mpl_toolkits.mplot3d import Axes3D | |
import streamlit as st | |
st.title('Schematic Design !') | |
tanasobat=crt.Antecedent(np.arange(0,3.05,0.05),'c') | |
jahat=crt.Antecedent(np.arange(0,25.1,0.1),'a') | |
jerm_hararati=crt.Antecedent(np.arange(0,4185.1,0.1),'b') | |
feshordegi=crt.Antecedent(np.arange(0,1,0.01),'d') | |
ertefa=crt.Antecedent(np.arange(2.3,10.001,0.001),'e') | |
WWR=crt.Antecedent(np.arange(0,1.001,0.001),'f') | |
emtiaz_HH=crt.Consequent(np.arange(-4,24.01,0.01),'score') | |
g1=st.sidebar.radio('climate',['hot and humid','hot and dry','cold','moderate and humid']) | |
jahat['low']=fuzz.trimf(jahat.universe,[0,5,12]) | |
jahat['medium']=fuzz.trimf(jahat.universe,[5,12,17.5]) | |
jahat['re_hight']=fuzz.trimf(jahat.universe,[12,17.5,25]) | |
jahat['high']=fuzz.trimf(jahat.universe,[17.5,25,25]) | |
jerm_hararati['low']=fuzz.trapmf(jerm_hararati.universe,[0,0,1500,1600]) | |
jerm_hararati['medium']=fuzz.trapmf(jerm_hararati.universe,[1500,2000,3000,3500]) | |
jerm_hararati['high']=fuzz.trapmf(jerm_hararati.universe,[3000,3500,4185,4185]) | |
tanasobat['low']=fuzz.trapmf(tanasobat.universe,[0,1.1,1.3,1.4]) | |
tanasobat['medium']=fuzz.trapmf(tanasobat.universe,[1.2,1.4,1.6,1.7]) | |
tanasobat['high']=fuzz.trapmf(tanasobat.universe,[1.6,1.7,3,3]) | |
feshordegi['low']=fuzz.trapmf(feshordegi.universe,[0,0.2,0.5,0.6]) | |
feshordegi['medium']=fuzz.trapmf(feshordegi.universe,[0.5,0.6,0.8,0.85]) | |
feshordegi['high']=fuzz.trapmf(feshordegi.universe,[0.8,0.85,1,1]) | |
ertefa['low']=fuzz.gbellmf(ertefa.universe,0.3,6,2.4) | |
ertefa['medium']=fuzz.gbellmf(ertefa.universe,0.2,6,3) | |
ertefa['high']=fuzz.smf(ertefa.universe,3.2,3.6) | |
WWR['low']=fuzz.gbellmf(WWR.universe,0.05,4,0.15) | |
#WWR['medium']=fuzz.gbellmf(WWR.universe,0.05,6,0.25) | |
WWR['RE_high']=fuzz.gbellmf(WWR.universe,0.05,4,0.30) | |
WWR['high']=fuzz.smf(WWR.universe,0.35,0.45) | |
emtiaz_HH['awful']=fuzz.gaussmf(emtiaz_HH.universe,0,1) | |
emtiaz_HH['bad']=fuzz.gaussmf(emtiaz_HH.universe,4,1) | |
emtiaz_HH['not_bad']=fuzz.gaussmf(emtiaz_HH.universe,8,1) | |
emtiaz_HH['good']=fuzz.gaussmf(emtiaz_HH.universe,12,1) | |
emtiaz_HH['very_good']=fuzz.gaussmf(emtiaz_HH.universe,16,1) | |
emtiaz_HH['excelent']=fuzz.gaussmf(emtiaz_HH.universe,20,1) | |
r1=crt.Rule(jahat['low']&jerm_hararati['low']&tanasobat['high']&feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['excelent']) | |
r2=crt.Rule(~jahat['low']&jerm_hararati['low']&tanasobat['high']&feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['very_good']) | |
r3=crt.Rule(jahat['low']&~jerm_hararati['low']&tanasobat['high']&feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['very_good']) | |
r4=crt.Rule(jahat['low']&jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['very_good']) | |
r5=crt.Rule(jahat['low']&jerm_hararati['low']&tanasobat['high']&~feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['very_good']) | |
r6=crt.Rule(jahat['low']&jerm_hararati['low']&tanasobat['high']&feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['very_good']) | |
r7=crt.Rule(jahat['low']&jerm_hararati['low']&tanasobat['high']&feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['very_good']) | |
r8=crt.Rule(~jahat['low']&~jerm_hararati['low']&tanasobat['high']&feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['good']) | |
r9=crt.Rule(~jahat['low']&jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['good']) | |
r10=crt.Rule(~jahat['low']&jerm_hararati['low']&tanasobat['high']&~feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['good']) | |
r11=crt.Rule(~jahat['low']&jerm_hararati['low']&tanasobat['high']&feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['good']) | |
r12=crt.Rule(~jahat['low']&jerm_hararati['low']&tanasobat['high']&feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['good']) | |
r13=crt.Rule(jahat['low']&~jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['good']) | |
r14=crt.Rule(jahat['low']&~jerm_hararati['low']&tanasobat['high']&~feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['good']) | |
r15=crt.Rule(jahat['low']&~jerm_hararati['low']&tanasobat['high']&feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['good']) | |
r16=crt.Rule(jahat['low']&~jerm_hararati['low']&tanasobat['high']&feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['good']) | |
r17=crt.Rule(jahat['low']&jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['good']) | |
r18=crt.Rule(jahat['low']&jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['good']) | |
r19=crt.Rule(jahat['low']&jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['good']) | |
r20=crt.Rule(jahat['low']&jerm_hararati['low']&tanasobat['high']&~feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['good']) | |
r21=crt.Rule(jahat['low']&jerm_hararati['low']&tanasobat['high']&~feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['good']) | |
r22=crt.Rule(jahat['low']&jerm_hararati['low']&tanasobat['high']&feshordegi['low']&~ertefa['high']&~WWR['RE_high'],emtiaz_HH['good']) | |
r23=crt.Rule(~jahat['low']&~jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['not_bad']) | |
r24=crt.Rule(~jahat['low']&~jerm_hararati['low']&tanasobat['high']&~feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['not_bad']) | |
r25=crt.Rule(~jahat['low']&~jerm_hararati['low']&tanasobat['high']&feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['not_bad']) | |
r26=crt.Rule(~jahat['low']&~jerm_hararati['low']&tanasobat['high']&feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['not_bad']) | |
r27=crt.Rule(~jahat['low']&jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['not_bad']) | |
r28=crt.Rule(~jahat['low']&jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['not_bad']) | |
r29=crt.Rule(~jahat['low']&jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['not_bad']) | |
r30=crt.Rule(~jahat['low']&jerm_hararati['low']&tanasobat['high']&~feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['not_bad']) | |
r31=crt.Rule(~jahat['low']&jerm_hararati['low']&tanasobat['high']&~feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['not_bad']) | |
r32=crt.Rule(~jahat['low']&jerm_hararati['low']&tanasobat['high']&feshordegi['low']&~ertefa['high']&~WWR['RE_high'],emtiaz_HH['not_bad']) | |
r33=crt.Rule(jahat['low']&~jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['not_bad']) | |
r34=crt.Rule(jahat['low']&~jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['not_bad']) | |
r35=crt.Rule(jahat['low']&~jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['not_bad']) | |
r36=crt.Rule(jahat['low']&~jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['not_bad']) | |
r37=crt.Rule(jahat['low']&jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['not_bad']) | |
r38=crt.Rule(jahat['low']&jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['not_bad']) | |
r39=crt.Rule(jahat['low']&jerm_hararati['low']&tanasobat['high']&~feshordegi['low']&~ertefa['high']&~WWR['RE_high'],emtiaz_HH['not_bad']) | |
r40=crt.Rule(~jahat['low']&~jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&ertefa['high']&WWR['RE_high'],emtiaz_HH['bad']) | |
r41=crt.Rule(~jahat['low']&~jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['bad']) | |
r42=crt.Rule(~jahat['low']&~jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['bad']) | |
r43=crt.Rule(~jahat['low']&~jerm_hararati['low']&tanasobat['high']&~feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['bad']) | |
r44=crt.Rule(~jahat['low']&~jerm_hararati['low']&tanasobat['high']&~feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['bad']) | |
r45=crt.Rule(~jahat['low']&~jerm_hararati['low']&tanasobat['high']&feshordegi['low']&~ertefa['high']&~WWR['RE_high'],emtiaz_HH['bad']) | |
r46=crt.Rule(~jahat['low']&jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['bad']) | |
r47=crt.Rule(~jahat['low']&jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['bad']) | |
r48=crt.Rule(~jahat['low']&jerm_hararati['low']&tanasobat['high']&~feshordegi['low']&~ertefa['high']&~WWR['RE_high'],emtiaz_HH['bad']) | |
r49=crt.Rule(jahat['low']&~jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['bad']) | |
r50=crt.Rule(jahat['low']&~jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['bad']) | |
r51=crt.Rule(jahat['low']&~jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&~ertefa['high']&~WWR['RE_high'],emtiaz_HH['bad']) | |
r52=crt.Rule(jahat['low']&~jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&~ertefa['high']&~WWR['RE_high'],emtiaz_HH['bad']) | |
r53=crt.Rule(jahat['low']&jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&~ertefa['high']&~WWR['RE_high'],emtiaz_HH['bad']) | |
r53=crt.Rule(jahat['low']&~jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&~ertefa['high']&~WWR['RE_high'],emtiaz_HH['awful']) | |
r54=crt.Rule(~jahat['low']&jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&~ertefa['high']&~WWR['RE_high'],emtiaz_HH['awful']) | |
r55=crt.Rule(~jahat['low']&~jerm_hararati['low']&tanasobat['high']&~feshordegi['low']&~ertefa['high']&~WWR['RE_high'],emtiaz_HH['awful']) | |
r56=crt.Rule(~jahat['low']&~jerm_hararati['low']&~tanasobat['high']&feshordegi['low']&~ertefa['high']&~WWR['RE_high'],emtiaz_HH['awful']) | |
r57=crt.Rule(~jahat['low']&~jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&ertefa['high']&~WWR['RE_high'],emtiaz_HH['awful']) | |
r58=crt.Rule(~jahat['low']&~jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&~ertefa['high']&WWR['RE_high'],emtiaz_HH['awful']) | |
r59=crt.Rule(~jahat['low']&~jerm_hararati['low']&~tanasobat['high']&~feshordegi['low']&~ertefa['high']&~WWR['RE_high'],emtiaz_HH['awful']) | |
cs=crt.ControlSystem([r1, | |
r2, | |
r3, | |
r4, | |
r5, | |
r6, | |
r7, | |
r8, | |
r9, | |
r10, | |
r11, | |
r12, | |
r13, | |
r14, | |
r15, | |
r16, | |
r17, | |
r18, | |
r19, | |
r20, | |
r21, | |
r22, | |
r23, | |
r24, | |
r25, | |
r26, | |
r27, | |
r28, | |
r29, | |
r30, | |
r31, | |
r32, | |
r33, | |
r34, | |
r35, | |
r36, | |
r37, | |
r38, | |
r39, | |
r40, | |
r41, | |
r42, | |
r43, | |
r44, | |
r45, | |
r46, | |
r47, | |
r48, | |
r49, | |
r50, | |
r51, | |
r52, | |
r53,r54,r55,r56,r57,r58,r59]) | |
cs1=crt.ControlSystemSimulation(cs) | |
width=st.sidebar.slider("width",min_value=1,max_value=10,step=1,value=5) | |
length=st.sidebar.slider("length",min_value=1,max_value=10,step=1,value=8) | |
c1=cs1.input['c']=length/width | |
a1=cs1.input['a']=st.sidebar.slider("jahat",min_value=0.00,max_value=40.00,step=0.1,value=0.0) | |
b1=cs1.input['b']=st.sidebar.slider("jerm_hararati",min_value=0.00,max_value=4180.00,step=0.1,value=0.0) | |
d1=cs1.input['d']=st.sidebar.slider("feshordegi",min_value=0.00,max_value=1.0,step=0.01,value=0.1) | |
e1=cs1.input['e']=st.sidebar.slider("ertefa",min_value=2.3,max_value=5.00,step=0.01,value=3.31) | |
height=e1 | |
f1=cs1.input['f']=st.sidebar.slider("wwr",min_value=0,max_value=100,step=5,value=50) | |
wwr= ((f1 - 1) / 99) * 50 + 50 | |
cs1.compute() | |
g11=cs1.output['score'] | |
g11=round(g11) | |
# Create axis | |
st.metric(label="your fuzzy score", value=g11) | |
#st.set_option('deprecation.showPyplotGlobalUse', False) | |
#st.pyplot() | |
#Create sliders to adjust the dimensions | |
# Use Plotly to create a 3D cube with the adjusted dimensions | |
fig = go.Figure(data=[ | |
# Main body of the cube | |
go.Mesh3d(x=[0, width, width, 0, 0, width, width, 0], | |
y=[0, 0, length, length, 0, 0, length, length], | |
z=[0, 0, 0, 0, height, height, height, height], | |
alphahull=0, | |
color='#F5DEB3', | |
opacity=1, | |
lighting=dict(ambient=0.5, diffuse=0.9, roughness=0.1, specular=0.2, fresnel=0.2), | |
flatshading=True, | |
hoverinfo='none'), | |
# Window surface | |
go.Mesh3d(x=[width+0.05,width+0.05,width+0.05,width+0.05], | |
y=[length*(wwr/100), length*(wwr/100), length*(1-wwr/100), length*(1-wwr/100) ], | |
z=[height*(wwr/100), height*(1-wwr/100), height*(1-wwr/100), height*(wwr/100)], | |
i=[2, 3, 0, 1, 0, 3], | |
j=[1, 2, 3, 3, 2, 0], | |
k=[0, 1, 2, 0, 2, 3], | |
color='skyblue', | |
opacity=1, | |
lighting=dict(ambient=0.5, diffuse=0.9, roughness=0.1, specular=0.2, fresnel=0.2), | |
flatshading=True, | |
hoverinfo='none')] | |
) | |
fig.update_layout(scene=dict(zaxis=dict(visible=False,range=[0,5],autorange=False),xaxis=dict(visible=False,range=[0,10],autorange=False),yaxis=dict(visible=False,range=[0,10],autorange=False)),width=100,height=800) | |
# Use Streamlit to display the 3D c ube | |
st.plotly_chart(fig,use_container_width=True) | |