コード例 #1
0
def test_single_parameter():
    param_space = ParameterSpace()
    param = Parameter()
    param_space.add(param)
    assert param_space.param_names == ['parameter']
    for attr in ['name', 'type', 'low', 'high']:
        assert getattr(param_space[0], attr) == getattr(param, attr)
コード例 #2
0
def test_parameter_ordering():
    param_space = ParameterSpace()
    for _ in range(4):
        param = Parameter(name='param_{}'.format(_))
        param_space.add(param)
    for _, param in enumerate(param_space):
        assert param.name == 'param_{}'.format(_)
コード例 #3
0
def test_from_functions():

    param_0 = Parameter(name='p0', type='continuous', low=0.0, high=1.0)
    param_1 = Parameter(name='p1', type='continuous', low=0.0, high=1.0)

    param_space = ParameterSpace()
    param_space.add([param_0, param_1])

    # from array
    paramvector0 = ParameterVector().from_array([0.1, 0.2], param_space)
    # from dictionary
    paramvector1 = ParameterVector().from_dict({'p0': 0.1, 'p1': 0.2})

    for attr0, attr1 in zip(paramvector0.attrs, paramvector1.attrs):
        assert attr0 == attr1

    for prop0, prop1 in zip(paramvector0.props, paramvector1.props):
        assert prop0 == prop1
コード例 #4
0
def test_name_collisions():
    param_space = ParameterSpace()
    for _ in range(4):
        param = Parameter(name=f'param_{_}')
        param_space.add(param)
    param_space.add(Parameter(name='param_0'))
    assert len(Logger.ERRORS) == 1
    Logger.purge()
コード例 #5
0
        Args:
            goal (str): The optimization goal, either 'minimize' or 'maximize'. Default is 'minimize'.
            disp (bool): Set to True to print convergence messages.
            maxiter (int): Maximum number of iterations to perform.
            gtol (float): Gradient norm must be less than gtol before successful termination.
            norm (float): Order of norm (Inf is max, -Inf is min).
            eps (float or ndarray): If jac is approximated, use this value for the step size.
            init_guess (array, optional): initial guess for the optimization
            init_guess_method (str): method to construct initial guesses if init_guess is not provided.
                Choose from: random
            init_guess_seed (str): random seed for init_guess_method
        """

        WrapperScipy.__init__(**locals())


#===============================================================================

if __name__ == '__main__':

    from olympus import Parameter, ParameterSpace
    param_space = ParameterSpace()
    param_space.add(Parameter(name='param_0'))
    param_space.add(Parameter(name='param_1'))

    planner = ConjugateGradient()
    planner.set_param_space(param_space=param_space)
    param = planner.ask()
    print('PARAM', param)
コード例 #6
0
def two_param_space():
    param_space = ParameterSpace()
    param_space.add(Parameter(name='param_0'))
    param_space.add(Parameter(name='param_1'))
    return param_space
コード例 #7
0
def test_multiple_parameters():
    param_space = ParameterSpace()
    params = [Parameter(name=f'param_{_}') for _ in range(4)]
    param_space.add(params)
    assert param_space.param_names == [f'param_{_}' for _ in range(4)]