Hongyuehao commited on
Commit
b4d291a
·
verified ·
1 Parent(s): 097817d

Add four/five switch

Browse files
Files changed (1) hide show
  1. app.py +25 -2
app.py CHANGED
@@ -3,8 +3,13 @@ import plotly.graph_objects as go
3
  import math
4
 
5
  def combineInf(envFact, envRatingDH, envRatingGates, envRatingOut,
6
- weatherFact, weatherRating, windSpeed,
7
  distValue, envValue, convValue, phyValue):
 
 
 
 
 
8
  distance = {'Mall': 70, 'Doherty': 90, 'Gates': 80}
9
 
10
  envRating = {'Mall': envRatingOut, 'Doherty': envRatingDH, 'Gates': envRatingGates}
@@ -20,6 +25,12 @@ def combineInf(envFact, envRatingDH, envRatingGates, envRatingOut,
20
 
21
  physicalIntensity = dict()
22
  energyCost = {'Mall': 28.8, 'Doherty': 28.908, 'Gates': 28.854}
 
 
 
 
 
 
23
  distanceOutside = {'Mall': 0.24, 'Doherty': 0.05, 'Gates': 0.06}
24
  windSpeedinms = windSpeed / 2.237
25
  for route in energyCost:
@@ -29,6 +40,14 @@ def combineInf(envFact, envRatingDH, envRatingGates, envRatingOut,
29
  phyScore = 100 * (math.e ** -((totalEnergy - 28) / 100))
30
  physicalIntensity[route] = phyScore
31
 
 
 
 
 
 
 
 
 
32
  total = distValue + envValue + convValue + phyValue
33
  percentage = [distValue / total, envValue / total, convValue / total, phyValue / total]
34
 
@@ -134,6 +153,10 @@ with gr.Blocks() as demo:
134
  weatherFact = gr.Slider(0, 10, value=5, label="How important weather is for your choice")
135
  weatherRating = gr.Slider(0, 100, value = 50, label = "How much do you like the weather today")
136
  windSpeed = gr.Slider(0, 100, value = 10, label = 'Wind speed in mph')
 
 
 
 
137
 
138
  with gr.Row():
139
  distValue = gr.Slider(0, 10, value = 2.5, label='How much you care about distance')
@@ -164,7 +187,7 @@ with gr.Blocks() as demo:
164
 
165
 
166
  update_btn.click(combineInf, inputs=[envFact, envRatingDH, envRatingGates, envRatingOut,
167
- weatherFact, weatherRating, windSpeed,
168
  distValue, envValue, convValue, phyValue],
169
  outputs=[g1, g2, g3, s1, s2, s3, routeOfMax])
170
 
 
3
  import math
4
 
5
  def combineInf(envFact, envRatingDH, envRatingGates, envRatingOut,
6
+ weatherFact, weatherRating, windSpeed, ffSwitch,
7
  distValue, envValue, convValue, phyValue):
8
+ if ffSwitch == '4th Floor':
9
+ isFourth = True
10
+ else:
11
+ isFourth = False
12
+
13
  distance = {'Mall': 70, 'Doherty': 90, 'Gates': 80}
14
 
15
  envRating = {'Mall': envRatingOut, 'Doherty': envRatingDH, 'Gates': envRatingGates}
 
25
 
26
  physicalIntensity = dict()
27
  energyCost = {'Mall': 28.8, 'Doherty': 28.908, 'Gates': 28.854}
28
+ if isFourth:
29
+ for route in ['Mall', 'Doherty']:
30
+ energyCost[route] += 1.254
31
+ else:
32
+ energyCost['Gates'] += 3.045
33
+
34
  distanceOutside = {'Mall': 0.24, 'Doherty': 0.05, 'Gates': 0.06}
35
  windSpeedinms = windSpeed / 2.237
36
  for route in energyCost:
 
40
  phyScore = 100 * (math.e ** -((totalEnergy - 28) / 100))
41
  physicalIntensity[route] = phyScore
42
 
43
+ if isFourth:
44
+ for route in ['Mall', 'Doherty']:
45
+ distance[route] -= 3
46
+ convenience[route] -= 14
47
+ else:
48
+ distance['Gates'] -= 3
49
+ convenience['Gates'] -= 17
50
+
51
  total = distValue + envValue + convValue + phyValue
52
  percentage = [distValue / total, envValue / total, convValue / total, phyValue / total]
53
 
 
153
  weatherFact = gr.Slider(0, 10, value=5, label="How important weather is for your choice")
154
  weatherRating = gr.Slider(0, 100, value = 50, label = "How much do you like the weather today")
155
  windSpeed = gr.Slider(0, 100, value = 10, label = 'Wind speed in mph')
156
+ with gr.Column():
157
+ ffSwitch = gr.Radio(["4th Floor", "5th Floor"],
158
+ value="4th Floor",
159
+ label="Target Floor")
160
 
161
  with gr.Row():
162
  distValue = gr.Slider(0, 10, value = 2.5, label='How much you care about distance')
 
187
 
188
 
189
  update_btn.click(combineInf, inputs=[envFact, envRatingDH, envRatingGates, envRatingOut,
190
+ weatherFact, weatherRating, windSpeed, ffSwitch,
191
  distValue, envValue, convValue, phyValue],
192
  outputs=[g1, g2, g3, s1, s2, s3, routeOfMax])
193