{"action":"opened","issue":{"url":"https://api.github.com/repos/convexopt/gpkit/issues/447","labels_url":"https://api.github.com/repos/convexopt/gpkit/issues/447/labels{/name}","comments_url":"https://api.github.com/repos/convexopt/gpkit/issues/447/comments","events_url":"https://api.github.com/repos/convexopt/gpkit/issues/447/events","html_url":"https://github.com/convexopt/gpkit/issues/447","id":115124948,"number":447,"title":"Manually specifying relationships between inter-model variables","user":{"login":"pgkirsch","id":8702579,"avatar_url":"https://avatars.githubusercontent.com/u/8702579?v=3","gravatar_id":"","url":"https://api.github.com/users/pgkirsch","html_url":"https://github.com/pgkirsch","followers_url":"https://api.github.com/users/pgkirsch/followers","following_url":"https://api.github.com/users/pgkirsch/following{/other_user}","gists_url":"https://api.github.com/users/pgkirsch/gists{/gist_id}","starred_url":"https://api.github.com/users/pgkirsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgkirsch/subscriptions","organizations_url":"https://api.github.com/users/pgkirsch/orgs","repos_url":"https://api.github.com/users/pgkirsch/repos","events_url":"https://api.github.com/users/pgkirsch/events{/privacy}","received_events_url":"https://api.github.com/users/pgkirsch/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/convexopt/gpkit/labels/design%20discussion","name":"design discussion","color":"000000"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-04T19:06:34Z","updated_at":"2015-11-04T19:06:34Z","closed_at":null,"body":"Extremely closely related to, and building on, issue #444.\r\n\r\nExample of need 1: Specifying relationships between inter-model variables\r\n----------------------------------------------------------------------------------------------------\r\nSay 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`.\r\n\r\nIf 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.\r\n\r\nExample of need 2: Differently named variables in interacting models\r\n-------------------------------------------------------------------------------------------\r\nThe 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.\r\n\r\nAnother obvious variable name that will be wildly overloaded is `W`.\r\n\r\nVery open to syntax suggestions. The only thing I can think of would replace the overloaded `&` (which, for the record, I do really like):\r\n```\r\n...\r\n# parent = Model(objective, constraints)\r\nbase_tail = Model(objective, constraints)\r\n\r\n# links = # {child_varkey: f(parent_variable)}\r\nlinks = {'T': T, 'S': Svt*2, `AR`: A} \r\n\r\n# parent.import_model(child)\r\nbase_tail.import_model(structure)\r\n```"}}