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
Recall Choices. In particular, I am interested in us looking at (2) and (3).
The goal of this ticket is to understand how we should add unmodular feature flags to Choices.
For starters, I want to add the following feature flags:
NoSimpleCalculationFunctions: this is essentially a weaker version of Make unmodular code generation a bit more unmodular #4233 where all code that would go into "simple calculation functions" would instead be inlined. Specifically, this would not inline "function definitions" (these would remain as functions) nor ODEs (these would again be left as extra functions that do the necessary prep work to make ODEs happen).
InlineOutputFunction: inline the write_output function in the main "controller" function.
InlineInputCalculations: inline all input-related calculations (constraint validation, derived inputs, and reading inputs) in the main "controller" function.
Note: the "controller" function is the function that we often place in the Calculations.py files that calls all other modules.
Now, some questions that would help us:
-1. What is "modularity"?
For the sake of providing a working definition, I'm going to work on the assumption that "modularity" is a spectrum involving splitting up code into "modules" exhibiting:
High cohesion: "modules" have well-defined purposes/clear scopes and all components of them are strictly relevant to said purpose/scope.
Low coupling: "modules" are highly independant, communicating with well-defined interfaces and not reliant on external shared knowledge.
Encapsulation: using "modules" that only expose what is absolutely necessary to interacting with it -- showing no internal complexity.
Now, with the existing Modularity data type, we are reducing "modularity" to a binary that isn't exactly true in the general case, but because this is in the context of generating code, we have the ability to make outputs "completely modular up to $X$ or completely unmodular up to $Y$."
0. What other feature flags would we be interested in?
For now, I think the above 3 are a good starting point, but I'm sure there are tons of other things we would want to turn on and off!
1. Is Modularity a feature only relevant to Program?
I don't think so? If a ModularLibrary generates all of the simple calculation functions, then I would assume that the UnmodularLibrary generates a single calculation function that, instead of inputting and outputting from stdin/stdout/files like its Program counterpart would, would just rely on an InputParameters class fed in to it (or just an enumeration of input parameters) and return an Outputs class (or again, an enumeration of output variables).
The other 2 feature flags are not really as relevant to Library.
2. Are these feature flags only relevant to Unmodular?
For example, I think that NoSimpleCalculationFunctions could also be relevant to Modular. However, the criteria for "simple" might be a bit different. For Unmodular, "simple" would mean any/all of our existing calculation functions, but for Modular, it could mean that the expressions are considered "complex" if their relevant expression ASTs are of a particular depth.
The other 2 feature flags are not really as relevant to Modular.
3. How is DataInfo related to modularity?
DataInfo contains the following settings:
inputStructure: a decision on input the structure of variables
Unbundled: each input variable was directly passed to the function as its own parameter.
Bundled: all input variables stored in a separated object.
constStructure: a decision on the structure of constants
Inline: macro expansion on variables. All constants that are represented by variables will be replaced by their value.
WithInputs: constants are stored in variables within the input object
Store Unbundled: constants are stored in variables that were directly passed to the function as its own parameter.
Store Bundled: constants are stored in variables within a separated object
constRepr: the representation of constants
Var: all constants represented as regular variables.
Const: use selected language's mechanism for defining constants. For example, C# has a build-in constant called const, but not all languages have build-in support on constants.
Are these not relevant to Modularity as well? For example, I would think that ConstStructure would have stricter meaning in Unmodular? WithInputs for example, could also perhaps only be relevant to Unmodular.
Recall
Choices. In particular, I am interested in us looking at (2) and (3).The goal of this ticket is to understand how we should add unmodular feature flags to
Choices.For starters, I want to add the following feature flags:
NoSimpleCalculationFunctions: this is essentially a weaker version of Make unmodular code generation a bit more unmodular #4233 where all code that would go into "simple calculation functions" would instead be inlined. Specifically, this would not inline "function definitions" (these would remain as functions) nor ODEs (these would again be left as extra functions that do the necessary prep work to make ODEs happen).InlineOutputFunction: inline thewrite_outputfunction in the main "controller" function.InlineInputCalculations: inline all input-related calculations (constraint validation, derived inputs, and reading inputs) in the main "controller" function.Note: the "controller" function is the function that we often place in the
Calculations.pyfiles that calls all other modules.Now, some questions that would help us:
-1. What is "modularity"?
For the sake of providing a working definition, I'm going to work on the assumption that "modularity" is a spectrum involving splitting up code into "modules" exhibiting:
Now, with the existing$X$ or completely unmodular up to $Y$ ."
Modularitydata type, we are reducing "modularity" to a binary that isn't exactly true in the general case, but because this is in the context of generating code, we have the ability to make outputs "completely modular up to0. What other feature flags would we be interested in?
For now, I think the above 3 are a good starting point, but I'm sure there are tons of other things we would want to turn on and off!
1. Is
Modularitya feature only relevant toProgram?I don't think so? If a
ModularLibrarygenerates all of the simple calculation functions, then I would assume that theUnmodularLibrarygenerates a single calculation function that, instead of inputting and outputting from stdin/stdout/files like itsProgramcounterpart would, would just rely on anInputParametersclass fed in to it (or just an enumeration of input parameters) and return anOutputsclass (or again, an enumeration of output variables).The other 2 feature flags are not really as relevant to
Library.2. Are these feature flags only relevant to
Unmodular?For example, I think that
NoSimpleCalculationFunctionscould also be relevant toModular. However, the criteria for "simple" might be a bit different. ForUnmodular, "simple" would mean any/all of our existing calculation functions, but forModular, it could mean that the expressions are considered "complex" if their relevant expression ASTs are of a particular depth.The other 2 feature flags are not really as relevant to
Modular.3. How is
DataInforelated to modularity?DataInfocontains the following settings:Are these not relevant to
Modularityas well? For example, I would think thatConstStructurewould have stricter meaning inUnmodular?WithInputsfor example, could also perhaps only be relevant toUnmodular.