def global_model_count(alpha,manager): mc = sdd.sdd_model_count(alpha,manager) var_count = sdd.sdd_manager_var_count(manager) var_used = sdd.sdd_variables(alpha,manager) for used in var_used[1:]: if not used: mc = 2*mc return mc
def global_model_count(alpha, manager): mc = sdd.sdd_model_count(alpha, manager) var_count = sdd.sdd_manager_var_count(manager) var_used = sdd.sdd_variables(alpha, manager) for used in var_used[1:]: if not used: mc = 2 * mc return mc
def print_grids(alpha,dimension,manager): #import pdb; pdb.set_trace() from inf import models var_count = 2*dimension*(dimension-1) #var_count = 2*dimension*(dimension-1) + dimension*dimension #var_count = 2*dimension[0]*dimension[1] - dimension[0] - dimension[1] print "COUNT:", sdd.sdd_model_count(alpha,manager) for model in models.models(alpha,sdd.sdd_manager_vtree(manager)): print models.str_model(model,var_count=var_count) draw_grid(model,dimension)
def encode_graph(g,manager): print "encoding graphs ..." start = time() sdd.sdd_manager_auto_gc_and_minimize_off(manager) # ACACAC alpha = _encode_graph(g,manager) print "done! (%.3fs)" % (time()-start) print "model count..." print "sdd mc :", sdd.sdd_model_count(alpha,manager) print "sdd mc-g:", global_model_count(alpha,manager) #print "minimizing ..." #sdd.sdd_ref(alpha,manager) #sdd.sdd_manager_minimize(manager) #sdd.sdd_deref(alpha,manager) print "sdd size:", sdd.sdd_size(alpha) print "sdd nc :", sdd.sdd_count(alpha) return alpha
def convert(filename): start = time.time() manager,alpha = orig.parse_bdd(filename+".zdd") end = time.time() print " sdd node count: %d" % sdd.sdd_count(alpha) print " sdd size: %d" % sdd.sdd_size(alpha) print " sdd model count: %d" % sdd.sdd_model_count(alpha,manager) print " global model count: %d" % orig.global_model_count(alpha,manager) print " read bdd time: %.3fs" % (end-start) sdd.sdd_save(filename + ".sdd",alpha) #sdd.sdd_save_as_dot(filename +".sdd.dot",alpha) vtree = sdd.sdd_manager_vtree(manager) sdd.sdd_vtree_save(filename + ".vtree",vtree) #sdd.sdd_vtree_save_as_dot(filename +".vtree.dot",vtree) print "====================" print "before garbage collecting..." print "live size:", sdd.sdd_manager_live_count(manager) print "dead size:", sdd.sdd_manager_dead_count(manager) print "garbage collecting..." sdd.sdd_manager_garbage_collect(manager) print "live size:", sdd.sdd_manager_live_count(manager) print "dead size:", sdd.sdd_manager_dead_count(manager)
if __name__ == '__main__': import sys if len(sys.argv) != 2: print "usage: %s [BDD_FILENAME]" % sys.argv[0] exit(1) filename = sys.argv[1] start = time.time() manager,alpha = parse_bdd(filename) end = time.time() print " sdd node count: %d" % sdd.sdd_count(alpha) print " sdd size: %d" % sdd.sdd_size(alpha) print " sdd model count: %d" % sdd.sdd_model_count(alpha,manager) print " global model count: %d" % global_model_count(alpha,manager) print " read bdd time: %.3fs" % (end-start) """ sdd.sdd_ref(alpha,manager) start = time.time() sdd.sdd_manager_minimize(manager) end = time.time() print " min sdd node count: %d" % sdd.sdd_count(alpha) print " min sdd time: %.3fs" % (end-start) sdd.sdd_deref(alpha,manager) """ sdd.sdd_save(filename + ".sdd",alpha) #sdd.sdd_save_as_dot(filename +".sdd.dot",alpha)
import sys if len(sys.argv) != 4: print "usage: %s [GRID-M] [GRID-N] [MIDPOINT]" % sys.argv[0] exit(1) m,n,midpoint = int(sys.argv[1]),int(sys.argv[2]),int(sys.argv[3]) filename = fnPrefix = ("graphs/asdf-%d-%d-%d" % (m,n,midpoint)) filenameNoMP = fnPrefixNoMP = ("graphs/asdf-no-mp-%d-%d-%d" % (m,n,midpoint)) start = time.time() manager,alpha = parse_bdd(filename+".zdd") end = time.time() print " sdd node count: %d" % sdd.sdd_count(alpha) print " sdd size: %d" % sdd.sdd_size(alpha) print " sdd model count: %d" % sdd.sdd_model_count(alpha,manager) print " global model count: %d" % global_model_count(alpha,manager) print " read bdd time: %.3fs" % (end-start) start = time.time() managerNoMP,alphaNoMP = parse_bdd(filenameNoMP+".zdd") end = time.time() print " sdd node count: %d" % sdd.sdd_count(alphaNoMP) print " sdd size: %d" % sdd.sdd_size(alphaNoMP) print " sdd model count: %d" % sdd.sdd_model_count(alphaNoMP,managerNoMP) print " global model count: %d" % global_model_count(alphaNoMP,managerNoMP) print " read bdd time: %.3fs" % (end-start) """ sdd.sdd_ref(alpha,manager) start = time.time()