idaholab / raven

RAVEN is a flexible and multi-purpose probabilistic risk analysis, validation and uncertainty quantification, parameter optimization, model reduction and data knowledge-discovering framework.
https://raven.inl.gov/
Apache License 2.0
219 stars 133 forks source link

[TASK] Constraints for Samplers #2351

Open sprapp-inl opened 2 months ago

sprapp-inl commented 2 months ago

Issue Description

Is your feature request related to a problem? Please describe.

At the moment, it appears to be impossible to constrain the input space from a sampler (Monte Carlo, for example) using a constraint function like the ones possible in optimizers.

Describe the solution you'd like

Additional optional fields to specify constraint functions (\) or implicit constraint functions (\) for use in Samplers where the inclusion of constraints would be applicable should the user need it. These would operate in the same way as the constraints for sampling input space for optimizers.

Describe alternatives you've considered

At the moment, the only features considered have been variable sampling functions or a Custom Sampling strategy, but the use of these relies on the user to provide a lot more data, where RAVEN could generate it automatically. A partial workaround is included below.


Example

As an example of the problem, the initialization of a Genetic Algorithm optimizer samples the input space of all variables using a sampler that is pulled from outside the optimizer for the first generation. This results in any defined constraints in the Genetic Algorithm optimizer to be ignored and a possibility that a portion of the initial population falls outside constraints, reducing diversity.

An example where 3 independent variables are constrained by their sum (the sum does not need to be sampled in RAVEN so a sampling function would be inapplicable):

This constraint is trivial to apply when sampled from within the optimizer, however the initial generation does not use the defined constraints if provided.

I do not know who would be best suited to be assigned to this, so I'm mentioning the following according to the contributing guidelines: @wangcj05 @PaulTalbot-INL @mandd


For Change Control Board: Issue Review

This review should occur before any development is performed as a response to this issue.


For Change Control Board: Issue Closure

This review should occur when the issue is imminently going to be closed.

PaulTalbot-INL commented 2 months ago

Hm, this is a good point. While I don't generally think most samplers can make good use of constraints when being used for statistical workflows, certainly if a sampler is used to prepopulate an optimizer, that sampler should follow the same constraints that we impose on the optimization itself. Good point!