[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[oMetah-devel] ometah ./ometah.pws common/itsPoint.cpp common/...
From: |
Johann |
Subject: |
[oMetah-devel] ometah ./ometah.pws common/itsPoint.cpp common/... |
Date: |
Tue, 31 May 2005 09:42:56 -0400 |
CVSROOT: /cvsroot/ometah
Module name: ometah
Branch:
Changes by: Johann <address@hidden> 05/05/31 13:42:56
Modified files:
. : ometah.pws
common : itsPoint.cpp itsPoint.hpp
interface : ometah.cpp
metaheuristic : itsMetaheuristic.cpp itsMetaheuristic.hpp
Log message:
* more stuff about log & debug
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/ometah.pws.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/itsPoint.cpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/itsPoint.hpp.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/interface/ometah.cpp.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/metaheuristic/itsMetaheuristic.cpp.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/metaheuristic/itsMetaheuristic.hpp.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
Patches:
Index: ometah/common/itsPoint.cpp
diff -u ometah/common/itsPoint.cpp:1.6 ometah/common/itsPoint.cpp:1.7
--- ometah/common/itsPoint.cpp:1.6 Sat May 28 19:26:01 2005
+++ ometah/common/itsPoint.cpp Tue May 31 13:42:56 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: itsPoint.cpp,v 1.6 2005/05/28 19:26:01 nojhan Exp $
+ * $Id: itsPoint.cpp,v 1.7 2005/05/31 13:42:56 nojhan Exp $
* Author : Johann Dréo <address@hidden>
****************************************************************************/
@@ -136,3 +136,43 @@
}
return res.str();
}
+
+
+string printSolutions( vector<itsPoint> vec, int dimension, const char*
separatorDimension, const char* separatorPoint )
+{
+ if( vec.size() <= 0 ) {
+ throw "ErrorSize: cannot print an empty vector";
+
+ } else {
+ if ( vec[0].getSolution().size()<=0 || dimension > (signed
int)vec[0].getSolution().size() ) {
+ throw "ErrorSize: cannot print a vector of empty points";
+ }
+ }
+
+ ostringstream res;
+
+ if(dimension>-1) { // if we want a specific dimension
+
+ res << vec[0].getSolution()[dimension];
+ for(unsigned int i=1; i<vec.size(); i++) { // points
+ res << separatorDimension << vec[i].getSolution()[dimension];
+ }
+
+ } else { // if we want all dimensions
+
+ // first point
+ res << vec[0].getSolution()[0];
+ for(unsigned int j=1; j<vec[0].getSolution().size(); j++) { //
dimensions
+ res << separatorDimension << vec[0].getSolution()[j];
+ }
+
+ // other points
+ for(unsigned int i=1; i<vec.size(); i++) { // points
+ res << separatorPoint << vec[i].getSolution()[0];
+ for(unsigned int j=1; j<vec[i].getSolution().size(); j++) { //
dimensions
+ res << separatorDimension << vec[i].getSolution()[j];
+ }
+ }
+ }
+ return res.str();
+}
Index: ometah/common/itsPoint.hpp
diff -u ometah/common/itsPoint.hpp:1.7 ometah/common/itsPoint.hpp:1.8
--- ometah/common/itsPoint.hpp:1.7 Thu May 26 17:15:06 2005
+++ ometah/common/itsPoint.hpp Tue May 31 13:42:56 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: itsPoint.hpp,v 1.7 2005/05/26 17:15:06 nojhan Exp $
+ * $Id: itsPoint.hpp,v 1.8 2005/05/31 13:42:56 nojhan Exp $
* Author : Walid TFAILI <address@hidden>
****************************************************************************/
@@ -80,4 +80,15 @@
*/
string printValues( vector<itsPoint> vec, int dimension=-1, const char*
separatorDimension=",", const char* separatorPoint=" " );
+//! Print the solution of a point
+/*!
+ If a dimension is given, it print only solutions for this dimension.
+ Else, it print all values.
+ By default :
+|11 12 13|
+|21 22 23| => 11,12,13 21,22,23 31,32,33
+|31 32 33|
+*/
+string printSolutions( vector<itsPoint> vec, int dimension=-1, const char*
separatorDimension=",", const char* separatorPoint=" " );
+
#endif
Index: ometah/interface/ometah.cpp
diff -u ometah/interface/ometah.cpp:1.17 ometah/interface/ometah.cpp:1.18
--- ometah/interface/ometah.cpp:1.17 Sat May 28 19:26:01 2005
+++ ometah/interface/ometah.cpp Tue May 31 13:42:56 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: ometah.cpp,v 1.17 2005/05/28 19:26:01 nojhan Exp $
+ * $Id: ometah.cpp,v 1.18 2005/05/31 13:42:56 nojhan Exp $
* Copyright : Université Paris 12 Val-de-Marne
* Author : Johann Dréo <address@hidden>
****************************************************************************/
@@ -144,22 +144,29 @@
// TESTS
- /*cout << "METAHEURISTIC" << endl <<
setMetaheuristic.item()->getInformations();
- cout << "PROBLEM" << endl << setProblem.item()->getInformations();
- cout << endl;*/
-
+
+ // Debug keys
+ setMetaheuristic.item()->addDebugKey("sample_solutions");
//setMetaheuristic.item()->addDebugKey("selectNumber");
- setMetaheuristic.item()->setLogLevel(99);
- setProblem.item()->setDimension(3);
-
- setMetaheuristic.item()->setSampleSize(10);
- setMetaheuristic.item()->setIterationsMaxNumber(30);
+ // Log
+ setMetaheuristic.item()->setLogLevel(0);
+
+ // parameters
+ setProblem.item()->setDimension(2);
+ setMetaheuristic.item()->setSampleSize(100);
+ setMetaheuristic.item()->setIterationsMaxNumber(100);
+
// Starting the optimization
+ /*
clog << "Launching " << setMetaheuristic.item()->getName()
<< " on " << setProblem.item()->getName()
<< " using " << setCommunicationClient.item()->getKey() << endl;
+ */
+
+ //clog << setProblem.item()->getName() << " description:" << endl;
+ //clog << setProblem.item()->getInformations() << endl;
try {
setMetaheuristic.item()->start();
Index: ometah/metaheuristic/itsMetaheuristic.cpp
diff -u ometah/metaheuristic/itsMetaheuristic.cpp:1.17
ometah/metaheuristic/itsMetaheuristic.cpp:1.18
--- ometah/metaheuristic/itsMetaheuristic.cpp:1.17 Sat May 28 19:26:01 2005
+++ ometah/metaheuristic/itsMetaheuristic.cpp Tue May 31 13:42:56 2005
@@ -1,5 +1,5 @@
/****************************************************************************
- * $Id: itsMetaheuristic.cpp,v 1.17 2005/05/28 19:26:01 nojhan Exp $
+ * $Id: itsMetaheuristic.cpp,v 1.18 2005/05/31 13:42:56 nojhan Exp $
* Copyright 2005 Walid TFAILI
* Authors : Walid Tfaili <address@hidden>, Johann Dréo <address@hidden>
****************************************************************************/
@@ -85,7 +85,7 @@
this->logKeys["communications"] = 2;
this->logKeys["instanciations"] = 2;
this->logKeys["iterations"] = 2;
- this->logKeys["sample_step"] = 3;
+ this->logKeys["sample_steps"] = 3;
}
@@ -144,8 +144,13 @@
printLog("steps"," intensification");
intensification(); // Intensification phase
+ // print in one line with a prefix
printLog("sample_steps", " sample_values "+printValues( this->sample ) );
-
+ printLog("sample_steps", " sample_solutions "+printSolutions(
this->sample ) );
+ // print in paragraphs without prefix
+ printDebug("sample_values", printValues( this->sample, -1, " ", "\n"
)+"\n\n", false );
+ printDebug("sample_solutions", printSolutions( this->sample, -1, " ", "\n"
)+"\n\n", false );
+
// one more iteration
iterationsCurrent++;
@@ -153,7 +158,10 @@
printLog("steps","end");
printLog("optimum", "optimum "+print( getOptimum().getValues() ) ); // FIXME
: print the solution too
- printLog("optimum_value", print( getOptimum().getValues() ) );
+
+ // print the result
+ *outEndResult << print( getOptimum().getValues() ) << " "; // values
+ *outEndResult << print( getOptimum().getSolution() ) << endl; // solution
}
void itsMetaheuristic::parameterParse()
@@ -298,7 +306,7 @@
void itsMetaheuristic::addDebugKey(string key)
{
- this->debugKeys.insert( key.c_str() );
+ this->debugKeys.insert( key );
}
int itsMetaheuristic::getLogLevel()
Index: ometah/metaheuristic/itsMetaheuristic.hpp
diff -u ometah/metaheuristic/itsMetaheuristic.hpp:1.17
ometah/metaheuristic/itsMetaheuristic.hpp:1.18
--- ometah/metaheuristic/itsMetaheuristic.hpp:1.17 Sat May 28 19:26:01 2005
+++ ometah/metaheuristic/itsMetaheuristic.hpp Tue May 31 13:42:56 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: itsMetaheuristic.hpp,v 1.17 2005/05/28 19:26:01 nojhan Exp $
+ * $Id: itsMetaheuristic.hpp,v 1.18 2005/05/31 13:42:56 nojhan Exp $
* Copyright : 2005 Université Paris 12 Val-de-Marne
* Author : Walid Tfaili <address@hidden>, Johann Dréo <address@hidden>
****************************************************************************/
@@ -151,7 +151,7 @@
/*!
This is a simple associative container, it contains only keys.
*/
- set<const char *> debugKeys;
+ set<string> debugKeys;
//! The log levels
/*!
@@ -264,10 +264,14 @@
Print the debug variable if its name is in debugKeys.
*/
template<class T>
- void printDebug(string id, T var) {
+ void printDebug(string id, T var, bool header=true) {
// if the string id is in keys, then print var on debug output
- if( debugKeys.count( id.c_str() ) > 0 ) {
- *outDebug << id << " " << var << endl;
+ if( this->debugKeys.count( id.c_str() ) > 0 ) {
+ if(header) {
+ *outDebug << id << " " << var << endl;
+ } else {
+ *outDebug << var << endl;
+ }
}
}
Index: ometah/ometah.pws
diff -u ometah/ometah.pws:1.16 ometah/ometah.pws:1.17
--- ometah/ometah.pws:1.16 Sat May 28 19:26:01 2005
+++ ometah/ometah.pws Tue May 31 13:42:55 2005
@@ -1,9 +1,9 @@
[filenumbers]
-0=80
-1=319
-2=184
-3=122
+0=1
+1=158
+2=136
+3=1
4=157
5=153
6=1