Beispiel #1
0
def test_rooms():

    rss = get_rs()
    rs = rss["mild_roomset"]
    l3 = rs.rooms.keys()

    #--------------------------------------
    folder = os.getcwd()
    folder = os.path.join(folder, "uniqes")

    p1 = PssAnalyzer()
    p2 = PssAnalyzer()

    p1.appent_pattern(folder, ".*best.*")
    p2.appent_pattern(folder, ".*beam.*")

    p1 = p1.select(".*Power.*", roomset_pattern=".*mild.*")
    p2 = p2.select(".*Power.*", roomset_pattern=".*mild.*")

    p1 = p1.union_db_by_agent_roomset()
    p2 = p2.union_db_by_agent_roomset()

    for db1, db2 in zip(p1.dbs, p2.dbs):
        l1 = db1.roomset.rooms.keys()
        l2 = db2.roomset.rooms.keys()
        print len(l1), db1.name, db2.roomset.name
        print len(l2), db2.name, db2.roomset.name
        print sorted(l1)
        print sorted(l2)

        l1, l2, l3 = [map(str, l) for l in [l1, l2, l3]]

        shared = 0
        in_source = 0

        for e1 in l1:
            if e1 in l2:
                shared += 1
            else:
                pass  #print e1, "NOT shared"

            if e1 in l3:
                in_source += 1
            else:
                pass  #print e1, "NOT shared"

        print shared, "Shared"
        print in_source, "In source"
Beispiel #2
0
def test_rooms():
    
    rss = get_rs()
    rs = rss["mild_roomset"]
    l3 = rs.rooms.keys()
    
    #--------------------------------------
    folder = os.getcwd()
    folder = os.path.join(folder,"uniqes")
    
    p1 = PssAnalyzer()
    p2 = PssAnalyzer()
    
    p1.appent_pattern(folder, ".*best.*")
    p2.appent_pattern(folder, ".*beam.*")
    
    p1 = p1.select(".*Power.*", roomset_pattern=".*mild.*")
    p2 = p2.select(".*Power.*", roomset_pattern=".*mild.*")
    
    p1 = p1.union_db_by_agent_roomset()
    p2 = p2.union_db_by_agent_roomset()
    
    for db1, db2 in zip (p1.dbs, p2.dbs):
        l1 = db1.roomset.rooms.keys()
        l2 = db2.roomset.rooms.keys()
        print len(l1), db1.name, db2.roomset.name
        print len(l2),  db2.name, db2.roomset.name
        print sorted(l1)
        print sorted(l2)
        
        l1, l2, l3 = [map(str,l) for l in [l1, l2, l3]]
        
        shared =0 
        in_source =0
        
        for e1 in l1:
            if e1 in l2:
                shared +=1
            else:
                pass #print e1, "NOT shared"
            
            if e1 in l3:
                in_source +=1
            else:
                pass #print e1, "NOT shared"                
        
        print shared, "Shared"
        print in_source, "In source"
Beispiel #3
0
def opt_solutions():
    '''
    @return: { roomset name => { room id => best solution,...},... }
    '''
    pp = PssAnalyzer()
    pp.appent_pattern(get_pickle_folder(), ".*")

    pp = pp.union_db_by_agent_roomset()
    res = {}
    for rsn in rooomsets_names:
        p = pp.select(".*", rsn)
        d = p.build_optimal_solution_table()
        #res.update(d)
        res[rsn] = d
        print "best solutions for", rsn
        #print_list(d.items())
        print "numberof rooms with solution:", len(d)
    return res
Beispiel #4
0
def opt_solutions():
    """
    @return: { roomset name => { room id => best solution,...},... }
    """
    pp = PssAnalyzer()
    pp.appent_pattern(get_pickle_folder(), ".*")

    pp = pp.union_db_by_agent_roomset()
    res = {}
    for rsn in rooomsets_names:
        p = pp.select(".*", rsn)
        d = p.build_optimal_solution_table()
        # res.update(d)
        res[rsn] = d
        print "best solutions for", rsn
        # print_list(d.items())
        print "numberof rooms with solution:", len(d)
    return res