mirror of
https://github.com/BlackLight/libCSP--.git
synced 2024-11-14 15:27:15 +01:00
176 lines
18 KiB
HTML
176 lines
18 KiB
HTML
<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<title>libCSP++: csp++-def.h Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javaScript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
|
|
</head>
|
|
<body onload='searchBox.OnSelectItem(0);'>
|
|
<!-- Generated by Doxygen 1.6.3 -->
|
|
<script type="text/javascript"><!--
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
--></script>
|
|
<div class="navigation" id="top">
|
|
<div class="tabs">
|
|
<ul>
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li class="current"><a href="files.html"><span>Files</span></a></li>
|
|
<li>
|
|
<div id="MSearchBox" class="MSearchBoxInactive">
|
|
<img id="MSearchSelect" src="search/search.png"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
alt=""/>
|
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="tabs">
|
|
<ul>
|
|
<li><a href="files.html"><span>File List</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<h1>csp++-def.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
|
|
<a name="l00002"></a>00002 <span class="comment"> * =====================================================================================</span>
|
|
<a name="l00003"></a>00003 <span class="comment"> *</span>
|
|
<a name="l00004"></a>00004 <span class="comment"> * Filename: csp++-def.h</span>
|
|
<a name="l00005"></a>00005 <span class="comment"> *</span>
|
|
<a name="l00006"></a>00006 <span class="comment"> * Description: Header file containing the CSP class definition. Never include this</span>
|
|
<a name="l00007"></a>00007 <span class="comment"> * file directly in your sources. Include csp++.h instead.</span>
|
|
<a name="l00008"></a>00008 <span class="comment"> *</span>
|
|
<a name="l00009"></a>00009 <span class="comment"> * Version: 1.0</span>
|
|
<a name="l00010"></a>00010 <span class="comment"> * Created: 16/05/2010 23:16:42</span>
|
|
<a name="l00011"></a>00011 <span class="comment"> * Revision: none</span>
|
|
<a name="l00012"></a>00012 <span class="comment"> * Compiler: gcc</span>
|
|
<a name="l00013"></a>00013 <span class="comment"> *</span>
|
|
<a name="l00014"></a>00014 <span class="comment"> * Author: BlackLight (http://0x00.ath.cx), <blacklight@autistici.org></span>
|
|
<a name="l00015"></a>00015 <span class="comment"> * Company: lulz</span>
|
|
<a name="l00016"></a>00016 <span class="comment"> *</span>
|
|
<a name="l00017"></a>00017 <span class="comment"> * =====================================================================================</span>
|
|
<a name="l00018"></a>00018 <span class="comment"> */</span>
|
|
<a name="l00019"></a>00019
|
|
<a name="l00020"></a>00020 <span class="preprocessor">#ifndef __CSPPP_H</span>
|
|
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define __CSPPP_H</span>
|
|
<a name="l00022"></a>00022 <span class="preprocessor"></span>
|
|
<a name="l00023"></a>00023 <span class="preprocessor">#ifndef __CSPPP_CPP</span>
|
|
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#error "csp++-def.h must not be included directly - include csp++.h instead"</span>
|
|
<a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
|
|
<a name="l00026"></a>00026 <span class="preprocessor"></span>
|
|
<a name="l00027"></a>00027 <span class="preprocessor">#include <vector></span>
|
|
<a name="l00028"></a>00028 <span class="preprocessor">#include <exception></span>
|
|
<a name="l00029"></a>00029
|
|
<a name="l00034"></a>00034 <span class="keyword">template</span><<span class="keyword">class</span> T>
|
|
<a name="l00035"></a><a class="code" href="structCSPvariable.html">00035</a> <span class="keyword">struct </span><a class="code" href="structCSPvariable.html" title="Struct used for describing a variable in the CSP.">CSPvariable</a> {
|
|
<a name="l00037"></a><a class="code" href="structCSPvariable.html#a1fb7622b0576133aa9a2445da22fddac">00037</a> <span class="keywordtype">int</span> <a class="code" href="structCSPvariable.html#a1fb7622b0576133aa9a2445da22fddac" title="Index of the variable.">index</a>;
|
|
<a name="l00038"></a>00038
|
|
<a name="l00040"></a><a class="code" href="structCSPvariable.html#a8e7a1cbd9af27e295508794f871dc599">00040</a> <span class="keywordtype">bool</span> <a class="code" href="structCSPvariable.html#a8e7a1cbd9af27e295508794f871dc599" title="If the value of the variable is set explicitely, this value is true.">fixed</a>;
|
|
<a name="l00041"></a>00041
|
|
<a name="l00043"></a><a class="code" href="structCSPvariable.html#acc2ff31b449351f04b1c3a2a096e584c">00043</a> T <a class="code" href="structCSPvariable.html#acc2ff31b449351f04b1c3a2a096e584c" title="The value of the variable.">value</a>;
|
|
<a name="l00044"></a>00044
|
|
<a name="l00046"></a><a class="code" href="structCSPvariable.html#a66cf86ebf0fbbf8e571d7b585c9528a2">00046</a> std::vector<T> <a class="code" href="structCSPvariable.html#a66cf86ebf0fbbf8e571d7b585c9528a2" title="Domain of the variable, declared as a vector.">domain</a>;
|
|
<a name="l00047"></a>00047 };
|
|
<a name="l00048"></a>00048
|
|
<a name="l00053"></a><a class="code" href="classCSPexception.html">00053</a> <span class="keyword">class </span><a class="code" href="classCSPexception.html" title="Class for managing exception in CSP.">CSPexception</a> : <span class="keyword">public</span> std::exception {
|
|
<a name="l00054"></a>00054 <span class="keyword">const</span> <span class="keywordtype">char</span>* message;
|
|
<a name="l00055"></a>00055
|
|
<a name="l00056"></a>00056 <span class="keyword">public</span>:
|
|
<a name="l00061"></a><a class="code" href="classCSPexception.html#a810bcfbb11d2e35d7b95f1e2b11b408c">00061</a> <a class="code" href="classCSPexception.html#a810bcfbb11d2e35d7b95f1e2b11b408c" title="Constructor.">CSPexception</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *m) {
|
|
<a name="l00062"></a>00062 message = m;
|
|
<a name="l00063"></a>00063 }
|
|
<a name="l00064"></a>00064
|
|
<a name="l00068"></a><a class="code" href="classCSPexception.html#a7013e90a6c26ba4c15bc6fbc42be02ef">00068</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classCSPexception.html#a7013e90a6c26ba4c15bc6fbc42be02ef" title="Return the description of the exception.">what</a>() {
|
|
<a name="l00069"></a>00069 <span class="keywordflow">return</span> message;
|
|
<a name="l00070"></a>00070 }
|
|
<a name="l00071"></a>00071 };
|
|
<a name="l00072"></a>00072
|
|
<a name="l00077"></a>00077 <span class="keyword">template</span><<span class="keyword">class</span> T>
|
|
<a name="l00078"></a><a class="code" href="classCSP.html">00078</a> <span class="keyword">class </span><a class="code" href="classCSP.html" title="Main class for managing a CSP.">CSP</a> {
|
|
<a name="l00079"></a>00079 <span class="keyword">private</span>:
|
|
<a name="l00080"></a>00080 <span class="keyword">template</span><<span class="keyword">class</span> TT>
|
|
<a name="l00081"></a>00081 <span class="keyword">struct </span>arc {
|
|
<a name="l00082"></a>00082 <a class="code" href="structCSPvariable.html">CSPvariable<TT></a> var[2];
|
|
<a name="l00083"></a>00083 TT <a class="code" href="classCSP.html#aafa5e1a65d6c5d80780437d8d684f32a" title="Get the value of the i-th variable of the CSP. Be careful: before using this function...">value</a>[2];
|
|
<a name="l00084"></a>00084 };
|
|
<a name="l00085"></a>00085
|
|
<a name="l00086"></a>00086 std::vector< CSPvariable<T> > variables;
|
|
<a name="l00087"></a>00087 std::vector< bool (*)(std::vector< CSPvariable<T> >) > constraints;
|
|
<a name="l00088"></a>00088 <span class="preprocessor"> #define constraint constraints[0]</span>
|
|
<a name="l00089"></a>00089 <span class="preprocessor"></span>
|
|
<a name="l00090"></a>00090 std::vector< std::vector<T> > __default_domains;
|
|
<a name="l00091"></a>00091 T __default_value;
|
|
<a name="l00092"></a>00092 <span class="keywordtype">bool</span> __has_default_value;
|
|
<a name="l00093"></a>00093 <span class="keyword">static</span> <span class="keywordtype">bool</span> __default_constraint ( std::vector< <a class="code" href="structCSPvariable.html" title="Struct used for describing a variable in the CSP.">CSPvariable<T></a> > v ) { <span class="keywordflow">return</span> <span class="keyword">true</span>; }
|
|
<a name="l00094"></a>00094 <span class="keywordtype">void</span> __init ( <span class="keywordtype">int</span> n, <span class="keywordtype">bool</span> (*c)(std::vector< <a class="code" href="structCSPvariable.html" title="Struct used for describing a variable in the CSP.">CSPvariable<T></a> >) );
|
|
<a name="l00095"></a>00095 <span class="keywordtype">void</span> restoreDomains ( <span class="keywordtype">void</span> );
|
|
<a name="l00096"></a>00096
|
|
<a name="l00097"></a>00097 <span class="keyword">public</span>:
|
|
<a name="l00102"></a><a class="code" href="classCSP.html#a3a4c1cfab4f5c2376b5f9da588e73f5a">00102</a> <a class="code" href="classCSP.html#a3a4c1cfab4f5c2376b5f9da588e73f5a" title="Empty constructor - just do nothing, used for declaring an object and initialize...">CSP</a>() {}
|
|
<a name="l00103"></a>00103
|
|
<a name="l00113"></a>00113 <a class="code" href="classCSP.html#a3a4c1cfab4f5c2376b5f9da588e73f5a" title="Empty constructor - just do nothing, used for declaring an object and initialize...">CSP</a> ( <span class="keywordtype">int</span> n, <span class="keywordtype">bool</span> (*c)(std::vector< <a class="code" href="structCSPvariable.html" title="Struct used for describing a variable in the CSP.">CSPvariable<T></a> >) = __default_constraint );
|
|
<a name="l00114"></a>00114
|
|
<a name="l00128"></a>00128 <a class="code" href="classCSP.html#a3a4c1cfab4f5c2376b5f9da588e73f5a" title="Empty constructor - just do nothing, used for declaring an object and initialize...">CSP</a> ( <span class="keywordtype">int</span> n, T default_value, <span class="keywordtype">bool</span> set_variables = <span class="keyword">false</span>, <span class="keywordtype">bool</span> (*c)(std::vector< <a class="code" href="structCSPvariable.html" title="Struct used for describing a variable in the CSP.">CSPvariable<T></a> >) = __default_constraint );
|
|
<a name="l00129"></a>00129
|
|
<a name="l00135"></a>00135 <span class="keywordtype">void</span> <a class="code" href="classCSP.html#a4017c17aac9d3e96d0e821ebbe09da7b" title="Set the domain for the i-th variable.">setDomain</a> ( <span class="keywordtype">size_t</span> index, std::vector<T> domain );
|
|
<a name="l00136"></a>00136
|
|
<a name="l00143"></a>00143 <span class="keywordtype">void</span> <a class="code" href="classCSP.html#a4017c17aac9d3e96d0e821ebbe09da7b" title="Set the domain for the i-th variable.">setDomain</a> ( <span class="keywordtype">size_t</span> index, T domain[], <span class="keywordtype">int</span> size );
|
|
<a name="l00144"></a>00144
|
|
<a name="l00149"></a>00149 <span class="keywordtype">void</span> <a class="code" href="classCSP.html#a534a0d9bd10fb544f94196bf3c386657" title="Apply the constraint to the CSP as a boolean function.">setConstraint</a> ( <span class="keywordtype">bool</span> (*c)(std::vector< <a class="code" href="structCSPvariable.html" title="Struct used for describing a variable in the CSP.">CSPvariable<T></a> >) );
|
|
<a name="l00150"></a>00150
|
|
<a name="l00156"></a>00156 <span class="keywordtype">void</span> <a class="code" href="classCSP.html#a534a0d9bd10fb544f94196bf3c386657" title="Apply the constraint to the CSP as a boolean function.">setConstraint</a> ( std::vector< <span class="keywordtype">bool</span>(*)(std::vector< <a class="code" href="structCSPvariable.html" title="Struct used for describing a variable in the CSP.">CSPvariable<T></a> >) > c );
|
|
<a name="l00157"></a>00157
|
|
<a name="l00162"></a>00162 <span class="keywordtype">void</span> <a class="code" href="classCSP.html#a0231b93bceae257f0e1c35041f8fe63f" title="Drops a constraint from the CSP.">dropConstraint</a> ( <span class="keywordtype">size_t</span> index );
|
|
<a name="l00163"></a>00163
|
|
<a name="l00168"></a>00168 <span class="keywordtype">void</span> <a class="code" href="classCSP.html#a8dc6aec6ca7e40d198e58b0ec14fee66" title="Append a constraint to the list of the constraint of the CSP.">appendConstraint</a> ( <span class="keywordtype">bool</span> (*c)(std::vector< <a class="code" href="structCSPvariable.html" title="Struct used for describing a variable in the CSP.">CSPvariable<T></a> >) );
|
|
<a name="l00169"></a>00169
|
|
<a name="l00173"></a>00173 <span class="keywordtype">void</span> <a class="code" href="classCSP.html#a466845256e638c5e258fd728b641359f" title="Updates the domains of the variables. Any constraint or node fixed value is applied...">refreshDomains</a>( <span class="keywordtype">void</span> );
|
|
<a name="l00174"></a>00174
|
|
<a name="l00180"></a>00180 std::vector<T> <a class="code" href="classCSP.html#a2a9a7d8072613f6984795d5495373847" title="Get the domain of the i-th variable.">getDomain</a> ( <span class="keywordtype">size_t</span> index );
|
|
<a name="l00181"></a>00181
|
|
<a name="l00186"></a>00186 <span class="keywordtype">size_t</span> <a class="code" href="classCSP.html#a91a0e89bc1882d39b88122bee392c5f3" title="Get the number of variables in the current CSP.">getSize</a> ( <span class="keywordtype">void</span> );
|
|
<a name="l00187"></a>00187
|
|
<a name="l00193"></a>00193 <span class="keywordtype">void</span> <a class="code" href="classCSP.html#ac25064c5b2d4e1020173b56913251ebd" title="Set the value of a variable as a constraint.">setValue</a> ( <span class="keywordtype">size_t</span> index, T <a class="code" href="classCSP.html#aafa5e1a65d6c5d80780437d8d684f32a" title="Get the value of the i-th variable of the CSP. Be careful: before using this function...">value</a> );
|
|
<a name="l00194"></a>00194
|
|
<a name="l00202"></a>00202 <span class="keywordtype">void</span> <a class="code" href="classCSP.html#a4c0cae125a610f519dc22eaec255a0ae" title="Marks a variable as not set, and if a default value was assigned in the CSP constructor...">unsetValue</a> ( <span class="keywordtype">size_t</span> index );
|
|
<a name="l00203"></a>00203
|
|
<a name="l00208"></a>00208 <span class="keywordtype">bool</span> <a class="code" href="classCSP.html#a7ef9eb91c38815c9d82182696a6bd5d3" title="Check if the current CSP, with the applied constraints, is satisfiable.">isSatisfiable</a> ( <span class="keywordtype">void</span> );
|
|
<a name="l00209"></a>00209
|
|
<a name="l00216"></a>00216 <span class="keywordtype">bool</span> <a class="code" href="classCSP.html#ae96286c6c7dfb6fe077544e0d4af15f4" title="Check if the CSP, with the given variables, domains and constraints, admits a unique...">hasUniqueSolution</a> ( <span class="keywordtype">void</span> );
|
|
<a name="l00217"></a>00217
|
|
<a name="l00223"></a>00223 <span class="keywordtype">void</span> <a class="code" href="classCSP.html#ac74cb751589a58bf6f2815f6878d2213" title="Check if any of the variables in the CSP has a domain containing an only item. If...">assignUniqueDomains</a> ( <span class="keywordtype">void</span> );
|
|
<a name="l00229"></a>00229 <span class="keywordtype">bool</span> <a class="code" href="classCSP.html#a213dafc1aae7b1825371810a511eca4f" title="Check if the i-th variable in the CSP has a fixed value.">isSet</a> ( <span class="keywordtype">size_t</span> i );
|
|
<a name="l00230"></a>00230
|
|
<a name="l00240"></a>00240 T <a class="code" href="classCSP.html#aafa5e1a65d6c5d80780437d8d684f32a" title="Get the value of the i-th variable of the CSP. Be careful: before using this function...">value</a> ( <span class="keywordtype">size_t</span> i );
|
|
<a name="l00241"></a>00241 };
|
|
<a name="l00242"></a>00242
|
|
<a name="l00243"></a>00243 <span class="preprocessor">#endif</span>
|
|
<a name="l00244"></a>00244 <span class="preprocessor"></span>
|
|
</pre></div></div>
|
|
<!--- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Variables</a></div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<hr class="footer"/><address style="text-align: right;"><small>Generated on Mon May 24 01:58:01 2010 for libCSP++ by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
|
|
</body>
|
|
</html>
|