Example #1
0
    def build_cnf(args):
        """Build a graph automorphism formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args,suffix="")
        T = SimpleGraphHelper.obtain_graph(args,suffix="T")
        return SubgraphFormula(G,[T],symmetric=False)
Example #2
0
    def build_cnf(args):
        """Build a graph automorphism formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G1 = SimpleGraphHelper.obtain_graph(args,suffix="1")
        G2 = SimpleGraphHelper.obtain_graph(args,suffix="2")
        return GraphIsomorphism(G1,G2)
Example #3
0
    def build_cnf(args):
        """Build a graph automorphism formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G1 = SimpleGraphHelper.obtain_graph(args, suffix="1")
        G2 = SimpleGraphHelper.obtain_graph(args, suffix="2")
        return GraphIsomorphism(G1, G2)
Example #4
0
    def build_cnf(args):
        """Build a graph automorphism formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args, suffix="")
        T = SimpleGraphHelper.obtain_graph(args, suffix="T")
        return SubgraphFormula(G, [T], symmetric=False)
Example #5
0
    def build_cnf(args):
        """Build Tseitin formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)

        if G.order()<1:
            charge=None

        elif args.charge=='first':

            charge=[1]+[0]*(G.order()-1)

        else: # random vector
            charge=[random.randint(0,1) for _ in range(G.order()-1)]

            parity=sum(charge) % 2

            if args.charge=='random':
                charge.append(random.randint(0,1))
            elif args.charge=='randomodd':
                charge.append(1-parity)
            elif args.charge=='randomeven':
                charge.append(parity)
            else:
                raise ValueError('Illegal charge specification on command line')

        return TseitinFormula(G,charge)
Example #6
0
    def build_cnf(args):
        """Build Tseitin formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)

        if G.order()<1:
            charge=None

        elif args.charge=='first':

            charge=[1]+[0]*(G.order()-1)

        else: # random vector
            charge=[random.randint(0,1) for _ in xrange(G.order()-1)]

            parity=sum(charge) % 2

            if args.charge=='random':
                charge.append(random.randint(0,1))
            elif args.charge=='randomodd':
                charge.append(1-parity)
            elif args.charge=='randomeven':
                charge.append(parity)
            else:
                raise ValueError('Illegal charge specification on command line')

        return TseitinFormula(G,charge)
Example #7
0
    def build_cnf(args):
        """Build a formula to check that a graph is a ramsey number lower bound

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        return RamseyWitnessFormula(G,args.k,args.s)
Example #8
0
    def build_cnf(args):
        """Build a k-colorability formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        return GraphColoringFormula(G,range(1,args.k+1))
Example #9
0
    def build_cnf(args):
        """Build a k-colorability formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        return GraphColoringFormula(G, list(range(1, args.k + 1)))
Example #10
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args)
     T = args.mass
     if args.rational:
         T = 2 * G.size()
     if args.no_rational:
         T = 2 * G.size() - 1
     return ExtendedEvenColoringFormula(G, T)
Example #11
0
    def build_cnf(args):
        """Build the k-dominating set formula

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        return DominatingSet(G, args.d, alternative = args.alternative )
Example #12
0
    def build_cnf(args):
        """Build a Graph ordering principle formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G= SimpleGraphHelper.obtain_graph(args)
        return GraphOrderingPrinciple(G,args.total,args.smart,args.plant,args.knuth)
Example #13
0
    def build_cnf(args):
        """Build a graph automorphism formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        return GraphAutomorphism(G)
Example #14
0
    def build_cnf(args):
        """Build the k-vertex cover formula

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        return VertexCover(G, args.k)
Example #15
0
    def build_cnf(args):
        """Build the k-dominating set formula

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        return DominatingSet(G, args.d, alternative=args.alternative)
Example #16
0
    def build_cnf(args):
        """Build a k-clique formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        return CliqueFormula(G,args.k)
Example #17
0
    def build_cnf(args):
        """Build a graph automorphism formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        return GraphAutomorphism(G)
Example #18
0
    def build_cnf(args):
        """Build a Graph ordering principle formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G= SimpleGraphHelper.obtain_graph(args)
        return GraphOrderingPrinciple(G,args.total,args.smart,args.plant,args.knuth)
Example #19
0
    def build_cnf(args):
        """Build a formula to check that a graph is a ramsey number lower bound

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        return RamseyWitnessFormula(G, args.k, args.s)
Example #20
0
    def build_cnf(args):
        """Build a k-clique formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        return BinaryCliqueFormula(G, args.k)
Example #21
0
    def build_cnf(args):
        """Build a formula to check that a graph is a ramsey number lower bound

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        return SubgraphFormula(G,[complete_graph(args.k),
                                  empty_graph(args.s)])
Example #22
0
    def build_cnf(args):
        """Build the k-dominating set formula

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        D = args.d
        if args.regular : D = G.order()/(2*G.number_of_edges()/G.order()+1)
        return DominatingSetOPB(G, D, args.tiling, args.seed)
Example #23
0
    def build_cnf(args):
        """Build the k-dominating set formula

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        D = args.d
        if args.rational : D = G.order()/2
        elif args.no_rational : D = G.order()/2-1
        return VertexCover(G, D)
Example #24
0
    def build_cnf(args):
        """Build the k-dominating set formula

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)
        D = args.d
        if args.rational:
            D = G.order()/2
        elif args.no_rational:
            D = G.order()/2-1
        return VertexCover(G, D)
Example #25
0
    def build_cnf(args):
        """Build Tseitin formula according to the arguments

        Arguments:
        - `args`: command line options
        """
        G = SimpleGraphHelper.obtain_graph(args)

        if G.order() < 1:
            charge = None

        elif args.charge == 'first':

            charge = [1] + [0] * (G.order() - 1)

        elif args.charge in ['0', '1']:
            charge = [int(args.charge)] * G.number_of_nodes()

        else:  # random vector
            charge = [random.randint(0, 1) for _ in range(G.order() - 1)]

            parity = sum(charge) % 2

            if args.charge == 'random':
                charge.append(random.randint(0, 1))
            elif args.charge == 'randomodd':
                charge.append(1 - parity)
            elif args.charge == 'randomeven':
                charge.append(parity)
            else:
                raise ValueError(
                    'Illegal charge specification on command line')

        encoding = None
        if args.extendedPBAnyHelper:
            encoding = "extendedPBAnyHelper"
        elif args.extendedPBOneHelper:
            encoding = "extendedPBOneHelper"
        elif args.extendedPBExpHelper:
            encoding = "extendedPBExpHelper"

        return TseitinFormula(G, charge, encoding)
Example #26
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args)
     T = args.mass
     if args.rational : T = 2*G.size()
     if args.no_rational : T = 2*G.size()-1
     return ExtendedEvenColoringFormula(G,T)
Example #27
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args) 
     return EvenColoringFormula(G)
Example #28
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args)
     return PerfectMatchingPrinciple(G)
Example #29
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args)
     return PerfectMatchingPrinciple(G)
Example #30
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args)
     return EvenColoringFormula(G)