Skip to content
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

How to avoid needing CSE? #136

Closed
dpsanders opened this issue May 21, 2019 · 4 comments
Closed

How to avoid needing CSE? #136

dpsanders opened this issue May 21, 2019 · 4 comments

Comments

@dpsanders
Copy link
Contributor

julia> @variables x y;

julia> function f(x, y)
       a = x + y
       return a + a^2
       end
f (generic function with 1 method)

julia> f(x, y)
(x() + y()) + (x() + y()) ^ 2

How can we prevent x + y being expanded each time that the intermediate a is used? This seems to be a bad idea, since it's giving more work for compiler later to do CSE. (Is this already implemented somehow?)

@HarrisonGrodin
Copy link
Contributor

HarrisonGrodin commented May 21, 2019

This is not yet implemented, but it will be soon. Once Terms.jl is finished, we will have an API for defining terms with custom behaviors and representations; then, the CSE-like behavior will happen inside the term itself, likely in the form of treating terms as DAGs and using "graph rewriting".

@asprionj asprionj mentioned this issue May 21, 2019
@asprionj
Copy link

What's the status here? There's been a lot going on w.r.t. components (i.e. connected systems); how do those developments relate to terms, CSE (and possibly automatic calculation of those intermediate values from the solution)?

@ChrisRackauckas
Copy link
Member

The component system makes it so there's a lot of calculations that are automatically reused, but not within a single expression. This is still something that could exist, but it's not the biggest deal in the grand scheme of things.

@ChrisRackauckas
Copy link
Member

CSE is a build_function Symbolics.jl thing now, and I wouldn't worry about it on the model building side since it rejiggers the equations into an optimized form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants