| Hosted by CoCalc | Download
# Import Polyhedral Omega from lds import * from util import * from geometry import * # Import time for timing from time import * # Define a function to help choose data for the demo def runPO(A, b, E, decomposition=True, parallelepipeds=True, rationalfunction=True, output=False): lds = LinearDiophantineSystem(A, b, E) print "A:" for row in lds._A: print row if decomposition == True: print "Computing cones" t1=time() cones = lds.symbolic_cones() t2=time() print "Cones computation took: ", t2-t1, " secs for ", len(cones), " cones" if parallelepipeds == True: print "Computing parallelepipeds" t3=time() pis = lds.fundamental_parallelepipeds() t4=time() print "Parallelepipeds computation took: ", t4-t3, " secs" if rationalfunction == True: print "Computing rational functions" t5=time() r = lds.rational_function_string() t6=time() print "Rational function computation took: ", t6-t5, " secs" if output == True: print "Symbolic Cones:" for c in cones: print(c) return cones, pis,r
Error in lines 1-1 Traceback (most recent call last): File "/cocalc/lib/python3.11/site-packages/smc_sagews/sage_server.py", line 1244, in execute exec( File "", line 1, in <module> File "/home/user/lds.py", line 46 print "iteration %d of %d: %d cones (%.2f%% of theoretical maximum %d) " % (i,len(E),num_cones,float(num_cones/max_cones)*100,max_cones) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
A = [] b = [] E= [] P = polytopes.Birkhoff_polytope(3) print(P.inequalities_list()) for i in P.inequalities_list(): A.append(i[1:]) b.append(-i[1]) E.append(0) for i in P.equations_list(): A.append(i[1:]) b.append(-i[1]) E.append(1) #print(A) #print(b) #print(E) runPO(A,b,E) cones
[[0, 0, -1, 0, 0, 0, 1, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, -1, 0, -1, 0, 0, 0], [1, 0, 1, 0, -1, 0, -1, 0, 0, -1], [1, 0, 0, 0, 0, 0, -1, 0, 0, -1], [0, 0, -1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0]] A: [0, -1, 0, 0, 0, 1, 0, 0, 1] [0, 0, 0, 0, 0, 0, 0, 0, 1] [0, 0, 0, -1, 0, -1, 0, 0, 0] [0, 1, 0, -1, 0, -1, 0, 0, -1] [0, 0, 0, 0, 0, -1, 0, 0, -1] [0, -1, 0, 1, 0, 1, 0, 0, 0] [0, 0, 0, 0, 0, 1, 0, 0, 0] [0, 0, 0, 1, 0, 0, 0, 0, 0] [0, 1, 0, 0, 0, 0, 0, 0, 0] [0, 0, 0, 1, 1, 1, 0, 0, 0] [1, 1, 0, 0, 0, -1, 0, 0, -1] [0, 1, 0, -1, 0, -1, -1, 0, -1] [0, 0, 1, 0, 0, 1, 0, 0, 1] [0, 1, 0, -1, 0, -1, 0, 1, 0] Computing cones Cones computation took: 0.00887894630432 secs for 0 cones Computing parallelepipeds Parallelepipeds computation took: 4.05311584473e-06 secs Computing rational functions Rational function computation took: 3.09944152832e-06 secs (, {}, '0') 1 * [ Cone: generators = ((1, -1, 0), (1, 0, -1)), apex = (10, 0, 0), openness = (1, 1) ] + 1 * [ Cone: generators = ((0, 1, -1), (1, 0, -1)), apex = (0, 0, 10), openness = (0, 0) ] + -1 * [ Cone: generators = ((0, 1, -1), (1, -1, 0)), apex = (0, 10, 0), openness = (1, 0) ]
A = ( (1,-1) ) b = ( 0, ) E = [ 0 ] runPO(A,b,E)
A: 1 -1 Computing cones Cones computation took: 0.000303983688354 secs for 2 cones Computing parallelepipeds Parallelepipeds computation took: 0.00177907943726 secs Computing rational functions Rational function computation took: 5.81741333008e-05 secs (1 * [ Cone: generators = ((0, 1), (1, 0)), apex = (0, 0), openness = (0, 0) ] + -1 * [ Cone: generators = ((0, 1), (1, 1)), apex = (0, 0), openness = (1, 0) ] , {[ Cone: generators = ((0, 1), (1, 0)), apex = (0, 0), openness = (0, 0) ]: [(0, 0)], [ Cone: generators = ((0, 1), (1, 1)), apex = (0, 0), openness = (1, 0) ]: [(0, 1)]}, '1*(z0**0*z1**0)/((1-z0**0*z1**1)*(1-z0**1*z1**0))+-1*(z0**0*z1**1)/((1-z0**0*z1**1)*(1-z0**1*z1**1))')
A = ( (1,1,1),(1,1,1),(1,1,1) ) b = ( 10,10,10) E = [ 1,1,1] cones, pis,r = runPO(A,b,E) P = PolynomialRing(QQ,["z0","z1","z2"]) print P F = P.fraction_field() print F print r rr = F(r) sr = SR(rr) sr.parent() var("z0,z1,z2") print sr print sr(1,1,1) #sr.series(z0==0,2)
A: (1, 1, 1) (1, 1, 1) (1, 1, 1) Computing cones Cones computation took: 0.000964879989624 secs for 3 cones Computing parallelepipeds Parallelepipeds computation took: 0.00580501556396 secs Computing rational functions Rational function computation took: 8.10623168945e-05 secs Multivariate Polynomial Ring in z0, z1, z2 over Rational Field Fraction Field of Multivariate Polynomial Ring in z0, z1, z2 over Rational Field 1*(z0**12*z1**-1*z2**-1)/((1-z0**1*z1**-1*z2**0)*(1-z0**1*z1**0*z2**-1))+1*(z0**0*z1**0*z2**10)/((1-z0**0*z1**1*z2**-1)*(1-z0**1*z1**0*z2**-1))+-1*(z0**0*z1**11*z2**-1)/((1-z0**0*z1**1*z2**-1)*(1-z0**1*z1**-1*z2**0)) Symbolic Ring (z0, z1, z2) z0^10 + z0^9*z1 + z0^8*z1^2 + z0^7*z1^3 + z0^6*z1^4 + z0^5*z1^5 + z0^4*z1^6 + z0^3*z1^7 + z0^2*z1^8 + z0*z1^9 + z1^10 + z0^9*z2 + z0^8*z1*z2 + z0^7*z1^2*z2 + z0^6*z1^3*z2 + z0^5*z1^4*z2 + z0^4*z1^5*z2 + z0^3*z1^6*z2 + z0^2*z1^7*z2 + z0*z1^8*z2 + z1^9*z2 + z0^8*z2^2 + z0^7*z1*z2^2 + z0^6*z1^2*z2^2 + z0^5*z1^3*z2^2 + z0^4*z1^4*z2^2 + z0^3*z1^5*z2^2 + z0^2*z1^6*z2^2 + z0*z1^7*z2^2 + z1^8*z2^2 + z0^7*z2^3 + z0^6*z1*z2^3 + z0^5*z1^2*z2^3 + z0^4*z1^3*z2^3 + z0^3*z1^4*z2^3 + z0^2*z1^5*z2^3 + z0*z1^6*z2^3 + z1^7*z2^3 + z0^6*z2^4 + z0^5*z1*z2^4 + z0^4*z1^2*z2^4 + z0^3*z1^3*z2^4 + z0^2*z1^4*z2^4 + z0*z1^5*z2^4 + z1^6*z2^4 + z0^5*z2^5 + z0^4*z1*z2^5 + z0^3*z1^2*z2^5 + z0^2*z1^3*z2^5 + z0*z1^4*z2^5 + z1^5*z2^5 + z0^4*z2^6 + z0^3*z1*z2^6 + z0^2*z1^2*z2^6 + z0*z1^3*z2^6 + z1^4*z2^6 + z0^3*z2^7 + z0^2*z1*z2^7 + z0*z1^2*z2^7 + z1^3*z2^7 + z0^2*z2^8 + z0*z1*z2^8 + z1^2*z2^8 + z0*z2^9 + z1*z2^9 + z2^10 66
A = ( (1,1,1),(1,1,1),(1,1,1) ) b = ( 10,10,10) E = [ 1,1,1] cones, pis,r = runPO(A,b,E) for c in cones: print(c)
A: (1, 1, 1) (1, 1, 1) (1, 1, 1) Computing cones Cones computation took: 0.00120496749878 secs for 3 cones Computing parallelepipeds Parallelepipeds computation took: 0.00563383102417 secs Computing rational functions Rational function computation took: 7.5101852417e-05 secs [ Cone: generators = ((1, -1, 0), (1, 0, -1)), apex = (10, 0, 0), openness = (1, 1) ] [ Cone: generators = ((0, 1, -1), (1, 0, -1)), apex = (0, 0, 10), openness = (0, 0) ] [ Cone: generators = ((0, 1, -1), (1, -1, 0)), apex = (0, 10, 0), openness = (1, 0) ]
A = ( (1,1,1),(1,1,1),(1,1,1) ) b = ( 10,10,10) E = [ 0,0,0] cones, pis,r = runPO(A,b,E) for c in cones: print(c)
A: (1, 1, 1) (1, 1, 1) (1, 1, 1) Computing cones Cones computation took: 0.00124502182007 secs for 3 cones Computing parallelepipeds Parallelepipeds computation took: 0.061665058136 secs Computing rational functions Rational function computation took: 8.98838043213e-05 secs [ Cone: generators = ((0, 0, 1), (0, 1, -1), (1, 0, -1)), apex = (0, 0, 10), openness = (0, 0, 0) ] [ Cone: generators = ((1, -1, 0), (1, 0, -1), (1, 0, 0)), apex = (10, 0, 0), openness = (1, 1, 0) ] [ Cone: generators = ((0, 1, -1), (0, 1, 0), (1, -1, 0)), apex = (0, 10, 0), openness = (1, 0, 0) ]