ema workbench

Other Sub Sites

util

Created on 13 jan. 2011

Code author: jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl>

This module provides various convenience functions and classes.

util.load_results(file_name, zipped=True)

load the specified bz2 file. the file is assumed to be saves using save_results.

Parameters:
  • file – the path of the file
  • zipped – load the pickled data from a zip file if True
Returns:

the unpickled results

Raises :

IOError if file not found

util.save_results(results, file_name, zipped=True)

save the results to the specified bz2 file. To facilitate transfer across different machines. the files are saved in binary format

see also: http://projects.scipy.org/numpy/ticket/1284

Parameters:
  • results – the return of run_experiments
  • file – the path of the file
  • zipped – save the pickled data to a zip file if True
Raises :

IOError if file not found

util.save_optimization_results(results, file_name, zipped=True)

save the results to the specified bz2 file. To facilitate transfer across different machines. the files are saved in binary format

see also: http://projects.scipy.org/numpy/ticket/1284

Parameters:
  • results – the return of run_experiments
  • file – the path of the file
  • zipped – save the pickled data to a zip file if True
Raises :

IOError if file not found

util.load_optimization_results(file_name, weights, zipped=True)

load the specified bz2 file. the file is assumed to be saves using save_results.

Parameters:
  • file – the path of the file
  • zipped – load the pickled data from a zip file if True
Returns:

the unpickled results

Raises :

IOError if file not found

Raises :

EMAError if weights are not correct

util.experiments_to_cases(experiments)

This function transform a structured experiments array into a list of case dicts. This can then for example be used as an argument for running perform_experiments().

Parameters:experiments – a structured array containing experiments
Returns:a list of case dicts.
util.merge_results(results1, results2, downsample=None)

convenience function for merging the return from perform_experiments().

The function merges results2 with results1. For the experiments, it generates an empty array equal to the size of the sum of the experiments. As dtype is uses the dtype from the experiments in results1. The function assumes that the ordering of dtypes and names is identical in both results.

A typical use case for this function is in combination with experiments_to_cases(). Using experiments_to_cases() one extracts the cases from a first set of experiments. One then performs these cases on a different model or policy, and then one wants to merge these new results with the old result for further analysis.

Parameters:
  • results1 – first results to be merged
  • results2 – second results to be merged
  • downsample – should be an integer, will be used in slicing the results in order to avoid memory problems.
Returns:

the merged results