hpp.corbaserver.benchmark.Benchmark Class Reference

class to do benchmarking More...

Inheritance diagram for hpp.corbaserver.benchmark.Benchmark:
[legend]
Collaboration diagram for hpp.corbaserver.benchmark.Benchmark:
[legend]

Public Member Functions

def __init__ (self, client, robot, problemSolver)
 
def do
 Solve the same problem for the specified cases, for various random seed. More...
 
def getCase (self, iter)
 
def writeResume (self, filename=None)
 Write data to file. More...
 
def tryResumeAndDelete (self, filename=None)
 In case of crash of HPP, the benchmark class writes temporary datas to a file. More...
 
def resumeFrom (self, fname)
 
def plotTime (self, axes)
 
def plotPathLength (self, axes)
 
def writeDatabase (self, nameDatabase, experimentName='default', nameLogFile='temp.log', append=False)
 This method create a database which store the benchmark results. More...
 
def __str__ (self)
 

Public Attributes

 seedRange
 A list of seed to initialize the random generator. More...
 
 cases
 A list of cases for which benchmarking will be done. More...
 
 iterPerCase
 Number of times one case is repeated (for one seed). More...
 
 client
 
 robot
 
 ps
 
 current
 
 results
 

Static Public Attributes

 toSeconds = np.array([60*60,60,1,1e-3])
 Used to transform HPP output into seconds. More...
 
string crashFile = "/tmp/resume.hpp.corbaserver.benchmark.pickle"
 The filename of the crash file. More...
 

Detailed Description

class to do benchmarking

Basic usage

1 # Here goes your script to load the problem.
2 robot = hpp.corbaserver.robot.Robot (...)
4 ...
5 
6 from hpp.corbaserver import Benchmark
7 benchmark = Benchmark (robot.client, robot, ps)
8 benchmark.iterPerCase = 10
9 results = benchmark.do()
See also
hpp.corbaserver.benchmark.Benchmark.do hpp.corbaserver.benchmark.Benchmark.seedRange

If you wish to replot datas stored in a file:

1 from hpp.corbaserver import Benchmark
2 import matplotlib.pyplot as plt
3 b = Benchmark (None, None, None)
4 b.resumeFrom ("datafile")
5 
6 fig, axes = plt.subplots(nrows=1, ncols=2)
7 b.plotTime (axes[0])
8 b.plotPathLength (axes[1])
9 plt.show ()
See also
hpp.corbaserver.benchmark.Benchmark.plotTime hpp.corbaserver.benchmark.Benchmark.plotPathLength

Advanced usage

1 from hpp.corbaserver import Benchmark
2 b = Benchmark (robot.client, robot, ps)
3 b.seedRange = range (10)
4 b.iterPerCase = 10
5 
6 b.cases = list()
7 for type in ["Progressive", "Global"]:
8  for param in [0.1, 0.2]:
9  b.cases.append((type,param))
10 b.cases.append(("None",0.1))
11 
12 b.tryResumeAndDelete ()
13 
14 def initialize (bench, case, iter):
15  bench.ps.selectPathProjector (case[0], case[1])
16 
17 results = b.do(initCase = initialize)
See also
hpp.corbaserver.benchmark.Benchmark.cases hpp.corbaserver.benchmark.Benchmark.iterPerCase hpp.corbaserver.benchmark.Benchmark.tryResumeAndDelete

What if HPP crashes

Note
This section assumes you have installed https://github.com/humanoid-path-planner/hpp-tools

You can do the following

1 try:
2  b.do ()
3 except:
4  import sys
5  sys.exit(1)
6 
7 b.writeResume (filename = "yourresults")

Then, launch your server with this:

1 hppautorestart hppcorbaserver

Finally, launch your script with this:

1 hpp_run_benchmark path_to_python_script_file.py

This will restart the server whenever it crashes and will resume the benchmarks where it stopped.

Constructor & Destructor Documentation

def hpp.corbaserver.benchmark.Benchmark.__init__ (   self,
  client,
  robot,
  problemSolver 
)

Member Function Documentation

def hpp.corbaserver.benchmark.Benchmark.__str__ (   self)

References hpp.corbaserver.benchmark.Benchmark._printStats(), hpp.corbaserver.benchmark.Benchmark.results, and hpp.corbaserver.benchmark.Benchmark.toSeconds.

def hpp.corbaserver.benchmark.Benchmark.do (   self,
  initCase = lambda this,
  case,
  iter 
)

Solve the same problem for the specified cases, for various random seed.

Parameters
initCasea function of 3 arguments:
  • the calling Benchmark instance
  • the current element of the list of Benchmark.cases
  • the current _BenchmarkIterator (Normally not useful).

References hpp.corbaserver.benchmark.Benchmark.cases, hpp.corbaserver.benchmark.Benchmark.current, hpp.corbaserver.benchmark.Benchmark.getCase(), hpp.corbaserver.benchmark.Benchmark.iterPerCase, hpp.corbaserver.benchmark.Benchmark.results, hpp.corbaserver.benchmark.Benchmark.seedRange, hpp.corbaserver.benchmark.Benchmark.toSeconds, and hpp.corbaserver.benchmark.Benchmark.writeResume().

def hpp.corbaserver.benchmark.Benchmark.getCase (   self,
  iter 
)
def hpp.corbaserver.benchmark.Benchmark.plotPathLength (   self,
  axes 
)
def hpp.corbaserver.benchmark.Benchmark.tryResumeAndDelete (   self,
  filename = None 
)

In case of crash of HPP, the benchmark class writes temporary datas to a file.

The method will check if the crash file exists and:

  • if it exists, the benchmarking will be initialized at the state before the crash. No datas are lost. The crash file is deleted after having been loaded.
  • if it does not exist, the method does nothing.
    Parameters
    filenameif None, it uses member Benchmark.crashFile

References hpp.corbaserver.benchmark.Benchmark.crashFile, and hpp.corbaserver.benchmark.Benchmark.resumeFrom().

def hpp.corbaserver.benchmark.Benchmark.writeDatabase (   self,
  nameDatabase,
  experimentName = 'default',
  nameLogFile = 'temp.log',
  append = False 
)

This method create a database which store the benchmark results.

You can then use it in the platform http://plannerarena.org/ to plot your results.

Parameters
nameDatabasethe name of the created file (extension must be in .db)
experimentNamethe name of the current scenario/problem (used when you append several scenario in the same database)
nameLogFilethe name of the text file writed
appendif True, the current result will be added in the given database.

References hpp.corbaserver.benchmark.Benchmark.cases, hpp.corbaserver.benchmark.Benchmark.iterPerCase, hpp.corbaserver.benchmark.Benchmark.results, hpp.corbaserver.benchmark.Benchmark.seedRange, and hpp.corbaserver.benchmark.Benchmark.toSeconds.

Member Data Documentation

hpp.corbaserver.benchmark.Benchmark.client
string hpp.corbaserver.benchmark.Benchmark.crashFile = "/tmp/resume.hpp.corbaserver.benchmark.pickle"
static
hpp.corbaserver.benchmark.Benchmark.ps
hpp.corbaserver.benchmark.Benchmark.robot
hpp.corbaserver.benchmark.Benchmark.toSeconds = np.array([60*60,60,1,1e-3])
static