Exemple #1
0
def setup_func():
    global T, tv, nb_trees, tree_list, mtg_name, g
    # build some random initial tree
    stat_tool.plot.DISABLE_PLOT = True
    inf_bound = 0
    sup_bound = 3
    distrib = stat_tool.Uniform(inf_bound, sup_bound)
    max_depth = 3
    max_size = 10
    nbtrees = 40
    # define a set of trees
    tree_list = []
    tv = [1., 0, 1, 2.]  # trees.TreeValue([1., 0])
    R = trees.TreeStructure(distrib, max_size, max_depth)
    tmp_tree = trees.Tree(tv, R)
    n = 1
    tree_list.append(trees.Tree(tmp_tree))
    while n < nbtrees:
        n = n + 1
        R.Simulate(distrib, max_size, max_depth)
        tmp_tree = trees.Tree(tv, R)
        tree_list.append(trees.Tree(tmp_tree))
    distrib_list = []
    for i in range(tmp_tree.NbInt()):
        distrib_list.append(distrib)
    for n in range(len(tree_list)):
        tree_list[n].Simulate(distrib_list)
    T = trees.Trees(tree_list)
    nb_trees = nbtrees
    mtg_name = "data/sample_mtg_forest.mtg"
    g = build_mtg()

    return T, tv, nb_trees, tree_list, mtg_name, g
def init():
    """Defines some constants"""
    global distrib, max_depth, max_size, nbtrees, n
    stat_tool.plot.DISABLE_PLOT = True
    inf_bound = 1
    sup_bound = 3
    distrib = stat_tool.Uniform(inf_bound, sup_bound)
    nbtrees = 40
    max_depth = 3
    max_size = 20
    n = 5
# -*- coding: utf-8 -*-
# comparison of the outputs for the Sequences and Trees classes
import sys, os
import openalea.stat_tool as stat_tool
import openalea.tree_statistic.trees as trees
import openalea.tree_statistic.hmt as hmt
import openalea.sequence_analysis as aml
nb_children=1
size=100
distrib = stat_tool.Uniform(1, 1)
# name of 
hmotrefpath= "./hmot_np.hmt";
hmotinitpath= "./hmot_np_init.hmt";
hmcinitpath= "./hmc_init.hmc";
HMT=hmt.HiddenMarkovIndOutTree(hmotrefpath)
HMTI=hmt.HiddenMarkovIndOutTree(hmotinitpath)
HMCI=aml.HiddenSemiMarkov(hmcinitpath)
T=HMT.Simulate(2, size, nb_children)
# delete state variable
T=T.SelectVariable(1, "Keep")
# build sequence from T
S=T.BuildPySequences()
# S = S.markovian_sequences()

# Print Sequences object
print S
# Print Trees object
print T

# Display sequence object
print(S.display())
Exemple #4
0
class MyThread(QThread):
    def __init__(self):
        QThread.__init__(self)
    
    def doit(self, T):
        app = QApplication([])
        T.Plot()
        #self.start()
        #app.exec_()


stat_tools.plot.DISABLE_PLOT = True

inf_bound=0
sup_bound=3
distrib = stat_tools.Uniform(inf_bound, sup_bound)
print "Distribution used for the number of children and the tree attributes:"
print distrib
max_depth=3
max_size=10
nbtrees=40
# define a set of trees
tree_list=[]
tv=[1., 0, 1, 2.] # trees.TreeValue([1., 0])
R=trees.TreeStructure(distrib, max_size, max_depth)
tmp_tree=trees.Tree(tv, R)
n=1
tree_list.append(trees.Tree(tmp_tree))
while n < nbtrees:
    n=n+1
    R.Simulate(distrib, max_size, max_depth)
# -*- coding: utf-8 -*-
# a test for the class trees.Trees: tree manipulation (merge, cluster, etc.)
import sys, os
import openalea.stat_tool as stat_tool
import openalea.tree_statistic.trees as trees
inf_bound = 1
sup_bound = 3
probability = 0.6
children_distrib = stat_tool.Uniform(inf_bound, sup_bound)
# distribution of the children
attributes_distrib = stat_tool.Uniform(0, 10)
# distribution of the attributes
max_depth = 3
max_size = 10
nbtrees = 2
# defining a set of trees
tree_list = []
# simulation of the structure
R = trees.TreeStructure(children_distrib, max_size, max_depth)
tmp_tree = trees.Tree([1., 0], R)
n = 1
tree_list.append(trees.Tree(tmp_tree))
while n < nbtrees:
    n = n+1
    R.Simulate(children_distrib, max_size, max_depth)
    tmp_tree = trees.Tree([1., 0], R)
    tree_list.append(trees.Tree(tmp_tree))

distrib_list = []
# simulation of the labels
for i in range(tmp_tree.NbInt()):