{"action":"created","issue":{"url":"https://api.github.com/repos/kroneckerbio/kroneckerbio/issues/5","labels_url":"https://api.github.com/repos/kroneckerbio/kroneckerbio/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/kroneckerbio/kroneckerbio/issues/5/comments","events_url":"https://api.github.com/repos/kroneckerbio/kroneckerbio/issues/5/events","html_url":"https://github.com/kroneckerbio/kroneckerbio/issues/5","id":33132959,"number":5,"title":"Concentration outputs","user":{"login":"drhagen","id":2952478,"avatar_url":"https://avatars.githubusercontent.com/u/2952478?v=3","gravatar_id":"","url":"https://api.github.com/users/drhagen","html_url":"https://github.com/drhagen","followers_url":"https://api.github.com/users/drhagen/followers","following_url":"https://api.github.com/users/drhagen/following{/other_user}","gists_url":"https://api.github.com/users/drhagen/gists{/gist_id}","starred_url":"https://api.github.com/users/drhagen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drhagen/subscriptions","organizations_url":"https://api.github.com/users/drhagen/orgs","repos_url":"https://api.github.com/users/drhagen/repos","events_url":"https://api.github.com/users/drhagen/events{/privacy}","received_events_url":"https://api.github.com/users/drhagen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"apgar","id":6304286,"avatar_url":"https://avatars.githubusercontent.com/u/6304286?v=3","gravatar_id":"","url":"https://api.github.com/users/apgar","html_url":"https://github.com/apgar","followers_url":"https://api.github.com/users/apgar/followers","following_url":"https://api.github.com/users/apgar/following{/other_user}","gists_url":"https://api.github.com/users/apgar/gists{/gist_id}","starred_url":"https://api.github.com/users/apgar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apgar/subscriptions","organizations_url":"https://api.github.com/users/apgar/orgs","repos_url":"https://api.github.com/users/apgar/repos","events_url":"https://api.github.com/users/apgar/events{/privacy}","received_events_url":"https://api.github.com/users/apgar/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/kroneckerbio/kroneckerbio/milestones/1","html_url":"https://github.com/kroneckerbio/kroneckerbio/milestones/0.5","labels_url":"https://api.github.com/repos/kroneckerbio/kroneckerbio/milestones/1/labels","id":1055204,"number":1,"title":"0.5","description":"","creator":{"login":"drhagen","id":2952478,"avatar_url":"https://avatars.githubusercontent.com/u/2952478?v=3","gravatar_id":"","url":"https://api.github.com/users/drhagen","html_url":"https://github.com/drhagen","followers_url":"https://api.github.com/users/drhagen/followers","following_url":"https://api.github.com/users/drhagen/following{/other_user}","gists_url":"https://api.github.com/users/drhagen/gists{/gist_id}","starred_url":"https://api.github.com/users/drhagen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drhagen/subscriptions","organizations_url":"https://api.github.com/users/drhagen/orgs","repos_url":"https://api.github.com/users/drhagen/repos","events_url":"https://api.github.com/users/drhagen/events{/privacy}","received_events_url":"https://api.github.com/users/drhagen/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":10,"state":"open","created_at":"2015-04-06T21:20:53Z","updated_at":"2015-05-22T18:56:47Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2014-05-08T23:22:27Z","updated_at":"2015-05-26T02:18:02Z","closed_at":null,"body":"Currently, outputs are defined as linear combination of states and inputs. States and inputs are canonically amounts of substance, so no linear combination will produce concentrations. Because compartment volumes are currently model constants, it is trivial to workaround this by multiplying each scaling constant of the linear combination by `1/v`. However, if #4 is implemented this workaround will not work for time- or parameter-varying compartments.\r\n\r\nOne thing to keep in mind is that outputs are mostly for convenience. Very little of Kronecker fails to function on a model with 0 outputs. Objective functions can be written as arbitrary functions of the states. The concentrations can be readily computed with `X = x .* m.v(m.vxInd)` and `U = u .* m.v(m.vuInd)`. If #4 is implemented, then it would be `v = m.v(t,x,u); X = x .* v(m.vxInd); U = u .* v(m.vuInd)`. What is lost is the convenience of outputs; they get their own function handle on simulation results. Also lost are the algorithms that take multiple topologies, because they do not necessarily work on objective functions that touch things other than `y`.\r\n\r\nThere are several ways to add back the convenience of outputs in concentration:\r\n\r\n(1) Have each output be one of two types: an amount output or a concentration output. The concentration output must be associated with a single compartment because some compartment needs to be the denominator. It makes no sense to simply sum concentrations from multiple compartments. However, it may make sense to sum the amounts of species from different compartments before dividing by the concentration of a main compartment if some of those compartments are lower dimensional compartments bordering the main high dimensional compartment. For example, species on the inside of a membrane can be considered to contribute to the concentration of the contained volume under some measurements. \r\n\r\nThe main compartment can be extracted from a valid list of species. The main compartment is necessarily the largest dimensional compartment of all the compartments containing one of the species that contribute to this output. If there are multiple compartments that tie for the largest compartment, this is necessarily nonsense and should throw an error. Kronecker has no concept of neighboring volumes, so it cannot verify that the lower dimensional compartments are actually adjacent to the main compartment.\r\n\r\nInterestingly, rule-based Kronecker has adjacency. It could be added to mass action Kronecker. It is naturally optional; models that don't need it would not have to specify it and would lose nothing. Still, that would be a nearly trivial use case.\r\n\r\n(2) Outputs can be made arbitrary functions. With this method, very little outside the model definition would have to change. There would be helper functions to add concentration outputs and amount outputs and arbitrary outputs. If the outputs are dependent on the states, this might be a little annoying. Each output currently has to be compiled; it has a regular expression that is matched to the states. Each output will either need a compile handle (ugly but general) or each type of output needs to be known by Kronecker (not so bad) or each output needs to be added after all the relevant states (most people do this already and probably would not notice, but it breaks a main property of Kronecker models in that order does not matter when adding components).\r\n\r\n(3) Just like (1) except there is a new type of output entirely. This output is a separate field on the model structure. If this is not done, then the outputs will have to be turned into arbitrary function handles from the perspective of the rest of Kronecker. A new member on the model, like `m.ConcentrationOutputs` is the only way to avoid this."},"comment":{"url":"https://api.github.com/repos/kroneckerbio/kroneckerbio/issues/comments/105361048","html_url":"https://github.com/kroneckerbio/kroneckerbio/issues/5#issuecomment-105361048","issue_url":"https://api.github.com/repos/kroneckerbio/kroneckerbio/issues/5","id":105361048,"user":{"login":"apgar","id":6304286,"avatar_url":"https://avatars.githubusercontent.com/u/6304286?v=3","gravatar_id":"","url":"https://api.github.com/users/apgar","html_url":"https://github.com/apgar","followers_url":"https://api.github.com/users/apgar/followers","following_url":"https://api.github.com/users/apgar/following{/other_user}","gists_url":"https://api.github.com/users/apgar/gists{/gist_id}","starred_url":"https://api.github.com/users/apgar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apgar/subscriptions","organizations_url":"https://api.github.com/users/apgar/orgs","repos_url":"https://api.github.com/users/apgar/repos","events_url":"https://api.github.com/users/apgar/events{/privacy}","received_events_url":"https://api.github.com/users/apgar/received_events","type":"User","site_admin":false},"created_at":"2015-05-26T02:18:02Z","updated_at":"2015-05-26T02:18:02Z","body":"That makes sense. Can a similar solution be applied to seeds. Ie a seed can\nhave a compartment associated with it and be a concentration value.\n\n-- josh\n\nOn May 22, 2015, at 2:52 PM, David Hagen <notifications@github.com> wrote:\n\nOutputs are being made into arbitrary functions of t, x, u, and k for\nanalytic models. If this was done for mass action models, then mass action\nmodels would require the symbolic toolbox and incur all the monetary and\ncomputational costs.\n\nHere is my proposal for adding concentration outputs to the model. The\noutputs of mass action models will get a third field called Compartment\nwhich will be either an empty string or a compartment name. If it is an\nempty string, then the output is in amounts (or in a compartment of size\n1). If it is a compartment name, then that output is an amount divided by\nthat volume of that compartment.\n\nI think that AddOutput should get a fourth parameter compartment, whose\ndefault value is ''. Alternatively, we could create a new function\nAddOutputConcentration, but I think that is unnecessary.\n\n—\nReply to this email directly or view it on GitHub\n<https://github.com/kroneckerbio/kroneckerbio/issues/5#issuecomment-104742535>\n.\n"}}