def default_mcts_parameters(): parameters = MctsParameters() parameters.DISCOUNT_FACTOR = 0.9 parameters.RANDOM_SEED = 1000 parameters.MAX_SEARCH_TIME = 1000 parameters.MAX_NUMBER_OF_ITERATIONS = 10000 parameters.MAX_SEARCH_DEPTH = 1000 parameters.MAX_NUMBER_OF_NODES = 10000 parameters.random_heuristic.MAX_SEARCH_TIME = 10 parameters.random_heuristic.MAX_NUMBER_OF_ITERATIONS = 1000 parameters.uct_statistic.LOWER_BOUND = -1000 parameters.uct_statistic.UPPER_BOUND = 100 parameters.uct_statistic.EXPLORATION_CONSTANT = 0.7 parameters.uct_statistic.PROGRESSIVE_WIDENING_ALPHA = 0.2 parameters.uct_statistic.PROGRESSIVE_WIDENING_K = 0.1 parameters.hypothesis_statistic.COST_BASED_ACTION_SELECTION = True parameters.hypothesis_statistic.PROGRESSIVE_WIDENING_HYPOTHESIS_BASED = True parameters.hypothesis_statistic.LOWER_COST_BOUND = 0 parameters.hypothesis_statistic.UPPER_COST_BOUND = 1 parameters.hypothesis_statistic.PROGRESSIVE_WIDENING_ALPHA = 0.5 parameters.hypothesis_statistic.PROGRESSIVE_WIDENING_K = 1 parameters.hypothesis_statistic.EXPLORATION_CONSTANT = 0.7 parameters.hypothesis_belief_tracker.RANDOM_SEED_HYPOTHESIS_SAMPLING = 1000 parameters.hypothesis_belief_tracker.HISTORY_LENGTH = 4 parameters.hypothesis_belief_tracker.PROBABILITY_DISCOUNT = 1.0 parameters.hypothesis_belief_tracker.POSTERIOR_TYPE = HypothesisBeliefTracker.PosteriorType.PRODUCT return parameters
def test_pickle_unpickle(self): from mamcts import MctsParameters, HypothesisBeliefTracker from mamcts import CrossingStateDefaultParametersFloat, CrossingStateDefaultParametersInt params_mcts = MctsParameters() params_mcts.DISCOUNT_FACTOR = 0.9 params_mcts.RANDOM_SEED = 1000 params_mcts.MAX_SEARCH_TIME = 1232423 params_mcts.MAX_NUMBER_OF_ITERATIONS = 2315677 params_mcts.random_heuristic.MAX_SEARCH_TIME = 10 params_mcts.random_heuristic.MAX_NUMBER_OF_ITERATIONS = 1000 params_mcts.uct_statistic.LOWER_BOUND = -1000 params_mcts.uct_statistic.UPPER_BOUND = 100 params_mcts.uct_statistic.EXPLORATION_CONSTANT = 0.7 params_mcts.hypothesis_statistic.COST_BASED_ACTION_SELECTION = True params_mcts.hypothesis_statistic.PROGRESSIVE_WIDENING_HYPOTHESIS_BASED = True params_mcts.hypothesis_statistic.LOWER_COST_BOUND = 0 params_mcts.hypothesis_statistic.UPPER_COST_BOUND = 1 params_mcts.hypothesis_statistic.PROGRESSIVE_WIDENING_ALPHA = 0.5 params_mcts.hypothesis_statistic.PROGRESSIVE_WIDENING_K = 1 params_mcts.hypothesis_statistic.EXPLORATION_CONSTANT = 0.7 params_mcts.hypothesis_belief_tracker.RANDOM_SEED_HYPOTHESIS_SAMPLING = 1000 params_mcts.hypothesis_belief_tracker.HISTORY_LENGTH = 4 params_mcts.hypothesis_belief_tracker.PROBABILITY_DISCOUNT = 1.0 params_mcts.hypothesis_belief_tracker.POSTERIOR_TYPE = HypothesisBeliefTracker.PosteriorType.PRODUCT params_mcts.hypothesis_belief_tracker.FIXED_HYPOTHESIS_SET = { 1: 5, 10: 4, 3: 100 } params_mcts_unpickle = pu(params_mcts) self.assertTrue(is_equal_mcts_params(params_mcts, params_mcts_unpickle)) params_crossing_state = CrossingStateDefaultParametersFloat() params_crossing_state_unpickle = pu(params_crossing_state) self.assertTrue( is_equal_crossing_state_params(params_crossing_state, params_crossing_state_unpickle)) params_crossing_state = CrossingStateDefaultParametersInt() params_crossing_state_unpickle = pu(params_crossing_state) self.assertTrue( is_equal_crossing_state_params(params_crossing_state, params_crossing_state_unpickle))