This file is indexed.

/usr/share/mozart/doc/fdt/node28.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>6.1 Example: Coloring a Map</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="node27.html">- Up -</A></TD><TD><A href="node29.html#section.minimizing.conference">Next &gt;&gt;</A></TD></TR></TABLE><DIV id="section.minimizing.mapcolor"><H2><A name="section.minimizing.mapcolor">6.1 Example: Coloring a Map</A></H2><DIV class="unnumbered"><H3><A name="label79">Problem Specification</A></H3><P>Given a map showing the West European countries Netherlands, Belgium, France, Spain, Portugal, Germany, Luxemburg, Switzerland, Austria, and Italy, find a coloring such that neighboring countries have different color and a minimal number of colors is used. </P></DIV><DIV class="unnumbered"><H3><A name="label80">Model</A></H3><P>We have a variable <IMG alt="NbColors" src="latex130.png"> saying how many different colors we can use. Moreover, we have a variable for every country. For every pair <IMG alt="A" src="latex98.png">, <IMG alt="B" src="latex39.png"> of countries having a border in common we impose the constraint <IMG alt="A\neq B" src="latex131.png">. We represent colors as numbers. Hence we constrain all variables for countries to integers in <IMG alt="0\#{NbColors}" src="latex132.png">. </P></DIV><DIV class="unnumbered"><H3><A name="label81">Distribution Strategy</A></H3><P>We first distribute on <IMG alt="NbColors" src="latex130.png">, trying the numbers <IMG alt="0,1,2,\ldots" src="latex133.png"> in ascending order. After <IMG alt="NbColors" src="latex130.png"> is determined, we distribute on the variables for the countries using the usual first-fail strategy. </P><DIV id="progmapcoloring"><HR><P><A name="progmapcoloring"></A></P><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">fun</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">MapColoring</SPAN>&nbsp;Data}<BR>&nbsp;&nbsp;&nbsp;Countries&nbsp;=&nbsp;{Map&nbsp;Data&nbsp;<SPAN class="keyword">fun</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;C<SPAN class="keyword">#</SPAN>_}&nbsp;C&nbsp;<SPAN class="keyword">end</SPAN>}<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;Color}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NbColors&nbsp;&nbsp;=&nbsp;{FD<SPAN class="keyword">.</SPAN>decl}<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;[NbColors]}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%%&nbsp;<SPAN class="comment">Color:&nbsp;Countries&nbsp;--&gt;&nbsp;1#NbColors<BR></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>record&nbsp;color&nbsp;Countries&nbsp;1<SPAN class="keyword">#</SPAN>NbColors&nbsp;Color}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ForAll&nbsp;Data<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;A<SPAN class="keyword">#</SPAN>Bs}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ForAll&nbsp;Bs&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;B}&nbsp;Color<SPAN class="keyword">.</SPAN>A&nbsp;<SPAN class="keyword">\=:</SPAN>&nbsp;Color<SPAN class="keyword">.</SPAN>B&nbsp;<SPAN class="keyword">end</SPAN>}<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;Color}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;<BR>Data&nbsp;=&nbsp;[&nbsp;austria&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">#</SPAN>&nbsp;[italy&nbsp;switzerland&nbsp;germany]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;belgium&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">#</SPAN>&nbsp;[france&nbsp;netherlands&nbsp;germany&nbsp;luxemburg]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;france&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">#</SPAN>&nbsp;[spain&nbsp;luxemburg&nbsp;italy]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;germany&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">#</SPAN>&nbsp;[austria&nbsp;france&nbsp;luxemburg&nbsp;netherlands]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;italy&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">#</SPAN>&nbsp;nil<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;luxemburg&nbsp;&nbsp;&nbsp;<SPAN class="keyword">#</SPAN>&nbsp;nil<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;netherlands&nbsp;<SPAN class="keyword">#</SPAN>&nbsp;nil<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;portugal&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">#</SPAN>&nbsp;nil<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;spain&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">#</SPAN>&nbsp;[portugal]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switzerland&nbsp;<SPAN class="keyword">#</SPAN>&nbsp;[italy&nbsp;france&nbsp;germany&nbsp;austria]&nbsp;]</CODE></DD></DL><P class="caption"><STRONG>Figure&nbsp;6.1:</STRONG> A script for the Map Coloring Problem together with a data specification.</P><HR></DIV><P> </P></DIV><DIV class="unnumbered"><H3><A name="label82">Script</A></H3><P>The script appears in <A href="node28.html#progmapcoloring">Figure&nbsp;6.1</A>. It is parameterized with the specification of the map to be colored. The figure shows the specification of a map containing some European countries.</P><P>The script first creates a local variable <CODE>NbColors</CODE> that specifies the number of different colors to be used for coloring the map. Then it distributes naively on <CODE>NbColors</CODE>. Recall that a distributor blocks its thread until it has done its job. After <CODE>NbColors</CODE> is determined by distribution, the variable <CODE>Color</CODE> is constrained to a record mapping the country names to integers in <CODE>1<SPAN class="keyword">#</SPAN>NbColors</CODE>. This implicitly creates the variables for the Countries. Next the script creates a propagator </P><BLOCKQUOTE class="code"><CODE>Color<SPAN class="keyword">.</SPAN>A&nbsp;<SPAN class="keyword">\=:</SPAN>&nbsp;Color<SPAN class="keyword">.</SPAN>B</CODE></BLOCKQUOTE><P> for every pair <CODE>A</CODE>, <CODE>B</CODE> of bordering countries. Finally, the script distributes on <CODE>Color</CODE> using the first-fail strategy.</P><P>The statement </P><BLOCKQUOTE class="code"><CODE>{ExploreOne&nbsp;{MapColoring&nbsp;Data}}</CODE></BLOCKQUOTE><P> will show the search tree explored to find the first solution, which looks as follows: </P><BLOCKQUOTE class="code"><CODE>color(<BR>&nbsp;&nbsp;&nbsp;austria:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;belgium:&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;france:&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;germany:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;italy:&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;luxemburg:&nbsp;4&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;netherlands:&nbsp;1&nbsp;&nbsp;&nbsp;portugal:&nbsp;1&nbsp;&nbsp;&nbsp;spain:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;switzerland:&nbsp;3&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</CODE></BLOCKQUOTE><P> The search tree of <CODE>MapColoring</CODE> is interesting. First, colorings with 0, 1, 2 and 3 colors are searched and not found. Then a coloring with 4 colors is searched. Now a solution is found quickly, without going through further failure nodes. There are many solutions using 4 colors since the particular color given to a country does not matter.</P></DIV></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node27.html">- Up -</A></TD><TD><A href="node29.html#section.minimizing.conference">Next &gt;&gt;</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 (20110908185330)</SPAN></ADDRESS></BODY></HTML>