Ejemplo n.º 1
0
class TestAckley(SyntheticTestFunctionBaseTestCase, BotorchTestCase):

    functions = [
        Ackley(),
        Ackley(negate=True),
        Ackley(noise_std=0.1),
        Ackley(dim=3)
    ]
Ejemplo n.º 2
0
 def testEncodeDecodeSimpleBenchmarkProblem(self):
     branin_problem = get_branin_simple_benchmark_problem()
     sum_problem = get_sum_simple_benchmark_problem()
     new_branin_problem = object_from_json(object_to_json(branin_problem))
     new_sum_problem = object_from_json(object_to_json(sum_problem))
     self.assertEqual(branin_problem.f(1, 2), new_branin_problem.f(1, 2),
                      branin(1, 2))
     self.assertEqual(sum_problem.f([1, 2]), new_sum_problem.f([1, 2]), 3)
     # Test using `from_botorch`.
     ackley_problem = SimpleBenchmarkProblem(f=from_botorch(Ackley()),
                                             noise_sd=0.0,
                                             minimize=True)
     new_ackley_problem = object_from_json(object_to_json(ackley_problem))
     self.assertEqual(ackley_problem.f(1, 2), new_ackley_problem.f(1, 2),
                      ackley(1, 2))
Ejemplo n.º 3
0
 def testEncodeDecodeSimpleBenchmarkProblem(self):
     branin_problem = get_branin_simple_benchmark_problem()
     sum_problem = get_sum_simple_benchmark_problem()
     new_branin_problem = object_from_json(
         object_to_json(
             branin_problem,
             encoder_registry=DEPRECATED_ENCODER_REGISTRY,
             class_encoder_registry=DEPRECATED_CLASS_ENCODER_REGISTRY,
         ),
         decoder_registry=DEPRECATED_DECODER_REGISTRY,
         class_decoder_registry=DEPRECATED_CLASS_DECODER_REGISTRY,
     )
     new_sum_problem = object_from_json(
         object_to_json(
             sum_problem,
             encoder_registry=DEPRECATED_ENCODER_REGISTRY,
             class_encoder_registry=DEPRECATED_CLASS_ENCODER_REGISTRY,
         ),
         decoder_registry=DEPRECATED_DECODER_REGISTRY,
         class_decoder_registry=DEPRECATED_CLASS_DECODER_REGISTRY,
     )
     self.assertEqual(
         branin_problem.f(1, 2), new_branin_problem.f(1, 2), branin(1, 2)
     )
     self.assertEqual(sum_problem.f([1, 2]), new_sum_problem.f([1, 2]), 3)
     # Test using `from_botorch`.
     ackley_problem = SimpleBenchmarkProblem(
         f=from_botorch(Ackley()), noise_sd=0.0, minimize=True
     )
     new_ackley_problem = object_from_json(
         object_to_json(
             ackley_problem,
             encoder_registry=DEPRECATED_ENCODER_REGISTRY,
             class_encoder_registry=DEPRECATED_CLASS_ENCODER_REGISTRY,
         ),
         decoder_registry=DEPRECATED_DECODER_REGISTRY,
         class_decoder_registry=DEPRECATED_CLASS_DECODER_REGISTRY,
     )
     self.assertEqual(
         ackley_problem.f(1, 2), new_ackley_problem.f(1, 2), ackley(1, 2)
     )
Ejemplo n.º 4
0
# LICENSE file in the root directory of this source tree.


from ax.benchmark.benchmark_problem import BenchmarkProblem, SimpleBenchmarkProblem
from ax.utils.measurement.synthetic_functions import from_botorch
from ax.utils.testing.core_stubs import (
    get_augmented_branin_optimization_config,
    get_augmented_hartmann_optimization_config,
    get_branin_search_space,
    get_hartmann_search_space,
)
from botorch.test_functions.synthetic import Ackley, Branin


# Initialize the single-fidelity problems
ackley = SimpleBenchmarkProblem(f=from_botorch(Ackley()), noise_sd=0.0, minimize=True)
branin = SimpleBenchmarkProblem(f=from_botorch(Branin()), noise_sd=0.0, minimize=True)
single_fidelity_problem_group = [ackley, branin]

# Initialize the multi-fidelity problems
augmented_branin = BenchmarkProblem(
    search_space=get_branin_search_space(with_fidelity_parameter=True),
    optimization_config=get_augmented_branin_optimization_config(),
)
augmented_hartmann = BenchmarkProblem(
    search_space=get_hartmann_search_space(with_fidelity_parameter=True),
    optimization_config=get_augmented_hartmann_optimization_config(),
)
multi_fidelity_problem_group = [augmented_branin, augmented_hartmann]

# Gather all of the problems
Ejemplo n.º 5
0
def ackley200(X, noise):
    return -Ackley(200, noise)(X).unsqueeze(1)
Ejemplo n.º 6
0
def ackley10(X, noise):
    return -Ackley(10, noise)(X).unsqueeze(1)
Ejemplo n.º 7
0
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from ax.benchmark.benchmark_problem import BenchmarkProblem, SimpleBenchmarkProblem
from ax.utils.measurement.synthetic_functions import from_botorch
from ax.utils.testing.core_stubs import (
    get_augmented_branin_optimization_config,
    get_augmented_hartmann_optimization_config,
    get_branin_search_space,
    get_hartmann_search_space,
)
from botorch.test_functions.synthetic import Ackley, Branin

# Initialize the single-fidelity problems
ackley = SimpleBenchmarkProblem(f=from_botorch(Ackley()),
                                noise_sd=0.0,
                                minimize=True)
branin = SimpleBenchmarkProblem(f=from_botorch(Branin()),
                                noise_sd=0.0,
                                minimize=True)
single_fidelity_problem_group = [ackley, branin]

# Initialize the multi-fidelity problems
augmented_branin = BenchmarkProblem(
    search_space=get_branin_search_space(with_fidelity_parameter=True),
    optimization_config=get_augmented_branin_optimization_config(),
)
augmented_hartmann = BenchmarkProblem(
    search_space=get_hartmann_search_space(with_fidelity_parameter=True),
    optimization_config=get_augmented_hartmann_optimization_config(),