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
Cursory (don't beat me) reading of some recent discussions(e.g., #3259, #3381) finds me wondering about whether the unit attribute is to become the "one attribute to rule them all". As the author of the Business Simulation library—a system dynamics library making use of acausal connectors and (notoriously) unconventional types like Amount and AmountRate—I am coming more from the "cybernetic" side of "cyber-physical" modeling. Nonetheless—or even exactly because of this more abstract nature—verification(e.g., will the model result in a solvable set of equations) and validation(e.g., is it meaningful with regard to the intended purpose) of models are important.
In programming, we typically use type to catch errors (statically or dynamically inferred by compilers). And indeed I adapted this principle by having modellers make type choices for causal (mostly output) connectors, which then are used within a component for variables and parameters (the nature of abstract libraries makes it much harder to make these definite choices when designing components).
But setting an explicit quantity attribute for causal connectors has just been called "inconvenient" and "unusual" (#3381) by Hans Olsson. I would argue on the contrary: It could be very convenient to set the type using a replaceable type and the beauty of it is that next to the quantityandunit attribute one can also set displayUnit or min/max in a single choice as to nudge users not to change the unit when what they need is a different displayUnit (e.g, have a derived type `Time_months).
I note that the predefined types Boolean, Integer, String, and even Enumeration all carry the quantity attribute. Maybe it should help us to distinguish fundamental differences even when a unit-system is not applicable:
String str1(quantity = "Message") = "This is likely a unit error.";
String str2(quantity = "Documentation") = "This is a basic converter class.";
String str3(quantity = "Label") = "SuperClass";
type Color = enumeration(red, yellow, green);
parameter Color condition(quantity = "Reliability") = Color.red;
Color signal(quantity = "TrafficSignal");
Make no mistake: It is absolutely essential that unit errors are caught (e.g., as to not mix mm and m in Quentins example in #3381). But to me quantity is more likely to catch fundamental equation errors (e.g., there is no meaningful way to propagate magnitudes from one side of an equation to the other), while unit mismatch has a higher likeliness to be an error in the order of magnitudes (e.g., numerical error only).
I had believed that this fundamental quality of quantity was the reason to make it—not the unit attribute—a restriction for connections in the section 9.3 of the specs:
In a connection set all variables having non-empty quantity attribute must have the same quantity attribute.
Hans Olssons post suggests that setting the quantity attribute for causal connectors is "inconvenient" to do and that it "cannot even be inferred". But that is exactly what makes quantity so valuable in catching fundamental errors and this even applies to causal connections because if you want to measure Time you should not connect to a sensor that measures Length or Speed.
I would like to stipulate the discussion here with the following:
While unit checking is important, make setting quantity and especially type more convenient for modelers in order to catch fundamental errors in equation formulation and to make it convenient to set multiple attributes at once.
A model may have numerical errors, but still give a solvable set of equations, if quantities match up, "mere" unit errors should give a warning, but not necessarily prevent models from being simulated (Note, that many of the unit error examples given in Infering units for empty unit variable. #3381 are in fact (dimensional) quantity errors mixing say m and s).
Cursory (don't beat me) reading of some recent discussions(e.g., #3259, #3381) finds me wondering about whether the
unitattribute is to become the "one attribute to rule them all". As the author of theBusiness Simulationlibrary—a system dynamics library making use of acausal connectors and (notoriously) unconventionaltypeslikeAmountandAmountRate—I am coming more from the "cybernetic" side of "cyber-physical" modeling. Nonetheless—or even exactly because of this more abstract nature—verification(e.g., will the model result in a solvable set of equations) and validation(e.g., is it meaningful with regard to the intended purpose) of models are important.In programming, we typically use
typeto catch errors (statically or dynamically inferred by compilers). And indeed I adapted this principle by having modellers maketypechoices for causal (mostlyoutput) connectors, which then are used within a component forvariablesandparameters(the nature of abstract libraries makes it much harder to make these definite choices when designing components).But setting an explicit
quantityattribute for causal connectors has just been called "inconvenient" and "unusual" (#3381) by Hans Olsson. I would argue on the contrary: It could be very convenient to set thetypeusing areplaceable typeand the beauty of it is that next to thequantityandunitattribute one can also setdisplayUnitormin/maxin a single choice as to nudge users not to change theunitwhen what they need is a differentdisplayUnit(e.g, have a derived type `Time_months).I note that the predefined types
Boolean,Integer,String, and evenEnumerationall carry thequantityattribute. Maybe it should help us to distinguish fundamental differences even when aunit-systemis not applicable:Make no mistake: It is absolutely essential that
uniterrors are caught (e.g., as to not mixmmandmin Quentins example in #3381). But to mequantityis more likely to catch fundamental equation errors (e.g., there is no meaningful way to propagatemagnitudesfrom one side of an equation to the other), whileunitmismatch has a higher likeliness to be an error in the order ofmagnitudes(e.g., numerical error only).I had believed that this fundamental quality of
quantitywas the reason to make it—not theunitattribute—a restriction for connections in the section 9.3 of the specs:Hans Olssons post suggests that setting the
quantityattribute for causal connectors is "inconvenient" to do and that it "cannot even be inferred". But that is exactly what makesquantityso valuable in catching fundamental errors and this even applies to causal connections because if you want to measureTimeyou should not connect to a sensor that measuresLengthorSpeed.I would like to stipulate the discussion here with the following:
While
unitchecking is important, make settingquantityand especiallytypemore convenient for modelers in order to catch fundamental errors in equation formulation and to make it convenient to set multiple attributes at once.A model may have numerical errors, but still give a solvable set of equations, if quantities match up, "mere" unit errors should give a warning, but not necessarily prevent models from being simulated (Note, that many of the
uniterror examples given in Infering units for empty unit variable. #3381 are in fact (dimensional)quantityerrors mixing saymands).