| Total Complexity | 1 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import numpy as np |
||
| 2 | |||
| 3 | from hyperactive.optimizers import HillClimbingOptimizer |
||
| 4 | from hyperactive.experiment import BaseExperiment |
||
| 5 | from hyperactive.search_config import SearchConfig |
||
| 6 | |||
| 7 | |||
| 8 | class Experiment(BaseExperiment): |
||
| 9 | def objective_function(self, opt): |
||
| 10 | score = -opt["x1"] * opt["x1"] |
||
| 11 | return score |
||
| 12 | |||
| 13 | |||
| 14 | experiment = Experiment() |
||
| 15 | |||
| 16 | search_config = SearchConfig( |
||
| 17 | x1=list(np.arange(-100, 101, 1)), |
||
| 18 | ) |
||
| 19 | |||
| 20 | |||
| 21 | hyper = HillClimbingOptimizer() |
||
| 22 | hyper.add_search(experiment, search_config, n_iter=30, memory=True) |
||
| 23 | hyper.run(verbosity=False) |
||
| 24 |