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: Chromosome::Representation::GaBit 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_chromosome.html">Chromosome</a>::<a class="el" href="namespace_chromosome_1_1_representation.html">Representation</a>::<a class="el" href="class_chromosome_1_1_representation_1_1_ga_bit.html">GaBit</a>
  </div>
</div>
<div class="contents">
<h1>Chromosome::Representation::GaBit Class Reference</h1><!-- doxytag: class="Chromosome::Representation::GaBit" --><!-- doxytag: inherits="Chromosome::Representation::GaCodeValue" -->This class is used by <a class="el" href="class_chromosome_1_1_representation_1_1_ga_binary_chromosome.html" title="This class can be used for solutions of problems which can be encoded as array of...">GaBinaryChromosome</a> class for extracting of single values from chromosome's code and other manipulation on chromosome's code.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;source/BinaryChromosome.h&gt;</code>
<p>
Inherits <a class="el" href="class_chromosome_1_1_representation_1_1_ga_code_value.html">Chromosome::Representation::GaCodeValue</a>.
<p>

<p>
<a href="class_chromosome_1_1_representation_1_1_ga_bit-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 void GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_chromosome_1_1_representation_1_1_ga_bit.html#efc39d5256a8e976c35941033c5b9351">Initialize</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Detailed description can be found in specification of <a class="el" href="class_chromosome_1_1_representation_1_1_ga_code_value.html#fe12973c77be984d3e80de60f75debcf" title="This method initializes value randomly.">GaCodeValue::Initialize</a>.  <a href="#efc39d5256a8e976c35941033c5b9351"></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_chromosome_1_1_representation_1_1_ga_bit.html#7a06c1cd6f6c284ff70279f7d62724f6">FromBuffer</a> (const <a class="el" href="class_chromosome_1_1_representation_1_1_ga_code_values_buffer.html">GaCodeValuesBuffer</a> &amp;buffer, int pos)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Detailed description can be found in specification of <a class="el" href="class_chromosome_1_1_representation_1_1_ga_code_value.html#c26dd54120c7d02398205dce09009cb0" title="This method extract value at given position form buffer of chromosome&#39;s code...">GaCodeValue::FromBuffer</a>.  <a href="#7a06c1cd6f6c284ff70279f7d62724f6"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_chromosome_1_1_representation_1_1_ga_bit.html#799687ee02d4ecd1b4fba410b92c5644">GaBit</a> (bool state)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This constructor initializes bit with user-defined state.  <a href="#799687ee02d4ecd1b4fba410b92c5644"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_chromosome_1_1_representation_1_1_ga_bit.html#59fde29cc729848d85e5880abeb08368">GaBit</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This constructor initializes bit with random state. It calls <a class="el" href="class_chromosome_1_1_representation_1_1_ga_bit.html#efc39d5256a8e976c35941033c5b9351" title="Detailed description can be found in specification of GaCodeValue::Initialize.">Initialize</a> method.  <a href="#59fde29cc729848d85e5880abeb08368"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_chromosome_1_1_representation_1_1_ga_bit.html#847c9d08b262780d4008ef3f7ed15d10">GetBitState</a> () const </td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method is not thread-safe.  <a href="#847c9d08b262780d4008ef3f7ed15d10"></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_chromosome_1_1_representation_1_1_ga_bit.html#216d237c5ec9adbbc2399afec6ab6457">SetBitState</a> (bool state)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><code>SetBitState</code> method sets state of the bit.  <a href="#216d237c5ec9adbbc2399afec6ab6457"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Private Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_chromosome_1_1_representation_1_1_ga_bit.html#60cae1e73b2f91b0b6ecb812c7011a34">_bitState</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This attribute stores state of the bit.  <a href="#60cae1e73b2f91b0b6ecb812c7011a34"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
This class is used by <a class="el" href="class_chromosome_1_1_representation_1_1_ga_binary_chromosome.html" title="This class can be used for solutions of problems which can be encoded as array of...">GaBinaryChromosome</a> class for extracting of single values from chromosome's code and other manipulation on chromosome's code. 
<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="799687ee02d4ecd1b4fba410b92c5644"></a><!-- doxytag: member="Chromosome::Representation::GaBit::GaBit" ref="799687ee02d4ecd1b4fba410b92c5644" args="(bool state)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Chromosome::Representation::GaBit::GaBit           </td>
          <td>(</td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>state</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This constructor initializes bit with user-defined state. 
<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>state</em>&nbsp;</td><td>state of the bit.</td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="59fde29cc729848d85e5880abeb08368"></a><!-- doxytag: member="Chromosome::Representation::GaBit::GaBit" ref="59fde29cc729848d85e5880abeb08368" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Chromosome::Representation::GaBit::GaBit           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This constructor initializes bit with random state. It calls <a class="el" href="class_chromosome_1_1_representation_1_1_ga_bit.html#efc39d5256a8e976c35941033c5b9351" title="Detailed description can be found in specification of GaCodeValue::Initialize.">Initialize</a> method. 
<p>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="efc39d5256a8e976c35941033c5b9351"></a><!-- doxytag: member="Chromosome::Representation::GaBit::Initialize" ref="efc39d5256a8e976c35941033c5b9351" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void GACALL Chromosome::Representation::GaBit::Initialize           </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>
Detailed description can be found in specification of <a class="el" href="class_chromosome_1_1_representation_1_1_ga_code_value.html#fe12973c77be984d3e80de60f75debcf" title="This method initializes value randomly.">GaCodeValue::Initialize</a>. 
<p>

<p>Implements <a class="el" href="class_chromosome_1_1_representation_1_1_ga_code_value.html#fe12973c77be984d3e80de60f75debcf">Chromosome::Representation::GaCodeValue</a>.</p>

</div>
</div><p>
<a class="anchor" name="7a06c1cd6f6c284ff70279f7d62724f6"></a><!-- doxytag: member="Chromosome::Representation::GaBit::FromBuffer" ref="7a06c1cd6f6c284ff70279f7d62724f6" args="(const GaCodeValuesBuffer &amp;buffer, int pos)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void GACALL Chromosome::Representation::GaBit::FromBuffer           </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_chromosome_1_1_representation_1_1_ga_code_values_buffer.html">GaCodeValuesBuffer</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>buffer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>pos</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [inline, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Detailed description can be found in specification of <a class="el" href="class_chromosome_1_1_representation_1_1_ga_code_value.html#c26dd54120c7d02398205dce09009cb0" title="This method extract value at given position form buffer of chromosome&#39;s code...">GaCodeValue::FromBuffer</a>. 
<p>

<p>Implements <a class="el" href="class_chromosome_1_1_representation_1_1_ga_code_value.html#c26dd54120c7d02398205dce09009cb0">Chromosome::Representation::GaCodeValue</a>.</p>

</div>
</div><p>
<a class="anchor" name="847c9d08b262780d4008ef3f7ed15d10"></a><!-- doxytag: member="Chromosome::Representation::GaBit::GetBitState" ref="847c9d08b262780d4008ef3f7ed15d10" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool GACALL Chromosome::Representation::GaBit::GetBitState           </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>Method returns state of bit.</dd></dl>

</div>
</div><p>
<a class="anchor" name="216d237c5ec9adbbc2399afec6ab6457"></a><!-- doxytag: member="Chromosome::Representation::GaBit::SetBitState" ref="216d237c5ec9adbbc2399afec6ab6457" args="(bool state)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void GACALL Chromosome::Representation::GaBit::SetBitState           </td>
          <td>(</td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>state</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<code>SetBitState</code> method sets state of the bit. 
<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>state</em>&nbsp;</td><td>new state.</td></tr>
  </table>
</dl>

</div>
</div><p>
<hr><h2>Member Data Documentation</h2>
<a class="anchor" name="60cae1e73b2f91b0b6ecb812c7011a34"></a><!-- doxytag: member="Chromosome::Representation::GaBit::_bitState" ref="60cae1e73b2f91b0b6ecb812c7011a34" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="class_chromosome_1_1_representation_1_1_ga_bit.html#60cae1e73b2f91b0b6ecb812c7011a34">Chromosome::Representation::GaBit::_bitState</a><code> [private]</code>          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This attribute stores state of the bit. 
<p>

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