Exemplo n.º 1
0
    def test_create_with_different_configure(self, benchmark_config_py,
                                             caplog):
        """Test creation with same name but different configure"""
        with OrionState():
            config = copy.deepcopy(benchmark_config_py)
            bm1 = get_or_create_benchmark(**config)

            config = copy.deepcopy(benchmark_config_py)
            config["targets"][0]["assess"] = [AverageResult(2)]

            with caplog.at_level(logging.WARNING,
                                 logger="orion.benchmark.benchmark_client"):
                bm2 = get_or_create_benchmark(**config)

            assert bm2.configuration == bm1.configuration
            assert (
                "Benchmark with same name is found but has different configuration, "
                "which will be used for this creation." in caplog.text)

            caplog.clear()
            config = copy.deepcopy(benchmark_config_py)
            config["targets"][0]["task"] = [
                RosenBrock(26, dim=3), CarromTable(20)
            ]
            with caplog.at_level(logging.WARNING,
                                 logger="orion.benchmark.benchmark_client"):
                bm3 = get_or_create_benchmark(**config)

            assert bm3.configuration == bm1.configuration
            assert (
                "Benchmark with same name is found but has different configuration, "
                "which will be used for this creation." in caplog.text)
Exemplo n.º 2
0
    def test_call(self):
        """Test to get task function"""
        carrom = CarromTable(2)

        assert callable(carrom)

        objectives = carrom([1, 2])
        assert type(objectives[0]) == dict
Exemplo n.º 3
0
    def test_call(self):
        """Test to get task function"""
        task = CarromTable(2)

        assert callable(task)

        objectives = task([1, 2])
        assert type(objectives[0]) == dict
Exemplo n.º 4
0
def benchmark_config_py(benchmark_algorithms):
    config = dict(
        name="bm00001",
        algorithms=benchmark_algorithms,
        targets=[{
            "assess": [AverageResult(2), AverageRank(2)],
            "task": [RosenBrock(25, dim=3),
                     CarromTable(20)],
        }],
    )
    return config
Exemplo n.º 5
0
def benchmark(benchmark_algorithms):
    """Return a benchmark instance"""
    return Benchmark(
        name="benchmark007",
        algorithms=benchmark_algorithms,
        targets=[{
            "assess": [AverageResult(2), AverageRank(2)],
            "task": [RosenBrock(25, dim=3),
                     CarromTable(20)],
        }],
    )
Exemplo n.º 6
0
def test_simple():
    """Test a end 2 end exucution of benchmark"""
    task_num = 2
    trial_num = 20
    assessments = [AverageResult(task_num), AverageRank(task_num)]
    tasks = [
        RosenBrock(trial_num, dim=3),
        EggHolder(trial_num, dim=4),
        CarromTable(trial_num),
        Branin(trial_num),
        BirdLike(trial_num),
    ]
    benchmark = get_or_create_benchmark(
        name="bm001",
        algorithms=algorithms,
        targets=[{
            "assess": assessments,
            "task": tasks
        }],
    )
    benchmark.process()

    assert len(benchmark.studies) == len(assessments) * len(tasks)

    status = benchmark.status()

    experiments = benchmark.experiments()

    assert len(experiments
               ) == len(algorithms) * task_num * len(assessments) * len(tasks)

    assert len(status) == len(algorithms) * len(assessments) * len(tasks)

    figures = benchmark.analysis()

    assert len(figures) == len(benchmark.studies)
    assert type(figures[0]) is plotly.graph_objects.Figure

    benchmark = get_or_create_benchmark(name="bm001")
    figures = benchmark.analysis()

    assert len(figures) == len(benchmark.studies)
    assert type(figures[0]) is plotly.graph_objects.Figure
Exemplo n.º 7
0
    def test_search_space(self):
        """Test to get task search space"""
        carrom = CarromTable(2)

        assert carrom.get_search_space() == {"x": "uniform(-10, 10, shape=2)"}
Exemplo n.º 8
0
 def test_creation(self):
     """Test creation"""
     branin = CarromTable(2)
     assert branin.max_trials == 2
     assert branin.configuration == {"CarromTable": {"max_trials": 2}}
Exemplo n.º 9
0
 def test_creation(self):
     """Test creation"""
     task = CarromTable(2)
     assert task.max_trials == 2
     assert task.configuration == {"CarromTable": {"max_trials": 2}}