-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Algebra for AbstractExpression
objects; and StructuredExpression
#92
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
2 similar comments
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Pull Request Test Coverage Report for Build 9799648670Details
💛 - Coveralls |
1 similar comment
Pull Request Test Coverage Report for Build 9799648670Details
💛 - Coveralls |
MilesCranmer
force-pushed
the
multi-expressions
branch
from
July 26, 2024 21:02
3786f59
to
55ae519
Compare
Pull Request Test Coverage Report for Build 10126841842Details
💛 - Coveralls |
MilesCranmer
force-pushed
the
multi-expressions
branch
from
July 27, 2024 22:16
76eeb84
to
59b26bc
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Algebra for
AbstractExpression
objectsThis lets you create new expressions with regular mathematical operators. Unlike the equivalent interface for
Node <: AbstractExpressionNode
, this does not rely on the admittedly hacky globalLATEST_OPERATORS
, but on the actual internal operators stored in the expression. Thus, this is much more robust.For example, say we create two expressions,
f
andg
, viaparse_expression
:we can compose these using any of the declared operators, into a new expression type:
Note that this requires the type of the expression to be identical for this to work. So, for example, since
OperatorEnum
types the functions, each expression much have a priori declared the right operators!This also means you can't use operators outside the enum:
StructuredExpression
This also introduces a
StructuredExpression
, which builds on the above point. It lets you declare an expression with fixed expression structure. You could also think of this as lazily building the expression based on a static expression.The nice part about this is it works directly on other
AbstractExpression
, putting them into aNamedTuple
, and then puts them together when callingget_tree
. For example, using the previous example:We can create
f_plus_g
which a fixed+
operation in the middle. This function is fixed into the expression type itself, so this should be very fast:Note the string printout – this is because
get_tree
calls the structure function, patching together the tree! But the overall structure is fixed.We can look at the individual components:
and get the function that puts them together:
which takes a named tuple as input.
This is all type stable, and should be a nice feature for SymbolicRegression.jl!
It also already has
get_constants
andset_constants!
declared – these simply loop through the individual sub-expressions and get or set constants.cc @gca30 @AlCap23 @avik-pal in case of interest