| Total Complexity | 1 |
| Total Lines | 21 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import numpy as np |
||
| 2 | from hyperactive import Hyperactive |
||
| 3 | |||
| 4 | |||
| 5 | def rosen(para, X, y): |
||
| 6 | """The Rosenbrock function""" |
||
| 7 | x = np.array([para["x1"], para["x2"], para["x3"], para["x4"]]) |
||
| 8 | y = np.array([para["x0"], para["x1"], para["x2"], para["x3"]]) |
||
| 9 | |||
| 10 | return -sum(100.0 * (x - y ** 2.0) ** 2.0 + (1 - y) ** 2.0) |
||
| 11 | |||
| 12 | |||
| 13 | x_range = np.arange(0, 3, 0.1) |
||
| 14 | |||
| 15 | search_config = { |
||
| 16 | rosen: {"x0": x_range, "x1": x_range, "x2": x_range, "x3": x_range, "x4": x_range} |
||
| 17 | } |
||
| 18 | |||
| 19 | opt = Hyperactive(0, 0, memory=None) |
||
| 20 | opt.search(search_config, n_iter=1000000) |
||
| 21 |