/usr/share/mozart/doc/demo/node13.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>The actual scheduler: Scheduler.oz</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node12.html#code.college.controller"><< Prev</A></TD><TD><A href="college.html">- Up -</A></TD><TD><A href="node14.html#code.college.graphics">Next >></A></TD></TR></TABLE><DIV class="unnumbered" id="code.college.scheduler"><H3><A name="code.college.scheduler">The actual scheduler: <CODE>Scheduler.oz</CODE></A></H3><P class="margin"><A href="College/Scheduler.oz">Source File</A></P><P> </P><BLOCKQUOTE><PRE><SPAN class="keyword">functor</SPAN> <BR> <BR><SPAN class="keyword">import</SPAN> <BR> <BR> Open<BR> <BR> FD<BR> <BR> OS<BR> <BR> Search<BR> <BR> Compiler<BR> <BR> Inspector(inspect: Inspect)<BR> <BR> Graphics(drawSchedule: DrawSchedule)<BR> <BR> Controller(topWindow: TopWindow)<BR> Latex(laTeX: LaTeX)<BR> Main(controllerLabel: ControllerLabel)<BR> <BR> Common(editor: Editor<BR> monday: Monday<BR> tuesday: Tuesday<BR> wednesday: Wednesday<BR> thursday: Thursday<BR> friday: Friday<BR> quartersPerDay: QuartersPerDay<BR> quartersPerHour: QuartersPerHour)<BR> <BR><SPAN class="keyword">export</SPAN> <BR> <BR> TimeTable<BR> <BR><SPAN class="keyword">define</SPAN> <BR> <BR> HourLimit = 180<BR> LecturesStartForDay = 8<BR> MaximumRooms = 7<BR> Teacher1Off = 3<BR> <BR> Week = [Monday Tuesday Wednesday Thursday Friday] <BR> <BR> MorningQuarters = 18<BR> <BR> [MondayM TuesdayM WednesdayM ThursdayM FridayM]<BR> = {Map Week <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> S<SPAN class="keyword">#</SPAN>_} S<SPAN class="keyword">#</SPAN>(S <SPAN class="keyword">+</SPAN> MorningQuarters <SPAN class="keyword">-</SPAN> 1) <SPAN class="keyword">end</SPAN>}<BR> <BR> Afternoon <BR> [MondayA TuesdayA WednesdayA ThursdayA FridayA]<BR> = Afternoon<BR> = {Map Week <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> S<SPAN class="keyword">#</SPAN>E} (S <SPAN class="keyword">+</SPAN> MorningQuarters)<SPAN class="keyword">#</SPAN>E <SPAN class="keyword">end</SPAN>}<BR> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">DayTimeToQuarters</SPAN> Day FH FQ TH TQ}<BR> Left Right Offset <SPAN class="keyword">in</SPAN> <BR> Offset = (36 <SPAN class="keyword">*</SPAN> (Day<SPAN class="keyword">.</SPAN>1 <SPAN class="keyword">div</SPAN> QuartersPerDay) <SPAN class="keyword">+</SPAN> 1) <BR> Left = Offset <SPAN class="keyword">+</SPAN> (FH <SPAN class="keyword">-</SPAN> LecturesStartForDay) <SPAN class="keyword">*</SPAN> QuartersPerHour <SPAN class="keyword">+</SPAN> FQ <SPAN class="keyword">-</SPAN> 1<BR> Right = Offset <SPAN class="keyword">+</SPAN> (TH<SPAN class="keyword">-</SPAN>LecturesStartForDay) <SPAN class="keyword">*</SPAN> QuartersPerHour <SPAN class="keyword">+</SPAN> TQ <SPAN class="keyword">-</SPAN> 1<BR> Left<SPAN class="keyword">#</SPAN>Right<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> AstaTime = {DayTimeToQuarters Tuesday 12 3 13 3}<BR> <BR> <BR> %% <SPAN class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<BR></SPAN> %% <SPAN class="comment">Lecture and Professor Manipulation :-} Functions<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<BR></SPAN> <BR> <SPAN class="keyword">local</SPAN> <BR> <BR> DayMap= map(monday: Monday<BR> tuesday: Tuesday<BR> wednesday: Wednesday<BR> thursday: Thursday<BR> friday: Friday)<BR> <BR> %% <SPAN class="comment">Translate the constraint description<BR></SPAN> %% <SPAN class="comment">into a domain that can stand after /* :: and \:: */<BR></SPAN> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">MakeC</SPAN> Desc}<BR> <SPAN class="keyword">case</SPAN> Desc<BR> <SPAN class="keyword">of</SPAN> inDays(L) <SPAN class="keyword">then</SPAN> {Map L <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> D} DayMap<SPAN class="keyword">.</SPAN>D <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">[]</SPAN> weekInterval(SH<SPAN class="keyword">#</SPAN>SM<SPAN class="keyword">#</SPAN>EH<SPAN class="keyword">#</SPAN>EM) <SPAN class="keyword">then</SPAN> <BR> {Map Week<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Day}<BR> {DayTimeToQuarters Day SH SM <SPAN class="keyword">div</SPAN> 15 EH EM <SPAN class="keyword">div</SPAN> 15}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">[]</SPAN> dayInterval(Day<SPAN class="keyword">#</SPAN>SH<SPAN class="keyword">#</SPAN>SM<SPAN class="keyword">#</SPAN>EH<SPAN class="keyword">#</SPAN>EM) <SPAN class="keyword">then</SPAN> <BR> [{DayTimeToQuarters DayMap<SPAN class="keyword">.</SPAN>Day SH (SM <SPAN class="keyword">div</SPAN> 15) EH (EM <SPAN class="keyword">div</SPAN> 15)}]<BR> <SPAN class="keyword">[]</SPAN> fix(Day<SPAN class="keyword">#</SPAN>H<SPAN class="keyword">#</SPAN>M) <SPAN class="keyword">then</SPAN> <BR> [{DayTimeToQuarters DayMap<SPAN class="keyword">.</SPAN>Day H (M <SPAN class="keyword">div</SPAN> 15) H (M <SPAN class="keyword">div</SPAN> 15)}]<BR> <SPAN class="keyword">else</SPAN> {Record<SPAN class="keyword">.</SPAN>foldR Desc<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> D In} {Append {MakeC D} In} <SPAN class="keyword">end</SPAN> nil}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %% <SPAN class="comment">compute the constraint procedure<BR></SPAN> %% <SPAN class="comment">for a lecturer from his/her constraint description<BR></SPAN> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">ApplyConstraint</SPAN> Desc X}<BR> <SPAN class="keyword">case</SPAN> {Label Desc}<BR> <SPAN class="keyword">of</SPAN> noT <SPAN class="keyword">then</SPAN> X <SPAN class="keyword">::</SPAN> compl({MakeC Desc<SPAN class="keyword">.</SPAN>1})<BR> <SPAN class="keyword">[]</SPAN> nil <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">else</SPAN> X <SPAN class="keyword">::</SPAN> {MakeC Desc}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %% <SPAN class="comment">compute the lectures of a prof<BR></SPAN> %% <SPAN class="comment">from the lecture list<BR></SPAN> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">ProfToLectures</SPAN> PName Ls}<BR> {Filter Ls <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> L} L<SPAN class="keyword">.</SPAN>professor<SPAN class="keyword">==</SPAN>PName <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">in</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">MakeLectures</SPAN> LecturesDescs Semester Ordering}<BR> {Map {Record<SPAN class="keyword">.</SPAN>toList LecturesDescs<SPAN class="keyword">.</SPAN>Semester}<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Ls}<BR> {Map Ls<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> L}<BR> Start = {FD<SPAN class="keyword">.</SPAN>int 1<SPAN class="keyword">#</SPAN>(HourLimit<SPAN class="keyword">-</SPAN>L<SPAN class="keyword">.</SPAN>dur)}<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">if</SPAN> {HasFeature L constraints}<BR> <SPAN class="keyword">then</SPAN> {ApplyConstraint L<SPAN class="keyword">.</SPAN>constraints Start}<BR> <SPAN class="keyword">else</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> {Adjoin L l(start: Start<BR> ordering: Ordering<BR> semester: Semester)}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %% <SPAN class="comment">translate the prof record into a<BR></SPAN> %% <SPAN class="comment">list of records, containing constraint procedures<BR></SPAN> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">MakeProfessors</SPAN> ProfDesc Ls}<BR> {Record<SPAN class="keyword">.</SPAN>foldRInd ProfDesc<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> I X In}<BR> PLs={ProfToLectures I Ls}<BR> <SPAN class="keyword">in</SPAN> <BR> {ForAll PLs <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> PL} {ApplyConstraint X PL<SPAN class="keyword">.</SPAN>start} <SPAN class="keyword">end</SPAN>}<BR> professor(lectures:PLs name:I) <SPAN class="keyword">|</SPAN> In<BR> <SPAN class="keyword">end</SPAN> <BR> nil}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %% <SPAN class="comment">get Lectures with size out of a given list of Specifiers<BR></SPAN> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">FilterSize</SPAN> Specifiers Lectures}<BR> {Filter Lectures <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> X} {Member X<SPAN class="keyword">.</SPAN>size Specifiers} <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %% <SPAN class="comment">make record for all lectures for easy access<BR></SPAN> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">MakeLectureRecord</SPAN> Flats}<BR> {List<SPAN class="keyword">.</SPAN>toRecord lectures {Map Flats <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> L} L<SPAN class="keyword">.</SPAN>name<SPAN class="keyword">#</SPAN>L <SPAN class="keyword">end</SPAN>}}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %% <SPAN class="comment">search for professor in list of profs<BR></SPAN> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">SearchProf</SPAN> Profs Name}<BR> {List<SPAN class="keyword">.</SPAN>dropWhile Profs <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> P} P<SPAN class="keyword">.</SPAN>name <SPAN class="keyword">\=</SPAN> Name <SPAN class="keyword">end</SPAN>}<SPAN class="keyword">.</SPAN>1<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %% <SPAN class="comment">%%%%%%%%%%%<BR></SPAN> %% <SPAN class="comment">Enumeration<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%%<BR></SPAN> <BR> <SPAN class="keyword">local</SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">SkipWait</SPAN> Xs}<BR> <SPAN class="keyword">case</SPAN> Xs<BR> <SPAN class="keyword">of</SPAN> X<SPAN class="keyword">|</SPAN>Xr <SPAN class="keyword">then</SPAN> <SPAN class="keyword">case</SPAN> {FD<SPAN class="keyword">.</SPAN>reflect<SPAN class="keyword">.</SPAN>size X<SPAN class="keyword">.</SPAN>start}<BR> <SPAN class="keyword">of</SPAN> 1 <SPAN class="keyword">then</SPAN> {SkipWait Xr}<BR> <SPAN class="keyword">else</SPAN> Xs<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> nil <SPAN class="keyword">then</SPAN> nil<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Choose</SPAN> Xs HoleTail HoleHead MinYet SizeYet ?Min ?Ys}<BR> <SPAN class="keyword">case</SPAN> Xs<BR> <SPAN class="keyword">of</SPAN> X<SPAN class="keyword">|</SPAN>Xr <SPAN class="keyword">then</SPAN> <BR> SizeX = {FD<SPAN class="keyword">.</SPAN>reflect<SPAN class="keyword">.</SPAN>size X<SPAN class="keyword">.</SPAN>start} <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">case</SPAN> SizeX <SPAN class="keyword">of</SPAN> 1 <SPAN class="keyword">then</SPAN> <BR> {Choose Xr HoleTail HoleHead MinYet SizeYet Min Ys}<BR> <SPAN class="keyword">elseif</SPAN> SizeX <SPAN class="keyword"><</SPAN> SizeYet <SPAN class="keyword">then</SPAN> <BR> NewHole <SPAN class="keyword">in</SPAN> <BR> HoleTail = MinYet <SPAN class="keyword">|</SPAN> HoleHead<BR> {Choose Xr Ys NewHole X SizeX Min NewHole}<BR> <SPAN class="keyword">else</SPAN> <BR> Ys=X <SPAN class="keyword">|</SPAN> {Choose Xr HoleTail HoleHead MinYet SizeYet Min}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> nil <SPAN class="keyword">then</SPAN> Min = MinYet Ys = nil HoleTail = HoleHead<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Cost</SPAN> I Ls C}<BR> <SPAN class="keyword">case</SPAN> Ls <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> <BR> {Exception<SPAN class="keyword">.</SPAN>raiseError college(Cost [I Ls C] <SPAN class="string">'tragic error'</SPAN>)}<BR> _<BR> <SPAN class="keyword">[]</SPAN> A<SPAN class="keyword">#</SPAN>B<SPAN class="keyword">|</SPAN>Lr <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">if</SPAN> A <SPAN class="keyword">=<</SPAN> I <SPAN class="keyword">andthen</SPAN> I <SPAN class="keyword">=<</SPAN> B<BR> <SPAN class="keyword">then</SPAN> C<BR> <SPAN class="keyword">else</SPAN> {Cost I Lr C<SPAN class="keyword">+</SPAN>1}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">GetFirst</SPAN> Domain Min MinVal Ordering}<BR> <SPAN class="keyword">case</SPAN> Domain <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> Min<BR> <SPAN class="keyword">[]</SPAN> D<SPAN class="keyword">|</SPAN>Dr<BR> <SPAN class="keyword">then</SPAN> TMinVal = {Cost D Ordering 1} <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">if</SPAN> TMinVal<SPAN class="keyword"><</SPAN>MinVal <SPAN class="keyword">then</SPAN> {GetFirst Dr D TMinVal Ordering}<BR> <SPAN class="keyword">else</SPAN> {GetFirst Dr Min MinVal Ordering}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Enum</SPAN> Xs}<BR> <SPAN class="keyword">choice</SPAN> <BR> <SPAN class="keyword">case</SPAN> {SkipWait Xs}<BR> <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">[]</SPAN> X<SPAN class="keyword">|</SPAN>Xr <SPAN class="keyword">then</SPAN> <BR> Y Yr Hole Val YDom YVar <SPAN class="keyword">in</SPAN> <BR> {Choose Xr Yr Hole X {FD<SPAN class="keyword">.</SPAN>reflect<SPAN class="keyword">.</SPAN>size X<SPAN class="keyword">.</SPAN>start} Y Hole}<BR> {Wait Y}<BR> YVar = Y<SPAN class="keyword">.</SPAN>start<BR> YDom = {FD<SPAN class="keyword">.</SPAN>reflect<SPAN class="keyword">.</SPAN>domList YVar}<BR> Val = {GetFirst YDom<SPAN class="keyword">.</SPAN>2 YDom<SPAN class="keyword">.</SPAN>1 {Cost YDom<SPAN class="keyword">.</SPAN>1 Y<SPAN class="keyword">.</SPAN>ordering 1}<BR> Y<SPAN class="keyword">.</SPAN>ordering}<BR> <SPAN class="keyword">choice</SPAN> <BR> YVar=Val {Enum Yr}<BR> <SPAN class="keyword">[]</SPAN> <BR> YVar<SPAN class="keyword">\=:</SPAN>Val {Enum Y<SPAN class="keyword">|</SPAN>Yr}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %% <SPAN class="comment">%%%%%%%%%%%%%%%%%%%%%<BR></SPAN> %% <SPAN class="comment">Branch and Bound Cost Function<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%%%%%%%%%%%%<BR></SPAN> <SPAN class="keyword">local</SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">SumUp</SPAN> Lectures Time}<BR> <SPAN class="keyword">case</SPAN> Lectures <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> nil<BR> <SPAN class="keyword">[]</SPAN> L<SPAN class="keyword">|</SPAN>Lr<BR> <SPAN class="keyword">then</SPAN> <SPAN class="keyword">case</SPAN> {Atom<SPAN class="keyword">.</SPAN>toString L<SPAN class="keyword">.</SPAN>name}<SPAN class="keyword">.</SPAN>1<BR> <SPAN class="keyword">of</SPAN> <SPAN class="string">&M</SPAN> <SPAN class="keyword">then</SPAN> 0<SPAN class="keyword">|</SPAN>{SumUp Lr Time}<BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">&F</SPAN> <SPAN class="keyword">then</SPAN> 0<SPAN class="keyword">|</SPAN>{SumUp Lr Time}<BR> <SPAN class="keyword">else</SPAN> (L<SPAN class="keyword">.</SPAN>start<SPAN class="keyword">::</SPAN>Time)<SPAN class="keyword">|</SPAN>{SumUp Lr Time}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Cost</SPAN> Lectures}<BR> Costs = {FD<SPAN class="keyword">.</SPAN>decl} <SPAN class="keyword">in</SPAN> <BR> {FD<SPAN class="keyword">.</SPAN>sum {SumUp Lectures [MondayA TuesdayA WednesdayA ThursdayA FridayA]} <SPAN class="string">'=:'</SPAN> Costs}<BR> Costs<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <BR> %% <SPAN class="comment">%%%%%%%%%%%%%%%%%%%%%<BR></SPAN> %% <SPAN class="comment">Constraint Procedures<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%%%%%%%%%%%%<BR></SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">OnSpecialDayOnly</SPAN> Lectures Day}<BR> {ForAll Lectures <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Lec} Lec<SPAN class="keyword">.</SPAN>start <SPAN class="keyword">::</SPAN> Day <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">OnSpecialTimeOnly</SPAN> Lectures Time}<BR> {ForAll Lectures <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Lec} Lec<SPAN class="keyword">.</SPAN>start <SPAN class="keyword">::</SPAN> Time <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">ForbidAsta</SPAN> Lectures}<BR> {ForAll Lectures<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Lec} Lec<SPAN class="keyword">.</SPAN>start <SPAN class="keyword">::</SPAN> compl((AstaTime<SPAN class="keyword">.</SPAN>1<SPAN class="keyword">-</SPAN>Lec<SPAN class="keyword">.</SPAN>dur<SPAN class="keyword">+</SPAN>1)<SPAN class="keyword">#</SPAN>AstaTime<SPAN class="keyword">.</SPAN>2) <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">DayBreak</SPAN> Break Lectures}<BR> {ForAll Lectures<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Lec}<BR> {ForAll Break <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> B}<BR> Left = (B<SPAN class="keyword">.</SPAN>1<SPAN class="keyword">-</SPAN>Lec<SPAN class="keyword">.</SPAN>dur)<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">if</SPAN> Left <SPAN class="keyword"><</SPAN> 0 <SPAN class="keyword">then</SPAN> <BR> Lec<SPAN class="keyword">.</SPAN>start <SPAN class="keyword">::</SPAN> compl(0<SPAN class="keyword">#</SPAN>B<SPAN class="keyword">.</SPAN>2)<BR> <SPAN class="keyword">else</SPAN> <BR> Lec<SPAN class="keyword">.</SPAN>start <SPAN class="keyword">::</SPAN> compl(Left<SPAN class="keyword">#</SPAN>B<SPAN class="keyword">.</SPAN>2)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">NotParallel</SPAN> Offset Teacher1 Teacher15}<BR> {ForAll Teacher1<SPAN class="keyword">.</SPAN>lectures<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> FL}<BR> {ForAll Teacher15<SPAN class="keyword">.</SPAN>lectures<BR> <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> LFL}<BR> {FD<SPAN class="keyword">.</SPAN>disjoint FL<SPAN class="keyword">.</SPAN>start FL<SPAN class="keyword">.</SPAN>dur<SPAN class="keyword">+</SPAN>Offset LFL<SPAN class="keyword">.</SPAN>start LFL<SPAN class="keyword">.</SPAN>dur<SPAN class="keyword">+</SPAN>Offset}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %% <SPAN class="comment">The lectures of a semester must not overlap<BR></SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">NoOverlapSemester</SPAN> Lectures}<BR> <SPAN class="keyword">case</SPAN> Lectures <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">[]</SPAN> L<SPAN class="keyword">|</SPAN>Lr<BR> <SPAN class="keyword">then</SPAN> {NoOverlap1 Lr L} {NoOverlapSemester Lr}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">NoOverlap1</SPAN> Lecs Lec1}<BR> <SPAN class="keyword">case</SPAN> Lecs <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">[]</SPAN> L<SPAN class="keyword">|</SPAN>Lr<BR> <SPAN class="keyword">then</SPAN> {NoOverlap2 Lec1 L} {NoOverlap1 Lr Lec1}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">NoOverlap2</SPAN> L1 L2}<BR> {ForAll L1<BR> <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> L}<BR> {ForAll L2<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> LP}<BR> %% <SPAN class="comment">After one hour must be a quarter<BR></SPAN> %% <SPAN class="comment">and after two hours two quarters<BR></SPAN> %% <SPAN class="comment">recreation time<BR></SPAN> LDur LPDur <SPAN class="keyword">in</SPAN> <BR> LDur= <SPAN class="keyword">if</SPAN> L<SPAN class="keyword">.</SPAN>dur<SPAN class="keyword"><</SPAN>4<BR> <SPAN class="keyword">then</SPAN> L<SPAN class="keyword">.</SPAN>dur<SPAN class="keyword">+</SPAN>1<BR> <SPAN class="keyword">else</SPAN> L<SPAN class="keyword">.</SPAN>dur<SPAN class="keyword">+</SPAN>2<BR> <SPAN class="keyword">end</SPAN> <BR> LPDur= <SPAN class="keyword">if</SPAN> LP<SPAN class="keyword">.</SPAN>dur<SPAN class="keyword"><</SPAN>4<BR> <SPAN class="keyword">then</SPAN> LP<SPAN class="keyword">.</SPAN>dur<SPAN class="keyword">+</SPAN>1<BR> <SPAN class="keyword">else</SPAN> LP<SPAN class="keyword">.</SPAN>dur<SPAN class="keyword">+</SPAN>2<BR> <SPAN class="keyword">end</SPAN> <BR> {FD<SPAN class="keyword">.</SPAN>disjoint L<SPAN class="keyword">.</SPAN>start LDur LP<SPAN class="keyword">.</SPAN>start LPDur}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %% <SPAN class="comment">The lectures of a professor must not overlap<BR></SPAN> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">NoOverlapLectures</SPAN> Lectures}<BR> <SPAN class="keyword">case</SPAN> Lectures <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">[]</SPAN> L<SPAN class="keyword">|</SPAN>Lr<BR> <SPAN class="keyword">then</SPAN> {NoOverlapLecs1 L Lr} {NoOverlapLectures Lr}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">NoOverlapLecs1</SPAN> Lec Lec1}<BR> <SPAN class="keyword">case</SPAN> Lec1 <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">[]</SPAN> L<SPAN class="keyword">|</SPAN>Lr<BR> <SPAN class="keyword">then</SPAN> {NoOverlapLecs2 Lec L} {NoOverlapLecs1 Lec Lr}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">NoOverlapLecs2</SPAN> L1 L2}<BR> %% <SPAN class="comment">After one hour must be a quarter<BR></SPAN> %% <SPAN class="comment">and after two hours two quarters<BR></SPAN> %% <SPAN class="comment">recreation time<BR></SPAN> L1Dur L2Dur <SPAN class="keyword">in</SPAN> <BR> L1Dur= <SPAN class="keyword">if</SPAN> L1<SPAN class="keyword">.</SPAN>dur <SPAN class="keyword"><</SPAN> 4 <SPAN class="keyword">then</SPAN> L1<SPAN class="keyword">.</SPAN>dur <SPAN class="keyword">+</SPAN> 1 <SPAN class="keyword">else</SPAN> L1<SPAN class="keyword">.</SPAN>dur <SPAN class="keyword">+</SPAN> 2 <SPAN class="keyword">end</SPAN> <BR> L2Dur= <SPAN class="keyword">if</SPAN> L2<SPAN class="keyword">.</SPAN>dur <SPAN class="keyword"><</SPAN> 4 <SPAN class="keyword">then</SPAN> L2<SPAN class="keyword">.</SPAN>dur <SPAN class="keyword">+</SPAN> 1 <SPAN class="keyword">else</SPAN> L2<SPAN class="keyword">.</SPAN>dur <SPAN class="keyword">+</SPAN> 2<BR> <SPAN class="keyword">end</SPAN> <BR> {FD<SPAN class="keyword">.</SPAN>disjoint L1<SPAN class="keyword">.</SPAN>start L1Dur L2<SPAN class="keyword">.</SPAN>start L2Dur}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %% <SPAN class="comment">Constraint AtMostLectures for rooms<BR></SPAN> <BR> <SPAN class="keyword">local</SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">SumUpLectures</SPAN> Lectures Hour}<BR> <SPAN class="keyword">case</SPAN> Lectures<BR> <SPAN class="keyword">of</SPAN> L<SPAN class="keyword">|</SPAN>Lr<BR> <SPAN class="keyword">then</SPAN> <BR> %% <SPAN class="comment">Rooms are empty for a quarter after each lecture<BR></SPAN> Left = Hour<SPAN class="keyword">-</SPAN>(L<SPAN class="keyword">.</SPAN>dur<SPAN class="keyword">+</SPAN>1)<SPAN class="keyword">+</SPAN>1<BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">if</SPAN> Left <SPAN class="keyword"><</SPAN> 0 <SPAN class="keyword">then</SPAN> (L<SPAN class="keyword">.</SPAN>start <SPAN class="keyword">::</SPAN> 0<SPAN class="keyword">#</SPAN>Hour)<SPAN class="keyword">|</SPAN>{SumUpLectures Lr Hour}<BR> <SPAN class="keyword">else</SPAN> (L<SPAN class="keyword">.</SPAN>start <SPAN class="keyword">::</SPAN> Left<SPAN class="keyword">#</SPAN>Hour)<SPAN class="keyword">|</SPAN>{SumUpLectures Lr Hour}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> nil <SPAN class="keyword">then</SPAN> nil<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">AtMostLectures</SPAN> Lectures Limit}<BR> {For 1 HourLimit 1<BR> <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> Hour}<BR> {FD<SPAN class="keyword">.</SPAN>sum {SumUpLectures Lectures Hour} <SPAN class="string">'=<:'</SPAN> Limit}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %% <SPAN class="comment">Constraint ThreeDaysOnly and OnDifferentDays<BR></SPAN> <BR> <SPAN class="keyword">local</SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">SumUp</SPAN> Lectures Day}<BR> <SPAN class="keyword">case</SPAN> Lectures <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> nil<BR> <SPAN class="keyword">[]</SPAN> L<SPAN class="keyword">|</SPAN>Lr<BR> <SPAN class="keyword">then</SPAN> (L<SPAN class="keyword">.</SPAN>start <SPAN class="keyword">::</SPAN> Day)<SPAN class="keyword">|</SPAN>{SumUp Lr Day}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">SumUpDays</SPAN> Lectures BDay Day}<BR> S= {SumUp Lectures Day}<BR> <SPAN class="keyword">in</SPAN> <BR> BDay = ({FoldL S FD<SPAN class="keyword">.</SPAN>plus 0} <SPAN class="keyword">>=:</SPAN> 1)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">ThreeDaysOnly</SPAN> Lectures DayLimit}<BR> [BMo BTu BWe BTh BFr]={FD<SPAN class="keyword">.</SPAN>dom 0<SPAN class="keyword">#</SPAN>1}<BR> <SPAN class="keyword">in</SPAN> <BR> BMo<SPAN class="keyword">+</SPAN>BTu<SPAN class="keyword">+</SPAN>BWe<SPAN class="keyword">+</SPAN>BTh<SPAN class="keyword">+</SPAN>BFr <SPAN class="keyword">=<:</SPAN> DayLimit<BR> {SumUpDays Lectures BMo Monday}<BR> {SumUpDays Lectures BTu Tuesday}<BR> {SumUpDays Lectures BWe Wednesday}<BR> {SumUpDays Lectures BTh Thursday}<BR> {SumUpDays Lectures BFr Friday}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">OnDifferentDays</SPAN> Lectures}<BR> [BMo BTu BWe BTh BFr]={FD<SPAN class="keyword">.</SPAN>dom 0<SPAN class="keyword">#</SPAN>1}<BR> <SPAN class="keyword">in</SPAN> <BR> BMo<SPAN class="keyword">+</SPAN>BTu<SPAN class="keyword">+</SPAN>BWe<SPAN class="keyword">+</SPAN>BTh<SPAN class="keyword">+</SPAN>BFr <SPAN class="keyword">=:</SPAN> {Length Lectures}<BR> {SumUpDays Lectures BMo Monday}<BR> {SumUpDays Lectures BTu Tuesday}<BR> {SumUpDays Lectures BWe Wednesday}<BR> {SumUpDays Lectures BTh Thursday}<BR> {SumUpDays Lectures BFr Friday}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">OnSameDay</SPAN> Lectures}<BR> [BMo BTu BWe BTh BFr]={FD<SPAN class="keyword">.</SPAN>dom 0<SPAN class="keyword">#</SPAN>1}<BR> <SPAN class="keyword">in</SPAN> <BR> BMo<SPAN class="keyword">+</SPAN>BTu<SPAN class="keyword">+</SPAN>BWe<SPAN class="keyword">+</SPAN>BTh<SPAN class="keyword">+</SPAN>BFr <SPAN class="keyword">=:</SPAN> 1<BR> {SumUpDays Lectures BMo Monday}<BR> {SumUpDays Lectures BTu Tuesday}<BR> {SumUpDays Lectures BWe Wednesday}<BR> {SumUpDays Lectures BTh Thursday}<BR> {SumUpDays Lectures BFr Friday}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">local</SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">SumUpOverlaps</SPAN> L1 Lectures}<BR> <SPAN class="keyword">case</SPAN> Lectures <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> nil<BR> <SPAN class="keyword">[]</SPAN> L2<SPAN class="keyword">|</SPAN>Lr <SPAN class="keyword">then</SPAN> B={FD<SPAN class="keyword">.</SPAN>int 0<SPAN class="keyword">#</SPAN>1} L1Dur L2Dur <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">if</SPAN> L1<SPAN class="keyword">.</SPAN>name<SPAN class="keyword">==</SPAN>L2<SPAN class="keyword">.</SPAN>name <SPAN class="keyword">then</SPAN> 0<SPAN class="keyword">|</SPAN>{SumUpOverlaps L1 Lr}<BR> <SPAN class="keyword">else</SPAN> L1S L2S <SPAN class="keyword">in</SPAN> <BR> L1Dur= <SPAN class="keyword">if</SPAN> L1<SPAN class="keyword">.</SPAN>dur <SPAN class="keyword"><</SPAN> 4 <SPAN class="keyword">then</SPAN> L1<SPAN class="keyword">.</SPAN>dur <SPAN class="keyword">+</SPAN> 1 <SPAN class="keyword">else</SPAN> L1<SPAN class="keyword">.</SPAN>dur <SPAN class="keyword">+</SPAN> 2 <SPAN class="keyword">end</SPAN> <BR> L2Dur= <SPAN class="keyword">if</SPAN> L2<SPAN class="keyword">.</SPAN>dur <SPAN class="keyword"><</SPAN> 4 <SPAN class="keyword">then</SPAN> L2<SPAN class="keyword">.</SPAN>dur <SPAN class="keyword">+</SPAN> 1 <SPAN class="keyword">else</SPAN> L2<SPAN class="keyword">.</SPAN>dur <SPAN class="keyword">+</SPAN> 2 <SPAN class="keyword">end</SPAN> <BR> L1S = L1<SPAN class="keyword">.</SPAN>start<BR> L2S = L2<SPAN class="keyword">.</SPAN>start<BR> <BR> /* <SPAN class="comment">That is the (operational) semantics of FD.tasksOverlap.<BR> FD.tasksOverlap implements constructive disjunction.<BR> condis<BR> B=:1<BR> L1S + L1Dur >: L2S<BR> L2S + L2Dur >: L1S<BR> []<BR> B=:0<BR> L1S + L1Dur =<: L2S<BR> []<BR> B=:0<BR> L2S + L2Dur =<: L1S<BR> end<BR> */</SPAN> <BR> {FD<SPAN class="keyword">.</SPAN>tasksOverlap L1S L1Dur L2S L2Dur B}<BR> B<SPAN class="keyword">|</SPAN>{SumUpOverlaps L1 Lr}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">AtmostOneOverlap</SPAN> Lecture Lectures}<BR> {FD<SPAN class="keyword">.</SPAN>sum {SumUpOverlaps Lecture Lectures} <SPAN class="string">'=<:'</SPAN> 1}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <BR> %% <SPAN class="comment">%%%%%%%%%%%<BR></SPAN> %% <SPAN class="comment">The Problem<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%%<BR></SPAN> <BR> %% <SPAN class="comment">MakeProblem makes the problem procedure<BR></SPAN> %% <SPAN class="comment">using the problem description as global variable<BR></SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">MakeProblem</SPAN> ProblemDescription}<BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> FlatAllLectures}<BR> <BR> %% <SPAN class="comment">%%%%%%%%<BR></SPAN> %% <SPAN class="comment">Lectures<BR></SPAN> %% <SPAN class="comment">%%%%%%%%<BR></SPAN> <BR> LecturesDescription = ProblemDescription<SPAN class="keyword">.</SPAN>lectures<BR> <BR> %% <SPAN class="comment">Second Semester<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%%%%%%<BR></SPAN> <BR> LecturesSecond = {MakeLectures<BR> LecturesDescription<BR> second<BR> %% <SPAN class="comment">other priorities<BR></SPAN> <BR> [MondayM MondayA<BR> TuesdayA TuesdayM<BR> WednesdayM WednesdayA<BR> FridayM FridayA<BR> ThursdayM ThursdayA<BR> ]<BR> }<BR> %% <SPAN class="comment">Fourth Semester<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%%%%%%<BR></SPAN> <BR> LecturesFourth = {MakeLectures<BR> LecturesDescription<BR> fourth<BR> %% <SPAN class="comment">other priorities<BR></SPAN> <BR> [<BR> WednesdayM WednesdayA<BR> TuesdayM TuesdayA<BR> MondayM MondayA<BR> ThursdayM ThursdayA<BR> FridayM FridayA<BR> ]<BR> <BR> <BR> }<BR> GrundStudiumLectures = {Append LecturesSecond LecturesFourth}<BR> FlatGrundStudiumLectures = {List<SPAN class="keyword">.</SPAN>flatten GrundStudiumLectures}<BR> <BR> %% <SPAN class="comment">Sixth Semester<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%%%%%<BR></SPAN> <BR> LecturesSixth = {MakeLectures<BR> LecturesDescription<BR> sixth<BR> %% <SPAN class="comment">other priorities<BR></SPAN> <BR> [ WednesdayM WednesdayA<BR> FridayM FridayA<BR> ThursdayM ThursdayA<BR> MondayM MondayA<BR> TuesdayM TuesdayA<BR> ]<BR> }<BR> <BR> FlatLecturesSixth = {List<SPAN class="keyword">.</SPAN>flatten LecturesSixth}<BR> <BR> %% <SPAN class="comment">Eighth Semester<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%%%%%%<BR></SPAN> <BR> LecturesEighth = {MakeLectures<BR> LecturesDescription<BR> eighth<BR> [<BR> ThursdayM ThursdayA<BR> WednesdayA WednesdayM<BR> MondayA MondayM<BR> TuesdayA TuesdayM<BR> FridayM FridayA<BR> ]}<BR> <BR> FlatLecturesEighth = {List<SPAN class="keyword">.</SPAN>flatten LecturesEighth}<BR> <BR> NotOnThursdayLectures = {Append GrundStudiumLectures LecturesSixth}<BR> AllSemesterLectures = {Append NotOnThursdayLectures LecturesEighth}<BR> FlatAllSemesterLectures={List<SPAN class="keyword">.</SPAN>flatten AllSemesterLectures}<BR> <BR> %% <SPAN class="comment">Medien Lectures<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%%%%%%<BR></SPAN> <BR> MedienLectures = {MakeLectures<BR> LecturesDescription<BR> medien<BR> [<BR> ThursdayA TuesdayA<BR> TuesdayM ThursdayM<BR> WednesdayM WednesdayA<BR> MondayM MondayA<BR> FridayM FridayA<BR> ]}<BR> <BR> FlatMedienLectures = {List<SPAN class="keyword">.</SPAN>flatten MedienLectures}<BR> <BR> %% <SPAN class="comment">Fakult Lectures<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%%%%%%<BR></SPAN> <BR> FakLectures = {MakeLectures<BR> LecturesDescription<BR> fac<BR> [<BR> WednesdayM WednesdayA<BR> ThursdayM ThursdayA<BR> MondayM MondayA<BR> FridayM FridayA<BR> TuesdayM TuesdayA<BR> ]<BR> }<BR> <BR> FlatFakLectures = {List<SPAN class="keyword">.</SPAN>flatten FakLectures}<BR> <BR> AllLectures = {Append AllSemesterLectures<BR> {Append MedienLectures FakLectures}}<BR> <BR> <SPAN class="keyword">!</SPAN>FlatAllLectures = {List<SPAN class="keyword">.</SPAN>flatten AllLectures}<BR> <BR> L = {MakeLectureRecord FlatAllLectures}<BR> <BR> %% <SPAN class="comment">%%%%%%%%%%<BR></SPAN> %% <SPAN class="comment">Professors<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%<BR></SPAN> <BR> ProfessorsDescription = ProblemDescription<SPAN class="keyword">.</SPAN>professors<BR> <BR> Professors = {MakeProfessors ProfessorsDescription FlatAllLectures}<BR> <BR> <SPAN class="keyword">in</SPAN> <BR> <BR> %% <SPAN class="comment">%%%%%%%%%%%%%%%<BR></SPAN> %% <SPAN class="comment">The Constraints<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%%%%%%<BR></SPAN> <BR> %% <SPAN class="comment">General constraints<BR></SPAN> %% <SPAN class="comment">Lecture must be finished at 17.00<BR></SPAN> <BR> {ForAll FlatAllLectures<BR> <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> L}<BR> Dur = L<SPAN class="keyword">.</SPAN>dur<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">AfterHours</SPAN> Day} Day<SPAN class="keyword">.</SPAN>2 <SPAN class="keyword">+</SPAN> 1 <SPAN class="keyword">-</SPAN> Dur<SPAN class="keyword">#</SPAN>Day<SPAN class="keyword">.</SPAN>2 <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">in</SPAN> <BR> L<SPAN class="keyword">.</SPAN>start <SPAN class="keyword">::</SPAN> compl({Map Week AfterHours})<BR> <SPAN class="keyword">end</SPAN>}<BR> <BR> <BR> %% <SPAN class="comment">All semesters but the eighth are not scheduled on thursday<BR></SPAN> %% <SPAN class="comment">seems to be to hard<BR></SPAN> <BR> {OnSpecialDayOnly FlatLecturesSixth Wednesday}<BR> %% <SPAN class="comment">The break must be lecturefree<BR></SPAN> <BR> {DayBreak<BR> {List<SPAN class="keyword">.</SPAN>map [0 1 2 3 4] <SPAN class="keyword">fun</SPAN>{<SPAN class="functionname">$</SPAN> I} (20<SPAN class="keyword">+</SPAN>I<SPAN class="keyword">*</SPAN>36)<SPAN class="keyword">#</SPAN>(23<SPAN class="keyword">+</SPAN>I<SPAN class="keyword">*</SPAN>36) <SPAN class="keyword">end</SPAN>}<BR> {Append FlatLecturesEighth FlatGrundStudiumLectures}}<BR> <BR> {DayBreak {List<SPAN class="keyword">.</SPAN>map [0 1 2 3 4]<BR> <SPAN class="keyword">fun</SPAN>{<SPAN class="functionname">$</SPAN> I} (16<SPAN class="keyword">+</SPAN>I<SPAN class="keyword">*</SPAN>36)<SPAN class="keyword">#</SPAN>(19<SPAN class="keyword">+</SPAN>I<SPAN class="keyword">*</SPAN>36) <SPAN class="keyword">end</SPAN>}<BR> FlatLecturesSixth}<BR> <BR> %% <SPAN class="comment">At Asta time no lectures allowed<BR></SPAN> {ForbidAsta FlatAllLectures}<BR> <BR> %% <SPAN class="comment">The Lectures for a semester must not overlap<BR></SPAN> {NoOverlapSemester [[L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.3'</SPAN>]<BR> [L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.6'</SPAN>]<BR> [L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.7'</SPAN>]<BR> [ L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.9'</SPAN>]<BR> [L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.10.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.10.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.10.3'</SPAN>]<BR> [L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.5.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.5.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.8.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.8.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.13.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.13.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.4.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.4.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.14.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.14.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.3'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.4'</SPAN> ]]}<BR> <BR> {ForAll [L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.5.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.5.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.8.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.8.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.13.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.13.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.4.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.4.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.14.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.14.2'</SPAN>]<BR> <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> Lecture}<BR> {AtmostOneOverlap Lecture [L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.5.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.5.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.8.1'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.8.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.13.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.13.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.4.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.4.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.14.1'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.14.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.3'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.4'</SPAN>]}<BR> <SPAN class="keyword">end</SPAN>}<BR> {ForAll [L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.3'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.4'</SPAN>]<BR> <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> Lecture}<BR> {AtmostOneOverlap Lecture [L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.5.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.5.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.8.1'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.8.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.13.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.13.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.4.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.4.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.14.1'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.14.2'</SPAN>]}<BR> <SPAN class="keyword">end</SPAN>}<BR> <BR> <BR> {NoOverlapSemester [[L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.1'</SPAN>] [L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.6'</SPAN>] [L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.11'</SPAN> ]<BR> [ L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.2.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.2.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.3.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.3.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.4.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.4.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.5.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.5.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.7.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.7.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.10.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.10.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.12.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.12.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.8.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.8.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.8.3'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.8.4'</SPAN>]]}<BR> <BR> {ForAll [ L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.2.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.2.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.3.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.3.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.4.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.4.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.5.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.5.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.7.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.7.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.10.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.10.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.12.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.12.2'</SPAN>]<BR> <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> Lecture}<BR> {AtmostOneOverlap<BR> Lecture [ L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.2.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.2.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.3.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.3.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.4.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.4.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.5.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.5.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.7.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.7.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.10.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.10.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.12.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.12.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.8.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.8.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.8.3'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.8.4'</SPAN>]}<BR> <SPAN class="keyword">end</SPAN>}<BR> <BR> {ForAll [L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.8.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.8.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.8.3'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.8.4'</SPAN>]<BR> <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> Lecture}<BR> {AtmostOneOverlap<BR> Lecture [ L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.2.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.2.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.3.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.3.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.4.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.4.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.5.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.5.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.7.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.7.2'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.10.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.10.2'</SPAN> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.12.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.12.2'</SPAN> ]}<BR> <SPAN class="keyword">end</SPAN>}<BR> <BR> <BR> <BR> {NoOverlapSemester [[L<SPAN class="keyword">.</SPAN><SPAN class="string">'6.2.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'6.2.2'</SPAN>] [L<SPAN class="keyword">.</SPAN><SPAN class="string">'6.5'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'6.6'</SPAN>] ]}<BR> {NoOverlapSemester [[L<SPAN class="keyword">.</SPAN><SPAN class="string">'8.1'</SPAN>][L<SPAN class="keyword">.</SPAN><SPAN class="string">'8.2'</SPAN>][L<SPAN class="keyword">.</SPAN><SPAN class="string">'8.3'</SPAN>][L<SPAN class="keyword">.</SPAN><SPAN class="string">'8.4'</SPAN>]<BR> [L<SPAN class="keyword">.</SPAN><SPAN class="string">'8.5'</SPAN>][L<SPAN class="keyword">.</SPAN><SPAN class="string">'8.6'</SPAN>][L<SPAN class="keyword">.</SPAN><SPAN class="string">'8.7.2'</SPAN>][L<SPAN class="keyword">.</SPAN><SPAN class="string">'8.8'</SPAN>]<BR> [L<SPAN class="keyword">.</SPAN><SPAN class="string">'8.9'</SPAN>][L<SPAN class="keyword">.</SPAN><SPAN class="string">'8.10'</SPAN>]<BR> ]}<BR> <BR> %% <SPAN class="comment">Lectures for a professor must not overlap<BR></SPAN> {ForAll Professors <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> L} {NoOverlapLectures L<SPAN class="keyword">.</SPAN>lectures} <SPAN class="keyword">end</SPAN>}<BR> <BR> %% <SPAN class="comment">At most MaximumRooms concurrent<BR></SPAN> {AtMostLectures {FilterSize [big small tiny] FlatAllLectures}<BR> MaximumRooms}<BR> <BR> %% <SPAN class="comment">Aula and 155 lectures at most 2<BR></SPAN> {AtMostLectures {FilterSize [big] FlatAllLectures} 2}<BR> <BR> %% <SPAN class="comment">Rooms Aula, 155, 152, 154, 250 lectures at most 5<BR></SPAN> {AtMostLectures {FilterSize [big small] FlatAllLectures} 5}<BR> <BR> %% <SPAN class="comment">All professors have a teaching limit of 3 days per week<BR></SPAN> {ForAll Professors<BR> <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> Professor} {ThreeDaysOnly Professor<SPAN class="keyword">.</SPAN>lectures 3} <SPAN class="keyword">end</SPAN>}<BR> <BR> %% <SPAN class="comment">At most 6 hours per day<BR></SPAN> {ForAll Professors<BR> <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> Professor}<BR> {ForAll [Monday Tuesday Wednesday Thursday Friday]<BR> <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> Day}<BR> {FoldL Professor<SPAN class="keyword">.</SPAN>lectures<BR> <SPAN class="keyword">fun</SPAN>{<SPAN class="functionname">$</SPAN> I L}<BR> {FD<SPAN class="keyword">.</SPAN>plus {FD<SPAN class="keyword">.</SPAN>times L<SPAN class="keyword">.</SPAN>dur (L<SPAN class="keyword">.</SPAN>start<SPAN class="keyword">::</SPAN>Day)} I}<BR> <SPAN class="keyword">end</SPAN> 0} <SPAN class="keyword">=<:</SPAN> 6<SPAN class="keyword">*</SPAN>4<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN>}<BR> <BR> %% <SPAN class="comment">Teacher1/Teacher15 couple cannot teach at the same time (+offset)<BR></SPAN> {NotParallel<BR> Teacher1Off<BR> {SearchProf Professors <SPAN class="string">'Teacher1'</SPAN>}<BR> {SearchProf Professors <SPAN class="string">'Teacher15'</SPAN>}}<BR> <BR> %% <SPAN class="comment">Special constraints for 2nd semester<BR></SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.1'</SPAN><SPAN class="keyword">.</SPAN>start=L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.2'</SPAN><SPAN class="keyword">.</SPAN>start=L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.3'</SPAN><SPAN class="keyword">.</SPAN>start<BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.10.1'</SPAN><SPAN class="keyword">.</SPAN>start=L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.10.2'</SPAN><SPAN class="keyword">.</SPAN>start=L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.10.3'</SPAN><SPAN class="keyword">.</SPAN>start<BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.1'</SPAN><SPAN class="keyword">.</SPAN>start=L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.2'</SPAN><SPAN class="keyword">.</SPAN>start=L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.3'</SPAN><SPAN class="keyword">.</SPAN>start=L<SPAN class="keyword">.</SPAN><SPAN class="string">'2.15.4'</SPAN><SPAN class="keyword">.</SPAN>start <BR> <BR> %% <SPAN class="comment">Special constraints for 4th semester<BR></SPAN> {OnDifferentDays [L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.7.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'4.7.2'</SPAN>]} % <SPAN class="comment">Teacher17's lecture<BR></SPAN> <BR> %% <SPAN class="comment">Special constraints for 6th semester<BR></SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'6.5'</SPAN><SPAN class="keyword">.</SPAN>start=L<SPAN class="keyword">.</SPAN><SPAN class="string">'6.6'</SPAN><SPAN class="keyword">.</SPAN>start<BR> (L<SPAN class="keyword">.</SPAN><SPAN class="string">'6.5'</SPAN><SPAN class="keyword">.</SPAN>start) <SPAN class="keyword">>:</SPAN> {FD<SPAN class="keyword">.</SPAN>max L<SPAN class="keyword">.</SPAN><SPAN class="string">'6.2.1'</SPAN><SPAN class="keyword">.</SPAN>start L<SPAN class="keyword">.</SPAN><SPAN class="string">'6.2.2'</SPAN><SPAN class="keyword">.</SPAN>start}<BR> <BR> L<SPAN class="keyword">.</SPAN><SPAN class="string">'6.2.1'</SPAN><SPAN class="keyword">.</SPAN>start=L<SPAN class="keyword">.</SPAN><SPAN class="string">'6.2.2'</SPAN><SPAN class="keyword">.</SPAN>start=L<SPAN class="keyword">.</SPAN><SPAN class="string">'6.2.3'</SPAN><SPAN class="keyword">.</SPAN>start<BR> <BR> %% <SPAN class="comment">Special constraints for eighth semester<BR></SPAN> <BR> %% <SPAN class="comment">Special constraints for Mediendidaktik<BR></SPAN> {NoOverlapSemester [FlatGrundStudiumLectures FlatMedienLectures]}<BR> <BR> %% <SPAN class="comment">Special constraints for Fakultative Veranstaltungen<BR></SPAN> {NoOverlapSemester FakLectures}<BR> {OnSpecialTimeOnly FlatFakLectures Afternoon}<BR> <BR> %% <SPAN class="comment">Special constraint for Teacher32<BR></SPAN> {OnSameDay [L<SPAN class="keyword">.</SPAN><SPAN class="string">'F.2.1'</SPAN> L<SPAN class="keyword">.</SPAN><SPAN class="string">'F.2.2'</SPAN>]}<BR> <BR> %% <SPAN class="comment">%%%%%%%%%%%%%%%<BR></SPAN> %% <SPAN class="comment">The Enumeration<BR></SPAN> %% <SPAN class="comment">%%%%%%%%%%%%%%%<BR></SPAN> <BR> {Enum FlatAllSemesterLectures}<BR> {Enum {Append FlatMedienLectures FlatFakLectures}}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">TimeTableClass</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> BaseObject</SPAN> <BR> <SPAN class="keyword">attr</SPAN> <BR> problemDescription: nil<BR> solution<BR> dir<BR> first: <SPAN class="keyword">true</SPAN> <BR> solver<BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">readProblem</SPAN>(InputFileName)<BR> <SPAN class="keyword">if</SPAN> InputFileName<SPAN class="keyword">==false</SPAN> <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">else</SPAN> <BR> InputFile = {New Open<SPAN class="keyword">.</SPAN>file init(name:InputFileName<BR> flags: [read])}<BR> Read = {InputFile read(size:all list:$)}<BR> <SPAN class="keyword">in</SPAN> <BR> problemDescription <SPAN class="keyword"><-</SPAN> {Compiler<SPAN class="keyword">.</SPAN>virtualStringToValue Read}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">setDir</SPAN>(D)<BR> dir <SPAN class="keyword"><-</SPAN> D<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">getDir</SPAN>(?D)<BR> D = <SPAN class="keyword">@</SPAN>dir <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">setProblem</SPAN>(P)<BR> problemDescription <SPAN class="keyword"><-</SPAN> P<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">inspectProblem</SPAN> <BR> {Inspect <SPAN class="keyword">@</SPAN>problemDescription}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">constrainProblem</SPAN> <BR> solution <SPAN class="keyword"><-</SPAN> {{MakeProblem <SPAN class="keyword">@</SPAN>problemDescription}}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">solveProblem</SPAN> <BR> PD = <SPAN class="keyword">@</SPAN>problemDescription<BR> <SPAN class="keyword">in</SPAN> <BR> first <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">true</SPAN> <BR> <SPAN class="keyword">if</SPAN> PD <SPAN class="keyword">==</SPAN> nil <SPAN class="keyword">then</SPAN> <BR> {ControllerLabel tk(configure text:<SPAN class="string">'No problem loaded'</SPAN>)}<BR> <SPAN class="keyword">else</SPAN> <BR> solver <SPAN class="keyword"><-</SPAN> {New Search<SPAN class="keyword">.</SPAN>object<BR> script({MakeProblem PD}<BR> <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN> Old New}<BR> CN = {Cost New}<BR> CO = {Cost Old} <SPAN class="keyword">in</SPAN> <BR> CN <SPAN class="keyword"><:</SPAN> CO<BR> <SPAN class="keyword">thread</SPAN> <BR> {Wait CO}<BR> /*<SPAN class="comment">{Show {FD.reflect.min CO}}*/</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> rcd : 20)}<BR> <SPAN class="keyword">local</SPAN> Solver = <SPAN class="keyword">@</SPAN>solver <SPAN class="keyword">in</SPAN> <BR> {<SPAN class="keyword">self</SPAN> setSolution(<SPAN class="keyword">thread</SPAN> {Solver next($)} <SPAN class="keyword">end</SPAN>)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">optimizeProblem</SPAN> <BR> Solver = <SPAN class="keyword">@</SPAN>solver <SPAN class="keyword">in</SPAN> <BR> {ControllerLabel tk(configure text:<SPAN class="string">'Computing...'</SPAN>)}<BR> {<SPAN class="keyword">self</SPAN> setSolution(<SPAN class="keyword">thread</SPAN> {Solver next($)} <SPAN class="keyword">end</SPAN>)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">setSolution</SPAN>(Sol)<BR> <SPAN class="keyword">thread</SPAN> <BR> <SPAN class="keyword">if</SPAN> Sol<SPAN class="keyword">==</SPAN>nil <SPAN class="keyword">then</SPAN> <BR> {ControllerLabel tk(configure text:<SPAN class="string">'No solution'</SPAN>)}<BR> <SPAN class="keyword">elseif</SPAN> Sol<SPAN class="keyword">==</SPAN>stopped <SPAN class="keyword">then</SPAN> <BR> {ControllerLabel tk(configure text:<SPAN class="string">'Stopped'</SPAN>)}<BR> <SPAN class="keyword">else</SPAN> <BR> {<SPAN class="keyword">self</SPAN> help(Sol)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">help</SPAN>(Sol)<BR> Solver = <SPAN class="keyword">@</SPAN>solver <SPAN class="keyword">in</SPAN> <BR> solution <SPAN class="keyword"><-</SPAN> Sol<BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>first <SPAN class="keyword">then</SPAN> <BR> first <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">false</SPAN> <BR> {<SPAN class="keyword">self</SPAN> graphic}<BR> <SPAN class="keyword">else</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> {<SPAN class="keyword">self</SPAN> setSolution(<SPAN class="keyword">thread</SPAN> {Solver next($)} <SPAN class="keyword">end</SPAN>)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">get</SPAN>(?Sol)<BR> Sol=<SPAN class="keyword">@</SPAN>solution<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">anyTime</SPAN> <BR> {<SPAN class="keyword">@</SPAN>solver stop}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">inspect</SPAN> <BR> {Inspect {Map <SPAN class="keyword">@</SPAN>solution <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> X} {Record<SPAN class="keyword">.</SPAN>subtract X ordering} <SPAN class="keyword">end</SPAN>}}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">text</SPAN> <BR> {LaTeX show <SPAN class="keyword">@</SPAN>solution}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">print</SPAN> <BR> {LaTeX print <SPAN class="keyword">@</SPAN>solution}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">graphic</SPAN> <BR> {DrawSchedule <SPAN class="keyword">@</SPAN>solution<SPAN class="keyword">.</SPAN>1 TopWindow}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">edit</SPAN>(FileName)<BR> <SPAN class="keyword">if</SPAN> FileName<SPAN class="keyword">==false</SPAN> <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">else</SPAN> <BR> {OS<SPAN class="keyword">.</SPAN>system Editor<SPAN class="keyword">#</SPAN><SPAN class="string">' '</SPAN><SPAN class="keyword">#</SPAN>FileName<SPAN class="keyword">#</SPAN><SPAN class="string">'\&'</SPAN> _}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">save</SPAN>(OutputFileName)<BR> <SPAN class="keyword">if</SPAN> OutputFileName<SPAN class="keyword">==false</SPAN> <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">else</SPAN> <BR> F = {New Open<SPAN class="keyword">.</SPAN>file init(name:OutputFileName<BR> flags: [read write <SPAN class="string">'create'</SPAN>])}<BR> <SPAN class="keyword">in</SPAN> <BR> {F write(vs:{Value<SPAN class="keyword">.</SPAN>toVirtualString <SPAN class="keyword">@</SPAN>solution 100 100})}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="reference">\ifndef ALONEDEMO</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">read</SPAN>(FileName)<BR> <SPAN class="keyword">if</SPAN> FileName<SPAN class="keyword">==false</SPAN> <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">else</SPAN> <BR> File = {New Open<SPAN class="keyword">.</SPAN>file init(name:FileName<BR> flags: [read write <SPAN class="string">'create'</SPAN>])}<BR> <SPAN class="keyword">in</SPAN> <BR> solution <SPAN class="keyword"><-</SPAN> {Compiler<SPAN class="keyword">.</SPAN>virtualStringToValue<BR> {File read(size:all list:$)}}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="reference">\else</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">read</SPAN>(_)<BR> solution <SPAN class="keyword"><-</SPAN> <BR> <SPAN class="reference">\insert KathHochWS9596Sol.ozt</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="reference">\endif</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> TimeTable = {New TimeTableClass <BR><SPAN class="reference">\ifdef ALONEDEMO</SPAN> <BR> setProblem(<BR> <SPAN class="reference">\insert KathHochWS9596.ozt</SPAN> <BR> )<BR><SPAN class="reference">\else</SPAN> <BR> noop<BR><SPAN class="reference">\endif</SPAN> <BR> }<BR><SPAN class="keyword">end</SPAN> <BR></PRE></BLOCKQUOTE><P></P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node12.html#code.college.controller"><< Prev</A></TD><TD><A href="college.html">- Up -</A></TD><TD><A href="node14.html#code.college.graphics">Next >></A></TD></TR></TABLE><HR><ADDRESS><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|