JacquesCarette / Drasil

Generate all the things (focusing on research software)
https://jacquescarette.github.io/Drasil
BSD 2-Clause "Simplified" License
137 stars 26 forks source link

Populate "Input" and "Input Constraints" fields of IMs automatically #3584

Open samm82 opened 11 months ago

samm82 commented 11 months ago

As mentioned in #3569, our IMs require their inputs (and the constraints on those inputs) to be entered manually. This results in duplication, causing a lack of traceability and a proneness to errors (again, see discussion on #3569). Since we can already "scrape" the quantities used in the "Equation" field to generate the "Description" field, it should be relatively straightforward to populate the "Input" field using these values, then getting all their constraints for the appropriate field.

One note about this is that the output is included in the list of quantities in the description. I'm tempted to assume that the left side of the equation can be used as the output, but with the examples involving DEs, I'm not sure this is the case. I think it makes sense to have the user specify the output, then remove this output from the list of quantities before it gets used in the "Inputs" field (while keeping it in the description). It may also be possible to automatically pull any constraints of this output to be used in the "Output Constraints", but this may have to be a separate issue if it is non-trivial.

smiths commented 11 months ago

I'm definitely in favour of as much automation as possible. If scraping the equation for the description field is working already, I think you are right that we can also find the inputs. I'm not sure it will always work, but at least for our current case studies, I think it should.

@samm82 I agree that we can't just take the left-hand side of the equation as the output. As you mention, we have ODEs where the left-hand side is a derivative, but the output is supposed to be the time history of the thing that is changing, not it's rate of change. We have a similar problem with partial differential equations. We also have equations like Ax = b for a linear system of equations. The output for this equation is nearly always x, even though it isn't typically written as x = A^-1 b. We also might define a quantity implicitly, where the thing that we want appears on both sides of the equation. This comes up in some root-finding problems. Even an example like finding the roots of a quadratic equation is often better expressed as finding the x values that make a x^2 + b x + c = 0, rather than giving the closed-form quadratic equation. As the polynomials get higher order, we don't have access to such nice formulas as the quadratic formula.