Exemplo n.º 1
0
    while (not done):
        yield valeurs
        done = True
        for k in valeurs:
            if (sauf.has_key(k)):
                continue
            if (valeurs[k] < bornes[k] - 1):
                valeurs[k] += 1
                done = False
                break
            else:
                valeurs[k] = 0


if __name__ == "__main__":
    pyAgrum_header(2011)

    print "#### ITERATION ON 3 VARIABLES #####"
    for i in multidim_generator(dict(x=4, y=3, z=2)):
        print i

    print "#### ITERATION ON Y AND Z (X=3) #####"
    for i in multidim_generator(dict(x=4, y=3, z=2), dict(x=3)):
        print i

    print "#### ITERATION ON X AND Y (Z=1) #####"
    for i in multidim_generator(dict(x=4, y=3, z=2), dict(z=1)):
        print i

    print "#### ITERATION ON Y (X=1 and Z=0) #####"
    for i in multidim_generator(dict(x=4, y=3, z=2), dict(x=1, z=0)):
Exemplo n.º 2
0
    defines help viewed if args are not OK on command line, and exit with exit_value
    """
    print os.path.basename(sys.argv[0]),"src.{"+gum.availableBNExts()+"}"
    sys.exit(exit_value)
    
def doLoadBN(s):
    # you could simply do that 
    # bn=gum.loadBN("test")
    # but listeners are fun !!
    
    title=os.path.basename(s)+" ("+'{0:,d}'.format(os.path.getsize(s)/1024).replace(',',' ')+" Ko)"
    progressbar=ProgressBar(title,0,100,mode='dynamic', char='-')
    
    def local_update(pourcent):
        progressbar.update_amount(pourcent)
        progressbar.display()
        if pourcent==100: print
    
    return gum.loadBN(s,local_update)
    

if __name__=="__main__":
    pyAgrum_header(2012)

    if len(sys.argv)<2:
            module_help()

    bn=doLoadBN(sys.argv[1])
    print(bn)
    
    
Exemplo n.º 3
0
    """
    print os.path.basename(sys.argv[0]), "src.{" + gum.availableBNExts() + "}"
    sys.exit(exit_value)


def doLoadBN(s):
    # you could simply do that
    # bn=gum.loadBN("test")
    # but listeners are fun !!

    title = os.path.basename(s) + " (" + '{0:,d}'.format(
        os.path.getsize(s) / 1024).replace(',', ' ') + " Ko)"
    progressbar = ProgressBar(title, 0, 100, mode='dynamic', char='-')

    def local_update(pourcent):
        progressbar.update_amount(pourcent)
        progressbar.display()
        if pourcent == 100: print

    return gum.loadBN(s, local_update)


if __name__ == "__main__":
    pyAgrum_header(2012)

    if len(sys.argv) < 2:
        module_help()

    bn = doLoadBN(sys.argv[1])
    print(bn)
Exemplo n.º 4
0
#thereof, including modifications, that you make.

#THE AUTHOR P.H. WUILLEMIN  DISCLAIMS ALL WARRANTIES
#WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
#WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
#SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT
#OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
#RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
#IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
#ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
#OR PERFORMANCE OF THIS SOFTWARE!

import pyAgrum as gum
from gumLib.pyAgrum_header import pyAgrum_header

pyAgrum_header(2011)

bn=gum.loadBN("bn.bif")

print bn.variable(0).name()
# a

print bn.cpt(0)[{'e':0,'f':1}]
# [ 0.0250064  0.974994 ]

bn.cpt(0)[{'e':0,'f':1}]=[1,0]
print bn.cpt(0)[{'e':0,'f':1}]
# [ 1. 0. ]

bn.cpt(0)[{'a':0, 'e':0,'f':1}]=12
print bn.cpt(0)[{'e':0,'f':1}]