Clean up configure/build-process.
- assume C++ standard-conforming environment - add a user-option for gnuplot-support - separate gnuplot-code into declaration and implementation, so we can define at EO-build-time whether to use it or not. Adopt code and Makefiles to above changes. Some minor fixes.
This commit is contained in:
parent
6485482f39
commit
47af7cfe5a
22 changed files with 603 additions and 537 deletions
|
|
@ -14,7 +14,7 @@ SUBDIRS = src doc contrib win $(SUBDIRS_APP) $(SUBDIRS_TUT) test
|
||||||
# Directory for documents
|
# Directory for documents
|
||||||
DOCDIR = ~/public_html/eodocs
|
DOCDIR = ~/public_html/eodocs
|
||||||
|
|
||||||
#Directory for indices -- not useful for the user
|
# Directory for indices -- not useful for the user
|
||||||
IDXDIR = ~/index
|
IDXDIR = ~/index
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
#
|
#
|
||||||
# Compile applications unless user requests not to do it.
|
# Compile applications unless user requests not to do it.
|
||||||
AC_DEFUN([AC_APPLICATIONS],[dnl
|
AC_DEFUN([AC_APPLICATIONS],[dnl
|
||||||
AC_ARG_ENABLE([applications],[ --enable-applications build applications (default=yes)],
|
AC_ARG_ENABLE([applications],
|
||||||
|
AC_HELP_STRING([--enable-applications], [build applications (default=yes)]),
|
||||||
[ case "${enableval}" in
|
[ case "${enableval}" in
|
||||||
yes) applications=true ;;
|
yes) applications=true ;;
|
||||||
no) applications=false ;;
|
no) applications=false ;;
|
||||||
|
|
@ -18,11 +19,34 @@ AC_DEFUN([AC_APPLICATIONS],[dnl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# AC_GNUPLOT()
|
||||||
|
#
|
||||||
|
# Compile applications unless user requests not to do it.
|
||||||
|
AC_DEFUN([AC_GNUPLOT], [dnl
|
||||||
|
AC_ARG_ENABLE([gnuplot],
|
||||||
|
AC_HELP_STRING([--enable-gnuplot], [use gnuplot for graphical display (default=yes)]),
|
||||||
|
[ac_cv_use_gnuplot=$enableval],
|
||||||
|
[ac_cv_use_gnuplot=yes])
|
||||||
|
AC_CACHE_CHECK([use gnuplot for graphical display],
|
||||||
|
[ac_cv_use_gnuplot],
|
||||||
|
[ac_cv_use_gnuplot=no])
|
||||||
|
if test "$ac_cv_use_gnuplot" = "yes"; then
|
||||||
|
AC_ARG_VAR([GNUPLOT], [gnuplot used for graphical display])
|
||||||
|
AC_CHECK_PROG([GNUPLOT], [gnuplot], [true])
|
||||||
|
AC_DEFINE([HAVE_GNUPLOT], [1], [gnuplot graphical display])
|
||||||
|
else
|
||||||
|
AC_DEFINE([NO_GNUPLOT], [1], [no gnuplot graphical display])
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# AC_TUTORIAL()
|
# AC_TUTORIAL()
|
||||||
#
|
#
|
||||||
# Compile tutorial unless user requests not to do it.
|
# Compile tutorial unless user requests not to do it.
|
||||||
AC_DEFUN([AC_TUTORIAL],[dnl
|
AC_DEFUN([AC_TUTORIAL],[dnl
|
||||||
AC_ARG_ENABLE([tutorial],[ --enable-tutorial build tutorial (default=yes)],
|
AC_ARG_ENABLE([tutorial],
|
||||||
|
AC_HELP_STRING([--enable-tutoria], [build tutorial (default=yes)]),
|
||||||
[ case "${enableval}" in
|
[ case "${enableval}" in
|
||||||
yes) tutorial=true ;;
|
yes) tutorial=true ;;
|
||||||
no) tutorial=false ;;
|
no) tutorial=false ;;
|
||||||
|
|
@ -35,46 +59,3 @@ AC_DEFUN([AC_TUTORIAL],[dnl
|
||||||
AM_CONDITIONAL([USE_TUTORIAL], false)
|
AM_CONDITIONAL([USE_TUTORIAL], false)
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dnl Available from the GNU Autoconf Macro Archive at:
|
|
||||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_namespaces.html
|
|
||||||
dnl
|
|
||||||
AC_DEFUN([AC_CXX_NAMESPACES],
|
|
||||||
[AC_CACHE_CHECK(whether the compiler implements namespaces,
|
|
||||||
ac_cv_cxx_namespaces,
|
|
||||||
[AC_LANG_SAVE
|
|
||||||
AC_LANG_CPLUSPLUS
|
|
||||||
AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
|
|
||||||
[using namespace Outer::Inner; return i;],
|
|
||||||
ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
|
|
||||||
AC_LANG_RESTORE
|
|
||||||
])
|
|
||||||
if test "$ac_cv_cxx_namespaces" = yes; then
|
|
||||||
AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dnl Available from the GNU Autoconf Macro Archive at:
|
|
||||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_numeric_limits.html
|
|
||||||
dnl
|
|
||||||
AC_DEFUN([AC_CXX_HAVE_NUMERIC_LIMITS],
|
|
||||||
[AC_CACHE_CHECK(whether the compiler has numeric_limits<T>,
|
|
||||||
ac_cv_cxx_have_numeric_limits,
|
|
||||||
[AC_REQUIRE([AC_CXX_NAMESPACES])
|
|
||||||
AC_LANG_SAVE
|
|
||||||
AC_LANG_CPLUSPLUS
|
|
||||||
AC_TRY_COMPILE([#include <limits>
|
|
||||||
#ifdef HAVE_NAMESPACES
|
|
||||||
using namespace std;
|
|
||||||
#endif],[double e = numeric_limits<double>::epsilon(); return 0;],
|
|
||||||
ac_cv_cxx_have_numeric_limits=yes, ac_cv_cxx_have_numeric_limits=no)
|
|
||||||
AC_LANG_RESTORE
|
|
||||||
])
|
|
||||||
if test "$ac_cv_cxx_have_numeric_limits" = yes; then
|
|
||||||
AC_DEFINE(HAVE_NUMERIC_LIMITS,,[define if the compiler has numeric_limits<T>])
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
|
|
|
||||||
|
|
@ -5,42 +5,30 @@
|
||||||
#ifndef mlp_h
|
#ifndef mlp_h
|
||||||
#define mlp_h
|
#define mlp_h
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_NUMERIC_LIMITS
|
|
||||||
#include <numeric>
|
|
||||||
#define MLP_MAXFLOAT std::numeric_limits<double>::max()
|
|
||||||
#define MLP_MINFLOAT std::numeric_limits<double>::min()
|
|
||||||
#elif defined HAVE_VALUES_H
|
|
||||||
#include <values.h>
|
|
||||||
#define MLP_MAXFLOAT MAXFLOAT
|
|
||||||
#define MLP_MINFLOAT MINFLOAT
|
|
||||||
#else
|
|
||||||
#error numerical limits not available
|
|
||||||
#endif
|
|
||||||
#include <math.h> // exp
|
|
||||||
#include <stdexcept> // invalid_argument
|
|
||||||
#include <iostream> // istream ostream
|
|
||||||
#include <algorithm> // generate
|
#include <algorithm> // generate
|
||||||
#include <vector> // vector
|
#include <cmath> // exp
|
||||||
#include <utils/eoRNG.h> // eoRng
|
#include <iostream>
|
||||||
#include <utils/rnd_generators.h> // normal_geneurator
|
|
||||||
#include <vecop.h> // *
|
|
||||||
#include <utility>
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <numeric>
|
||||||
|
#include <stdexcept> // invalid_argument
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
#include <utils/eoRNG.h> // eoRng
|
||||||
|
#include <utils/rnd_generators.h> // normal_generator
|
||||||
|
#include <vecop.h> // *
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
namespace mlp
|
namespace mlp
|
||||||
{
|
{
|
||||||
typedef double real;
|
using namespace std;
|
||||||
typedef std::vector<real> vector;
|
|
||||||
|
typedef double real;
|
||||||
|
typedef std::vector<real> vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
ostream& operator<<(ostream& os, const mlp::vector& v)
|
ostream& operator<<(ostream& os, const mlp::vector& v)
|
||||||
{
|
{
|
||||||
|
|
@ -60,13 +48,15 @@ namespace std {
|
||||||
|
|
||||||
namespace mlp
|
namespace mlp
|
||||||
{
|
{
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// useful typedefs
|
// useful typedefs
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
const real max_real = MLP_MAXFLOAT;
|
const real max_real = std::numeric_limits<real>::max();
|
||||||
const real min_real = MLP_MINFLOAT;
|
const real min_real = std::numeric_limits<real>::min();
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
@ -459,12 +449,9 @@ namespace mlp {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef MLP_MAXFLOAT
|
|
||||||
#undef MLP_MINFLOAT
|
|
||||||
|
|
||||||
|
|
||||||
#endif // mlp_h
|
#endif // mlp_h
|
||||||
|
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode:C++
|
// mode:C++
|
||||||
// c-file-style: "Stroustrup"
|
// c-file-style: "Stroustrup"
|
||||||
|
|
|
||||||
|
|
@ -11,5 +11,5 @@ LIBEO = $(top_builddir)/src/libeo.a
|
||||||
LIBEOUTILS = $(top_builddir)/src/utils/libeoutils.a
|
LIBEOUTILS = $(top_builddir)/src/utils/libeoutils.a
|
||||||
|
|
||||||
AM_CXXFLAGS = -I$(top_srcdir)/src
|
AM_CXXFLAGS = -I$(top_srcdir)/src
|
||||||
DEPS = $(LIBEOUTILS) $(LIBEO)
|
DEPS = $(LIBEO) $(LIBEOUTILS)
|
||||||
LIBS = $(LIBEOUTILS) $(LIBEO)
|
LIBS = $(LIBEO) $(LIBEOUTILS)
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,5 @@ LIBEO = $(top_builddir)/src/libeo.a
|
||||||
LIBEOUTILS = $(top_builddir)/src/utils/libeoutils.a
|
LIBEOUTILS = $(top_builddir)/src/utils/libeoutils.a
|
||||||
|
|
||||||
AM_CXXFLAGS = -I$(top_srcdir)/src
|
AM_CXXFLAGS = -I$(top_srcdir)/src
|
||||||
DEPS = $(LIBEOUTILS) $(LIBEO)
|
DEPS = $(LIBEO) $(LIBEOUTILS)
|
||||||
LIBS = $(LIBEOUTILS) $(LIBEO)
|
LIBS = $(LIBEO) $(LIBEOUTILS)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#include <eoVector.h> // eoVectorLength
|
#include <eoVector.h> // eoVectorLength
|
||||||
#include <eoOp.h> // eoMonOp eoQuadraticOp
|
#include <eoOp.h> // eoMonOp eoQuadraticOp
|
||||||
#include <eoInit.h> // eoInit
|
#include <eoInit.h> // eoInit
|
||||||
#include <utils/rnd_generators.h> // uniform_generator
|
#include "utils/rnd_generators.h" // uniform_generator
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// phenotype
|
// phenotype
|
||||||
|
|
@ -87,7 +87,7 @@ void init_eoChromEvaluator(const unsigned& c, const unsigned& l, std::string s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check number of colors
|
// check number of colors
|
||||||
if (c != default_colors && c < *max_element(s.begin(), s.end()) - '0')
|
if ((c != default_colors) && (c < unsigned(*max_element(s.begin(), s.end()) - '0')))
|
||||||
{
|
{
|
||||||
std::cerr << "too high color number found!" << std::endl;
|
std::cerr << "too high color number found!" << std::endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
DIE=0
|
DIE=0
|
||||||
|
|
||||||
PROG=eo
|
PROG=eo
|
||||||
|
|
||||||
(autoconf --version) < /dev/null > /dev/null 2>&1 ||
|
(autoconf --version) < /dev/null > /dev/null 2>&1 ||
|
||||||
|
|
@ -11,13 +10,6 @@ PROG=eo
|
||||||
DIE=1
|
DIE=1
|
||||||
}
|
}
|
||||||
|
|
||||||
#(libtool --version) < /dev/null > /dev/null 2>&1 ||
|
|
||||||
#{
|
|
||||||
# echo
|
|
||||||
# echo "You must have libtool installed to compile $PROG."
|
|
||||||
# DIE=1
|
|
||||||
#}
|
|
||||||
|
|
||||||
(automake --version) < /dev/null > /dev/null 2>&1 ||
|
(automake --version) < /dev/null > /dev/null 2>&1 ||
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
|
|
@ -37,7 +29,7 @@ automake -a -c
|
||||||
autoconf
|
autoconf
|
||||||
|
|
||||||
# we want doc to be recompiled - and it keeps saying it's up to date!!!
|
# we want doc to be recompiled - and it keeps saying it's up to date!!!
|
||||||
touch doc/eo.cfg
|
# touch doc/eo.cfg
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Now run 'configure' and 'make' to build $PROG."
|
echo "Now run 'configure' and 'make' to build $PROG."
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@ dnl automake initialization
|
||||||
AM_INIT_AUTOMAKE([gnu dist-bzip2 dist-zip])
|
AM_INIT_AUTOMAKE([gnu dist-bzip2 dist-zip])
|
||||||
AM_CONFIG_HEADER(config.h)
|
AM_CONFIG_HEADER(config.h)
|
||||||
|
|
||||||
dnl user-switches
|
|
||||||
AC_APPLICATIONS
|
|
||||||
AC_TUTORIAL
|
|
||||||
|
|
||||||
dnl Checks for programs.
|
dnl Checks for programs.
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AC_PROG_CXX
|
AC_PROG_CXX
|
||||||
|
|
@ -27,33 +23,32 @@ AC_PROG_INSTALL
|
||||||
AC_PROG_LN_S
|
AC_PROG_LN_S
|
||||||
AC_PROG_MAKE_SET
|
AC_PROG_MAKE_SET
|
||||||
AC_PROG_RANLIB
|
AC_PROG_RANLIB
|
||||||
AC_ARG_VAR([DOXYGEN], [doxygen - automatic documentation generator])
|
AC_PATH_PROG([AR], [ar], [false], [$PATH:/usr/ccs/bin]) # solaris-x86 needs extra path
|
||||||
|
AC_ARG_VAR([DOXYGEN], [automatic documentation generation])
|
||||||
AC_CHECK_PROGS([DOXYGEN], [doxygen], [true])
|
AC_CHECK_PROGS([DOXYGEN], [doxygen], [true])
|
||||||
AC_ARG_VAR([AR], [ar - archiver for static libraries])
|
|
||||||
# solaris-x86 hides ar at "/usr/ccs/bin/ar"
|
|
||||||
AC_CHECK_PROGS([AR], [ar /usr/ccs/bin/ar], [false])
|
|
||||||
|
|
||||||
dnl Checks for compiler characteristics.
|
|
||||||
AC_CXX_NAMESPACES
|
|
||||||
AC_TYPE_SIZE_T
|
|
||||||
|
|
||||||
dnl Checks for header files.
|
dnl Checks for header files.
|
||||||
AC_LANG(C++)
|
AC_LANG(C++)
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_CHECK_HEADERS(limits.h)
|
AC_CHECK_HEADERS(limits, [], AC_MSG_ERROR([Need limits C++ include.]))
|
||||||
AC_CHECK_HEADERS(sstream, [], AC_MSG_ERROR([Need sstream C++ include.]))
|
AC_CHECK_HEADERS(sstream, [], AC_MSG_ERROR([Need sstream C++ include.]))
|
||||||
AC_CHECK_HEADERS(stdint.h, [], AC_MSG_WARN([Need C99 standard header.]))
|
AC_CHECK_HEADERS(stdint.h, [], AC_MSG_WARN([Need C99 standard header.]))
|
||||||
AC_CXX_HAVE_NUMERIC_LIMITS
|
|
||||||
|
|
||||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_CHECK_SIZEOF(unsigned long)
|
AC_CHECK_SIZEOF(unsigned long)
|
||||||
AC_CHECK_TYPES(uint32_t, [], AC_MSG_WARN([Need uint32_t from C99 standard.]))
|
AC_CHECK_TYPES(uint32_t, [], AC_MSG_WARN([Need uint32_t from C99 standard.]))
|
||||||
|
AC_TYPE_SIZE_T
|
||||||
|
|
||||||
dnl Checks for libraries.
|
dnl Checks for libraries.
|
||||||
|
|
||||||
dnl Checks for library functions.
|
dnl Checks for library functions.
|
||||||
AC_CHECK_LIB(m, cos)
|
AC_CHECK_LIB(m, cos)
|
||||||
|
|
||||||
|
dnl user-switches
|
||||||
|
AC_APPLICATIONS
|
||||||
|
AC_GNUPLOT
|
||||||
|
AC_TUTORIAL
|
||||||
|
|
||||||
dnl create makefiles
|
dnl create makefiles
|
||||||
AC_OUTPUT(Makefile \
|
AC_OUTPUT(Makefile \
|
||||||
app/Makefile \
|
app/Makefile \
|
||||||
|
|
|
||||||
|
|
@ -67,27 +67,32 @@
|
||||||
<h2>Platforms</h2>
|
<h2>Platforms</h2>
|
||||||
</td>
|
</td>
|
||||||
<td bgcolor="#ffcc99">
|
<td bgcolor="#ffcc99">
|
||||||
<p>EO should work on Windows and any Un*x-like operating system with
|
<p>
|
||||||
a standard-conforming C++ development system.
|
EO should work on Windows and any Un*x-like operating system with
|
||||||
|
a standard-conforming C++ development system.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>Recent versions of EO have been tested on the following
|
<p>
|
||||||
platforms:
|
Recent versions of EO have been tested on the following platforms:
|
||||||
<ul>
|
<ul>
|
||||||
<li>Linux-x86 with GCC 3.x and 4.x</li>
|
<li>Linux x86 with GCC 3.x and 4.x</li>
|
||||||
<li>Linux-x86_64 with GCC 3.x</li>
|
<li>Linux x86_64 with GCC 3.x</li>
|
||||||
<li>Darwin-powerpc (Macintosh) with GCC 3.3</li>
|
<li>MacOS X/Darwin PowerPC with GCC 3.3</li>
|
||||||
|
<li>Solaris SPARC with GCC 3.3.2</li>
|
||||||
|
<li>Solaris x86 with GCC 3.3.2 (t-MGE1bit fails)</li>
|
||||||
<li>CygWin (Windows XP) with GCC 3.3.1 (cygming special).
|
<li>CygWin (Windows XP) with GCC 3.3.1 (cygming special).
|
||||||
<li>Win95/NT with VC++ 5.0 and Borland Builder. Makefiles and
|
<li>Win95/NT with VC++ 5.0 and Borland Builder. Makefiles and
|
||||||
projects files are provided.</li>
|
projects files are provided.</li>
|
||||||
</ul>
|
</ul>
|
||||||
If you have tested EO on a system not listed here, please
|
If you have tested EO on a system not listed here, please
|
||||||
<a href="mailto:eodev-main@lists.sourceforge.net?subject=test-report">let us know</a>.
|
<a href="mailto:eodev-main@lists.sourceforge.net?subject=test-report">let
|
||||||
|
us know</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>If you are working on a system with an older C++ compiler there
|
<p>
|
||||||
is a good chance that eo-0.9.3zz works. It is tested on Linux with
|
If you are working on a system with an older C++ compiler there is
|
||||||
gcc-2.9x and several systems (IRIX, Solaris) with egcs.
|
a good chance that eo-0.9.3zz works. It is tested on Linux with
|
||||||
|
gcc-2.9x and several systems (IRIX, Solaris) with egcs.
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
||||||
|
|
@ -113,5 +113,3 @@ pkginclude_HEADERS = eo \
|
||||||
ga.h
|
ga.h
|
||||||
|
|
||||||
AM_CXXFLAGS = -I$(top_srcdir)/src
|
AM_CXXFLAGS = -I$(top_srcdir)/src
|
||||||
|
|
||||||
AM_LIBS = -Lutils -leoutil
|
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,19 @@
|
||||||
lib_LIBRARIES = libeoutils.a
|
lib_LIBRARIES = libeoutils.a
|
||||||
|
|
||||||
libeoutils_a_SOURCES = eoData.cpp \
|
libeoutils_a_SOURCES = eoData.cpp \
|
||||||
|
eoFileMonitor.cpp \
|
||||||
|
eoGnuplot.cpp \
|
||||||
|
eoGnuplot1DMonitor.cpp \
|
||||||
|
eoGnuplot1DSnapshot.cpp \
|
||||||
|
eoIntBounds.cpp \
|
||||||
eoParser.cpp \
|
eoParser.cpp \
|
||||||
|
eoRealBounds.cpp \
|
||||||
eoRNG.cpp \
|
eoRNG.cpp \
|
||||||
eoState.cpp \
|
eoState.cpp \
|
||||||
eoUpdater.cpp \
|
|
||||||
eoFileMonitor.cpp \
|
|
||||||
eoStdoutMonitor.cpp \
|
eoStdoutMonitor.cpp \
|
||||||
eoRealBounds.cpp \
|
eoUpdater.cpp \
|
||||||
eoIntBounds.cpp \
|
make_help.cpp \
|
||||||
make_help.cpp
|
pipecom.cpp
|
||||||
|
|
||||||
utilsincludedir = $(pkgincludedir)/utils
|
utilsincludedir = $(pkgincludedir)/utils
|
||||||
|
|
||||||
|
|
@ -50,5 +54,4 @@ utilsinclude_HEADERS = checkpointing \
|
||||||
rnd_generators.h \
|
rnd_generators.h \
|
||||||
selectors.h
|
selectors.h
|
||||||
|
|
||||||
AM_CXXFLAGS = -I$(top_srcdir)/src
|
AM_CXXFLAGS = -I$(top_srcdir)/src -DGNUPLOT_PROGRAM=\"@GNUPLOT@\"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,26 +21,25 @@
|
||||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||||
Marc.Schoenauer@polytechnique.fr
|
Marc.Schoenauer@polytechnique.fr
|
||||||
mkeijzer@dhi.dk
|
mkeijzer@dhi.dk
|
||||||
CVS Info: $Date: 2004-09-21 19:49:48 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/utils/eoFileMonitor.h,v 1.13 2004-09-21 19:49:48 maartenkeijzer Exp $ $Author: maartenkeijzer $
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Modified the default behavior, so that it erases existing files.
|
|
||||||
Can be modified in the ctor.
|
|
||||||
MS 25/11/00
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _eoFileMonitor_h
|
#ifndef EO_eoFileMonitor_h
|
||||||
#define _eoFileMonitor_h
|
#define EO_eoFileMonitor_h
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <utils/eoMonitor.h>
|
#include "utils/eoMonitor.h"
|
||||||
#include <eoObject.h>
|
#include "eoObject.h"
|
||||||
|
|
||||||
/**
|
/** Prints statistics to file
|
||||||
Prints statistics to file
|
|
||||||
|
Modified the default behavior, so that it erases existing files. Can
|
||||||
|
be modified in the ctor.
|
||||||
|
|
||||||
|
@version MS 25/11/00
|
||||||
*/
|
*/
|
||||||
class eoFileMonitor : public eoMonitor
|
class eoFileMonitor : public eoMonitor
|
||||||
{
|
{
|
||||||
|
|
|
||||||
93
eo/src/utils/eoGnuplot.cpp
Normal file
93
eo/src/utils/eoGnuplot.cpp
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// (c) Marc Schoenauer, 2001
|
||||||
|
// Copyright (C) 2005 Jochen Küpper
|
||||||
|
/*
|
||||||
|
This library is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU Lesser General Public License as published by the Free
|
||||||
|
Software Foundation; either version 2 of the License, or (at your option) any
|
||||||
|
later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||||
|
details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with this library; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Contact: Marc.Schoenauer@polytechnique.fr
|
||||||
|
*/
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include "eoGnuplot.h"
|
||||||
|
|
||||||
|
|
||||||
|
unsigned eoGnuplot::numWindow=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
eoGnuplot::eoGnuplot(std::string _title, std::string _extra)
|
||||||
|
: firstTime(true)
|
||||||
|
{
|
||||||
|
initGnuPlot(_title, _extra);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
eoGnuplot::~eoGnuplot()
|
||||||
|
{
|
||||||
|
if( gpCom ) {
|
||||||
|
PipeComSend( gpCom, "quit\n" );
|
||||||
|
PipeComClose( gpCom );
|
||||||
|
gpCom =NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void eoGnuplot::gnuplotCommand(const char *_command)
|
||||||
|
{
|
||||||
|
if(gpCom) {
|
||||||
|
PipeComSend( gpCom, _command );
|
||||||
|
PipeComSend( gpCom, "\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
|
||||||
|
{
|
||||||
|
std::ostringstream os;
|
||||||
|
os << "250x150-0+" << numWindow*170;
|
||||||
|
numWindow++;
|
||||||
|
char *args[6];
|
||||||
|
args[0] = strdup( GNUPLOT_PROGRAM );
|
||||||
|
args[1] = strdup( "-geometry" );
|
||||||
|
args[2] = strdup( os.str().c_str());
|
||||||
|
args[3] = strdup( "-title" );
|
||||||
|
args[4] = strdup( _title.c_str() );
|
||||||
|
args[5] = 0;
|
||||||
|
gpCom = PipeComOpenArgv( GNUPLOT_PROGRAM, args );
|
||||||
|
if(! gpCom )
|
||||||
|
throw std::runtime_error("Cannot spawn gnuplot\n");
|
||||||
|
else {
|
||||||
|
PipeComSend( gpCom, "set grid\n" );
|
||||||
|
PipeComSend( gpCom, _extra.c_str() );
|
||||||
|
PipeComSend( gpCom, "\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// c-file-style: "Stroustrup"
|
||||||
|
// fill-column: 80
|
||||||
|
// End:
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// eoGnuplot1DMonitor.h
|
// eoGnuplot1DMonitor.h
|
||||||
// (c) Marc Schoenauer, 2001
|
// (c) Marc Schoenauer, 2001
|
||||||
|
|
@ -21,275 +19,81 @@
|
||||||
Contact: Marc.Schoenauer@polytechnique.fr
|
Contact: Marc.Schoenauer@polytechnique.fr
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#ifndef NO_GNUPLOT
|
#ifndef EO_eoGnuplot_H
|
||||||
|
#define EO_eoGnuplot_H
|
||||||
#ifndef _eoGnuplot_H
|
|
||||||
#define _eoGnuplot_H
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/**
|
#include "pipecom.h"
|
||||||
@author Marc Schoenauer 2001
|
|
||||||
@version 0.0
|
|
||||||
|
|
||||||
This class is the abstract class that will be used by further gnuplot calls
|
|
||||||
to plots what is already written by some eoMonitor into a file
|
|
||||||
|
|
||||||
|
/** Base class for calls to gnuplot
|
||||||
|
|
||||||
|
This class is the abstract class that will be used by further gnuplot
|
||||||
|
calls to plots what is already written by some eoMonitor into a file
|
||||||
|
|
||||||
|
@author Marc Schoenauer
|
||||||
|
@version 0.0 (2001)
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <utils/pipecom.h>
|
|
||||||
|
|
||||||
|
|
||||||
/** eoGnuplot: base class that will be used to call gnuplot
|
|
||||||
*/
|
|
||||||
class eoGnuplot
|
class eoGnuplot
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Ctor
|
|
||||||
eoGnuplot(std::string _title, std::string _extra = std::string("")) :
|
|
||||||
firstTime(true)
|
|
||||||
{
|
|
||||||
// opens pipe with Gnuplot
|
|
||||||
initGnuPlot(_title, _extra);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dtor
|
/** Open pipe to Gnuplot.
|
||||||
virtual ~eoGnuplot() {
|
|
||||||
// close - the gnuplot windows if pipe was correctly opened
|
|
||||||
if( gpCom ) {
|
|
||||||
PipeComSend( gpCom, "quit\n" ); // Ferme gnuplot
|
|
||||||
PipeComClose( gpCom );
|
|
||||||
gpCom =NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Class name.
|
@param _title Title for gnuplot window.
|
||||||
virtual std::string className() const { return "eoGnuplot"; }
|
@param _extra Extra parameters to gnuplot.
|
||||||
|
*/
|
||||||
|
eoGnuplot(std::string _title, std::string _extra = std::string(""));
|
||||||
|
|
||||||
/** send a command to gnuplot directly
|
/** Destructor
|
||||||
*/
|
|
||||||
void gnuplotCommand(std::string _command)
|
|
||||||
{
|
|
||||||
if( gpCom ) {
|
|
||||||
PipeComSend( gpCom, _command.c_str() );
|
|
||||||
PipeComSend( gpCom, "\n" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** send a command to gnuplot directly
|
Close the gnuplot windows if pipe was correctly opened
|
||||||
*/
|
*/
|
||||||
void gnuplotCommand(char * _command)
|
virtual ~eoGnuplot();
|
||||||
{
|
|
||||||
if( gpCom ) {
|
/** Class name */
|
||||||
PipeComSend( gpCom, _command );
|
virtual std::string className() const
|
||||||
PipeComSend( gpCom, "\n" );
|
{ return "eoGnuplot"; }
|
||||||
}
|
|
||||||
}
|
/** Send command to gnuplot */
|
||||||
|
void gnuplotCommand(const char * _command);
|
||||||
|
|
||||||
|
/** Send command to gnuplot
|
||||||
|
|
||||||
|
@overload
|
||||||
|
*/
|
||||||
|
void gnuplotCommand(std::string _command)
|
||||||
|
{ gnuplotCommand(_command.c_str()); }
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initGnuPlot(std::string _title, std::string _extra);
|
|
||||||
// the private data
|
/** Initialize gnuplot
|
||||||
bool firstTime; // the stats might be unknown in Ctor
|
|
||||||
PCom *gpCom; // Communication with gnuplot OK
|
@param _title Title for gnuplot window.
|
||||||
private:
|
@param _extra Extra parameters to gnuplot.
|
||||||
|
*/
|
||||||
|
void initGnuPlot(std::string _title, std::string _extra);
|
||||||
|
|
||||||
|
/** The stats might be unknown in Ctor */
|
||||||
|
bool firstTime;
|
||||||
|
|
||||||
|
/** Communication with gnuplot OK */
|
||||||
|
PCom *gpCom;
|
||||||
|
|
||||||
|
/** Internal counter for gnuplot windows */
|
||||||
|
static unsigned numWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
// the following should be placed in a separate eoGnuplot.cpp
|
|
||||||
|
|
||||||
static unsigned numWindow=0;
|
#endif // EO_eoGnuplot_H
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
inline void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
|
|
||||||
/////////////////////////////////////////////////////////
|
|
||||||
{
|
|
||||||
std::ostringstream os;
|
|
||||||
os << "250x150-0+" << numWindow*170;
|
|
||||||
numWindow++;
|
|
||||||
char *args[6];
|
|
||||||
args[0] = strdup( "gnuplot" );
|
|
||||||
args[1] = strdup( "-geometry" );
|
|
||||||
args[2] = strdup( os.str().c_str());
|
|
||||||
args[3] = strdup( "-title" );
|
|
||||||
args[4] = strdup( _title.c_str() );
|
|
||||||
args[5] = 0;
|
|
||||||
gpCom = PipeComOpenArgv( "gnuplot", args );
|
|
||||||
if( ! gpCom )
|
|
||||||
throw std::runtime_error("Impossible to spawn gnuplot\n");
|
|
||||||
else {
|
|
||||||
PipeComSend( gpCom, "set grid\n" );
|
|
||||||
PipeComSend( gpCom, _extra.c_str() );
|
|
||||||
PipeComSend( gpCom, "\n" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// the following should be placed in a separate file pipecom.c
|
|
||||||
// together with the corresponding pipecom.h
|
|
||||||
// but first their MSC equivalent must be written and tested
|
|
||||||
// or some #idef instructions put with clear message at compile time
|
|
||||||
// that this is for Unix only ???
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
|
||||||
* Where........: CMAP - Polytechnique
|
|
||||||
* File.........: pipecom.c
|
|
||||||
* Author.......: Bertrand Lamy (Equipe genetique)
|
|
||||||
* Created......: Mon Mar 13 13:50:11 1995
|
|
||||||
* Description..: Communication par pipe bidirectionnel avec un autre process
|
|
||||||
*
|
|
||||||
* Ident........: $Id: eoGnuplot.h,v 1.13 2005-09-28 21:49:26 kuepper Exp $
|
|
||||||
* ----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
// #include "pipecom.h"
|
|
||||||
|
|
||||||
|
|
||||||
inline int Check( PCom *com )
|
|
||||||
{
|
|
||||||
if( ! com ) {
|
|
||||||
fprintf( stderr, "PipeCom: Null pointer.\n" );
|
|
||||||
fflush( stderr );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if( kill( com->pid, 0 ) != 0 ) {
|
|
||||||
fprintf( stderr, "PipeCom: process doesn't exists.\n" );
|
|
||||||
fflush( stderr );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline PCom * PipeComOpen( char *prog )
|
|
||||||
{
|
|
||||||
char *args[2];
|
|
||||||
args[0] = prog;
|
|
||||||
args[1] = NULL;
|
|
||||||
return PipeComOpenArgv( prog, args );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline PCom * PipeComOpenArgv( char *prog, char *argv[] )
|
|
||||||
{
|
|
||||||
int toFils[2];
|
|
||||||
int toPere[2];
|
|
||||||
int sonPid;
|
|
||||||
PCom * ret = NULL;
|
|
||||||
|
|
||||||
if( pipe( toFils ) < 0 ) {
|
|
||||||
perror( "PipeComOpen: Creating pipes" );
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
if( pipe( toPere ) < 0 ) {
|
|
||||||
perror( "PipeComOpen: Creating pipes" );
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch( (sonPid = vfork()) ) {
|
|
||||||
case -1:
|
|
||||||
perror("PipeComOpen: fork failed" );
|
|
||||||
return ret;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0:
|
|
||||||
/* --- Here's the son --- */
|
|
||||||
/* --- replace old stdin --- */
|
|
||||||
if( dup2( toFils[0], fileno(stdin) ) < 0 ) {
|
|
||||||
perror( "PipeComOpen(son): could not connect" );
|
|
||||||
exit( -1 );
|
|
||||||
/* --- AVOIR: kill my father --- */
|
|
||||||
}
|
|
||||||
if( dup2( toPere[1], fileno(stdout) ) < 0 ) {
|
|
||||||
perror( "PipeComOpen(son): could not connect" );
|
|
||||||
exit( -1 );
|
|
||||||
}
|
|
||||||
if( execvp( prog, argv ) < 0 ) {
|
|
||||||
perror( prog );
|
|
||||||
perror( "PipeComOpen: can't exec" );
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = (PCom *) malloc( sizeof(PCom) );
|
|
||||||
if( ! ret )
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ret->fWrit = (FILE *)fdopen( toFils[1], "w" );
|
|
||||||
ret->fRead = (FILE *)fdopen( toPere[0], "r" );
|
|
||||||
ret->pid = sonPid;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline int PipeComSend( PCom *to, const char *line )
|
|
||||||
{
|
|
||||||
int nb = 0;
|
|
||||||
if( ! Check(to ) )
|
|
||||||
return nb;
|
|
||||||
nb = fprintf( to->fWrit, line );
|
|
||||||
fflush( to->fWrit );
|
|
||||||
return nb;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline int PipeComSendn( PCom *to, const char *data, int n )
|
|
||||||
{
|
|
||||||
int nb = 0;
|
|
||||||
if( ! Check(to) )
|
|
||||||
return nb;
|
|
||||||
|
|
||||||
nb = fwrite( data, 1, n, to->fWrit );
|
|
||||||
fflush( to->fWrit );
|
|
||||||
return nb;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline int PipeComReceive( PCom *from, char *data, int max )
|
|
||||||
{
|
|
||||||
if( ! Check(from) )
|
|
||||||
return 0;
|
|
||||||
if( ! data ) {
|
|
||||||
fprintf( stderr, "PipeComReceive: Invalid data pointer\n" );
|
|
||||||
fflush( stderr );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if( fgets( data, max, from->fRead ) )
|
|
||||||
return strlen(data);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline int PipeComClose( PCom *to )
|
// Local Variables:
|
||||||
{
|
// c-file-style: "Stroustrup"
|
||||||
if( ! Check(to) )
|
// comment-column: 35
|
||||||
return 0;
|
// fill-column: 80
|
||||||
fclose( to->fRead );
|
// mode: C++
|
||||||
fclose( to->fWrit );
|
// End:
|
||||||
free( to );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline int PipeComWaitFor( PCom *from, char *what )
|
|
||||||
{
|
|
||||||
char buffer[256];
|
|
||||||
do {
|
|
||||||
if( ! PipeComReceive( from, buffer, 256 ) )
|
|
||||||
return 0;
|
|
||||||
} while( strcmp( buffer, what ) );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
|
||||||
82
eo/src/utils/eoGnuplot1DMonitor.cpp
Normal file
82
eo/src/utils/eoGnuplot1DMonitor.cpp
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// eoGnuplot1DMonitor.h
|
||||||
|
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
|
||||||
|
/*
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||||
|
Marc.Schoenauer@polytechnique.fr
|
||||||
|
mkeijzer@dhi.dk
|
||||||
|
*/
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "eoGnuplot1DMonitor.h"
|
||||||
|
#include "eoParam.h"
|
||||||
|
|
||||||
|
|
||||||
|
eoMonitor& eoGnuplot1DMonitor::operator() (void)
|
||||||
|
{
|
||||||
|
// update file using the eoFileMonitor
|
||||||
|
eoFileMonitor::operator()();
|
||||||
|
|
||||||
|
// sends plot order to gnuplot
|
||||||
|
// assumes successive plots will have same nb of columns!!!
|
||||||
|
if (firstTime)
|
||||||
|
{
|
||||||
|
FirstPlot();
|
||||||
|
firstTime = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( gpCom ) {
|
||||||
|
PipeComSend( gpCom, "replot\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void eoGnuplot1DMonitor::FirstPlot()
|
||||||
|
{
|
||||||
|
if (vec.size() < 2)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Must have some stats to plot!\n");
|
||||||
|
}
|
||||||
|
std::ostringstream os;
|
||||||
|
os << "plot";
|
||||||
|
for (unsigned i=1; i<vec.size(); i++) {
|
||||||
|
os << " '" << getFileName().c_str() <<
|
||||||
|
"' using 1:" << i+1 << " title '" << (vec[i])->longName() << "' with lines" ;
|
||||||
|
if (i<vec.size()-1)
|
||||||
|
os << ", ";
|
||||||
|
}
|
||||||
|
os << '\n';
|
||||||
|
PipeComSend( gpCom, os.str().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// c-file-style: "Stroustrup"
|
||||||
|
// fill-column: 80
|
||||||
|
// End:
|
||||||
|
|
@ -23,100 +23,51 @@
|
||||||
mkeijzer@dhi.dk
|
mkeijzer@dhi.dk
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#ifndef NO_GNUPLOT
|
#ifndef EO_eoGnuplot1DMonitor_H
|
||||||
|
#define EO_eoGnuplot1DMonitor_H
|
||||||
#ifndef _eoGnuplot1DMonitor_H
|
|
||||||
#define _eoGnuplot1DMonitor_H
|
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <utils/eoMonitor.h>
|
#include "eoObject.h"
|
||||||
#include <utils/eoGnuplot.h>
|
#include "utils/eoFileMonitor.h"
|
||||||
#include <eoObject.h>
|
#include "utils/eoGnuplot.h"
|
||||||
|
#include "utils/pipecom.h"
|
||||||
|
|
||||||
/**
|
/** Plot eoStat
|
||||||
@author Marc Schoenauer 2000
|
|
||||||
@version 0.0
|
@author Marc Schoenauer
|
||||||
|
@version 0.0 (2000)
|
||||||
|
|
||||||
This class plots through gnuplot the eoStat given as argument
|
This class plots through gnuplot the eoStat given as argument
|
||||||
|
|
||||||
|
eoGnuplot1DMonitor plots stats through gnuplot
|
||||||
|
|
||||||
|
Assumes that the same file is appened every so and so, and replots it
|
||||||
|
everytime
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
class eoGnuplot1DMonitor : public eoFileMonitor, public eoGnuplot
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <utils/pipecom.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** eoGnuplot1DMonitor plots stats through gnuplot
|
|
||||||
* assumes that the same file is appened every so and so,
|
|
||||||
* and replots it everytime
|
|
||||||
*/
|
|
||||||
class eoGnuplot1DMonitor: public eoFileMonitor, public eoGnuplot
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Ctor
|
using eoMonitor::vec;
|
||||||
eoGnuplot1DMonitor(std::string _filename, bool _top=false) :
|
|
||||||
eoFileMonitor(_filename, " "),
|
|
||||||
eoGnuplot(_filename,(_top?"":"set key bottom"))
|
|
||||||
{}
|
|
||||||
|
|
||||||
// Dtor
|
/** Constructor */
|
||||||
virtual ~eoGnuplot1DMonitor(){}
|
eoGnuplot1DMonitor(std::string _filename, bool _top=false) :
|
||||||
|
eoFileMonitor(_filename, " "),
|
||||||
|
eoGnuplot(_filename,(_top?"":"set key bottom"))
|
||||||
|
{}
|
||||||
|
|
||||||
virtual eoMonitor& operator() (void) ;
|
/** Destructor */
|
||||||
virtual void FirstPlot();
|
virtual ~eoGnuplot1DMonitor(){}
|
||||||
|
|
||||||
/// Class name.
|
virtual eoMonitor& operator()();
|
||||||
virtual std::string className() const { return "eoGnuplot1DMonitor"; }
|
|
||||||
|
|
||||||
private:
|
virtual void FirstPlot();
|
||||||
|
|
||||||
|
/** Class name */
|
||||||
|
virtual std::string className() const
|
||||||
|
{ return "eoGnuplot1DMonitor"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// the following should be placed in a separate eoGnuplot1DMonitor.cpp
|
|
||||||
// then the inline specifier should dissappear
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
inline eoMonitor& eoGnuplot1DMonitor::operator() (void)
|
|
||||||
/////////////////////////////////////////////////////////
|
|
||||||
{
|
|
||||||
// update file using the eoFileMonitor
|
|
||||||
eoFileMonitor::operator()();
|
|
||||||
|
|
||||||
// sends plot order to gnuplot
|
|
||||||
// assumes successive plots will have same nb of columns!!!
|
|
||||||
if (firstTime)
|
|
||||||
{
|
|
||||||
FirstPlot();
|
|
||||||
firstTime = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( gpCom ) {
|
|
||||||
PipeComSend( gpCom, "replot\n" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
inline void eoGnuplot1DMonitor::FirstPlot()
|
|
||||||
////////////////////////////////////////////////////////
|
|
||||||
{
|
|
||||||
if (vec.size() < 2)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("Must have some stats to plot!\n");
|
|
||||||
}
|
|
||||||
std::ostringstream os;
|
|
||||||
os << "plot";
|
|
||||||
for (unsigned i=1; i<vec.size(); i++) {
|
|
||||||
os << " '" << getFileName().c_str() <<
|
|
||||||
"' using 1:" << i+1 << " title '" << vec[i]->longName() << "' with lines" ;
|
|
||||||
if (i<vec.size()-1)
|
|
||||||
os << ", ";
|
|
||||||
}
|
|
||||||
os << '\n';
|
|
||||||
PipeComSend( gpCom, os.str().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
|
||||||
30
eo/src/utils/eoGnuplot1DSnapshot.cpp
Normal file
30
eo/src/utils/eoGnuplot1DSnapshot.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "eoGnuplot1DSnapshot.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline eoMonitor& eoGnuplot1DSnapshot::operator() (void)
|
||||||
|
{
|
||||||
|
// update file using the eoFileMonitor method
|
||||||
|
eoFileSnapshot::operator()();
|
||||||
|
|
||||||
|
// sends plot order to gnuplot
|
||||||
|
//std::string buff; // need local memory
|
||||||
|
std::ostringstream os;
|
||||||
|
os << "set title 'Gen. " << getCounter() << "'; plot '"
|
||||||
|
// mk: had to use getFilename().c_str(), because it seems the string(stream) lib is screwed in gcc3.2
|
||||||
|
<< getFileName().c_str() << "' notitle with points ps " << pointSize;
|
||||||
|
os << std::endl;
|
||||||
|
PipeComSend( gpCom, os.str().c_str());
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// c-file-style: "Stroustrup"
|
||||||
|
// fill-column: 80
|
||||||
|
// End:
|
||||||
|
|
@ -23,36 +23,30 @@
|
||||||
mkeijzer@dhi.dk
|
mkeijzer@dhi.dk
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#ifndef NO_GNUPLOT
|
|
||||||
|
|
||||||
#ifndef _eoGnuplot1DSnapshot_H
|
|
||||||
#define _eoGnuplot1DSnapshot_H
|
|
||||||
|
|
||||||
|
#ifndef EO_eoGnuplot1DSnapshot_H
|
||||||
|
#define EO_eoGnuplot1DSnapshot_H
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <eoObject.h>
|
||||||
|
#include "eoRealVectorBounds.h"
|
||||||
|
#include <utils/pipecom.h>
|
||||||
#include <utils/eoFileSnapshot.h>
|
#include <utils/eoFileSnapshot.h>
|
||||||
#include <utils/eoGnuplot.h>
|
#include <utils/eoGnuplot.h>
|
||||||
#include <eoObject.h>
|
|
||||||
|
|
||||||
/**
|
/** Plot stats through gnuplot
|
||||||
|
|
||||||
@author Marc Schoenauer 2000
|
@author Marc Schoenauer 2000
|
||||||
@version 0.0
|
@version 0.0
|
||||||
|
|
||||||
This class plots through gnuplot the eoStat given as argument
|
This class plots through gnuplot the eoStat given as argument
|
||||||
|
|
||||||
*/
|
Assumes that the same file is re-written every so and so, and plots it
|
||||||
//-----------------------------------------------------------------------------
|
from scratch everytime it's called
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include "eoRealVectorBounds.h"
|
|
||||||
#include <utils/pipecom.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** eoGnuplot1DSnapshot plots stats through gnuplot
|
|
||||||
* assumes that the same file is re-written every so and so,
|
|
||||||
* and plots it from scratch everytime it's called
|
|
||||||
*/
|
*/
|
||||||
class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot
|
class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot
|
||||||
{
|
{
|
||||||
|
|
@ -118,25 +112,5 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// the following should be placed in a separate eoGnuplot1DMonitor.cpp
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
inline eoMonitor& eoGnuplot1DSnapshot::operator() (void)
|
|
||||||
/////////////////////////////////////////////////////////
|
|
||||||
{
|
|
||||||
// update file using the eoFileMonitor method
|
|
||||||
eoFileSnapshot::operator()();
|
|
||||||
|
|
||||||
// sends plot order to gnuplot
|
|
||||||
//std::string buff; // need local memory
|
|
||||||
std::ostringstream os;
|
|
||||||
os << "set title 'Gen. " << getCounter() << "'; plot '"
|
|
||||||
// mk: had to use getFilename().c_str(), because it seems the string(stream) lib is screwed in gcc3.2
|
|
||||||
<< getFileName().c_str() << "' notitle with points ps " << pointSize;
|
|
||||||
os << std::endl;
|
|
||||||
PipeComSend( gpCom, os.str().c_str());
|
|
||||||
return (*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
|
||||||
173
eo/src/utils/pipecom.cpp
Normal file
173
eo/src/utils/pipecom.cpp
Normal file
|
|
@ -0,0 +1,173 @@
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Where........: CMAP - Polytechnique
|
||||||
|
* File.........: pipecom.c
|
||||||
|
* Author.......: Bertrand Lamy (Equipe genetique)
|
||||||
|
* Created......: Mon Mar 13 13:50:11 1995
|
||||||
|
* Description..: Communication par pipe bidirectionnel avec un autre process
|
||||||
|
* ----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
// MSC equivalent must be written and tested or some #idef instructions added
|
||||||
|
// with a clear message at compile time that this is for Unix only ???
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "pipecom.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int Check( PCom *com )
|
||||||
|
{
|
||||||
|
if( ! com ) {
|
||||||
|
fprintf( stderr, "PipeCom: Null pointer.\n" );
|
||||||
|
fflush( stderr );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if( kill( com->pid, 0 ) != 0 ) {
|
||||||
|
fprintf( stderr, "PipeCom: process doesn't exists.\n" );
|
||||||
|
fflush( stderr );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCom * PipeComOpen( char *prog )
|
||||||
|
{
|
||||||
|
char *args[2];
|
||||||
|
args[0] = prog;
|
||||||
|
args[1] = NULL;
|
||||||
|
return PipeComOpenArgv( prog, args );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PCom * PipeComOpenArgv( char *prog, char *argv[] )
|
||||||
|
{
|
||||||
|
int toFils[2];
|
||||||
|
int toPere[2];
|
||||||
|
int sonPid;
|
||||||
|
PCom * ret = NULL;
|
||||||
|
|
||||||
|
if( pipe( toFils ) < 0 ) {
|
||||||
|
perror( "PipeComOpen: Creating pipes" );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if( pipe( toPere ) < 0 ) {
|
||||||
|
perror( "PipeComOpen: Creating pipes" );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( (sonPid = vfork()) ) {
|
||||||
|
case -1:
|
||||||
|
perror("PipeComOpen: fork failed" );
|
||||||
|
return ret;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
/* --- Here's the son --- */
|
||||||
|
/* --- replace old stdin --- */
|
||||||
|
if( dup2( toFils[0], fileno(stdin) ) < 0 ) {
|
||||||
|
perror( "PipeComOpen(son): could not connect" );
|
||||||
|
exit( -1 );
|
||||||
|
/* --- AVOIR: kill my father --- */
|
||||||
|
}
|
||||||
|
if( dup2( toPere[1], fileno(stdout) ) < 0 ) {
|
||||||
|
perror( "PipeComOpen(son): could not connect" );
|
||||||
|
exit( -1 );
|
||||||
|
}
|
||||||
|
if( execvp( prog, argv ) < 0 ) {
|
||||||
|
perror( prog );
|
||||||
|
perror( "PipeComOpen: can't exec" );
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = (PCom *) malloc( sizeof(PCom) );
|
||||||
|
if( ! ret )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ret->fWrit = (FILE *)fdopen( toFils[1], "w" );
|
||||||
|
ret->fRead = (FILE *)fdopen( toPere[0], "r" );
|
||||||
|
ret->pid = sonPid;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PipeComSend( PCom *to, const char *line )
|
||||||
|
{
|
||||||
|
int nb = 0;
|
||||||
|
if( ! Check(to ) )
|
||||||
|
return nb;
|
||||||
|
nb = fprintf( to->fWrit, line );
|
||||||
|
fflush( to->fWrit );
|
||||||
|
return nb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PipeComSendn( PCom *to, const char *data, int n )
|
||||||
|
{
|
||||||
|
int nb = 0;
|
||||||
|
if( ! Check(to) )
|
||||||
|
return nb;
|
||||||
|
|
||||||
|
nb = fwrite( data, 1, n, to->fWrit );
|
||||||
|
fflush( to->fWrit );
|
||||||
|
return nb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PipeComReceive( PCom *from, char *data, int max )
|
||||||
|
{
|
||||||
|
if( ! Check(from) )
|
||||||
|
return 0;
|
||||||
|
if( ! data ) {
|
||||||
|
fprintf( stderr, "PipeComReceive: Invalid data pointer\n" );
|
||||||
|
fflush( stderr );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if( fgets( data, max, from->fRead ) )
|
||||||
|
return strlen(data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int PipeComClose( PCom *to )
|
||||||
|
{
|
||||||
|
if( ! Check(to) )
|
||||||
|
return 0;
|
||||||
|
fclose( to->fRead );
|
||||||
|
fclose( to->fWrit );
|
||||||
|
free( to );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int PipeComWaitFor( PCom *from, char *what )
|
||||||
|
{
|
||||||
|
char buffer[256];
|
||||||
|
do {
|
||||||
|
if( ! PipeComReceive( from, buffer, 256 ) )
|
||||||
|
return 0;
|
||||||
|
} while( strcmp( buffer, what ) );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// coding: iso-8859-1
|
||||||
|
// mode: C++
|
||||||
|
// c-file-style: "Stroustrup"
|
||||||
|
// fill-column: 80
|
||||||
|
// End:
|
||||||
|
|
@ -4,19 +4,14 @@
|
||||||
* Author.......: Bertrand Lamy (EEAAX)
|
* Author.......: Bertrand Lamy (EEAAX)
|
||||||
* Created......: Thu Mar 9 17:21:15 1995
|
* Created......: Thu Mar 9 17:21:15 1995
|
||||||
* Description..: Pipe communication with a process
|
* Description..: Pipe communication with a process
|
||||||
*
|
|
||||||
* Ident........: $Id: pipecom.h,v 1.3 2001-10-08 09:13:16 evomarc Exp $
|
|
||||||
* ----------------------------------------------------------------------
|
* ----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PIPECOM_H
|
// This file cannot be used from C any more due to some const additions.
|
||||||
#define PIPECOM_H
|
// However, if you remove the const, it should work in C as well.
|
||||||
|
|
||||||
// this file cannot be used from C or C++ any more due to some const additions
|
#ifndef EO_PIPECOM_H
|
||||||
// however, if you remove the const, it should work in C also
|
#define EO_PIPECOM_H
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
@ -28,21 +23,25 @@ typedef struct PipeCommunication {
|
||||||
} PCom;
|
} PCom;
|
||||||
|
|
||||||
|
|
||||||
|
extern PCom *PipeComOpen( char *prog );
|
||||||
|
extern PCom *PipeComOpenArgv( char *prog, char *argv[] );
|
||||||
|
|
||||||
PCom *PipeComOpen( char *prog );
|
extern int PipeComSend( PCom *to, const char *line );
|
||||||
PCom *PipeComOpenArgv( char *prog, char *argv[] );
|
extern int PipeComSendn( PCom *to, const char *data, int n );
|
||||||
|
|
||||||
int PipeComSend( PCom *to, const char *line );
|
extern int PipeComReceive( PCom *from, char *data, int max );
|
||||||
int PipeComSendn( PCom *to, const char *data, int n );
|
|
||||||
|
|
||||||
int PipeComReceive( PCom *from, char *data, int max );
|
extern int PipeComClose( PCom *to );
|
||||||
|
extern int PipeComWaitFor( PCom *from, char *what );
|
||||||
|
|
||||||
int PipeComClose( PCom *to );
|
|
||||||
|
|
||||||
int PipeComWaitFor( PCom *from, char *what );
|
#endif // EO_PIPECOM_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} /* ferme extern "C" */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
// Local Variables:
|
||||||
|
// coding: iso-8859-1
|
||||||
|
// mode: C++
|
||||||
|
// c-file-style: "Stroustrup"
|
||||||
|
// fill-column: 80
|
||||||
|
// End:
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ extra_DIST = Makefile.simple
|
||||||
|
|
||||||
LDADD = -L$(top_builddir)/src -L$(top_builddir)/src/ga -L$(top_builddir)/src/utils
|
LDADD = -L$(top_builddir)/src -L$(top_builddir)/src/ga -L$(top_builddir)/src/utils
|
||||||
|
|
||||||
LIBS = -lga -leoutils -leo
|
LIBS = -lga -leo -leoutils
|
||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)/src
|
INCLUDES = -I$(top_srcdir)/src
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,6 @@ extra_DIST = Makefile.simple
|
||||||
|
|
||||||
LDADD = -L$(top_builddir)/src -L$(top_builddir)/src/ga -L$(top_builddir)/src/utils
|
LDADD = -L$(top_builddir)/src -L$(top_builddir)/src/ga -L$(top_builddir)/src/utils
|
||||||
|
|
||||||
LIBS = -lga -leoutils -leo
|
LIBS = -lga -leo -leoutils
|
||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)/src
|
INCLUDES = -I$(top_srcdir)/src
|
||||||
|
|
|
||||||
Reference in a new issue