Click here to Skip to main content
15,896,526 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 439.7K   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::GaRandomBool 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_random_bool.html">GaRandomBool</a>
  </div>
</div>
<div class="contents">
<h1>Common::GaRandomBool Class Reference</h1><!-- doxytag: class="Common::GaRandomBool" --><!-- doxytag: inherits="GaRandom&lt; bool &gt;" --><code><a class="el" href="class_common_1_1_ga_random_bool.html" title="GaRandomBool class generates random boolean values. It supports generating boolean...">GaRandomBool</a></code> class generates random boolean values. It supports generating boolean with defined probabilities of <code>true</code> and <code>false</code> states. The class implements <a class="el" href="class_common_1_1_ga_random.html" title="Interface for random value generators.">GaRandom</a> interface. 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, but all public methods are thread-safe.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;source/Random.h&gt;</code>
<p>
Inherits <a class="el" href="class_common_1_1_ga_random.html">Common::GaRandom&lt; bool &gt;</a>.
<p>

<p>
<a href="class_common_1_1_ga_random_bool-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_random_bool.html#14cdbb26fcac6fd77f47d416c586bf30">GaRandomBool</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This constructor initializes random generator with current time as seed.  <a href="#14cdbb26fcac6fd77f47d416c586bf30"></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_common_1_1_ga_random_bool.html#3ba96627cfbd7ba3fdf241082c55a4cf">GaRandomBool</a> (unsigned long seed)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This constructor initialize random generator with user-defined seed.  <a href="#3ba96627cfbd7ba3fdf241082c55a4cf"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual bool GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_random_bool.html#c951a9347bfb8de6e7b0ea8c9900a4d8">Generate</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method generates random Boolean values.  <a href="#c951a9347bfb8de6e7b0ea8c9900a4d8"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual bool GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_random_bool.html#973149dd16ecefeaad73120e1178861d">Generate</a> (const bool &amp;max)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method generates random Boolean values.  <a href="#973149dd16ecefeaad73120e1178861d"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual bool GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_random_bool.html#b85311d9233c4c40b2039a1f4db2e89f">Generate</a> (const bool &amp;min, const bool &amp;max)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method generates random Boolean values.  <a href="#b85311d9233c4c40b2039a1f4db2e89f"></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_common_1_1_ga_random_bool.html#23410b56dad55e70c5091f543806237f">Generate</a> (double p)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method generates Boolean value with <code>p</code> probability of <code>true</code> value.  <a href="#23410b56dad55e70c5091f543806237f"></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_common_1_1_ga_random_bool.html#be180a8dbc53c8dbb4ba899c41c00b7e">Generate</a> (int p)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method generates Boolean value with <code>p</code> probability of <code>true</code> and <code>100-p</code> of <code>false</code> value.  <a href="#be180a8dbc53c8dbb4ba899c41c00b7e"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Private Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="class_common_1_1_ga_random_generator.html">GaRandomGenerator</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_random_bool.html#bf4ef387d21028fee72f7c2f35ab269c">_generator</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Instance of algorithm for generating random numbers.  <a href="#bf4ef387d21028fee72f7c2f35ab269c"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
<code><a class="el" href="class_common_1_1_ga_random_bool.html" title="GaRandomBool class generates random boolean values. It supports generating boolean...">GaRandomBool</a></code> class generates random boolean values. It supports generating boolean with defined probabilities of <code>true</code> and <code>false</code> states. The class implements <a class="el" href="class_common_1_1_ga_random.html" title="Interface for random value generators.">GaRandom</a> interface. 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, but all public methods are thread-safe. 
<p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="14cdbb26fcac6fd77f47d416c586bf30"></a><!-- doxytag: member="Common::GaRandomBool::GaRandomBool" ref="14cdbb26fcac6fd77f47d416c586bf30" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Common::GaRandomBool::GaRandomBool           </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 random generator with current time as seed. 
<p>

</div>
</div><p>
<a class="anchor" name="3ba96627cfbd7ba3fdf241082c55a4cf"></a><!-- doxytag: member="Common::GaRandomBool::GaRandomBool" ref="3ba96627cfbd7ba3fdf241082c55a4cf" args="(unsigned long seed)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Common::GaRandomBool::GaRandomBool           </td>
          <td>(</td>
          <td class="paramtype">unsigned long&nbsp;</td>
          <td class="paramname"> <em>seed</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This constructor initialize random generator with user-defined seed. 
<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>seed</em>&nbsp;</td><td>user-defined seed.</td></tr>
  </table>
</dl>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="c951a9347bfb8de6e7b0ea8c9900a4d8"></a><!-- doxytag: member="Common::GaRandomBool::Generate" ref="c951a9347bfb8de6e7b0ea8c9900a4d8" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual bool GACALL Common::GaRandomBool::Generate           </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>
This method generates random Boolean values. 
<p>
This method is thread-safe. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Returns generate random value.</dd></dl>

<p>Implements <a class="el" href="class_common_1_1_ga_random.html#d6f9ee3346f19a552da4e70484de49eb">Common::GaRandom&lt; bool &gt;</a>.</p>

</div>
</div><p>
<a class="anchor" name="973149dd16ecefeaad73120e1178861d"></a><!-- doxytag: member="Common::GaRandomBool::Generate" ref="973149dd16ecefeaad73120e1178861d" args="(const bool &amp;max)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual bool GACALL Common::GaRandomBool::Generate           </td>
          <td>(</td>
          <td class="paramtype">const bool &amp;&nbsp;</td>
          <td class="paramname"> <em>max</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This method generates random Boolean values. 
<p>
This method is 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>max</em>&nbsp;</td><td>this parameter is ignored.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Returns generate random value.</dd></dl>

<p>Implements <a class="el" href="class_common_1_1_ga_random.html#6116f8c2789932b7d8739362602af738">Common::GaRandom&lt; bool &gt;</a>.</p>

</div>
</div><p>
<a class="anchor" name="b85311d9233c4c40b2039a1f4db2e89f"></a><!-- doxytag: member="Common::GaRandomBool::Generate" ref="b85311d9233c4c40b2039a1f4db2e89f" args="(const bool &amp;min, const bool &amp;max)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual bool GACALL Common::GaRandomBool::Generate           </td>
          <td>(</td>
          <td class="paramtype">const bool &amp;&nbsp;</td>
          <td class="paramname"> <em>min</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const bool &amp;&nbsp;</td>
          <td class="paramname"> <em>max</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>
This method generates random Boolean values. 
<p>
This method is 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>min</em>&nbsp;</td><td>this parameter is ignored.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>max</em>&nbsp;</td><td>this parameter is ignored.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Returns generate random value.</dd></dl>

<p>Implements <a class="el" href="class_common_1_1_ga_random.html#cbd6b1eced274f8896b381428adee435">Common::GaRandom&lt; bool &gt;</a>.</p>

</div>
</div><p>
<a class="anchor" name="23410b56dad55e70c5091f543806237f"></a><!-- doxytag: member="Common::GaRandomBool::Generate" ref="23410b56dad55e70c5091f543806237f" args="(double p)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool GACALL Common::GaRandomBool::Generate           </td>
          <td>(</td>
          <td class="paramtype">double&nbsp;</td>
          <td class="paramname"> <em>p</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This method generates Boolean value with <code>p</code> probability of <code>true</code> value. 
<p>
This method is 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>p</em>&nbsp;</td><td>probability of <code>true</code> value (0, 1).</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Returns generate random value.</dd></dl>

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

<p>
This method generates Boolean value with <code>p</code> probability of <code>true</code> and <code>100-p</code> of <code>false</code> value. 
<p>
This method is 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>p</em>&nbsp;</td><td>probability in percents of <code>true</code> value (0 - 100).</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Returns generate random value.</dd></dl>

</div>
</div><p>
<hr><h2>Member Data Documentation</h2>
<a class="anchor" name="bf4ef387d21028fee72f7c2f35ab269c"></a><!-- doxytag: member="Common::GaRandomBool::_generator" ref="bf4ef387d21028fee72f7c2f35ab269c" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_common_1_1_ga_random_generator.html">GaRandomGenerator</a> <a class="el" href="class_common_1_1_ga_random_bool.html#bf4ef387d21028fee72f7c2f35ab269c">Common::GaRandomBool::_generator</a><code> [private]</code>          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Instance of algorithm for generating random numbers. 
<p>

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