Skip to content

Constraints on operators within each function within TemplateExpressionSpec #786

Answered by MilesCranmer
Andrea-gm asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks @Andrea-gm. Right now there is no built-in way to do this. But if you are willing to get your hands dirty, you could hack it in? You can overload the function https://github.com/MilesCranmer/SymbolicRegression.jl/blob/433669068acf9d285deacb1dfa7912f739f14112/src/TemplateExpression.jl#L489-L513 for your particular expression type. I guess since this is a very specific constraint, it might just be easier to write up a constraint manually?

For example:

using SymbolicRegression: TemplateExpression, TemplateStructure, AbstractOptions, compute_complexity, get_contents
using SymbolicRegression.TemplateExpressionModule: has_invalid_variables

# Overload the behavior of check_constraints:
i…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Andrea-gm
Comment options

Answer selected by Andrea-gm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
PySR PySR-related discussion SymbolicRegression.jl SymbolicRegression.jl-related discussion
2 participants