示例#1
0
    def getSuccessors(self, points, groups):
        successors = []

        for g in groups:
            memtup = cluster_util.totuple(g.members)

            if len(self.state.intersection(memtup)) <= allow_intersection:
                asd = BNode(self.state.union(memtup), self, g.uuid, g.cost)
                if asd.gain > 0:
                    successors.append(asd)
        return successors
示例#2
0
    def getSuccessors(self, points,groups):
        successors = []

        for g in groups:
            memtup = cluster_util.totuple(g.members)

            if len(self.state.intersection(memtup))<=allow_intersection:
                asd=BNode(self.state.union(memtup),self,g.uuid,g.cost)
                if asd.gain > 0:
                    successors.append(asd)
        return successors
def sceneEval(inputObjectSet,params = ClusterParams(2,0.9,3,0.05,0.1,1,0,10)):
    
    '''
    find the clusters
    evaulate the inside of the clusters as lines to see if they'd be better as lines than clusters
    evaluate the outside of clusters for lines
    concatenate the lists of clusters and lines
    evaluate the whole thing with bundle search
    '''
    
    clusterCandidates = clustercost(dbscan(np.array(map(lambda x: (x.position,x.id),inputObjectSet))))
    lineCandidates = findChains(inputObjectSet,params)
    print'***'
    allCandidates = clusterCandidates + lineCandidates
    evali = bundleSearch(cluster_util.totuple(inputObjectSet), allCandidates, params.allow_intersection, 10)
    print evali
    return evali
示例#4
0
def sceneEval(inputObjectSet,params = ClusterParams(2,0.9,3,0.05,0.1,1,0,11,False)):
    
    '''
    find the clusters
    evaulate the inside of the clusters as lines to see if they'd be better as lines than clusters
    evaluate the outside of clusters for lines
    concatenate the lists of clusters and lines
    evaluate the whole thing with bundle search
    '''
    reducedObjectSet = copy(inputObjectSet)
    
    clusterCandidates = clustercost(dbscan(np.array(map(lambda x: (x.position,x.id),inputObjectSet))))
    
    innerLines = []
    #search for lines inside large clusters
    if params.attempt_dnc==True:
        for cluster in clusterCandidates[1]:

            innerObjects = []
            for id in cluster:
                for x in inputObjectSet:
                    if x.id == id:
                        innerObjects.append(x)
            innerChains = findChains(innerObjects,params)
            for thing in innerChains:
                innerLines.append(thing)
            
        #remove core clusters
        for cluster in clusterCandidates[0]:
            for id in cluster:
                for x in reducedObjectSet:
                    if x.id == id:
                        reducedObjectSet.remove(x)

    lineCandidates = findChains(reducedObjectSet,params)
    
    allCandidates = clusterCandidates[0]+clusterCandidates[1] + lineCandidates + innerLines
    groupDictionary = dict()
    for i in allCandidates:
        groupDictionary[i.uuid]=i
    evali = bundleSearch(cluster_util.totuple(inputObjectSet), allCandidates, params.allow_intersection, params.beam_width)   
    #find the things in evali that aren't in the dictionary ,and make a singleton group out of them, and add it to the output
    output = map(lambda x: groupDictionary.get(x),evali)
    return output