Hi all this is the code of university time tabling ,my question is this I have 2 hard constraint,I want to know whether such red line codes are true or not :-local reference(days,5). :-local reference(periods,3). solve(T):- getval(days,Days), getval(periods,Periods), Timeslots is Days*Periods, course_data(Course_data), room_data(Room_data), length(Course_data,NCourse), length(Room_data,NRoom), course_period(Times), dim(CP,[NCourse]), length(Times,N), ( count(CT,1,N), foreach(X,Times),param(CP)do subscript(CP,[CT],X) ), dim(T,[NCourse,Timeslots,NRoom]), term_variables(T,Vars), Vars::0..1, (for(I,1,NCourse),param(T,Timeslots,NRoom,CP)do (for(J,1,Timeslots),foreach(L,L2),param(T,NRoom,I)do (for(K,1,NRoom),foreach(X,L),param(T,I,J)do subscript(T,[I,J,K],X) ) ), flatten(L2,L3), subscript(CP,[I],V), sum(L3) #=<V ), ( for(K,1,NRoom),param(T,Timeslots,NCourse)do (for(J,1,Timeslots),param(NCourse,T)do (for(I,1,NCourse),foreach(X,L),param()do subscript(T,[I,J,K],X) ) flatten(L,L1), sum(L1)#=<1 ) ), labeling(Vars) %,make_display_matrix(T, roster) . course_period(Times) :- course_data(L), course_period2(Times,L). course_period2([],[]). course_period2(Times,[(_,_,Time,_,_)|T]):- course_period2(Times2,T), Times=[Time|Times2]. %data course_data([ (c1,t1,4,3,60), (c2,t2,3,3,70), (c3,t3,4,2,90), (c4,t4,2,1,20), (c5,t5,6,4,35), (c6,t6,5,3,85), (c7,t2,5,4,60), (c8,t7,2,2,40), (c9,t4,4,2,30), (c10,t8,6,3,82), (c11,t2,3,3,90), (c12,t1,5,2,41), (c13,t3,6,3,62), (c14,t9,4,2,92), (c15,t8,3,3,80), (c16,t2,5,4,24), (c17,t1,5,3,47), (c18,t5,2,2,82), (c19,t6,7,4,52), (c20,t7,3,2,21)]). room_data([ (a, 100), (b, 50), (d ,30)]). curriculum_data([ (first,c1), (first ,c2), (first ,c3), (first ,c4), (first ,c5), (first ,c6), (first ,c7), (first ,c8), (second ,c9), (second ,c10), (second ,c11), (second ,c12), (second ,c13), (third ,c14), (third ,c15), (third ,c16), (third ,c17), (third ,c18), (third ,c19), (third ,c20)]).Received on Fri Aug 06 2010 - 19:58:07 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST