Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Genetic Algorithm Library

, 7 Apr 2012
A framework for genetic algorithms
galdemoapps.zip
TSP.exe
GeneticLibrary.dll
TestApp1.exe
TestApp2.exe
GaSchedule.exe
GaSchedule.cfg
GalDemoSource.zip
TestApp1
TestApp1.vcxproj.filters
TestApp2
TestApp2.vcxproj.filters
TSP
res
.svn
entries
prop-base
Toolbar.bmp.svn-base
TSP.ico.svn-base
props
text-base
Toolbar.bmp.svn-base
TSP.ico.svn-base
TSP.rc2.svn-base
tmp
prop-base
props
text-base
Toolbar.bmp
TSP.ico
TSP.vcxproj.filters
GaSchedule
Algorithm
GaSchedule.cfg
GaSchedule.vcxproj.filters
res
GaSchedule.ico
galdocumentation.zip
doxygen.png
Graphic
ab_cp.png
alg_st.png
a_cr.png
c_cp.png
i_cp.png
mp_cr.png
mv_cr.png
r_cp.png
s_cp.png
s_cr.png
galsource.zip
GeneticLibrary
build
release
gcc_bsd
gcc_linux
gcc_macos
gcc_solaris
icc_linux
icc_macos
icc_win
mingw
msvc
scc_solaris
makefiles
gcc_bsd_debug
gcc_bsd_release
gcc_linux_debug
gcc_linux_release
gcc_macos_debug
gcc_macos_release
gcc_solaris_debug
gcc_solaris_release
icc_linux_debug
icc_linux_release
icc_macos_debug
icc_macos_release
scc_solaris_debug
scc_solaris_release
source
vs
<!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::GaRandomGenerator 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_generator.html">GaRandomGenerator</a>
  </div>
</div>
<div class="contents">
<h1>Common::GaRandomGenerator Class Reference</h1><!-- doxytag: class="Common::GaRandomGenerator" --><code><a class="el" href="class_common_1_1_ga_random_generator.html" title="GaRandomGenerator class implements algorithm for generating 64-bits wide random unsigned...">GaRandomGenerator</a></code> class implements algorithm for generating 64-bits wide random unsigned integers and floating-point numbers. It takes care of architecture's endianness, but underlying CPU architecture must support floating-point by IEEE 754 standard. <code><a class="el" href="class_common_1_1_ga_random_generator.html" title="GaRandomGenerator class implements algorithm for generating 64-bits wide random unsigned...">GaRandomGenerator</a></code> class does not implement <a class="el" href="class_common_1_1_ga_random.html" title="Interface for random value generators.">GaRandom</a> interface. Primary purpose of this class is to provide service for generating random numbers for classes which implement <a class="el" href="class_common_1_1_ga_random.html" title="Interface for random value generators.">GaRandom</a> interface.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;source/Random.h&gt;</code>
<p>

<p>
<a href="class_common_1_1_ga_random_generator-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_generator.html#4a5829dd9f09b0d921bd1f77f6d01b5f">GaRandomGenerator</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This constructor initialize random generator with current time as seed.  <a href="#4a5829dd9f09b0d921bd1f77f6d01b5f"></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_generator.html#132bec0068471263df2156485d9bc9c0">GaRandomGenerator</a> (unsigned int seed)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This constructor initialize random generator with user-defined seed.  <a href="#132bec0068471263df2156485d9bc9c0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">GAL_API unsigned int GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_random_generator.html#4d9f0e1a24f5571858dfdcb3e3521652">Generate</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><code>Generate</code> method generates and returns 32-bit wide unsigned integer.  <a href="#4d9f0e1a24f5571858dfdcb3e3521652"></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_random_generator.html#534aefb9ad412ccaeea5dbd8155fadfb">GenerateFloat</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><code>GeneratrFloat</code> method generates single precision floating point number i interval (0, 1).  <a href="#534aefb9ad412ccaeea5dbd8155fadfb"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">GAL_API double GACALL&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_random_generator.html#874d031f3bea11f68797b817308de80e">GenerateDouble</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><code>GeneratrFloat</code> method generates double precision floating point number i interval (0, 1).  <a href="#874d031f3bea11f68797b817308de80e"></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_random_generator.html#f4f32962bc2ff3d564e1d7dbd6a3f697">Initalization</a> (unsigned int seed1, unsigned int seed2)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initializes random generator with specified seed. <code>Initialization</code> method is called by constructor.  <a href="#f4f32962bc2ff3d564e1d7dbd6a3f697"></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="struct_common_1_1_ga_random_generator_1_1_ga_state.html">GaState</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_random_generator.html#0ff9e90c52b02a65700491bce39263e0">_currentState</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Current state of random generator.  <a href="#0ff9e90c52b02a65700491bce39263e0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_common_1_1_ga_random_generator.html#31546d13945781612e6bef80577671ad">_littleEndian</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This attribute indicates endianness of architecture. If it is set to <code>true</code>, the architecture is little-endian, if the architecture is big-endian this attribute is set to <code>false</code>.  <a href="#31546d13945781612e6bef80577671ad"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Classes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_common_1_1_ga_random_generator_1_1_ga_state.html">GaState</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Defines representations of random generator's state.  <a href="struct_common_1_1_ga_random_generator_1_1_ga_state.html#_details">More...</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_generator.html" title="GaRandomGenerator class implements algorithm for generating 64-bits wide random unsigned...">GaRandomGenerator</a></code> class implements algorithm for generating 64-bits wide random unsigned integers and floating-point numbers. It takes care of architecture's endianness, but underlying CPU architecture must support floating-point by IEEE 754 standard. <code><a class="el" href="class_common_1_1_ga_random_generator.html" title="GaRandomGenerator class implements algorithm for generating 64-bits wide random unsigned...">GaRandomGenerator</a></code> class does not implement <a class="el" href="class_common_1_1_ga_random.html" title="Interface for random value generators.">GaRandom</a> interface. Primary purpose of this class is to provide service for generating random numbers for classes which implement <a class="el" href="class_common_1_1_ga_random.html" title="Interface for random value generators.">GaRandom</a> interface. 
<p>
This class has built-in synchronizator so it is allowed to use <code>LOCK_OBJECT</code> and <code>LOCK_THIS_OBJECT</code> macros with instances of this class. All public methods are thread-safe. <hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="4a5829dd9f09b0d921bd1f77f6d01b5f"></a><!-- doxytag: member="Common::GaRandomGenerator::GaRandomGenerator" ref="4a5829dd9f09b0d921bd1f77f6d01b5f" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Common::GaRandomGenerator::GaRandomGenerator           </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 initialize random generator with current time as seed. 
<p>

</div>
</div><p>
<a class="anchor" name="132bec0068471263df2156485d9bc9c0"></a><!-- doxytag: member="Common::GaRandomGenerator::GaRandomGenerator" ref="132bec0068471263df2156485d9bc9c0" args="(unsigned int seed)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Common::GaRandomGenerator::GaRandomGenerator           </td>
          <td>(</td>
          <td class="paramtype">unsigned int&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="4d9f0e1a24f5571858dfdcb3e3521652"></a><!-- doxytag: member="Common::GaRandomGenerator::Generate" ref="4d9f0e1a24f5571858dfdcb3e3521652" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int Common::GaRandomGenerator::Generate           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<code>Generate</code> method generates and returns 32-bit wide unsigned integer. 
<p>
This method is thread-safe. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Method returns generated number.</dd></dl>

</div>
</div><p>
<a class="anchor" name="534aefb9ad412ccaeea5dbd8155fadfb"></a><!-- doxytag: member="Common::GaRandomGenerator::GenerateFloat" ref="534aefb9ad412ccaeea5dbd8155fadfb" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">float Common::GaRandomGenerator::GenerateFloat           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<code>GeneratrFloat</code> method generates single precision floating point number i interval (0, 1). 
<p>
This method is thread-safe. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Method returns generated number.</dd></dl>

</div>
</div><p>
<a class="anchor" name="874d031f3bea11f68797b817308de80e"></a><!-- doxytag: member="Common::GaRandomGenerator::GenerateDouble" ref="874d031f3bea11f68797b817308de80e" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">double Common::GaRandomGenerator::GenerateDouble           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
<code>GeneratrFloat</code> method generates double precision floating point number i interval (0, 1). 
<p>
This method is thread-safe. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Method returns generated number.</dd></dl>

</div>
</div><p>
<a class="anchor" name="f4f32962bc2ff3d564e1d7dbd6a3f697"></a><!-- doxytag: member="Common::GaRandomGenerator::Initalization" ref="f4f32962bc2ff3d564e1d7dbd6a3f697" args="(unsigned int seed1, unsigned int seed2)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Common::GaRandomGenerator::Initalization           </td>
          <td>(</td>
          <td class="paramtype">unsigned int&nbsp;</td>
          <td class="paramname"> <em>seed1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&nbsp;</td>
          <td class="paramname"> <em>seed2</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>
Initializes random generator with specified seed. <code>Initialization</code> method is called by constructor. 
<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>seed1</em>&nbsp;</td><td>seed used to initialize the first part of generator's state.</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>seed2</em>&nbsp;</td><td>seed used to initialize the second part of generator's state.</td></tr>
  </table>
</dl>

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

<p>
Current state of random generator. 
<p>

</div>
</div><p>
<a class="anchor" name="31546d13945781612e6bef80577671ad"></a><!-- doxytag: member="Common::GaRandomGenerator::_littleEndian" ref="31546d13945781612e6bef80577671ad" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="class_common_1_1_ga_random_generator.html#31546d13945781612e6bef80577671ad">Common::GaRandomGenerator::_littleEndian</a><code> [private]</code>          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This attribute indicates endianness of architecture. If it is set to <code>true</code>, the architecture is little-endian, if the architecture is big-endian this attribute is set to <code>false</code>. 
<p>

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

Share

About the Author

Mladen Janković
Software Developer
Serbia Serbia
No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 7 Apr 2012
Article Copyright 2008 by Mladen Janković
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid