File size: 798 Bytes
21fece8
 
 
 
 
 
 
 
 
78e7db4
21fece8
 
 
 
 
 
 
076dfd1
f293fe1
21fece8
5e2fc9d
78e7db4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eb0a99d
78e7db4
 
21fece8
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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=15.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://www.sfu.ca/~ssurjano/branin.html

    """,
)
iface.launch()