15.08.2015 Views

Introduction to the Modeling and Analysis of Complex Systems

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.3. SIMULATING DISCRETE-TIME MODELS WITH ONE VARIABLE 39Linear equations are always analytically solvable, while nonlinear equations don’thave analytical solutions in general.Here, an analytical solution means a solution written in <strong>the</strong> form <strong>of</strong> x t = f(t) withoutusing state variables on <strong>the</strong> right h<strong>and</strong> side. This kind <strong>of</strong> solution is also called a closedformsolution because <strong>the</strong> right h<strong>and</strong> side is “closed,” i.e., it only needs t <strong>and</strong> doesn’t needx. Obtaining a closed-form solution is helpful because it gives you a way <strong>to</strong> calculate (i.e.,predict) <strong>the</strong> system’s state directly from t at any point in time in <strong>the</strong> future, without actuallysimulating <strong>the</strong> whole his<strong>to</strong>ry <strong>of</strong> its behavior. Unfortunately this is not possible for nonlinearsystems in most cases.4.3 Simulating Discrete-Time Models with One VariableNow is <strong>the</strong> time <strong>to</strong> do our very first exercise <strong>of</strong> computer simulation <strong>of</strong> discrete-time modelsin Python. Let’s begin with this very simple linear difference equation model <strong>of</strong> a scalarvariable x:x t = ax t−1 (4.12)Here, a is a model parameter that specifies <strong>the</strong> ratio between <strong>the</strong> current state <strong>and</strong> <strong>the</strong>next state. Our objective is <strong>to</strong> find out what kind <strong>of</strong> behavior this model will show throughcomputer simulation.When you want <strong>to</strong> conduct a computer simulation <strong>of</strong> any sort, <strong>the</strong>re are at least threeessential things you will need <strong>to</strong> program, as follows:Three essential components <strong>of</strong> computer simulationInitialize. You will need <strong>to</strong> set up <strong>the</strong> initial values for all <strong>the</strong> state variables <strong>of</strong> <strong>the</strong>system.Observe. You will need <strong>to</strong> define how you are going <strong>to</strong> moni<strong>to</strong>r <strong>the</strong> state <strong>of</strong> <strong>the</strong> system.This could be done by just printing out some variables, collecting measurementsin a list structure, or visualizing <strong>the</strong> state <strong>of</strong> <strong>the</strong> system.Update. You will need <strong>to</strong> define how you are going <strong>to</strong> update <strong>the</strong> values <strong>of</strong> thosestate variables in every time step. This part will be defined as a function, <strong>and</strong> itwill be executed repeatedly.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!