complexity_encoding.py
def encode_cardinality_sat(self, bound, variables: Dict[int, Dict[int, int]]):
        """
        Enforce weighted cardinality constraint on 2-d structure of variables
        * weights are read from self.weights
        * bound is adjusted by weight of the outer variable
        * inner variable is replicated as many times as its weight to form final
          list of variables to be cardinally constrained
        """
        old = self.num_clauses
        for i in range(len(variables)):
            node = self.node_reverse_lookup[i]
            varcounts = OrderedDict()
            if self.debug:
                self.current_cardinality_outer_var = node
                self.current_cardinality_inner_vars = []
            for j in range(len(variables[i])):
                var = variables[i][j]
                other = self.node_reverse_lookup[j]
                if other == node: continue
                varcounts[var] = self.weights[other]
                # vararray.extend([var]*self.weights[other])
                if self.debug: self.current_cardinality_inner_vars.extend([other]*self.weights[other])
            if self.use_dd:
                self.encode_single_cardinality_with_dd(bound - self.weights[node], varcounts)
            else:
                self.encode_single_cardinality(bound - self.weights[node], varcounts)
        #print("#cardinality clauses:", self.num_clauses - old)

        Enforce weighted cardinality constraint on 2-d structure of variables
        * weights are read from self.weights
        * bound is adjusted by weight of the outer variable
        * inner variable is replicated as many times as its weight to form final
          list of variables to be cardinally constrained
        
Enforce weighted cardinality constraint on 2-d structure of variables
weights are read from self.weights
bound is adjusted by weight of the outer variable
inner variable is replicated as many times as its weight to form final
list of variables to be cardinally constrained
Enforce weighted cardinality constraint on 2 - d structure of variables weights are read from self . weights bound is adjusted by weight of the outer variable inner variable is replicated as many times as its weight to form final list of variables to be cardinally constrained
def encode_cardinality_sat(self, bound, variables: Dict[int, Dict[int, int]]):
        old = self.num_clauses
        for i in range(len(variables)):
            node = self.node_reverse_lookup[i]
            varcounts = OrderedDict()
            if self.debug:
                self.current_cardinality_outer_var = node
                self.current_cardinality_inner_vars = []
            for j in range(len(variables[i])):
                var = variables[i][j]
                other = self.node_reverse_lookup[j]
                if other == node: continue
                varcounts[var] = self.weights[other]
                if self.debug: self.current_cardinality_inner_vars.extend([other]*self.weights[other])
            if self.use_dd:
                self.encode_single_cardinality_with_dd(bound - self.weights[node], varcounts)
            else:
                self.encode_single_cardinality(bound - self.weights[node], varcounts)
def encode_cardinality_sat ( self , bound , variables : Dict [ int , Dict [ int , int ] ] ) : old = self . num_clauses for i in range ( len ( variables ) ) : node = self . node_reverse_lookup [ i ] varcounts = OrderedDict ( ) if self . debug : self . current_cardinality_outer_var = node self . current_cardinality_inner_vars = [ ] for j in range ( len ( variables [ i ] ) ) : var = variables [ i ] [ j ] other = self . node_reverse_lookup [ j ] if other == node : continue varcounts [ var ] = self . weights [ other ] if self . debug : self . current_cardinality_inner_vars . extend ( [ other ] * self . weights [ other ] ) if self . use_dd : self . encode_single_cardinality_with_dd ( bound - self . weights [ node ] , varcounts ) else : self . encode_single_cardinality ( bound - self . weights [ node ] , varcounts )
Enforce weighted cardinality constraint on 2-d structure of variables
 weights are read from self.weights
 bound is adjusted by weight of the outer variable
 inner variable is replicated as many times as its weight to form final
list of variables to be cardinally constrained
Enforce weighted cardinality constraint on 2 - d structure of variables weights are read from self . weights bound is adjusted by weight of the outer variable inner variable is replicated as many times as its weight to form final list of variables to be cardinally constrained
"""
        Enforce weighted cardinality constraint on 2-d structure of variables
        * weights are read from self.weights
        * bound is adjusted by weight of the outer variable
        * inner variable is replicated as many times as its weight to form final
          list of variables to be cardinally constrained
        """ # vararray.extend([var]*self.weights[other]) #print("#cardinality clauses:", self.num_clauses - old)
self
bound
variables
Dict[int, Dict[int, int]]