Falcetto
Rapid Prototyping of Computer Simulations
 Introduction
 History
 Modeling
 Simulation
 Server Side
 Visualization
 GUI
 Community
 @ethertear

# Simulation – How a Model is processed

## Basic explanation of Modeling and Simulation

Computer Modeling and Simulation are how we use computers to predict the behavior of real world Systems.  A Computer Model is the collection of logic and data that represents a System.  A Computer Simulation is using the Computer Model to find out “what happens next.”  The goal of using computers to perform Modeling and Simulation is that they can be faster and more accurate than a person trying to calculate the logic.  Sometimes, a Computer Model is so complicated or inefficient, that it takes a “long time” for the Simulation to calculate its results.  A Computer Scientist’s job is to figure out how to tweak a Model to improve accuracy and speed, or at least to be able to trade accuracy for speed or speed for accuracy.

### Simulation modes

Discrete Event Simulations are the systems that computers like the most.  These are Simulations where things change only at certain times, but otherwise remain unchanged in-between these times.  These can be most useful for macroscopic systems, technical systems, or systems that have already been analyzed into convenient Models.  For instance, instead of Modeling how a person receives each paycheck and pays each bill on different days throughout a month, a financial Simulation may just say “each month they have this much income and these many bills” and do its processing a whole month at a time.

Continuous systems are the most natural systems, such as physics.  Imagine the classic apple falling from a tree example.  The apple continuously exists as it falls: it doesn’t just exist on the tree one second and on the ground the next.  These systems can be calculated with advanced math, which gets even more complicated with every aspect added to it.

## Continuous Simulation features

Continuous Simulations can never be done perfectly by our modern Digital Devices, but there are several techniques that have been developed to make it quite accurate.  The simplest technique is to make each processing cycle represent a very small amount of time, allowing the calculations and changes in the Simulation to be very small also, and less likely to be wrong or overshoot the correct answer.   Unfortunately, running a Simulation with a small time step can take a very long time to process.  The challenge is to find the largest time step possible, that still allows the changes to be small enough to be accurate.  The solution is a dynamic time step, where the amount of time may be different for each processing cycle.  When the changes are “too big”, the processing cycle is thrown away, and redone with a smaller time step.  When the changes are “too small”, a larger time step is used for the next processing cycle.  The result is quite like watching an action movie, where “boring” stuff goes quickly, but a shootout goes into “slow motion” allowing you to see more details.

Falcetto will handle the overhead of time step management.  Falcetto will default to a static time step, where the time step stays the same between cycles, as a beginner would likely expect each cycle to represent something “normal” like a second.  Falcetto provides many easy to use tools to manage dynamic time steps though:

·         Single place to set the default accuracy settings that will be used System wide.

·         (possibly unique to Falcetto) Each variable can have its own accuracy setting.

·         A variable can be set to be ignored for accuracy.  Some data types may not be eligible for accuracy settings, such as words, images, or object types.

·         Falcetto will pay attention to just how much it was “too big” or “too small” so that it can make a smart choice in the size of the new time step.

## Load Balancing Systems, Convergence Simulations

Sometimes a simulation is not trying to figure out the changes from moment to moment, but instead is trying to figure out how something is balanced within a single moment.  Consider an electric power grid: at any moment the power plants are outputting power, cities are consuming power, and power lines are transporting power with some losses.  The math to model a “steady state” of the power grid is complicated, but not nearly as complicated as a “dynamic state” simulation (like PowerWorld), so it could be a student’s assignment to model the “steady state” of a power grid.

Falcetto can be set to run a series of Convergence cycles, instead of, or in addition to, the normal time step processing.  The rules for Convergence cycles are different than for time step processing:  the expectation is that changes will be big to start with, and the simulation can stop when the changes are small.

Falcetto can combine time step and Convergence cycles in a simulation.  Again, consider the electric power grid.  The time step simulation can be used to determine how much power the city is consuming, such as more power during working hours, and less at night.  The time step simulation could also simulate how the power plants attempt to anticipate how much power they need to generate.  After each cycle of the time step simulation, the convergence would run to recalculate how much power is going over each line.  For more fun, add in logic to the time step simulation for lines to “trip” if they have too much power going through them.  Then, you can watch your simulation react as power lines fail, and see how power re-routes itself.  (Note: I wrote simulators like this during college using Flash, and thus had to build all the overhead that Falcetto will provide)

## Rapid Prototyping

Falcetto allows the User to rapidly try out new ideas, without being burdened by the overhead of graphics, user input, and data management.

### Pause, Edit, Resume

While running a Simulation, you may notice something is wrong with your Model, possibly several minutes into the Simulation.  Traditionally, you would need to stop your Simulation, edit your Model, and then restart your Simulation.   Falcetto allows you to fix it more quickly, as you can pause your Simulation, edit your Model, and then resume your Simulation.  This might not seem like a big difference, but consider how annoying it can be if the problem does not appear until 5 minutes has gone by, and also consider that your first attempt at fixing it may not work.  Traditionally, each attempt would take 5 minutes to find out if it worked, but with Falcetto you can find out immediately, and try again until it works.  In either case, after you’ve fixed the Model, you’ll want to restart the Simulation for the most accuracy.

## Exporting Data

Falcetto will allow the Simulation results, as well as the whole Model, to be exported out of Falcetto.  The export formats will initially be JSON and CSV, as those are both freely readable text formats.  From the JS/HTML application, this will manifest as “here is the data, now copy/paste to save the data” when in offline mode.  When online the data can be shared with the Community, which allows downloading the data in some extra formats.

Falcetto will provide some basic password protection support for its exported data.  This will be useful for situations where a teacher asks for assignments to be turned in via a shared network drive, or through an online forum (other than the Community).  This will also be useful if a student saves their data onto a flash drive, and wants to ensure that the data is unusable if the flash drive is stolen by an unscrupulous classmate.