Linking diagrams for models with duplicate variables
See original GitHub issueThis has to do with implementing gpkit/gpkit/interactive/linking_diagram.py in models with hierarchy, with duplicate variable names.
I have tried to make a linking diagram for hoburg/d8/CFP_Fuselage_Performance_int_HT.py, in commit cb63fa5, when I realized that the previous linking diagram infrastructure doesn’t like duplicate variable names.
As an example, the aircraft model in CFP has:
ac = Aircraft()
subsystems = [Fuselage(), Engine(), VerticalTail(), HorizontalTail(), Wing()]
I implement linking_diagram in the file make_figure.py, and it returns the following error
Traceback (most recent call last):
File "C:\Users\Berk\Anaconda2\lib\site-packages\IPython\core\interactiveshell.py", line 2666, in safe_execfile
self.compile if kw['shell_futures'] else None)
File "C:\Users\Berk\Anaconda2\lib\site-packages\IPython\utils\py3compat.py", line 276, in execfile
exec(compiler(scripttext, filename, 'exec'), glob, loc)
File "C:\Users\Berk\Dropbox (MIT)\MIT Graduate School\D8\d8\make_figure.py", line 111, in <module>
make_figure()
File "C:\Users\Berk\Dropbox (MIT)\MIT Graduate School\D8\d8\make_figure.py", line 55, in make_figure
zidane[tuple(keychain[key])] += [key]
KeyError: ('VerticalTail', 'Wing', 'Wing')
because some variable names appear both in Wing and VerticalTail, although there are two distinct variables with the same name (example ‘I_{cap}’, which is a wing spar moment of inertia).
As a workaround, I was going to suggest scrubbing through the constraints within the hyperclasses of Aircraft and AircraftP, instead of variables within the model, to make the diagram. This way you avoid the issues with duplicate names (although you will oddly have two variables with the same name that are not related at all in the diagram). Or is there another way to fix the issue? Let me know what you think.
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (14 by maintainers)
Top GitHub Comments
And/or, the models in a variable’s name tell you where it came from, which would be useful information to visualize…
superseded by #1088