Esempio n. 1
0
 def testOutputValid(self) :
     ''' Verify that output is indeed SMTLIB2 valid syntax and can be solved
     by a SMT solver
     '''
     optmods = ['CS1231', 'CS1020', 'CS2100', 'CS2020', 'CS2105', 'MA1101R', 
                'ST2131']
     options = {}
     smtlib2, modmapping = queryParserBV.parseQuery(4, [], optmods, options, semester = SEMESTER)
     assertions = parse_smt2_string(smtlib2)
     s = Solver()
     s.add(assertions)
     self.assertEqual(s.check(), sat)
Esempio n. 2
0
def apiQuery(semester, numToTake, compMods, optMods, options):
	compMods = compMods.split(',') if compMods != 'null' else []
	optMods = optMods.split(',') if optMods != 'null' else []
	options = json.loads(options)

	if semester == 1:
		semester = 'AY1718S1'
	elif semester == 2:
		semester = 'AY1617S2'		

	print [compMods, optMods, options]

	smtQuery, modMapping = queryParserBV.parseQuery(numToTake, compMods, optMods, options, semester)

	return jsonify([smtQuery, modMapping])
Esempio n. 3
0
def solveQuery(numToTake,
               compmodsstr=[],
               optmodsstr=[],
               options={},
               semester='AY1617S2'):
    s, modlst = parseQuery(numToTake,
                           compmodsstr,
                           optmodsstr,
                           options,
                           semester,
                           debug=True)
    if "numFreedays" in options and options["numFreedays"] > 0:
        freedayFlag = True
    else:
        freedayFlag = False

    if s.check() == sat:
        # print "Candidate Timetable:"
        m = s.model()
        # outputFormatter(m, numToTake, modlst)
        return timetable(m, numToTake, modlst, freedayFlag)
    else:
        return []
Esempio n. 4
0
import queryParserBV

data = sys.argv[1]
data = json.loads(data)

semester = data['semester']
numTake = data['numToTake']
if 'compMods' in data:
    compMods = data['compMods']
else:
    compMods = []

if 'optMods' in data:
    optMods = data['optMods']
else:
    optMods = []

if 'options' in data:
    options = data['options']
else:
    options = {}
''' Print out the SMTLIB 2 query first followed by the module mapping (JSON)
Last line of output will be module mapping
'''
smtlib2, moduleMapping = queryParserBV.parseQuery(int(numTake), compMods,
                                                  optMods, options, semester)
print smtlib2
print json.dumps(moduleMapping)

sys.stdout.flush()