import gradio as gr import numpy as np def branin(x1, x2): y = float( (x2 - 5.1 / (4 * np.pi**2) * x1**2 + 5.0 / np.pi * x1 - 6.0) ** 2 + 10 * (1 - 1.0 / (8 * np.pi)) * np.cos(x1) + 10 ) # return y iface = gr.Interface( fn=branin, inputs=[ gr.Number(0.25, label="x1", minimum=-5.0, maximum=10.0), gr.Number(0.75, label="x2", minimum=0.0, maximum=10.0), ], outputs=gr.Number(branin(0.25, 0.75), label="branin function value"), description=""" ## Objective Minimize the Branin function by selecting appropriate values of x1 and x2. ## Constraints ### Bounds -5 <= x1 <= 10 0 <= x2 <= 15 ## References - https://ax.dev/api/_modules/ax/utils/measurement/synthetic_functions.html#Branin """, ) iface.launch()