MemoizeEvaluation

class MemoizeEvaluation(*args)

Evaluation which keeps tracks of input and output.

Usually we use MemoizeFunction (aa function provides both the evaluation, the gradient and the hessian). that relies on a Function passed as argument, and store input and output Sample. It also has a caching behavior, enabled by default.

Parameters:
functionEvaluation

Delegate evaluation

historyStrategyHistoryStrategy (optional)

Strategy used to store points, default is Full.

Examples

>>> import openturns as ot
>>> f = ot.SymbolicEvaluation(['x'], ['y'], ['x^2'])
>>> inputSample = ot.Sample([[1], [2], [3], [4]])
>>> f = ot.MemoizeEvaluation(f)
>>> outputSample = f(inputSample)

Retrieve input sample:

>>> print(f.getInputHistory())
0 : [ 1 ]
1 : [ 2 ]
2 : [ 3 ]
3 : [ 4 ]

Retrieve output sample:

>>> print(f.getOutputHistory())
0 : [  1 ]
1 : [  4 ]
2 : [  9 ]
3 : [ 16 ]

Methods

addCacheContent(inSample, outSample)

Add input and output points to the cache.

clearCache()

Empty the content of the cache.

clearHistory()

Clear input and output history.

disableCache()

Disable the cache.

disableHistory()

Disable the history.

enableCache()

Enable the cache.

enableHistory()

Enable the history.

getCacheHits()

Accessor to the number of computations saved thanks to the cache.

getCacheInput()

Accessor to the input points stored in the cache.

getCacheOutput()

Accessor to the output points stored in the cache.

getClassName()

Accessor to the object's name.

getInputHistory()

Get the input sample history.

getMarginal(*args)

Accessor to marginal.

getOutputHistory()

Get the output sample history.

isCacheEnabled()

Test whether the cache is enabled or not.

isHistoryEnabled()

Test whether the history is enabled or not.

setEvaluation(evaluation)

Set the evaluation.

getEvaluation

__init__(*args)
addCacheContent(inSample, outSample)

Add input and output points to the cache.

Parameters:
input_sample2-d sequence of float

Input points to be added to the cache.

output_sample2-d sequence of float

Output points associated with the input_sample to be added to the cache.

clearCache()

Empty the content of the cache.

clearHistory()

Clear input and output history.

disableCache()

Disable the cache.

disableHistory()

Disable the history.

enableCache()

Enable the cache.

enableHistory()

Enable the history.

getCacheHits()

Accessor to the number of computations saved thanks to the cache.

Returns:
cacheHitsint

Integer that counts the number of computations saved thanks to the cache.

getCacheInput()

Accessor to the input points stored in the cache.

Returns:
cacheInputSample

The input points stored in the cache.

getCacheOutput()

Accessor to the output points stored in the cache.

Returns:
cacheInputSample

The output points stored in the cache.

getClassName()

Accessor to the object’s name.

Returns:
class_namestr

The object class name (object.__class__.__name__).

getInputHistory()

Get the input sample history.

Returns:
inputSampleSample

Input points which have been evaluated.

getMarginal(*args)

Accessor to marginal.

Parameters:
indicesint or list of ints

Set of indices for which the marginal is extracted.

Returns:
marginalFunction

Function corresponding to either f_i or (f_i)_{i \in indices}, with f:\Rset^n \rightarrow \Rset^p and f=(f_0 , \dots, f_{p-1}).

getOutputHistory()

Get the output sample history.

Returns:
outputSampleSample

Output points which have been evaluated.

isCacheEnabled()

Test whether the cache is enabled or not.

Returns:
isCacheEnabledbool

Flag telling whether the cache is enabled. It is enabled by default.

isHistoryEnabled()

Test whether the history is enabled or not.

Returns:
isHistoryEnabledbool

Flag telling whether the history is enabled.

setEvaluation(evaluation)

Set the evaluation.

Parameters:
evaluationEvaluation

Evaluation.

Notes

This sets a new evaluation of interest. Cache and history are cleaned and the class will stores new one accounting for the given evaluation and store input and output Sample. It also has a caching behavior, enabled by default.