Click here to Skip to main content
15,885,767 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.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::GaRandomInteger 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_integer.html">GaRandomInteger</a>
  </div>
</div>
<div class="contents">
<h1>Common::GaRandomInteger Class Reference</h1><!-- doxytag: class="Common::GaRandomInteger" --><!-- doxytag: inherits="GaRandom&lt; int &gt;" --><code><a class="el" href="class_common_1_1_ga_random_integer.html" title="GaRandomInteger class generates random 32-bits wide integer numbers. The class implements...">GaRandomInteger</a></code> class generates random 32-bits wide integer numbers. 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; int &gt;</a>.
<p>

<p>
<a href="class_common_1_1_ga_random_integer-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_integer.html#c3621463fb1633e5c82c4be60f568069">GaRandomInteger</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This constructor initializes random generator with current time as seed.  <a href="#c3621463fb1633e5c82c4be60f568069"></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_integer.html#2bdbd87e807e4c57eadb30752f1842f0">GaRandomInteger</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="#2bdbd87e807e4c57eadb30752f1842f0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual int GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_random_integer.html#1f66e70ab6906703a2fec32e89cc0fd4">Generate</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method generates random values in interval(0, 2147483647).  <a href="#1f66e70ab6906703a2fec32e89cc0fd4"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual int GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_random_integer.html#0b442616a91a62801256fb26f2b7447d">Generate</a> (const int &amp;max)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method generates random values in interval(0, <code>max</code>).  <a href="#0b442616a91a62801256fb26f2b7447d"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual int GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_random_integer.html#091d19be164f0194415813e82d302528">Generate</a> (const int &amp;min, const int &amp;max)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This method generates random values in interval(<code>min</code>, <code>max</code>).  <a href="#091d19be164f0194415813e82d302528"></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_integer.html#8bdbff25b7c8f8ee1390c3bc0718dcb4">_generator</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Instance of algorithm for generating random numbers.  <a href="#8bdbff25b7c8f8ee1390c3bc0718dcb4"></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_integer.html" title="GaRandomInteger class generates random 32-bits wide integer numbers. The class implements...">GaRandomInteger</a></code> class generates random 32-bits wide integer numbers. 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="c3621463fb1633e5c82c4be60f568069"></a><!-- doxytag: member="Common::GaRandomInteger::GaRandomInteger" ref="c3621463fb1633e5c82c4be60f568069" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Common::GaRandomInteger::GaRandomInteger           </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="2bdbd87e807e4c57eadb30752f1842f0"></a><!-- doxytag: member="Common::GaRandomInteger::GaRandomInteger" ref="2bdbd87e807e4c57eadb30752f1842f0" args="(unsigned long seed)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Common::GaRandomInteger::GaRandomInteger           </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="1f66e70ab6906703a2fec32e89cc0fd4"></a><!-- doxytag: member="Common::GaRandomInteger::Generate" ref="1f66e70ab6906703a2fec32e89cc0fd4" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual int GACALL Common::GaRandomInteger::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 values in interval(0, 2147483647). 
<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; int &gt;</a>.</p>

</div>
</div><p>
<a class="anchor" name="0b442616a91a62801256fb26f2b7447d"></a><!-- doxytag: member="Common::GaRandomInteger::Generate" ref="0b442616a91a62801256fb26f2b7447d" args="(const int &amp;max)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual int GACALL Common::GaRandomInteger::Generate           </td>
          <td>(</td>
          <td class="paramtype">const int &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 values in interval(0, <code>max</code>). 
<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>maximal value which can be generated.</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; int &gt;</a>.</p>

</div>
</div><p>
<a class="anchor" name="091d19be164f0194415813e82d302528"></a><!-- doxytag: member="Common::GaRandomInteger::Generate" ref="091d19be164f0194415813e82d302528" args="(const int &amp;min, const int &amp;max)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual int GACALL Common::GaRandomInteger::Generate           </td>
          <td>(</td>
          <td class="paramtype">const int &amp;&nbsp;</td>
          <td class="paramname"> <em>min</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int &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 values in interval(<code>min</code>, <code>max</code>). 
<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>minimal value which can be generated.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>max</em>&nbsp;</td><td>maximal value which can be generated.</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; int &gt;</a>.</p>

</div>
</div><p>
<hr><h2>Member Data Documentation</h2>
<a class="anchor" name="8bdbff25b7c8f8ee1390c3bc0718dcb4"></a><!-- doxytag: member="Common::GaRandomInteger::_generator" ref="8bdbff25b7c8f8ee1390c3bc0718dcb4" 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_integer.html#8bdbff25b7c8f8ee1390c3bc0718dcb4">Common::GaRandomInteger::_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