lundi 28 mars 2016

Assignment problems with simple random number generation in Modelica

I am relatively new to Modelica (Dymola-environment) and I am getting very desperate/upset that I cannot solve such a simple problem as a random number generation in Modelica and I hope that you can help me out. The simple function random produces a random number between 0 and 1 with an input seed seedIn[3] and produces the output seed seedOut[3] for the next time step or event. The call (z,seedOut) = random(seedIn); works perfectly fine.

The problem is that I cannot find a way in Modelica to compute this assignment over time by using the seedOut[3] as the next seedIn[3], which is very frustrating.

My simple program looks like this: *model Randomgenerator Real z; Integer seedIn3, seedOut[3]; equation (z,seedOut) = random(seedIn); algorithm seedIn := seedOut;

end Randomgenerator;*

I have tried nearly all possibilities with algorithm assignements, initial conditions and equations but none of them works. I just simply want to use seedOut in the next time step. One problem seems to be that when entering into the algorithm section, neither the initial conditions nor the values from the equation section are used.

I hope that you can help me with this problem.

Thanks, Daniel




Aucun commentaire:

Enregistrer un commentaire