Click here to Skip to main content
15,879,326 members
Articles / Desktop Programming / MFC

Genetic Algorithm Library

Rate me:
Please Sign up or sign in to vote.
4.93/5 (175 votes)
7 Apr 2012GPL358 min read 435.4K   34.7K   555  
A framework for genetic algorithms
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Genetic Algorithm Library: Common::GaStatistics Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="namespace_common.html">Common</a>::<a class="el" href="class_common_1_1_ga_statistics.html">GaStatistics</a>
  </div>
</div>
<div class="contents">
<h1>Common::GaStatistics Class Reference</h1><!-- doxytag: class="Common::GaStatistics" --><code><a class="el" href="class_common_1_1_ga_statistics.html" title="GaStatistics class keeps track of statistical information about populations, groups...">GaStatistics</a></code> class keeps track of statistical information about populations, groups of populations or algorithms. It contains information about previous and current statistics, and provides information about progress of statistical values.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;source/Statistics.h&gt;</code>
<p>

<p>
<a href="class_common_1_1_ga_statistics-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#a6321d6eddb7982a2f28787d0976c954">GaStatistics</a> (const <a class="el" href="class_chromosome_1_1_ga_fitness_comparator.html">GaFitnessComparator</a> *comarator)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default constructor initializes all statistical values to zeros and restart generation counter.  <a href="#a6321d6eddb7982a2f28787d0976c954"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">GAL_API void GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#e5f17fd9ab049b55288c53a9164fb810">Clear</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><code>Clear</code> method clears all statistical information and restarts generation counter.  <a href="#e5f17fd9ab049b55288c53a9164fb810"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">GAL_API void GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#67fb4f6957306097a5dbee42dd64117d">NextGeneration</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><code>NextGeneration</code> method prepares statistical values for next generation (shifts current values to previous) and increments generation counter.  <a href="#67fb4f6957306097a5dbee42dd64117d"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">GAL_API void GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#559affdc07f7fa58ef9588c3f892181d">CopyFrom</a> (const <a class="el" href="class_common_1_1_ga_statistics.html">GaStatistics</a> &amp;stats, bool previous, bool current, bool currentGeneration)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><code>CopyFrom</code> method copies statistical information and/or generation counter from another object.  <a href="#559affdc07f7fa58ef9588c3f892181d"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#e8cb7f7eb01344736ed26c2bb268d9d2">GetCurrentGeneration</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method is not thread-safe.  <a href="#e8cb7f7eb01344736ed26c2bb268d9d2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">GAL_API float GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#6072488b5f88982e69f6e8f462c8af45">GetValueProgress</a> (<a class="el" href="namespace_common.html#211adeaf284bd67a8274d58e54a5cb56">GaStatValueType</a> value, bool percent) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><code>GetValueProgress</code> method calculates progress of statistical value between previous and current generation.  <a href="#6072488b5f88982e69f6e8f462c8af45"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">GAL_API void GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#5a2dee4df779f7da8fa3bd501b65b7b1">ChangeValue</a> (<a class="el" href="namespace_common.html#211adeaf284bd67a8274d58e54a5cb56">GaStatValueType</a> type, float value, bool relative)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The method changes statistical value of current generation, change can be absolute or a relative offset to the current value. If <code>GSV_TOTAL_FITNESS</code>, <code>GSV_TOTAL_FITNESS_SCALED</code> or <code>GSV_POPULATION_SIZE</code> values are changed, <code>GSV_AVG_FITNESS</code> and <code>GSV_AVG_FITNESS_SCALED</code> values are updated automatically.  <a href="#5a2dee4df779f7da8fa3bd501b65b7b1"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="class_common_1_1_ga_stat_value.html">GaFloatStatValue</a> &amp;GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#1802d6fceae2187c363d6a8147d40ae2">GetValue</a> (<a class="el" href="namespace_common.html#211adeaf284bd67a8274d58e54a5cb56">GaStatValueType</a> value) const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method is not thread-safe.  <a href="#1802d6fceae2187c363d6a8147d40ae2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="class_chromosome_1_1_ga_fitness_comparator.html">GaFitnessComparator</a> *GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#002ac043d1d503cd79ae42616801ee0f">GetFitnessComarator</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method is not thread-safe.  <a href="#002ac043d1d503cd79ae42616801ee0f"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#3a0f681641239fff3b6f0faaf3f85a15">SetFitnessComparator</a> (const <a class="el" href="class_chromosome_1_1_ga_fitness_comparator.html">GaFitnessComparator</a> *comparator)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><code>SetFitnessComparator</code> method sets fitness comparator which is going to be used to compare statistical values.  <a href="#3a0f681641239fff3b6f0faaf3f85a15"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="class_common_1_1_ga_statistics.html">GaStatistics</a> GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#94d4779faa668f8b924c89d44379601d">operator+</a> (const <a class="el" href="class_common_1_1_ga_statistics.html">GaStatistics</a> &amp;rhs)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This operator produce new object by combining two instances of <code>GaStatistic</code> class. For detailed description of combining statistical values see <a class="el" href="class_common_1_1_ga_statistics.html#3538d0bccc7ea4f8162e94445a3b558d" title="This operator combines statistical values of two instances of GaStatistics class...">operator +=</a> operator.  <a href="#94d4779faa668f8b924c89d44379601d"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">GAL_API <a class="el" href="class_common_1_1_ga_statistics.html">GaStatistics</a> &amp;GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#3538d0bccc7ea4f8162e94445a3b558d">operator+=</a> (const <a class="el" href="class_common_1_1_ga_statistics.html">GaStatistics</a> &amp;rhs)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This operator combines statistical values of two instances of <code><a class="el" href="class_common_1_1_ga_statistics.html" title="GaStatistics class keeps track of statistical information about populations, groups...">GaStatistics</a></code> class. Result of combining is stored in this object. Combining is done in fallowing way: <br>
 1. Better value between two <code>GSV_BEST_FITNESS</code> values is chosen for new <code>GSV_BEST_FITNESS</code> value. <br>
 2. Worse value between two <code>GSV_WORST_FITNESS</code> values is chosen for new <code>GSV_WORST_FITNESS</code>. <br>
 3. Two <code>GSV_TOTAL_FITNESS</code> values are summed and the sum becomes new <code>GSV_TOTAL_FITNESS</code> value. <br>
 4. Two <code>GSV_POPULATION_SIZE</code> values are summed and the sum becomes new <code>GSV_POPULATION_SIZE</code>. <br>
 5. <code>GSV_AVG_FITNES</code> is calculated as: <code>GSV_TOTAL_FITNESS/GSV_POPULATION_SIZE</code>, where <code>GSV_TOTAL_FITNESS</code> and <code>GSV_POPULATION_SIZE</code> have new values. <br>
 6. All scaled fitness values are restarted to zeros. These values cannot be combined because they are calculated differently for different populations.  <a href="#3538d0bccc7ea4f8162e94445a3b558d"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Private Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#7276b7002b24d49a7bd6313860f35414">_currentGeneration</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Generation counter keeps track of current generation of a population or an algorithm.  <a href="#7276b7002b24d49a7bd6313860f35414"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="class_common_1_1_ga_stat_value.html">GaFloatStatValue</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#b76b0bc43547e91330702d94579b6352">_values</a> [<a class="el" href="namespace_common.html#de76616faf39ae480d1356e1b2f9f406">GaNumberOfStatValueTypes</a>]</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Array of statistical information. All statistical values are single precision floating-point numbers.  <a href="#b76b0bc43547e91330702d94579b6352"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="class_chromosome_1_1_ga_fitness_comparator.html">GaFitnessComparator</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_statistics.html#15098b33a5713dfd0745801cafae97df">_fitnessComparator</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Fitness comparator used to compare statistical values.  <a href="#15098b33a5713dfd0745801cafae97df"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
<code><a class="el" href="class_common_1_1_ga_statistics.html" title="GaStatistics class keeps track of statistical information about populations, groups...">GaStatistics</a></code> class keeps track of statistical information about populations, groups of populations or algorithms. It contains information about previous and current statistics, and provides information about progress of statistical values. 
<p>
This class has no built-in synchronizator, so <code>LOCK_OBJECT</code> and <code>LOCK_THIS_OBJECT</code> macros cannot be used with instances of this class. No public or private methods are thread-safe. <hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="a6321d6eddb7982a2f28787d0976c954"></a><!-- doxytag: member="Common::GaStatistics::GaStatistics" ref="a6321d6eddb7982a2f28787d0976c954" args="(const GaFitnessComparator *comarator)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Common::GaStatistics::GaStatistics           </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_chromosome_1_1_ga_fitness_comparator.html">GaFitnessComparator</a> *&nbsp;</td>
          <td class="paramname"> <em>comarator</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Default constructor initializes all statistical values to zeros and restart generation counter. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>comarator</em>&nbsp;</td><td>fitness comparator used to compare statistical values.</td></tr>
  </table>
</dl>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="e5f17fd9ab049b55288c53a9164fb810"></a><!-- doxytag: member="Common::GaStatistics::Clear" ref="e5f17fd9ab049b55288c53a9164fb810" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Common::GaStatistics::Clear           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<code>Clear</code> method clears all statistical information and restarts generation counter. 
<p>
This method is not thread-safe. 
</div>
</div><p>
<a class="anchor" name="67fb4f6957306097a5dbee42dd64117d"></a><!-- doxytag: member="Common::GaStatistics::NextGeneration" ref="67fb4f6957306097a5dbee42dd64117d" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Common::GaStatistics::NextGeneration           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<code>NextGeneration</code> method prepares statistical values for next generation (shifts current values to previous) and increments generation counter. 
<p>
This method is not thread-safe 
</div>
</div><p>
<a class="anchor" name="559affdc07f7fa58ef9588c3f892181d"></a><!-- doxytag: member="Common::GaStatistics::CopyFrom" ref="559affdc07f7fa58ef9588c3f892181d" args="(const GaStatistics &amp;stats, bool previous, bool current, bool currentGeneration)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Common::GaStatistics::CopyFrom           </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_common_1_1_ga_statistics.html">GaStatistics</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>stats</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>previous</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>current</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>currentGeneration</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<code>CopyFrom</code> method copies statistical information and/or generation counter from another object. 
<p>
This method is not thread-safe. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>stats</em>&nbsp;</td><td>object form which information is going to be copied.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>previous</em>&nbsp;</td><td>if it is set to <code>true</code>, then statistical information form previous generation is copied.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>current</em>&nbsp;</td><td>if it is set to <code>true</code>, then statistical information from current generation is copied.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>currentGeneration</em>&nbsp;</td><td>if it is set to <code>true</code>, then generation counter is copied.</td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="e8cb7f7eb01344736ed26c2bb268d9d2"></a><!-- doxytag: member="Common::GaStatistics::GetCurrentGeneration" ref="e8cb7f7eb01344736ed26c2bb268d9d2" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int GACALL Common::GaStatistics::GetCurrentGeneration           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This method is not thread-safe. 
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Returns value of generation counter.</dd></dl>

</div>
</div><p>
<a class="anchor" name="6072488b5f88982e69f6e8f462c8af45"></a><!-- doxytag: member="Common::GaStatistics::GetValueProgress" ref="6072488b5f88982e69f6e8f462c8af45" args="(GaStatValueType value, bool percent) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">float Common::GaStatistics::GetValueProgress           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="namespace_common.html#211adeaf284bd67a8274d58e54a5cb56">GaStatValueType</a>&nbsp;</td>
          <td class="paramname"> <em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>percent</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<code>GetValueProgress</code> method calculates progress of statistical value between previous and current generation. 
<p>
This method is not thread-safe. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>value</em>&nbsp;</td><td>statistical value which progress is queried.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>percent</em>&nbsp;</td><td>if it is set to <code>true</code>, the method returns progress of the value in percents, otherwise it returns absolute progress.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Returns progress of statistical value between previous and current generation. If percent parameter is <code>true</code>, the method return progress in percents, otherwise it returns absolute progress.</dd></dl>

</div>
</div><p>
<a class="anchor" name="5a2dee4df779f7da8fa3bd501b65b7b1"></a><!-- doxytag: member="Common::GaStatistics::ChangeValue" ref="5a2dee4df779f7da8fa3bd501b65b7b1" args="(GaStatValueType type, float value, bool relative)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Common::GaStatistics::ChangeValue           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="namespace_common.html#211adeaf284bd67a8274d58e54a5cb56">GaStatValueType</a>&nbsp;</td>
          <td class="paramname"> <em>type</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&nbsp;</td>
          <td class="paramname"> <em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>relative</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
The method changes statistical value of current generation, change can be absolute or a relative offset to the current value. If <code>GSV_TOTAL_FITNESS</code>, <code>GSV_TOTAL_FITNESS_SCALED</code> or <code>GSV_POPULATION_SIZE</code> values are changed, <code>GSV_AVG_FITNESS</code> and <code>GSV_AVG_FITNESS_SCALED</code> values are updated automatically. 
<p>
This method is not thread-safe. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>type</em>&nbsp;</td><td>statistical value which is going to be changed.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>value</em>&nbsp;</td><td>new value or relative offset to the current value.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>relative</em>&nbsp;</td><td>if is set to <code>true</code>, value parameter is interpreted as relative offset to the current value, if it is set to <code>false</code>, value parameter is interpreted as new value.</td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="1802d6fceae2187c363d6a8147d40ae2"></a><!-- doxytag: member="Common::GaStatistics::GetValue" ref="1802d6fceae2187c363d6a8147d40ae2" args="(GaStatValueType value) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="class_common_1_1_ga_stat_value.html">GaFloatStatValue</a>&amp; GACALL Common::GaStatistics::GetValue           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="namespace_common.html#211adeaf284bd67a8274d58e54a5cb56">GaStatValueType</a>&nbsp;</td>
          <td class="paramname"> <em>value</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This method is not thread-safe. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>value</em>&nbsp;</td><td>statistical value which is queried.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Returns reference to queried statistical value.</dd></dl>

</div>
</div><p>
<a class="anchor" name="002ac043d1d503cd79ae42616801ee0f"></a><!-- doxytag: member="Common::GaStatistics::GetFitnessComarator" ref="002ac043d1d503cd79ae42616801ee0f" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="class_chromosome_1_1_ga_fitness_comparator.html">GaFitnessComparator</a>* GACALL Common::GaStatistics::GetFitnessComarator           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const<code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This method is not thread-safe. 
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Returns pointer to fitness comparator used to compare statistical values.</dd></dl>

</div>
</div><p>
<a class="anchor" name="3a0f681641239fff3b6f0faaf3f85a15"></a><!-- doxytag: member="Common::GaStatistics::SetFitnessComparator" ref="3a0f681641239fff3b6f0faaf3f85a15" args="(const GaFitnessComparator *comparator)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void GACALL Common::GaStatistics::SetFitnessComparator           </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_chromosome_1_1_ga_fitness_comparator.html">GaFitnessComparator</a> *&nbsp;</td>
          <td class="paramname"> <em>comparator</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<code>SetFitnessComparator</code> method sets fitness comparator which is going to be used to compare statistical values. 
<p>
This method is not thread-safe. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>comparator</em>&nbsp;</td><td>fitness comparator.</td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="94d4779faa668f8b924c89d44379601d"></a><!-- doxytag: member="Common::GaStatistics::operator+" ref="94d4779faa668f8b924c89d44379601d" args="(const GaStatistics &amp;rhs)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_common_1_1_ga_statistics.html">GaStatistics</a> GACALL Common::GaStatistics::operator+           </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_common_1_1_ga_statistics.html">GaStatistics</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>rhs</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This operator produce new object by combining two instances of <code>GaStatistic</code> class. For detailed description of combining statistical values see <a class="el" href="class_common_1_1_ga_statistics.html#3538d0bccc7ea4f8162e94445a3b558d" title="This operator combines statistical values of two instances of GaStatistics class...">operator +=</a> operator. 
<p>
This operator is not thread-safe. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>rhs</em>&nbsp;</td><td>reference to the second instance of <code>GaStatistic</code>, the first instance is <code>this</code> object.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Operator returns new instance of GaStatistic class by value.</dd></dl>

</div>
</div><p>
<a class="anchor" name="3538d0bccc7ea4f8162e94445a3b558d"></a><!-- doxytag: member="Common::GaStatistics::operator+=" ref="3538d0bccc7ea4f8162e94445a3b558d" args="(const GaStatistics &amp;rhs)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_common_1_1_ga_statistics.html">GaStatistics</a> &amp; Common::GaStatistics::operator+=           </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_common_1_1_ga_statistics.html">GaStatistics</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>rhs</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This operator combines statistical values of two instances of <code><a class="el" href="class_common_1_1_ga_statistics.html" title="GaStatistics class keeps track of statistical information about populations, groups...">GaStatistics</a></code> class. Result of combining is stored in this object. Combining is done in fallowing way: <br>
 1. Better value between two <code>GSV_BEST_FITNESS</code> values is chosen for new <code>GSV_BEST_FITNESS</code> value. <br>
 2. Worse value between two <code>GSV_WORST_FITNESS</code> values is chosen for new <code>GSV_WORST_FITNESS</code>. <br>
 3. Two <code>GSV_TOTAL_FITNESS</code> values are summed and the sum becomes new <code>GSV_TOTAL_FITNESS</code> value. <br>
 4. Two <code>GSV_POPULATION_SIZE</code> values are summed and the sum becomes new <code>GSV_POPULATION_SIZE</code>. <br>
 5. <code>GSV_AVG_FITNES</code> is calculated as: <code>GSV_TOTAL_FITNESS/GSV_POPULATION_SIZE</code>, where <code>GSV_TOTAL_FITNESS</code> and <code>GSV_POPULATION_SIZE</code> have new values. <br>
 6. All scaled fitness values are restarted to zeros. These values cannot be combined because they are calculated differently for different populations. 
<p>
This operation is not thread-safe. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>rhs</em>&nbsp;</td><td>reference to the instance of class <code><a class="el" href="class_common_1_1_ga_statistics.html" title="GaStatistics class keeps track of statistical information about populations, groups...">GaStatistics</a></code> which is used for combining result statistical values of this object.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The operator returns reference to <code>this</code> object.</dd></dl>

</div>
</div><p>
<hr><h2>Member Data Documentation</h2>
<a class="anchor" name="7276b7002b24d49a7bd6313860f35414"></a><!-- doxytag: member="Common::GaStatistics::_currentGeneration" ref="7276b7002b24d49a7bd6313860f35414" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="class_common_1_1_ga_statistics.html#7276b7002b24d49a7bd6313860f35414">Common::GaStatistics::_currentGeneration</a><code> [private]</code>          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Generation counter keeps track of current generation of a population or an algorithm. 
<p>

</div>
</div><p>
<a class="anchor" name="b76b0bc43547e91330702d94579b6352"></a><!-- doxytag: member="Common::GaStatistics::_values" ref="b76b0bc43547e91330702d94579b6352" args="[GaNumberOfStatValueTypes]" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_common_1_1_ga_stat_value.html">GaFloatStatValue</a> <a class="el" href="class_common_1_1_ga_statistics.html#b76b0bc43547e91330702d94579b6352">Common::GaStatistics::_values</a>[<a class="el" href="namespace_common.html#de76616faf39ae480d1356e1b2f9f406">GaNumberOfStatValueTypes</a>]<code> [private]</code>          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Array of statistical information. All statistical values are single precision floating-point numbers. 
<p>

</div>
</div><p>
<a class="anchor" name="15098b33a5713dfd0745801cafae97df"></a><!-- doxytag: member="Common::GaStatistics::_fitnessComparator" ref="15098b33a5713dfd0745801cafae97df" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="class_chromosome_1_1_ga_fitness_comparator.html">GaFitnessComparator</a>* <a class="el" href="class_common_1_1_ga_statistics.html#15098b33a5713dfd0745801cafae97df">Common::GaStatistics::_fitnessComparator</a><code> [private]</code>          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Fitness comparator used to compare statistical values. 
<p>

</div>
</div><p>
<hr>The documentation for this class was generated from the following files:<ul>
<li>source/<a class="el" href="_statistics_8h.html">Statistics.h</a><li>source/<a class="el" href="_statistics_8cpp.html">Statistics.cpp</a></ul>
</div>
<br/><a href="http://www.coolsoft-sd.com/ProductVersion.aspx?vid=9">Genetic Algorithm Library</a><br/><a href="http://www.coolsoft-sd.com/">Coolsoft Software Development</a>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer
Serbia Serbia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions