Hi all,
as you in this video, I was able to use Roassal to visualize a multi-agent simulation in a grid. https://www.youtube.com/watch?v=EXvsdL5sTRw
Now I would like to do animate the simulation without using I/O from user. I try to use the VIVA framework without any success ...
Basically, I'm doing one step of the model, modify the elements of the view and do a signalUpdate on the view.
|choosenModel aModel nbSteps | choosenModel := ECEC. nbSteps := 200. aModel := choosenModel initialize;new. aModel initSimulation. v := RTView new. b := RTMenuBuilder new view:v. n := (RTMultiLinearColor new) colors: (ColorPalette sequential colors: 9 scheme: 'Greens'). c := n command: [:cells| (cells biomass)/10.0.]. b menu: 'step' background: Color red callback:[ |es| aModel runStep. v removeAllElements. es := (RTBox new color: c; size: 25) elementsOn: aModel theVegetationUnits. v addAll: es. RTGridLayout new gapSize:0; lineItemsCount: aModel spaceModel column; on: v elements. v signalUpdate. ]. v
Any hints ?
Hi Serge!
Your video is really cool. I do not understand the problem you describe. The user has to press the red button to start the animation. What do you mean by I/O from user?
Alexandre
On Thu, Jun 4, 2015 at 3:28 PM, Alexandre Bergel alexandre.bergel@me.com wrote:
Hi Serge!
Your video is really cool. I do not understand the problem you describe. The user has to press the red button to start the animation. What do you mean by I/O from user?
Sorry Alex, not to be clear enough.
Maybe this is not visible on the video, but I have to click on the step button to run one step of the model and update the viz. I want to do the same but without any user action.
I think he means that he wants to build the animation continuously without triggering it from the button :).
Cheers, Doru
On Thu, Jun 4, 2015 at 3:28 PM, Alexandre Bergel alexandre.bergel@me.com wrote:
Hi Serge!
Your video is really cool. I do not understand the problem you describe. The user has to press the red button to start the animation. What do you mean by I/O from user?
Alexandre
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
On Jun 4, 2015, at 10:16 AM, Serge Stinckwich serge.stinckwich@gmail.com wrote:
Hi all,
as you in this video, I was able to use Roassal to visualize a multi-agent simulation in a grid. https://www.youtube.com/watch?v=EXvsdL5sTRw
Now I would like to do animate the simulation without using I/O from user. I try to use the VIVA framework without any success ...
Basically, I'm doing one step of the model, modify the elements of the view and do a signalUpdate on the view.
|choosenModel aModel nbSteps | choosenModel := ECEC. nbSteps := 200. aModel := choosenModel initialize;new. aModel initSimulation. v := RTView new. b := RTMenuBuilder new view:v. n := (RTMultiLinearColor new) colors: (ColorPalette sequential colors: 9 scheme: 'Greens'). c := n command: [:cells| (cells biomass)/10.0.]. b menu: 'step' background: Color red callback:[ |es| aModel runStep. v removeAllElements. es := (RTBox new color: c; size: 25) elementsOn: aModel theVegetationUnits. v addAll: es. RTGridLayout new gapSize:0; lineItemsCount: aModel spaceModel column; on: v elements. v signalUpdate. ]. v
Any hints ?
-- Serge Stinckwich UCBN & UMI UMMISCO 209 (IRD/UPMC) Every DSL ends up being Smalltalk http://www.doesnotunderstand.org/ _______________________________________________ Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
On Thu, Jun 4, 2015 at 3:36 PM, Tudor Girba tudor@tudorgirba.com wrote:
I think he means that he wants to build the animation continuously without triggering it from the button :).
Yes, thank you Doru ;-)
When I grow up I want to replace Google Translate for English to English :)
Doru
On Thu, Jun 4, 2015 at 3:40 PM, Serge Stinckwich <serge.stinckwich@gmail.com
wrote:
On Thu, Jun 4, 2015 at 3:36 PM, Tudor Girba tudor@tudorgirba.com wrote:
I think he means that he wants to build the animation continuously
without
triggering it from the button :).
Yes, thank you Doru ;-)
-- Serge Stinckwich UCBN & UMI UMMISCO 209 (IRD/UPMC) Every DSL ends up being Smalltalk http://www.doesnotunderstand.org/ _______________________________________________ Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
What I would try is to take the code of the callback block for the button and fork it in a new thread. Or have the button launch the thread. e.g.:
b menu: ‘animate' background: Color red callback:[ [ |es| aModel runStep. v removeAllElements. es := (RTBox new color: c; size: 25) elementsOn: aModel theVegetationUnits. v addAll: es. RTGridLayout new gapSize:0; lineItemsCount: aModel spaceModel column; on: v elements. v signalUpdate. ] fork. ].
I have not tried this though, I’m just inventing on the fly … but I guess it should work OK. Just don’t click the button more than once ;-)
On Jun 4, 2015, at 10:16, Serge Stinckwich serge.stinckwich@gmail.com wrote:
Hi all,
as you in this video, I was able to use Roassal to visualize a multi-agent simulation in a grid. https://www.youtube.com/watch?v=EXvsdL5sTRw
Now I would like to do animate the simulation without using I/O from user. I try to use the VIVA framework without any success ...
Basically, I'm doing one step of the model, modify the elements of the view and do a signalUpdate on the view.
|choosenModel aModel nbSteps | choosenModel := ECEC. nbSteps := 200. aModel := choosenModel initialize;new. aModel initSimulation. v := RTView new. b := RTMenuBuilder new view:v. n := (RTMultiLinearColor new) colors: (ColorPalette sequential colors: 9 scheme: 'Greens'). c := n command: [:cells| (cells biomass)/10.0.]. b menu: 'step' background: Color red callback:[ |es| aModel runStep. v removeAllElements. es := (RTBox new color: c; size: 25) elementsOn: aModel theVegetationUnits. v addAll: es. RTGridLayout new gapSize:0; lineItemsCount: aModel spaceModel column; on: v elements. v signalUpdate. ]. v
Any hints ?
-- Serge Stinckwich UCBN & UMI UMMISCO 209 (IRD/UPMC) Every DSL ends up being Smalltalk http://www.doesnotunderstand.org/ _______________________________________________ Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
---> Save our in-boxes! http://emailcharter.org <---
Johan Fabry - http://pleiad.cl/~jfabry PLEIAD lab - Computer Science Department (DCC) - University of Chile
On Thu, Jun 4, 2015 at 3:48 PM, Johan Fabry jfabry@dcc.uchile.cl wrote:
What I would try is to take the code of the callback block for the button and fork it in a new thread. Or have the button launch the thread. e.g.:
b menu: ‘animate' background: Color red callback:[ [ |es| aModel runStep. v removeAllElements. es := (RTBox new color: c; size: 25) elementsOn: aModel theVegetationUnits. v addAll: es. RTGridLayout new gapSize:0; lineItemsCount: aModel spaceModel column; on: v elements. v signalUpdate. ] fork. ].
I have not tried this though, I’m just inventing on the fly … but I guess it should work OK. Just don’t click the button more than once ;-)
I would like to avoid fork.
I try to use VIVA and do the following, but nothing happens:
|choosenModel aModel nbSteps | choosenModel := ECEC. nbSteps := 200. aModel := choosenModel initialize;new. aModel initSimulation. v := RTView new. b := RTMenuBuilder new view:v. n := (RTMultiLinearColor new) colors: (ColorPalette sequential colors: 9 scheme: 'YlGnBu'). c := n command: [:cells| (cells biomass)/10.0.]. timer := VITimer new. timer repeat. time := VIAnimatedValue new evaluator:[:t| |es| aModel runStep. v clean. es := (RTBox new color: c; size: 25) elementsOn: aModel theVegetationUnits. v addAll: es. RTGridLayout new gapSize:0; lineItemsCount: aModel spaceModel column; on: v elements. v signalUpdate. t ]; timer: timer; yourself. time start. v addAnimation: (TRResetAllShapes new). v
Hi Serge,
You are perfectly right to avoid fork in my opinion. I am convinced that threads are evil language constructions. I have just improved RTActiveAnimation. You can get inspiration from: -=-=-=-=-=-=-=-=-=-=-=-= | v anim | v := RTView new.
anim := RTActiveAnimation new. anim intervalInMilliseconds: 1000. anim blockToExecute: [ | e | e := (RTEllipse new size: 40 atRandom; color: (Color red alpha: 0.2)) element. e translateTo: (500 atRandom @ 500 atRandom) - (250 @ 250). v add: e. ]. anim inView: v. ^ v
-=-=-=-=-=-=-=-=-=-=-=-=
You need to update Roassal. Let us know how it goes
Cheers, Alexandre
On Jun 4, 2015, at 10:55 AM, Serge Stinckwich serge.stinckwich@gmail.com wrote:
On Thu, Jun 4, 2015 at 3:48 PM, Johan Fabry jfabry@dcc.uchile.cl wrote:
What I would try is to take the code of the callback block for the button and fork it in a new thread. Or have the button launch the thread. e.g.:
b menu: ‘animate' background: Color red callback:[ [ |es| aModel runStep. v removeAllElements. es := (RTBox new color: c; size: 25) elementsOn: aModel theVegetationUnits. v addAll: es. RTGridLayout new gapSize:0; lineItemsCount: aModel spaceModel column; on: v elements. v signalUpdate. ] fork. ].
I have not tried this though, I’m just inventing on the fly … but I guess it should work OK. Just don’t click the button more than once ;-)
I would like to avoid fork.
I try to use VIVA and do the following, but nothing happens:
|choosenModel aModel nbSteps | choosenModel := ECEC. nbSteps := 200. aModel := choosenModel initialize;new. aModel initSimulation. v := RTView new. b := RTMenuBuilder new view:v. n := (RTMultiLinearColor new) colors: (ColorPalette sequential colors: 9 scheme: 'YlGnBu'). c := n command: [:cells| (cells biomass)/10.0.]. timer := VITimer new. timer repeat. time := VIAnimatedValue new evaluator:[:t| |es| aModel runStep. v clean. es := (RTBox new color: c; size: 25) elementsOn: aModel theVegetationUnits. v addAll: es. RTGridLayout new gapSize:0; lineItemsCount: aModel spaceModel column; on: v elements. v signalUpdate. t ]; timer: timer; yourself. time start. v addAnimation: (TRResetAllShapes new). v
-- Serge Stinckwich UCBN & UMI UMMISCO 209 (IRD/UPMC) Every DSL ends up being Smalltalk http://www.doesnotunderstand.org/
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Alex, they are not evil, they are powerful. And with great power comes great responsibilities ;-)
On Jun 4, 2015, at 17:52, Alexandre Bergel alexandre.bergel@me.com wrote:
I am convinced that threads are evil language constructions.
---> Save our in-boxes! http://emailcharter.org <---
Johan Fabry - http://pleiad.cl/~jfabry PLEIAD lab - Computer Science Department (DCC) - University of Chile
On Fri, Jun 5, 2015 at 12:07 AM, Johan Fabry jfabry@dcc.uchile.cl wrote:
Alex, they are not evil, they are powerful. And with great power comes great responsibilities ;-)
And great responsibility is a great risk which you need to mitigate, for example by not using threads. :)
But maybe using Job (see Job class>>example) might be a more manageable replacement for fork.
Peter
On Jun 4, 2015, at 19:51, Peter Uhnák i.uhnak@gmail.com wrote:
On Fri, Jun 5, 2015 at 12:07 AM, Johan Fabry <jfabry@dcc.uchile.cl mailto:jfabry@dcc.uchile.cl> wrote:
Alex, they are not evil, they are powerful. And with great power comes great responsibilities ;-) And great responsibility is a great risk which you need to mitigate, for example by not using threads. :)
But maybe using Job (see Job class>>example) might be a more manageable replacement for fork.
Yes, it would be nice to have a cleaner abstraction for multithreading in the image, but creating this is not an easy task. There are a lot of use cases for such an abstraction. Parallel programming is hard, that’s just the way it is.
I had a quick look at Job and its examples and it does not really seem to abstract that much. example2 even uses fork :-P
---> Save our in-boxes! http://emailcharter.org <---
Johan Fabry - http://pleiad.cl/~jfabry PLEIAD lab - Computer Science Department (DCC) - University of Chile
Alex, they are not evil, they are powerful. And with great power comes great responsibilities ;-)
In my experience, threads are useful when implementing a web server. Beside this, I have never faced situations where threads is key to success. :-)
Cheers, Alexandre
On Jun 4, 2015, at 17:52, Alexandre Bergel alexandre.bergel@me.com wrote:
I am convinced that threads are evil language constructions.
---> Save our in-boxes! http://emailcharter.org <---
Johan Fabry - http://pleiad.cl/~jfabry PLEIAD lab - Computer Science Department (DCC) - University of Chile
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
On Jun 5, 2015, at 10:18, Alexandre Bergel alexandre.bergel@me.com wrote:
Alex, they are not evil, they are powerful. And with great power comes great responsibilities ;-)
In my experience, threads are useful when implementing a web server. Beside this, I have never faced situations where threads is key to success. :-)
Let’s work on robotics or distributed systems together, I’d like you to see you handle that without the use of threads ;-)
---> Save our in-boxes! http://emailcharter.org <---
Johan Fabry - http://pleiad.cl/~jfabry PLEIAD lab - Computer Science Department (DCC) - University of Chile
On Thu, Jun 4, 2015 at 10:52 PM, Alexandre Bergel alexandre.bergel@me.com wrote:
Hi Serge,
You are perfectly right to avoid fork in my opinion. I am convinced that threads are evil language constructions. I have just improved RTActiveAnimation. You can get inspiration from: -=-=-=-=-=-=-=-=-=-=-=-= | v anim | v := RTView new.
anim := RTActiveAnimation new. anim intervalInMilliseconds: 1000. anim blockToExecute: [ | e | e := (RTEllipse new size: 40 atRandom; color: (Color red alpha: 0.2)) element. e translateTo: (500 atRandom @ 500 atRandom) - (250 @ 250). v add: e. ]. anim inView: v. ^ v
-=-=-=-=-=-=-=-=-=-=-=-=
Great ! Thank you Alex.
I made another example:
| v anim | v := RTView new.
anim := RTActiveAnimation new. anim intervalInMilliseconds: 100. anim blockToExecute: [ |e| v clean. (1 to: 400) do:[:i| e := (RTBox new color: Color random; size: 25) element. v add: e].
RTGridLayout new gapSize:0; lineItemsCount: 20; on:v elements. ]. anim inView: v. ^ v
It works without problem ;-)
There is some delay from time to time, I guess this is related to the GC ?
There is some delay from time to time, I guess this is related to the GC ?
Yes, this script is probably the most inefficient way to implement this. On my machine, there is a pause every 9 seconds approx.
Consider this slightly modified script:
| v anim | v := RTView new.
shape := RTBox new color: [ :o | Color random ]; size: 25.
anim := RTActiveAnimation new. anim intervalInMilliseconds: 100. anim blockToExecute: [ |e| v clean. (1 to: 400) do:[:i| e := shape element. v add: e].
RTGridLayout new gapSize:0; lineItemsCount: 20; on:v elements. ]. anim inView: v. ^ v
Shape are reused and not created each time. Again on my machine, the pause occurs after ~15 seconds. Removing, creating and adding elements at each refresh is not efficient at all. You can simply update the property of the element by either sending #updateShape or directly modifying the trachel shape.
In that case, you need a model and the element reflect the property of the model. There is no need to recreate elements all the time.
Cheers, Alexandre
This is a new multi-agent simulation with the animation now:
https://www.youtube.com/watch?v=tadvdsSC98w
Thank you Alex !
On Thu, Jun 4, 2015 at 10:52 PM, Alexandre Bergel alexandre.bergel@me.com wrote:
Hi Serge,
You are perfectly right to avoid fork in my opinion. I am convinced that threads are evil language constructions. I have just improved RTActiveAnimation. You can get inspiration from: -=-=-=-=-=-=-=-=-=-=-=-= | v anim | v := RTView new.
anim := RTActiveAnimation new. anim intervalInMilliseconds: 1000. anim blockToExecute: [ | e | e := (RTEllipse new size: 40 atRandom; color: (Color red alpha: 0.2)) element. e translateTo: (500 atRandom @ 500 atRandom) - (250 @ 250). v add: e. ]. anim inView: v. ^ v
-=-=-=-=-=-=-=-=-=-=-=-=
You need to update Roassal. Let us know how it goes
Cheers, Alexandre
On Jun 4, 2015, at 10:55 AM, Serge Stinckwich serge.stinckwich@gmail.com wrote:
On Thu, Jun 4, 2015 at 3:48 PM, Johan Fabry jfabry@dcc.uchile.cl wrote:
What I would try is to take the code of the callback block for the button and fork it in a new thread. Or have the button launch the thread. e.g.:
b menu: ‘animate' background: Color red callback:[ [ |es| aModel runStep. v removeAllElements. es := (RTBox new color: c; size: 25) elementsOn: aModel theVegetationUnits. v addAll: es. RTGridLayout new gapSize:0; lineItemsCount: aModel spaceModel column; on: v elements. v signalUpdate. ] fork. ].
I have not tried this though, I’m just inventing on the fly … but I guess it should work OK. Just don’t click the button more than once ;-)
I would like to avoid fork.
I try to use VIVA and do the following, but nothing happens:
|choosenModel aModel nbSteps | choosenModel := ECEC. nbSteps := 200. aModel := choosenModel initialize;new. aModel initSimulation. v := RTView new. b := RTMenuBuilder new view:v. n := (RTMultiLinearColor new) colors: (ColorPalette sequential colors: 9 scheme: 'YlGnBu'). c := n command: [:cells| (cells biomass)/10.0.]. timer := VITimer new. timer repeat. time := VIAnimatedValue new evaluator:[:t| |es| aModel runStep. v clean. es := (RTBox new color: c; size: 25) elementsOn: aModel theVegetationUnits. v addAll: es. RTGridLayout new gapSize:0; lineItemsCount: aModel spaceModel column; on: v elements. v signalUpdate. t ]; timer: timer; yourself. time start. v addAnimation: (TRResetAllShapes new). v
-- Serge Stinckwich UCBN & UMI UMMISCO 209 (IRD/UPMC) Every DSL ends up being Smalltalk http://www.doesnotunderstand.org/
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Extremely cool!
Can you make a screensaver out of that? ;-)
On Jun 5, 2015, at 04:16, Serge Stinckwich serge.stinckwich@gmail.com wrote:
This is a new multi-agent simulation with the animation now:
https://www.youtube.com/watch?v=tadvdsSC98w
Thank you Alex !
---> Save our in-boxes! http://emailcharter.org <---
Johan Fabry - http://pleiad.cl/~jfabry PLEIAD lab - Computer Science Department (DCC) - University of Chile
Really nice Serge! Would you mind to share with us the playground's code via stfx?
Thanks,
Offray
On 05/06/15 02:16, Serge Stinckwich wrote:
This is a new multi-agent simulation with the animation now:
https://www.youtube.com/watch?v=tadvdsSC98w
Thank you Alex !
On Thu, Jun 4, 2015 at 10:52 PM, Alexandre Bergel alexandre.bergel@me.com wrote:
Hi Serge,
You are perfectly right to avoid fork in my opinion. I am convinced that threads are evil language constructions. I have just improved RTActiveAnimation. You can get inspiration from: -=-=-=-=-=-=-=-=-=-=-=-= | v anim | v := RTView new.
anim := RTActiveAnimation new. anim intervalInMilliseconds: 1000. anim blockToExecute: [ | e | e := (RTEllipse new size: 40 atRandom; color: (Color red alpha: 0.2)) element. e translateTo: (500 atRandom @ 500 atRandom) - (250 @ 250). v add: e. ]. anim inView: v. ^ v
-=-=-=-=-=-=-=-=-=-=-=-=
You need to update Roassal. Let us know how it goes
Cheers, Alexandre
On Jun 4, 2015, at 10:55 AM, Serge Stinckwich serge.stinckwich@gmail.com wrote:
On Thu, Jun 4, 2015 at 3:48 PM, Johan Fabry jfabry@dcc.uchile.cl wrote:
What I would try is to take the code of the callback block for the button and fork it in a new thread. Or have the button launch the thread. e.g.:
b menu: ‘animate' background: Color red callback:[ [ |es| aModel runStep. v removeAllElements. es := (RTBox new color: c; size: 25) elementsOn: aModel theVegetationUnits. v addAll: es. RTGridLayout new gapSize:0; lineItemsCount: aModel spaceModel column; on: v elements. v signalUpdate. ] fork. ].
I have not tried this though, I’m just inventing on the fly … but I guess it should work OK. Just don’t click the button more than once ;-)
I would like to avoid fork.
I try to use VIVA and do the following, but nothing happens:
|choosenModel aModel nbSteps | choosenModel := ECEC. nbSteps := 200. aModel := choosenModel initialize;new. aModel initSimulation. v := RTView new. b := RTMenuBuilder new view:v. n := (RTMultiLinearColor new) colors: (ColorPalette sequential colors: 9 scheme: 'YlGnBu'). c := n command: [:cells| (cells biomass)/10.0.]. timer := VITimer new. timer repeat. time := VIAnimatedValue new evaluator:[:t| |es| aModel runStep. v clean. es := (RTBox new color: c; size: 25) elementsOn: aModel theVegetationUnits. v addAll: es. RTGridLayout new gapSize:0; lineItemsCount: aModel spaceModel column; on: v elements. v signalUpdate. t ]; timer: timer; yourself. time start. v addAnimation: (TRResetAllShapes new). v
-- Serge Stinckwich UCBN & UMI UMMISCO 209 (IRD/UPMC) Every DSL ends up being Smalltalk http://www.doesnotunderstand.org/
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev