[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: |
Sat, 28 May 2005 15:26:01 -0400 |
CVSROOT: /cvsroot/ometah
Module name: ometah
Branch:
Changes by: Johann <address@hidden> 05/05/28 19:26:01
Modified files:
. : ometah.pws
common : itsPoint.cpp string.hpp
interface : ometah.cpp
metaheuristic : itsEstimationOfDistribution.cpp
itsMetaheuristic.cpp itsMetaheuristic.hpp
Log message:
* new interface for print functions
* correction of the resize bug for EDA
* optimum output
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/ometah.pws.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/itsPoint.cpp.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/string.hpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/interface/ometah.cpp.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/metaheuristic/itsEstimationOfDistribution.cpp.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/metaheuristic/itsMetaheuristic.cpp.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/metaheuristic/itsMetaheuristic.hpp.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
Patches:
Index: ometah/common/itsPoint.cpp
diff -u ometah/common/itsPoint.cpp:1.5 ometah/common/itsPoint.cpp:1.6
--- ometah/common/itsPoint.cpp:1.5 Fri May 27 12:22:33 2005
+++ ometah/common/itsPoint.cpp Sat May 28 19:26:01 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: itsPoint.cpp,v 1.5 2005/05/27 12:22:33 nojhan Exp $
+ * $Id: itsPoint.cpp,v 1.6 2005/05/28 19:26:01 nojhan Exp $
* Author : Johann Dréo <address@hidden>
****************************************************************************/
@@ -118,13 +118,14 @@
ostringstream res;
if(dimension>-1) { // if we want a specific dimension
+
res << vec[0].getValues()[dimension];
for(unsigned int i=1; i<vec.size(); i++) { // points
res << separatorDimension << vec[i].getValues()[dimension];
}
} else { // if we want all dimensions
-
+
res << vec[0].getValues()[0];
for(unsigned int i=1; i<vec.size(); i++) { // points
res << separatorPoint << vec[i].getValues()[0];
Index: ometah/common/string.hpp
diff -u ometah/common/string.hpp:1.6 ometah/common/string.hpp:1.7
--- ometah/common/string.hpp:1.6 Wed May 25 15:33:15 2005
+++ ometah/common/string.hpp Sat May 28 19:26:01 2005
@@ -1,6 +1,6 @@
/***************************************************************************
- * $Id: string.hpp,v 1.6 2005/05/25 15:33:15 nojhan Exp $
+ * $Id: string.hpp,v 1.7 2005/05/28 19:26:01 nojhan Exp $
* Author : Johann Dréo <address@hidden>
****************************************************************************/
@@ -30,8 +30,8 @@
using namespace std;
//! Print a vector
-template<class T,class U>
-void print( T aVector, U aSeparator, ostream * outer )
+template<class T>
+void print( T aVector, char * aSeparator=",", ostream * outer)
{
*outer << aVector[0];
@@ -41,8 +41,8 @@
};
//! Print a vector
-template<class T,class U>
-string print( T aVector, U aSeparator )
+template<class T>
+string print( T aVector, char * aSeparator="," )
{
ostringstream out;
out << aVector[0];
@@ -51,7 +51,7 @@
out << aSeparator << aVector[i];
}
- return out;
+ return out.str();
};
Index: ometah/interface/ometah.cpp
diff -u ometah/interface/ometah.cpp:1.16 ometah/interface/ometah.cpp:1.17
--- ometah/interface/ometah.cpp:1.16 Fri May 27 12:22:33 2005
+++ ometah/interface/ometah.cpp Sat May 28 19:26:01 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: ometah.cpp,v 1.16 2005/05/27 12:22:33 nojhan Exp $
+ * $Id: ometah.cpp,v 1.17 2005/05/28 19:26:01 nojhan Exp $
* Copyright : Université Paris 12 Val-de-Marne
* Author : Johann Dréo <address@hidden>
****************************************************************************/
@@ -148,9 +148,18 @@
cout << "PROBLEM" << endl << setProblem.item()->getInformations();
cout << endl;*/
- setMetaheuristic.item()->addDebugKey("selectNumber");
+ //setMetaheuristic.item()->addDebugKey("selectNumber");
setMetaheuristic.item()->setLogLevel(99);
- setMetaheuristic.item()->setSampleSize(5);
+
+ setProblem.item()->setDimension(3);
+
+ setMetaheuristic.item()->setSampleSize(10);
+ setMetaheuristic.item()->setIterationsMaxNumber(30);
+
+ // Starting the optimization
+ clog << "Launching " << setMetaheuristic.item()->getName()
+ << " on " << setProblem.item()->getName()
+ << " using " << setCommunicationClient.item()->getKey() << endl;
try {
setMetaheuristic.item()->start();
@@ -158,6 +167,9 @@
catch(const char * str) {
cerr << str << endl;
}
+ catch(string str) {
+ cerr << str << endl;
+ }
catch (...) {
cerr << "Unknown error" << endl;
}
Index: ometah/metaheuristic/itsEstimationOfDistribution.cpp
diff -u ometah/metaheuristic/itsEstimationOfDistribution.cpp:1.15
ometah/metaheuristic/itsEstimationOfDistribution.cpp:1.16
--- ometah/metaheuristic/itsEstimationOfDistribution.cpp:1.15 Fri May 27
12:22:34 2005
+++ ometah/metaheuristic/itsEstimationOfDistribution.cpp Sat May 28
19:26:01 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: itsEstimationOfDistribution.cpp,v 1.15 2005/05/27 12:22:34 nojhan Exp
$
+ * $Id: itsEstimationOfDistribution.cpp,v 1.16 2005/05/28 19:26:01 nojhan Exp
$
* Author : Johann Dréo <address@hidden>
****************************************************************************/
@@ -25,6 +25,7 @@
#include <vector>
#include <algorithm>
#include <cmath>
+#include <sstream>
#include "itsEstimationOfDistribution.hpp"
#include "../common/matrix.hpp"
@@ -80,12 +81,20 @@
// transpose it so that the row correspond to a dimension, and not a
solution
transposedSimplifiedSample = transpose(transposedSimplifiedSample);
- // verify that we have the correct dimension
+// verify that we have the correct dimension
if( transposedSimplifiedSample.size() != (unsigned
int)this->problem->getDimension() ) {
- throw "ErrorSize: transposed matrix does not correspond to problem
dimension";
+ ostringstream err;
+ err << "ErrorSize: transposed matrix size ("
+ << transposedSimplifiedSample.size()
+ << ") does not correspond to problem dimension ("
+ << this->problem->getDimension()
+ << ")";
+ throw err.str();
}
// find the minimum and the maximum for each dimension
+ this->parameterUniformMinima.clear();
+ this->parameterUniformMaxima.clear();
for(int dim=0; dim < this->problem->getDimension(); dim++) {
// store them
this->parameterUniformMinima.push_back( min(
transposedSimplifiedSample[dim] ) );
@@ -104,7 +113,7 @@
itsPoint p;
p.setSolution( randomUniform(this->parameterUniformMinima,
this->parameterUniformMaxima) );
// get values
- sample[i] = this->problem->call(p);
+ sample[i] = evaluate(p);
}
}
Index: ometah/metaheuristic/itsMetaheuristic.cpp
diff -u ometah/metaheuristic/itsMetaheuristic.cpp:1.16
ometah/metaheuristic/itsMetaheuristic.cpp:1.17
--- ometah/metaheuristic/itsMetaheuristic.cpp:1.16 Fri May 27 16:06:39 2005
+++ ometah/metaheuristic/itsMetaheuristic.cpp Sat May 28 19:26:01 2005
@@ -1,5 +1,5 @@
/****************************************************************************
- * $Id: itsMetaheuristic.cpp,v 1.16 2005/05/27 16:06:39 nojhan Exp $
+ * $Id: itsMetaheuristic.cpp,v 1.17 2005/05/28 19:26:01 nojhan Exp $
* Copyright 2005 Walid TFAILI
* Authors : Walid Tfaili <address@hidden>, Johann Dréo <address@hidden>
****************************************************************************/
@@ -28,6 +28,7 @@
#include <cstdlib>
#include "itsMetaheuristic.hpp"
#include "../common/random.hpp"
+#include "../common/string.hpp"
#include "../common/itsPoint.hpp"
#include "../problem/itsProblem.hpp"
#include "../communication/itsCommunicationClient.hpp"
@@ -77,6 +78,9 @@
this->iterationsCurrent=0;
this->logLevel = 0;
+
+ this->logKeys["optimum_value"] = 0;
+ this->logKeys["optimum"] = 1;
this->logKeys["steps"] = 1;
this->logKeys["communications"] = 2;
this->logKeys["instanciations"] = 2;
@@ -97,7 +101,7 @@
// draw a vector in the bounds
aRandomPoint.setSolution( randomUniform(min,max) );
// ask for the associated values
- aRandomPoint = problem->call(aRandomPoint);
+ aRandomPoint = evaluate(aRandomPoint);
// add it to the sample
//sample.push_back(aRandomPoint);
sample[i] = aRandomPoint;
@@ -112,13 +116,11 @@
// no iterations has been computed
iterationsCurrent=0;
-
// log
-
ostringstream msg1;
msg1 << "iteration " << iterationsCurrent;
printLog("iterations", msg1.str() );
- printLog("sample_steps", " sample "+printValues( this->sample ) );
+ printLog("sample_steps", " sample_values "+printValues( this->sample ) );
// while no stopping criterion reached
while( !isStoppingCriteria() ) {
@@ -137,22 +139,26 @@
diversification(); // Diversification phase
// log sample
- printLog("sample_steps", " sample "+printValues( this->sample ) );
+ printLog("sample_steps", " sample_values "+printValues( this->sample ) );
printLog("steps"," intensification");
intensification(); // Intensification phase
- printLog("sample_steps", " sample "+printValues( this->sample ) );
+ printLog("sample_steps", " sample_values "+printValues( this->sample ) );
// one more iteration
iterationsCurrent++;
}
+
+ printLog("steps","end");
+ printLog("optimum", "optimum "+print( getOptimum().getValues() ) ); // FIXME
: print the solution too
+ printLog("optimum_value", print( getOptimum().getValues() ) );
}
-void itsMetaheuristic::parse()
+void itsMetaheuristic::parameterParse()
{ }
-void itsMetaheuristic::parseCommon()
+void itsMetaheuristic::parameterParseCommon()
{ }
bool itsMetaheuristic::isStoppingCriteria()
@@ -282,15 +288,6 @@
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)
{
@@ -314,3 +311,22 @@
{
this->logLevel = level;
}
+
+itsPoint itsMetaheuristic::evaluate(itsPoint p)
+{
+ itsPoint res = this->problem->call(p);
+ printDebug("evaluations",res.getValues().size());
+ return res;
+}
+
+itsPoint itsMetaheuristic::getOptimum()
+{
+ // FIXME : check if it is faster to use the sorting function
+ itsPoint optimum = sample[0];
+ for(unsigned int i=1; i<getSampleSizeCurrent(); i++) {
+ if( isValueSmaller(sample[i],optimum) ) {
+ optimum = sample[i];
+ }
+ }
+ return optimum;
+}
Index: ometah/metaheuristic/itsMetaheuristic.hpp
diff -u ometah/metaheuristic/itsMetaheuristic.hpp:1.16
ometah/metaheuristic/itsMetaheuristic.hpp:1.17
--- ometah/metaheuristic/itsMetaheuristic.hpp:1.16 Fri May 27 16:06:39 2005
+++ ometah/metaheuristic/itsMetaheuristic.hpp Sat May 28 19:26:01 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: itsMetaheuristic.hpp,v 1.16 2005/05/27 16:06:39 nojhan Exp $
+ * $Id: itsMetaheuristic.hpp,v 1.17 2005/05/28 19:26:01 nojhan Exp $
* Copyright : 2005 Université Paris 12 Val-de-Marne
* Author : Walid Tfaili <address@hidden>, Johann Dréo <address@hidden>
****************************************************************************/
@@ -180,11 +180,17 @@
//! start executing a Metaheuristic
void start();
+ //! Take a point and evaluate its values
+ itsPoint evaluate(itsPoint p);
+
+ //! Find the optimum
+ itsPoint getOptimum();
+
//! Parse data from an interface
void parameterParse();
//! Parse data common to all metaheuristics
- void parseCommon();
+ void parameterParseCommon();
//! Simple attribute accesses
Index: ometah/ometah.pws
diff -u ometah/ometah.pws:1.15 ometah/ometah.pws:1.16
--- ometah/ometah.pws:1.15 Fri May 27 12:22:33 2005
+++ ometah/ometah.pws Sat May 28 19:26:01 2005
@@ -1,10 +1,10 @@
[filenumbers]
-0=111
-1=147
-2=240
-3=133
-4=81
+0=80
+1=319
+2=184
+3=122
+4=157
5=153
6=1
7=56
@@ -30,14 +30,6 @@
[Project State]
clean before build=false
-[filelist]
-0=/home/nojhan/travail/openMetaheuristic/source/ometah/metaheuristic/itsEstimationOfDistribution.cpp
-1=/home/nojhan/travail/openMetaheuristic/source/ometah/metaheuristic/itsMetaheuristic.cpp
-2=/home/nojhan/travail/openMetaheuristic/source/ometah/metaheuristic/itsMetaheuristic.hpp
-3=/home/nojhan/travail/openMetaheuristic/source/ometah/common/itsPoint.cpp
-4=/home/nojhan/travail/openMetaheuristic/source/ometah/common/itsPoint.hpp
-5=/home/nojhan/travail/openMetaheuristic/source/ometah/interface/ometah.cpp
-
[Project Tree]
0=0
1=0:0