Using custom dimensions from DynamicQuantities
#679
-
Hello, I'm trying to do equation discovery in a dimensionally consistent way but I'm having a hard time of it. Many of my quantities are either number concentration (#/kg) or mass mixing ratio (kg of A/kg of B). I can not figure out how to express these units using the I've tried switching to the # ...
# create our dimensions
struct ExtendedDimensions{R} <: AbstractDimensions{R}
length::R
mass::R
time::R
current::R
temperature::R
luminosity::R
amount::R
angle::R
mass_h2o::R
mass_air::R
count::R
end
# ...
const mmr = Quantity(1.0, ExtendedDimensions(mass_h2o=1, mass_air=-1))
const nconc = Quantity(1.0, ExtendedDimensions(count=1, mass_air=-1))
const dens = Quantity(1.0, ExtendedDimensions(mass_air=1, length=-3))
X = (; A=data.A * mmr, B=data.B * nconc)
y = data.C * mmr
# create model
model = SRRegressor(
binary_operators=[*,^,/],
dimensional_constraint_penalty=10^5,
nested_constraints=[(^) => [(^) => 0]],
constraints=[(^) => (-1,1)]
)
# create machine
mach = machine(model, X, y)
# do the fitting
fit!(mach)
r = report(mach) but I get this error when I run the script:
I'm very new to Julia, but it seems to me like the Does anyone have any advice? Is it possible to use a custom version of (I'm asking here since it did not seem reasonable to open an issue on |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi @HenryDane, Thanks for the post! Do you want to post this is as an issue on SymbolicRegression.jl? Custom Cheers, |
Beta Was this translation helpful? Give feedback.
-
Sure -- I'll open an issue on the |
Beta Was this translation helpful? Give feedback.
-
P.S., as a quick hack, you could treat the other existing units as the units you are interested in. So, e.g., luminosity (cd) could be mass_h20. |
Beta Was this translation helpful? Give feedback.
Hi @HenryDane,
Thanks for the post! Do you want to post this is as an issue on SymbolicRegression.jl? Custom
AbstractDimensions
have actually not yet been set up withinSymbolicRegression
– simply because I didn't know anybody would want to customize this :). But that sounds like a cool use-case, and it should hopefully be fairly easy to add this.Cheers,
Miles