{"action":"created","issue":{"url":"https://api.github.com/repos/nengo/nengo/issues/941","repository_url":"https://api.github.com/repos/nengo/nengo","labels_url":"https://api.github.com/repos/nengo/nengo/issues/941/labels{/name}","comments_url":"https://api.github.com/repos/nengo/nengo/issues/941/comments","events_url":"https://api.github.com/repos/nengo/nengo/issues/941/events","html_url":"https://github.com/nengo/nengo/pull/941","id":131115920,"number":941,"title":"Spaopt v4 and build time parameters","user":{"login":"jgosmann","id":850157,"avatar_url":"https://avatars.githubusercontent.com/u/850157?v=3","gravatar_id":"","url":"https://api.github.com/users/jgosmann","html_url":"https://github.com/jgosmann","followers_url":"https://api.github.com/users/jgosmann/followers","following_url":"https://api.github.com/users/jgosmann/following{/other_user}","gists_url":"https://api.github.com/users/jgosmann/gists{/gist_id}","starred_url":"https://api.github.com/users/jgosmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgosmann/subscriptions","organizations_url":"https://api.github.com/users/jgosmann/orgs","repos_url":"https://api.github.com/users/jgosmann/repos","events_url":"https://api.github.com/users/jgosmann/events{/privacy}","received_events_url":"https://api.github.com/users/jgosmann/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nengo/nengo/labels/discussion","name":"discussion","color":"207de5"},{"url":"https://api.github.com/repos/nengo/nengo/labels/work%20in%20progress","name":"work in progress","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"jgosmann","id":850157,"avatar_url":"https://avatars.githubusercontent.com/u/850157?v=3","gravatar_id":"","url":"https://api.github.com/users/jgosmann","html_url":"https://github.com/jgosmann","followers_url":"https://api.github.com/users/jgosmann/followers","following_url":"https://api.github.com/users/jgosmann/following{/other_user}","gists_url":"https://api.github.com/users/jgosmann/gists{/gist_id}","starred_url":"https://api.github.com/users/jgosmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgosmann/subscriptions","organizations_url":"https://api.github.com/users/jgosmann/orgs","repos_url":"https://api.github.com/users/jgosmann/repos","events_url":"https://api.github.com/users/jgosmann/events{/privacy}","received_events_url":"https://api.github.com/users/jgosmann/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2016-02-03T18:42:05Z","updated_at":"2016-02-17T13:50:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nengo/nengo/pulls/941","html_url":"https://github.com/nengo/nengo/pull/941","diff_url":"https://github.com/nengo/nengo/pull/941.diff","patch_url":"https://github.com/nengo/nengo/pull/941.patch"},"body":"I started putting together another spaopt branch which will hopefully be merged in the future. This implementaton is still WIP, but I would like some comments on how I implement some stuff.\r\n\r\nThe main issue with spaopt is that it requires the radius to be determined at build time. For that I defined a new type of parameter `BuildTimeParam` which can be set to a function with two arguments: The building simulator and the Nengo object being build (in that order). The builder is supposed to call that function and use the return value as a parameter value.\r\n\r\nBecause we want to set the radius at build time for spaopt, but not in other cases, I introduce [another type of parameter called `StaticOrBuildTimeParam`](https://github.com/nengo/nengo/compare/spaopt-v4?expand=1#diff-455ef842e1c051dcd59972ebcb821c46R366) that allows for both. There are a few things I would like opinions on:\r\n\r\n* `StaticOrBuildTimeParam` gets instantiated with another `Parameter` instance as argument which specifies the permitted parameter values for non-build-time (static) parameters. The `default`, `optional`, and `readonly` values of that instance are ignored. Not sure if that might cause confusion\r\n* `StaticOrBuildTimeParam` derives from `BuildTimeParam`, but not from the class of the static parameter type. That leads to slightly different implementations depending on what value is set (calling `super` vs accessing `self.static...`). But it is pretty equivalent to what is done in DistOrArrayParam.\r\n* It is not possible to have a `StaticOrBuildTimeParam` where the static parameter variant accepts a function because setting it to a function is taken as in indicator that it should be calculated at build time.\r\n\r\nA related discussion point:\r\n* Changes to the builder are needed. It has to check whether the parameter is a function (and call that function) or otherwise just use whatever value is given. This will require all backends to implement that. Not sure if there would be any way around this.\r\n\r\n[I hard coded the use of the reference `Simulator` in the reference builder.](https://github.com/nengo/nengo/compare/spaopt-v4?expand=1#diff-03ffa76bf6ad121e7cfb21534a08961dR59) One reason is that we have no way to access the Simulator in the build functions at the moment (and I am not sure whether we should add that argument to all the build functions or the model, though maybe some kind of `build_with` argument on the (builder) model would be appropriate). Also, I am not sure how much of an issue the hard coded `Simulator` is. Potentially it could be the wrong one if other backends reuse the builder code, but if they do it might matter because they are using the reference builder code anyways? However, it is ugly that this requires a circular import at the moment (which only works when putting the import in the line before the Simulator is used).\r\n\r\nOne more question: Could it be an issue to build a model within the build process of another model with some backends? (i.e. When does SpiNNaker acquire the hardware resources in the build/run process?)"},"comment":{"url":"https://api.github.com/repos/nengo/nengo/issues/comments/185211580","html_url":"https://github.com/nengo/nengo/pull/941#issuecomment-185211580","issue_url":"https://api.github.com/repos/nengo/nengo/issues/941","id":185211580,"user":{"login":"arvoelke","id":5420057,"avatar_url":"https://avatars.githubusercontent.com/u/5420057?v=3","gravatar_id":"","url":"https://api.github.com/users/arvoelke","html_url":"https://github.com/arvoelke","followers_url":"https://api.github.com/users/arvoelke/followers","following_url":"https://api.github.com/users/arvoelke/following{/other_user}","gists_url":"https://api.github.com/users/arvoelke/gists{/gist_id}","starred_url":"https://api.github.com/users/arvoelke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arvoelke/subscriptions","organizations_url":"https://api.github.com/users/arvoelke/orgs","repos_url":"https://api.github.com/users/arvoelke/repos","events_url":"https://api.github.com/users/arvoelke/events{/privacy}","received_events_url":"https://api.github.com/users/arvoelke/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T13:50:49Z","updated_at":"2016-02-17T13:50:49Z","body":"Note this PR is a special case of #869.\r\n\r\nI don't think there's any way to circumvent the need to integrate this with the builder, and that's probably for the best if we want to keep this general enough to handle a good class of use cases.\r\n\r\nHow difficult would it be to make `RadiusForUnitVector` have the same interface as the builder methods? That is, take `model` rather than `Simulator`. This might solve the circular dependency problem that you have.\r\n\r\nWithout yet discussing the potential scope here, I think my only other concern here is the case-handling that was added to determine where the radius should come from. Might be good to have this abstracted away (and as a nitpick, checking the instance is some base class, rather than callable).\r\n\r\nI'll have to do some more thinking to determine how close this is to addressing my use cases. But even if it doesn't, I think this potentially taps into an good chunk of them in a fairly straightforward way."}}