close

open override fun close()(source)

End of life, not end of experiment.

The element does not call this at afterExperiment(), and the first version did — which meant a model simulated twice ran its second experiment against a policy whose resources had already been released, with no error and no sign in the output. Measured on a two-run, two- replication model: the policy was closed after run 1 and then used twelve more times. Repeated evaluation of one model is not an exotic case; it is what a parameter sweep and simulation optimization (B.5) both do.

The element closes only what the element opened (§4.7). It opens a sink, through the factory at beforeExperiment(), so it closes the sink. It never opened the policy — the user constructed it and assigned it — so the only moment it closes one is when that policy is replaced, which is the user saying they are finished with it here. The last policy assigned is the user's to close, exactly as WelchFileObserver is (observers/welch/WelchFileObserver.kt:100, whose own close is documented "Call when done with the observer. Idempotent.").

Implementations should be idempotent, for the same reason that one is.