Skip to content

Can I add roll as a custom unary operator #426

Answered by MilesCranmer
breakds asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @breakds,

All operators are only defined on 1 or 2 real numbers. So you cannot, by default, define operators on vectors like in your example.

However, this is possible by writing your own custom evaluation scheme. Take a look at https://astroautomata.com/PySR/api/#the-objective for an example, and also https://astroautomata.com/PySR/backend/ for info about customizing behavior.

You would essentially need to write a custom eval_tree_array that can handle roll.

Basically, you would edit _eval_tree_array in DynamicExpressions.jl to be (copying from https://github.com/SymbolicML/DynamicExpressions.jl/blob/46388518281b0be12479afcb3a3b8bdabc361ccd/src/EvaluateEquation.jl and then simplifying)

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by breakds
Comment options

You must be logged in to vote
3 replies
@MilesCranmer
Comment options

@MilesCranmer
Comment options

@breakds
Comment options

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