def test_eval(self): dim = 100 obj = Objective(func=ackley, dim=Dimension(dim, [[-1, 1]] * dim, [True] * dim)) sol = Solution(x=[0.2] * dim) res = obj.eval(sol) assert abs(res) <= 1e-7
def test_resample(self): dim = 100 obj = Objective(func=ackley, dim=Dimension(dim, [[-1, 1]] * dim, [True] * dim)) sol = Solution(x=[0.2] * dim) res = obj.eval(sol) obj.resample(sol, 3) assert abs(sol.get_value()) <= 1e-7 sol.set_value(0) obj.resample_func(sol, 3) assert abs(sol.get_value()) <= 1e-7