Beispiel #1
0
    def setup_command_line(parser):
        """Setup the command line options for Perfect Matching Principle formula

        Arguments:
        - `parser`: parser to load with options.
        """
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #2
0
    def setup_command_line(parser):
        """Setup the command line options for graph automorphism formula

        Arguments:
        - `parser`: parser to load with options.
        """
        SimpleGraphHelper.setup_command_line(parser)
    def setup_command_line(parser):
        """Setup the command line options for graph automorphism formula

        Arguments:
        - `parser`: parser to load with options.
        """
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #4
0
    def setup_command_line(parser):
        """Setup the command line options for Perfect Matching Principle formula

        Arguments:
        - `parser`: parser to load with options.
        """
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #5
0
    def setup_command_line(parser):
        """Setup the command line options for graph isomorphism formula

        Arguments:
        - `parser`: parser to load with options.
        """
        SimpleGraphHelper.setup_command_line(parser, suffix="", required=True)
        SimpleGraphHelper.setup_command_line(parser, suffix="T", required=True)
Beispiel #6
0
    def setup_command_line(parser):
        """Setup the command line options for k-clique formula

        Arguments:
        - `parser`: parser to load with options.
        """
        parser.add_argument('k',metavar='<k>',type=int,action='store',help="size of the clique to be found")
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #7
0
    def setup_command_line(parser):
        """Setup the command line options for vertex cover formula

        Arguments:
        - `parser`: parser to load with options.
        """
        parser.add_argument('k',metavar='<k>',type=int,action='store',help="size of the vertex cover")
        SimpleGraphHelper.setup_command_line(parser)
    def setup_command_line(parser):
        """Setup the command line options for graph isomorphism formula

        Arguments:
        - `parser`: parser to load with options.
        """
        SimpleGraphHelper.setup_command_line(parser,suffix="1",required=True)
        SimpleGraphHelper.setup_command_line(parser,suffix="2",required=True)
Beispiel #9
0
    def setup_command_line(parser):
        """Setup the command line options for k-color formula

        Arguments:
        - `parser`: parser to load with options.
        """
        parser.add_argument('k',metavar='<k>',type=int,action='store',help="number of available colors")
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #10
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)
Beispiel #11
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)
Beispiel #12
0
    def setup_command_line(parser):
        """Setup the command line options for dominating set formula

        Arguments:
        - `parser`: parser to load with options.
        """
        parser.add_argument('d',metavar='<d>',type=int,action='store',help="size of the dominating set")
        parser.add_argument('--alternative','-a',action='store_true',default=False,help="produce the provably hard version")
        SimpleGraphHelper.setup_command_line(parser)
    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)
Beispiel #14
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)
Beispiel #15
0
    def setup_command_line(parser):
        """Setup the command line options for ramsey witness formula

        Arguments:
        - `parser`: parser to load with options.
        """
        parser.add_argument('k', metavar='<k>', type=int,
                            action='store', help="size of the clique to be found")
        parser.add_argument('s', metavar='<s>', type=int,
                            action='store', help="size of the stable to be found")
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #16
0
    def setup_command_line(parser):
        """Setup the command line options for dominating set formula

        Arguments:
        - `parser`: parser to load with options.
        """
        group = parser.add_mutually_exclusive_group(required=True)
        group.add_argument('--d',metavar='<d>',type=int,action='store',help="size of the cover")
        group.add_argument('--rational',action='store_true',help="Set size to V/2")
        group.add_argument('--no-rational',action='store_true',help="Set size to V/2-1")
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #17
0
    def setup_command_line(parser):
        """Setup the command line options for dominating set formula

        Arguments:
        - `parser`: parser to load with options.
        """
        group = parser.add_mutually_exclusive_group(required=True)
        group.add_argument('--d',metavar='<d>',type=int,action='store',help="size of the dominating set")
        group.add_argument('--regular',action='store_true',help="Set size to V/(deg+1)")
        group.add_argument('--tiling',action='store_true',help="Add tiling constraints")
        parser.add_argument('--seed',action='store_true',help="Set some vertex to true")
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #18
0
    def setup_command_line(parser):
        """Setup the command line options for k-color formula

        Arguments:
        - `parser`: parser to load with options.
        """
        parser.add_argument('k',
                            metavar='<k>',
                            type=int,
                            action='store',
                            help="number of available colors")
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #19
0
 def setup_command_line(parser):
     group = parser.add_mutually_exclusive_group(required=True)
     group.add_argument('--mass',
                        metavar='<T>',
                        type=int,
                        action='store',
                        help="Truth mass in the unbalancedness constraint")
     group.add_argument('--rational',
                        action='store_true',
                        help="Set truth mass to 2E")
     group.add_argument('--no-rational',
                        action='store_true',
                        help="Set truth mass to 2E-1")
     SimpleGraphHelper.setup_command_line(parser)
Beispiel #20
0
    def setup_command_line(parser):
        """Setup the command line options for dominating set formula

        Arguments:
        - `parser`: parser to load with options.
        """
        group = parser.add_mutually_exclusive_group(required=True)
        group.add_argument('--d', metavar='<d>', type=int,
                           action='store', help="size of the cover")
        group.add_argument('--rational', action='store_true',
                           help="Set size to V/2")
        group.add_argument(
            '--no-rational', action='store_true', help="Set size to V/2-1")
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #21
0
    def setup_command_line(parser):
        """Setup the command line options for Graph ordering principle formula

        Arguments:
        - `parser`: parser to load with options.
        """
        g=parser.add_mutually_exclusive_group()
        g.add_argument('--total','-t',default=False,action='store_true',help="assume a total order")
        g.add_argument('--smart','-s',default=False,action='store_true',help="encode 'x<y' and 'x>y' in a single variable (implies totality)")
        g.add_argument('--knuth2', action='store_const', dest='knuth',const=2,
                       help="transitivity axioms: \"(i<j)(j<k)->(i,k)\" only for j>i,k")
        g.add_argument('--knuth3', action='store_const', dest='knuth',const=3,
                       help="transitivity axioms: \"(i<j)(j<k)->(i,k)\" only for k>i,j")
        parser.add_argument('--plant','-p',default=False,action='store_true',help="allow a minimum element")
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #22
0
    def setup_command_line(parser):
        """Setup the command line options for Tseitin formula

        Arguments:
        - `parser`: parser to load with options.
        """
        parser.add_argument('--charge',metavar='<charge>',default='first',
                            choices=['first','random','randomodd','randomeven'],
                            help="""charge on the vertices.
                                    `first'  puts odd charge on first vertex;
                                    `random' puts a random charge on vertices;
                                    `randomodd' puts random odd  charge on vertices;
                                    `randomeven' puts random even charge on vertices.
                                     """)
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #23
0
    def setup_command_line(parser):
        """Setup the command line options for Tseitin formula

        Arguments:
        - `parser`: parser to load with options.
        """
        parser.add_argument('--charge',metavar='<charge>',default='first',
                            choices=['first','random','randomodd','randomeven'],
                            help="""charge on the vertices.
                                    `first'  puts odd charge on first vertex;
                                    `random' puts a random charge on vertices;
                                    `randomodd' puts random odd  charge on vertices;
                                    `randomeven' puts random even charge on vertices.
                                     """)
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #24
0
    def setup_command_line(parser):
        """Setup the command line options for Graph ordering principle formula

        Arguments:
        - `parser`: parser to load with options.
        """
        g=parser.add_mutually_exclusive_group()
        g.add_argument('--total','-t',default=False,action='store_true',help="assume a total order")
        g.add_argument('--smart','-s',default=False,action='store_true',help="encode 'x<y' and 'x>y' in a single variable (implies totality)")
        g.add_argument('--knuth2', action='store_const', dest='knuth',const=2,
                       help="transitivity axioms: \"(i<j)(j<k)->(i,k)\" only for j>i,k")
        g.add_argument('--knuth3', action='store_const', dest='knuth',const=3,
                       help="transitivity axioms: \"(i<j)(j<k)->(i,k)\" only for k>i,j")
        parser.add_argument('--plant','-p',default=False,action='store_true',help="allow a minimum element")
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #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)

        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)
Beispiel #26
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)
Beispiel #27
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)
Beispiel #28
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)
Beispiel #29
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)
Beispiel #30
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)
Beispiel #31
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)
Beispiel #32
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)
Beispiel #33
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)))
Beispiel #34
0
    def setup_command_line(parser):
        """Setup the command line options for dominating set formula

        Arguments:
        - `parser`: parser to load with options.
        """
        parser.add_argument('d',
                            metavar='<d>',
                            type=int,
                            action='store',
                            help="size of the dominating set")
        parser.add_argument('--alternative',
                            '-a',
                            action='store_true',
                            default=False,
                            help="produce the provably hard version")
        SimpleGraphHelper.setup_command_line(parser)
Beispiel #35
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)
Beispiel #36
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))
Beispiel #37
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 )
Beispiel #38
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)
Beispiel #39
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)
    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)
Beispiel #41
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)
Beispiel #42
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)])
Beispiel #43
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)
Beispiel #44
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)
Beispiel #45
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)
Beispiel #46
0
    def setup_command_line(parser):
        """Setup the command line options for Tseitin formula

        Arguments:
        - `parser`: parser to load with options.
        """
        parser.add_argument(
            '--charge',
            metavar='<charge>',
            default='first',
            choices=['first', 'random', 'randomodd', 'randomeven', '0', '1'],
            help="""charge on the vertices.
                                    `first'  puts odd charge on first vertex;
                                    `random' puts a random charge on vertices;
                                    `randomodd' puts random odd  charge on vertices;
                                    `randomeven' puts random even charge on vertices.
                                     """)
        group = parser.add_mutually_exclusive_group()
        group.add_argument(
            "--extendedPBAnyHelper",
            action='store_true',
            help=
            "Encode xor as pseudo boolean constraint with extended variables.")
        group.add_argument(
            "--extendedPBOneHelper",
            action='store_true',
            help="""Encode xor as pseudo boolean constraint with extended
                variables, such that exactly one of the extension variables ist
                true.""")
        group.add_argument(
            "--extendedPBExpHelper",
            action='store_true',
            help="""Encode xor as pseudo boolean constraint with extended
                variables, using powers of two encoding.""")

        SimpleGraphHelper.setup_command_line(parser)
Beispiel #47
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)
Beispiel #48
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)
Beispiel #49
0
 def setup_command_line(parser):
     group = parser.add_mutually_exclusive_group(required=True)
     group.add_argument('--mass',metavar='<T>',type=int,action='store',help="Truth mass in the unbalancedness constraint")
     group.add_argument('--rational',action='store_true',help="Set truth mass to 2E")
     group.add_argument('--no-rational',action='store_true',help="Set truth mass to 2E-1")
     SimpleGraphHelper.setup_command_line(parser)
Beispiel #50
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args) 
     return EvenColoringFormula(G)
Beispiel #51
0
 def setup_command_line(parser):
     SimpleGraphHelper.setup_command_line(parser)
Beispiel #52
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args)
     return EvenColoringFormula(G)
Beispiel #53
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args)
     return PerfectMatchingPrinciple(G)
Beispiel #54
0
 def build_cnf(args):
     G = SimpleGraphHelper.obtain_graph(args)
     return PerfectMatchingPrinciple(G)
Beispiel #55
0
 def setup_command_line(parser):
     SimpleGraphHelper.setup_command_line(parser)