[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[oMetah-devel] ometah/experiment metahtest.py
From: |
Jean-Philippe Aumasson |
Subject: |
[oMetah-devel] ometah/experiment metahtest.py |
Date: |
Tue, 07 Jun 2005 10:05:43 -0400 |
CVSROOT: /cvsroot/ometah
Module name: ometah
Branch:
Changes by: Jean-Philippe Aumasson <address@hidden> 05/06/07 14:05:43
Modified files:
experiment : metahtest.py
Log message:
* plot boxes and stand.dev, detect some errors -> log
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/experiment/metahtest.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
Patches:
Index: ometah/experiment/metahtest.py
diff -u ometah/experiment/metahtest.py:1.6 ometah/experiment/metahtest.py:1.7
--- ometah/experiment/metahtest.py:1.6 Tue Jun 7 10:09:39 2005
+++ ometah/experiment/metahtest.py Tue Jun 7 14:05:42 2005
@@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
-# $Id:
+
# Author: Jean-Philippe Aumasson <address@hidden>
# Open Metaheuristic is a Library aimed at the conception of metaheuristics
@@ -31,15 +31,16 @@
TODO
------
-histogramme 3D ?? transfo Xdim en 1 ou 2 dim...
-fonctions 'plotAutrechosequedistribution (listOfPoints)'
+TD histogramme 3D ?? transfo Xdim en 1 ou 2 dim...
+
+WIP.. fonctions 'plotAutrechosequedistribution (listOfPoints)'
-Exceptions ! Errors in log !
+WIP.. Exceptions ! Errors in log !
-Nommer fichiers en fx du problème...
+Nommer fichiers en fx du problème...(à partir de l'instance de Header, crée à
partir du header XML..)
-Organisation fichiers (arborescencec ? noms fichiers ? clé/ID unique ? ..?)
+Organisation fichiers (arborescence ? noms fichiers ? clé/ID unique ? ..?)
/----
@@ -56,6 +57,11 @@
executer commandes R : r('cmd...')
+fonctions statistiques :
+r.sd(list) (standard deviation)
+r.sd(list) (variance)
+
+
"""
import os
@@ -66,8 +72,6 @@
import datetime
-
-
def setPostscriptOutput(filename):
""" set a postscript output file """
r.postscript(filename, paper='letter')
@@ -85,7 +89,6 @@
class Interface:
""" the main interface with ometah output """
- # if true, log events in *.log file
LOG_ON = 0
def __init__(self, args):
@@ -97,7 +100,10 @@
""" execute ometah with given arguments,
returns the file objects corresponding to the cmd output """
cmd = path + string.join(self.__argv)
- fd = os.popen(cmd)
+ try:
+ fd = os.popen(cmd)
+ except:
+ sef.log('ERROR : wrong path to ometah')
return fd
def setAttributes():
@@ -110,7 +116,6 @@
for x in plist:
vlist.append(float(x.value))
r.hist(vlist, breaks, col='green', main='Distribution', xlab='Values')
- r.lines(r.density(vlist, bw=0.3), col='red')
def plotValues(self, plist, dimension):
""" plot values """
@@ -119,23 +124,41 @@
for x in plist:
vlist.append(float(x.value))
r.plot(vlist, type='o', col='red', main='Values evolution',
xlab='Points', ylab='Value')
- else :
- if dimension == 2 :
- self.log('ERROR : dimension 2')
-
-
- def getProblemName():
- return self.__problemName
-
- def getMetahName():
- return self.__metahName
-
- def getDimension():
- return self.__dimension
-
- def getIterations():
- return self.__iterations
+ elif dimension == 2:
+ self.log('ERROR : dimension 2')
+ def plotClusters(self, plist, iterations):
+ """ plot the given list in iterations clusters """
+ clist = [] # is a list of lists, which are the
iterations
+ ppi = len(plist) / iterations
+ if ppi != int(ppi):
+ self.log('ERROR : Iteration number does not match list size\n')
+ return -1
+ for i in range(iterations): # for each iteration
+ buf = [] # buf is a set of points for an
iteration
+ for j in range(ppi): # for each point of the cluster
+ buf.append( float((plist[i * (ppi-1) + j]).value) )
+ clist.append(buf) # add the created cluster to our
plotted list
+ r.boxplot(clist, style='quantile', col='orange', main='Boxes of
samples', xlab='Iterations')
+
+ def plotSD(self, plist, iterations):
+ """ plot the standard deviation for each iteration cluster """
+ sdlist = []
+ bflist = []
+ ppi = len(plist) / iterations
+ if ppi != int(ppi):
+ self.log('ERROR : Iteration number does not match list size\n')
+ return -1
+ for i in range(iterations):
+ buf = []
+ for j in range(ppi):
+ buf.append( float((plist[i * (ppi-1) + j]).value))
+ bflist.append(buf)
+ for i in bflist:
+ sdlist.append(r.sd(i))
+ r.plot(sdlist, col='blue', type='o', main='Standard deviations',
xlab='Iteration', ylab='SD')
+
+
def log(self, string):
""" will write log of current job in a *.log file with date,
pb name, output files... """
@@ -144,7 +167,6 @@
fd.write(string)
fd.close()
-
def setLog(self, boolean):
self.LOG_ON = boolean
@@ -203,14 +225,27 @@
class Header:
""" for additional informations in XML file """
- dimension = None
- iterations = None
- problemName = None
- metahName = None
+
+ __dimension = None
+ __iterations = None
+ __problemName = None
+ __metahName = None
def __init__(self):
pass
+ def getProblemName(self):
+ return self.__problemName
+
+ def getMetahName(self):
+ return self.__metahName
+
+ def getDimension(self):
+ return self.__dimension
+
+ def getIterations(self):
+ return self.__iterations
+
class Point:
""" a point has a set of coordinates, and a value """
@@ -236,10 +271,10 @@
interface = Interface(sys.argv)
interface.setLog(1)
- slog = "\n\n[ Starting at " + time.ctime() + " ] \n"
+ slog = "\n[ Starting at " + time.ctime() + " ] \n"
interface.log(slog)
- # fd ~ XML output
+ # fd = XML output
fd = interface.execOmetah(__OMETAH_PATH)
interface.log('ometah execution ... OK\n')
@@ -253,17 +288,31 @@
pointsList = parser.getPoints()
interface.log('getting points list : getPoints() ... OK\n')
- # set_postscript_output(R_OUT)
setBitmapOutput(datedFileName(__R_OUT, '.png'))
interface.plotDistribution(pointsList, __HIST_BREAKS)
r.dev_off()
interface.log('outputing results : plotDistribution(...) ... OK\n')
+ """
setBitmapOutput(datedFileName('values', '.png'))
- interface.plotValues(pointsList, 1)
+ interface.plotValues(pointsList, 1)
r.dev_off()
interface.log('outputing results : plotValues(...) ... OK\n')
-
+ """
+ setBitmapOutput(datedFileName('boxes', '.png'))
+ interface.plotClusters(pointsList, 10)
+ r.dev_off()
+ interface.log('outputing results : plotClusters(...) ... OK\n')
+
+ setBitmapOutput(datedFileName('standdev', '.png'))
+ interface.plotSD(pointsList, 10)
+ r.dev_off()
+ interface.log('outputing results : plotSD(...) ... OK\n')
+
+
+ slog = "\n[ End at " + time.ctime() + " ] \n"
+ interface.log(slog)
+
if __name__ == '__main__':
main()
- [oMetah-devel] ometah/experiment metahtest.py, Jean-Philippe Aumasson, 2005/06/06
- [oMetah-devel] ometah/experiment metahtest.py, Jean-Philippe Aumasson, 2005/06/07
- [oMetah-devel] ometah/experiment metahtest.py, Jean-Philippe Aumasson, 2005/06/07
- [oMetah-devel] ometah/experiment metahtest.py, Jean-Philippe Aumasson, 2005/06/07
- [oMetah-devel] ometah/experiment metahtest.py,
Jean-Philippe Aumasson <=
- [oMetah-devel] ometah/experiment metahtest.py, Jean-Philippe Aumasson, 2005/06/07
- [oMetah-devel] ometah/experiment metahtest.py, Jean-Philippe Aumasson, 2005/06/09
- [oMetah-devel] ometah/experiment metahtest.py, Jean-Philippe Aumasson, 2005/06/09
- [oMetah-devel] ometah/experiment metahtest.py, Jean-Philippe Aumasson, 2005/06/10
- [oMetah-devel] ometah/experiment metahtest.py, Jean-Philippe Aumasson, 2005/06/13