Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,7 +18,7 @@ def gen_pulsive_noise(count, min_val, max_val):
|
|
| 18 |
pulse = random.randint(min_val, max_val)
|
| 19 |
|
| 20 |
return pulse
|
| 21 |
-
def simulation(input_noise, output_noise,
|
| 22 |
vrs = {}
|
| 23 |
fmu = 'Pharmacokinetics_4_comportmental_model_PI_ref_FMU_base4_OAAS_lnx.fmu'
|
| 24 |
model_description = read_model_description(fmu)
|
|
@@ -73,7 +73,7 @@ def simulation(input_noise, output_noise, min_val, max_val, kp, ki):
|
|
| 73 |
|
| 74 |
bis = fmu.getReal([int(vr_output)])[0] if time > step_size else 95.6
|
| 75 |
if input_noise:
|
| 76 |
-
bis += add_noise(
|
| 77 |
p = bis - target
|
| 78 |
i = i + p
|
| 79 |
infusion_rate = np.clip(kp*p + ki*i, 0, 200)
|
|
@@ -114,13 +114,18 @@ with gr.Blocks() as demo:
|
|
| 114 |
with gr.Row():
|
| 115 |
with gr.Column(scale=1):
|
| 116 |
gr.Markdown("**BIS noise**")
|
| 117 |
-
input_noise = gr.inputs.Checkbox(label="Add noise")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
gr.Markdown("**Infusion noise**")
|
| 119 |
with gr.Blocks():
|
| 120 |
-
output_noise = gr.inputs.Checkbox(label="Add noise")
|
| 121 |
with gr.Accordion("noise range"):
|
| 122 |
-
|
| 123 |
-
|
| 124 |
gr.Markdown("**PI controller paramters**")
|
| 125 |
with gr.Blocks():
|
| 126 |
kp_slider = gr.inputs.Slider(minimum=0, maximum=19, default=4, label="kp")
|
|
@@ -129,5 +134,5 @@ with gr.Blocks() as demo:
|
|
| 129 |
with gr.Column(scale=5):
|
| 130 |
plot1 = gr.Plot(label="BIS evolution")
|
| 131 |
plot2 = gr.Plot(label="Infusion evolution")
|
| 132 |
-
button.click(simulation, inputs=[input_noise, output_noise, min_slider, max_slider, kp_slider, ki_slider], outputs=[plot1, plot2])
|
| 133 |
demo.launch()
|
|
|
|
| 18 |
pulse = random.randint(min_val, max_val)
|
| 19 |
|
| 20 |
return pulse
|
| 21 |
+
def simulation(input_noise, output_noise, min, max, std, mean, min_pul, max_pul, kp, ki):
|
| 22 |
vrs = {}
|
| 23 |
fmu = 'Pharmacokinetics_4_comportmental_model_PI_ref_FMU_base4_OAAS_lnx.fmu'
|
| 24 |
model_description = read_model_description(fmu)
|
|
|
|
| 73 |
|
| 74 |
bis = fmu.getReal([int(vr_output)])[0] if time > step_size else 95.6
|
| 75 |
if input_noise:
|
| 76 |
+
bis += add_noise(min, max, std, mean)
|
| 77 |
p = bis - target
|
| 78 |
i = i + p
|
| 79 |
infusion_rate = np.clip(kp*p + ki*i, 0, 200)
|
|
|
|
| 114 |
with gr.Row():
|
| 115 |
with gr.Column(scale=1):
|
| 116 |
gr.Markdown("**BIS noise**")
|
| 117 |
+
input_noise = gr.inputs.Checkbox(label="Add Gaussian noise")
|
| 118 |
+
with gr.Accordion("noise range"):
|
| 119 |
+
min = gr.inputs.Slider(minimum=0, maximum=20, step=1, default=5, label="noise min")
|
| 120 |
+
max = gr.inputs.Slider(minimum=0, maximum=20, step=1, default=10, label="noise max")
|
| 121 |
+
std = gr.inputs.Slider(minimum=0, maximum=10, step=1, default=2, label="noise standard deviation")
|
| 122 |
+
mean = gr.inputs.Slider(minimum=0, maximum=20, step=1, default=7, label="noise mean")
|
| 123 |
gr.Markdown("**Infusion noise**")
|
| 124 |
with gr.Blocks():
|
| 125 |
+
output_noise = gr.inputs.Checkbox(label="Add Pulsive noise")
|
| 126 |
with gr.Accordion("noise range"):
|
| 127 |
+
min_pul = gr.inputs.Slider(minimum=0, maximum=50, step=1, default=50, label="noise min")
|
| 128 |
+
max_pul = gr.inputs.Slider(minimum=0, maximum=150, step=1, default=150, label="noise max")
|
| 129 |
gr.Markdown("**PI controller paramters**")
|
| 130 |
with gr.Blocks():
|
| 131 |
kp_slider = gr.inputs.Slider(minimum=0, maximum=19, default=4, label="kp")
|
|
|
|
| 134 |
with gr.Column(scale=5):
|
| 135 |
plot1 = gr.Plot(label="BIS evolution")
|
| 136 |
plot2 = gr.Plot(label="Infusion evolution")
|
| 137 |
+
button.click(simulation, inputs=[input_noise, output_noise, min, max, std, mean, min_slider, max_slider, kp_slider, ki_slider], outputs=[plot1, plot2])
|
| 138 |
demo.launch()
|