3.12.1. Optimization History

class History(file=None, start=0)

History helper class for logging of x, fx, t (rel. time of addition) during an optimization and processing. Can be used to load saved history files produced by the Logger.

add(x: Sequence[float], fx: float)

Add a new tuple of (x, f(x)) to the history. This is done automatically by the Logger class.

__getitem__(index)

Get the history entry at index. Each entry has the attributes x and fx.

__len__()

Get the total number of history entries

__iter__()

Iterate over history entries

min()

Return the entry with the lowest fx in this instance

max()

Return the entry with the highest fx in this instance

x

Return a 2d array of x for all entries in this instance.

fx

Return a 1d array of fx for all entries in this instance.

t

Return a 1d array of t relative times for all entries in this instance.

sorted() → Tuple[numpy.ndarray, numpy.ndarray]

Returns the x, fx tuple sorted by the latter

write(fpath)

Write all history entries to fpath. The per line write order is
index fx x

load(fpath)

Load entries from fpath.