Petri.Adaptation (petri v0.4.0)

Copy Markdown View Source

Adaptive parameter resolution for the engine.

A rate field in a config can hold a constant, a function of the generation, or a decay strategy tuple. resolve/2 returns the number to use for a given generation. The two factories build the built-in decay strategies; the tuples are sugar for them.

Summary

Functions

Builds an exponential decay starting at start, multiplied by rate each generation, never dropping below min_val.

Builds a linear decay from start to finish over max_gen generations. The value stays at finish once max_gen is passed.

Returns the parameter value for generation.

Resolves the adaptive fields of config for generation, returning a config with numbers in place of functions and decay tuples. Fields holding constants pass through unchanged, and fields absent from the config (gaussian_sigma on encodings without it) are left alone.

Functions

exponential_decay(start, min_val, rate)

Builds an exponential decay starting at start, multiplied by rate each generation, never dropping below min_val.

linear_decay(start, finish, max_gen)

Builds a linear decay from start to finish over max_gen generations. The value stays at finish once max_gen is passed.

resolve(value, generation)

Returns the parameter value for generation.

Constants pass through unchanged, functions are called with the generation, and decay strategy tuples expand through their factory.

resolve_config(generation, config)

Resolves the adaptive fields of config for generation, returning a config with numbers in place of functions and decay tuples. Fields holding constants pass through unchanged, and fields absent from the config (gaussian_sigma on encodings without it) are left alone.