Initial commit

parents
main.lp
*~
#*
\ No newline at end of file
#include 'course.lp'.
_hasTaken(Student, Course):-
_substitution(Course, Course2), %valid substitutitions in req file
_hasTaken(Student, Course2).
hasNotTaken(Student,Course) :- not _hasTaken(Student, Course).
_t(Student,Course) :- _hasTaken(Student,Course).
_t(Student,Course) :- hasNotTaken(Student,Course).
_takenFor(Student, Course, Req):-
writef('takenFor/3 %t %t %t\n',[Student, Course, Req]),
not _takenForElective(Student,Course,Req).
_takenForElective(Student, Course):-
_req(Course,none),
writef('takenForElective/2 %t %t (None)\n',[Student, Course]).
_takenForElective(Student, Course, Req):-
writef('takenForElective/3 %t %t %t\n',[Student, Course,Req]),
not _takenFor(Student,Course,Req).
_takenForElective(Student, Course):-
writef('takenForElective/2 %t %t\n',[Student, Course]),
_req(Course, Req),
not _takenFor(Student,Course,Req).
_meetsHours(Student, Req, Min):-
_countHours(Student,Sum,Req),
Sum >= Min.
_auditHours(Student, Req, Min):-
_taken(Student, CourseList),
_auditHours(Student, Req, CourseList,Min).
_auditHours(Student, Req, Min):-
_countHours(Student, Sum, Req),
Diff is Min - Sum,
needsHours(Student,Req,Diff).
needsHours(Student, Req, Diff).
_auditHours(Student, Req, List, Min):-
Min =< 0.
_auditHours(Student, Req, [Course|Tail], Min):-
_req(Course, Req),
_course(Course, H),
_takenFor(Student, Course, Req),
Min_sub is Min - H,
_auditHours(Student, Req, Tail, Min_sub).
_auditHours(Student, Req, [Course|Tail], Min):-
_auditHours(Student, Req, Tail, Min).
_countHours(Student, Sum, Req):-
_taken(Student, List),
_countHours(Student,List,Sum,Req).
_countHours(Student, [], 0, Req).
_countHours(Student, [Course|Tail], Sum, Req):-
_req(Course, Req),
_course(Course, H),
_takenFor(Student,Course,Req),
_countHours(Student,Tail,Sum_Tail,Req),
Sum is H + Sum_Tail.
_countHours(Student,[H|T],Sum,Req):-
_countHours(Student,T,Sum,Req).
_meetsElectiveHours(Student, Min):-
_countElectiveHours(Student, Sum),
Sum >= Min.
_auditElectiveHours(Student, Min):-
_taken(Student, CourseList),
_auditElectiveHours(Student, CourseList, Min).
_auditElectiveHours(Student, Min):-
_countElectiveHours(Student, Sum),
Diff is Min - Sum,
needsElectiveHours(Student,Diff).
needsElectiveHours(Student,Diff).
_auditElectiveHours(Student, Min):-
_taken(Student, CourseList),
_auditElectiveHours(Student, CourseList, Min).
_auditElectiveHours(Student, List, Min):-
Min =< 0.
_auditElectiveHours(Student, [Course|Tail], Min):-
_course(Course,H),
_takenForElective(Student, Course),
Min_sub is Min - H,
_auditElectiveHours(Student, Tail, Min_sub).
_auditElectiveHours(Student,[Course|Tail], Sum):-
_auditElectiveHours(Student,Tail, Sum).
_countElectiveHours(Student, Sum):-
_taken(Student, List),
_countElectiveHours(Student,List,Sum).
_countElectiveHours(Student, [], 0).
_countElectiveHours(Student, [Course|Tail], Sum):-
_course(Course, H),
_takenForElective(Student,Course),
_countElectiveHours(Student,Tail,Sum_Tail),
Sum is H + Sum_Tail.
_countElectiveHours(Student,[H|T],Sum):-
_countElectiveHours(Student,T,Sum).
This diff is collapsed.
_auditRequiredCourses(Student):-
_t(Student,rhet1302),
_t(Student,govt2305),
_t(Student,govt2306),
_t(Student,phys2125),
_t(Student,phys2126),
_t(Student,phys2325),
_t(Student,phys2326),
_t(Student,ecs1200),
_t(Student,cs1337),
_t(Student,cs2305),
_t(Student,cs2336),
_t(Student,math2418),
_t(Student,cs3162),
_t(Student,cs3305),
_t(Student,cs3340),
_t(Student,cs3341),
_t(Student,cs3345),
_t(Student,cs3354),
_t(Student,cs3376),
_t(Student,ecs3361),
_t(Student,ecs3390),
_t(Student,cs4141),
_t(Student,cs4337),
_t(Student,cs4341),
_t(Student,cs4348),
_t(Student,cs4349),
_t(Student,cs4384),
_t(Student,cs4485).
%The two ways math credit can be obtained
_auditMathCourses(Student):-
_hasTaken(Student,math2413),
_t(Student,math2414),
_takenFor(Student,math2413,math),
_takenFor(Student,math2414,math).
_auditMathCourses(Student):-
_hasTaken(Student,math2417),
_t(Student,math2419),
_takenFor(Student,math2417,math),
_takenFor(Student,math2419,math).
_auditMathCourses(Student):-
_t(Student,math2413),
_t(Student,math2414),
_takenFor(Student,math2413,math),
_takenFor(Student,math2414,math).
_metRequiredCourses(Student):-
_hasTaken(Student,rhet1302),
_hasTaken(Student,govt2305),
_hasTaken(Student,govt2306),
_hasTaken(Student,phys2125),
_hasTaken(Student,phys2126),
_hasTaken(Student,phys2325),
_hasTaken(Student,phys2326),
_hasTaken(Student,ecs1200),
_hasTaken(Student,cs1337),
_hasTaken(Student,cs2305),
_hasTaken(Student,cs2336),
_hasTaken(Student,math2418),
_hasTaken(Student,cs3162),
_hasTaken(Student,cs3305),
_hasTaken(Student,cs3340),
_hasTaken(Student,cs3341),
_hasTaken(Student,cs3345),
_hasTaken(Student,cs3354),
_hasTaken(Student,cs3376),
_hasTaken(Student,ecs3361),
_hasTaken(Student,ecs3390),
_hasTaken(Student,cs4141),
_hasTaken(Student,cs4337),
_hasTaken(Student,cs4341),
_hasTaken(Student,cs4348),
_hasTaken(Student,cs4349),
_hasTaken(Student,cs4384),
_hasTaken(Student,cs4485).
%The two ways math credit can be obtained
_metMathCourses(Student):-
_hasTaken(Student,math2413),
_hasTaken(Student,math2414),
_takenFor(Student,math2413,math),
_takenFor(Student,math2414,math).
_metMathCourses(Student):-
_hasTaken(Student,math2417),
_hasTaken(Student,math2419),
_takenFor(Student,math2417,math),
_takenFor(Student,math2419,math).
%course for communication (6 hours)
_req(rhet1302,required).
%couses for government (6 hours)
_req(govt2305,required).
_req(govt2306,required).
%courses for csPrep (20 total but no room for choice)
_req(phys2125,required).
_req(phys2126,required).
_req(phys2325,required).
_req(phys2326,required).
_req(ecs1200,required).
_req(cs1337,required).
_req(cs2305,required).
_req(cs2336,required).
_req(math2418,required).
%courses for cs core (42 hours)
_req(cs3162,required).
_req(cs3305,required).
_req(cs3340,required).
_req(cs3341,required).
_req(cs3345,required).
_req(cs3354,required).
_req(cs3376,required).
_req(ecs3361,required).
_req(ecs3390,required).
_req(cs4141,required).
_req(cs4337,required).
_req(cs4341,required).
_req(cs4348,required).
_req(cs4349,required).
_req(cs4384,required).
_req(cs4485,required).
%courses for math credit (8 hours)
_req(math2413,math).
_req(math2414,math).
_req(math2417,math).
_req(math2419,math).
%courses for creative arts credit
_req(ahst1303,art).
_req(ahst1304,art).
_req(ahst2331,art).
_req(arts1301,art).
_req(danc1310,art).
_req(dram1310,art).
_req(film2332,art).
_req(musi1306,art).
%these classes are the csGuided electives (9 credit hours)
_req(cs4314,csGuided).
_req(cs4315,csGuided).
_req(cs4334,csGuided).
_req(cs4336,csGuided).
_req(cs4347,csGuided).
_req(cs4352,csGuided).
_req(cs4353,csGuided).
_req(cs4361,csGuided).
_req(cs4365,csGuided).
_req(cs4375,csGuided).
_req(cs4376,csGuided).
_req(cs4386,csGuided).
_req(cs4389,csGuided).
_req(cs4390,csGuided).
_req(cs4391,csGuided).
_req(cs4392,csGuided).
_req(cs4393,csGuided).
_req(cs4394,csGuided).
_req(cs4395,csGuided).
_req(cs4396,csGuided).
_req(cs4397,csGuided).
_req(cs4398,csGuided).
_req(cs4399,csGuided).
_req(ee4325,csGuided).
_req(se4351,csGuided).
_req(se4352,csGuided).
_req(se4367,csGuided).
_req(se4381,csGuided).
_req(se4485,csGuided).
_req(cs4V98,csGuided).
%courses for history credit (6 hours)
_req(hist1301,americanHist).
_req(hist1302,americanHist).
_req(hist2301,americanHist).
_req(hist2331,americanHist).
%courses for language philosophy and culture (3 hours)
_req(phil1301,lang).
_req(phil2316,lang).
_req(huma1301,lang).
_req(arab2312,lang).
_req(chin2312,lang).
_req(fren2312,lang).
_req(germ2312,lang).
_req(japn2312,lang).
_req(lit2331,lang).
_req(span2312,lang).
_req(ams2300,lang).
_req(ams2341,lang).
_req(ams3300,lang).
%Any of these courses can count for the sci 3 hour sci elective.
_req(biol1300,sci).
_req(biol2281,sci).
_req(biol2311,sci).
_req(biol2312,sci).
_req(biol2350,sci).
_req(biol318,sci).
_req(ce1202,sci).
_req(cgs2301,sci).
_req(chem1111,sci).
_req(chem1112,sci).
_req(chem1311,sci).
_req(chem1312,sci).
_req(ee1202,sci).
_req(envr2302,sci).
_req(geog2302,sci).
_req(geos1103,sci).
_req(geos1104,sci).
_req(geos1303,sci).
_req(geos1304,sci).
_req(geos2302,sci).
_req(geos2310,sci).
_req(geos2409,sci).
_req(isis2305,sci).
_req(isis2308,sci).
_req(isns2359,sci).
_req(isns2367,sci).
_req(isns2368,sci).
_req(nats1311,sci).
_req(nats2330,sci).
_req(nsc3344,sci).
_req(nsc3361,sci).
_req(nsc4352,sci).
_req(nsc4354,sci).
_req(phys1301,sci).
_req(phys1302,sci).
_req(phys2422,sci).
_req(psy2364,sci).
_req(spau2233,sci).
_req(te1202,sci).
This diff is collapsed.
#include 'cs2014req.lp'.
#include 'cs2014req2.lp'.
#include 'cs2014grad.lp'.
#include 'cs2014audit.lp'.
ableToGraduate(Student):-
_metRequiredCourses(Student),
_auditMathCourses(Student),
_meetsHours(Student,lang,3),
_meetsHours(Student,art,3),
_meetsHours(Student,americanHist,6),
_meetsHours(Student,sci,3),
_meetsHours(Student,csGuided,9),
_meetsElectiveHours(Student,11).
_audit(Student):-
_auditRequiredCourses(Student),
_auditMathCourses(Student),
_auditHours(Student,lang,3),
_auditHours(Student,art,3),
_auditHours(Student,americanHist,6),
_auditHours(Student,sci,3),
_auditHours(Student,csGuided,9),
_auditElectiveHours(Student,11).
_main(Student):-
ableToGraduate(Student).
_main(Student):-
_audit(Student).
_auditRequiredCourses(Student):-
_t(Student,cs3162),
_t(Student,cs3305),
_t(Student,cs3340),
_t(Student,cs3341),
_t(Student,cs3345),
_t(Student,cs3354),
_t(Student,cs3376),
_t(Student,ecs3361),
_t(Student,ecs3390),
_t(Student,cs4141),
_t(Student,cs4337),
_t(Student,cs4341),
_t(Student,cs4347),
_t(Student,cs4348),
_t(Student,cs4349),
_t(Student,cs4384),
_t(Student,cs4485),
_t(Student,ecs1100),
_t(Student,cs1200),
_t(Student,cs1337),
_t(Student,cs2305),
_t(Student,cs2336),
_t(Student,math2418),
_t(Student,phys2125),
_t(Student,phys2126),
_t(Student,phys2326),
_t(Student,phys2325),
_t(Student,rhet1302),
_t(Student,govt2305),
_t(Student,govt2306).
%The two ways math credit can be obtained
_auditMathCourses(Student):-
_hasTaken(Student,math2413),
_t(Student,math2414),
_takenFor(Student,math2413,math),
_takenFor(Student,math2414,math).
_auditMathCourses(Student):-
_hasTaken(Student,math2417),
_t(Student,math2419),
_takenFor(Student,math2417,math),
_takenFor(Student,math2419,math).
_auditMathCourses(Student):-
_t(Student,math2413),
_t(Student,math2414),
_takenFor(Student,math2413,math),
_takenFor(Student,math2414,math).
_metRequiredCourses(Student):-
_hasTaken(Student,cs3162),
_hasTaken(Student,cs3305),
_hasTaken(Student,cs3340),
_hasTaken(Student,cs3341),
_hasTaken(Student,cs3345),
_hasTaken(Student,cs3354),
_hasTaken(Student,cs3376),
_hasTaken(Student,ecs3361),
_hasTaken(Student,ecs3390),
_hasTaken(Student,cs4141),
_hasTaken(Student,cs4337),
_hasTaken(Student,cs4341),
_hasTaken(Student,cs4347),
_hasTaken(Student,cs4348),
_hasTaken(Student,cs4349),
_hasTaken(Student,cs4384),
_hasTaken(Student,cs4485),
_hasTaken(Student,ecs1100),
_hasTaken(Student,cs1200),
_hasTaken(Student,cs1337),
_hasTaken(Student,cs2305),
_hasTaken(Student,cs2336),
_hasTaken(Student,math2418),
_hasTaken(Student,phys2125),
_hasTaken(Student,phys2126),
_hasTaken(Student,phys2326),
_hasTaken(Student,phys2325),
_hasTaken(Student,rhet1302),
_hasTaken(Student,govt2305),
_hasTaken(Student,govt2306).
%The two ways math credit can be obtained
_metMathCourses(Student):-
_hasTaken(Student,math2413),
_hasTaken(Student,math2414),
_takenFor(Student,math2413,math),
_takenFor(Student,math2414,math).
_metMathCourses(Student):-
_hasTaken(Student,math2417),
_hasTaken(Student,math2419),
_takenFor(Student,math2417,math),
_takenFor(Student,math2419,math).
%course for communication (6 hours)
_req(rhet1302,required).
%couses for government (6 hours)
_req(govt2305,required).
_req(govt2306,required).
%courses for csPrep (20 total but no room for choice)
_req(phys2125,required).
_req(phys2126,required).
_req(phys2325,required).
_req(phys2326,required).
_req(ecs1100,required).
_req(cs1200,required).
_req(cs1337,required).
_req(cs2305,required).
_req(cs2336,required).
_req(math2418,required).
%courses for cs core (42 hours)
_req(cs3162,required).
_req(cs3305,required).
_req(cs3340,required).
_req(cs3341,required).
_req(cs3345,required).
_req(cs3354,required).
_req(cs3376,required).
_req(ecs3361,required).
_req(ecs3390,required).
_req(cs4141,required).
_req(cs4337,required).
_req(cs4341,required).
_req(cs4347,required).
_req(cs4348,required).
_req(cs4349,required).
_req(cs4384,required).
_req(cs4485,required).
%courses for math credit (8 hours)
_req(math2413,math).
_req(math2414,math).
_req(math2417,math).
_req(math2419,math).
%courses for creative arts credit
_req(ahst1303,art).
_req(ahst1304,art).
_req(ahst2331,art).
_req(arts1301,art).
_req(danc1310,art).
_req(dram1310,art).
_req(film2332,art).
_req(musi1306,art).
%these classes are the csGuided electives (9 credit hours)
_req(cs4314,csGuided).
_req(cs4315,csGuided).
_req(cs4334,csGuided).
_req(cs4336,csGuided).
_req(cs4352,csGuided).
_req(cs4353,csGuided).
_req(cs4361,csGuided).
_req(cs4365,csGuided).
_req(cs4375,csGuided).
_req(cs4376,csGuided).
_req(cs4386,csGuided).
_req(cs4389,csGuided).
_req(cs4390,csGuided).
_req(cs4391,csGuided).
_req(cs4392,csGuided).
_req(cs4393,csGuided).
_req(cs4394,csGuided).
_req(cs4395,csGuided).
_req(cs4396,csGuided).
_req(cs4397,csGuided).
_req(cs4398,csGuided).
_req(cs4399,csGuided).
_req(ee4325,csGuided).
_req(se4351,csGuided).
_req(se4352,csGuided).
_req(se4367,csGuided).
_req(se4381,csGuided).
_req(se4485,csGuided).
_req(cs4V98,csGuided).
%courses for history credit (6 hours)
_req(hist1301,americanHist).
_req(hist1302,americanHist).
_req(hist2301,americanHist).
_req(hist2331,americanHist).
%courses for language philosophy and culture (3 hours)
_req(phil1301,lang).
_req(phil2316,lang).
_req(huma1301,lang).
_req(arab2312,lang).
_req(chin2312,lang).
_req(fren2312,lang).
_req(germ2312,lang).
_req(japn2312,lang).
_req(lit2331,lang).
_req(span2312,lang).
_req(ams2300,lang).
_req(ams2341,lang).
_req(ams3300,lang).
%Any of these courses can count for the sci 3 hour sci elective.
_req(biol1300,sci).
_req(biol2281,sci).
_req(biol2311,sci).
_req(biol2312,sci).
_req(biol2350,sci).
_req(biol318,sci).
_req(ce1202,sci).
_req(cgs2301,sci).
_req(chem1111,sci).
_req(chem1112,sci).
_req(chem1311,sci).
_req(chem1312,sci).
_req(ee1202,sci).
_req(envr2302,sci).
_req(geog2302,sci).
_req(geos1103,sci).
_req(geos1104,sci).
_req(geos1303,sci).
_req(geos1304,sci).
_req(geos2302,sci).
_req(geos2310,sci).
_req(geos2409,sci).
_req(isis2305,sci).
_req(isis2308,sci).
_req(isns2359,sci).
_req(isns2367,sci).
_req(isns2368,sci).
_req(nats1311,sci).
_req(nats2330,sci).
_req(nsc3344,sci).
_req(nsc3361,sci).
_req(nsc4352,sci).
_req(nsc4354,sci).
_req(phys1301,sci).
_req(phys1302,sci).
_req(phys2422,sci).
_req(psy2364,sci).
_req(spau2233,sci).
_req(te1202,sci).
\ No newline at end of file
This diff is collapsed.
#include 'cs2015req.lp'.
#include 'cs2015req2.lp'.
#include 'cs2015grad.lp'.
#include 'cs2015audit.lp'.
ableToGraduate(Student):-
_metRequiredCourses(Student),
_auditMathCourses(Student),
_meetsHours(Student,lang,3),
_meetsHours(Student,art,3),
_meetsHours(Student,americanHist,6),
_meetsHours(Student,sci,4),
_meetsHours(Student,csGuided,9),
_meetsElectiveHours(Student,11).
_audit(Student):-
_auditRequiredCourses(Student),
_auditMathCourses(Student),
_auditHours(Student,lang,3),
_auditHours(Student,art,3),
_auditHours(Student,americanHist,6),
_auditHours(Student,sci,4),
_auditHours(Student,csGuided,9),
_auditElectiveHours(Student,11).
_main(Student):-
ableToGraduate(Student).
_main(Student):-
_audit(Student).
"""
This program writes 'main.lp'.
Pass in a transcript in the specified csv format.
"""
import csv,sys
if len(sys.argv) != 2:
print("Usage: give transcript as argument")
transcript = sys.argv[1]
try:
transcript = open(transcript)
except IOError:
print("transcript not found")
sys.exit()
csvr = list(csv.reader(csvfile))
student = csvr[0][0] #name of student is first value on first line
major = csvr[0][1] #major is second value on first line
year = csvr[0][2] #degree plan year is third value on first line
spec = csvr[2][0] #specialization is first value on third line
req = "%s/%s/%s%sreq.lp" % (major,year,major,year)
try:
req = open(req)
req = req.read()
except:
print('requirements file not found')
sys.exit()
with open('main.lp','w') as main:
main.write("student(%s,%s).\n"%(student,major))
csvr = csvr[1]
taken = '_taken(%s,[' % student
hasTaken = str()
for c in csvr:
#include only those courses that could possibly
#counted as electives in the 'taken list' i.e.
#those that are not required.
if not ('_req(%s,required).' % c) in req:
taken += "%s," % c
hasTaken += '_hasTaken(%s,%s).\n' % (student, c)
main.write('\n')
taken = taken[:-1]
taken += ']).\n'
main.write(hasTaken+'\n')
main.write(taken+'\n')
#write the student's specialization as a fact if it is
#declared in the transcript
if spec != 'none':
main.write('_specialization(%s,%s).\n' %(student,spec))
main.write("#include 'counting.lp'.\n")
main.write("#include '%s/%s/%s%srules.lp'.\n" % (major,year,major,year))
main.write('?- _main(%s).\n' % student)
_auditRequiredCourses(Student):-
_t(Student,comm1311),
_t(Student,rhet1302),
_t(Student,math2417),
_t(Student,govt2305),
_t(Student,govt2306),
_t(Student,math2418),
_t(Student,math2419),
_t(Student,math2420),
_t(Student,math2451),
_t(Student,math3310),
_t(Student,math3311),
_t(Student,math3379),
_t(Student,math4301),
_t(Student,math4302),
_t(Student,math4334),
_t(Student,stat4351).
_auditPhysics(Student):-
_t(Student,phys2325),
_t(Student,phys2125),
_takenFor(Student,phys2325,sci),
_takenFor(Student,phys2125,sci),
_t(Student,phys2326),
_t(Student,phys2126),
_takenFor(Student,phys2326,sci),
_takenFor(Student,phys2126,sci).
specialization(Student, applied):-
_auditPhysics(Student),
_t(Student,math4341),
_t(Student,math4355),
_t(Student,math4362),
_t(Student,stat4382).
specialization(Student, mathematics):-