ometah-devel
[Top][All Lists]
Advanced

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

[oMetah-devel] ometah ./ometah.pws interface/itsArgument.cpp i...


From: NoJhan
Subject: [oMetah-devel] ometah ./ometah.pws interface/itsArgument.cpp i...
Date: Thu, 02 Jun 2005 17:59:40 -0400

CVSROOT:        /cvsroot/ometah
Module name:    ometah
Branch:         
Changes by:     NoJhan <address@hidden> 05/06/02 21:59:40

Modified files:
        .              : ometah.pws 
        interface      : itsArgument.cpp itsArgument.hpp ometah.cpp 

Log message:
        * more consistent names
        * more parameters
        * some doc-comments

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/ometah.pws.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/interface/itsArgument.cpp.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/interface/itsArgument.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.25&tr2=1.26&r1=text&r2=text

Patches:
Index: ometah/interface/itsArgument.cpp
diff -u ometah/interface/itsArgument.cpp:1.7 
ometah/interface/itsArgument.cpp:1.8
--- ometah/interface/itsArgument.cpp:1.7        Thu Jun  2 19:19:12 2005
+++ ometah/interface/itsArgument.cpp    Thu Jun  2 21:59:39 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  $Id: itsArgument.cpp,v 1.7 2005/06/02 19:19:12 jpa Exp $
+ *  $Id: itsArgument.cpp,v 1.8 2005/06/02 21:59:39 nojhan Exp $
  *  Copyright : Université Paris 12 Val-de-Marne
  *  Author : Johann Dréo <address@hidden>
  *  Author : Jean-Philippe Aumasson <address@hidden>
@@ -73,19 +73,19 @@
 // ITSPARSER 
 
 // destructor
-itsParser::~itsParser()
+itsArgumentParser::~itsArgumentParser()
 {
 
 }
 
 // constructor, with argv as the command line values
-itsParser::itsParser(int argc, vector<string> argv)
+itsArgumentParser::itsArgumentParser(int argc, vector<string> argv)
 {
   this->argv = argv;
   this->argc = argc;
 }
 
-void itsParser::searchEndFlags() {
+void itsArgumentParser::searchEndFlags() {
   // termination flags : if there, don't execute program
   // following order <=> flags' priorities
 
@@ -99,7 +99,7 @@
 
 
 // parse argv searching the given flag, then update the vector with a new 
argument
-bool itsParser::defArg(string flagShort, string flagLong, string usage, 
+bool itsArgumentParser::defArg(string flagShort, string flagLong, string 
usage, 
                       bool hasValue, string type, string valueDefault)
 {
   unsigned i = 1;
@@ -140,7 +140,7 @@
 }
 
 
-string itsParser::getStringValue(string key){
+string itsArgumentParser::getStringValue(string key){
 
   vector<itsArgument>::iterator iter;
   iter = arguments.begin();
@@ -152,7 +152,7 @@
   return "";
 }
 
-double itsParser::getDoubleValue(string key){
+double itsArgumentParser::getDoubleValue(string key){
   
   vector<itsArgument>::iterator iter;
   iter = arguments.begin();
@@ -165,7 +165,7 @@
   return -1.;
 }
 
-int itsParser::getIntValue(string key){
+int itsArgumentParser::getIntValue(string key){
 
   int i = -1;
   vector<itsArgument>::iterator iter;
@@ -181,7 +181,7 @@
   return i;
 }
 
-bool itsParser::getBoolValue(string key){
+bool itsArgumentParser::getBoolValue(string key){
 
   vector<itsArgument>::iterator iter;
   iter = arguments.begin();
Index: ometah/interface/itsArgument.hpp
diff -u ometah/interface/itsArgument.hpp:1.6 
ometah/interface/itsArgument.hpp:1.7
--- ometah/interface/itsArgument.hpp:1.6        Thu Jun  2 19:19:12 2005
+++ ometah/interface/itsArgument.hpp    Thu Jun  2 21:59:39 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  $Id: itsArgument.hpp,v 1.6 2005/06/02 19:19:12 jpa Exp $
+ *  $Id: itsArgument.hpp,v 1.7 2005/06/02 21:59:39 nojhan Exp $
  *  Copyright : Université Paris 12 Val-de-Marne
  *  Author : Johann Dréo <address@hidden>
  *  Author : Jean-Philippe Aumasson <address@hidden>
@@ -40,19 +40,19 @@
 class itsArgument
 {
 protected:
-  // short cmd line flag (ie -v for version)
+  //! short cmd line flag (ie -v for version)
   string flagShort;
   
-  // short cmd line flag (ie --version for version)
+  //! Short cmd line flag (ie --version for version)
   string flagLong;
 
-  // true if a value must be associated to the argument
+  //! True if a value must be associated to the argument
   bool hasValue;
   
-  // usage instructions
+  //! Usage instructions
   string usage;
 
-  // type of the associated value, if there
+  //! Type of the associated value, if there
   string type;
 
   // default value
@@ -61,10 +61,10 @@
 
 public:
 
-  // destructor
+  //! Destructor
   ~itsArgument();
 
-  // constructor
+  //! Constructor
   itsArgument(string flaShort, string flagLong, string usage, 
                bool hasValue=false, string type="", string valueDefault="");  
 
@@ -77,7 +77,7 @@
 };
 
 
-class itsParser
+class itsArgumentParser
 {
 protected:
 
@@ -90,11 +90,11 @@
 
 public:
   
-  // destructor
-  ~itsParser();
+  //! Destructor
+  ~itsArgumentParser();
 
-  // constructor
-  itsParser(int, vector<string>);
+  //! Constructor
+  itsArgumentParser(int, vector<string>);
   
   bool defArg(string flagShort, string flagLong, string usage, 
                bool hasValue=false, string type="", string valueDefault="");
Index: ometah/interface/ometah.cpp
diff -u ometah/interface/ometah.cpp:1.25 ometah/interface/ometah.cpp:1.26
--- ometah/interface/ometah.cpp:1.25    Thu Jun  2 19:19:12 2005
+++ ometah/interface/ometah.cpp Thu Jun  2 21:59:39 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  $Id: ometah.cpp,v 1.25 2005/06/02 19:19:12 jpa Exp $
+ *  $Id: ometah.cpp,v 1.26 2005/06/02 21:59:39 nojhan Exp $
  *  Copyright : Université Paris 12 Val-de-Marne
  *  Author : Johann Dréo <address@hidden>
  *  Author : Jean-Philippe Aumasson <address@hidden>
@@ -37,53 +37,6 @@
 int main(int argc, char ** argv)
 {
   
-  // fill the argv vector
-  vector<string> argumentsVector;
-  for(int i=0; i<argc; i++){
-    argumentsVector.push_back(argv[i]);
-  }
-
-  // create a parser
-  itsParser theParser(argc, argumentsVector);
-
-
-  // arguments definitions
-  theParser.defArg("-p", "--problem",
-                  "the name of the problem", true, "string", "Rosenbrock");
-  theParser.defArg("-m", "--metah",
-                  "metaheuristic name", true, "string", "CEDA");
-  theParser.defArg("-cC", "--com-client", 
-                  "communication client mode" ,true, "string", "Embedded");
-  theParser.defArg("-cS", "--com-client", 
-                  "communication server mode" ,true, "string", "Embedded");
-  theParser.defArg("-d", "--debug", 
-                  "debug key" ,true, "string", "");
-
-
-
-
-  // look for end flags (-v, -h, etc...)
-  try{
-    theParser.searchEndFlags();
-  }
-  catch (const char * s){
-    if (!strcmp(s, VERSION)){
-      cerr << s << endl;
-      return -1;
-    }
-    else if (!strcmp(s, USAGE)){
-      usage();
-      return -1;
-    }
-  }
-
-  
-  
-#ifdef DEBUG
-  cout << "\ngetValues :" << "\n problem: " << theParser.getStringValue("-p") 
-       << "\nmetah: "<< theParser.getStringValue("-m") << endl; 
-#endif
-
   // differents sets of objects
   itsSet<itsMetaheuristic*> setMetaheuristic;
   itsSet<itsProblem*> setProblem;
@@ -130,14 +83,72 @@
   factoryServer = new itsCommunicationServerFactory_embedded;
   setCommunicationServer.add( factoryServer->create() );
 
+  /*
+   * Arguments
+   */
+
+  // fill the argv vector
+  vector<string> argumentsVector;
+  for(int i=0; i<argc; i++){
+    argumentsVector.push_back(argv[i]);
+  }
+
+  // create a parser
+  itsArgumentParser argumentParser(argc, argumentsVector);
+
+
+  // arguments definitions
+  argumentParser.defArg("-p", "--problem",
+                  "the name of the problem", true, "string", "Rosenbrock");
+  argumentParser.defArg("-m", "--metah",
+                  "metaheuristic name", true, "string", "CEDA");
+  argumentParser.defArg("-c", "--com-client", 
+                  "communication client mode" ,true, "string", "Embedded");
+  argumentParser.defArg("-s", "--com-server", 
+                  "communication server mode" ,true, "string", "Embedded");
+  argumentParser.defArg("-d", "--debug", 
+                  "debug key" ,true, "string", "");
+
+  argumentParser.defArg("-i", "--iterations", 
+                  "maximum number of iterations" ,true, "int", "10");
+  argumentParser.defArg("-a", "--sample-size", 
+                  "number of points in the sample" ,true, "int", "10");
+  argumentParser.defArg("-m", "--dimension", 
+                  "dimension of the problem" ,true, "int", "1");
+
+
+
+  // look for end flags (-v, -h, etc...)
+  try{
+    argumentParser.searchEndFlags();
+  }
+  catch (const char * s){
+    if (s==VERSION){
+      cerr << s << endl;
+      return -1;
+    }
+    else if (s==USAGE){
+      usage();
+      return -1;
+    }
+  }
+
+  
+  
+#ifdef DEBUG
+  cout << "\ngetValues :" << "\n problem: " << 
argumentParser.getStringValue("-p") 
+       << "\nmetah: "<< argumentParser.getStringValue("-m") << endl; 
+#endif
+
+
   /* 
    *  Choose the items
    */
     
-  setMetaheuristic.choose(theParser.getStringValue("-m"));
-  setProblem.choose(theParser.getStringValue("-p"));
-  setCommunicationClient.choose(theParser.getStringValue("-cC"));
-  setCommunicationServer.choose(theParser.getStringValue("-cS"));
+  setMetaheuristic.choose(argumentParser.getStringValue("-m"));
+  setProblem.choose(argumentParser.getStringValue("-p"));
+  setCommunicationClient.choose(argumentParser.getStringValue("-c"));
+  setCommunicationServer.choose(argumentParser.getStringValue("-s"));
     
     
   /*
@@ -151,17 +162,17 @@
   // server -> problem
   setCommunicationServer.item()->problem = setProblem.item();
     
+  // Special case for the embedded protocol : we must link client and server
+  if( setCommunicationClient.item()->getKey() == 
argumentParser.getStringValue("-c") && 
+      setCommunicationServer.item()->getKey() ==  
argumentParser.getStringValue("-s")) {
+    setCommunicationClient.item()->problem = setCommunicationServer.item();
+  }
+
     
   /*
    *  Parameter setting
    */
     
-  // Special case for the embedded protocol : we must link client and server
-  if( setCommunicationClient.item()->getKey() == 
theParser.getStringValue("-cC") && 
-      setCommunicationServer.item()->getKey() ==  
theParser.getStringValue("-cS")) {
-    setCommunicationClient.item()->problem = setCommunicationServer.item();
-  }
-
   // giving parameters
   hash_map<string,string, eqstr> parameters;
   setCommunicationClient.item()->initialization( parameters );
@@ -181,9 +192,9 @@
   //setMetaheuristic.item()->setLogLevel(0);
 
   // parameters
-  setProblem.item()->setDimension(2);
-  setMetaheuristic.item()->setSampleSize(100);
-  setMetaheuristic.item()->setIterationsMaxNumber(100);
+  setProblem.item()->setDimension( argumentParser.getIntValue("-m") );
+  setMetaheuristic.item()->setSampleSize( argumentParser.getIntValue("-a") );
+  setMetaheuristic.item()->setIterationsMaxNumber( 
argumentParser.getIntValue("-i") );
 
 
   // Starting the optimization
Index: ometah/ometah.pws
diff -u ometah/ometah.pws:1.17 ometah/ometah.pws:1.18
--- ometah/ometah.pws:1.17      Tue May 31 13:42:55 2005
+++ ometah/ometah.pws   Thu Jun  2 21:59:39 2005
@@ -1,10 +1,10 @@
 
 [filenumbers]
-0=1
-1=158
-2=136
-3=1
-4=157
+0=88
+1=96
+2=197
+3=50
+4=36
 5=153
 6=1
 7=56
@@ -30,6 +30,12 @@
 [Project State]
 clean before build=false
 
+[filelist]
+0=/home/nojhan/travail/openMetaheuristic/source/ometah/interface/itsArgument.cpp
+1=/home/nojhan/travail/openMetaheuristic/source/ometah/interface/itsArgument.hpp
+2=/home/nojhan/travail/openMetaheuristic/source/ometah/interface/ometah.cpp
+3=/home/nojhan/travail/openMetaheuristic/source/ometah/interface/ometah.hpp
+
 [Project Tree]
 0=0
 1=0:0
@@ -40,3 +46,4 @@
 
 [File Tree]
 0=0
+1=0:6




reply via email to

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