Ejemplo n.º 1
0
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 20 02:19:35 2015

@author: dante
version: 1.0
"""

import sys                   # Needed for exit() function and arguments
import QCPHelper as qcph     # Needed for property clauses and other functions

''' Read in command line arguments '''
(inF, outF) = qcph.checkArg(sys.argv, "MainACD")

''' Read QCP instance '''
data = qcph.readFile(inF)
qcpLen = len(data)

''' Generate CNF formula '''
clauses = qcph.cnfACD(data, qcpLen)

''' Write the CNF formula to a file '''
qcph.writeToFile(clauses, qcpLen, outF)
Ejemplo n.º 2
0
'''

'''
Notice that if (a) and (c) are satisfied, then (b) and (e) is satisfied.
Similarly, if (a) and (d) are satisfied, then so is (b) and (f).

Therefore, we now have a minimal subset of the properties of (a) - (f):
(a) Each cell of the square contains a number in [n];
(c) No row has two cells containing the same number;
(d) No column has two cells containing the same number.
'''

arguments = sys.argv        # Stores command line arguments

''' Create desired directories for storing results '''
qcph.createDir()

''' Pre-stored orders of QCP instances '''
instanceOrder = [10, 16, 20, 24, 30, 32, 49]

''' Generate three CNF formulas for each of the QCP instances '''
for x in range(0, 7):
    for j in range(1, 5):
        clauses = []        # Stores all clauses of a given QCP instance
        
        qcpFile = "../instances/q_" + str(instanceOrder[x]) + "_0" + str(j) + ".qcp"
        
        data = qcph.readFile(qcpFile)       # QCP instance
        qcpLen = len(data)                  # Order of the QCP instance
        
        outputFileName = "../CNF/ACD/q_" + str(instanceOrder[x]) + "_0" + str(j) + "_ACD.cnf"