示例#1
0
def main():
    sys.setrecursionlimit(8000)
    
    '''CAP NO TEST'''
#    instancePath='/Users/Victor/Dropbox/DBMI/2. Spring 2013/Artificial Intelligence/Project/Instances/SURPRISE/graph01/'
#    library=formula(instancePath+'dimacs.txt')
#    t1=datetime.datetime.now()
#    GRASP(1,library)
#    t2=datetime.datetime.now()
#    totalT=t2-t1
#    print totalT
    
    ''' CAP WITH TEST'''
    instancePath='/Users/Victor/Dropbox/DBMI/2. Spring 2013/Artificial Intelligence/Project/Instances/CELAR/scen01/'
    constraints=open(instancePath+'ctr.txt','r').readlines()
    domains=open(instancePath+'dom.txt','r').readlines()
    var_domains=open(instancePath+'var.txt','r').readlines()
    instance=celar(constraints, domains, var_domains)
    dimacsPath=instancePath
    x=celar2SAT(instance._varDomains,instance._domains,instance._constraints,dimacsPath)
    library=formula(instancePath+'dimacs.txt')
    t1=datetime.datetime.now()
    GRASP(1,library)
    t2=datetime.datetime.now()
    totalT=t2-t1
    print totalT
    SAT2CAP2(library._assignment,instancePath,x._varDictionary)
#    sat=0
#    for w in library._clauses:
#        if library._clauses[w]._status == True:
#            sat+=1
#    sat
    (sat,unsatConstraints)=evalCAP(instance,instancePath+'solution.txt')
    print unsatConstraints
    print sat

    
   
    '''WITHOUT CAP'''
#    path='/Users/Victor/Dropbox/DBMI/2. Spring 2013/Artificial Intelligence/Project/Instances/test/dimacs.txt'
#    library=formula(path)
#    GRASP(1,library)
#    printAssignment(library)
#    
    '''TEST SOLUTION'''
#    instancePath='/Users/Victor/Dropbox/DBMI/2. Spring 2013/Artificial Intelligence/Project/Instances/SURPRISE/graph01/'
#    constraints=open(instancePath+'ctr.txt','r').readlines()
#    domains=open(instancePath+'dom.txt','r').readlines()
#    var_domains=open(instancePath+'var.txt','r').readlines()
#    instance=celar(constraints, domains, var_domains)
#    (sat,unsatConstraints)=evalCAP(instance,instancePath+'solution.txt')
#    print unsatConstraints
#    print sat

    '''ALL INSTANCES'''
示例#2
0
def main():
    sys.setrecursionlimit(8000)
#    
#    for arg in sys.argv:
#        file=re.match(r'file=(.+)', arg)
#        if file:
#            instancePath=file.group(1)
#    
    
    
    ''' WITH CAP'''
    instancePath='/Users/Victor/Dropbox/DBMI/2. Spring 2013/Artificial Intelligence/Project/Instances/SURPRISE/graph01/'
    constraints=open(instancePath+'ctr.txt','r').readlines()
    domains=open(instancePath+'dom.txt','r').readlines()
    var_domains=open(instancePath+'var.txt','r').readlines()
    instance=celar(constraints, domains, var_domains)
    dimacsPath=instancePath
    x=celar2SAT(instance._varDomains,instance._domains,instance._constraints,dimacsPath)
    library=formula(instancePath+'dimacs.txt')
    t1=datetime.datetime.now()
    GRASP(1,library)
    t2=datetime.datetime.now()
    totalT=t2-t1
    print totalT
    SAT2CAP2(library._vars,instancePath,x._varDictionary)
    (sat,unsatConstraints)=evalCAP(instance,instancePath+'solution.txt')
#    print unsatConstraints
    print sat

    
   
    '''WITHOUT CAP'''
#    path='/Users/Victor/Dropbox/DBMI/2. Spring 2013/Artificial Intelligence/Project/Instances/test/dimacs.txt'
#    library=formula(path)
#    GRASP(1,library)
#    printAssignment(library)
    
    '''TEST SOLUTION'''
#    instancePath='/Users/Victor/Dropbox/DBMI/2. Spring 2013/Artificial Intelligence/Project/Instances/SURPRISE/graph01/'
#    constraints=open(instancePath+'ctr.txt','r').readlines()
#    domains=open(instancePath+'dom.txt','r').readlines()
#    var_domains=open(instancePath+'var.txt','r').readlines()
#    instance=celar(constraints, domains, var_domains)
#    (sat,unsatConstraints)=evalCAP(instance,instancePath+'solution.txt')
#    print unsatConstraints
#    print sat

    '''ALL INSTANCES'''
示例#3
0
def main():
    sys.setrecursionlimit(8000)
    
    ''' WITH CAP'''
    path='/Users/Victor/Dropbox/DBMI/2. Spring 2013/Artificial Intelligence/Project/Instances/test/dimacs.txt'
    path='/Users/Victor/Dropbox/DBMI/2. Spring 2013/Artificial Intelligence/Project/Instances/SURPRISE/graph01/dimacs.txt'
    instancePath='/Users/Victor/Dropbox/DBMI/2. Spring 2013/Artificial Intelligence/Project/Instances/SURPRISE/graph01/'
    constraints=open(instancePath+'ctr.txt','r').readlines()
    domains=open(instancePath+'dom.txt','r').readlines()
    var_domains=open(instancePath+'var.txt','r').readlines()
    instance=celar(constraints, domains, var_domains)
    dimacsPath=instancePath
    x=celar2SAT(instance._varDomains,instance._domains,instance._constraints,dimacsPath)
    library=formula(path)
    GRASP(1,library)
    SAT2CAP2(library._vars,instancePath,x._varDictionary)
    
#    
#    '''WITHOUT CAP'''
#    path='/Users/Victor/Dropbox/DBMI/2. Spring 2013/Artificial Intelligence/Project/Instances/test/dimacs.txt'
#    library=formula(path)
#    GRASP(1,library)
    
    '''TEST SOLUTION'''