Can the equation parser handle temporary variables?
- This topic has 7 replies, 2 voices, and was last updated 3 years, 11 months ago by
Eli Allensworth.
-
AuthorPosts
-
September 12, 2022 at 3:57 pm #262
Hey @Rich Howard,
I've been having some trouble with using temporary variables in the equation parser; whether I set them to a constant or to a calculated value, Assisi doesn't seem to recognize them. Can Assisi handle temporary variables, and if so, how do I set them?
September 12, 2022 at 3:57 pm #263Yeah, I didn't workshop the equation too much, just threw it in there real quick. If you set the argument to 'Value', it will then ask for 'Diameter'. Is it looking for both arguments?
September 12, 2022 at 3:57 pm #264OK. Got it. Assisi parsing code now matches your example in 2022.3.8.
September 12, 2022 at 3:57 pm #265Its a bug that I fixed here in the next version already. If you could fix the equation I will test it again and release 2022.3.7.
September 12, 2022 at 3:57 pm #266As an example, here is settings snippet for a parsed tree shape equation. ' Hann, D.W. 2011. Revised volume and taper equations for six major conifer species in southwest Oregon. Department of Forest Engineering, Resources, and Management., Oregon State University, Corvallis, Oregon. Forest Biometrics Research Paper 2. 14p.
' Equations 7 & 10, Tables 6 & 10, Douglas-firb1 = 0.92443655
b2 = 0.988866545
b3 = -0.0341455033
b11 = -0.550298007
b12 = -0.69479837
b13 = -0.0613100423
b21 = 0.356974513RH = (H – 4.5) / (HT – 4.5)
HD = (HT – 4.5) / DBH
PDIB = (b1 * DBH ^ b2) * EXP(b3 * (1.0 – (HCB / HT)) ^ 0.5)
WLT = (alpha * HCB – 4.5) / (HT – 4.5)
I1 = IIF(RH > WLT, 1, 0)
I2 = IIF(WLT > 0, 1, 0)
JP1 = (RH – 1.0) / (WLT – 1.0)
JP2 = (WLT – RH) / (WLT – 1.0)
Z0 = 1.0 – RH + I2 * (RH + I1 * (JP1 * (1.0 + JP2) – 1.0)) – (RH – 1.0) * (RH – I2 * RH)
Z1 = (I2 * (RH + I1 * (JP1 * (RH + (WLT * JP2)) – RH)) – (RH – 1.0) * (RH – I2 * RH))
Z2 = I2 * ((RH ^ 2) + I1 * ((JP1 * WLT * (2 * RH – WLT + (WLT * JP2)) – RH ^ 2))
DIB = PDIB * (Z0 + (b11 + b12 * HD + b13 * HD ^ 2) * Z1 + b21 * Z2)After an initial error that the term 'Value' was not included (I'm guessing this is the expected output value?), I received this error:Failed to set up stand.
Failed to set up Plot 99, Tree 1 (DF):
Failed to create tree of shape PARSE. 'CFM-SIS FVS-CA' calibration, species 'Douglas-fir' Failed to parse equation: term 'Diameter' not found in:
' hann, d.w. 2011. revised volume and taper equations for six major conifer species in southwest oregon. department of forest engineering, resources, and management., oregon state university, corvallis, oregon. forest biometrics research paper 2. 14p.
' equations 7 & 10, tables 6 & 10, douglas-firb1 = 0.92443655
b2 = 0.988866545
b3 = -0.0341455033
b11 = -0.550298007
b12 = -0.69479837
b13 = -0.0613100423
b21 = 0.356974513rh = (h – 4.5) / (ht – 4.5)
hd = (ht – 4.5) / dbh
pdib = (b1 * dbh ^ b2) * exp(b3 * (1.0 – (hcb / ht)) ^ 0.5)
wlt = (alpha * hcb – 4.5) / (ht – 4.5)
i1 = iif(rh > wlt, 1, 0)
i2 = iif(wlt > 0, 1, 0)
jp1 = (rh – 1.0) / (wlt – 1.0)
jp2 = (wlt – rh) / (wlt – 1.0)
z0 = 1.0 – rh + i2 * (rh + i1 * (jp1 * (1.0 + jp2) – 1.0)) – (rh – 1.0) * (rh – i2 * rh)
z1 = (i2 * (rh + i1 * (jp1 * (rh + (wlt * jp2)) – rh)) – (rh – 1.0) * (rh – i2 * rh))
z2 = i2 * ((rh ^ 2) + i1 * ((jp1 * wlt * (2 * rh – wlt + (wlt * jp2)) – rh ^ 2))
value = pdib * (z0 + (b11 + b12 * hd + b13 * hd ^ 2) * z1 + b21 * z2)I think this brings up a secondary issue: what are the expected values for each parse field? I've seen the same thing with bark equations. It would be helpful to have the expected final output value defined for each parse equation option, including units.September 12, 2022 at 3:57 pm #267True, its looking for "Value". It should be looking for "Diameter". I'll fix in 2022.3.7. But also:Must put the "master" equations above other terms. So put Value = PDIB * (Z0 + (b11 + b12 * HD + b13 * HD ^ 2) * Z1 + b21 * Z2)above the rest.Must end every equation with semicolon ";".There is an extra "(" in Z2 term.I put the equation in excel and used a tree from a cruise. I am getting neg diameters. See the attached sheet. Can you verify/fix then re post here?Rich
September 12, 2022 at 3:57 pm #268Also, for 2022.3.7, I think you should make HT40 and DBH40 exposed to the parser as well.
September 12, 2022 at 3:57 pm #269Got it. Attached is an Excel with a functioning form of the equation (Douglas-fir coefficients). Also attached is the paper they are derived from.
-
AuthorPosts
- You must be logged in to reply to this topic.
