Exemplo n.º 1
0
def test_suggest_to_minimize():
    """Test ProboBackend suggest_to_minimize on a dataset."""
    model_config = {'name': 'simplegp', 'ls': 3.0, 'alpha': 1.5, 'sigma': 1e-5}
    acqfunction_config = {'name': 'default', 'acq_str': 'ei'}
    acqoptimizer_config = {'name': 'default', 'max_iter': 200}
    domain_config = {'name': 'real', 'min_max': [[0.0, 2.0]]}
    probo_config = {'real_idx': [0], 'all_real': True}
    pb = ProboBackend(
        model_config,
        acqfunction_config,
        acqoptimizer_config,
        domain_config,
        probo_config,
    )

    data = Namespace()
    data.x = [[0.5], [1.0], [1.5]]
    data.y = [6.0, 1.0, 4.0]
    suggestion = pb.suggest_to_minimize(data)
    assert isinstance(suggestion, list)
    assert 0.75 < suggestion[0] < 1.25
Exemplo n.º 2
0
def test_initialize():
    """Test initialize ProboBackend."""
    model_config = {'name': 'simplegp', 'ls': 3.0, 'alpha': 1.5, 'sigma': 1e-5}
    acqfunction_config = {'name': 'default', 'acq_str': 'ei'}
    acqoptimizer_config = {'name': 'default', 'max_iter': 200}
    domain_config = {'name': 'real', 'min_max': [[-5, 5]]}
    probo_config = {'real_idx': [0], 'all_real': True}
    pb = ProboBackend(
        model_config,
        acqfunction_config,
        acqoptimizer_config,
        domain_config,
        probo_config,
    )
    assert getattr(pb, 'model_config', None)
Exemplo n.º 3
0
from tuun.backend import ProboBackend

model_config = {'name': 'simplegp', 'ls': 3.0, 'alpha': 1.5, 'sigma': 1e-5}
acqfunction_config = {'name': 'default', 'acq_str': 'ei'}
acqoptimizer_config = {'name': 'default', 'max_iter': 200}
domain_config = {'name': 'real', 'min_max': [(-5, 5)]}

data = {
    'x': [[0.0], [1.0], [2.0]],
    'y': [6.0, 3.0, 4.0],
}

pb = ProboBackend(model_config, acqfunction_config, acqoptimizer_config, domain_config)
suggestion = pb.suggest_to_minimize(data)
    'ig1': 4.0,
    'ig2': 3.0,
    'n1': 1.0,
    'n2': 1.0,
    'sigma': 1e-5,
    'niter': 70,
}
acqfunction_config = {'name': 'default', 'acq_str': 'ucb', 'n_gen': 500}
acqoptimizer_config = {'name': 'cobyla', 'rand_every': 4, 'jitter': True}
domain_config = {
    'name':
    'product',
    'dom_config_list': [
        {
            'name': 'real',
            'min_max': [(-10, 10)]
        },
        {
            'name': 'real',
            'min_max': [(-10, 10)]
        },
    ],
}

f_s = lambda x: x[0]**4 - x[0]**2 + 0.1 * x[0]
f = lambda x_list: f_s(x_list[0]) + f_s(x_list[1])

pb = ProboBackend(model_config, acqfunction_config, acqoptimizer_config,
                  domain_config)
results = pb.minimize_function(f, 50)