def test_hiddenfunctions_general():
    function = func.HiddenFunction1()
    assert function.funcname == 'test_func_1.bin'
    assert function.ranges == [[-30.0, 30.0], [-30.0, 30.0]]
    x = np.random.rand(10, 2)
    print(function(x))
    assert function(x).shape[0] == len(x)
def test_hiddenfunctions_all():
    function = func.HiddenFunction1()
    x = np.random.rand(10, 2)
    assert function(x).shape[0] == len(x)
    function = func.HiddenFunction2()
    x = np.random.rand(7, 4)
    assert function(x).shape[0] == len(x)
    function = func.HiddenFunction3()
    x = np.random.rand(99, 6)
    assert function(x).shape[0] == len(x)
    function = func.HiddenFunction4()
    x = np.random.rand(1, 16)
    assert function(x).shape[0] == len(x)
Ejemplo n.º 3
0
numdim = sys.argv[1]
print('Number of dimensions:', numdim)
""" ===========================================================================
        Configuration
=========================================================================== """
""" Functions to test the procedure with """
# Set this boolean flag to `True` if your procedure requires the test functions
# to have a bounded input range. Note that this only influences the *known*
# test functions, as the hidden test functions are all bounded
PROCEDURE_REQUIRES_BOUNDED_FUNCTIONS = False
# RUN_HIDDEN_FUNCTIONS_LIST is a list of *initialised* HiddenFunctions to test
# the procedure against. If no HiddenFunction should be tested, provide an
# empty list.
RUN_HIDDEN_FUNCTIONS_LIST = [
    func.HiddenFunction1(int(numdim)),
    func.HiddenFunction2(int(numdim)),
    func.HiddenFunction3(int(numdim)),
    func.HiddenFunction4(int(numdim))
]
# The RUN_TEST_FUNCTIONS boolean indicates if the procedure should be tested
# against the all available test functions that have a known functional form.
RUN_TEST_FUNCTIONS = False
""" Configuration of test and hidden functions """
# The HDS framework interprets optimisation as a minimalisation task. If your
# procedure sees optimisation as a maximisation task, set the following
# INVERSE_OPTIMISATION flag to `True`
INVERSE_OPTIMISATION = False
# The interface of the test functions might not match the interface that your
# procedure expects test functions to have. This is especially the case if the
# procedure is implemented in a third-party library. To solve this, the
def test_hiddenfunctions_use():
    procedure = optim.RandomOptimisation()
    path = "./tmpexperiment"
    experiment = TmpExperimentCorrect(procedure, path)
    experiment.run(func.HiddenFunction1(), log_data=False)
    shutil.rmtree(path)
Ejemplo n.º 5
0
import sys


""" Configure experiment """
# Location to store results
RESULTS_FOLDER = "./results/{}d_wd{}_log{}_sr{}"

input_dimensionality = int(sys.argv[1]) # 2, 3, 5, 7
input_width_decay = float(sys.argv[2]) # 0.9, 0.95, 0.99
input_stdev_configs = bool(int(sys.argv[3])) # 0, 1
input_survival_rates = float(sys.argv[4]) # 0.2, 0.5


# Create functions to loop over
functions = [
    func.HiddenFunction1(input_dimensionality),
    func.HiddenFunction2(input_dimensionality),
    func.HiddenFunction3(input_dimensionality),
    func.HiddenFunction4(input_dimensionality)
]

# Number of seed data points
N_SEED = int(10**(1+np.sqrt(input_dimensionality)))
# Number of samples to add in each iteration
N_ITERATION_STEP = N_SEED*10
# Maximum number of samples to take
MAX_N_SAMPLES = int(1e7)

for function in functions:

    # Create ParticleFilter instance