source: tspsg-svn/trunk/docs/html/tspsolver_8h_source.html @ 80

Last change on this file since 80 was 76, checked in by laleppa, 15 years ago
  • TCandidate should, actually, be SCandidate (struct, not typedef). Renamed it.
  • Documentation update.
File size: 17.7 KB
Line 
1<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4<head>
5<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
6<title>TSPSG: TSP Solver and Generator: src/tspsolver.h Source File</title>
7<link href="tabs.css" rel="stylesheet" type="text/css"/>
8<link href="search/search.css" rel="stylesheet" type="text/css"/>
9<script type="text/javaScript" src="search/search.js"></script>
10<link href="doxygen.css" rel="stylesheet" type="text/css"/>
11</head>
12<body onload='searchBox.OnSelectItem(0);'>
13<!-- Generated by Doxygen 1.6.1 -->
14<script type="text/javascript"><!--
15var searchBox = new SearchBox("searchBox", "search",false,'Search');
16--></script>
17<script type="text/javascript">
18<!--
19function changeDisplayState (e){
20  var num=this.id.replace(/[^[0-9]/g,'');
21  var button=this.firstChild;
22  var sectionDiv=document.getElementById('dynsection'+num);
23  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
24    sectionDiv.style.display='block';
25    button.src='open.gif';
26  }else{
27    sectionDiv.style.display='none';
28    button.src='closed.gif';
29  }
30}
31function initDynSections(){
32  var divs=document.getElementsByTagName('div');
33  var sectionCounter=1;
34  for(var i=0;i<divs.length-1;i++){
35    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
36      var header=divs[i];
37      var section=divs[i+1];
38      var button=header.firstChild;
39      if (button!='IMG'){
40        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
41        button=document.createElement('img');
42        divs[i].insertBefore(button,divs[i].firstChild);
43      }
44      header.style.cursor='pointer';
45      header.onclick=changeDisplayState;
46      header.id='dynheader'+sectionCounter;
47      button.src='closed.gif';
48      section.id='dynsection'+sectionCounter;
49      section.style.display='none';
50      section.style.marginLeft='14px';
51      sectionCounter++;
52    }
53  }
54}
55window.onload = initDynSections;
56-->
57</script>
58<div class="navigation" id="top">
59  <div class="tabs">
60    <ul>
61      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
62      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
63      <li><a href="annotated.html"><span>Classes</span></a></li>
64      <li class="current"><a href="files.html"><span>Files</span></a></li>
65      <li>
66        <div id="MSearchBox" class="MSearchBoxInactive">
67        <img id="MSearchSelect" src="search/search.png"
68             onmouseover="return searchBox.OnSearchSelectShow()"
69             onmouseout="return searchBox.OnSearchSelectHide()"
70             alt=""/>
71        <input type="text" id="MSearchField" value="Search" accesskey="S"
72             onfocus="searchBox.OnSearchFieldFocus(true)" 
73             onblur="searchBox.OnSearchFieldFocus(false)" 
74             onkeyup="searchBox.OnSearchFieldChange(event)"/>
75        <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
76        </div>
77      </li>
78    </ul>
79  </div>
80  <div class="tabs">
81    <ul>
82      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
83      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
84    </ul>
85  </div>
86<h1>src/tspsolver.h</h1><a href="tspsolver_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
87<a name="l00028"></a>00028 <span class="preprocessor">#ifndef TSPSOLVER_H</span>
88<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#define TSPSOLVER_H</span>
89<a name="l00030"></a>00030 <span class="preprocessor"></span>
90<a name="l00031"></a>00031 <span class="preprocessor">#include &quot;<a class="code" href="globals_8h.html" title="Contains TSPSG global defines.">globals.h</a>&quot;</span>
91<a name="l00032"></a>00032
92<a name="l00033"></a>00033 <span class="preprocessor">#include &quot;<a class="code" href="tspmodel_8h.html" title="Defines CTSPModel class.">tspmodel.h</a>&quot;</span>
93<a name="l00034"></a>00034
94<a name="l00036"></a><a class="code" href="tspsolver_8h.html#a3addcca59ef59d0b3892b3670f808965">00036</a> <span class="keyword">typedef</span> <a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qlist.html">QList&lt;QList&lt;double&gt;</a> &gt; <a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qlist.html">TMatrix</a>;
95<a name="l00037"></a>00037
96<a name="l00041"></a><a class="code" href="struct_s_candidate.html">00041</a> <span class="keyword">struct </span><a class="code" href="struct_s_candidate.html" title="A structure that represents a candidate for branching.">SCandidate</a> {
97<a name="l00042"></a><a class="code" href="struct_s_candidate.html#aebab56506cadaa3c7d0e57037925cea5">00042</a>     <span class="keywordtype">int</span> <a class="code" href="struct_s_candidate.html#aebab56506cadaa3c7d0e57037925cea5" title="A zero-based row number of the candidate.">nRow</a>;
98<a name="l00043"></a><a class="code" href="struct_s_candidate.html#a95a822e8bd7f4709ff24a7ba79f9f338">00043</a>     <span class="keywordtype">int</span> <a class="code" href="struct_s_candidate.html#a95a822e8bd7f4709ff24a7ba79f9f338" title="A zero-based column number of the candidate.">nCol</a>;
99<a name="l00044"></a>00044
100<a name="l00046"></a><a class="code" href="struct_s_candidate.html#ad7ac35a48148fcc51614079714c03e6f">00046</a>     <a class="code" href="struct_s_candidate.html#ad7ac35a48148fcc51614079714c03e6f" title="Assigns default values.">SCandidate</a>() {
101<a name="l00047"></a>00047         <a class="code" href="struct_s_candidate.html#a95a822e8bd7f4709ff24a7ba79f9f338" title="A zero-based column number of the candidate.">nCol</a> = <a class="code" href="struct_s_candidate.html#aebab56506cadaa3c7d0e57037925cea5" title="A zero-based row number of the candidate.">nRow</a> = -1;
102<a name="l00048"></a>00048     }
103<a name="l00050"></a><a class="code" href="struct_s_candidate.html#a9e4f4f1861131ed23b5576f9cd8d4c68">00050</a>     <span class="keywordtype">bool</span> <a class="code" href="struct_s_candidate.html#a9e4f4f1861131ed23b5576f9cd8d4c68" title="An operator == implementation.">operator ==</a>(<span class="keyword">const</span> <a class="code" href="struct_s_candidate.html" title="A structure that represents a candidate for branching.">SCandidate</a> &amp;cand)<span class="keyword"> const </span>{
104<a name="l00051"></a>00051         <span class="keywordflow">return</span> ((cand.<a class="code" href="struct_s_candidate.html#aebab56506cadaa3c7d0e57037925cea5" title="A zero-based row number of the candidate.">nRow</a> == <a class="code" href="struct_s_candidate.html#aebab56506cadaa3c7d0e57037925cea5" title="A zero-based row number of the candidate.">nRow</a>) &amp;&amp; (cand.<a class="code" href="struct_s_candidate.html#a95a822e8bd7f4709ff24a7ba79f9f338" title="A zero-based column number of the candidate.">nCol</a> == <a class="code" href="struct_s_candidate.html#a95a822e8bd7f4709ff24a7ba79f9f338" title="A zero-based column number of the candidate.">nCol</a>));
105<a name="l00052"></a>00052     }
106<a name="l00053"></a>00053 };
107<a name="l00054"></a>00054
108<a name="l00060"></a><a class="code" href="struct_s_step.html">00060</a> <span class="keyword">struct </span><a class="code" href="struct_s_step.html" title="This structure represents one step of solving.">SStep</a> {
109<a name="l00061"></a><a class="code" href="struct_s_step.html#a0353eb66f83d46f88fb47cc2d1a923dd">00061</a>     <a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qlist.html">TMatrix</a> <a class="code" href="struct_s_step.html#a0353eb66f83d46f88fb47cc2d1a923dd" title="This step&amp;#39;s matrix.">matrix</a>;
110<a name="l00062"></a><a class="code" href="struct_s_step.html#a0355ec75846222996de07108a7c2e9c8">00062</a>     <span class="keywordtype">double</span> <a class="code" href="struct_s_step.html#a0355ec75846222996de07108a7c2e9c8" title="The price of travel to this step.">price</a>;
111<a name="l00063"></a><a class="code" href="struct_s_step.html#aeb798262cbff5ddd819a7056f8d21f21">00063</a>     <a class="code" href="struct_s_candidate.html" title="A structure that represents a candidate for branching.">SCandidate</a> <a class="code" href="struct_s_step.html#aeb798262cbff5ddd819a7056f8d21f21" title="A candiadate for branching in the current matrix.">candidate</a>;
112<a name="l00064"></a><a class="code" href="struct_s_step.html#a02196d3433e2deed89ab540b875cd527">00064</a>     <a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qlist.html">QList&lt;SCandidate&gt;</a> <a class="code" href="struct_s_step.html#a02196d3433e2deed89ab540b875cd527" title="A list of alternative branching candidates.">alts</a>;
113<a name="l00065"></a><a class="code" href="struct_s_step.html#a8776e917cd02f86a57e103c025f5530c">00065</a>     <a class="code" href="struct_s_step.html" title="This structure represents one step of solving.">SStep</a> *<a class="code" href="struct_s_step.html#a8776e917cd02f86a57e103c025f5530c" title="Pointer to the left branch step.">plNode</a>;
114<a name="l00066"></a><a class="code" href="struct_s_step.html#a51b304fcfc71508203d2becefcae5d31">00066</a>     <a class="code" href="struct_s_step.html" title="This structure represents one step of solving.">SStep</a> *<a class="code" href="struct_s_step.html#a51b304fcfc71508203d2becefcae5d31" title="Pointer to the right branch step.">prNode</a>;
115<a name="l00067"></a>00067
116<a name="l00069"></a><a class="code" href="struct_s_step.html#a450adac026150c0a49967a20ce46e51e">00069</a>     <a class="code" href="struct_s_step.html#a450adac026150c0a49967a20ce46e51e" title="Assigns default values.">SStep</a>() {
117<a name="l00070"></a>00070         <a class="code" href="struct_s_step.html#a0355ec75846222996de07108a7c2e9c8" title="The price of travel to this step.">price</a> = -1;
118<a name="l00071"></a>00071         <a class="code" href="struct_s_step.html#a8776e917cd02f86a57e103c025f5530c" title="Pointer to the left branch step.">plNode</a> = <a class="code" href="struct_s_step.html#a51b304fcfc71508203d2becefcae5d31" title="Pointer to the right branch step.">prNode</a> = NULL;
119<a name="l00072"></a>00072     }
120<a name="l00073"></a>00073 };
121<a name="l00074"></a>00074
122<a name="l00081"></a><a class="code" href="class_c_t_s_p_solver.html">00081</a> <span class="keyword">class </span><a class="code" href="class_c_t_s_p_solver.html" title="This class solves Travelling Salesman Problem task.">CTSPSolver</a>
123<a name="l00082"></a>00082 {
124<a name="l00083"></a>00083     Q_DECLARE_TR_FUNCTIONS(<a class="code" href="class_c_t_s_p_solver.html" title="This class solves Travelling Salesman Problem task.">CTSPSolver</a>)
125<a name="l00084"></a>00084
126<a name="l00085"></a>00085 <span class="keyword">public</span>:
127<a name="l00086"></a>00086     <a class="code" href="class_c_t_s_p_solver.html#aa5e45813d8f5e1c039b1bb9746d367bd" title="Class constructor.">CTSPSolver</a>();
128<a name="l00087"></a>00087     <a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qstring.html">QString</a> <a class="code" href="class_c_t_s_p_solver.html#a57556c971a25e3556c4aa3cc1fd2d3d0" title="Returns the sorted optimal path, starting from City 1.">getSortedPath</a>() <span class="keyword">const</span>;
129<a name="l00088"></a>00088     <span class="keyword">static</span> <a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qstring.html">QString</a> <a class="code" href="class_c_t_s_p_solver.html#a677a878c4c8a06316a5d8d5a4fc8ab65" title="Returns CTSPSolver&amp;#39;s version ID.">getVersionId</a>();
130<a name="l00089"></a>00089     <span class="keywordtype">bool</span> <a class="code" href="class_c_t_s_p_solver.html#a28d546e840cf53c639b45c0f26419f7a" title="Returns whether or not the solution is definitely optimal.">isOptimal</a>() <span class="keyword">const</span>;
131<a name="l00090"></a>00090     <a class="code" href="struct_s_step.html" title="This structure represents one step of solving.">SStep</a> *<a class="code" href="class_c_t_s_p_solver.html#a9a6545dd05e449151aabe325f4058edd" title="Solves the given task.">solve</a>(<span class="keywordtype">int</span> numCities, <a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qlist.html">TMatrix</a> task, <a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qwidget.html">QWidget</a> *parent = 0);
132<a name="l00091"></a>00091     ~<a class="code" href="class_c_t_s_p_solver.html" title="This class solves Travelling Salesman Problem task.">CTSPSolver</a>();
133<a name="l00092"></a>00092
134<a name="l00093"></a>00093 <span class="keyword">private</span>:
135<a name="l00094"></a>00094     <span class="keywordtype">bool</span> mayNotBeOptimal;
136<a name="l00095"></a>00095     <span class="keywordtype">int</span> nCities;
137<a name="l00096"></a>00096     <a class="code" href="struct_s_step.html" title="This structure represents one step of solving.">SStep</a> *root;
138<a name="l00097"></a>00097     <a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qhash.html">QHash&lt;int,int&gt;</a> route;
139<a name="l00098"></a>00098 <span class="comment">//  QHash&lt;int,int&gt; forbidden;</span>
140<a name="l00099"></a>00099
141<a name="l00100"></a>00100     <span class="keywordtype">double</span> align(<a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qlist.html">TMatrix</a> &amp;matrix);
142<a name="l00101"></a>00101     <span class="keywordtype">void</span> cleanup();
143<a name="l00102"></a>00102     <span class="keywordtype">void</span> deleteNode(<a class="code" href="struct_s_step.html" title="This structure represents one step of solving.">SStep</a> *node);
144<a name="l00103"></a>00103     <a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qlist.html">QList&lt;SCandidate&gt;</a> findCandidate(<span class="keyword">const</span> <a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qlist.html">TMatrix</a> &amp;matrix, <span class="keywordtype">int</span> &amp;nRow, <span class="keywordtype">int</span> &amp;nCol) <span class="keyword">const</span>;
145<a name="l00104"></a>00104     <span class="keywordtype">double</span> findMinInCol(<span class="keywordtype">int</span> nCol, <span class="keyword">const</span> <a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qlist.html">TMatrix</a> &amp;matrix, <span class="keywordtype">int</span> exr = -1) <span class="keyword">const</span>;
146<a name="l00105"></a>00105     <span class="keywordtype">double</span> findMinInRow(<span class="keywordtype">int</span> nRow, <span class="keyword">const</span> <a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qlist.html">TMatrix</a> &amp;matrix, <span class="keywordtype">int</span> exc = -1) <span class="keyword">const</span>;
147<a name="l00106"></a>00106     <span class="keywordtype">bool</span> hasSubCycles(<span class="keywordtype">int</span> nRow, <span class="keywordtype">int</span> nCol) <span class="keyword">const</span>;
148<a name="l00107"></a>00107     <span class="keywordtype">void</span> subCol(<a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qlist.html">TMatrix</a> &amp;matrix, <span class="keywordtype">int</span> nCol, <span class="keywordtype">double</span> val);
149<a name="l00108"></a>00108     <span class="keywordtype">void</span> subRow(<a class="codeRef" doxygen="qt-4.6.tag:http://doc.trolltech.com/4.6/" href="http://doc.trolltech.com/4.6/qlist.html">TMatrix</a> &amp;matrix, <span class="keywordtype">int</span> nRow, <span class="keywordtype">double</span> val);
150<a name="l00109"></a>00109 };
151<a name="l00110"></a>00110
152<a name="l00111"></a>00111 <span class="preprocessor">#endif // TSPSOLVER_H</span>
153</pre></div></div>
154<!--- window showing the filter options -->
155<div id="MSearchSelectWindow"
156     onmouseover="return searchBox.OnSearchSelectShow()"
157     onmouseout="return searchBox.OnSearchSelectHide()"
158     onkeydown="return searchBox.OnSearchSelectKey(event)">
159<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Defines</a></div>
160
161<!-- iframe showing the search results (closed by default) -->
162<div id="MSearchResultsWindow">
163<iframe src="" frameborder="0" 
164        name="MSearchResults" id="MSearchResults">
165</iframe>
166</div>
167
168<hr size="1"/><address style="text-align: right;"><small>Generated on Thu Dec 17 00:37:27 2009 for TSPSG: TSP Solver and Generator by&nbsp;
169<a href="http://www.doxygen.org/index.html">
170<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
171</body>
172</html>
Note: See TracBrowser for help on using the repository browser.