Resample when a point is out-of-bounds#11
Conversation
| self | ||
| } | ||
|
|
||
| /// Changes the bounds from the defalt value. Vector length must match the number of dimensions. |
There was a problem hiding this comment.
This condition should be checked in CMAES::new, and can you add a test for it as well? Also, minor typo: defalt -> default.
There was a problem hiding this comment.
Hm, when I go the dyn Constraints way, this will not be possible anymore. We don't know what the concrete Constraints require. I could probably try to downcast do Bounds specifically, but that would be a code smell I think.
What do you think?
There was a problem hiding this comment.
A clean way to verify constraints would be adding a method like fn are_constraints_valid(&CMAESOptions) -> bool to Constraints and calling it in CMAES::new. I'm fine with leaving this out for now because the code providing the constraints can ensure their validity.
|
Thanks for the PR! I left some minor comments, and can you also run rustfmt? This feature is definitely useful, and the implementation looks good as well. I'm wondering though if it would be better to generalize trait Constraints {
fn meets_constraints(x: &DVector<f64>) -> bool;
}
|
|
Went the |
|
Looks great! I left one more comment, but I'll merge this as soon as it's resolved. |
4d6f94f to
66c52d1
Compare
|
Squashed the fixups. |
|
Thanks! |
Adds resampling to keep points within defined bounds. Compared to other constraint-handling methods, this can speed up convergence significantly. It's not a one-size-fits-all solution, however.
Also supports a resampling limit in order to not get stuck resampling on the boundary's edges.