You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the past few years by far the most requested feature in SymbolicRegression.jl & PySR has been a way of checking whether expressions are dimensionally correct. I have not looked at adding this yet because I argue that unknown constants could have units that simply cancel out units in your expressions - thus obviating the need. However I definitely see some use-cases where this could be very useful, especially if you wish to not allow learning new constants (e.g., you simply want to pass a set of constants and set complexity_of_constants=100, say).
I think the easiest way of doing this is to integrate Unitful.jl (h/t @tfiers for recommendation). An example API could be:
These units could be stored in the Dataset object. Then, adding another step to check_constraints, you could basically see whether an expression is dimensionally correct. You would require that + and - maintain the same units as their input, * and / propagate units, and all other operators require dimensionless inputs. When there is a constant in an expression, you could have some sort of "wildcard" units, and do a solve to see whether such units exist. This might be the most expensive part though...
@tfiers@ChrisRackauckas do you know if there is a way to have some sort of "wildcard" units, and solve for them, using Unitful.jl?
The text was updated successfully, but these errors were encountered:
You could create a new unit, say "wildcard". Then recursively evaluate an expression and aggregate units. When you hit a * or /, you would combine units, and, if there is any wildcard, you simply combine it with the units. When you get to an operator that requires dimensionless input, you would first check whether there is a wildcard in the units. If there is, you are safe. Otherwise, you would see whether the units simplify or not.
Likewise for + and -: if any wildcard at all, you are safe. Otherwise, you check whether the units are compatible!
For the past few years by far the most requested feature in SymbolicRegression.jl & PySR has been a way of checking whether expressions are dimensionally correct. I have not looked at adding this yet because I argue that unknown constants could have units that simply cancel out units in your expressions - thus obviating the need. However I definitely see some use-cases where this could be very useful, especially if you wish to not allow learning new constants (e.g., you simply want to pass a set of constants and set
complexity_of_constants=100
, say).I think the easiest way of doing this is to integrate Unitful.jl (h/t @tfiers for recommendation). An example API could be:
These units could be stored in the
Dataset
object. Then, adding another step tocheck_constraints
, you could basically see whether an expression is dimensionally correct. You would require that+
and-
maintain the same units as their input,*
and/
propagate units, and all other operators require dimensionless inputs. When there is a constant in an expression, you could have some sort of "wildcard" units, and do a solve to see whether such units exist. This might be the most expensive part though...@tfiers @ChrisRackauckas do you know if there is a way to have some sort of "wildcard" units, and solve for them, using Unitful.jl?
The text was updated successfully, but these errors were encountered: