def test_brute_parameter_sweep(self): config = { "call_path": unittest_root, "max_population": None, "max_generation": 10, "tree_generation": { "method": "RAMPED_HALF_AND_HALF_METHOD", "depth_ranges": [{ "size": 4, "percentage": 0.25 }, { "size": 3, "percentage": 0.25 }, { "size": 2, "percentage": 0.25 }, { "size": 1, "percentage": 0.25 }] }, "evaluator": { "use_cache": True }, "selection": { "method": "ELITEST_SELECTION" }, "crossover": { "method": "POINT_CROSSOVER", "probability": None }, "mutation": { "methods": ["SUBTREE_MUTATION"], "probability": None }, "function_nodes": [{ "type": "FUNCTION", "name": "ADD", "arity": 2 }, { "type": "FUNCTION", "name": "SUB", "arity": 2 }, { "type": "FUNCTION", "name": "MUL", "arity": 2 }, { "type": "FUNCTION", "name": "DIV", "arity": 2 }, { "type": "FUNCTION", "name": "COS", "arity": 1 }, { "type": "FUNCTION", "name": "SIN", "arity": 1 }], "terminal_nodes": [ { "type": "CONSTANT", "value": 0.0 }, { "type": "CONSTANT", "value": 1.0 }, { "type": "CONSTANT", "value": 2.0 }, { "type": "CONSTANT", "value": 2.0 }, { "type": "CONSTANT", "value": 3.0 }, { "type": "CONSTANT", "value": 4.0 }, { "type": "CONSTANT", "value": 5.0 }, { "type": "CONSTANT", "value": 6.0 }, { "type": "CONSTANT", "value": 7.0 }, { "type": "CONSTANT", "value": 8.0 }, { "type": "CONSTANT", "value": 9.0 }, { "type": "CONSTANT", "value": 10.0 }, ], "data_file": None, "input_variables": [{ "type": "INPUT", "name": "var1" }], "response_variables": [{ "name": "answer" }], "recorder": { "store_file": None, "record_level": "MIN", "compress": True } } test_parameters = { "play_config": config, "random_seeds": [10, 20], "iterations": 2, "processes": 1, "population_size": { "range": [100] }, "crossover_probability": { "range": [0.80] }, "mutation_probability": { "range": [0.10] }, "training_data": ["data/arabas_et_al-f1.dat"], "record_dir": "/tmp/unittest", "log_path": "/tmp/unittest/benchmark.log" } tuner.brute_parameter_sweep(test_parameters, self.functions, gp_benchmark_loop) # asserts self.assertTrue(os.path.isfile(test_parameters["log_path"])) # test exception test_parameters["random_seeds"] = range(0) self.assertRaises(RuntimeError, tuner.brute_parameter_sweep, test_parameters, self.functions, gp_benchmark_loop)
def setUp(self): config = { "call_path": os.path.dirname(os.path.realpath(sys.argv[0])), "max_population": None, "max_generation": 100, "tree_generation": { "method": "RAMPED_HALF_AND_HALF_METHOD", "depth_ranges": [ {"size": 2, "percentage": 1.0}, ] }, "evaluator": {"use_cache": True}, "selection": {"method": "ELITEST_SELECTION"}, "crossover": { "method": "POINT_CROSSOVER", "probability": None }, "mutation": { "methods": [ "SUBTREE_MUTATION", "SHRINK_MUTATION" ], "probability": None }, "function_nodes": [ {"type": "FUNCTION", "name": "ADD", "arity": 2}, {"type": "FUNCTION", "name": "SUB", "arity": 2}, {"type": "FUNCTION", "name": "MUL", "arity": 2}, {"type": "FUNCTION", "name": "DIV", "arity": 2}, {"type": "FUNCTION", "name": "COS", "arity": 1}, {"type": "FUNCTION", "name": "SIN", "arity": 1} ], "terminal_nodes": [ {"type": "CONSTANT", "value": 0.0}, {"type": "CONSTANT", "value": 1.0}, {"type": "CONSTANT", "value": 2.0}, {"type": "CONSTANT", "value": 2.0}, {"type": "CONSTANT", "value": 3.0}, {"type": "CONSTANT", "value": 4.0}, {"type": "CONSTANT", "value": 5.0}, {"type": "CONSTANT", "value": 6.0}, {"type": "CONSTANT", "value": 7.0}, {"type": "CONSTANT", "value": 8.0}, {"type": "CONSTANT", "value": 9.0}, {"type": "CONSTANT", "value": 10.0}, {"type": "CONSTANT", "value": math.pi} ], "data_file": None, "input_variables": [{"type": "INPUT", "name": "var1"}], "response_variables": [{"name": "answer"}], "recorder": { "store_file": None, "record_level": "MAX", "compress": True } } test_parameters = { "play_config": config, "random_seeds": range(1), "iterations": 1, "processes": 1, "population_size": {"range": [100]}, "crossover_probability": {"range": [0.80]}, "mutation_probability": {"range": [0.80, 0.70]}, "training_data": ["../data/arabas_et_al-f1.dat"], "record_dir": "./analyzer_test_data", "log_path": "./analyzer_test_data/benchmark.log" } functions = { "ADD": "+", "SUB": "-", "MUL": "*", "DIV": "/", "POW": "**", "SIN": "math.sin", "COS": "math.cos", "RAD": "math.radians", "LN": "math.ln", "LOG": "math.log" } brute_parameter_sweep(test_parameters, functions, gp_benchmark_loop)
0.55, 0.60, 0.65, 0.70, 0.75, 0.80, # 0.85, # 0.90, # 0.95, # 1.00 ] }, "training_data": ["training_data/arabas_et_al-f1.dat"], "record_dir": "$HOME/data", "log_path": "$HOME/data/f1.log" } functions = { "ADD": "+", "SUB": "-", "MUL": "*", "DIV": "/", "POW": "**", "SIN": "math.sin", "COS": "math.cos", "RAD": "math.radians", "LN": "math.ln", "LOG": "math.log" } brute_parameter_sweep(test_parameters, functions, gp_benchmark_loop)
def setUp(self): config = { "call_path": os.path.dirname(os.path.realpath(sys.argv[0])), "max_population": None, "max_generation": 100, "tree_generation": { "method": "RAMPED_HALF_AND_HALF_METHOD", "depth_ranges": [ { "size": 2, "percentage": 1.0 }, ] }, "evaluator": { "use_cache": True }, "selection": { "method": "ELITEST_SELECTION" }, "crossover": { "method": "POINT_CROSSOVER", "probability": None }, "mutation": { "methods": ["SUBTREE_MUTATION", "SHRINK_MUTATION"], "probability": None }, "function_nodes": [{ "type": "FUNCTION", "name": "ADD", "arity": 2 }, { "type": "FUNCTION", "name": "SUB", "arity": 2 }, { "type": "FUNCTION", "name": "MUL", "arity": 2 }, { "type": "FUNCTION", "name": "DIV", "arity": 2 }, { "type": "FUNCTION", "name": "COS", "arity": 1 }, { "type": "FUNCTION", "name": "SIN", "arity": 1 }], "terminal_nodes": [{ "type": "CONSTANT", "value": 0.0 }, { "type": "CONSTANT", "value": 1.0 }, { "type": "CONSTANT", "value": 2.0 }, { "type": "CONSTANT", "value": 2.0 }, { "type": "CONSTANT", "value": 3.0 }, { "type": "CONSTANT", "value": 4.0 }, { "type": "CONSTANT", "value": 5.0 }, { "type": "CONSTANT", "value": 6.0 }, { "type": "CONSTANT", "value": 7.0 }, { "type": "CONSTANT", "value": 8.0 }, { "type": "CONSTANT", "value": 9.0 }, { "type": "CONSTANT", "value": 10.0 }, { "type": "CONSTANT", "value": math.pi }], "data_file": None, "input_variables": [{ "type": "INPUT", "name": "var1" }], "response_variables": [{ "name": "answer" }], "recorder": { "store_file": None, "record_level": "MAX", "compress": True } } test_parameters = { "play_config": config, "random_seeds": range(1), "iterations": 1, "processes": 1, "population_size": { "range": [100] }, "crossover_probability": { "range": [0.80] }, "mutation_probability": { "range": [0.80, 0.70] }, "training_data": ["../data/arabas_et_al-f1.dat"], "record_dir": "./analyzer_test_data", "log_path": "./analyzer_test_data/benchmark.log" } functions = { "ADD": "+", "SUB": "-", "MUL": "*", "DIV": "/", "POW": "**", "SIN": "math.sin", "COS": "math.cos", "RAD": "math.radians", "LN": "math.ln", "LOG": "math.log" } brute_parameter_sweep(test_parameters, functions, gp_benchmark_loop)
def test_brute_parameter_sweep(self): config = { "call_path": unittest_root, "max_population": None, "max_generation": 10, "tree_generation": { "method": "RAMPED_HALF_AND_HALF_METHOD", "depth_ranges": [ {"size": 4, "percentage": 0.25}, {"size": 3, "percentage": 0.25}, {"size": 2, "percentage": 0.25}, {"size": 1, "percentage": 0.25}, ], }, "evaluator": {"use_cache": True}, "selection": {"method": "ELITEST_SELECTION"}, "crossover": {"method": "POINT_CROSSOVER", "probability": None}, "mutation": {"methods": ["SUBTREE_MUTATION"], "probability": None}, "function_nodes": [ {"type": "FUNCTION", "name": "ADD", "arity": 2}, {"type": "FUNCTION", "name": "SUB", "arity": 2}, {"type": "FUNCTION", "name": "MUL", "arity": 2}, {"type": "FUNCTION", "name": "DIV", "arity": 2}, {"type": "FUNCTION", "name": "COS", "arity": 1}, {"type": "FUNCTION", "name": "SIN", "arity": 1}, ], "terminal_nodes": [ {"type": "CONSTANT", "value": 0.0}, {"type": "CONSTANT", "value": 1.0}, {"type": "CONSTANT", "value": 2.0}, {"type": "CONSTANT", "value": 2.0}, {"type": "CONSTANT", "value": 3.0}, {"type": "CONSTANT", "value": 4.0}, {"type": "CONSTANT", "value": 5.0}, {"type": "CONSTANT", "value": 6.0}, {"type": "CONSTANT", "value": 7.0}, {"type": "CONSTANT", "value": 8.0}, {"type": "CONSTANT", "value": 9.0}, {"type": "CONSTANT", "value": 10.0}, ], "data_file": None, "input_variables": [{"type": "INPUT", "name": "var1"}], "response_variables": [{"name": "answer"}], "recorder": {"store_file": None, "record_level": "MIN", "compress": True}, } test_parameters = { "play_config": config, "random_seeds": [10, 20], "iterations": 2, "processes": 1, "population_size": {"range": [100]}, "crossover_probability": {"range": [0.80]}, "mutation_probability": {"range": [0.10]}, "training_data": ["data/arabas_et_al-f1.dat"], "record_dir": "/tmp/unittest", "log_path": "/tmp/unittest/benchmark.log", } tuner.brute_parameter_sweep(test_parameters, self.functions, gp_benchmark_loop) # asserts self.assertTrue(os.path.isfile(test_parameters["log_path"])) # test exception test_parameters["random_seeds"] = range(0) self.assertRaises(RuntimeError, tuner.brute_parameter_sweep, test_parameters, self.functions, gp_benchmark_loop)
0.75, 0.80, # 0.85, # 0.90, # 0.95, # 1.00 ] }, "training_data": [ "training_data/arabas_et_al-f1.dat" ], "record_dir": "$HOME/data", "log_path": "$HOME/data/f1.log" } functions = { "ADD": "+", "SUB": "-", "MUL": "*", "DIV": "/", "POW": "**", "SIN": "math.sin", "COS": "math.cos", "RAD": "math.radians", "LN": "math.ln", "LOG": "math.log" } brute_parameter_sweep(test_parameters, functions, gp_benchmark_loop)