ometah-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[oMetah-devel] ometah ./SConstruct common/matrix.cpp common/ma...


From: Johann
Subject: [oMetah-devel] ometah ./SConstruct common/matrix.cpp common/ma...
Date: Fri, 11 Mar 2005 16:28:50 -0500

CVSROOT:        /cvsroot/ometah
Module name:    ometah
Branch:         
Changes by:     Johann <address@hidden> 05/03/11 21:28:50

Modified files:
        .              : SConstruct 
        common         : matrix.cpp matrix.hpp 
        metaheuristic  : itsEstimationOfDistribution.cpp 
                         itsMetaheuristic.cpp itsMetaheuristic.hpp 
        problem        : itsProblem.cpp itsProblem.hpp itsRosenbrock.cpp 
                         itsRosenbrock.hpp 

Log message:
        * toward compilation

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/SConstruct.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/matrix.cpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/matrix.hpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/metaheuristic/itsEstimationOfDistribution.cpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/metaheuristic/itsMetaheuristic.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/metaheuristic/itsMetaheuristic.hpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/problem/itsProblem.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/problem/itsProblem.hpp.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/problem/itsRosenbrock.cpp.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/problem/itsRosenbrock.hpp.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: ometah/SConstruct
diff -u ometah/SConstruct:1.2 ometah/SConstruct:1.3
--- ometah/SConstruct:1.2       Fri Mar 11 10:25:24 2005
+++ ometah/SConstruct   Fri Mar 11 21:28:50 2005
@@ -1,4 +1,4 @@
-env = Environment(CCFLAGS = '-Wno-deprecated')
+env = Environment(CCFLAGS = '-Wno-deprecated -g')
 
 
 
Index: ometah/common/matrix.cpp
diff -u ometah/common/matrix.cpp:1.3 ometah/common/matrix.cpp:1.4
--- ometah/common/matrix.cpp:1.3        Fri Mar 11 19:03:50 2005
+++ ometah/common/matrix.cpp    Fri Mar 11 21:28:50 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  $Id: matrix.cpp,v 1.3 2005/03/11 19:03:50 nojhan Exp $
+ *  $Id: matrix.cpp,v 1.4 2005/03/11 21:28:50 nojhan Exp $
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
 
@@ -316,14 +316,14 @@
 }
 
 //! Find the minimum value of a vector
-template<class T, class U>
-T minimum(U aVector, int begin=0, int during=0)
+template<class T>
+typename T::value_type min(T aVector, int begin=0, int during=0)
 {
   if (during==0) {
     during = aVector.size() - begin;
   }
 
-  T aMin = aVector[begin];
+  typename T::value_type aMin = aVector[begin];
 
   for (unsigned int i=begin+1; i<during; i++) {
     if ( aVector[i] < aMin ) {
@@ -335,14 +335,14 @@
 }
 
 //! Find the maximum value of a vector
-template<class T, class U>
-T maximum(U aVector, int begin=0, int during=0)
+template<class T>
+typename T::value_type max(T aVector, int begin=0, int during=0)
 {
   if (during==0) {
     during = aVector.size() - begin;
   }
 
-  T aMax = aVector[begin];
+  typename T::value_type aMax = aVector[begin];
 
   for (unsigned int i=begin+1; i<during; i++) {
     if ( aVector[i] > aMax ) {
Index: ometah/common/matrix.hpp
diff -u ometah/common/matrix.hpp:1.4 ometah/common/matrix.hpp:1.5
--- ometah/common/matrix.hpp:1.4        Fri Mar 11 19:03:50 2005
+++ ometah/common/matrix.hpp    Fri Mar 11 21:28:50 2005
@@ -1,7 +1,7 @@
 /***************************************************************************
  *  matrix.hpp
  *
- *  $Id: matrix.hpp,v 1.4 2005/03/11 19:03:50 nojhan Exp $
+ *  $Id: matrix.hpp,v 1.5 2005/03/11 21:28:50 nojhan Exp $
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
 
@@ -77,12 +77,12 @@
 T stdev( U aVector, int begin=0, int during=0 );
 
 //! Find the minimum value of a vector
-template<class T, class U>
-T minimum( U aVector, int begin=0, int during=0 );
+template<class T>
+typename T::value_type min( T aVector, int begin=0, int during=0 );
 
 //! Find the maximum value of a vector
-template<class T, class U>
-T maximum( U aVector, int begin=0, int during=0 );
+template<class T>
+typename T::value_type max( T aVector, int begin=0, int during=0 );
 
 //! Substraction of two vectors, terms by terms
 template<class T>
Index: ometah/metaheuristic/itsEstimationOfDistribution.cpp
diff -u ometah/metaheuristic/itsEstimationOfDistribution.cpp:1.6 
ometah/metaheuristic/itsEstimationOfDistribution.cpp:1.7
--- ometah/metaheuristic/itsEstimationOfDistribution.cpp:1.6    Fri Mar 11 
19:09:51 2005
+++ ometah/metaheuristic/itsEstimationOfDistribution.cpp        Fri Mar 11 
21:28:50 2005
@@ -1,7 +1,7 @@
 /***************************************************************************
  *  itsMetaheuristic.hpp 
  *   
- *  $Id: itsEstimationOfDistribution.cpp,v 1.6 2005/03/11 19:09:51 nojhan Exp $
+ *  $Id: itsEstimationOfDistribution.cpp,v 1.7 2005/03/11 21:28:50 nojhan Exp $
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
 
@@ -61,11 +61,8 @@
     // find the minimum and the maximum for each dimension  
     for(unsigned int dim=0; dim < this->problem->getDimension(); dim++) {
         // store them
-        vector<double> v = transposedSimplifiedSample[dim];
-        double mi = minimum( v );
-        
-        this->parameterUniformMinima.push_back( mi );
-        this->parameterUniformMaxima.push_back( maximum( 
transposedSimplifiedSample[dim] ) );
+        this->parameterUniformMinima.push_back( min( 
transposedSimplifiedSample[dim] ) );
+        this->parameterUniformMaxima.push_back( max( 
transposedSimplifiedSample[dim] ) );
     }
 }
  
Index: ometah/metaheuristic/itsMetaheuristic.cpp
diff -u ometah/metaheuristic/itsMetaheuristic.cpp:1.4 
ometah/metaheuristic/itsMetaheuristic.cpp:1.5
--- ometah/metaheuristic/itsMetaheuristic.cpp:1.4       Fri Mar 11 19:09:51 2005
+++ ometah/metaheuristic/itsMetaheuristic.cpp   Fri Mar 11 21:28:50 2005
@@ -24,8 +24,13 @@
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
  
+
+#include <iostream>
 #include "itsMetaheuristic.hpp"
 #include "../common/random.hpp"
+#include "../problem/itsProblem.hpp"
+ 
+using namespace std;
  
 //! global optimization methods 
 /*! 
@@ -34,13 +39,13 @@
   metaheuristics
 */
  
-itsMetaheuristic::intensification()
+void itsMetaheuristic::intensification()
 { }
-itsMetaheuristic::diversification()
+void itsMetaheuristic::diversification()
 { }
-itsMetaheuristic::learning()
+void itsMetaheuristic::learning()
 { }
-itsMetaheuristic::parseSpecific()
+void itsMetaheuristic::parseSpecific()
 { }
 
 
@@ -65,11 +70,11 @@
   this->iterationsCurrent=0;
 }
 
-itsMetaheuristic::initialization()
+void itsMetaheuristic::initialization()
 {
   // ask for the bounds
-  vector<double> min = problem->boundsMinima();
-  vector<double> max = problem->boundsMaxima();
+  vector<double> min = this->problem->boundsMinima();
+  vector<double> max = this->problem->boundsMaxima();
   
   // create the initial sample
   for(unsigned int i=0; i<getSampleSize(); i++) {
@@ -83,7 +88,7 @@
   }
 }
 
-itsMetaheuristic::start()
+void itsMetaheuristic::start()
 {
   initialization();
 
@@ -91,7 +96,7 @@
   iterationsCurrent=0;
 
   // while no stopping criterion reached
-  do {
+  while( !isStoppingCriteria() ) {
     // main phases
     learning();
     diversification();
@@ -99,14 +104,14 @@
     
     // one more iteration
     iterationsCurrent++;
-  } while( !isStoppingCriteria() )
+  }
 }
 
-itsMetaheuristic::evaluate()
+void itsMetaheuristic::evaluate()
 { }
-itsMetaheuristic::parse()
+void itsMetaheuristic::parse()
 { }
-itsMetaheuristic::parseCommon()
+void itsMetaheuristic::parseCommon()
 { }
 
 bool itsMetaheuristic::isStoppingCriteria()
@@ -125,81 +130,81 @@
 
  
 
-string getName()
+string itsMetaheuristic::getName()
 {
     return this->name;
 }
 
-void setName(string name)
+void itsMetaheuristic::setName(string name)
 {
     this->name = name;
 }
 
 
-string getAccronym()
+string itsMetaheuristic::getAccronym()
 {
     return this->accronym;
 }
 
-void setAccronym(string accronym)
+void itsMetaheuristic::setAccronym(string accronym)
 {
     this->accronym = accronym;
 }
 
 
-string getDescription()
+string itsMetaheuristic::getDescription()
 {
     return this->description;
 }
 
-void setDescription(string description)
+void itsMetaheuristic::setDescription(string description)
 {
     this->description = description;
 }
   
 
-string getCitation()
+string itsMetaheuristic::getCitation()
 {
     return this->citation;
 }
 
-void setCitation(string citation)
+void itsMetaheuristic::setCitation(string citation)
 {
     this->citation = citation;
 }
 
 
-string getFamily()
+string itsMetaheuristic::getFamily()
 {
     return this->family;
 }
 
-void setFamily(string family)
+void itsMetaheuristic::setFamily(string family)
 {
     this->family = family;
 }
 
 
-int getSampleSize()
+int itsMetaheuristic::getSampleSize()
 {
     return this->sampleSize;
 }
 
-void setSampleSize(int size)
+void itsMetaheuristic::setSampleSize(int size)
 {
     this->sampleSize = size;
     // WARNING : changing the size cause the vector to be reinitialized
-    this->sample.erase();
+    this->sample.erase( this->sample.begin(), this->sample.end() );
     this->sample.reserve( this->sampleSize );
 }
 
 
-string getIterationsMaxNumber()
+int itsMetaheuristic::getIterationsMaxNumber()
 {
     return this->iterationsMaxNumber;
 }
 
-void setIterationsMaxNumber(string nbr)
+void itsMetaheuristic::setIterationsMaxNumber(int nbr)
 {
     this->iterationsMaxNumber = nbr;
 }
Index: ometah/metaheuristic/itsMetaheuristic.hpp
diff -u ometah/metaheuristic/itsMetaheuristic.hpp:1.4 
ometah/metaheuristic/itsMetaheuristic.hpp:1.5
--- ometah/metaheuristic/itsMetaheuristic.hpp:1.4       Fri Mar 11 19:09:51 2005
+++ ometah/metaheuristic/itsMetaheuristic.hpp   Fri Mar 11 21:28:50 2005
@@ -148,6 +148,9 @@
 
 
 public:
+  //! Constructor
+  itsMetaheuristic();
+
   //! start executing a Metaheuristic
   void start();
     
@@ -202,9 +205,9 @@
   void setSampleSize(int size);
 
   //! Return the maximum iterations number
-  string getIterationsMaxNumber();
+  int getIterationsMaxNumber();
   //! Change the  maximum iterations number
-  void setIterationsMaxNumber(string nbr);
+  void setIterationsMaxNumber(int nbr);
     
   //@}
 };
Index: ometah/problem/itsProblem.cpp
diff -u ometah/problem/itsProblem.cpp:1.4 ometah/problem/itsProblem.cpp:1.5
--- ometah/problem/itsProblem.cpp:1.4   Sun Mar  6 11:55:28 2005
+++ ometah/problem/itsProblem.cpp       Fri Mar 11 21:28:50 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  $Id: itsProblem.cpp,v 1.4 2005/03/06 11:55:28 nojhan Exp $
+ *  $Id: itsProblem.cpp,v 1.5 2005/03/11 21:28:50 nojhan Exp $
  *  Copyright 2005 Université Paris 12 Val-de-Marne
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
@@ -21,9 +21,14 @@
 02111-1307 USA
 */
 
+
 #include <string>
+#include <vector>
+#include <sstream>
 #include "itsProblem.hpp"
 
+using namespace std;
+
 //! the default constructor
 itsProblem::itsProblem()
 {
@@ -37,10 +42,10 @@
   setBoundsMaximaAll(0);
   setBoundsMinimaAll(0);
 
-  itsPoint optim();
-  optim.setSolution(vector<double> sol);
-  optim.setValues(vector<double> val);
-  setOptima(optim);
+  //vector<itsPoint> optim;
+  //optim.setSolution(vector<double> sol);
+  //optim.setValues(vector<double> val);
+  //setOptima(optim);
 }
 
 string itsProblem::getName() 
@@ -67,7 +72,7 @@
 
 string itsProblem::getCitation()
 {
-  return this->ciation;
+  return this->citation;
 }
 
 void itsProblem::setCitation(string citation)
@@ -86,7 +91,8 @@
   this->dimension = dimension;
 
   // reinitialization of bounds
-  setBoundsMinima(-1);
+  vector<double> v(dimension,0);
+  setBoundsMinima( v );
 }
 
 
@@ -116,30 +122,30 @@
 vector<vector<double> > itsProblem::getBounds()
 {
     vector<vector<double> > bounds;
-    range.reserve(getDimension());
+    bounds.reserve(getDimension());
 
-    for(unsigned int i=0, i < getDimension(); i++) {
+    for(unsigned int i=0; i < getDimension(); i++) {
         double mini = getBoundsMinima()[i];
         double maxi = getBoundsMaxima()[i];
         vector<double> v; 
         v.reserve(2);
         v.push_back(mini);
         v.push_back(maxi);
-        range.push_back(v);
+        bounds.push_back(v);
     }
 
-    return range;
+    return bounds;
 }
 
-void itsProblem::setBounds(vector<vector<double> > range)
+void itsProblem::setBounds(vector<vector<double> > bounds)
 {
     vector<double> mins, maxs;
     mins.reserve(getDimension());
     maxs.reserve(getDimension());
 
-    for(unsigned int i=0, i < getDimension(); i++) {
-        mins.push_back(range[i][0]);
-        maxs.push_back(range[i][1]);
+    for(unsigned int i=0; i < getDimension(); i++) {
+        mins.push_back(bounds[i][0]);
+        maxs.push_back(bounds[i][1]);
     }
     
     setBoundsMinima(mins);
@@ -148,7 +154,7 @@
 
 vector<double> itsProblem::getBoundsMinima()
 {
-    return this->rangeMinima;
+    return this->boundsMinima;
 }
 
 void itsProblem::setBoundsMinima(vector<double> minima)
@@ -156,13 +162,13 @@
     if(minima.size() != getDimension() ) {
         throw "ErrorSize";
     } else {
-        this->rangeMinima = minima;
+        this->boundsMinima = minima;
     }
 }
 
 vector<double> itsProblem::getBoundsMaxima()
 {
-    return this->rangeMaxima;
+    return this->boundsMaxima;
 }
 
 void itsProblem::setBoundsMaxima(vector<double> maxima)
@@ -170,7 +176,7 @@
     if(maxima.size() != getDimension() ) {
         throw "ErrorSize";
     } else {
-        this->rangeMaxima = maxima;
+        this->boundsMaxima = maxima;
     }
 }
   
@@ -199,3 +205,12 @@
     }
     setBoundsMaxima(v);
 }
+string itsProblem::getFormula()
+{
+    return this->formula;
+}
+
+void itsProblem::setFormula(string formula)
+{
+    this->formula = formula;
+}
Index: ometah/problem/itsProblem.hpp
diff -u ometah/problem/itsProblem.hpp:1.7 ometah/problem/itsProblem.hpp:1.8
--- ometah/problem/itsProblem.hpp:1.7   Fri Mar 11 10:27:02 2005
+++ ometah/problem/itsProblem.hpp       Fri Mar 11 21:28:50 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  $Id: itsProblem.hpp,v 1.7 2005/03/11 10:27:02 nojhan Exp $
+ *  $Id: itsProblem.hpp,v 1.8 2005/03/11 21:28:50 nojhan Exp $
  *  Copyright 2005 Université Paris 12 Val-de-Marne
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
@@ -85,7 +85,9 @@
   
   
 public:
-  
+  //! Constructor
+  itsProblem();
+
   //! Simple attribute accesses
   //address@hidden
 
@@ -110,9 +112,9 @@
   void setDimension(int dimension);
 
   //! Return the formula
-  int getFormula();
+  string getFormula();
   //! Change the formula
-  void setFormula(int formula);
+  void setFormula(string formula);
 
   //! Return the informations about the global optima
   vector<itsPoint> getOptima();
Index: ometah/problem/itsRosenbrock.cpp
diff -u ometah/problem/itsRosenbrock.cpp:1.1 
ometah/problem/itsRosenbrock.cpp:1.2
--- ometah/problem/itsRosenbrock.cpp:1.1        Sat Mar  5 22:44:43 2005
+++ ometah/problem/itsRosenbrock.cpp    Fri Mar 11 21:28:50 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  $Id: itsRosenbrock.cpp,v 1.1 2005/03/05 22:44:43 nojhan Exp $
+ *  $Id: itsRosenbrock.cpp,v 1.2 2005/03/11 21:28:50 nojhan Exp $
  *  Copyright 2005 Université Paris 12 Val-de-Marne
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
@@ -22,24 +22,32 @@
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+
+#include <vector>
 #include "itsRosenbrock.hpp"
  
+using namespace std;
+ 
 itsRosenbrock::itsRosenbrock()
 {
     // informations 
     setName("Rosenbrock");
     setDescription("Rosenbrock is a classical test problem");
     setCitation("Unknown");
-    
setFormula("$R_{n}(\overrightarrow{x})=\sum_{i=1}^{n-1}\left(100\cdot\left(x_{i}^{2}-x_{i+1}\right)^{2}+\left(x_{i}-1\right)^{2}\right)$");
+    
setFormula("$R_{n}(\\overrightarrow{x})=\\sum_{i=1}^{n-1}\\left(100\\cdot\\left(x_{i}^{2}-x_{i+1}\\right)^{2}+\\left(x_{i}-1\\right)^{2}\\right)$");
     
     setDimension(1); // one dimension is the default, but one may change it 
after instanciation
     
-    setRangeMinimaAll(-5);
-    setRangeMaximaAll(10);
+    setBoundsMinimaAll(-5);
+    setBoundsMaximaAll(10);
     
-    itsPoint optim;
-    optim.setSolution(vector<double> sol(getDimension(),1)); // a vector of 1
-    optim.setValues(vector<double> val(1,0)); // a value of 0
+    vector<itsPoint> optim;
+    itsPoint pt;
+    vector<double> sol(getDimension(),1);
+    pt.setSolution(sol); // a vector of 1
+    vector<double> val(1,0);
+    pt.setValues(val); // a value of 0
+    optim.push_back(pt);
     setOptima(optim);
 }
 
@@ -49,12 +57,13 @@
     int dim=getDimension();
 
     for (int i=0;i<dim;i++) {
-        double X=point[i];
-        double Y=point[i+1];
+        double X=point.getSolution()[i];
+        double Y=point.getSolution()[i+1];
         rosen+=(100*(X*X-Y)*(X*X-Y)+(X-1)*(X-1));
     }
     
-    point.setValues(vector<double> val(1,rosen));
+    vector<double> val(1,rosen);
+    point.setValues(val);
     
     return point;
 }
Index: ometah/problem/itsRosenbrock.hpp
diff -u ometah/problem/itsRosenbrock.hpp:1.1 
ometah/problem/itsRosenbrock.hpp:1.2
--- ometah/problem/itsRosenbrock.hpp:1.1        Sat Mar  5 22:44:43 2005
+++ ometah/problem/itsRosenbrock.hpp    Fri Mar 11 21:28:50 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  $Id: itsRosenbrock.hpp,v 1.1 2005/03/05 22:44:43 nojhan Exp $
+ *  $Id: itsRosenbrock.hpp,v 1.2 2005/03/11 21:28:50 nojhan Exp $
  *  Copyright 2005 Université Paris 12 Val-de-Marne
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
@@ -25,14 +25,18 @@
 
 #ifndef ITSROSENBROCK
 #define ITSROSENBROCK
- 
+
+#include "../common/itsPoint.hpp"
 #include "itsProblem.hpp"
  
 class itsRosenbrock : public itsProblem
 {
 public:
+    //! Constructor
     itsRosenbrock();
+
+    //! Function
     itsPoint objectiveFunction(itsPoint point);
-}
+};
 
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]