Пример #1
0
def test_track(silent=True, precision='d', decimals=80):
    """
    Tests the path tracking on a small random system.
    Two random trinomials are generated and random constants
    are added to ensure there are no singular solutions
    so we can use this generated system as a start system.
    The target system has the same monomial structure as
    the start system, but with random real coefficients.
    Because all coefficients are random, the number of
    paths tracked equals the mixed volume of the system.
    """
    from solver import random_trinomials, real_random_trinomials
    from solver import solve, mixed_volume, newton_step
    pols = random_trinomials()
    real_pols = real_random_trinomials(pols)
    from random import uniform as u
    qone = pols[0][:-1] + ('%+.17f' % u(-1, +1)) + ';'
    qtwo = pols[1][:-1] + ('%+.17f' % u(-1, +1)) + ';'
    rone = real_pols[0][:-1] + ('%+.17f' % u(-1, +1)) + ';'
    rtwo = real_pols[1][:-1] + ('%+.17f' % u(-1, +1)) + ';'
    start = [qone, qtwo]
    target = [rone, rtwo]
    start_sols = solve(start, silent)
    sols = track(target, start, start_sols, precision, decimals)
    mixvol = mixed_volume(target)
    print 'mixed volume of the target is', mixvol
    print 'number of solutions found :', len(sols)
    newton_step(target, sols, precision, decimals)
Пример #2
0
def main():
    """
    Launches one server and clients on the
    same computer.
    """
    clorsv = raw_input("client or server ? (type c or s) ")
    if clorsv == 'c':
        client()
    else:
        import solver
        if clorsv == 's':
            nbsys = input('-> how many systems ? ')
            probs = [solver.random_trinomials() for i in range(0, nbsys)]
            nbclt = input('-> how many clients ? ')
            start_server(probs, nbclt)
        else:
            print 'sorry, expected c or s, please try again'
Пример #3
0
def main():
    """
    Launches one server and clients on the
    same computer.
    """
    clorsv = raw_input("client or server ? (type c or s) ")
    if clorsv == 'c':
        client()
    else:
        import solver
        if clorsv == 's':
            nbsys = input('-> how many systems ? ')
            probs = [solver.random_trinomials() for i in range(0, nbsys)]
            nbclt = input('-> how many clients ? ')
            start_server(probs, nbclt)
        else:
            print 'sorry, expected c or s, please try again'
Пример #4
0
def test():
    """
    Generates a random trinomial system,
    solves it, converts the solutions,
    and then sums the multiplicities.
    """
    import solver
    pols = solver.random_trinomials()
    sols = solver.solve(pols)
    dsols = [strsol2dict(sol) for sol in sols]
    mult = 0
    s0d = strsol2dict(sols[0])
    print 'variables :', variables(s0d)
    print evaluate(pols, s0d)
    for sol in dsols:
        mult  = mult + sol['m']
    print 'sum of multiplicities :', mult
    print 'sum of values at the solutions :'
    for sol in dsols:
        print sum(evaluate(pols, sol))
Пример #5
0
def test():
    """
    Generates a random trinomial system,
    solves it, converts the solutions,
    and then sums the multiplicities.
    """
    import solver
    pols = solver.random_trinomials()
    sols = solver.solve(pols)
    dsols = [strsol2dict(sol) for sol in sols]
    mult = 0
    s0d = strsol2dict(sols[0])
    print 'variables :', variables(s0d)
    print evaluate(pols, s0d)
    for sol in dsols:
        mult = mult + sol['m']
    print 'sum of multiplicities :', mult
    print 'sum of values at the solutions :'
    for sol in dsols:
        print sum(evaluate(pols, sol))