示例#1
0
### use_combo: weather to use Bayesian optimisation or not in combination with Monte Carlo tree search.
# COMBO package is used to engineer the palyout instead of random selection.
### combo_play_out: total number of candidates to be examind by COMBO.
### combo_init_random: the initial random selection for Bayesian optimisation. Default is 1
### combo_step: the interval for Bayesian optimisation to perfrom hyperparameter optimization. Default is 1
### combo_lvl: the level of the tree at which start to apply Bayesian optimisation. Default is 1 (apply at all levels)

myTree = mdts.Tree(no_positions=16,
                   atom_types=[0, 1],
                   atom_const=[8, 8],
                   get_reward=get_reward,
                   positions_order=range(16),
                   max_flag=True,
                   expand_children=2,
                   play_out=5,
                   play_out_selection="best",
                   space=None,
                   candidate_pool_size=100,
                   ucb="mean",
                   use_combo=True,
                   combo_play_out=20,
                   combo_init_random=5,
                   combo_step=5,
                   combo_lvl=5)

### Start the search for certain number of candidates and returns an object of type Result contains the result of the search
res = myTree.search(display=True, no_candidates=500)

### Optimal reward
print res.optimal_fx
myTree = mdts.Tree(
    no_positions=
    14,  # number of positions in each structure. For example, 16 atoms.
    atom_types=[
        0, 1
    ],  # atom types. For example, types of atoms: 0 for Si and 1 for Ge.
    atom_const=[
        7, 7
    ],  # number of each atom type in the structure. For example, 8 atoms Si and 8 atoms Ge.
    get_reward=get_reward,  # the experiment simulation function.
    positions_order=list(
        range(14)
    ),  # define the order to assign atoms to the positions in the structure.
    max_flag=
    False,  # if True the algorithm searches for maximum reward, else for minimum.
    expand_children=
    2,  # number of children to expand at each node, 1 means expand one child at a time.
    play_out=5,  # number of play outs et each node.
    play_out_selection=
    "best",  # when performing multiple playouts, best or mean is returned.
    space=None,  # numpy ndarray representing the candidates space. 
    candidate_pool_size=100,
    ucb="mean",  # taking either average or best ucb score for MC tree search.
    use_combo=
    False,  # weather to use Bayesian optimisation or not in combination with MC tree search.
    combo_play_out=20,  # total number of candidates to be examind by COMBO.
    combo_init_random=
    5,  # the initial random selection for Bayesian optimisation.
    combo_step=
    5,  # the interval for Bayesian optimisation to perfrom hyperparameter optimization.
    combo_lvl=5
)  # the level of the tree at which start to apply Bayesian optimisation.
示例#3
0
### combo_lvl: the level of the tree at which start to apply Bayesian optimisation. Default is 1 (apply at all levels)
### combo_init_random: the initial random selection for Bayesian optimisation. Default is 1
### combo_step: the interval for Bayesian optimisation to perfrom hyperparameter optimization. Default is 1
### combo_play_out: total number of candidates to be examind by COMBO.
### use_XP: Whether to use neural network expansion policy in combination with MCTS or not (you may use both combo and XP together too)
### XP_batch_size: the size of the batch to be used to train the neural network

myTree = mdts.Tree(no_positions=16,
                   position_values=[0, 1],
                   position_values_const=[8, 8],
                   positions_order=list(range(16)),
                   max_flag=True,
                   get_reward=get_reward,
                   constraints=None,
                   expand_children=1,
                   play_out=1,
                   play_out_selection="best",
                   use_combo=False,
                   candidate_pool_size=100,
                   combo_lvl=1,
                   combo_init_random=5,
                   combo_step=5,
                   combo_play_out=20,
                   use_XP=False,
                   XP_batch_size=50)

### Start the search for certain number of candidates and returns an object of type Result contains the result of the search
res = myTree.search(display=True, no_candidates=500)

# ### Optimal reward
print(res.optimal_fx)
示例#4
0
文件: test2.py 项目: AspirinCode/MDTS
        t_thickness += bil_thick[j][0]
        thickness.append(bil_thick[j][1])
        t_thickness += bil_thick[j][1]

    return thickness, t_thickness


myTree = mdts.Tree(no_positions=20,
                   atom_types=list(range(1521)),
                   atom_const=None,
                   get_reward=simul_ref,
                   positions_order="direct",
                   max_flag=True,
                   expand_children=2,
                   play_out=1,
                   play_out_selection="best",
                   space=None,
                   candidate_pool_size=100,
                   ucb="mean",
                   use_combo=False,
                   combo_play_out=20,
                   combo_init_random=5,
                   combo_step=5,
                   combo_lvl=5)

res = myTree.search_PG(display=True,
                       no_candidates=100)  # apply MCTS search with PG

#res=myTree.search(display=True,no_candidates=20000)# apply MCTS search without PG

### Optimal reward