[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[oMetah-devel] ometah/interface ometah.cpp ometah.hpp itsArgum...
From: |
Jean-Philippe Aumasson |
Subject: |
[oMetah-devel] ometah/interface ometah.cpp ometah.hpp itsArgum... |
Date: |
Wed, 01 Jun 2005 11:50:58 -0400 |
CVSROOT: /cvsroot/ometah
Module name: ometah
Branch:
Changes by: Jean-Philippe Aumasson <address@hidden> 05/06/01 15:50:57
Modified files:
interface : ometah.cpp ometah.hpp
Added files:
interface : itsArgument.cpp itsArgument.hpp
Log message:
* new command line handling, using classes itsArgument and parser,
WIP...
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/interface/itsArgument.cpp?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/interface/itsArgument.hpp?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/interface/ometah.cpp.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/interface/ometah.hpp.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: ometah/interface/ometah.cpp
diff -u ometah/interface/ometah.cpp:1.19 ometah/interface/ometah.cpp:1.20
--- ometah/interface/ometah.cpp:1.19 Wed Jun 1 13:49:02 2005
+++ ometah/interface/ometah.cpp Wed Jun 1 15:50:57 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: ometah.cpp,v 1.19 2005/06/01 13:49:02 jpa Exp $
+ * $Id: ometah.cpp,v 1.20 2005/06/01 15:50:57 jpa Exp $
* Copyright : Université Paris 12 Val-de-Marne
* Author : Johann Dréo <address@hidden>
* Author : Jean-Philippe Aumasson <address@hidden>
@@ -35,37 +35,16 @@
cerr << "\twhere metaheuristic can be :\n";
cerr << "\t\tCEDA\t\tCEDA metaheuristic\n";
cerr << "\twhere problem can be :\n";
- cerr << "\t\tROSE\t\tRosenbrock problem\n";
+ cerr << "\t\tRosenbrock\t\tRosenbrock problem\n";
cerr << "Options:\n";
- cerr << "\t-cC\tmode\t\tCommunication client mode (default: embedded)\n";
- cerr << "\t-cS\tmode\t\tCommunication server mode (default: embedded)\n";
- cerr << "\t-D\tmode\t\tDebug key (default: none)\n";
+ cerr << "\t-cC\tmode\t\tCommunication client mode (default: Embedded)\n";
+ cerr << "\t-cS\tmode\t\tCommunication server mode (default: Embedded)\n";
+ cerr << "\t-D\tmode\t\tDebug key (sample_solutions...default: none)\n";
cerr << "\t-o\tfile\t\tOutput to the given file (default: stdout)\n";
exit(-1);
}
-void fatal(char * msg){
- /* when an error in cmd line entries occurs, ie problem unknown... */
- cout << "Fatal error: " << msg << "\n";
- exit(-1);
-}
-
-
-/*
- Parameters in cmd line :
- -----------------------
- required :
- problem (key)
- metaheuristic (key)
-
- not required :
- debugkey (default = none)
- ComClient (default = Embedded)
- ComServer (default = Embedded)
- output (default = stdout )
-*/
-
int get_args(int argc, char ** argv, cmdargs_t *cmd){
/* from the cmd line arguments, return a vector of string parameters */
int i = 1;
@@ -108,28 +87,17 @@
return 1;
}
-void display_cmd(cmdargs_t * cmd){
-
- cout << "\nproblem: " << cmd->problem_key;
- cout << "\nmetaheur: " << cmd->metaheur_key;
- cout << "\nclient: " << cmd->cc_mode;
- cout << "\nserver: " << cmd->cs_mode;
- cout << "\ndebug: " << cmd->debug_key;
- cout << "\noutput: " << cmd->output;
- cout << "\n";
-}
-
int main(int argc, char ** argv)
{
- cmdargs_t cmd;
-
- // check cmd line correctness and alter cmd_args
- if (!get_args(argc, argv, &cmd))
- usage(argv[0]);
+
+ cmdargs_t cmd;
- display_cmd(&cmd);
+ // check cmd line correctness and alter cmd_args
+ if (!get_args(argc, argv, &cmd))
+ usage(argv[0]);
+
// differents sets of objects
itsSet<itsMetaheuristic*> setMetaheuristic;
@@ -182,10 +150,10 @@
* Choose the items
*/
- setMetaheuristic.choose("CEDA");
- setProblem.choose("Rosenbrock");
- setCommunicationClient.choose("Embedded");
- setCommunicationServer.choose("Embedded");
+ setMetaheuristic.choose(cmd.metaheur_key);
+ setProblem.choose(cmd.problem_key);
+ setCommunicationClient.choose(cmd.cc_mode);
+ setCommunicationServer.choose(cmd.cs_mode);
/*
@@ -205,8 +173,8 @@
*/
// Special case for the embedded protocol : we must link client and server
- if( setCommunicationClient.item()->getKey() == "Embedded" &&
- setCommunicationServer.item()->getKey() == "Embedded" ) {
+ if( setCommunicationClient.item()->getKey() == cmd.cc_mode &&
+ setCommunicationServer.item()->getKey() == cmd.cs_mode ) {
setCommunicationClient.item()->problem = setCommunicationServer.item();
}
@@ -222,7 +190,7 @@
// TESTS
// Debug keys
- setMetaheuristic.item()->addDebugKey("sample_solutions");
+ setMetaheuristic.item()->addDebugKey(cmd.debug_key);
//setMetaheuristic.item()->addDebugKey("selectNumber");
// Log
@@ -244,20 +212,20 @@
//clog << setProblem.item()->getName() << " description:" << endl;
//clog << setProblem.item()->getInformations() << endl;
- /*
- try {
+
+ try {
setMetaheuristic.item()->start();
- }
- catch(const char * str) {
+ }
+ catch(const char * str) {
cerr << str << endl;
- }
- catch(string str) {
+ }
+ catch(string str) {
cerr << str << endl;
- }
- catch (...) {
+ }
+ catch (...) {
cerr << "Unknown error" << endl;
- }
- */
+ }
+
}
Index: ometah/interface/ometah.hpp
diff -u ometah/interface/ometah.hpp:1.1 ometah/interface/ometah.hpp:1.2
--- ometah/interface/ometah.hpp:1.1 Wed Jun 1 13:54:08 2005
+++ ometah/interface/ometah.hpp Wed Jun 1 15:50:57 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: ometah.hpp,v 1.1 2005/06/01 13:54:08 jpa Exp $
+ * $Id: ometah.hpp,v 1.2 2005/06/01 15:50:57 jpa Exp $
* Copyright : Université Paris 12 Val-de-Marne
* Author : Johann Dréo <address@hidden>
* Author : Jean-Philippe Aumasson <address@hidden>
@@ -51,6 +51,8 @@
// argc max value
#define MAX_ARGS 12
+using namespace std;
+
struct cmdargs {
string problem_key;
string metaheur_key;
@@ -63,6 +65,39 @@
typedef struct cmdargs cmdargs_t;
void usage (char *);
-void fatal(char *);
int get_args(int, char **, cmdargs_t *);
-void display_cmd(cmdargs_t *);
+
+
+/*
+ class commandLine
+ {
+ protected:
+
+ // required !
+ string problem_key;
+
+ // required !
+ string metaheur_key;
+
+ // communication client mode (default = Embedded)
+ string cc_mode;
+
+ // communication server mode (default = Embedded)
+ string cs_mode;
+
+ string debug_key;
+
+ // stdout or file name
+ string output;
+ public:
+ // ~ destructor
+ ~commandLine();
+
+ // constructor, set default values
+ commandLine();
+
+ int getArg(string, string, int, char **);
+
+ void display();
+ };
+*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [oMetah-devel] ometah/interface ometah.cpp ometah.hpp itsArgum...,
Jean-Philippe Aumasson <=