Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > e7618febbb9cbed15bb79e326774c050 > files > 134

ompl-devel-0.9.5-1.fc14.i686.rpm

<!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>OMPL: src/ompl/tools/benchmark/src/Benchmark.cpp Source File</title>
<meta name="author" content="Ioan A. Șucan, Mark Moll, Lydia E. Kavraki">
<link rel="stylesheet" href="../css/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../css/print.css" type="text/css" media="print">
<!--[if lt IE 7]>
<script type="text/javascript" src="../js/jquery/jquery.js"></script>
<script type="text/javascript" src="../js/jquery/jquery.dropdown.js"></script>
<![endif]-->
<script type="text/javaScript" src="search/search.js"></script>
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-9156598-2']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search API');
--></script>
<div class="navigation" id="top">
  <div class="tabs" id="ompltitle">
    <ul class="tablist">
      <li>The Open Motion Planning Library</li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search API" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)"
               onblur="searchBox.OnSearchFieldFocus(false)"
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>

  <ul id="nav" class="dropdown">
    <li class="first"><a href="index.html">Home</a></li>
    <li><a href="download.html">Download</a></li>
    <li><a href="documentation.html">Documentation</a></li>
    <li><span class="dir">Code API</span>
      <ul>
        <li><a href="api_overview.html">API Overview</a></li>
        <li><a href="namespaces.html">Namespaces</a></li>
        <li><a href="annotated.html">Classes</a></li>
        <li><a href="files.html">Files</a></li>
        <li><a href="dirs.html">Directories</a></li>
      </ul>
    </li>
    <li><span class="dir">Community</span>
      <ul>
        <li><a href="developers.html">Developers</a></li>
        <li><a href="thirdparty.html">Contributions</a></li>
        <li><a href="education.html">Education</a></li>
        <li><a href="gallery.html">Gallery</a></li>
      </ul>
    </li>
    <li><span class="dir">About</span>
      <ul>
        <li><a href="license.html">License</a></li>
        <li><a href="citations.html">Citations</a></li>
        <li><a href="acknowledgements.html">Acknowledgments</a></li>
        <li><a href="contact.html">Contact Us</a></li>
      </ul>
    </li>
  </ul>
</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">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
  <iframe src="" frameborder="0"name="MSearchResults" id="MSearchResults"></iframe>
</div>

<div class="container">
  <div class="span-22 push-2 first last">
  <div>
<!-- Generated by Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="dir_f5421e52a658cd938113ed6044324834.html">src</a>      </li>
      <li class="navelem"><a class="el" href="dir_ae92c2ff78847f0cb49b545f9089bbbc.html">ompl</a>      </li>
      <li class="navelem"><a class="el" href="dir_5e8650903f98ceacc72eaf4a07632c23.html">tools</a>      </li>
      <li class="navelem"><a class="el" href="dir_d20d0c1680ab4a8f976eb8b99870b40a.html">benchmark</a>      </li>
      <li class="navelem"><a class="el" href="dir_1025ce666345db1406432bc78be274c5.html">src</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">Benchmark.cpp</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*********************************************************************</span>
<a name="l00002"></a>00002 <span class="comment">* Software License Agreement (BSD License)</span>
<a name="l00003"></a>00003 <span class="comment">*</span>
<a name="l00004"></a>00004 <span class="comment">*  Copyright (c) 2010, Rice University</span>
<a name="l00005"></a>00005 <span class="comment">*  All rights reserved.</span>
<a name="l00006"></a>00006 <span class="comment">*</span>
<a name="l00007"></a>00007 <span class="comment">*  Redistribution and use in source and binary forms, with or without</span>
<a name="l00008"></a>00008 <span class="comment">*  modification, are permitted provided that the following conditions</span>
<a name="l00009"></a>00009 <span class="comment">*  are met:</span>
<a name="l00010"></a>00010 <span class="comment">*</span>
<a name="l00011"></a>00011 <span class="comment">*   * Redistributions of source code must retain the above copyright</span>
<a name="l00012"></a>00012 <span class="comment">*     notice, this list of conditions and the following disclaimer.</span>
<a name="l00013"></a>00013 <span class="comment">*   * Redistributions in binary form must reproduce the above</span>
<a name="l00014"></a>00014 <span class="comment">*     copyright notice, this list of conditions and the following</span>
<a name="l00015"></a>00015 <span class="comment">*     disclaimer in the documentation and/or other materials provided</span>
<a name="l00016"></a>00016 <span class="comment">*     with the distribution.</span>
<a name="l00017"></a>00017 <span class="comment">*   * Neither the name of the Rice University nor the names of its</span>
<a name="l00018"></a>00018 <span class="comment">*     contributors may be used to endorse or promote products derived</span>
<a name="l00019"></a>00019 <span class="comment">*     from this software without specific prior written permission.</span>
<a name="l00020"></a>00020 <span class="comment">*</span>
<a name="l00021"></a>00021 <span class="comment">*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span>
<a name="l00022"></a>00022 <span class="comment">*  &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span>
<a name="l00023"></a>00023 <span class="comment">*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS</span>
<a name="l00024"></a>00024 <span class="comment">*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE</span>
<a name="l00025"></a>00025 <span class="comment">*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,</span>
<a name="l00026"></a>00026 <span class="comment">*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,</span>
<a name="l00027"></a>00027 <span class="comment">*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;</span>
<a name="l00028"></a>00028 <span class="comment">*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER</span>
<a name="l00029"></a>00029 <span class="comment">*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</span>
<a name="l00030"></a>00030 <span class="comment">*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN</span>
<a name="l00031"></a>00031 <span class="comment">*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE</span>
<a name="l00032"></a>00032 <span class="comment">*  POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00033"></a>00033 <span class="comment">*********************************************************************/</span>
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="comment">/* Author: Ioan Sucan */</span>
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="preprocessor">#include &quot;ompl/tools/benchmark/Benchmark.h&quot;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &quot;ompl/tools/benchmark/MachineSpecs.h&quot;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &quot;ompl/util/Time.h&quot;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;boost/lexical_cast.hpp&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;boost/progress.hpp&gt;</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include &lt;fstream&gt;</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include &lt;sstream&gt;</span>
<a name="l00044"></a>00044 
<a name="l00046"></a>00046 <span class="keyword">namespace </span>ompl
<a name="l00047"></a>00047 {
<a name="l00049"></a>00049     <span class="keyword">static</span> std::string getResultsFilename(<span class="keyword">const</span> Benchmark::CompleteExperiment &amp;exp)
<a name="l00050"></a>00050     {
<a name="l00051"></a>00051         <span class="keywordflow">return</span> <span class="stringliteral">&quot;ompl_&quot;</span> + exp.host + <span class="stringliteral">&quot;_&quot;</span> + boost::posix_time::to_iso_extended_string(exp.startTime) + <span class="stringliteral">&quot;.log&quot;</span>;
<a name="l00052"></a>00052     }
<a name="l00053"></a>00053 
<a name="l00055"></a>00055     <span class="keyword">static</span> std::string getConsoleFilename(<span class="keyword">const</span> Benchmark::CompleteExperiment &amp;exp)
<a name="l00056"></a>00056     {
<a name="l00057"></a>00057         <span class="keywordflow">return</span> <span class="stringliteral">&quot;ompl_&quot;</span> + exp.host + <span class="stringliteral">&quot;_&quot;</span> + boost::posix_time::to_iso_extended_string(exp.startTime) + <span class="stringliteral">&quot;.console&quot;</span>;
<a name="l00058"></a>00058     }
<a name="l00059"></a>00059 
<a name="l00060"></a>00060     <span class="keyword">static</span> <span class="keywordtype">bool</span> terminationCondition(<span class="keyword">const</span> <a class="code" href="namespaceompl_1_1machine.html#ab33b6ae8d7c29d501ac4f205cc5719e4" title="Amount of memory used, in bytes.">machine::MemUsage_t</a> maxMem, <span class="keyword">const</span> <a class="code" href="namespaceompl_1_1time.html#a9f28e947d7e95cfa5f0790ccdb7f0953" title="Representation of a point in time.">time::point</a> &amp;endTime)
<a name="l00061"></a>00061     {
<a name="l00062"></a>00062         <span class="keywordflow">if</span> (<a class="code" href="namespaceompl_1_1time.html#a1413ad6c9709d0699343679b291b9c1d" title="Get the current time point.">time::now</a>() &lt; endTime &amp;&amp; <a class="code" href="namespaceompl_1_1machine.html#a8924e2e9ab70ab753b43d4d47e22c3eb" title="Get the amount of memory the current process is using. This should work on major platforms (Windows...">machine::getProcessMemoryUsage</a>() &lt; maxMem)
<a name="l00063"></a>00063             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00064"></a>00064         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00065"></a>00065     }
<a name="l00066"></a>00066 
<a name="l00067"></a>00067     <span class="keyword">class </span>RunPlanner
<a name="l00068"></a>00068     {
<a name="l00069"></a>00069     <span class="keyword">public</span>:
<a name="l00070"></a>00070 
<a name="l00071"></a>00071         RunPlanner(<span class="keyword">const</span> Benchmark *benchmark) : benchmark_(benchmark), timeUsed_(0.0), memUsed_(0), crashed_(false)
<a name="l00072"></a>00072         {
<a name="l00073"></a>00073         }
<a name="l00074"></a>00074 
<a name="l00075"></a>00075         <span class="keywordtype">void</span> run(<span class="keyword">const</span> base::PlannerPtr &amp;planner, <span class="keyword">const</span> <a class="code" href="namespaceompl_1_1machine.html#ab33b6ae8d7c29d501ac4f205cc5719e4" title="Amount of memory used, in bytes.">machine::MemUsage_t</a> memStart, <span class="keyword">const</span> <a class="code" href="namespaceompl_1_1machine.html#ab33b6ae8d7c29d501ac4f205cc5719e4" title="Amount of memory used, in bytes.">machine::MemUsage_t</a> maxMem, <span class="keyword">const</span> <span class="keywordtype">double</span> maxTime)
<a name="l00076"></a>00076         {
<a name="l00077"></a>00077             boost::thread t(boost::bind(&amp;RunPlanner::runThread, <span class="keyword">this</span>, planner, memStart + maxMem, <a class="code" href="namespaceompl_1_1time.html#acac374ab4374adb207edb38cedb7fbb1" title="Return the time duration representing a given number of seconds.">time::seconds</a>(maxTime)));
<a name="l00078"></a>00078 
<a name="l00079"></a>00079             <span class="comment">// allow 25% more time than originally specified, in order to detect planner termination</span>
<a name="l00080"></a>00080             <span class="keywordflow">if</span> (!t.timed_join(<a class="code" href="namespaceompl_1_1time.html#acac374ab4374adb207edb38cedb7fbb1" title="Return the time duration representing a given number of seconds.">time::seconds</a>(maxTime * 1.25)))
<a name="l00081"></a>00081             {
<a name="l00082"></a>00082                 crashed_ = <span class="keyword">true</span>;
<a name="l00083"></a>00083 
<a name="l00084"></a>00084                 std::stringstream es;
<a name="l00085"></a>00085                 es &lt;&lt; <span class="stringliteral">&quot;Planner &quot;</span> &lt;&lt; benchmark_-&gt;getStatus().activePlanner &lt;&lt; <span class="stringliteral">&quot; did not complete run &quot;</span> &lt;&lt; benchmark_-&gt;getStatus().activeRun
<a name="l00086"></a>00086                    &lt;&lt; <span class="stringliteral">&quot; within the specified amount of time (possible crash). Attempting to force termination of planning thread ...&quot;</span> &lt;&lt; std::endl;
<a name="l00087"></a>00087                 std::cerr &lt;&lt; es.str();
<a name="l00088"></a>00088                 msg_.error(es.str());
<a name="l00089"></a>00089 
<a name="l00090"></a>00090                 t.interrupt();
<a name="l00091"></a>00091                 t.join();
<a name="l00092"></a>00092 
<a name="l00093"></a>00093                 std::string m = <span class="stringliteral">&quot;Planning thread cancelled&quot;</span>;
<a name="l00094"></a>00094                 std::cerr &lt;&lt; m &lt;&lt; std::endl;
<a name="l00095"></a>00095                 msg_.error(m);
<a name="l00096"></a>00096             }
<a name="l00097"></a>00097 
<a name="l00098"></a>00098             <span class="keywordflow">if</span> (memStart &lt; memUsed_)
<a name="l00099"></a>00099                 memUsed_ -= memStart;
<a name="l00100"></a>00100             <span class="keywordflow">else</span>
<a name="l00101"></a>00101                 memUsed_ = 0;
<a name="l00102"></a>00102         }
<a name="l00103"></a>00103 
<a name="l00104"></a>00104         <span class="keywordtype">double</span> getTimeUsed(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00105"></a>00105 <span class="keyword">        </span>{
<a name="l00106"></a>00106             <span class="keywordflow">return</span> timeUsed_;
<a name="l00107"></a>00107         }
<a name="l00108"></a>00108 
<a name="l00109"></a>00109         <a class="code" href="namespaceompl_1_1machine.html#ab33b6ae8d7c29d501ac4f205cc5719e4" title="Amount of memory used, in bytes.">machine::MemUsage_t</a> getMemUsed(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00110"></a>00110 <span class="keyword">        </span>{
<a name="l00111"></a>00111             <span class="keywordflow">return</span> memUsed_;
<a name="l00112"></a>00112         }
<a name="l00113"></a>00113 
<a name="l00114"></a>00114         <span class="keywordtype">bool</span> crashed(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00115"></a>00115 <span class="keyword">        </span>{
<a name="l00116"></a>00116             <span class="keywordflow">return</span> crashed_;
<a name="l00117"></a>00117         }
<a name="l00118"></a>00118 
<a name="l00119"></a>00119     <span class="keyword">private</span>:
<a name="l00120"></a>00120 
<a name="l00121"></a>00121         <span class="keywordtype">void</span> runThread(<span class="keyword">const</span> base::PlannerPtr &amp;planner, <span class="keyword">const</span> <a class="code" href="namespaceompl_1_1machine.html#ab33b6ae8d7c29d501ac4f205cc5719e4" title="Amount of memory used, in bytes.">machine::MemUsage_t</a> maxMem, <span class="keyword">const</span> <a class="code" href="namespaceompl_1_1time.html#a4c9f24d26cae91eb6598630f6a22e1b9" title="Representation of a time duration.">time::duration</a> &amp;maxDuration)
<a name="l00122"></a>00122         {
<a name="l00123"></a>00123             <a class="code" href="namespaceompl_1_1time.html#a9f28e947d7e95cfa5f0790ccdb7f0953" title="Representation of a point in time.">time::point</a> timeStart = <a class="code" href="namespaceompl_1_1time.html#a1413ad6c9709d0699343679b291b9c1d" title="Get the current time point.">time::now</a>();
<a name="l00124"></a>00124 
<a name="l00125"></a>00125             <span class="keywordflow">try</span>
<a name="l00126"></a>00126             {
<a name="l00127"></a>00127                 <a class="code" href="namespaceompl_1_1base.html#a23037e2dfd720e4b1b7b4d1c6b09ba1d" title="Signature for functions that decide whether termination conditions have been met for a planner...">base::PlannerTerminationConditionFn</a> ptc = boost::bind(&amp;terminationCondition, maxMem, <a class="code" href="namespaceompl_1_1time.html#a1413ad6c9709d0699343679b291b9c1d" title="Get the current time point.">time::now</a>() + maxDuration);
<a name="l00128"></a>00128                 planner-&gt;solve(ptc, 0.1);
<a name="l00129"></a>00129             }
<a name="l00130"></a>00130             <span class="keywordflow">catch</span>(std::runtime_error &amp;e)
<a name="l00131"></a>00131             {
<a name="l00132"></a>00132                 std::stringstream es;
<a name="l00133"></a>00133                 es &lt;&lt; <span class="stringliteral">&quot;There was an error executing planner &quot;</span> &lt;&lt; benchmark_-&gt;getStatus().activePlanner &lt;&lt;  <span class="stringliteral">&quot;, run = &quot;</span> &lt;&lt; benchmark_-&gt;getStatus().activeRun &lt;&lt; std::endl;
<a name="l00134"></a>00134                 es &lt;&lt; <span class="stringliteral">&quot;*** &quot;</span> &lt;&lt; e.what() &lt;&lt; std::endl;
<a name="l00135"></a>00135                 std::cerr &lt;&lt; es.str();
<a name="l00136"></a>00136                 msg_.error(es.str());
<a name="l00137"></a>00137             }
<a name="l00138"></a>00138 
<a name="l00139"></a>00139             timeUsed_ = <a class="code" href="namespaceompl_1_1time.html#acac374ab4374adb207edb38cedb7fbb1" title="Return the time duration representing a given number of seconds.">time::seconds</a>(<a class="code" href="namespaceompl_1_1time.html#a1413ad6c9709d0699343679b291b9c1d" title="Get the current time point.">time::now</a>() - timeStart);
<a name="l00140"></a>00140             memUsed_ = <a class="code" href="namespaceompl_1_1machine.html#a8924e2e9ab70ab753b43d4d47e22c3eb" title="Get the amount of memory the current process is using. This should work on major platforms (Windows...">machine::getProcessMemoryUsage</a>();
<a name="l00141"></a>00141         }
<a name="l00142"></a>00142 
<a name="l00143"></a>00143         <span class="keyword">const</span> Benchmark    *benchmark_;
<a name="l00144"></a>00144         <span class="keywordtype">double</span>              timeUsed_;
<a name="l00145"></a>00145         <a class="code" href="namespaceompl_1_1machine.html#ab33b6ae8d7c29d501ac4f205cc5719e4" title="Amount of memory used, in bytes.">machine::MemUsage_t</a> memUsed_;
<a name="l00146"></a>00146         <span class="keywordtype">bool</span>                crashed_;
<a name="l00147"></a>00147 
<a name="l00148"></a>00148         msg::Interface      msg_;
<a name="l00149"></a>00149     };
<a name="l00150"></a>00150 
<a name="l00151"></a>00151 }
<a name="l00153"></a>00153 
<a name="l00154"></a><a class="code" href="classompl_1_1Benchmark.html#acc0d4a751aeb070d5250e6345809de19">00154</a> <span class="keywordtype">bool</span> <a class="code" href="classompl_1_1Benchmark.html#a848349a734629a46cae8b425ea688018" title="Save the results of the benchmark to a file. The name of the file is the current date and time...">ompl::Benchmark::saveResultsToFile</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *filename)<span class="keyword"> const</span>
<a name="l00155"></a>00155 <span class="keyword"></span>{
<a name="l00156"></a>00156     <span class="keywordtype">bool</span> result = <span class="keyword">false</span>;
<a name="l00157"></a>00157 
<a name="l00158"></a>00158     std::ofstream fout(filename);
<a name="l00159"></a>00159     <span class="keywordflow">if</span> (fout.good())
<a name="l00160"></a>00160     {
<a name="l00161"></a>00161         result = <a class="code" href="classompl_1_1Benchmark.html#abaf7d3138d919aa4592f46108f95f4d2" title="Save the results of the benchmark to a stream.">saveResultsToStream</a>(fout);
<a name="l00162"></a>00162         <a class="code" href="classompl_1_1Benchmark.html#a739e8d29b9e507c96b91dfd234786389" title="Interface for console output.">msg_</a>.<a class="code" href="classompl_1_1msg_1_1Interface.html#a545368346a008e4de3ea44ce21daccd5" title="Forward information.">inform</a>(<span class="stringliteral">&quot;Results saved to &#39;%s&#39;&quot;</span>, filename);
<a name="l00163"></a>00163     }
<a name="l00164"></a>00164     <span class="keywordflow">else</span>
<a name="l00165"></a>00165     {
<a name="l00166"></a>00166         <span class="comment">// try to save to a different file, if we can</span>
<a name="l00167"></a>00167         <span class="keywordflow">if</span> (getResultsFilename(<a class="code" href="classompl_1_1Benchmark.html#a74dfbbcaad551d0b74096e80fd1b143c" title="The collected experimental data (for all planners)">exp_</a>) != std::string(filename))
<a name="l00168"></a>00168             result = <a class="code" href="classompl_1_1Benchmark.html#a848349a734629a46cae8b425ea688018" title="Save the results of the benchmark to a file. The name of the file is the current date and time...">saveResultsToFile</a>();
<a name="l00169"></a>00169 
<a name="l00170"></a>00170         <a class="code" href="classompl_1_1Benchmark.html#a739e8d29b9e507c96b91dfd234786389" title="Interface for console output.">msg_</a>.<a class="code" href="classompl_1_1msg_1_1Interface.html#ab9c7d9a3fd8a6358e6d8e27c73a52575" title="Forward an error.">error</a>(<span class="stringliteral">&quot;Unable to write results to &#39;%s&#39;&quot;</span>, filename);
<a name="l00171"></a>00171     }
<a name="l00172"></a>00172     <span class="keywordflow">return</span> result;
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174 
<a name="l00175"></a><a class="code" href="classompl_1_1Benchmark.html#a848349a734629a46cae8b425ea688018">00175</a> <span class="keywordtype">bool</span> <a class="code" href="classompl_1_1Benchmark.html#a848349a734629a46cae8b425ea688018" title="Save the results of the benchmark to a file. The name of the file is the current date and time...">ompl::Benchmark::saveResultsToFile</a>(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
<a name="l00176"></a>00176 <span class="keyword"></span>{
<a name="l00177"></a>00177     std::string filename = getResultsFilename(exp_);
<a name="l00178"></a>00178     <span class="keywordflow">return</span> saveResultsToFile(filename.c_str());
<a name="l00179"></a>00179 }
<a name="l00180"></a>00180 
<a name="l00181"></a><a class="code" href="classompl_1_1Benchmark.html#abaf7d3138d919aa4592f46108f95f4d2">00181</a> <span class="keywordtype">bool</span> <a class="code" href="classompl_1_1Benchmark.html#abaf7d3138d919aa4592f46108f95f4d2" title="Save the results of the benchmark to a stream.">ompl::Benchmark::saveResultsToStream</a>(std::ostream &amp;out)<span class="keyword"> const</span>
<a name="l00182"></a>00182 <span class="keyword"></span>{
<a name="l00183"></a>00183     <span class="keywordflow">if</span> (exp_.planners.empty())
<a name="l00184"></a>00184     {
<a name="l00185"></a>00185         msg_.warn(<span class="stringliteral">&quot;There is no experimental data to save&quot;</span>);
<a name="l00186"></a>00186         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00187"></a>00187     }
<a name="l00188"></a>00188 
<a name="l00189"></a>00189     <span class="keywordflow">if</span> (!out.good())
<a name="l00190"></a>00190     {
<a name="l00191"></a>00191         msg_.error(<span class="stringliteral">&quot;Unable to write to stream&quot;</span>);
<a name="l00192"></a>00192         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00193"></a>00193     }
<a name="l00194"></a>00194 
<a name="l00195"></a>00195     out &lt;&lt; <span class="stringliteral">&quot;Experiment &quot;</span> &lt;&lt; (exp_.name.empty() ? <span class="stringliteral">&quot;NO_NAME&quot;</span> : exp_.name) &lt;&lt; std::endl;
<a name="l00196"></a>00196     out &lt;&lt; <span class="stringliteral">&quot;Running on &quot;</span> &lt;&lt; (exp_.host.empty() ? <span class="stringliteral">&quot;UNKNOWN&quot;</span> : exp_.host) &lt;&lt; std::endl;
<a name="l00197"></a>00197     out &lt;&lt; <span class="stringliteral">&quot;Starting at &quot;</span> &lt;&lt; boost::posix_time::to_iso_extended_string(exp_.startTime) &lt;&lt; std::endl;
<a name="l00198"></a>00198     out &lt;&lt; <span class="stringliteral">&quot;&lt;&lt;&lt;|&quot;</span> &lt;&lt; std::endl &lt;&lt; exp_.setupInfo &lt;&lt; <span class="stringliteral">&quot;|&gt;&gt;&gt;&quot;</span> &lt;&lt; std::endl;
<a name="l00199"></a>00199 
<a name="l00200"></a>00200     out &lt;&lt; exp_.seed &lt;&lt; <span class="stringliteral">&quot; is the random seed&quot;</span> &lt;&lt; std::endl;
<a name="l00201"></a>00201     out &lt;&lt; exp_.maxTime &lt;&lt; <span class="stringliteral">&quot; seconds per run&quot;</span> &lt;&lt; std::endl;
<a name="l00202"></a>00202     out &lt;&lt; exp_.maxMem &lt;&lt; <span class="stringliteral">&quot; MB per run&quot;</span> &lt;&lt; std::endl;
<a name="l00203"></a>00203     out &lt;&lt; exp_.totalDuration &lt;&lt; <span class="stringliteral">&quot; seconds spent to collect the data&quot;</span> &lt;&lt; std::endl;
<a name="l00204"></a>00204     out &lt;&lt; exp_.planners.size() &lt;&lt; <span class="stringliteral">&quot; planners&quot;</span> &lt;&lt; std::endl;
<a name="l00205"></a>00205 
<a name="l00206"></a>00206     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0 ; i &lt; exp_.planners.size() ; ++i)
<a name="l00207"></a>00207     {
<a name="l00208"></a>00208         out &lt;&lt; exp_.planners[i].name &lt;&lt; std::endl;
<a name="l00209"></a>00209 
<a name="l00210"></a>00210         <span class="comment">// get names of common properties</span>
<a name="l00211"></a>00211         std::vector&lt;std::string&gt; properties;
<a name="l00212"></a>00212         <span class="keywordflow">for</span> (std::map&lt;std::string, std::string&gt;::const_iterator mit = exp_.planners[i].common.begin() ;
<a name="l00213"></a>00213              mit != exp_.planners[i].common.end() ; ++mit)
<a name="l00214"></a>00214             properties.push_back(mit-&gt;first);
<a name="l00215"></a>00215         std::sort(properties.begin(), properties.end());
<a name="l00216"></a>00216 
<a name="l00217"></a>00217         <span class="comment">// print names &amp; values of common properties</span>
<a name="l00218"></a>00218         out &lt;&lt; properties.size() &lt;&lt; <span class="stringliteral">&quot; common properties&quot;</span> &lt;&lt; std::endl;
<a name="l00219"></a>00219         <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> k = 0 ; k &lt; properties.size() ; ++k)
<a name="l00220"></a>00220         {
<a name="l00221"></a>00221             std::map&lt;std::string, std::string&gt;::const_iterator it = exp_.planners[i].common.find(properties[k]);
<a name="l00222"></a>00222             out &lt;&lt; it-&gt;first &lt;&lt; <span class="stringliteral">&quot; = &quot;</span> &lt;&lt; it-&gt;second &lt;&lt; std::endl;
<a name="l00223"></a>00223         }
<a name="l00224"></a>00224 
<a name="l00225"></a>00225         <span class="comment">// construct the list of all possible properties for all runs</span>
<a name="l00226"></a>00226         std::map&lt;std::string, bool&gt; propSeen;
<a name="l00227"></a>00227         <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = 0 ; j &lt; exp_.planners[i].runs.size() ; ++j)
<a name="l00228"></a>00228             <span class="keywordflow">for</span> (std::map&lt;std::string, std::string&gt;::const_iterator mit = exp_.planners[i].runs[j].begin() ;
<a name="l00229"></a>00229                  mit != exp_.planners[i].runs[j].end() ; ++mit)
<a name="l00230"></a>00230                 propSeen[mit-&gt;first] = <span class="keyword">true</span>;
<a name="l00231"></a>00231 
<a name="l00232"></a>00232         properties.clear();
<a name="l00233"></a>00233 
<a name="l00234"></a>00234         <span class="keywordflow">for</span> (std::map&lt;std::string, bool&gt;::iterator it = propSeen.begin() ; it != propSeen.end() ; ++it)
<a name="l00235"></a>00235             properties.push_back(it-&gt;first);
<a name="l00236"></a>00236         std::sort(properties.begin(), properties.end());
<a name="l00237"></a>00237 
<a name="l00238"></a>00238         <span class="comment">// print the property names</span>
<a name="l00239"></a>00239         out &lt;&lt; properties.size() &lt;&lt; <span class="stringliteral">&quot; properties for each run&quot;</span> &lt;&lt; std::endl;
<a name="l00240"></a>00240         <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = 0 ; j &lt; properties.size() ; ++j)
<a name="l00241"></a>00241             out &lt;&lt; properties[j] &lt;&lt; std::endl;
<a name="l00242"></a>00242 
<a name="l00243"></a>00243         <span class="comment">// print the data for each run</span>
<a name="l00244"></a>00244         out &lt;&lt; exp_.planners[i].runs.size() &lt;&lt; <span class="stringliteral">&quot; runs&quot;</span> &lt;&lt; std::endl;
<a name="l00245"></a>00245         <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = 0 ; j &lt; exp_.planners[i].runs.size() ; ++j)
<a name="l00246"></a>00246         {
<a name="l00247"></a>00247             <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> k = 0 ; k &lt; properties.size() ; ++k)
<a name="l00248"></a>00248             {
<a name="l00249"></a>00249                 std::map&lt;std::string, std::string&gt;::const_iterator it = exp_.planners[i].runs[j].find(properties[k]);
<a name="l00250"></a>00250                 <span class="keywordflow">if</span> (it != exp_.planners[i].runs[j].end())
<a name="l00251"></a>00251                     out &lt;&lt; it-&gt;second;
<a name="l00252"></a>00252                 out &lt;&lt; <span class="stringliteral">&quot;; &quot;</span>;
<a name="l00253"></a>00253             }
<a name="l00254"></a>00254             out &lt;&lt; std::endl;
<a name="l00255"></a>00255         }
<a name="l00256"></a>00256 
<a name="l00257"></a>00257         out &lt;&lt; <span class="charliteral">&#39;.&#39;</span> &lt;&lt; std::endl;
<a name="l00258"></a>00258     }
<a name="l00259"></a>00259     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00260"></a>00260 }
<a name="l00261"></a>00261 
<a name="l00262"></a><a class="code" href="classompl_1_1Benchmark.html#a14e970715817e989b272006274a07876">00262</a> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Benchmark.html#a14e970715817e989b272006274a07876" title="Benchmark the added planners on the defined problem. Repeated calls clear previously gathered data...">ompl::Benchmark::benchmark</a>(<span class="keywordtype">double</span> maxTime, <span class="keywordtype">double</span> maxMem, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> runCount, <span class="keywordtype">bool</span> displayProgress)
<a name="l00263"></a>00263 {
<a name="l00264"></a>00264     <span class="comment">// sanity checks</span>
<a name="l00265"></a>00265     <span class="keywordflow">if</span> (gsetup_)
<a name="l00266"></a>00266         gsetup_-&gt;setup();
<a name="l00267"></a>00267     <span class="keywordflow">else</span>
<a name="l00268"></a>00268         csetup_-&gt;setup();
<a name="l00269"></a>00269 
<a name="l00270"></a>00270     <span class="keywordflow">if</span> (!(gsetup_ ? gsetup_-&gt;getGoal() : csetup_-&gt;getGoal()))
<a name="l00271"></a>00271     {
<a name="l00272"></a>00272         msg_.error(<span class="stringliteral">&quot;No goal defined&quot;</span>);
<a name="l00273"></a>00273         <span class="keywordflow">return</span>;
<a name="l00274"></a>00274     }
<a name="l00275"></a>00275 
<a name="l00276"></a>00276     <span class="keywordflow">if</span> (planners_.empty())
<a name="l00277"></a>00277     {
<a name="l00278"></a>00278         msg_.error(<span class="stringliteral">&quot;There are no planners to benchmark&quot;</span>);
<a name="l00279"></a>00279         <span class="keywordflow">return</span>;
<a name="l00280"></a>00280     }
<a name="l00281"></a>00281 
<a name="l00282"></a>00282     status_.running = <span class="keyword">true</span>;
<a name="l00283"></a>00283     exp_.totalDuration = 0.0;
<a name="l00284"></a>00284     exp_.maxTime = maxTime;
<a name="l00285"></a>00285     exp_.maxMem = maxMem;
<a name="l00286"></a>00286     exp_.host = <a class="code" href="namespaceompl_1_1machine.html#a2127521d1fee6fec67dfb652f8ba63fe" title="Get the hostname of the machine in use.">machine::getHostname</a>();
<a name="l00287"></a>00287     exp_.seed = <a class="code" href="classompl_1_1RNG.html#a6609dc30a714e43d5f96673c30c30872" title="Get the seed used for random number generation. Passing the returned value to setSeed() at a subseque...">RNG::getSeed</a>();
<a name="l00288"></a>00288 
<a name="l00289"></a>00289     exp_.startTime = <a class="code" href="namespaceompl_1_1time.html#a1413ad6c9709d0699343679b291b9c1d" title="Get the current time point.">time::now</a>();
<a name="l00290"></a>00290 
<a name="l00291"></a>00291     msg_.inform(<span class="stringliteral">&quot;Configuring planners ...&quot;</span>);
<a name="l00292"></a>00292 
<a name="l00293"></a>00293     <span class="comment">// clear previous experimental data</span>
<a name="l00294"></a>00294     exp_.planners.clear();
<a name="l00295"></a>00295     exp_.planners.resize(planners_.size());
<a name="l00296"></a>00296 
<a name="l00297"></a>00297     <span class="keyword">const</span> <a class="code" href="classompl_1_1base_1_1ProblemDefinitionPtr.html" title="A boost shared pointer wrapper for ompl::base::ProblemDefinition.">base::ProblemDefinitionPtr</a> &amp;pdef = gsetup_ ? gsetup_-&gt;getProblemDefinition() : csetup_-&gt;getProblemDefinition();
<a name="l00298"></a>00298     <span class="comment">// set up all the planners</span>
<a name="l00299"></a>00299     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0 ; i &lt; planners_.size() ; ++i)
<a name="l00300"></a>00300     {
<a name="l00301"></a>00301         <span class="comment">// configure the planner</span>
<a name="l00302"></a>00302         planners_[i]-&gt;setProblemDefinition(pdef);
<a name="l00303"></a>00303         <span class="keywordflow">if</span> (!planners_[i]-&gt;isSetup())
<a name="l00304"></a>00304             planners_[i]-&gt;setup();
<a name="l00305"></a>00305         exp_.planners[i].name = (gsetup_ ? <span class="stringliteral">&quot;geometric_&quot;</span> : <span class="stringliteral">&quot;control_&quot;</span>) + planners_[i]-&gt;getName();
<a name="l00306"></a>00306     }
<a name="l00307"></a>00307 
<a name="l00308"></a>00308     msg_.inform(<span class="stringliteral">&quot;Done configuring planners.&quot;</span>);
<a name="l00309"></a>00309     msg_.inform(<span class="stringliteral">&quot;Saving planner setup information ...&quot;</span>);
<a name="l00310"></a>00310 
<a name="l00311"></a>00311     std::stringstream setupInfo;
<a name="l00312"></a>00312     <span class="keywordflow">if</span> (gsetup_)
<a name="l00313"></a>00313         gsetup_-&gt;print(setupInfo);
<a name="l00314"></a>00314     <span class="keywordflow">else</span>
<a name="l00315"></a>00315         csetup_-&gt;print(setupInfo);
<a name="l00316"></a>00316     exp_.setupInfo = setupInfo.str();
<a name="l00317"></a>00317 
<a name="l00318"></a>00318     msg_.inform(<span class="stringliteral">&quot;Done saving information&quot;</span>);
<a name="l00319"></a>00319 
<a name="l00320"></a>00320     msg_.inform(<span class="stringliteral">&quot;Beginning benchmark&quot;</span>);
<a name="l00321"></a>00321     <a class="code" href="classompl_1_1msg_1_1OutputHandler.html" title="Generic class to handle output from a piece of code.">msg::OutputHandler</a> *oh = <a class="code" href="namespaceompl_1_1msg.html#ac32f8f123774d2644538b9ce7ebd24e6" title="Get the instance of the OutputHandler currently used. This is NULL in case there is no output handler...">msg::getOutputHandler</a>();
<a name="l00322"></a>00322     <a class="code" href="classompl_1_1msg_1_1OutputHandlerFile.html" title="Implementation of OutputHandler that saves messages in a file.">msg::OutputHandlerFile</a> ohf(getConsoleFilename(exp_).c_str());
<a name="l00323"></a>00323     <a class="code" href="namespaceompl_1_1msg.html#a66fd8fd39855d4166ff40164fe4d9d6b" title="Specify the instance of the OutputHandler to use. By default, this is OutputHandlerSTD.">msg::useOutputHandler</a>(&amp;ohf);
<a name="l00324"></a>00324     msg_.inform(<span class="stringliteral">&quot;Beginning benchmark&quot;</span>);
<a name="l00325"></a>00325 
<a name="l00326"></a>00326     boost::shared_ptr&lt;boost::progress_display&gt; progress;
<a name="l00327"></a>00327     <span class="keywordflow">if</span> (displayProgress)
<a name="l00328"></a>00328     {
<a name="l00329"></a>00329         std::cout &lt;&lt; <span class="stringliteral">&quot;Running experiment &quot;</span> &lt;&lt; exp_.name &lt;&lt; std::endl;
<a name="l00330"></a>00330         progress.reset(<span class="keyword">new</span> boost::progress_display(100, std::cout));
<a name="l00331"></a>00331     }
<a name="l00332"></a>00332 
<a name="l00333"></a>00333     <a class="code" href="namespaceompl_1_1machine.html#ab33b6ae8d7c29d501ac4f205cc5719e4" title="Amount of memory used, in bytes.">machine::MemUsage_t</a> memStart = <a class="code" href="namespaceompl_1_1machine.html#a8924e2e9ab70ab753b43d4d47e22c3eb" title="Get the amount of memory the current process is using. This should work on major platforms (Windows...">machine::getProcessMemoryUsage</a>();
<a name="l00334"></a>00334     <a class="code" href="namespaceompl_1_1machine.html#ab33b6ae8d7c29d501ac4f205cc5719e4" title="Amount of memory used, in bytes.">machine::MemUsage_t</a> maxMemBytes = (<a class="code" href="namespaceompl_1_1machine.html#ab33b6ae8d7c29d501ac4f205cc5719e4" title="Amount of memory used, in bytes.">machine::MemUsage_t</a>)(maxMem * 1024 * 1024);
<a name="l00335"></a>00335 
<a name="l00336"></a>00336     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0 ; i &lt; planners_.size() ; ++i)
<a name="l00337"></a>00337     {
<a name="l00338"></a>00338         status_.activePlanner = exp_.planners[i].name;
<a name="l00339"></a>00339 
<a name="l00340"></a>00340         <span class="comment">// run the planner</span>
<a name="l00341"></a>00341         <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = 0 ; j &lt; runCount ; ++j)
<a name="l00342"></a>00342         {
<a name="l00343"></a>00343             status_.activeRun = j;
<a name="l00344"></a>00344             status_.progressPercentage = (double)(100 * (runCount * i + j)) / (<span class="keywordtype">double</span>)(planners_.size() * runCount);
<a name="l00345"></a>00345 
<a name="l00346"></a>00346             <span class="keywordflow">if</span> (displayProgress)
<a name="l00347"></a>00347                 <span class="keywordflow">while</span> (status_.progressPercentage &gt; progress-&gt;count())
<a name="l00348"></a>00348                     ++(*progress);
<a name="l00349"></a>00349 
<a name="l00350"></a>00350             msg_.inform(<span class="stringliteral">&quot;Preparing for run %d of %s&quot;</span>, status_.activeRun, status_.activePlanner.c_str());
<a name="l00351"></a>00351 
<a name="l00352"></a>00352             <span class="comment">// make sure all planning data structures are cleared</span>
<a name="l00353"></a>00353             <span class="keywordflow">try</span>
<a name="l00354"></a>00354             {
<a name="l00355"></a>00355                 planners_[i]-&gt;clear();
<a name="l00356"></a>00356                 <span class="keywordflow">if</span> (gsetup_)
<a name="l00357"></a>00357                 {
<a name="l00358"></a>00358                     gsetup_-&gt;getGoal()-&gt;clearSolutionPath();
<a name="l00359"></a>00359                     gsetup_-&gt;getSpaceInformation()-&gt;getMotionValidator()-&gt;resetMotionCounter();
<a name="l00360"></a>00360                 }
<a name="l00361"></a>00361                 <span class="keywordflow">else</span>
<a name="l00362"></a>00362                 {
<a name="l00363"></a>00363                     csetup_-&gt;getGoal()-&gt;clearSolutionPath();
<a name="l00364"></a>00364                     csetup_-&gt;getSpaceInformation()-&gt;getMotionValidator()-&gt;resetMotionCounter();
<a name="l00365"></a>00365                 }
<a name="l00366"></a>00366             }
<a name="l00367"></a>00367             <span class="keywordflow">catch</span>(std::runtime_error &amp;e)
<a name="l00368"></a>00368             {
<a name="l00369"></a>00369                 std::stringstream es;
<a name="l00370"></a>00370                 es &lt;&lt; <span class="stringliteral">&quot;There was an error while preparing for run &quot;</span> &lt;&lt; status_.activeRun &lt;&lt; <span class="stringliteral">&quot; of planner &quot;</span> &lt;&lt; status_.activePlanner &lt;&lt; std::endl;
<a name="l00371"></a>00371                 es &lt;&lt; <span class="stringliteral">&quot;*** &quot;</span> &lt;&lt; e.what() &lt;&lt; std::endl;
<a name="l00372"></a>00372                 std::cerr &lt;&lt; es.str();
<a name="l00373"></a>00373                 msg_.error(es.str());
<a name="l00374"></a>00374             }
<a name="l00375"></a>00375 
<a name="l00376"></a>00376             <span class="comment">// execute pre-run event, if set</span>
<a name="l00377"></a>00377             <span class="keywordflow">try</span>
<a name="l00378"></a>00378             {
<a name="l00379"></a>00379                 <span class="keywordflow">if</span> (preRun_)
<a name="l00380"></a>00380                 {
<a name="l00381"></a>00381                     msg_.inform(<span class="stringliteral">&quot;Executing pre-run event for run %d of planner %s ...&quot;</span>, status_.activeRun, status_.activePlanner.c_str());
<a name="l00382"></a>00382                     preRun_(planners_[i]);
<a name="l00383"></a>00383                     msg_.inform(<span class="stringliteral">&quot;Completed execution of pre-run event&quot;</span>);
<a name="l00384"></a>00384                 }
<a name="l00385"></a>00385             }
<a name="l00386"></a>00386             <span class="keywordflow">catch</span>(std::runtime_error &amp;e)
<a name="l00387"></a>00387             {
<a name="l00388"></a>00388                 std::stringstream es;
<a name="l00389"></a>00389                 es &lt;&lt; <span class="stringliteral">&quot;There was an error executing the pre-run event for run &quot;</span> &lt;&lt; status_.activeRun &lt;&lt; <span class="stringliteral">&quot; of planner &quot;</span> &lt;&lt; status_.activePlanner &lt;&lt; std::endl;
<a name="l00390"></a>00390                 es &lt;&lt; <span class="stringliteral">&quot;*** &quot;</span> &lt;&lt; e.what() &lt;&lt; std::endl;
<a name="l00391"></a>00391                 std::cerr &lt;&lt; es.str();
<a name="l00392"></a>00392                 msg_.error(es.str());
<a name="l00393"></a>00393             }
<a name="l00394"></a>00394 
<a name="l00395"></a>00395             RunPlanner rp(<span class="keyword">this</span>);
<a name="l00396"></a>00396             rp.run(planners_[i], memStart, maxMemBytes, maxTime);
<a name="l00397"></a>00397             <span class="keywordtype">bool</span> solved = gsetup_ ? gsetup_-&gt;haveSolutionPath() : csetup_-&gt;haveSolutionPath();
<a name="l00398"></a>00398 
<a name="l00399"></a>00399             <span class="comment">// store results</span>
<a name="l00400"></a>00400             <span class="keywordflow">try</span>
<a name="l00401"></a>00401             {
<a name="l00402"></a>00402                 <a class="code" href="classompl_1_1Benchmark.html#a5140cf758234fc69a8d9f828f5ef2e04" title="The data collected from a run of a planner is stored as key-value pairs.">RunProperties</a> run;
<a name="l00403"></a>00403 
<a name="l00404"></a>00404                 run[<span class="stringliteral">&quot;crashed BOOLEAN&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(rp.crashed());
<a name="l00405"></a>00405                 run[<span class="stringliteral">&quot;time REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(rp.getTimeUsed());
<a name="l00406"></a>00406                 run[<span class="stringliteral">&quot;memory REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;((double)rp.getMemUsed() / (1024.0 * 1024.0));
<a name="l00407"></a>00407                 <span class="keywordflow">if</span> (gsetup_)
<a name="l00408"></a>00408                 {
<a name="l00409"></a>00409                     run[<span class="stringliteral">&quot;solved BOOLEAN&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;haveExactSolutionPath());
<a name="l00410"></a>00410                     run[<span class="stringliteral">&quot;valid segment fraction REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getSpaceInformation()-&gt;getMotionValidator()-&gt;getValidMotionFraction());
<a name="l00411"></a>00411                 }
<a name="l00412"></a>00412                 <span class="keywordflow">else</span>
<a name="l00413"></a>00413                 {
<a name="l00414"></a>00414                     run[<span class="stringliteral">&quot;solved BOOLEAN&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(csetup_-&gt;haveExactSolutionPath());
<a name="l00415"></a>00415                     run[<span class="stringliteral">&quot;valid segment fraction REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(csetup_-&gt;getSpaceInformation()-&gt;getMotionValidator()-&gt;getValidMotionFraction());
<a name="l00416"></a>00416                 }
<a name="l00417"></a>00417 
<a name="l00418"></a>00418                 <span class="keywordflow">if</span> (solved)
<a name="l00419"></a>00419                 {
<a name="l00420"></a>00420                     <span class="keywordflow">if</span> (gsetup_)
<a name="l00421"></a>00421                     {
<a name="l00422"></a>00422                         run[<span class="stringliteral">&quot;approximate solution BOOLEAN&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getGoal()-&gt;isApproximate());
<a name="l00423"></a>00423                         run[<span class="stringliteral">&quot;solution difference REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getGoal()-&gt;getDifference());
<a name="l00424"></a>00424                         run[<span class="stringliteral">&quot;solution length REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getSolutionPath().length());
<a name="l00425"></a>00425                         run[<span class="stringliteral">&quot;solution smoothness REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getSolutionPath().smoothness());
<a name="l00426"></a>00426                         run[<span class="stringliteral">&quot;solution clearance REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getSolutionPath().clearance());
<a name="l00427"></a>00427                         run[<span class="stringliteral">&quot;solution segments INTEGER&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getSolutionPath().states.size() - 1);
<a name="l00428"></a>00428                         run[<span class="stringliteral">&quot;correct solution BOOLEAN&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getSolutionPath().check());
<a name="l00429"></a>00429 
<a name="l00430"></a>00430                         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> factor = gsetup_-&gt;getStateSpace()-&gt;getValidSegmentCountFactor();
<a name="l00431"></a>00431                         gsetup_-&gt;getStateSpace()-&gt;setValidSegmentCountFactor(factor * 4);
<a name="l00432"></a>00432                         run[<span class="stringliteral">&quot;correct solution strict BOOLEAN&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getSolutionPath().check());
<a name="l00433"></a>00433                         gsetup_-&gt;getStateSpace()-&gt;setValidSegmentCountFactor(factor);
<a name="l00434"></a>00434 
<a name="l00435"></a>00435                         <span class="comment">// simplify solution</span>
<a name="l00436"></a>00436                         <a class="code" href="namespaceompl_1_1time.html#a9f28e947d7e95cfa5f0790ccdb7f0953" title="Representation of a point in time.">time::point</a> timeStart = <a class="code" href="namespaceompl_1_1time.html#a1413ad6c9709d0699343679b291b9c1d" title="Get the current time point.">time::now</a>();
<a name="l00437"></a>00437                         gsetup_-&gt;simplifySolution();
<a name="l00438"></a>00438                         <span class="keywordtype">double</span> timeUsed = <a class="code" href="namespaceompl_1_1time.html#acac374ab4374adb207edb38cedb7fbb1" title="Return the time duration representing a given number of seconds.">time::seconds</a>(<a class="code" href="namespaceompl_1_1time.html#a1413ad6c9709d0699343679b291b9c1d" title="Get the current time point.">time::now</a>() - timeStart);
<a name="l00439"></a>00439                         run[<span class="stringliteral">&quot;simplification time REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(timeUsed);
<a name="l00440"></a>00440                         run[<span class="stringliteral">&quot;simplified solution length REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getSolutionPath().length());
<a name="l00441"></a>00441                         run[<span class="stringliteral">&quot;simplified solution smoothness REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getSolutionPath().smoothness());
<a name="l00442"></a>00442                         run[<span class="stringliteral">&quot;simplified solution clearance REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getSolutionPath().clearance());
<a name="l00443"></a>00443                         run[<span class="stringliteral">&quot;simplified solution segments INTEGER&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getSolutionPath().states.size() - 1);
<a name="l00444"></a>00444                         run[<span class="stringliteral">&quot;simplified correct solution BOOLEAN&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getSolutionPath().check());
<a name="l00445"></a>00445                         gsetup_-&gt;getStateSpace()-&gt;setValidSegmentCountFactor(factor * 4);
<a name="l00446"></a>00446                         run[<span class="stringliteral">&quot;simplified correct solution strict BOOLEAN&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(gsetup_-&gt;getSolutionPath().check());
<a name="l00447"></a>00447                         gsetup_-&gt;getStateSpace()-&gt;setValidSegmentCountFactor(factor);
<a name="l00448"></a>00448                     }
<a name="l00449"></a>00449                     <span class="keywordflow">else</span>
<a name="l00450"></a>00450                     {
<a name="l00451"></a>00451                         run[<span class="stringliteral">&quot;approximate solution BOOLEAN&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(csetup_-&gt;getGoal()-&gt;isApproximate());
<a name="l00452"></a>00452                         run[<span class="stringliteral">&quot;solution difference REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(csetup_-&gt;getGoal()-&gt;getDifference());
<a name="l00453"></a>00453                         run[<span class="stringliteral">&quot;solution length REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(csetup_-&gt;getSolutionPath().length());
<a name="l00454"></a>00454                         run[<span class="stringliteral">&quot;solution clearance REAL&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(csetup_-&gt;getSolutionPath().asGeometric().clearance());
<a name="l00455"></a>00455                         run[<span class="stringliteral">&quot;solution segments INTEGER&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(csetup_-&gt;getSolutionPath().states.size() - 1);
<a name="l00456"></a>00456                         run[<span class="stringliteral">&quot;correct solution BOOLEAN&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(csetup_-&gt;getSolutionPath().check());
<a name="l00457"></a>00457                     }
<a name="l00458"></a>00458                 }
<a name="l00459"></a>00459 
<a name="l00460"></a>00460                 <a class="code" href="classompl_1_1base_1_1PlannerData.html" title="Datatype holding data a planner can expose for debug purposes.">base::PlannerData</a> pd;
<a name="l00461"></a>00461                 planners_[i]-&gt;getPlannerData(pd);
<a name="l00462"></a>00462                 run[<span class="stringliteral">&quot;graph states INTEGER&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(pd.<a class="code" href="classompl_1_1base_1_1PlannerData.html#a7f2d6be893b0165ac2348750a40ef389" title="The list of states in the current exploration datastructure.">states</a>.size());
<a name="l00463"></a>00463                 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> edges = 0;
<a name="l00464"></a>00464                 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> k = 0 ; k &lt; pd.<a class="code" href="classompl_1_1base_1_1PlannerData.html#af420313f052ef87fc4935e71c6d474e9" title="For each i, edges[i] contains the values edges[i][j] such that states[i] connects to every states[edg...">edges</a>.size() ; ++k)
<a name="l00465"></a>00465                     edges += pd.<a class="code" href="classompl_1_1base_1_1PlannerData.html#af420313f052ef87fc4935e71c6d474e9" title="For each i, edges[i] contains the values edges[i][j] such that states[i] connects to every states[edg...">edges</a>[k].size();
<a name="l00466"></a>00466                 run[<span class="stringliteral">&quot;graph motions INTEGER&quot;</span>] = boost::lexical_cast&lt;std::string&gt;(edges);
<a name="l00467"></a>00467 
<a name="l00468"></a>00468                 <span class="keywordflow">for</span> (std::map&lt;std::string, std::string&gt;::const_iterator it = pd.<a class="code" href="classompl_1_1base_1_1PlannerData.html#aca9e2da9d9a46e42c516fc8b926ab65c" title="Any extra properties (key-value pairs) the planner can set.">properties</a>.begin() ; it != pd.<a class="code" href="classompl_1_1base_1_1PlannerData.html#aca9e2da9d9a46e42c516fc8b926ab65c" title="Any extra properties (key-value pairs) the planner can set.">properties</a>.end() ; ++it)
<a name="l00469"></a>00469                     run[it-&gt;first] = it-&gt;second;
<a name="l00470"></a>00470 
<a name="l00471"></a>00471                 <span class="comment">// execute post-run event, if set</span>
<a name="l00472"></a>00472                 <span class="keywordflow">try</span>
<a name="l00473"></a>00473                 {
<a name="l00474"></a>00474                     if (postRun_)
<a name="l00475"></a>00475                     {
<a name="l00476"></a>00476                         msg_.inform(<span class="stringliteral">&quot;Executing post-run event for run %d of planner %s ...&quot;</span>, status_.activeRun, status_.activePlanner.c_str());
<a name="l00477"></a>00477                         postRun_(planners_[i], run);
<a name="l00478"></a>00478                         msg_.inform(<span class="stringliteral">&quot;Completed execution of post-run event&quot;</span>);
<a name="l00479"></a>00479                     }
<a name="l00480"></a>00480                 }
<a name="l00481"></a>00481                 <span class="keywordflow">catch</span>(std::runtime_error &amp;e)
<a name="l00482"></a>00482                 {
<a name="l00483"></a>00483                     std::stringstream es;
<a name="l00484"></a>00484                     es &lt;&lt; <span class="stringliteral">&quot;There was an error in the execution of the post-run event for run &quot;</span> &lt;&lt; status_.activeRun &lt;&lt; <span class="stringliteral">&quot; of planner &quot;</span> &lt;&lt; status_.activePlanner &lt;&lt; std::endl;
<a name="l00485"></a>00485                     es &lt;&lt; <span class="stringliteral">&quot;*** &quot;</span> &lt;&lt; e.what() &lt;&lt; std::endl;
<a name="l00486"></a>00486                     std::cerr &lt;&lt; es.str();
<a name="l00487"></a>00487                     msg_.error(es.str());
<a name="l00488"></a>00488                 }
<a name="l00489"></a>00489 
<a name="l00490"></a>00490                 exp_.planners[i].runs.push_back(run);
<a name="l00491"></a>00491             }
<a name="l00492"></a>00492             <span class="keywordflow">catch</span>(std::runtime_error &amp;e)
<a name="l00493"></a>00493             {
<a name="l00494"></a>00494                 std::stringstream es;
<a name="l00495"></a>00495                 es &lt;&lt; <span class="stringliteral">&quot;There was an error in the extraction of planner results: planner = &quot;</span> &lt;&lt; status_.activePlanner &lt;&lt; <span class="stringliteral">&quot;, run = &quot;</span> &lt;&lt; status_.activePlanner &lt;&lt; std::endl;
<a name="l00496"></a>00496                 es &lt;&lt; <span class="stringliteral">&quot;*** &quot;</span> &lt;&lt; e.what() &lt;&lt; std::endl;
<a name="l00497"></a>00497                 std::cerr &lt;&lt; es.str();
<a name="l00498"></a>00498                 msg_.error(es.str());
<a name="l00499"></a>00499             }
<a name="l00500"></a>00500         }
<a name="l00501"></a>00501     }
<a name="l00502"></a>00502 
<a name="l00503"></a>00503     status_.running = <span class="keyword">false</span>;
<a name="l00504"></a>00504     status_.progressPercentage = 100.0;
<a name="l00505"></a>00505     <span class="keywordflow">if</span> (displayProgress)
<a name="l00506"></a>00506     {
<a name="l00507"></a>00507         <span class="keywordflow">while</span> (status_.progressPercentage &gt; progress-&gt;count())
<a name="l00508"></a>00508             ++(*progress);
<a name="l00509"></a>00509         std::cout &lt;&lt; std::endl;
<a name="l00510"></a>00510     }
<a name="l00511"></a>00511 
<a name="l00512"></a>00512     exp_.totalDuration = <a class="code" href="namespaceompl_1_1time.html#acac374ab4374adb207edb38cedb7fbb1" title="Return the time duration representing a given number of seconds.">time::seconds</a>(<a class="code" href="namespaceompl_1_1time.html#a1413ad6c9709d0699343679b291b9c1d" title="Get the current time point.">time::now</a>() - exp_.startTime);
<a name="l00513"></a>00513 
<a name="l00514"></a>00514     msg_.inform(<span class="stringliteral">&quot;Benchmark complete&quot;</span>);
<a name="l00515"></a>00515     <a class="code" href="namespaceompl_1_1msg.html#a66fd8fd39855d4166ff40164fe4d9d6b" title="Specify the instance of the OutputHandler to use. By default, this is OutputHandlerSTD.">msg::useOutputHandler</a>(oh);
<a name="l00516"></a>00516     msg_.inform(<span class="stringliteral">&quot;Benchmark complete&quot;</span>);
<a name="l00517"></a>00517 }
</pre></div></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">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div>

<div class="footer span-22 push-2 last">
  <a href="http://www.kavrakilab.org">Physical and Biological Computing Group</a> &bull;
  <a href="http://www.cs.rice.edu">Department of Computer Science</a> &bull;
  <a href="http://www.rice.edu">Rice University</a><br>
  <div class="gray">Generated on Sun Oct 9 2011 23:04:40 by&#160;<a href="http://www.doxygen.org/index.html">doxygen</a> 1.7.4</div>
</div>
</div>
</body>
</html>