move edo stuff, that was in the wriong place after the merge, in the edo directory
This commit is contained in:
parent
d4765851d5
commit
cbb1771dd6
77 changed files with 0 additions and 0 deletions
14
edo/application/CMakeLists.txt
Normal file
14
edo/application/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
######################################################################################
|
||||
### 1) Where do we go now ?!?
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/common
|
||||
)
|
||||
|
||||
ADD_SUBDIRECTORY(common)
|
||||
ADD_SUBDIRECTORY(eda_sa)
|
||||
ADD_SUBDIRECTORY(eda)
|
||||
#ADD_SUBDIRECTORY(sa)
|
||||
|
||||
######################################################################################
|
||||
15
edo/application/common/CMakeLists.txt
Normal file
15
edo/application/common/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
PROJECT(common)
|
||||
|
||||
SET(RESOURCES
|
||||
gplot.py
|
||||
ggobi.py
|
||||
boxplot_eda_n_edasa.py
|
||||
)
|
||||
|
||||
FOREACH(file ${RESOURCES})
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${file}
|
||||
${DO_BINARY_DIR}/${file}
|
||||
)
|
||||
ENDFOREACH(file)
|
||||
42
edo/application/common/Rosenbrock.h
Normal file
42
edo/application/common/Rosenbrock.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef _Rosenbrock_h
|
||||
#define _Rosenbrock_h
|
||||
|
||||
#include <eo>
|
||||
#include <es.h>
|
||||
#include <es/eoRealInitBounded.h>
|
||||
#include <es/eoRealOp.h>
|
||||
#include <es/eoEsChromInit.h>
|
||||
#include <es/eoRealOp.h>
|
||||
#include <es/make_real.h>
|
||||
#include <apply.h>
|
||||
#include <eoProportionalCombinedOp.h>
|
||||
|
||||
template < typename EOT >
|
||||
class Rosenbrock : public eoEvalFunc< EOT >
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
virtual void operator()( EOT& p )
|
||||
{
|
||||
if (!p.invalid())
|
||||
return;
|
||||
|
||||
p.fitness( _evaluate( p ) );
|
||||
}
|
||||
|
||||
private:
|
||||
AtomType _evaluate( EOT& p )
|
||||
{
|
||||
AtomType r = 0.0;
|
||||
|
||||
for (unsigned int i = 0; i < p.size() - 1; ++i)
|
||||
{
|
||||
r += p[i] * p[i];
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_Rosenbrock_h
|
||||
42
edo/application/common/Sphere.h
Normal file
42
edo/application/common/Sphere.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef _Sphere_h
|
||||
#define _Sphere_h
|
||||
|
||||
#include <eo>
|
||||
#include <es.h>
|
||||
#include <es/eoRealInitBounded.h>
|
||||
#include <es/eoRealOp.h>
|
||||
#include <es/eoEsChromInit.h>
|
||||
#include <es/eoRealOp.h>
|
||||
#include <es/make_real.h>
|
||||
#include <apply.h>
|
||||
#include <eoProportionalCombinedOp.h>
|
||||
|
||||
template < typename EOT >
|
||||
class Sphere : public eoEvalFunc< EOT >
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
virtual void operator()( EOT& p )
|
||||
{
|
||||
if (!p.invalid())
|
||||
return;
|
||||
|
||||
p.fitness( _evaluate( p ) );
|
||||
}
|
||||
|
||||
private:
|
||||
AtomType _evaluate( EOT& p )
|
||||
{
|
||||
AtomType r = 0.0;
|
||||
|
||||
for (unsigned int i = 0; i < p.size() - 1; ++i)
|
||||
{
|
||||
r += p[i] * p[i];
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !_Sphere_h
|
||||
36
edo/application/common/boxplot_eda_n_edasa.py
Executable file
36
edo/application/common/boxplot_eda_n_edasa.py
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from pylab import *
|
||||
#from pprint import pprint
|
||||
|
||||
FILE_LOCATIONS = 'EDA_ResPop/list_of_files.txt'
|
||||
|
||||
data = []
|
||||
|
||||
locations = [ line.split()[0] for line in open( FILE_LOCATIONS ) ]
|
||||
#pprint( locations )
|
||||
|
||||
for cur_file in locations:
|
||||
fitnesses = [ float(line.split()[0]) for line in open( cur_file ).readlines()[1:-1] ]
|
||||
data.append( fitnesses[1:] )
|
||||
|
||||
#pprint( data )
|
||||
|
||||
boxplot( data )
|
||||
|
||||
# FILE_LOCATIONS = 'EDASA_ResPop/list_of_files.txt'
|
||||
|
||||
# data = []
|
||||
|
||||
# locations = [ line.split()[0] for line in open( FILE_LOCATIONS ) ]
|
||||
# #pprint( locations )
|
||||
|
||||
# for cur_file in locations:
|
||||
# fitnesses = [ float(line.split()[0]) for line in open( cur_file ).readlines()[1:-1] ]
|
||||
# data.append( fitnesses[1:] )
|
||||
|
||||
# #pprint( data )
|
||||
|
||||
# boxplot( data )
|
||||
|
||||
show()
|
||||
68
edo/application/common/ggobi.py
Executable file
68
edo/application/common/ggobi.py
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from pprint import *
|
||||
import sys, os
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# parameter phase
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print 'Usage: %s [FILE]' % sys.argv[0]
|
||||
sys.exit()
|
||||
|
||||
filename = sys.argv[1]
|
||||
|
||||
lines = open(filename).readlines()
|
||||
|
||||
# formatting phase
|
||||
|
||||
try:
|
||||
results = [ x.split() for x in lines[1:-1] ]
|
||||
except IOError, e:
|
||||
print 'Error: %s' % e
|
||||
sys.exit()
|
||||
|
||||
# dimension estimating phase
|
||||
|
||||
popsize = int(lines[0].split()[0])
|
||||
dimsize = int(results[0][1])
|
||||
|
||||
# printing phase
|
||||
|
||||
print 'popsize: %d' % popsize
|
||||
print 'dimsize: %d' % dimsize
|
||||
|
||||
print
|
||||
pprint( results )
|
||||
|
||||
# cvs converting phase
|
||||
|
||||
i = 1
|
||||
for x in results:
|
||||
x.insert(0, '"%d"' % i)
|
||||
i += 1
|
||||
|
||||
header = ['""', '"fitness"', '"dimsize"']
|
||||
|
||||
for i in range(0, dimsize):
|
||||
header.append( '"dim%d"' % i )
|
||||
|
||||
results.insert(0, header)
|
||||
|
||||
# cvs printing phase
|
||||
|
||||
file_results = '\n'.join( [ ','.join( x ) for x in results ] )
|
||||
|
||||
print
|
||||
print file_results
|
||||
|
||||
try:
|
||||
open('%s.csv' % filename, 'w').write(file_results + '\n')
|
||||
except IOError, e:
|
||||
print 'Error: %s' % e
|
||||
sys.exit()
|
||||
|
||||
# ggobi plotting phase
|
||||
|
||||
os.system('ggobi %s.csv' % filename)
|
||||
399
edo/application/common/gplot.py
Executable file
399
edo/application/common/gplot.py
Executable file
|
|
@ -0,0 +1,399 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""plot.py -- Plot EDA-SA results file"""
|
||||
|
||||
import os, time, math, tempfile
|
||||
import numpy
|
||||
|
||||
try:
|
||||
import Gnuplot, Gnuplot.PlotItems, Gnuplot.funcutils
|
||||
except ImportError:
|
||||
# kludge in case Gnuplot hasn't been installed as a module yet:
|
||||
import __init__
|
||||
Gnuplot = __init__
|
||||
import PlotItems
|
||||
Gnuplot.PlotItems = PlotItems
|
||||
import funcutils
|
||||
Gnuplot.funcutils = funcutils
|
||||
|
||||
import optparse, logging, sys
|
||||
|
||||
LEVELS = {'debug': logging.DEBUG,
|
||||
'info': logging.INFO,
|
||||
'warning': logging.WARNING,
|
||||
'error': logging.ERROR,
|
||||
'critical': logging.CRITICAL}
|
||||
|
||||
def logger(level_name, filename='plot.log'):
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
|
||||
filename=filename, filemode='a'
|
||||
)
|
||||
|
||||
console = logging.StreamHandler()
|
||||
console.setLevel(LEVELS.get(level_name, logging.NOTSET))
|
||||
console.setFormatter(logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s'))
|
||||
logging.getLogger('').addHandler(console)
|
||||
|
||||
def parser(parser=optparse.OptionParser()):
|
||||
parser.add_option('-v', '--verbose', choices=LEVELS.keys(), default='warning', help='set a verbose level')
|
||||
parser.add_option('-f', '--files', help='give some input sample files separated by comma (cf. gen1,gen2,...)', default='')
|
||||
parser.add_option('-r', '--respop', help='define the population results containing folder', default='./ResPop')
|
||||
parser.add_option('-o', '--output', help='give an output filename for logging', default='plot.log')
|
||||
parser.add_option('-d', '--dimension', help='give a dimension size', default=2)
|
||||
parser.add_option('-m', '--multiplot', action="store_true", help='plot all graphics in one window', dest="multiplot", default=True)
|
||||
parser.add_option('-p', '--plot', action="store_false", help='plot graphics separetly, one by window', dest="multiplot")
|
||||
parser.add_option('-w', '--windowid', help='give the window id you want to display, 0 means we display all ones, this option should be combined with -p', default=0)
|
||||
parser.add_option('-G', '--graphicsdirectory', help='give a directory name for graphics, this option should be combined with -u', default='plot')
|
||||
parser.add_option('-g', '--graphicsprefixname', help='give a prefix name for graphics, this option should be combined with -u', default='plot')
|
||||
parser.add_option('-t', '--terminal', action="store_true", help='display graphics on gnuplot windows', dest="terminal", default=True)
|
||||
parser.add_option('-u', '--png', action="store_false", help='display graphics on png files', dest="terminal")
|
||||
|
||||
options, args = parser.parse_args()
|
||||
|
||||
logger(options.verbose, options.output)
|
||||
|
||||
return options
|
||||
|
||||
options = parser()
|
||||
|
||||
def wait(str=None, prompt='Press return to show results...\n'):
|
||||
if str is not None:
|
||||
print str
|
||||
raw_input(prompt)
|
||||
|
||||
def draw2DRect(min=(0,0), max=(1,1), color='black', state=None, g=None):
|
||||
if g == None: g = Gnuplot.Gnuplot()
|
||||
if state != None: state.append(g)
|
||||
|
||||
xmin, ymin = min
|
||||
xmax, ymax = max
|
||||
|
||||
cmd = 'set arrow from %s,%s to %s,%s nohead lc rgb "%s"'
|
||||
|
||||
g(cmd % (xmin, ymin, xmin, ymax, color))
|
||||
g(cmd % (xmin, ymax, xmax, ymax, color))
|
||||
g(cmd % (xmax, ymax, xmax, ymin, color))
|
||||
g(cmd % (xmax, ymin, xmin, ymin, color))
|
||||
|
||||
return g
|
||||
|
||||
def draw3DRect(min=(0,0,0), max=(1,1,1), state=None, g=None):
|
||||
if g == None: g = Gnuplot.Gnuplot()
|
||||
if state != None: state.append(g)
|
||||
|
||||
# TODO
|
||||
|
||||
return g
|
||||
|
||||
def getSortedFiles(path):
|
||||
assert path != None
|
||||
|
||||
if options.files == '':
|
||||
|
||||
filelist = os.listdir(path)
|
||||
filelist.sort()
|
||||
|
||||
else:
|
||||
|
||||
filelist = options.files.split(',')
|
||||
|
||||
checkFileErrors(path, filelist)
|
||||
|
||||
return filelist
|
||||
|
||||
def checkFileErrors(path, filelist):
|
||||
for filename in filelist:
|
||||
for line in open('%s/%s' % (path, filename)):
|
||||
if '-nan' in line:
|
||||
logging.warning("checkFileErrors: %s/%s file contains bad value, it is going to be skipped" % (path, filename))
|
||||
filelist.remove(filename)
|
||||
break
|
||||
|
||||
def plotXPointYFitness(path, fields='3:1', state=None, g=None):
|
||||
if g == None:
|
||||
g = Gnuplot.Gnuplot()
|
||||
|
||||
if not options.terminal:
|
||||
g('set terminal png')
|
||||
g('set output \'%s/%s_%s.png\'' % (options.graphicsdirectory, options.graphicsprefixname, 'plotXPointYFitness'))
|
||||
|
||||
if state != None: state.append(g)
|
||||
|
||||
g.title('Fitness observation')
|
||||
g.xlabel('Coordinates')
|
||||
g.ylabel('Fitness (Quality)')
|
||||
|
||||
files=[]
|
||||
for filename in getSortedFiles(path):
|
||||
files.append(Gnuplot.File(path + '/' + filename, using=fields,
|
||||
with_='points',
|
||||
#title='distribution \'' + filename + '\''
|
||||
title=""
|
||||
)
|
||||
)
|
||||
|
||||
if len(files) > 0:
|
||||
g.plot(*files)
|
||||
|
||||
return g
|
||||
|
||||
def plotXYPointZFitness(path, fields='4:3:1', state=None, g=None):
|
||||
if g == None:
|
||||
g = Gnuplot.Gnuplot()
|
||||
|
||||
if not options.terminal:
|
||||
g('set terminal png')
|
||||
g('set output \'%s/%s_%s.png\'' % (options.graphicsdirectory, options.graphicsprefixname, 'plotXYPointZFitness'))
|
||||
|
||||
if state != None: state.append(g)
|
||||
|
||||
g.title('Fitness observation in 3-D')
|
||||
g.xlabel('x-axes')
|
||||
g.ylabel('y-axes')
|
||||
g.zlabel('Fitness (Quality)')
|
||||
|
||||
files=[]
|
||||
for filename in getSortedFiles(path):
|
||||
files.append(Gnuplot.File(path + '/' + filename, using=fields,
|
||||
with_='points',
|
||||
#title='distribution \'' + filename + '\''
|
||||
title=""
|
||||
)
|
||||
)
|
||||
|
||||
if len(files) > 0:
|
||||
g.splot(*files)
|
||||
|
||||
return g
|
||||
|
||||
def plotXYPoint(path, fields='3:4', state=None, g=None):
|
||||
if g == None:
|
||||
g = Gnuplot.Gnuplot()
|
||||
|
||||
if not options.terminal:
|
||||
g('set terminal png')
|
||||
g('set output \'%s/%s_%s.png\'' % (options.graphicsdirectory, options.graphicsprefixname, 'plotXYPoint'))
|
||||
|
||||
if state != None: state.append(g)
|
||||
|
||||
g.title('Points observation in 2-D')
|
||||
g.xlabel('x-axes')
|
||||
g.ylabel('y-axes')
|
||||
|
||||
files=[]
|
||||
for filename in getSortedFiles(path):
|
||||
files.append(Gnuplot.File(path + '/' + filename, using=fields,
|
||||
with_='points',
|
||||
#title='distribution \'' + filename + '\''
|
||||
title=""
|
||||
)
|
||||
)
|
||||
|
||||
if len(files) > 0:
|
||||
g.plot(*files)
|
||||
|
||||
return g
|
||||
|
||||
def plotXYZPoint(path, fields='3:4:5', state=None, g=None):
|
||||
if g == None:
|
||||
g = Gnuplot.Gnuplot()
|
||||
|
||||
if not options.terminal:
|
||||
g('set terminal png')
|
||||
g('set output \'%s/%s_%s.png\'' % (options.graphicsdirectory, options.graphicsprefixname, 'plotXYZPoint'))
|
||||
|
||||
if state != None: state.append(g)
|
||||
|
||||
g.title('Points observation in 3-D')
|
||||
g.xlabel('x-axes')
|
||||
g.ylabel('y-axes')
|
||||
g.zlabel('z-axes')
|
||||
|
||||
files=[]
|
||||
for filename in getSortedFiles(path):
|
||||
files.append(Gnuplot.File(path + '/' + filename, using=fields,
|
||||
with_='points',
|
||||
#title='distribution \'' + filename + '\''
|
||||
title=""
|
||||
)
|
||||
)
|
||||
|
||||
if len(files) > 0:
|
||||
g.splot(*files)
|
||||
|
||||
return g
|
||||
|
||||
def plotParams(path, field='1', state=None, g=None):
|
||||
if g == None:
|
||||
g = Gnuplot.Gnuplot()
|
||||
|
||||
if not options.terminal:
|
||||
g('set terminal png')
|
||||
g('set output \'%s/%s_%s.png\'' % (options.graphicsdirectory, options.graphicsprefixname, 'plotXYZPoint'))
|
||||
|
||||
if state != None: state.append(g)
|
||||
|
||||
g.title('Hyper-volume comparaison through all dimensions')
|
||||
g.xlabel('Iterations')
|
||||
g.ylabel('Hyper-volume')
|
||||
|
||||
g.plot(Gnuplot.File(path, with_='lines', using=field,
|
||||
title='multivariate distribution narrowing'))
|
||||
|
||||
return g
|
||||
|
||||
def plot2DRectFromFiles(path, state=None, g=None, plot=True):
|
||||
if g == None:
|
||||
g = Gnuplot.Gnuplot()
|
||||
|
||||
if not options.terminal:
|
||||
g('set terminal png')
|
||||
g('set output \'%s_%s.png\'' % (options.graphicsprefixname, 'plot2DRectFromFiles'))
|
||||
|
||||
if state != None: state.append(g)
|
||||
|
||||
g.title('Rectangle drawing observation')
|
||||
g.xlabel('x-axes')
|
||||
g.ylabel('y-axes')
|
||||
|
||||
x1,x2,y1,y2 = 0,0,0,0
|
||||
|
||||
colors = ['red', 'orange', 'blue', 'green', 'gold', 'yellow', 'gray']
|
||||
#colors = open('rgb.txt', 'r').readlines()
|
||||
colors_size = len(colors)
|
||||
i = 0 # for color
|
||||
|
||||
for filename in getSortedFiles(path):
|
||||
line = open(path + '/' + filename, 'r').readline()
|
||||
|
||||
fields = line.split(' ')
|
||||
|
||||
if not fields[0] == '2':
|
||||
print 'plot2DRectFromFiles: higher than 2 dimensions not possible to draw'
|
||||
return
|
||||
|
||||
xmin,ymin,xmax,ymax = fields[1:5]
|
||||
#print xmin,ymin,xmax,ymax
|
||||
|
||||
cur_color = colors[i % colors_size]
|
||||
|
||||
draw2DRect((xmin,ymin), (xmax,ymax), cur_color, g=g)
|
||||
|
||||
g('set obj rect from %s,%s to %s,%s back lw 1.0 fc rgb "%s" fillstyle solid 1.00 border -1'
|
||||
% (xmin,ymin,xmax,ymax,cur_color)
|
||||
)
|
||||
|
||||
if plot:
|
||||
if float(xmin) < x1: x1 = float(xmin)
|
||||
if float(ymin) < y1: y1 = float(ymin)
|
||||
if float(xmax) > x2: x2 = float(xmax)
|
||||
if float(ymax) > y2: y2 = float(ymax)
|
||||
|
||||
#print x1,y1,x2,y2
|
||||
|
||||
i += 1
|
||||
|
||||
#print x1,y1,x2,y2
|
||||
|
||||
if plot:
|
||||
g.plot('[%s:%s][%s:%s] -9999 notitle' % (x1, x2, y1, y2))
|
||||
|
||||
return g
|
||||
|
||||
def main():
|
||||
gstate = []
|
||||
|
||||
n = int(options.dimension)
|
||||
w = int(options.windowid)
|
||||
r = options.respop
|
||||
|
||||
if not options.terminal:
|
||||
try:
|
||||
os.mkdir(options.graphicsdirectory)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if options.multiplot:
|
||||
g = Gnuplot.Gnuplot()
|
||||
|
||||
if not options.terminal:
|
||||
g('set terminal png')
|
||||
g('set output \'%s/%s_%s.png\'' % (options.graphicsdirectory, options.graphicsprefixname, 'multiplot'))
|
||||
|
||||
g('set parametric')
|
||||
g('set nokey')
|
||||
g('set noxtic')
|
||||
g('set noytic')
|
||||
g('set noztic')
|
||||
|
||||
g('set size 1.0, 1.0')
|
||||
g('set origin 0.0, 0.0')
|
||||
g('set multiplot')
|
||||
|
||||
g('set size 0.5, 0.5')
|
||||
g('set origin 0.0, 0.5')
|
||||
|
||||
if n >= 1:
|
||||
plotXPointYFitness(r, state=gstate, g=g)
|
||||
|
||||
g('set size 0.5, 0.5')
|
||||
g('set origin 0.0, 0.0')
|
||||
|
||||
if n >= 2:
|
||||
plotXPointYFitness(r, '4:1', state=gstate, g=g)
|
||||
|
||||
g('set size 0.5, 0.5')
|
||||
g('set origin 0.5, 0.5')
|
||||
|
||||
if n >= 2:
|
||||
plotXYPointZFitness(r, state=gstate, g=g)
|
||||
|
||||
g('set size 0.5, 0.5')
|
||||
g('set origin 0.5, 0.0')
|
||||
|
||||
if n >= 2:
|
||||
plotXYPoint(r, state=gstate, g=g)
|
||||
elif n >= 3:
|
||||
plotXYZPoint(r, state=gstate, g=g)
|
||||
|
||||
g('set nomultiplot')
|
||||
|
||||
else:
|
||||
|
||||
if n >= 1 and w in [0, 1]:
|
||||
plotXPointYFitness(r, state=gstate)
|
||||
|
||||
if n >= 2 and w in [0, 2]:
|
||||
plotXPointYFitness(r, '4:1', state=gstate)
|
||||
|
||||
if n >= 2 and w in [0, 3]:
|
||||
plotXYPointZFitness(r, state=gstate)
|
||||
|
||||
if n >= 3 and w in [0, 4]:
|
||||
plotXYZPoint(r, state=gstate)
|
||||
|
||||
if n >= 2 and w in [0, 5]:
|
||||
plotXYPoint(r, state=gstate)
|
||||
|
||||
# if n >= 1:
|
||||
# plotParams('./ResParams.txt', state=gstate)
|
||||
|
||||
# if n >= 2:
|
||||
# plot2DRectFromFiles('./ResBounds', state=gstate)
|
||||
# plotXYPoint(r, state=gstate)
|
||||
|
||||
# g = plot2DRectFromFiles('./ResBounds', state=gstate, plot=False)
|
||||
# plotXYPoint(r, g=g)
|
||||
|
||||
if options.terminal:
|
||||
wait(prompt='Press return to end the plot.\n')
|
||||
|
||||
# when executed, just run main():
|
||||
if __name__ == '__main__':
|
||||
logging.debug('### plotting started ###')
|
||||
|
||||
main()
|
||||
|
||||
logging.debug('### plotting ended ###')
|
||||
27
edo/application/eda/CMakeLists.txt
Normal file
27
edo/application/eda/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
PROJECT(eda)
|
||||
|
||||
FIND_PACKAGE(Boost 1.33.0)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
|
||||
|
||||
SET(RESOURCES
|
||||
${PROJECT_NAME}.param
|
||||
)
|
||||
|
||||
FOREACH(file ${RESOURCES})
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${file}
|
||||
${EDO_BINARY_DIR}/${file}
|
||||
)
|
||||
ENDFOREACH(file)
|
||||
|
||||
FILE(GLOB SOURCES *.cpp)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${EDO_BINARY_DIR})
|
||||
|
||||
ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES})
|
||||
TARGET_LINK_LIBRARIES(${PROJECT_NAME} edo edoutils ${EO_LIBRARIES} ${MO_LIBRARIES} ${Boost_LIBRARIES})
|
||||
7
edo/application/eda/eda.param
Normal file
7
edo/application/eda/eda.param
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
--rho=0 # -p : <etropolis sample size
|
||||
--alpha=0 # -a : Temperature dicrease rate
|
||||
--threshold=0.1 # -t : Temperature threshold stopping criteria
|
||||
--sample-size=10 # -P : Sample size
|
||||
--dimension-size=10 # -d : Dimension size
|
||||
--temperature=100 # -T : Initial temperature
|
||||
#--verbose # Enable verbose mode
|
||||
315
edo/application/eda/main.cpp
Normal file
315
edo/application/eda/main.cpp
Normal file
|
|
@ -0,0 +1,315 @@
|
|||
/*
|
||||
The Evolving Distribution Objects framework (EDO) is a template-based,
|
||||
ANSI-C++ evolutionary computation library which helps you to write your
|
||||
own estimation of distribution algorithms.
|
||||
|
||||
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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Copyright (C) 2010 Thales group
|
||||
*/
|
||||
/*
|
||||
Authors:
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
|
||||
#include <utils/eoLogger.h>
|
||||
#include <utils/eoParserLogger.h>
|
||||
|
||||
#include <eoEvalFuncCounterBounder.h>
|
||||
|
||||
#include <do/make_pop.h>
|
||||
#include <do/make_run.h>
|
||||
#include <do/make_continue.h>
|
||||
#include <do/make_checkpoint.h>
|
||||
|
||||
#include <edo>
|
||||
|
||||
#include "Rosenbrock.h"
|
||||
#include "Sphere.h"
|
||||
|
||||
|
||||
typedef eoReal<eoMinimizingFitness> EOT;
|
||||
typedef edoNormalMulti< EOT > Distrib;
|
||||
|
||||
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
eoParserLogger parser(ac, av);
|
||||
|
||||
// Letters used by the following declarations:
|
||||
// a d i p t
|
||||
|
||||
std::string section("Algorithm parameters");
|
||||
|
||||
// FIXME: default value to check
|
||||
//double initial_temperature = parser.createParam((double)10e5, "temperature", "Initial temperature", 'i', section).value(); // i
|
||||
|
||||
eoState state;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Instantiate all needed parameters for EDA algorithm
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
double selection_rate = parser.createParam((double)0.5, "selection_rate", "Selection Rate", 'R', section).value(); // R
|
||||
|
||||
eoSelect< EOT >* selector = new eoDetSelect< EOT >( selection_rate );
|
||||
state.storeFunctor(selector);
|
||||
|
||||
edoEstimator< Distrib >* estimator = new edoEstimatorNormalMulti< EOT >();
|
||||
state.storeFunctor(estimator);
|
||||
|
||||
eoSelectOne< EOT >* selectone = new eoDetTournamentSelect< EOT >( 2 );
|
||||
state.storeFunctor(selectone);
|
||||
|
||||
edoModifierMass< Distrib >* modifier = new edoNormalMultiCenter< EOT >();
|
||||
state.storeFunctor(modifier);
|
||||
|
||||
eoEvalFunc< EOT >* plainEval = new Rosenbrock< EOT >();
|
||||
state.storeFunctor(plainEval);
|
||||
|
||||
unsigned long max_eval = parser.getORcreateParam((unsigned long)0, "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion").value(); // E
|
||||
eoEvalFuncCounterBounder< EOT > eval(*plainEval, max_eval);
|
||||
|
||||
eoRndGenerator< double >* gen = new eoUniformGenerator< double >(-5, 5);
|
||||
state.storeFunctor(gen);
|
||||
|
||||
|
||||
unsigned int dimension_size = parser.createParam((unsigned int)10, "dimension-size", "Dimension size", 'd', section).value(); // d
|
||||
|
||||
eoInitFixedLength< EOT >* init = new eoInitFixedLength< EOT >( dimension_size, *gen );
|
||||
state.storeFunctor(init);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// (1) Population init and sampler
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Generation of population from do_make_pop (creates parameters, manages persistance and so on...)
|
||||
// ... and creates the parameters: L P r S
|
||||
|
||||
// this first sampler creates a uniform distribution independently from our distribution (it does not use doUniform).
|
||||
|
||||
eoPop< EOT >& pop = do_make_pop(parser, state, *init);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// (2) First evaluation before starting the research algorithm
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
apply(eval, pop);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Prepare bounder class to set bounds of sampling.
|
||||
// This is used by doSampler.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
edoBounder< EOT >* bounder = new edoBounderRng< EOT >(EOT(pop[0].size(), -5),
|
||||
EOT(pop[0].size(), 5),
|
||||
*gen);
|
||||
state.storeFunctor(bounder);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Prepare sampler class with a specific distribution
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
edoSampler< Distrib >* sampler = new edoSamplerNormalMulti< EOT >( *bounder );
|
||||
state.storeFunctor(sampler);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Metropolis sample parameters
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//unsigned int popSize = parser.getORcreateParam((unsigned int)20, "popSize", "Population Size", 'P', "Evolution Engine").value();
|
||||
|
||||
//moContinuator< moDummyNeighbor<EOT> >* sa_continue = new moIterContinuator< moDummyNeighbor<EOT> >( popSize );
|
||||
//state.storeFunctor(sa_continue);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SA parameters
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//double threshold_temperature = parser.createParam((double)0.1, "threshold", "Minimal temperature at which stop", 't', section).value(); // t
|
||||
//double alpha = parser.createParam((double)0.1, "alpha", "Temperature decrease rate", 'a', section).value(); // a
|
||||
|
||||
//moCoolingSchedule<EOT>* cooling_schedule = new moSimpleCoolingSchedule<EOT>(initial_temperature, alpha, 0, threshold_temperature);
|
||||
//state.storeFunctor(cooling_schedule);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// stopping criteria
|
||||
// ... and creates the parameter letters: C E g G s T
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
eoContinue< EOT >& eo_continue = do_make_continue(parser, state, eval);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// population output
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
eoCheckPoint< EOT >& pop_continue = do_make_checkpoint(parser, state, eval, eo_continue);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// distribution output
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
edoDummyContinue< Distrib >* dummy_continue = new edoDummyContinue< Distrib >();
|
||||
state.storeFunctor(dummy_continue);
|
||||
|
||||
edoCheckPoint< Distrib >* distribution_continue = new edoCheckPoint< Distrib >( *dummy_continue );
|
||||
state.storeFunctor(distribution_continue);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoEPRemplacement causes the using of the current and previous
|
||||
// sample for sampling.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
eoReplacement< EOT >* replacor = new eoEPReplacement< EOT >(pop.size());
|
||||
|
||||
// Below, use eoGenerationalReplacement to sample only on the current sample
|
||||
|
||||
//eoReplacement< EOT >* replacor = new eoGenerationalReplacement< EOT >(); // FIXME: to define the size
|
||||
|
||||
state.storeFunctor(replacor);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Some stuff to display helper when we are using -h option
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
if (parser.userNeedsHelp())
|
||||
{
|
||||
parser.printHelp(std::cout);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Help + Verbose routines
|
||||
|
||||
make_verbose(parser);
|
||||
make_help(parser);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// population output (after helper)
|
||||
//
|
||||
// FIXME: theses objects are instanciate there in order to avoid a folder
|
||||
// removing as doFileSnapshot does within ctor.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
edoPopStat< EOT >* popStat = new edoPopStat<EOT>;
|
||||
state.storeFunctor(popStat);
|
||||
pop_continue.add(*popStat);
|
||||
|
||||
edoFileSnapshot* fileSnapshot = new edoFileSnapshot("EDA_ResPop");
|
||||
state.storeFunctor(fileSnapshot);
|
||||
fileSnapshot->add(*popStat);
|
||||
pop_continue.add(*fileSnapshot);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// distribution output (after helper)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
edoDistribStat< Distrib >* distrib_stat = new edoStatNormalMulti< EOT >();
|
||||
state.storeFunctor(distrib_stat);
|
||||
|
||||
distribution_continue->add( *distrib_stat );
|
||||
|
||||
// eoMonitor* stdout_monitor = new eoStdoutMonitor();
|
||||
// state.storeFunctor(stdout_monitor);
|
||||
// stdout_monitor->add(*distrib_stat);
|
||||
// distribution_continue->add( *stdout_monitor );
|
||||
|
||||
eoFileMonitor* file_monitor = new eoFileMonitor("eda_distribution_bounds.txt");
|
||||
state.storeFunctor(file_monitor);
|
||||
file_monitor->add(*distrib_stat);
|
||||
distribution_continue->add( *file_monitor );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// EDA algorithm configuration
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
edoAlgo< Distrib >* algo = new edoEDA< Distrib >
|
||||
(*selector, *estimator, *selectone, *modifier, *sampler,
|
||||
pop_continue, *distribution_continue,
|
||||
eval,
|
||||
//*sa_continue, *cooling_schedule, initial_temperature,
|
||||
*replacor);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Beginning of the algorithm call
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
try
|
||||
{
|
||||
do_run(*algo, pop);
|
||||
}
|
||||
catch (eoEvalFuncCounterBounderException& e)
|
||||
{
|
||||
eo::log << eo::warnings << "warning: " << e.what() << std::endl;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
eo::log << eo::errors << "error: " << e.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
27
edo/application/eda_sa/CMakeLists.txt
Normal file
27
edo/application/eda_sa/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
PROJECT(eda_sa)
|
||||
|
||||
FIND_PACKAGE(Boost 1.33.0)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
|
||||
|
||||
SET(RESOURCES
|
||||
${PROJECT_NAME}.param
|
||||
)
|
||||
|
||||
FOREACH(file ${RESOURCES})
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${file}
|
||||
${EDO_BINARY_DIR}/${file}
|
||||
)
|
||||
ENDFOREACH(file)
|
||||
|
||||
FILE(GLOB SOURCES *.cpp)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${EDO_BINARY_DIR})
|
||||
|
||||
ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES})
|
||||
TARGET_LINK_LIBRARIES(${PROJECT_NAME} edo edoutils ${EO_LIBRARIES} ${MO_LIBRARIES} ${Boost_LIBRARIES})
|
||||
7
edo/application/eda_sa/eda_sa.param
Normal file
7
edo/application/eda_sa/eda_sa.param
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
--rho=0 # -p : <etropolis sample size
|
||||
--alpha=0 # -a : Temperature dicrease rate
|
||||
--threshold=0.1 # -t : Temperature threshold stopping criteria
|
||||
--sample-size=10 # -P : Sample size
|
||||
--dimension-size=10 # -d : Dimension size
|
||||
--temperature=100 # -T : Initial temperature
|
||||
#--verbose # Enable verbose mode
|
||||
287
edo/application/eda_sa/main.cpp
Normal file
287
edo/application/eda_sa/main.cpp
Normal file
|
|
@ -0,0 +1,287 @@
|
|||
#include <eo>
|
||||
#include <mo>
|
||||
|
||||
#include <utils/eoLogger.h>
|
||||
#include <utils/eoParserLogger.h>
|
||||
|
||||
#include <eoEvalFuncCounterBounder.h>
|
||||
|
||||
#include <do/make_pop.h>
|
||||
#include <do/make_run.h>
|
||||
#include <do/make_continue.h>
|
||||
#include <do/make_checkpoint.h>
|
||||
|
||||
#include <edo>
|
||||
|
||||
#include "Rosenbrock.h"
|
||||
#include "Sphere.h"
|
||||
|
||||
|
||||
typedef eoReal<eoMinimizingFitness> EOT;
|
||||
typedef edoNormalMulti< EOT > Distrib;
|
||||
|
||||
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
eoParserLogger parser(ac, av);
|
||||
|
||||
// Letters used by the following declarations:
|
||||
// a d i p t
|
||||
|
||||
std::string section("Algorithm parameters");
|
||||
|
||||
// FIXME: default value to check
|
||||
double initial_temperature = parser.createParam((double)10e5, "temperature", "Initial temperature", 'i', section).value(); // i
|
||||
|
||||
eoState state;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Instantiate all needed parameters for EDASA algorithm
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
double selection_rate = parser.createParam((double)0.5, "selection_rate", "Selection Rate", 'R', section).value(); // R
|
||||
|
||||
eoSelect< EOT >* selector = new eoDetSelect< EOT >( selection_rate );
|
||||
state.storeFunctor(selector);
|
||||
|
||||
edoEstimator< Distrib >* estimator = new edoEstimatorNormalMulti< EOT >();
|
||||
state.storeFunctor(estimator);
|
||||
|
||||
eoSelectOne< EOT >* selectone = new eoDetTournamentSelect< EOT >( 2 );
|
||||
state.storeFunctor(selectone);
|
||||
|
||||
edoModifierMass< Distrib >* modifier = new edoNormalMultiCenter< EOT >();
|
||||
state.storeFunctor(modifier);
|
||||
|
||||
eoEvalFunc< EOT >* plainEval = new Rosenbrock< EOT >();
|
||||
state.storeFunctor(plainEval);
|
||||
|
||||
unsigned long max_eval = parser.getORcreateParam((unsigned long)0, "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion").value(); // E
|
||||
eoEvalFuncCounterBounder< EOT > eval(*plainEval, max_eval);
|
||||
|
||||
eoRndGenerator< double >* gen = new eoUniformGenerator< double >(-5, 5);
|
||||
state.storeFunctor(gen);
|
||||
|
||||
|
||||
unsigned int dimension_size = parser.createParam((unsigned int)10, "dimension-size", "Dimension size", 'd', section).value(); // d
|
||||
|
||||
eoInitFixedLength< EOT >* init = new eoInitFixedLength< EOT >( dimension_size, *gen );
|
||||
state.storeFunctor(init);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// (1) Population init and sampler
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Generation of population from do_make_pop (creates parameters, manages persistance and so on...)
|
||||
// ... and creates the parameters: L P r S
|
||||
|
||||
// this first sampler creates a uniform distribution independently from our distribution (it does not use doUniform).
|
||||
|
||||
eoPop< EOT >& pop = do_make_pop(parser, state, *init);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// (2) First evaluation before starting the research algorithm
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
apply(eval, pop);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Prepare bounder class to set bounds of sampling.
|
||||
// This is used by doSampler.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
edoBounder< EOT >* bounder = new edoBounderRng< EOT >(EOT(pop[0].size(), -5),
|
||||
EOT(pop[0].size(), 5),
|
||||
*gen);
|
||||
state.storeFunctor(bounder);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Prepare sampler class with a specific distribution
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
edoSampler< Distrib >* sampler = new edoSamplerNormalMulti< EOT >( *bounder );
|
||||
state.storeFunctor(sampler);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Metropolis sample parameters
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
unsigned int popSize = parser.getORcreateParam((unsigned int)20, "popSize", "Population Size", 'P', "Evolution Engine").value();
|
||||
|
||||
moContinuator< moDummyNeighbor<EOT> >* sa_continue = new moIterContinuator< moDummyNeighbor<EOT> >( popSize );
|
||||
state.storeFunctor(sa_continue);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SA parameters
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
double threshold_temperature = parser.createParam((double)0.1, "threshold", "Minimal temperature at which stop", 't', section).value(); // t
|
||||
double alpha = parser.createParam((double)0.1, "alpha", "Temperature decrease rate", 'a', section).value(); // a
|
||||
|
||||
moCoolingSchedule<EOT>* cooling_schedule = new moSimpleCoolingSchedule<EOT>(initial_temperature, alpha, 0, threshold_temperature);
|
||||
state.storeFunctor(cooling_schedule);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// stopping criteria
|
||||
// ... and creates the parameter letters: C E g G s T
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
eoContinue< EOT >& eo_continue = do_make_continue(parser, state, eval);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// population output
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
eoCheckPoint< EOT >& pop_continue = do_make_checkpoint(parser, state, eval, eo_continue);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// distribution output
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
edoDummyContinue< Distrib >* dummy_continue = new edoDummyContinue< Distrib >();
|
||||
state.storeFunctor(dummy_continue);
|
||||
|
||||
edoCheckPoint< Distrib >* distribution_continue = new edoCheckPoint< Distrib >( *dummy_continue );
|
||||
state.storeFunctor(distribution_continue);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoEPRemplacement causes the using of the current and previous
|
||||
// sample for sampling.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
eoReplacement< EOT >* replacor = new eoEPReplacement< EOT >(pop.size());
|
||||
|
||||
// Below, use eoGenerationalReplacement to sample only on the current sample
|
||||
|
||||
//eoReplacement< EOT >* replacor = new eoGenerationalReplacement< EOT >(); // FIXME: to define the size
|
||||
|
||||
state.storeFunctor(replacor);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Some stuff to display helper when we are using -h option
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
if (parser.userNeedsHelp())
|
||||
{
|
||||
parser.printHelp(std::cout);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Help + Verbose routines
|
||||
|
||||
make_verbose(parser);
|
||||
make_help(parser);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// population output (after helper)
|
||||
//
|
||||
// FIXME: theses objects are instanciate there in order to avoid a folder
|
||||
// removing as edoFileSnapshot does within ctor.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
edoPopStat< EOT >* popStat = new edoPopStat<EOT>;
|
||||
state.storeFunctor(popStat);
|
||||
pop_continue.add(*popStat);
|
||||
|
||||
edoFileSnapshot* fileSnapshot = new edoFileSnapshot("EDASA_ResPop");
|
||||
state.storeFunctor(fileSnapshot);
|
||||
fileSnapshot->add(*popStat);
|
||||
pop_continue.add(*fileSnapshot);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// distribution output (after helper)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
edoDistribStat< Distrib >* distrib_stat = new edoStatNormalMulti< EOT >();
|
||||
state.storeFunctor(distrib_stat);
|
||||
|
||||
distribution_continue->add( *distrib_stat );
|
||||
|
||||
// eoMonitor* stdout_monitor = new eoStdoutMonitor();
|
||||
// state.storeFunctor(stdout_monitor);
|
||||
// stdout_monitor->add(*distrib_stat);
|
||||
// distribution_continue->add( *stdout_monitor );
|
||||
|
||||
eoFileMonitor* file_monitor = new eoFileMonitor("eda_sa_distribution_bounds.txt");
|
||||
state.storeFunctor(file_monitor);
|
||||
file_monitor->add(*distrib_stat);
|
||||
distribution_continue->add( *file_monitor );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// EDASA algorithm configuration
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
edoAlgo< Distrib >* algo = new edoEDASA< Distrib >
|
||||
(*selector, *estimator, *selectone, *modifier, *sampler,
|
||||
pop_continue, *distribution_continue,
|
||||
eval, *sa_continue, *cooling_schedule,
|
||||
initial_temperature, *replacor);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Beginning of the algorithm call
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
try
|
||||
{
|
||||
do_run(*algo, pop);
|
||||
}
|
||||
catch (eoEvalFuncCounterBounderException& e)
|
||||
{
|
||||
eo::log << eo::warnings << "warning: " << e.what() << std::endl;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
eo::log << eo::errors << "error: " << e.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in a new issue