Penalty Function Spec
Serializable selection of a penalty function used by an optimization problem to penalize constraint violations.
Mirrors the two engine implementations of ksl.simopt.problem.PenaltyFunctionIfc that are constructed from plain data and therefore can round-trip through JSON/TOML:
WithMemory — mirrors ksl.simopt.problem.PenaltyFunctionWithMemory, whose memory factor dampens stochastic noise by scaling with the inverse square root of the response sample count;
DynamicPolynomial — mirrors ksl.simopt.problem.DynamicPolynomialPenalty, a polynomial penalty that grows with both the violation magnitude and the iteration counter.
The ksl.simopt.problem.PenaltyFunctionIfc interface itself is a fun interface and so cannot be persisted in general; only the two concrete data-only implementations have a serializable representation.
Sealed-class polymorphic serialization is used: the JSON/TOML output carries a "type" discriminator with values "withMemory" or "dynamicPolynomial".