Exemple #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)
    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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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))
Exemple #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)))
Exemple #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)
Exemple #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 )
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
    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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)])
    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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #27
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args) 
     return EvenColoringFormula(G)
Exemple #28
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args)
     return PerfectMatchingPrinciple(G)
Exemple #29
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args)
     return PerfectMatchingPrinciple(G)
Exemple #30
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args)
     return EvenColoringFormula(G)