Computer Simulation - Abandoned

0 Conversations

This entry has been abandoned, as I no longer study computer science, and hence have no desire to finish the entry. Perhaps some other researcher will turn this entry into a finished product, but that researcher isn't me!

Whenever people talk about a virtual world, as opposed to the real world, chances are they're talking about a simulation: virtual reality simulates reality and virtual chatrooms simulate (badly) people chatting in a room. Such simulations are all about fun.

But simulations are more versatile than that, and are used in a variety of situations were failure in the real world is unacceptable, such as chemical factories, nuclear power stations, or the software used to power Satellites. By finding out when things go wrong in the simulation, they can make sure they only kill virtual people.

They are also useful when modification is costly in the real world. For example, road planners look at models of traffic through a city in order to find out how they can change the roads, or add speed bumps, so that the driver frustration level is highest. This sort of care and attention leads to such masterpieces as the M25.

Creating a Simulation

The first thing to do when creating a simulation is to observe the thing you want to simulate in practice. Closely. Then, from your observations, try to come up with rough rules that seem to govern behaviour, such as 'When a book uses an equation, half the readers will get confused'.

Next you use this to create a computer program which performs the simulation. It's possible to combine this with the first step by using a neural network or some other AI method, which can both figure out the rules, and apply them. However, this is very much an experimental idea.

Finally, you have to measure the information that you want from your simulation. Whereas the simulation tells you its precise state at any one time, what are often required are averages and so forth, such as the average traffic flow along some road, or how much variation in the speed there is along a school road.

Discrete versus Continuous

Simulations can either use discrete variables, such as the number of items waiting at various stages of the production line, or continuous, such as the amounts of some chemical in a vat.

Similarly they can use discrete time, or continuous time. Continuous time is what we all think about when we think of time, but discrete time is when the value of something is only defined at certain points. For example, the number of people watching a weekly TV show is a discrete variable over discrete time.

Discrete variables are a lot easier to deal with, so they're the best to work with. Even where things are actually continuous, people often tend to assume their discrete anyway to make their life easier.

Event-based Simulations

The best way to create an accurate simulation is to make it event-based, and specialised programming languages have been set up to do precisely that, such as Simula.

The key to an event-based simulation is a big pile of all the events that are scheduled to happen in the future. The simulation then goes repeatedly through the following loop:

  1. Remove the event that would happen next from the pile (ie, the one with the smallest time).
  2. Set the simulation time to be the time of this event.
  3. Perform whatever action is appropriate because of the event.
  4. Goto 1

More advanced simulators specify a target for the event, and the event will be processed according to both the target and the event. As a total sideline, this is part of the origin of Object Orientated Programming.

Carwash Example

A really simple example would be a carwash.

Pros and Cons

Bookmark on your Personal Space

Conversations About This Entry

There are no Conversations for this Entry



Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry

Written and Edited by

Currently in:


h2g2 is created by h2g2's users, who are members of the public. The views expressed are theirs and unless specifically stated are not those of the Not Panicking Ltd. Unlike Edited Entries, Entries have not been checked by an Editor. If you consider any Entry to be in breach of the site's House Rules, please register a complaint. For any other comments, please visit the Feedback page.

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more