## Developing Understanding

### Exercise 2-1

Insight Maker doesn’t complain because its simulation engine is smart enough to convert the myriad of similar dimensions, e.g., miles, kilometers, feet, etc. However, it’s best to make conversions explicit, otherwise models become very difficult to understand.

### Exercise 2-2

One alternative would be to start with Distance to Grandmas House = 0 and add to the stock as Red walks toward it. This way the model is tracking the distance traveled rather than the distance remaining.

### Exercise 2-5

It takes time for a flow to change a stock and even longer for that flow to change a flow. It’s important to remember that reducing a flow still adds to the stock, just a bit slower.

### Exercise 2-6

There are actually two approaches: 1) Figure out how to shorten the delay; or 2) Slow down the action and wait for the feedback before further action. There are times when these approaches may be applied. Due to the nature of the situation there are other times when you simply need to act and then deal with the effects later.

## Models and Truth

### Exercise 4-1

It would be better to build a statistical model in this case.

### Exercise 4-2

It would be better to build a mechanistic model in this case.

### Exercise 4-5

1. Prediction

2. Inference

3. Prediction

4. Narrative

5. Narrative

6. Inference

## Building Confidence in Models

### Exercise 5-1

Minimum value: 0

Maximum value: 10,000,000 (this value is somewhat arbitrary but should be larger than the maximum size you expect this city to ever grow to)

### Exercise 5-2

We use a standard deviation of 4 as we lack any information on what the dispersion should be.

Round(Rand(5, 15))

### Exercise 5-3

Round(RandTriangular(0, 100, 20))

### Exercise 5-4

Round(RandLogNormal(20, 4))

We use a standard deviation of 4 as we lack any information on what the dispersion should be.

### Exercise 5-5

RandNormal(2.1, 0.3625)

### Exercise 5-6

RandNormal(0.837, 0.106)

## The Mathematics of Modeling

### Exercise 7-1

You can denote volume of water in the jar using the state variable *J*. Our equations will then be:

*J(0) = 40*

### Exercise 7-2

You can denote the healthy stock using state variable *H* and the infected stock *I*. Our equations will then be:

### Exercise 7-3

Approximately 8,865 animals.

### Exercise 7-4

### Exercise 7-5

### Exercise 7-6

### Exercise 7-7

20.0, 25.0, 29.0, 32.4, 35.5, 38.3

### Exercise 7-8

20.0, 27.0, 37.5, 53.9, 78.3, 124.5

### Exercise 7-9

20.0, 24.5, 28.3, 31.6, 34.6, 37.4

### Exercise 7-10

20.0, 29.1, 44.7, 73.6, 131.5, 260.4

## Equilibria and Stability Analysis

### Exercise 8-1

Stable Equilibria: A piece of rubber that returns to its original shape after pulled; a forest where trees grow back once cut down.

Unstable Equilibria: A ball balanced on top of a sloped roof; a pole balanced perfectly on the floor.

### Exercise 8-2

*X *= −2.30 and *X *= 1.30

### Exercise 8-3

*X *= 0, *π*, 2*π*, 3*π*, 4*π*, …

### Exercise 8-4

*X *= −1.82, *Y *= −1.36

### Exercise 8-5

*X *= 0, *Y *= 0 and *X *= −1.41, *Y *= −2 and *X *= 1.41, *Y *= −2

### Exercise 8-9

### Exercise 8-10

### Exercise 8-11

### Exercise 8-12

Eigenvalue of 6 with eigenvector of [1,1]. Eigenvalue of -2 with eigenvector of [-1,1].

### Exercise 8-13

Eigenvalue of 2 with eigenvector of [1,5]. Eigenvalue of 1 with eigenvector of [0,1].

### Exercise 8-14

Eigenvalue of *α − β* with eigenvector of [-1,1]. Eigenvalue of *β + α* with eigenvector of [1,1].

### Exercise 8-15

Eigenvalue of *α* with eigenvector of [1,0]. Eigenvalue of *β* with eigenvector of

### Exercise 8-16

- Unstable
- A saddle (unstable)
- Stable

### Exercise 8-17

- Unstable oscillations
- Damped oscillations (stable)
- Stable oscillations

### Exercise 8-18

- Unstable
- Stable
- Unstable

### Exercise 8-19

Equilibrium *X* = 2, *Y* = −2 is unstable.

*X* = 0, *Y* = *−*2 is an unstable saddle point.

### Exercise 8-20

Equilibrium *Q* = 1, *R* = 1 is stable if *α* ≥ 0. Otherwise it is unstable.

*Q* = 1, *R* = *−*1 is unstable.

### Exercise 8-21

The first equilibrium has no wolves and is unstable.

The second equilibrium is when the population size is equal to the carrying capacity. This equilibrium is stable.

## Optimization and Complexity

### Exercise 9-1

Squared error:

([Widgets]-[Historical Production])^2

Absolute value error:

Abs([Widgets]-[Historical Production])

### Exercise 9-2

([Simulated]-[Historical])^4

### Exercise 9-3

The optimizer can always minimize this simply making Simulated as small as possible. This will not result in a fit to the historical data.

### Exercise 9-7

Change:

nullError += Math.pow(results.value(historical)[t] – average, 2);

simulatedError += Math.pow(results.value(historical)[t] – results.value(simulated)[t], 2);

To:

nullError += Math.abs(results.value(historical)[t] – average);

simulatedError += Math.abs(results.value(historical)[t] – results.value(simulated)[t]);

### Exercise 9-10

Example procedure:

1. Find the average hamster size at each time period by taking the mean of observations at that period.

2. Define two variables in the model: Infant Rate and Juvenile Rate.

3. Define an error primitive Error the equation taking the absolute value of the difference between the simulated size and the average empirical size.

4. Run the optimizer to minimize this error term by adjusting the two rate variables.

## Modeling With Agents

### Exercise 10-2

1. Timeout trigger with value 10 days.

2. Probability trigger with value 20% (assuming time units of years).

3. Condition trigger. Value: [Volume] > 5

### Exercise 10-4

{2, 1.8, 1.9, 1.5}.Filter(x < 1.95).Max()

or

Max(Filter({2, 1.8, 1.9, 1.5}, x < 1.95))

### Exercise 10-5

(a^2).Median()

or

Median(a^2)

### Exercise 10-6

Intersection(a, b).Min()

or

Min(Intersection(a, b))

### Exercise 10-7

a.Sum()/a.Length()

or

Sum(a)/Length(a)

### Exercise 10-8

[Population].FindState([Infected]).FindState([Female])

### Exercise 10-9

Union([Population].FindNotState([Infected]), [Population].FindState([Female]))

### Exercise 10-10

Mean([Population].FindState([Male]).Value([Height]))-Mean([Population].FindState([Female]).Value([Height]))

### Exercise 10-11

Self.MoveTowards([Population.FindState([Healthy]).FindFurthest(Self), {2 Meters})

### Exercise 10-12

range(x) <- max(x)-min(x)

or

Function Range(x)

Max(x)-Min(x)

End Function

### Exercise 10-13

Function Fib(n)

If n = 1 or n = 2 Then

1

Else

Fib(n-1) + Fib(n-2)

End If

End Function

The 15th Fibonacci number is 610.

## Going Global

### Exercise 11-1

This **<b>**text is **<i>**italic**</i>** and bold.**</b>**

### Exercise 11-2

Ordered list:

**<ol>**

** <li>**Croatia**</li>**

**<li>**Greece**</li>**

**<li>**Peru**</li>**

**</ol>**

Unordered list:

**<ul>**

** <li>**Croatia**</li>**

** <li>**Greece**</li>**

** <li>**Peru**</li>**

**</ul>**

### Exercise 11-4

u **{**

**color:** green**;**

**}**

### Exercise 11-5

a **{**

**border:** solid 2px red**;**

**}**

### Exercise 11-6

**var** a = prompt(“Enter the first number:”);

**var** b = prompt(“Enter the second number:”);

**var** sum = a+b;

alert(“Their sum is: “+sum);

### Exercise 11-8

input **{**

**background-color:** yellow**;**

**color:** navy**;**

**}**

### Exercise 11-9

Change the alert to:

alert(“Failed! You need “+(5000000000-pop)+” more people!”);

**Article and header image source:** Beyond Connecting the Dots. Reproduced by permission.