def test_optimisation_implementations(tmp_path):
    # These are the implementations to test
    implementations = [
        optimisation.RandomOptimisation(),
        optimisation.ParticleFilter(),
        optimisation.GPyOpt(),
        optimisation.CMAOptimisation(),
        optimisation.Ampgo(),
        optimisation.TuRBO(max_evals=11, n_training_steps=30)
        # optimisation.Pygmo,  # excluded because of a mandatory install
        # optimisation.PyScannerBit  # excluded because of a mandatory install
    ]

    for procedure in implementations:
        experiment = exp.OptimisationExperiment(procedure, str(tmp_path))
        experiment.run(func.Himmelblau(), finish_line=250)
        shutil.rmtree(str(tmp_path))
Example #2
0
def test_optimisation_randomoptimisation(tmp_path):
    procedure = optimisation.RandomOptimisation()
    experiment = exp.OptimisationExperiment(procedure, str(tmp_path))
    experiment.run(func.Himmelblau(), finish_line=250)
    shutil.rmtree(str(tmp_path))
Example #3
0
""" Procedure configuration """
# The MAXIMUM_NUMBER_OF_SAMPLES configuration defines how many samples are to
# be sampled. If after any iteration the number of samples exceeds this number,
# the optimisation procedure is stopped.
MAXIMUM_NUMBER_OF_SAMPLES = 1000
""" Output """
# Folder in which the results of the experiment will be stored. If the folder
# does not exist, it will be created.
RESULTS_FOLDER = "./hds"
""" ===========================================================================
        Procedure initialisation
=========================================================================== """

# Initialise the procedure that you want to use in your experiment. The
# object that you create should be stored in the `procedure` variable.
procedure = optimisation.RandomOptimisation(n_initial=5)
""" ===========================================================================
        Initialisation of experiment and functions
=========================================================================== """
# This code initialises the experiment by providing it with your procedure
# of choice and the folder to which results should be stored. No futher changes
# to this part of the code are necessary

# Initialise experiment
experiment = hds.OptimisationExperiment(procedure, RESULTS_FOLDER)

# Create function feeder
feeder = hds.functions.FunctionFeeder()
# Add test functions with known functional forms if this was requested through
# the RUN_TEST_FUNCTIONS configuration parameter
if RUN_TEST_FUNCTIONS:
def test_hiddenfunctions_use():
    procedure = optim.RandomOptimisation()
    path = "./tmpexperiment"
    experiment = TmpExperimentCorrect(procedure, path)
    experiment.run(func.HiddenFunction1(), log_data=False)
    shutil.rmtree(path)