Click here to Skip to main content
15,886,724 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 437.9K   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: Observing::GaObserver 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_observing.html">Observing</a>::<a class="el" href="class_observing_1_1_ga_observer.html">GaObserver</a>
  </div>
</div>
<div class="contents">
<h1>Observing::GaObserver Class Reference</h1><!-- doxytag: class="Observing::GaObserver" --><code><a class="el" href="class_observing_1_1_ga_observer.html" title="GaObserver interface is base class for all algorithms&#39; observers. This interface...">GaObserver</a></code> interface is base class for all algorithms' observers. This interface has defined methods to handle each event which can be raised by an algorithm.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;source/Observing.h&gt;</code>
<p>
Inherited by <a class="el" href="class_observing_1_1_ga_observer_adapter.html">Observing::GaObserverAdapter</a>, and <a class="el" href="class_observing_1_1_ga_observers_list.html">Observing::GaObserversList</a>.
<p>

<p>
<a href="class_observing_1_1_ga_observer-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">virtual&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_observing_1_1_ga_observer.html#2fe5ced336cb9053fbdda530a2a0badc">~GaObserver</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Because this is base class, virtual destructor must be defined in order to enable calling of right destructor (destructor of inheriting class).  <a href="#2fe5ced336cb9053fbdda530a2a0badc"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_observing_1_1_ga_observer.html#a5c50a114aa0fdeedb58ba0cf70abdcc">StatisticUpdate</a> (const <a class="el" href="class_common_1_1_ga_statistics.html">GaStatistics</a> &amp;statistics, const <a class="el" href="class_algorithm_1_1_ga_algorithm.html">GaAlgorithm</a> &amp;algorithm)=0</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method handles event which is raised at the end of a generation by the algorithm.  <a href="#a5c50a114aa0fdeedb58ba0cf70abdcc"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_observing_1_1_ga_observer.html#e875da8a8dfdce8fee930383dc13b045">NewBestChromosome</a> (const <a class="el" href="class_chromosome_1_1_ga_chromosome.html">GaChromosome</a> &amp;newChromosome, const <a class="el" href="class_algorithm_1_1_ga_algorithm.html">GaAlgorithm</a> &amp;algorithm)=0</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method handles event which is raised when algorithm finds new chromosome (solution) which is better then the best chromosome of previous generation.  <a href="#e875da8a8dfdce8fee930383dc13b045"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_observing_1_1_ga_observer.html#0928c438abe107cc450c32e81bb09fb7">EvolutionStateChanged</a> (<a class="el" href="namespace_algorithm.html#a58c687815e8ac4491235b5a9a40dcfb">GaAlgorithmState</a> newState, const <a class="el" href="class_algorithm_1_1_ga_algorithm.html">GaAlgorithm</a> &amp;algorithm)=0</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method handles event which is raised when state of algorithm's execution is change.  <a href="#0928c438abe107cc450c32e81bb09fb7"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
<code><a class="el" href="class_observing_1_1_ga_observer.html" title="GaObserver interface is base class for all algorithms&#39; observers. This interface...">GaObserver</a></code> interface is base class for all algorithms' observers. This interface has defined methods to handle each event which can be raised by an algorithm. 
<p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="2fe5ced336cb9053fbdda530a2a0badc"></a><!-- doxytag: member="Observing::GaObserver::~GaObserver" ref="2fe5ced336cb9053fbdda530a2a0badc" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual Observing::GaObserver::~GaObserver           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Because this is base class, virtual destructor must be defined in order to enable calling of right destructor (destructor of inheriting class). 
<p>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="a5c50a114aa0fdeedb58ba0cf70abdcc"></a><!-- doxytag: member="Observing::GaObserver::StatisticUpdate" ref="a5c50a114aa0fdeedb58ba0cf70abdcc" args="(const GaStatistics &amp;statistics, const GaAlgorithm &amp;algorithm)=0" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void GACALL Observing::GaObserver::StatisticUpdate           </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>statistics</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="class_algorithm_1_1_ga_algorithm.html">GaAlgorithm</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>algorithm</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [pure virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This method handles event which is raised at the end of a generation by the algorithm. 
<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>statistics</em>&nbsp;</td><td>reference to object with statistical information.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>algorithm</em>&nbsp;</td><td>reference the algorithm which raised event.</td></tr>
  </table>
</dl>

<p>Implemented in <a class="el" href="class_observing_1_1_ga_observer_adapter.html#7ac912c224c0e08c3365fcc0d62f3923">Observing::GaObserverAdapter</a>, and <a class="el" href="class_observing_1_1_ga_observers_list.html#250718a0c069a99a8f67798f64f9e7bd">Observing::GaObserversList</a>.</p>

</div>
</div><p>
<a class="anchor" name="e875da8a8dfdce8fee930383dc13b045"></a><!-- doxytag: member="Observing::GaObserver::NewBestChromosome" ref="e875da8a8dfdce8fee930383dc13b045" args="(const GaChromosome &amp;newChromosome, const GaAlgorithm &amp;algorithm)=0" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void GACALL Observing::GaObserver::NewBestChromosome           </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_chromosome_1_1_ga_chromosome.html">GaChromosome</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>newChromosome</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="class_algorithm_1_1_ga_algorithm.html">GaAlgorithm</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>algorithm</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [pure virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This method handles event which is raised when algorithm finds new chromosome (solution) which is better then the best chromosome of previous generation. 
<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>newChromosome</em>&nbsp;</td><td>reference to the chromosome.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>algorithm</em>&nbsp;</td><td>reference the algorithm which raised event.</td></tr>
  </table>
</dl>

<p>Implemented in <a class="el" href="class_observing_1_1_ga_observer_adapter.html#af25342570f7e2f1f3ac76b1fd0dee30">Observing::GaObserverAdapter</a>, and <a class="el" href="class_observing_1_1_ga_observers_list.html#996a0f90d7140d667b90af4ae8778c3d">Observing::GaObserversList</a>.</p>

</div>
</div><p>
<a class="anchor" name="0928c438abe107cc450c32e81bb09fb7"></a><!-- doxytag: member="Observing::GaObserver::EvolutionStateChanged" ref="0928c438abe107cc450c32e81bb09fb7" args="(GaAlgorithmState newState, const GaAlgorithm &amp;algorithm)=0" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void GACALL Observing::GaObserver::EvolutionStateChanged           </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="namespace_algorithm.html#a58c687815e8ac4491235b5a9a40dcfb">GaAlgorithmState</a>&nbsp;</td>
          <td class="paramname"> <em>newState</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="class_algorithm_1_1_ga_algorithm.html">GaAlgorithm</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>algorithm</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [pure virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This method handles event which is raised when state of algorithm's execution is change. 
<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>newState</em>&nbsp;</td><td>new state of algorithm's execution</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>algorithm</em>&nbsp;</td><td>reference the algorithm which raised event.</td></tr>
  </table>
</dl>

<p>Implemented in <a class="el" href="class_observing_1_1_ga_observer_adapter.html#3723833754b947f5d1d188c32db7b7ef">Observing::GaObserverAdapter</a>, and <a class="el" href="class_observing_1_1_ga_observers_list.html#6f696f7d126b7603930196605dc17ef3">Observing::GaObserversList</a>.</p>

</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li>source/<a class="el" href="_observing_8h.html">Observing.h</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