예제 #1
0
    def run():
        import copy
        search_space_obj = SearchSpace()

        search_space = GetDefaultConfig.get_default_config().get("domain_config").get("search_space")

        PopulateSearchSpace.populate_search_space(search_space_obj, search_space)
        population = Population(5, 5, 1, search_space_obj=search_space_obj)

        tree_to_mutate = copy.deepcopy(population.trees[0])
        child_function_mutation = Mutation.weighted_function_mutation(tree_to_mutate, 1, search_space_obj)
        child_literal_mutation = Mutation.mutate_value_literal_nodes(child_function_mutation, 1)
        child_leaf_mutation = Mutation.mutate_leaf_node(child_literal_mutation, 1, search_space_obj)
        child_shrink_mutation = Mutation.shrink_mutation(child_leaf_mutation, 1, search_space_obj)
        child_hoist_mutation = Mutation.hoist_mutation(child_shrink_mutation, 1)
        child_literal_swap_mutation = Mutation.literal_swap_mutation(child_hoist_mutation, 1, search_space_obj)

        trees_to_vis = []
        trees_to_vis.append(tree_to_mutate)
        trees_to_vis.append(child_function_mutation)
        trees_to_vis.append(child_literal_mutation)
        trees_to_vis.append(child_leaf_mutation)
        trees_to_vis.append(child_shrink_mutation)
        trees_to_vis.append(child_hoist_mutation)
        trees_to_vis.append(child_literal_swap_mutation)

        Visualize.visualize(trees_to_vis)
예제 #2
0
    def __init__(self, DomainNetworkConstructionClass, DataGeneratorClass):

        config = ArgumentParser.add_parser()
        default_config = GetDefaultConfig.get_default_config()
        self.conf = Overlayer.overlay_configs(default_config, config)

        self.domain_config = self.conf.get("domain_config")
        self.domain_name = self.domain_config.get("domain")
        self.studio_config = self.conf.get("studio_config")
        self.evaluator_config = self.domain_config.get("evaluator_specs")

        self.search_space = self.domain_config.get("search_space")

        print(
            f"################################# Evolf is currently Running on {self.domain_name}"
        )
        self.data_config = self.evaluator_config.get("data_config")

        self.model_generation_config = self.domain_config.get(
            "model_generation")

        data_generator_object = DataGeneratorClass(self.data_config)
        predictors, labels = data_generator_object.get_data()
        self.data_dict = data_generator_object.process_data(predictors, labels)

        generate_model = self.model_generation_config.get("generate_model")
        if generate_model:
            network_constructor = DomainNetworkConstructionClass(
                self.data_dict.get("input_shape"),
                self.model_generation_config)
            network_constructor.model = network_constructor.create_model()
            network_constructor.compile_model()
            network_constructor.save_model()

        self.search_space_obj = SearchSpace()
        self.search_space_obj = PopulateSearchSpace.populate_search_space(
            self.search_space_obj, self.search_space)
        super().__init__(self.conf, self.data_dict, self.search_space_obj)
예제 #3
0
        "neg_scalar": 1
    },
    "R": {
        "mean": 1
    }
}

pickled_search_space = pickle.dumps(search_space)

# Initialize Search Space
url = "http://127.0.0.1:5000/init"
response = requests.post(url=url, data=pickled_search_space)

# Request initial Population
url = "http://127.0.0.1:5000/request_inital_population"

population_config = {"min_height": 3, "max_height": 5, "population_size": 100}

population_config_bytes = pickle.dumps(population_config)
response = requests.post(url=url, data=population_config_bytes)
population_bytes = response._content
deserialized_population = pickle.loads(population_bytes)

search_space_obj = SearchSpace()
search_space_obj = PopulateSearchSpace.populate_search_space(
    search_space_obj, search_space)
population_deserializer = PopulationSerializer(deserialized_population,
                                               search_space_obj)
pop_obj = population_deserializer.deserialize()

[print(tree.symbolic_expression) for tree in pop_obj.trees]
예제 #4
0
from search_space.search_space import SearchSpace
from framework.population.population import Population

fl = SearchSpace()
population = Population(3, 3, 10, search_space_obj=fl)

tree = population.working_trees[0]

print(f"{tree.binary_count}, {tree.unary_count}, {tree.literal_count}, {tree.height}")
print(tree.nodes[0].node_id)
print(tree.nodes[0].operator_type)
# print(f"{tree.nodes}")
tree.reset_tree()
# print(f"{tree.nodes}")
print(f"{tree.binary_count}, {tree.unary_count}, {tree.literal_count}, {tree.height}")
print(tree.nodes[0].node_id)
print(tree.nodes[0].operator_type)
예제 #5
0
    model_path = './model_2d.pkl'

    # obstacles
    raw_obs, vertices_obs, encoded_obs = LoadDataset.load_obs_data(obs_index)

    Obstacles = vertices_obs

    x_init, x_goal = LoadDataset.load_init_goal(obs_index)

    print('init: ({:+.10f}, {:+.10f}, {:+.10f})'.format(
        x_init[0], x_init[1], x_init[2]))
    print('goal: ({:+.10f}, {:+.10f}, {:+.10f})'.format(
        x_goal[0], x_goal[1], x_goal[2]))

    # create search space
    X = SearchSpace(X_dimensions, Obstacles)
    nn_rrt, nn_path, nn_step, nn_cost_time = nn_rrt_star_bid(
        X, Q, x_init, x_goal, encoded_obs, max_samples, num_attempt, r,
        model_path, prc, rewire_count)
    rc_rrt, rc_path, rc_step, rc_cost_time = rrt_connect(
        X, Q_rt, x_init, x_goal, max_samples, r, prc)
    rs_rrt, rs_path, rs_step, rs_cost_time = rrt_star(X, Q, x_init, x_goal,
                                                      max_samples, r, prc,
                                                      rewire_count)

    print('\nStep: nn: {}, rc: {}, rs: {}'.format(nn_step, rc_step, rs_step))
    print('Time: nn: {:.10f}, rc: {:.10f}, rs: {:.10f}'.format(
        nn_cost_time, rc_cost_time, rs_cost_time))

    # plot
    paths = [nn_path, rc_path, rs_path]