Manually specifying relationships between inter-model variables
See original GitHub issueExtremely closely related to, and building on, issue #444.
Example of need 1: Specifying relationships between inter-model variables
Say I have a wing
model and a tail
model. Both of these models require a structure
model, however the definition of the tail reference area, Svt
, is different from the wing
and structure
models’ definitions of the reference area, S
. More specifically Svt = S/2
.
If I import the structure model into the tail model, I currently need to add a constraint that specifies Svt == S/2
, which means I need to add a Variable declaration S = Var...
that my base tail model otherwise wouldn’t care about. Otherwise I could add an Svt
variable and corresponding constraint to the structure
model, but it doesn’t care about Svt
and is confused about what it is and why it has been burdened with another variable.
Example of need 2: Differently named variables in interacting models
The current solution to #444 is awesome, but it doesn’t discriminate between cases where variables with the same name are intended to be the same quantity and when they aren’t. I believe that the user should only be responsible for choosing unique names within the scope of a model. Consider an example where you have an aircraft with thrust T
. Its engine and flight conditions submodels also has thrust variables named T
. But by convention, the landing gear model uses T
to mean wheel track. Obviously if thrust is equal to wheel track we have a problem, not to mention that pint
will get wildly offended and throw a tantrum. If the designer is manually responsible for specifying which variables connect to each other then you put the responsibility on them to get the distinction right. You could argue the designer should use something other than T
, but that is suggesting that any model curator should have perfect foresight for all future models and their variable naming conventions.
Another obvious variable name that will be wildly overloaded is W
.
Very open to syntax suggestions. The only thing I can think of would replace the overloaded &
(which, for the record, I do really like):
...
# parent = Model(objective, constraints)
base_tail = Model(objective, constraints)
# links = # {child_varkey: f(parent_variable)}
links = {'T': T, 'S': Svt*2, `AR`: A}
# parent.import_model(child)
base_tail.import_model(Structure())
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (10 by maintainers)
Top GitHub Comments
@pgkirsch:
Need 1 still isn’t solved, but Need 2 can be met by:
m.subinplace(wing["x"], tail["y"])
orm.subinplace({wing["x"]: tail["y"], ...})
Documented (and heavily built upon) by the performance-modeling example 😄