Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualization framework with animation #7

Open
abeham opened this issue Sep 24, 2018 · 8 comments
Open

Visualization framework with animation #7

abeham opened this issue Sep 24, 2018 · 8 comments

Comments

@abeham
Copy link
Member

abeham commented Sep 24, 2018

It would be great if a simple animation framework could be integrated into Sim# in a way that visual objects can be defined and updates to the visual objects be specified during execution of the process.

Currently only the log output is available.

Such a stream of changes could then be played forward, backward, etc. and be useful in determining how the simulation works. Maybe something like Review.

@abeham
Copy link
Member Author

abeham commented Aug 30, 2019

Salabim also has built-in animation.

@linyanghuan
Copy link

Have you ever thought of using Unity3D as a visualization platform?

@abeham
Copy link
Member Author

abeham commented May 27, 2021

So far we have created visualizations mostly on top of a simulation in the following way:

  1. We have a shared object model of the world state
  2. We have a simulation model that modifies that world state
  3. We have a visualization of the world state

Then we grab with a certain frequency the current world state object and put it into the visualization. You can do this with any kind of technology and with the current version of Sim#. This creates animations, and is rather easy to handle, though a lot of data is being exchanged (depending on the size of the world state). The difficulty when modeling is to decide what is included in the world state and what is excluded.

For instance, to make it more clear with what I mean with included vs excluded: Consider the simulation of a warehouse admission process. There is the arrival time of the next parcel. This date is known to the simulation, because some process is suspended until that time (i.e., a state of the simulation). Now the question is, is that arrival time also part of the world state that you'd make public and if yes in which way in its exact and precise way or in a noisy and uncertain way. I think this highly depends on your use case. If you intend to initialize the simulation given just such a representation of the world state then you'd have to put everything in that state in full precision and no local state must exist in any process or class. If you intend to portray that system as someone would be able to observe it also in the real world, there's these things that you'd hide from the world state and only represent what you can access also in the real world through data bases and by actually inspecting that item/process in the real world and you'd want to add uncertainty to that information. If you just want visualization, uncertainty and noise is not required as part of the world state, but if you have an interactive process with the simulation, e.g. a real-time simulation where you want to simulate the effects of a decision maker, then uncertainty and noise is very important.

So, you asked for my thoughts.

And further thinking, why do I need to care about 2D, 3D, unity, web, winforms, etc.? I think having an object representation of the state of a queue should be enough so that someone with visualization skills represents that in a graphical way. Right now, this is impaired in that the object representation of a queue is integrated with the processes and functionality and many properties are not publicly accessible. If we can somehow achieve a composable state description where you can "plug" on top simulation objects, processes, and entities that will modify these parts of the state, then I think that'd be a very cool feature and would support any kind of visualization very well.

So far we have an implementation for a deeper integration of visualization created by Klara Durst who realized a web-based visualization that is currently in a fork. This includes a visual language in the form of certain shapes and allows you to describe your state and changes with that visual language (and the corresponding API), e.g. resources and have processes directly interact with the visualization framework in order to trigger an animation. The advantage is that creating simple simulations and visualizations is easier. But I fear for more complex cases it's not sufficient and you have a rather tight integration, e.g. your processes need to trigger an animation explicitely. Exactly the last thing is what I personally have tried to avoid with the shared world state approach. I usually want to make processes that are pure and simple.

@hols-zhaw
Copy link

Hi - I haven't been using Sim# for a long time now, but rather used Salabim that has an animation framework built in. Now we are considering to use Sim# for a web-based solution, since Salabim uses Tk for the animation and is therefore desktop-bound.

Can anyone recommend an animation framework in .NET that can be used for the approach that you describe (grab the system state at a certain frequency) and can be used in a web-context (ideally WebAssembly)? Would you be a share an example? Thanks!

@abeham
Copy link
Member Author

abeham commented Apr 5, 2023

I can't share an example, because we only have non-public code, but we used this approach in https://dynstack.adaptop.at. The simulation code is public: https://github.com/dynstack/dynstack but not the visualization, because this is integrated into a blazor web app which is linked to a database.

However, the approach is, as I said, describe your world state in form of a protobuf object, serialize this and dump it into some database. Then, load it from the database into the blazor webapp and draw a visualization of the state as an SVG. Then visualize the dynamics, by taking the difference in the simulated timestamps as a delay.

@GR8DAN
Copy link

GR8DAN commented Apr 5, 2023

C# supports compilation to WebAssembly (WASM). I've been wondering if using HTML Canvas as a drawing surface for animation would be worth a try. See: Draw Animated Graphics in the Browser with Blazor WebAssembly and Blazor Extensions Canvas.

@hols-zhaw
Copy link

Thank you very much! I'll take a look at both suggestions and come back with an update.

@Amr-Abdelaziz
Copy link

Thank you very much! I'll take a look at both suggestions and come back with an update.

Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants