Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bd5c3d824c3db63ffd9226c15941e6ad > files > 1202

mozart-1.4.0-1mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>6.2 Example: Conference</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="node28.html#section.minimizing.mapcolor">&lt;&lt; Prev</A></TD><TD><A href="node27.html">- Up -</A></TD></TR></TABLE><DIV id="section.minimizing.conference"><H2><A name="section.minimizing.conference">6.2 Example: Conference</A></H2><P>This example will employ the constraint provided by <CODE>FD<SPAN class="keyword">.</SPAN>atMost</CODE>. </P><DIV class="unnumbered"><H3><A name="label83">Problem Specification</A></H3><P>We want to construct the time table of a conference. The conference will consist of 11 sessions of equal length. The time table is to be organized as a sequence of slots, where a slot can take up to 3 parallel sessions. There are the following constraints on the timing of the sessions: </P><OL type="1"><LI><P>Session 4 must take place before Session 11.</P></LI><LI><P>Session 5 must take place before Session 10.</P></LI><LI><P>Session 6 must take place before Session 11.</P></LI><LI><P>Session 1 must not be in parallel with Sessions 2, 3, 5, 7, 8, and 10.</P></LI><LI><P>Session 2 must not be in parallel with Sessions 3, 4, 7, 8, 9, and 11.</P></LI><LI><P>Session 3 must not be in parallel with Sessions 5, 6, and 8.</P></LI><LI><P>Session 4 must not be in parallel with Sessions 6, 8, and 10.</P></LI><LI><P>Session 6 must not be in parallel with Sessions 7 and 10.</P></LI><LI><P>Session 7 must not be in parallel with Sessions 8 and 9.</P></LI><LI><P>Session 8 must not be in parallel with Session 10.</P></LI></OL><P> The time table should minimize the number of slots. </P></DIV><DIV class="unnumbered"><H3><A name="label84">Model</A></H3><P>The model has a variable <IMG alt="{\it NbSlots}" src="latex134.png"> saying how many slots the conference has. For the given data, <IMG alt="{\it NbSlots}" src="latex134.png"> can be constrained to the finite domain <IMG alt="4\#{11}" src="latex135.png">. The model also has a variable <IMG alt="{\it Plan}_i" src="latex136.png"> for every session <IMG alt="i" src="latex115.png">, where <IMG alt="{\it Plan}_i" src="latex136.png"> stands for the number of the slot in which Session <IMG alt="i" src="latex115.png"> will take place. Every variable <IMG alt="{\it Plan}_i" src="latex136.png"> can be constrained to the finite domain <IMG alt="1\#{\it NbSlots}" src="latex137.png">. The remaining constraints are obvious from the problem description. </P></DIV><DIV class="unnumbered"><H3><A name="label85">Distribution Strategy</A></H3><P>We use a two-dimensional distribution strategy. We first distribute on <IMG alt="{\it NbSlots}" src="latex134.png">, trying smaller values first. Once <IMG alt="{\it NbSlots}" src="latex134.png"> is determined, we distribute on the variables <IMG alt="{\it Plan}_1,\ldots,{\it Plan}_{11}" src="latex138.png"> using the standard first-fail strategy. </P><P></P><DIV id="progconference"><HR><P><A name="progconference"></A></P><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">fun</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Conference</SPAN>&nbsp;Data}<BR>&nbsp;&nbsp;&nbsp;NbSessions&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;Data<SPAN class="keyword">.</SPAN>nbSessions<BR>&nbsp;&nbsp;&nbsp;NbParSessions&nbsp;=&nbsp;Data<SPAN class="keyword">.</SPAN>nbParSessions<BR>&nbsp;&nbsp;&nbsp;Constraints&nbsp;&nbsp;&nbsp;=&nbsp;Data<SPAN class="keyword">.</SPAN>constraints<BR>&nbsp;&nbsp;&nbsp;MinNbSlots&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;NbSessions&nbsp;<SPAN class="keyword">div</SPAN>&nbsp;NbParSessions<BR><SPAN class="keyword">in</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;Plan}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NbSlots&nbsp;&nbsp;=&nbsp;{FD<SPAN class="keyword">.</SPAN>int&nbsp;MinNbSlots<SPAN class="keyword">#</SPAN>NbSessions}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">in</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>distribute&nbsp;naive&nbsp;[NbSlots]}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%%&nbsp;<SPAN class="comment">Plan:&nbsp;Session&nbsp;--&gt;&nbsp;Slot<BR></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>tuple&nbsp;plan&nbsp;NbSessions&nbsp;1<SPAN class="keyword">#</SPAN>NbSlots&nbsp;Plan}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%%&nbsp;<SPAN class="comment">at&nbsp;most&nbsp;NbParSessions&nbsp;per&nbsp;slot<BR></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{For&nbsp;1&nbsp;NbSlots&nbsp;1&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;Slot}&nbsp;{FD<SPAN class="keyword">.</SPAN>atMost&nbsp;NbParSessions&nbsp;Plan&nbsp;Slot}&nbsp;<SPAN class="keyword">end</SPAN>}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%%&nbsp;<SPAN class="comment">impose&nbsp;constraints<BR></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ForAll&nbsp;Constraints<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;C}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">case</SPAN>&nbsp;C<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">of</SPAN>&nbsp;before(X&nbsp;Y)&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Plan<SPAN class="keyword">.</SPAN>X&nbsp;<SPAN class="keyword">&lt;:</SPAN>&nbsp;Plan<SPAN class="keyword">.</SPAN>Y<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">[]</SPAN>&nbsp;disjoint(X&nbsp;Ys)&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ForAll&nbsp;Ys&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;Y}&nbsp;Plan<SPAN class="keyword">.</SPAN>X&nbsp;<SPAN class="keyword">\=:</SPAN>&nbsp;Plan<SPAN class="keyword">.</SPAN>Y&nbsp;<SPAN class="keyword">end</SPAN>}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>distribute&nbsp;ff&nbsp;Plan}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;<BR>Data&nbsp;=&nbsp;data(nbSessions:11&nbsp;&nbsp;nbParSessions:3<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;constraints:&nbsp;[&nbsp;before(4&nbsp;11)&nbsp;&nbsp;before(5&nbsp;10)&nbsp;&nbsp;before(6&nbsp;11)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;disjoint(1&nbsp;[2&nbsp;3&nbsp;5&nbsp;7&nbsp;8&nbsp;10])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;disjoint(2&nbsp;[3&nbsp;4&nbsp;7&nbsp;8&nbsp;9&nbsp;11])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;disjoint(3&nbsp;[5&nbsp;6&nbsp;8])&nbsp;&nbsp;disjoint(4&nbsp;[6&nbsp;8&nbsp;10])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;disjoint(6&nbsp;[7&nbsp;10])&nbsp;&nbsp;&nbsp;disjoint(7&nbsp;[8&nbsp;9])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;disjoint(8&nbsp;[10])&nbsp;]&nbsp;)</CODE></DD></DL><P class="caption"><STRONG>Figure&nbsp;6.2:</STRONG> A script for conference scheduling together with a data specification.</P><HR></DIV><P> </P></DIV><DIV class="unnumbered"><H3><A name="label86">Script</A></H3><P>The script in <A href="node29.html#progconference">Figure&nbsp;6.2</A> is parameterized with an argument <CODE>Data</CODE> specifying the conference to be organized. The figure also shows the specification of the conference described in the problem specification. </P><P>The script creates a local variable <CODE>NbSlots</CODE> specifying the number of slots used by the conference. It then distributes naively on <CODE>NbSlots</CODE>. After <CODE>NbSlots</CODE> is determined, it constrains its root variable <CODE>Plan</CODE> to a tuple mapping the session numbers <CODE>1</CODE>, ..., <CODE>11</CODE> to integers in <CODE>1<SPAN class="keyword">#</SPAN>NbSlots</CODE>. This implicitly creates variables corresponding to the variables <IMG alt="{\it
Plan}_i" src="latex139.png"> of the model. </P><P>The statement </P><BLOCKQUOTE class="code"><CODE>{FD<SPAN class="keyword">.</SPAN>atMost&nbsp;NbParSessions&nbsp;Plan&nbsp;Slot}</CODE></BLOCKQUOTE><P> creates a propagator for a constraint saying that at most <CODE>NbParSessions</CODE> components of <CODE>Plan</CODE> can be equal to <CODE>Slot</CODE>. </P><P>The statement <CODE>{ForAll&nbsp;Constraints&nbsp;<SPAN class="keyword">...</SPAN>&nbsp;}</CODE> imposes the constraints of the conference to be scheduled. </P><P>The last statement distributes on <CODE>Plan</CODE> using the first-fail strategy. </P><P>The statement </P><BLOCKQUOTE class="code"><CODE>{ExploreOne&nbsp;{Conference&nbsp;Data}}</CODE></BLOCKQUOTE><P> will explore the search tree until the first solution is found. The first solution minimizes the number of slots and looks as follows: </P><BLOCKQUOTE class="code"><CODE>plan(1&nbsp;2&nbsp;3&nbsp;1&nbsp;2&nbsp;2&nbsp;3&nbsp;4&nbsp;1&nbsp;3&nbsp;4)</CODE></BLOCKQUOTE><P> This plan says that the conference requires 4 slots, where the sessions 1, 4 and 9 take place in slot 1, the sessions 2, 5 and 6 take place in slot 2, the sessions 3, 7 and 10 take place in slot 3, and the sessions 8 and 11 take place in slot 4. </P></DIV></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node28.html#section.minimizing.mapcolor">&lt;&lt; Prev</A></TD><TD><A href="node27.html">- Up -</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian&nbsp;Schulte</A> and&nbsp;<A href="http://www.ps.uni-sb.de/~smolka/">Gert&nbsp;Smolka</A><BR><SPAN class="version">Version 1.4.0 (20090610)</SPAN></ADDRESS></BODY></HTML>