{"action":"created","issue":{"url":"https://api.github.com/repos/tbeu/Modelica/issues/1733","repository_url":"https://api.github.com/repos/tbeu/Modelica","labels_url":"https://api.github.com/repos/tbeu/Modelica/issues/1733/labels{/name}","comments_url":"https://api.github.com/repos/tbeu/Modelica/issues/1733/comments","events_url":"https://api.github.com/repos/tbeu/Modelica/issues/1733/events","html_url":"https://github.com/tbeu/Modelica/issues/1733","id":197617268,"number":1733,"title":"Noise blocks: Impure functions in MSL 3.2.x","user":{"login":"modelica-trac-importer","id":22202507,"avatar_url":"https://avatars.githubusercontent.com/u/22202507?v=3","gravatar_id":"","url":"https://api.github.com/users/modelica-trac-importer","html_url":"https://github.com/modelica-trac-importer","followers_url":"https://api.github.com/users/modelica-trac-importer/followers","following_url":"https://api.github.com/users/modelica-trac-importer/following{/other_user}","gists_url":"https://api.github.com/users/modelica-trac-importer/gists{/gist_id}","starred_url":"https://api.github.com/users/modelica-trac-importer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modelica-trac-importer/subscriptions","organizations_url":"https://api.github.com/users/modelica-trac-importer/orgs","repos_url":"https://api.github.com/users/modelica-trac-importer/repos","events_url":"https://api.github.com/users/modelica-trac-importer/events{/privacy}","received_events_url":"https://api.github.com/users/modelica-trac-importer/received_events","type":"User","site_admin":false},"labels":[{"id":506762999,"url":"https://api.github.com/repos/tbeu/Modelica/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":506770201,"url":"https://api.github.com/repos/tbeu/Modelica/labels/P:%20highest","name":"P: highest","color":"aa8888","default":false}],"state":"open","locked":false,"assignee":{"login":"beutlich","id":14896695,"avatar_url":"https://avatars.githubusercontent.com/u/14896695?v=3","gravatar_id":"","url":"https://api.github.com/users/beutlich","html_url":"https://github.com/beutlich","followers_url":"https://api.github.com/users/beutlich/followers","following_url":"https://api.github.com/users/beutlich/following{/other_user}","gists_url":"https://api.github.com/users/beutlich/gists{/gist_id}","starred_url":"https://api.github.com/users/beutlich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beutlich/subscriptions","organizations_url":"https://api.github.com/users/beutlich/orgs","repos_url":"https://api.github.com/users/beutlich/repos","events_url":"https://api.github.com/users/beutlich/events{/privacy}","received_events_url":"https://api.github.com/users/beutlich/received_events","type":"User","site_admin":false},"assignees":[{"login":"beutlich","id":14896695,"avatar_url":"https://avatars.githubusercontent.com/u/14896695?v=3","gravatar_id":"","url":"https://api.github.com/users/beutlich","html_url":"https://github.com/beutlich","followers_url":"https://api.github.com/users/beutlich/followers","following_url":"https://api.github.com/users/beutlich/following{/other_user}","gists_url":"https://api.github.com/users/beutlich/gists{/gist_id}","starred_url":"https://api.github.com/users/beutlich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beutlich/subscriptions","organizations_url":"https://api.github.com/users/beutlich/orgs","repos_url":"https://api.github.com/users/beutlich/repos","events_url":"https://api.github.com/users/beutlich/events{/privacy}","received_events_url":"https://api.github.com/users/beutlich/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/tbeu/Modelica/milestones/59","html_url":"https://github.com/tbeu/Modelica/milestone/59","labels_url":"https://api.github.com/repos/tbeu/Modelica/milestones/59/labels","id":2214862,"number":59,"title":"MSL3.2.2","description":"","creator":{"login":"modelica-trac-importer","id":22202507,"avatar_url":"https://avatars.githubusercontent.com/u/22202507?v=3","gravatar_id":"","url":"https://api.github.com/users/modelica-trac-importer","html_url":"https://github.com/modelica-trac-importer","followers_url":"https://api.github.com/users/modelica-trac-importer/followers","following_url":"https://api.github.com/users/modelica-trac-importer/following{/other_user}","gists_url":"https://api.github.com/users/modelica-trac-importer/gists{/gist_id}","starred_url":"https://api.github.com/users/modelica-trac-importer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modelica-trac-importer/subscriptions","organizations_url":"https://api.github.com/users/modelica-trac-importer/orgs","repos_url":"https://api.github.com/users/modelica-trac-importer/repos","events_url":"https://api.github.com/users/modelica-trac-importer/events{/privacy}","received_events_url":"https://api.github.com/users/modelica-trac-importer/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":79,"state":"closed","created_at":"2016-12-25T13:02:16Z","updated_at":"2016-12-26T20:19:29Z","due_on":"2016-03-11T08:00:00Z","closed_at":"2016-12-25T13:02:16Z"},"comments":1,"created_at":"2016-12-26T20:19:29Z","updated_at":"2016-12-26T20:19:38Z","closed_at":null,"body":"**Reported by otter on 11 Jun 2015 14:32 UTC**\nWe are currently finalizing the Noise library. There is one remaining issue that we do not know how to handle (everything else should take previous comments into account). A quick respond is appreciated (since deadline of July 15 for new features in next MSL version, including reviews):\n\n**Local seed in Noise block**\n\nThere is a block GenericNoise that generates noise: At every sample period a random value is drawn and provided as constant signal to the output. It is important that users are able to define the Noise instances so that the noise of this instance does not depend on anything else in the model (so whenever the model is simulated, a noise block A, always generates the same noise; provided the same global seed valid for the complete model is used).\n\nThe simplest solution that always works is that a user has to provide the seed as one Integer, and all blocks with the same Integer values generate the same noise.\n\nThe problem is that this is error prone: A user drags the GenericNoise block and provides an Integer that is already provided somewhere else in the whole model, or he just copies a noise block, and forgets to provide a different value for the copied block.\n\nA better solution was proposed by Martin Sjölund several months ago, and this is implemented in the Noise library: Once flag \"automaticSeed=true\" (= default), the local seed is computed as:\n\n```\nparameter Integer localSeed = hashString(getInstanceName())\n```\nThere are two (tiny) issues with this:\n\n * getInstanceName is a built-in operator of Modelica 3.3. When using this operator, the current scheme of MSL requires that the next MSL version is 3.3.1 (and not 3.2.2). It seems to be quite an overkill, to increment the second number, just because one built-in operator of Modelica 3.3 is used. Another question is whether all tool vendors support this operator already. If not, of course this operator should not be used.\n * In the 3.3 specification there is a comment: [_The simulation result should not depend on the return value of this function._]. Since this is a comment and not mandatory, I think it is o.k. to ignore it in this case (because there is a good reason for it; and for the next version of the specification, it should be stated a bit differently).\n\n**Impure random number generator**\n\nIn some cases, e.g., state machines with transitions that are computed by drawing a random number, the following type of code is needed:\n\n```\n   when {initial(), sample(samplePeriod,samplePeriod)} then\n      y = globalSeed.random();\n   end when;\n```\nwhere function random() is an impure function. This means that every call of random() produces a different value. The problem is that in Modelica 3.2, it is not clear whether this construction will work in tools, because a tool could deduce that random() has no input arguments and then just call it once (since assumed that the function is pure).\n\nIn Modelica 3.3 there is a better solution, becaues the keyword \"impure\" was introduced:\n\n```\nimpure function random\n   ...\nend random;\n```\nThe cleanest way would be to use the keyword \"impure\" in the Noise package. I checked and this also works fine in Dymola. If this keyword is used, again the next MSL release number should be 3.3.1. And again, the question is whether tools support the \"impure\" keyword already.\n\nThe alternative would be to not use this \"keyword\" and \"hope\" that all tools do not optimize function calls away, if present in a when-clause and the function is an external function.\n\n----\n\nMigrated-From: https://trac.modelica.org/Modelica/ticket/1733"},"comment":{"url":"https://api.github.com/repos/tbeu/Modelica/issues/comments/269239344","html_url":"https://github.com/tbeu/Modelica/issues/1733#issuecomment-269239344","issue_url":"https://api.github.com/repos/tbeu/Modelica/issues/1733","id":269239344,"user":{"login":"modelica-trac-importer","id":22202507,"avatar_url":"https://avatars.githubusercontent.com/u/22202507?v=3","gravatar_id":"","url":"https://api.github.com/users/modelica-trac-importer","html_url":"https://github.com/modelica-trac-importer","followers_url":"https://api.github.com/users/modelica-trac-importer/followers","following_url":"https://api.github.com/users/modelica-trac-importer/following{/other_user}","gists_url":"https://api.github.com/users/modelica-trac-importer/gists{/gist_id}","starred_url":"https://api.github.com/users/modelica-trac-importer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modelica-trac-importer/subscriptions","organizations_url":"https://api.github.com/users/modelica-trac-importer/orgs","repos_url":"https://api.github.com/users/modelica-trac-importer/repos","events_url":"https://api.github.com/users/modelica-trac-importer/events{/privacy}","received_events_url":"https://api.github.com/users/modelica-trac-importer/received_events","type":"User","site_admin":false},"created_at":"2016-12-26T20:19:38Z","updated_at":"2016-12-26T20:19:38Z","body":"**Modified by otter on 11 Jun 2015 14:32 UTC**"}}
{"actor":{"display_login":"modelica-trac-importer"}}