JuliaSymbolics / Metatheory.jl

Makes Julia reason with equations. General purpose metaprogramming, symbolic computation and algebraic equational reasoning library for the Julia programming language: E-Graphs & equality saturation, term rewriting and more.
https://juliasymbolics.github.io/Metatheory.jl/dev/
MIT License
362 stars 47 forks source link

Q: Metatheory.jl - algebraic simplification for JuMP nonlinear expression #157

Open vinhpb opened 1 year ago

vinhpb commented 1 year ago

Hi,

I have a use case where I have long algebraic nonlinear expressions (type Expr) to be fed to an optimization model in JuMP, and I wish to simplify the expressions before feeding them to the model to reduce the solver running time and readability. I think Metatheory.jl is the right solution and have tried to use the code from test/integration/cas.jl to simplify my expressions. They were partially simplified, but not as much as SymbolicUtils.jl or MATLAB would do, as in the following example:

I would really appreciate it if you can give some guidances on how should I improve the code from test/integration/cas.jl to reach simp_expr. Although SymbolicUtils.jl is able to simplify the expressions completely, Metatheory.jl is better for my use case due to its ability to transform Expr from JuMP directly. Thank you.