Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ParameterRandomizer.cpp

Go to the documentation of this file.
00001 // ParameterRandomizer.cpp: implementation of the CParameterRandomizer class.
00002 //
00004 
00005 #include "ParameterRandomizer.h"
00006 
00008 // Construction/Destruction
00010 
00011 CParameterRandomizer::CParameterRandomizer(int seed)
00012 {
00013         m_iSeed = seed;
00014         m_pRNG = new Rand(seed);
00015 }
00016 
00017 CParameterRandomizer::~CParameterRandomizer()
00018 {
00019         delete m_pRNG;
00020 }
00021 
00022 void CParameterRandomizer::Randomize(double *parameters, int nParameters, double fraction, int nIterations)
00023 {
00024         if(fraction > 1.0)
00025         {
00026                 fraction = 1.0;
00027         }
00028         if(fraction < 0.0)
00029         {
00030                 fraction = 0.0;
00031         }
00032 
00033         for(int iCount = 0; iCount < nIterations; iCount++)
00034         {
00035                 for(int i = 0; i < nParameters; i++)
00036                 {
00037                         parameters[i] += (-1 + 2*(m_pRNG->uniform()))*fraction*parameters[i];
00038                 }
00039         }
00040 }

Generated on Mon Nov 3 09:38:05 2003 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002