Spaces:
Runtime error
Runtime error
Commit
·
892d6e9
1
Parent(s):
ab3d6ca
Addes rastrigin_2d function
Browse files- app.py +1 -1
- src/functions.py +12 -1
app.py
CHANGED
|
@@ -35,7 +35,7 @@ with st.container():
|
|
| 35 |
# available_functions = ["testfunc_2d", "camel3_2d", "camel16_2d", "treccani_2d", "goldstein_2d", "branin_2d",
|
| 36 |
# "rosenbrock_2d", "ackley_2d"]
|
| 37 |
|
| 38 |
-
available_functions = ["testfunc_2d", "camel3_2d", "camel16_2d", "treccani_2d", "goldstein_2d", "branin_2d",
|
| 39 |
"rosenbrock_2d", "ackley_2d", "rosenbrock_10d", "griewank_10d", "rastrigin_10d"]
|
| 40 |
|
| 41 |
st.sidebar.header('User Inputs')
|
|
|
|
| 35 |
# available_functions = ["testfunc_2d", "camel3_2d", "camel16_2d", "treccani_2d", "goldstein_2d", "branin_2d",
|
| 36 |
# "rosenbrock_2d", "ackley_2d"]
|
| 37 |
|
| 38 |
+
available_functions = ["testfunc_2d", "rastrigin_2d", "camel3_2d", "camel16_2d", "treccani_2d", "goldstein_2d", "branin_2d",
|
| 39 |
"rosenbrock_2d", "ackley_2d", "rosenbrock_10d", "griewank_10d", "rastrigin_10d"]
|
| 40 |
|
| 41 |
st.sidebar.header('User Inputs')
|
src/functions.py
CHANGED
|
@@ -104,7 +104,15 @@ def rastrigin_10d(X):
|
|
| 104 |
except:
|
| 105 |
X = np.array([X])
|
| 106 |
return (np.sum(X**2 - 10 * np.cos(2 * np.pi * X) + 10, axis=1)).reshape(-1, 1)
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
# ------- END FUNCTIONS -------
|
| 109 |
|
| 110 |
if __name__ == "__main__":
|
|
@@ -141,6 +149,9 @@ if __name__ == "__main__":
|
|
| 141 |
elif f == rastrigin_10d:
|
| 142 |
x1_min = x2_min = -5.12
|
| 143 |
x1_max = x2_max = 5.12
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
|
| 146 |
N = 100
|
|
|
|
| 104 |
except:
|
| 105 |
X = np.array([X])
|
| 106 |
return (np.sum(X**2 - 10 * np.cos(2 * np.pi * X) + 10, axis=1)).reshape(-1, 1)
|
| 107 |
+
|
| 108 |
+
# 2d Rastrigin
|
| 109 |
+
def rastrigin_2d(X):
|
| 110 |
+
try:
|
| 111 |
+
X.shape[1]
|
| 112 |
+
except:
|
| 113 |
+
X = np.array([X])
|
| 114 |
+
return (np.sum(X**2 - 10 * np.cos(2 * np.pi * X) + 10, axis=1)).reshape(-1, 1)
|
| 115 |
+
|
| 116 |
# ------- END FUNCTIONS -------
|
| 117 |
|
| 118 |
if __name__ == "__main__":
|
|
|
|
| 149 |
elif f == rastrigin_10d:
|
| 150 |
x1_min = x2_min = -5.12
|
| 151 |
x1_max = x2_max = 5.12
|
| 152 |
+
elif f == rastrigin_2d:
|
| 153 |
+
x1_min = x2_min = -5.12
|
| 154 |
+
x1_max = x2_max = 5.12
|
| 155 |
|
| 156 |
|
| 157 |
N = 100
|