Hive

=Problem Definition=
 * Project name: Hive
 * Class: 4IT495 Simulation of Systems (WS 2012/2013)
 * Author: Adam Sedláček
 * Model type: Agent-based simulation
 * Software used: NetLogo 5.0.3

As is known, the hive is a community that is very complex and is influenced by both internal and external factors. Also it is said, that hive is the only working communist and feminist community in the world. Therefore,the simulation was created to examine the influence of internal and external circumstances which influence the hive and the ecosystem in which they live. Especially I mean these factors:  Number and distance of flowers to pollinate  Number of workers and drones in the hive  How duration of winter affect stocks of honey and colony survival How number of workers affect pollination of flowers and therefore the number of flowers in neighborhood.  The goal of this hive simulation is to understand the dependencies among factors listed above.

=Method= Because of hive is multiagent system, NetLogo 5.0.3 is used for this simulation. NetLogo is powerful tool and is easy to learn. But it has also disadvantages. For example low speed and performance. Only standard NetLogo procedures and features was used, except some turtle´s shapes, which was created by author. To understand dependencies of individual factors, lot of data is needed. The results presented in this page comes from many repetitions of simulation with many different settings of model variables.

=Model= As it was said, hive is very complex community and it´s behavior is also very complicated. Therefore the model is simplified to be able get reasonable results at reasonable time. Although many real values of the variables are used in the model.

Model behavior
This model tries to imitate behavior of the hive and surrounding areas with flowers, including changing of day and night and season.

Model environment
In the model the world is a square with edge dimension of 200 patches. Bees can move and flowers grow in a space of 200 * 150 patches. The rest 50 patches are reserved for sky and the Sun. The world doesn't wrap horizontally and vertically, so it is not possible to move from one edge to opposite one in one step. Next sub-chapters describing behavior of individual parts of the model and we can distinguish these agents:

Sun
The Sun is not only visual element in the model, but it also determines behavior of the hive. When sun is beyond the horizon, bees are in the beehive. If Sun is on the sky, than new day begins and bees start to fly. How long the day is depends on how fast Sun goes across the sky.

Flowers
Flowers are important part of the model. They give food for bees. Every unpollinated flower is red and has variable nectar, which determines amount of nectar in the flower. It is defined as random number from 1 to 10. If variable nectar = 0, than flower is pollinated and it is ready to proliferate. There is also variable, which says how long does it take to new flowers grow. If this time is reached, than new flower grow in the von Neumann neighborhood of the pollinated flower which has orange color. Flowers also have variable age. (At the beginning of the simulation defined as random number from 0 to the value of variable, which defines how long flower lives before it dies.) If flower is not pollinated, than according to it´s age dies. (Dead flower has brown color.)

Beehive
Beehive is a "home" of bees, including workers, drones and queen. Also bee´s larvae (eggs in model)growing in the beehive. In the beehive are situated provisions of honey which is consumed by bees, when they are hungry. Bees are hidden here during the night and winter. Beehive is randomly situated on the grass in the model or is in the middle of the grass(depending on settings).

Workers
Workers are female bees which are responsible for pollinating the flowers and collecting the nectar. They fly random direction in the morning to find flowers. If they find them, they pollinate it and collect nectar. Every worker can collect only 3 mg (milligrams) from each flower in a row, then she moves and looking for another flower. When worker has 30 mg of nectar, then she returns to the beehive. If the worker is very close to beehive and has found the flower, then she tells other workers in the beehive direction of the flower and they fly this direction. If worker didn't find anything, then it returns to the beehive. Every worker consumes honey in the beehive. Worker consumes 4.5 mg of honey (nectar) a day (in the night and winter consumes a half). At the beginning of the simulation the value of energy is set for every worker to her maximum level. Maximum level of energy is defined as random-normal distribution, mean 22, standard deviation 2.5. This value describes how long can worker life without food. If variable energy = 0, then worker dies. If the value of energy is less than 5, than worker moves back to beehive for honey and if there is enough honey, then sets energy to the maximum energy. Workers has also age, which is set at the beginning of the simulation. The value of age is defined for each worker as random number from 0 to 40. If age is > 50 in the summer or > 180 in the winter, worker dies.

Drones
Drones are male bees which are responsible for fertilization of the queen´s eggs. They fly random direction and when they meet queen, they fertilize her and than die. If they don´t meet her, they fly back to the beehive and than fly random direction out of the beehive again. In case of honey consumption it is the same as workers except their max energy value, which is defined as random normal distribution, mean 18, sd 2.5. Just as workers, drones has age set and defined same as workers, except winter. This is because drones are expelled from beehive and the community at the beginning of the winter.

Queen
Queen is a female bee which is sexually mature and it is mother of all bees in the hive. She is responsible for laying eggs. Queen flies random direction and oviposits every two days if she is in the beehive. She needs to mate with at last six drones to be fertilized. If she is fertilized then she oviposits "worker´s" eggs. If she is not, she oviposits "drone´s" eggs. Just as workers and drones, queen has variable energy and max energy value is defined as random normal distribution, mean 100, sd 2. This difference is because of the fact that queen is preferred in honey allocation. That means, that queen is the last one who suffer from lack of honey in the beehive. In case of honey consumption, queen consumes 1.5 times more every day than worker/drone. Unlike workers and drones, queen lives much longer. In simulation it is 1000 days. There is always only one queen in the model.

Eggs
There are two types of the eggs in the model. The first one is the "worker´s" egg and the second one is "drone´s egg". Their attributes are the same, but from "worker´s" eggs  can hatch only workers and from drone´s ones only drones. Eggs consume the same amount of honey as mature worker/drone. Same as others, eggs has value of energy and maximum energy. Value of maximum energy is defined as random normal distribution, mean 15 st 2. Every egg has variable age. When it´s age reach 21 days, new worker/drone is hatched and egg "dies"

Patches

 * pollinated - true/false, if true, than flower is pollinated
 * nectar - current quantity of nectar in the flower
 * old - flower´s age at the beginning of the simulation
 * howold - current age
 * time-to-grow - support variable that says how much time passed since pollination

Workers

 * nectar-worker- current quantity of nectar collected
 * old-worker - worker´s age at the beginning of the simulation
 * howold-worker - current age
 * direction - direction from beehive to flower if she found any
 * is-flower  - true/false, if true, than worker found flower
 * energy - current amount of energy left
 * max-energy - maximum energy of worker
 * ch - support variable
 * tell - support variable, values 1/2/3, if worker said to the other worker direction of flowers, than this variable = 2, if worker was told, where flowers are, than tell= 1. Otherwise 3

Drones

 * old-drone - drone´s age at the beginning of the simulation
 * howold-drone - current age
 * energy - current amount of energy left
 * max-energy - maximum energy of drone
 * ch - support variable

Queen

 * old-queen - queen´s age at the beginning of the simulation
 * howold-queen - current age
 * energy - current amount of energy left
 * max-energy - maximum energy of queen
 * ch - support variable
 * num-of-fertilization - current quantity of fertilization

Eggs

 * old-egg - day when egg arises
 * howold-egg - current age
 * energy - current amount of energy left
 * max-energy - maximum energy of egg
 * ch - support variable
 * workr -true/false, if true, than egg is "worker´s egg"
 * dron-true/false, if true, than egg is "drone´s egg"

User interface and controls
User interface of the simulation consists of three parts. The first one is Animation box in which the visualization of simulation is showed. The second part are controls, which enable to control and set the parameters of the simulation. The third part of user interface consists of plots and monitors, where values of selected variables are displayed.

Buttons

 * setup- setups the simulation and variables at selected values
 * go- runs and stops the simulation

Sliders and switches

 * daytime- if switched on, then visualization of day/night is enabled
 * control-winter-if switched on, then beginning/end of winter is set manually
 * set-winter- works only when control-winter is on, if switched on, then winter mode is activated
 * real-days-if switched on, then Sun moves across the sky and changing of day/night is activated
 * flowers-percent-unit if switched on, then slider number-of-flowers sets amount of flowers as % of number of green patches(grass)
 * beehive-fixed-position- if switched on, beehive is situated in the middle of the grass, otherwise is placed randomly
 * speed- works only when real-days is on, changes the speed of moving sun -> length of day
 * flower-size - changes size of flower group, also influences the number of flowers (the number set is radius of the circle (flower group) in which are flowers placed at the beginning of simulation)
 * time-to-live-flowers- changes how long will flowers live (days)
 * set-time-to-grow- changes how long it takes before new flowers are made from pollinated one (days)
 * how-much-eat- changes how much honey bees eat every day (mg)
 * how-long-winter- changes length of winter (days)
 * how-long-day- works only if real-days is off, changes day length  (ticks)
 * num-of-flowers- changes number of flower group, where flowers are situated at the beginning of the simulation (number, if flowers-percent-unit is off, otherwise is defined as % of number of green patches )
 * num-of-workers- changes number of workers in the model
 * num-of-drones- changes number of drones in the model
 * num-of-eggs- changes number of eggs that queen lays at one time
 * distance-from-beehive- changes minimum distance from beehive, where flowers could be placed at the beginning of the simulation(radius)

Plots and monitors

 * honey - shows amount of honey stored in beehive in mg
 * number of workers/drones/eggs - shows number of workers, drones and eggs in the model
 * flowers - shows number of flowers and average distance of flowers from hive
 * day - this monitor shows current day number
 * eggs workers - this monitor shows current number of "worker´s egg"
 * eggs drones - this monitor shows current number of "drone´s egg"
 * fertilized - this monitor shows whether queen is fertilized at the moment"

Limitations of the model
In real life, things are more complicated. For example there is about 20 000 - 50 000 bees in hive. Not every worker collect nectar, there could be more than one queen in the hive and so on. Also many different flowers grow in the meadow... These and many other aspect can´t be simply implemented because of computational complexity. So this model shows basic dependencies and influences between hive and environment in which bees live.

=Results= Model can run in two different modes. First mode could be called "real mode", because of changing day and night and season. This mode is more complicated to analyze due to huge amount of data. It is because of the simulation runs about 250 000 ticks, so it is very time consuming. But it showed, that to discover some dependencies, switching day/night and season is not needed. Due to this finding, second mode was crated, in which day length can be set in ticks and sun is always in the Sky. Because of getting much data and results from simulation runs, I will present only important dependencies and influences which arise in the model. Next results are from simulation which has these variable values:
 * daytime- false
 * control-wintertrue
 * set-winter- false
 * real-days-false
 * flowers-percent-unit false
 * beehive-fixed-position- true
 * flower-size - 4 or 8 (in graphs shortcut FS 4 or FS 8)
 * time-to-live-flowers - 20
 * set-time-to-grow- 5
 * how-much-eat- 4.5
 * how-long-day- 110 or 150 (in graphs shortcut DL 110 or DL 150 )
 * num-of-flowers- 20
 * num-of-workers- 50 or 100
 * num-of-drones- 20
 * num-of-eggs- 15
 * distance-from-beehive- 50

How day length / number of workers at the beginning/ flower size affect on stock of honey
These two graphs show how day length, number of workers at the beginning of the simulation and flower size affect on stock of honey. As we can see from these graphs all factors listed in headline influence stock of honey. The strongest influence in the simulation has day length. That is because workers has more time to collect nectar. We can see that 40 ticks difference makes huge difference in the stock of honey. There is also big difference in stock of honey between flower size 4 and 8. This difference means that more flowers are at the beginning in the meadow, more stock honey we have. But in this case these influences are in effect only in short term. In the long therm, stock of honey is influenced by the number of workers, which grows and then isn't enough honey to feed all the workers and stock of honey drops. This can be more obvious when we see next graphs with number of workers and flowers.

How day length / number of workers at the beginning/ flower size affect on number of workers
Number of workers during the simulation is very connected with amount of honey. We can see that number of workers rises when stock of honey is high. But then comes a break point, where is not possible to feed all the bees and workers(and of course eggs and drones) die. Number of workers oscillates around value, which is determined by stock of honey, day length, number of flowers and many other factors (number of eggs, flower´s distance from beehive ). Number of workers is also influenced by flower size. Where there is´t enough flowers at the beginning of the simulation and day length is short, hive will not survive. But as we can see day length is more important then flower size. Interesting is, that although there is difference between number of workers at the beginning of the simulation, process of number of workers is very similar.

How day length / number of workers at the beginning/ flower size affect on number of flowers
As we can see, these two graph are very similar. It means that number of flowers is not influenced by day length. Obviously flower size influences number of flowers at the beginning. But from the long term view, there is very little influence. We can see that number of flowers at the beginning of the simulation is bigger, than hive need to subsist. So the number of flowers stabilizes at needed level.

How minimum distance of flowers from beehive influences stock of honey
These two charts reflect same situation as listed in charts above except variable distance-from-beehive, which is set to 80. We can see that results are pretty different. The main difference is in amount of honey, which is much less than in simulation with minimum distance = 50. It is because of workers have to fly longer distance to collect nectar. But in very long therm (longer than in this simulation) stock of honey will be similar. It is because of the fact, that average distance of flowers from beehive is continuously decreasing. The speed of flowers "approach" to the beehive depends on how fast they reproduce and their distance from beehive at the beginning of the simulation. After some time beehive is surrounded by flowers.

Relationship between number of workers and number of drones
Number of workers is highly influenced by number of drones. It is because drones fertilize queen and only fertilized queen oviposits eggs, from which workers will arise. Big number of drones will be later reflected in big number of workers and vice versa. If there is low number of drones in the hive, than queen start to lay unfertilized eggs and more drones will arise. Without this dependence, number of workers could rise without limits (in case of enough stock of honey).

How length of winter affects on stock of honey
The answer for the question, whether hive survive winter, depends on stock of honey. Which factors influence stock of honey is explained above. It is obvious, that hive will survive winter, if the stock of honey is bigger than winter length * number of workers/drones/eggs * how much they eat.

=Conclusion= In this simulation is showed, how basic parts of hive and environment affect on each other. Therefore this simulation is limited, basic dependencies work accurately and hive and it´s closest environment works as self-organising ecosystem. But if we want to understand all parts and dependencies, we will need much bigger analysis. =Source code= =Resources= WILENSKY, Uri. NetLogo User Manual [online]. October 2012 [cit. 2012-12-06]. Dostupné z: http://ccl.northwestern.edu/netlogo/docs/NetLogo%20User%20Manual.pdf Vcelky.cz [online]. [cit. 2013-01-13]. Dostupné z: http://www.vcelky.cz