[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[oMetah-devel] ometah/metaheuristic itsEstimationOfDistributio...
From: |
NoJhan |
Subject: |
[oMetah-devel] ometah/metaheuristic itsEstimationOfDistributio... |
Date: |
Sun, 12 Jun 2005 12:11:13 -0400 |
CVSROOT: /cvsroot/ometah
Module name: ometah
Branch:
Changes by: NoJhan <address@hidden> 05/06/12 16:11:13
Modified files:
metaheuristic : itsEstimationOfDistribution.cpp
itsEstimationOfDistribution.hpp
Log message:
* adding a normal probability density function
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/metaheuristic/itsEstimationOfDistribution.cpp.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/metaheuristic/itsEstimationOfDistribution.hpp.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
Patches:
Index: ometah/metaheuristic/itsEstimationOfDistribution.cpp
diff -u ometah/metaheuristic/itsEstimationOfDistribution.cpp:1.17
ometah/metaheuristic/itsEstimationOfDistribution.cpp:1.18
--- ometah/metaheuristic/itsEstimationOfDistribution.cpp:1.17 Tue Jun 7
12:11:57 2005
+++ ometah/metaheuristic/itsEstimationOfDistribution.cpp Sun Jun 12
16:11:13 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: itsEstimationOfDistribution.cpp,v 1.17 2005/06/07 12:11:57 nojhan Exp
$
+ * $Id: itsEstimationOfDistribution.cpp,v 1.18 2005/06/12 16:11:13 nojhan Exp
$
* Copyright : Université Paris 12 Val-de-Marne
* (61 avenue du Général de Gaulle, 94010, Créteil, France)
* Author : Johann Dréo <address@hidden>
@@ -65,25 +65,19 @@
setFamily("Estimation of Distribution Algorithm");
- setDistribution("Uniform");
+ //setDistribution("Uniform");
+ setDistribution("Normal");
+
setSelectRatio(0.5);
}
-void itsEstimationOfDistribution::learning()
+void itsEstimationOfDistribution::learningUniform(vector< vector<double> >
aSample)
{
- vector< vector<double> > transposedSimplifiedSample;
-
- // for each point, extract the solution vector
- for(unsigned int i=0; i < getSampleSizeCurrent(); i++) {
- // put this vector in a matrix
- transposedSimplifiedSample.push_back( sample[i].getSolution() );
- }
-
// transpose it so that the row correspond to a dimension, and not a
solution
- transposedSimplifiedSample = transpose(transposedSimplifiedSample);
+ vector< vector<double> > transposedSimplifiedSample = transpose(aSample);
-// verify that we have the correct dimension
+ // verify that we have the correct dimension
if( transposedSimplifiedSample.size() != (unsigned
int)this->problem->getDimension() ) {
ostringstream err;
err << "ErrorSize: transposed matrix size ("
@@ -99,8 +93,40 @@
this->parameterUniformMaxima.clear();
for(int dim=0; dim < this->problem->getDimension(); dim++) {
// store them
- this->parameterUniformMinima.push_back( min(
transposedSimplifiedSample[dim] ) );
- this->parameterUniformMaxima.push_back( max(
transposedSimplifiedSample[dim] ) );
+ this->parameterUniformMinima.push_back( min( aSample[dim] ) );
+ this->parameterUniformMaxima.push_back( max( aSample[dim] ) );
+ }
+}
+
+void itsEstimationOfDistribution::learningNormal(vector< vector<double> >
aSample)
+{
+ //! mean on each dimension
+ this->parameterNormalMean = mean( transpose(aSample) );
+
+ //! variance covariance matrix
+ this->parameterNormalVarCovar = varianceCovariance(aSample);
+}
+
+
+void itsEstimationOfDistribution::learning()
+{
+ vector< vector<double> > simplifiedSample;
+
+ // for each point, extract the solution vector
+ for(unsigned int i=0; i < getSampleSizeCurrent(); i++) {
+ // put this vector in a matrix
+ simplifiedSample.push_back( sample[i].getSolution() );
+ }
+
+
+ if ( distribution == "Uniform" ) {
+ learningUniform( simplifiedSample );
+
+ } else if (distribution == "Normal") {
+ learningNormal( simplifiedSample );
+
+ } else {
+ learningUniform( simplifiedSample );
}
}
@@ -113,7 +139,17 @@
for( unsigned int i=0; i < getSampleSize(); i++) {
// draw solution
itsPoint p;
- p.setSolution( randomUniform(this->parameterUniformMinima,
this->parameterUniformMaxima) );
+
+ if ( distribution == "Uniform" ) {
+ p.setSolution( randomUniform(this->parameterUniformMinima,
this->parameterUniformMaxima) );
+
+ } else if (distribution == "Normal") {
+ p.setSolution( randomNormalMulti(this->parameterNormalMean,
this->parameterNormalVarCovar) );
+
+ } else {
+ p.setSolution( randomUniform(this->parameterUniformMinima,
this->parameterUniformMaxima) );
+ }
+
// get values
sample[i] = evaluate(p);
}
Index: ometah/metaheuristic/itsEstimationOfDistribution.hpp
diff -u ometah/metaheuristic/itsEstimationOfDistribution.hpp:1.9
ometah/metaheuristic/itsEstimationOfDistribution.hpp:1.10
--- ometah/metaheuristic/itsEstimationOfDistribution.hpp:1.9 Tue Jun 7
12:11:57 2005
+++ ometah/metaheuristic/itsEstimationOfDistribution.hpp Sun Jun 12
16:11:13 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: itsEstimationOfDistribution.hpp,v 1.9 2005/06/07 12:11:57 nojhan Exp $
+ * $Id: itsEstimationOfDistribution.hpp,v 1.10 2005/06/12 16:11:13 nojhan Exp
$
* Copyright : Université Paris 12 Val-de-Marne
* (61 avenue du Général de Gaulle, 94010, Créteil, France)
* Author : Johann Dréo <address@hidden>
@@ -37,6 +37,7 @@
/*!
Either :
- Uniform
+ - Normal
*/
string distribution;
@@ -46,6 +47,12 @@
//! The maxima parameter for the uniform distribution
vector<double> parameterUniformMaxima;
+ //! The minima parameter for the uniform distribution
+ vector<double> parameterNormalMean;
+
+ //! The maxima parameter for the uniform distribution
+ vector<vector<double> > parameterNormalVarCovar;
+
//! The select ratio
/*!
A number in [0,1] telling what proportion of points
@@ -63,6 +70,11 @@
//! the learning
void learning();
+ //! Learn the parameters of an uniform distribution
+ void learningUniform(vector< vector<double> > aSample);
+
+ //! Learn the parameters of a normal distribution
+ void learningNormal(vector< vector<double> > aSample);
public:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [oMetah-devel] ometah/metaheuristic itsEstimationOfDistributio...,
NoJhan <=