Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import numpy as np | |
| # Goal: Minimize | |
| def process( | |
| x1, | |
| x2, | |
| x3, | |
| x4, | |
| x5, | |
| x6, | |
| x7, | |
| x8, | |
| x9, | |
| x10, | |
| x11, | |
| x12, | |
| x13, | |
| x14, | |
| x15, | |
| x16, | |
| x17, | |
| x18, | |
| x19, | |
| x20, | |
| ): | |
| y = ( | |
| (x1 - 2) ** 2 | |
| + 0.8 * x3 | |
| + 0.4 * (x6 + 1) ** 2 | |
| + (x12) ** 2 | |
| - 0.3 * (x18 - 2) ** 2 | |
| + x1 * x6 | |
| ) | |
| return y | |
| # | |
| defaults = np.random.uniform(0, 1, 20) | |
| iface = gr.Interface( | |
| fn=process, | |
| inputs=[ | |
| gr.Slider(minimum=0.0, maximum=1.0, value=defaults[k], label=f"x{k+1}") | |
| for k in range(20) | |
| ], | |
| outputs=gr.Number(process(*defaults), label="process function value (minimize)"), | |
| ) | |
| iface.launch() | |