ometah-devel
[Top][All Lists]
Advanced

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

[oMetah-devel] ometah ./SConstruct ./ometah.pws common/matrix....


From: Johann
Subject: [oMetah-devel] ometah ./SConstruct ./ometah.pws common/matrix....
Date: Wed, 25 May 2005 11:33:16 -0400

CVSROOT:        /cvsroot/ometah
Module name:    ometah
Branch:         
Changes by:     Johann <address@hidden> 05/05/25 15:33:16

Modified files:
        .              : SConstruct ometah.pws 
        common         : matrix.hpp string.hpp 
        communication  : itsCommunicationClient.cpp 
                         itsCommunicationClient.hpp 
        interface      : ometah.cpp 
        metaheuristic  : itsEstimationOfDistribution.cpp 
                         itsMetaheuristic.cpp itsMetaheuristic.hpp 
        problem        : itsProblem.cpp itsRosenbrock.cpp 

Log message:
        * correcting the segfault error
        * adding some log/debug methods

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/SConstruct.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/ometah.pws.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/matrix.hpp.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/string.hpp.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/communication/itsCommunicationClient.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/communication/itsCommunicationClient.hpp.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/interface/ometah.cpp.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/metaheuristic/itsEstimationOfDistribution.cpp.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/metaheuristic/itsMetaheuristic.cpp.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/metaheuristic/itsMetaheuristic.hpp.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/problem/itsProblem.cpp.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/problem/itsRosenbrock.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: ometah/SConstruct
diff -u ometah/SConstruct:1.8 ometah/SConstruct:1.9
--- ometah/SConstruct:1.8       Sat May 14 16:07:57 2005
+++ ometah/SConstruct   Wed May 25 15:33:15 2005
@@ -4,8 +4,9 @@
           -ffloat-store -funroll-all-loops -funroll-loops -O3'
 
 # flags for checking the code
-fcheck = '-Wall -ansi -pedantic -Wimplicit -Wmissing-prototypes \
-          -Wredundant-decls -Wreturn-type -Wstrict-prototypes -Wunused'
+#-Wstrict-prototypes -Wmissing-prototypes 
+fcheck = '-Wall -ansi -pedantic -Wimplicit \
+          -Wredundant-decls -Wreturn-type -Wunused'
           
 # flags for debugging
 fdebug = '-ggdb'
Index: ometah/common/matrix.hpp
diff -u ometah/common/matrix.hpp:1.8 ometah/common/matrix.hpp:1.9
--- ometah/common/matrix.hpp:1.8        Mon Apr 18 09:16:59 2005
+++ ometah/common/matrix.hpp    Wed May 25 15:33:15 2005
@@ -1,7 +1,7 @@
 /***************************************************************************
  *  matrix.hpp
  *
- *  $Id: matrix.hpp,v 1.8 2005/04/18 09:16:59 tfaili Exp $
+ *  $Id: matrix.hpp,v 1.9 2005/05/25 15:33:15 nojhan Exp $
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
 
@@ -27,6 +27,7 @@
 #include <vector>
 
 using namespace std;
+
 //! Test if a vector is comprised in bounds
 template<class T>
 bool isInBounds( T aVector, T mins, T maxs)
Index: ometah/common/string.hpp
diff -u ometah/common/string.hpp:1.5 ometah/common/string.hpp:1.6
--- ometah/common/string.hpp:1.5        Mon May 16 10:03:54 2005
+++ ometah/common/string.hpp    Wed May 25 15:33:15 2005
@@ -1,6 +1,6 @@
 
 /***************************************************************************
- *  $Id: string.hpp,v 1.5 2005/05/16 10:03:54 nojhan Exp $
+ *  $Id: string.hpp,v 1.6 2005/05/25 15:33:15 nojhan Exp $
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
 
@@ -24,6 +24,7 @@
 #define STRING
 
 #include <ostream>
+#include <sstream>
 #include <string>
 
 using namespace std;
@@ -39,6 +40,21 @@
   }
 };
 
+//! Print a vector
+template<class T,class U>
+string print( T aVector, U aSeparator )
+{
+  ostringstream out;
+  out << aVector[0];
+  
+  for( unsigned int i=1; i<aVector.size(); i++ ) {
+    out << aSeparator << aVector[i];
+  }
+
+  return out;
+};
+
+
 //! Make a double vector from a string vector
 /*
 template<template <class T> class V>
Index: ometah/communication/itsCommunicationClient.cpp
diff -u ometah/communication/itsCommunicationClient.cpp:1.4 
ometah/communication/itsCommunicationClient.cpp:1.5
--- ometah/communication/itsCommunicationClient.cpp:1.4 Sat May 14 16:07:57 2005
+++ ometah/communication/itsCommunicationClient.cpp     Wed May 25 15:33:15 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  $Id: itsCommunicationClient.cpp,v 1.4 2005/05/14 16:07:57 nojhan Exp $
+ *  $Id: itsCommunicationClient.cpp,v 1.5 2005/05/25 15:33:15 nojhan Exp $
  *  Copyright : Université Paris 12 Val-de-Marne
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
@@ -20,39 +20,5 @@
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
  
- #include "../common/logic.hpp"
- #include "itsCommunicationClient.hpp"
-
-
-void itsCommunicationClient::initialization(hash_map<string,string, eqstr> 
args)
-{
-}
-
-//! Call the problem on a point to get its associated values
-itsPoint itsCommunicationClient::call(itsPoint point)
-{
-}
 
-//! The minima of the problem bounds
-vector<double> itsCommunicationClient::boundsMinima()
-{
-}
-
-//! The maxima of the problem bounds
-vector<double> itsCommunicationClient::boundsMaxima()
-{
-}
-
-//! The bounds matrix
-/*!  
-    This method call getBoundsMinima and getBoundsMaxima to produce
-    a matrix with each dimension on a row.
-*/
-vector<vector<double> > itsCommunicationClient::bounds()
-{
-}
-
-//! Return the dimension
-int itsCommunicationClient::getDimension()
-{
-}
+ #include "itsCommunicationClient.hpp"
Index: ometah/communication/itsCommunicationClient.hpp
diff -u ometah/communication/itsCommunicationClient.hpp:1.12 
ometah/communication/itsCommunicationClient.hpp:1.13
--- ometah/communication/itsCommunicationClient.hpp:1.12        Sat May 14 
16:07:57 2005
+++ ometah/communication/itsCommunicationClient.hpp     Wed May 25 15:33:15 2005
@@ -1,7 +1,7 @@
 /***************************************************************************
  *  itsCommunicationClientt.hpp
  *
- *  $Id: itsCommunicationClient.hpp,v 1.12 2005/05/14 16:07:57 nojhan Exp $
+ *  $Id: itsCommunicationClient.hpp,v 1.13 2005/05/25 15:33:15 nojhan Exp $
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
 
@@ -41,26 +41,26 @@
 
 public:
     
-    virtual void initialization(hash_map<string,string, eqstr> args);
+    virtual void initialization(hash_map<string,string, eqstr> args) {};
 
     //! Call the problem on a point to get its associated values
-    virtual itsPoint call(itsPoint point);
+    virtual itsPoint call(itsPoint point) =0;
 
     //! The minima of the problem boundsitsCommunication
-    virtual vector<double> boundsMinima();
+    virtual vector<double> boundsMinima() =0;
 
     //! The maxima of the problem bounds
-    virtual vector<double> boundsMaxima();
+    virtual vector<double> boundsMaxima() =0;
 
     //! The bounds matrix
     /*!  
         This method call getBoundsMinima and getBoundsMaxima to produce
         a matrix with each dimension on a row.
     */
-    virtual vector<vector<double> > bounds();
+    virtual vector<vector<double> > bounds() =0;
 
     //! Return the dimension
-    virtual int getDimension();
+    virtual int getDimension() =0;
 
 };
 
Index: ometah/interface/ometah.cpp
diff -u ometah/interface/ometah.cpp:1.12 ometah/interface/ometah.cpp:1.13
--- ometah/interface/ometah.cpp:1.12    Mon May 16 10:03:54 2005
+++ ometah/interface/ometah.cpp Wed May 25 15:33:16 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  $Id: ometah.cpp,v 1.12 2005/05/16 10:03:54 nojhan Exp $
+ *  $Id: ometah.cpp,v 1.13 2005/05/25 15:33:16 nojhan Exp $
  *  Copyright : Université Paris 12 Val-de-Marne
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
@@ -126,7 +126,8 @@
      */
     
     // Special case for the embedded protocol : we must link client and server
-    if( setMetaheuristic.item()->getKey() == "Embedded" ) {
+    if( setCommunicationClient.item()->getKey() == "Embedded" && 
+        setCommunicationServer.item()->getKey() == "Embedded" ) {
         setCommunicationClient.item()->problem = setCommunicationServer.item();
     }
 
@@ -143,9 +144,12 @@
 
 
     // TESTS
-    cout << "METAHEURISTIC" << endl << 
setMetaheuristic.item()->getInformations();
+    /*cout << "METAHEURISTIC" << endl << 
setMetaheuristic.item()->getInformations();
     cout << "PROBLEM" << endl << setProblem.item()->getInformations();
-    cout << endl;
+    cout << endl;*/
+    
+    setMetaheuristic.item()->addDebugKey("bounds");
+    setMetaheuristic.item()->setLogLevel(2);
 
     setMetaheuristic.item()->start();
 
Index: ometah/metaheuristic/itsEstimationOfDistribution.cpp
diff -u ometah/metaheuristic/itsEstimationOfDistribution.cpp:1.11 
ometah/metaheuristic/itsEstimationOfDistribution.cpp:1.12
--- ometah/metaheuristic/itsEstimationOfDistribution.cpp:1.11   Mon Mar 28 
14:47:23 2005
+++ ometah/metaheuristic/itsEstimationOfDistribution.cpp        Wed May 25 
15:33:16 2005
@@ -1,7 +1,7 @@
 /***************************************************************************
  *  itsMetaheuristic.hpp 
  *   
- *  $Id: itsEstimationOfDistribution.cpp,v 1.11 2005/03/28 14:47:23 nojhan Exp 
$
+ *  $Id: itsEstimationOfDistribution.cpp,v 1.12 2005/05/25 15:33:16 nojhan Exp 
$
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
 
@@ -81,7 +81,7 @@
     transposedSimplifiedSample = transpose(transposedSimplifiedSample);
 
     // verify that we have the correct dimension
-    if( transposedSimplifiedSample.size() != this->problem->getDimension() ) {
+    if( transposedSimplifiedSample.size() != (unsigned 
int)this->problem->getDimension() ) {
         throw "ErrorSize";
     }
 
Index: ometah/metaheuristic/itsMetaheuristic.cpp
diff -u ometah/metaheuristic/itsMetaheuristic.cpp:1.11 
ometah/metaheuristic/itsMetaheuristic.cpp:1.12
--- ometah/metaheuristic/itsMetaheuristic.cpp:1.11      Mon May 16 10:03:54 2005
+++ ometah/metaheuristic/itsMetaheuristic.cpp   Wed May 25 15:33:16 2005
@@ -27,6 +27,7 @@
 
 #include <iostream>
 #include <sstream>
+#include <cstdlib>
 #include "itsMetaheuristic.hpp"
 #include "../common/random.hpp"
 #include "../problem/itsProblem.hpp"
@@ -75,6 +76,13 @@
   this->outDebug = &clog;
 
   this->iterationsCurrent=0;
+
+  this->logLevel = 0;
+  this->logKeys["steps"] = 1;
+  this->logKeys["communications"] = 2;
+  this->logKeys["instanciations"] = 2;
+  this->logKeys["iterations"] = 2;
+
 }
 
 void itsMetaheuristic::initialization()
@@ -113,7 +121,10 @@
     iterationsCurrent++;
   
     //TESTS
-      clog << iterationsCurrent << " ";
+    //string msg = itoa(iterationsCurrent);
+    ostringstream msg;
+    msg << iterationsCurrent;
+    printLog("iterations", msg.str() );
   }
 }
 
@@ -246,3 +257,36 @@
 {
     this->iterationsMaxNumber = nbr;
 }
+
+/*
+void itsMetaheuristic::printDebug(string id, string var)
+{
+    // if the string id is in keys, then print var on debug output
+    if( debugKeys.count( id.c_str() ) > 0 ) {
+        *outDebug << id << " " << var << endl;
+    }
+}
+*/
+
+void itsMetaheuristic::printLog(string level, string message)
+{
+    if( logLevel >= logKeys[level.c_str()] ) {
+        *outLog << message << endl;
+    }
+}
+
+void itsMetaheuristic::addDebugKey(string key) 
+{
+    this->debugKeys.insert( key.c_str() );
+}
+
+int itsMetaheuristic::getLogLevel()
+{
+    return this->logLevel;
+}
+  
+
+void itsMetaheuristic::setLogLevel(int level)
+{
+    this->logLevel = level;
+}
Index: ometah/metaheuristic/itsMetaheuristic.hpp
diff -u ometah/metaheuristic/itsMetaheuristic.hpp:1.13 
ometah/metaheuristic/itsMetaheuristic.hpp:1.14
--- ometah/metaheuristic/itsMetaheuristic.hpp:1.13      Mon May 16 10:03:54 2005
+++ ometah/metaheuristic/itsMetaheuristic.hpp   Wed May 25 15:33:16 2005
@@ -1,8 +1,7 @@
 /***************************************************************************
- *  itsMetaheuristic.hpp 
- *   
- *  Fri Feb  4 13:31:48 2005
- *  Copyright  2005  Walid TFAILI address@hidden
+ *  $Id: itsMetaheuristic.hpp,v 1.14 2005/05/25 15:33:16 nojhan Exp $
+ *  Copyright : 2005 Université Paris 12 Val-de-Marne
+ *  Author : Walid Tfaili <address@hidden>, Johann Dréo <address@hidden>
  ****************************************************************************/
 
 /*  Open Metaheuristic is a Library aimed at the conception of metaheuristics 
@@ -28,9 +27,12 @@
 
 #include <ostream>
 
+#include <set.h>
+
 #include "../common/itsPoint.hpp"
 #include "../communication/itsCommunicationClient.hpp"
 
+
 using namespace std;
 
 /*! 
@@ -145,6 +147,22 @@
   //! Stream for debug
   ostream* outDebug;
 
+  //! The debug keys we want to use
+  /*!
+      This is a simple associative container, it contains only keys.
+  */
+  set<const char *> debugKeys;
+  
+  //! The log levels
+  /*!
+      This is an associative container of the form :
+      level name => level number
+  */
+  hash_map< const char*, int, hash<const char*>, eqstr > logKeys;
+  
+  //! The current log levels
+  int logLevel;
+  
 
 public:
   //! Virtual destructor
@@ -230,8 +248,38 @@
   string getKey();
   //! Change the key
   void setKey( string key );
-    
+  
+  //! Return the log level  
+  int getLogLevel();
+  
+  //! Change the log level
+  void setLogLevel(int level);
+
   //@}
+  
+  
+  //! Output a debug variable
+  /*!
+      Print the debug variable if its name is in debugKeys.
+  */
+  template<class T>
+  void printDebug(string id, T var) {
+    // if the string id is in keys, then print var on debug output
+    if( debugKeys.count( id.c_str() ) > 0 ) {
+        *outDebug << id << " " << var << endl;
+    }
+  }
+
+  //! Output a log message
+  /*! 
+      Print the message if its level is greater than logKeys[level]
+  */
+  void printLog(string level, string message);
+
+  
+  //! Add a debug key
+  void addDebugKey(string key);
+
 };
 
 
Index: ometah/ometah.pws
diff -u ometah/ometah.pws:1.11 ometah/ometah.pws:1.12
--- ometah/ometah.pws:1.11      Mon May 16 10:03:54 2005
+++ ometah/ometah.pws   Wed May 25 15:33:15 2005
@@ -1,13 +1,13 @@
 
 [filenumbers]
-0=1
-1=1
-2=29
-3=32
-4=1
+0=195
+1=56
+2=83
+3=195
+4=80
 5=27
-6=41
-7=136
+6=1
+7=56
 
 [filemarkers]
 0=
@@ -30,6 +30,10 @@
 [Project State]
 clean before build=false
 
+[filelist]
+0=/home/nojhan/travail/openMetaheuristic/source/ometah/problem/itsProblem.cpp
+1=/home/nojhan/travail/openMetaheuristic/source/ometah/interface/ometah.cpp
+
 [Project Tree]
 0=0
 1=0:0
Index: ometah/problem/itsProblem.cpp
diff -u ometah/problem/itsProblem.cpp:1.11 ometah/problem/itsProblem.cpp:1.12
--- ometah/problem/itsProblem.cpp:1.11  Mon May 16 10:03:54 2005
+++ ometah/problem/itsProblem.cpp       Wed May 25 15:33:16 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  $Id: itsProblem.cpp,v 1.11 2005/05/16 10:03:54 nojhan Exp $
+ *  $Id: itsProblem.cpp,v 1.12 2005/05/25 15:33:16 nojhan Exp $
  *  Copyright 2005 Université Paris 12 Val-de-Marne
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
@@ -20,8 +20,7 @@
 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 02111-1307 USA
 */
-
-
+#include <iostream>
 #include <string>
 #include <vector>
 #include <sstream>
@@ -45,7 +44,7 @@
   
   setDimension(1);
 
-  setBoundsMaximaAll(0);
+  setBoundsMaximaAll(1);
   setBoundsMinimaAll(0);
 
   //vector<itsPoint> optim;
@@ -97,8 +96,10 @@
   this->dimension = dimension;
 
   // reinitialization of bounds
-  vector<double> v(dimension,0);
-  setBoundsMinima( v );
+  vector<double> n(dimension,0);
+  setBoundsMinima( n );
+  vector<double> x(dimension,1);
+  setBoundsMaxima( x );
 }
 
 
@@ -142,8 +143,6 @@
 
   msg << "Reference" << sep << getCitation() << endl;
 
-//Name, Description, Dimension, Formula, Optimum, Bounds and Reference 
-
   // return only the string
   return msg.str();  
 }
Index: ometah/problem/itsRosenbrock.cpp
diff -u ometah/problem/itsRosenbrock.cpp:1.4 
ometah/problem/itsRosenbrock.cpp:1.5
--- ometah/problem/itsRosenbrock.cpp:1.4        Sat Mar 26 20:33:02 2005
+++ ometah/problem/itsRosenbrock.cpp    Wed May 25 15:33:16 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  $Id: itsRosenbrock.cpp,v 1.4 2005/03/26 20:33:02 nojhan Exp $
+ *  $Id: itsRosenbrock.cpp,v 1.5 2005/05/25 15:33:16 nojhan Exp $
  *  Copyright 2005 Université Paris 12 Val-de-Marne
  *  Author : Johann Dréo <address@hidden>
  ****************************************************************************/
@@ -22,10 +22,9 @@
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-
 #include <vector>
 #include "itsRosenbrock.hpp"
- 
+
 using namespace std;
  
 itsRosenbrock::itsRosenbrock()




reply via email to

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