Chapter 5

Agent-Based Models and Optimal Control in Biology: A Discrete Approach

Reinhard Laubenbacher*, Franziska Hinkelmann and Matt Oremland*, *Virginia Bioinformatics Institute, Virginia Tech, Blacksburg, VA, USA, Mathematical Biosciences Institute, The Ohio State University, Columbus, OH, USA, [email protected]

5.1 Introduction

The need to control complex systems, both engineered and natural, pervades our lives. From the thermostat that controls the temperature in our homes to the software that controls flight characteristics of the space shuttle during landing, the vast majority of engineered systems have built-in control mechanisms. Being able to control certain biological systems is no less important. For instance, we control ecosystems for agriculture and wildlife management; we control different parts of the human body to treat and cure diseases such as hypertension, cancer, or heart disease. And we control microbes for the efficient production of a vast array of biomaterials. With control comes the requirement to carry it out in a fashion that is optimal with respect to a given objective. For instance, we want to devise a schedule for administering radiation therapy to cancer patients in a way that maximizes the number of cancer cells killed while minimizing side effects. We apply pesticides to fields in a way that minimizes environmental damage. And we aim to control the metabolism of engineered strains of microbes so they produce the maximal amount of biofuel. Thus, the need for optimal control is a problem we face everywhere. This chapter will focus on optimal control of biological systems.

The most common approach to optimal control is through the use of mathematical models, often consisting of one or more (ordinary or partial) differential equations. These equations model key features of the system to be controlled and include one or more variables that represent control inputs. The following example illustrates this approach; it is taken from [1], where more details can be found. The problem we want to focus on is the optimization of cancer chemotherapy, taking into account certain immunological activity. The two relevant variables are x, which represents the volume of the tumor to be treated, and y, which quantifies the density of so-called immunocompetent cells, capturing various types of T-cells activated during the immune reaction to the tumor. These two variables are governed by the system of ordinary differential equations,

image

Here, F is a function that represents the carrying capacity of the tumor, a concept adapted from ecology, in that it represents that ability of the environment to sustain the tumor. The Greek letters are constant parameters of the model. For instance, image represents the rate of natural death of T-cells. For our purposes the exact model structure is not important, and details can be found in [1]. For instance, the term image represents the observation that tumors suppress the activity of the immune system.

The control objective here is to reduce the tumor volume through the use of a chemotherapeutic agent. We will refer to this as the “treatment.” We implement this control with a term image, where image represents the control input, namely the amount of the chemotherapeutic agent administered. The factor x takes account of the assumption that the effect of chemotherapy on the tumor is proportional to the tumor volume. Thus, the first equation becomes

image

Here, image represents the carrying capacity of the tumor, as above. The parameter image captures the growth rate of the tumor, with dimension cells/day. The parameter image denotes the rate at which cancer cells are eliminated as a result of activity by T-cells, so that the term image in the equation models the beneficial effect of the immune reaction on the tumor volume. Finally, we assume that the elimination terms are proportional to the tumor volume. We therefore subtract a term image in the x-equation.

What kind of drug regime is appropriate for a given cancer patient depends in part on the particular state of this patient’s disease. Our goal now is to optimize the influence of the control variable u, that is, the treatment, with respect to several factors. On the one hand we want to shrink the tumor through the administration of a maximal dose of the agent, and on the other hand we need to take into account the toxic side effects of the medication. Also, the treatment should be as short as possible. All this can be combined into the cost function

image

This equation represents the cost of applying treatment schedule u for a length of time T. The optimal control problem now is to find a control u that minimizes this cost function. Solving such control problems is an active area of research, and algorithms have been developed to find u[2]. See also [3] for optimal control problems in systems biology.

Modeling biological systems through differential equations has its limitations, however. In many cases, the processes involved might be fundamentally discrete rather than continuous. For instance, in the case of a predator–prey relationship between two species inside an ecosystem, both populations are comprised of discrete individuals that engage in typically binary discrete interactions. Thus, it is not immediately clear whether one can apply methods such as differential equations, which assume that the quantities modeled vary continuously. In molecular biology, when we study regulatory relationships between genes inside a cell, these relationships are based on the interactions of discrete molecules. Modeling such systems using differential equations is based on two assumptions: first, there are many individuals involved, so that we can view them collectively as a continuous quantity; second, that we are able to describe the individual interactions in a “global” manner, as a term in a set of differential equations, usually involving one or more global parameters. Sometimes, both of these assumptions are justified, such as for large populations of bacteria or large quantities of chemicals in a fermenter. But at other times, one or the other, or both, of these assumptions fail. For example, in a cell, there might only be two or three molecules of a particular protein present at any given time, so that its role in a regulatory network becomes discrete and stochastic, and cannot be accurately modeled with continuous functions. And, as another example, in an ecosystem with several species, continuous models sometimes cannot accurately capture extinction events when one species reaches a very low count.

For these reasons, and others, several other frameworks have been used to model biological systems. One of these consists of so-called “agent-based,” also called “individual-based” models. These types of model have a long history, going back to the 1940s and the work of John von Neumann [4].

Von Neumann was interested in the process of self-replication and aimed to construct a machine that could faithfully replicate itself. A theoretical instantiation of such a machine turned into the concept of a cellular automaton as a computational model. A very well-known example of a cellular automaton is John Conway’s Game of Life[5]. Since it includes many of the basic concepts of agent-based models, we describe it briefly.

The Game of Life takes place on a chess-board-like 2-dimensional grid. This grid can either be finite or extend infinitely in all directions, thereby yielding two different versions of the game. Each square, or cell, on the grid can be either black or white. Since the Game of Life is intended to simulate life, a cell is instead referred to as either alive (black) or dead (white). Each cell away from the boundary of the grid has eight neighbors on the grid that physically touch it, four with which it shares an edge, and four that touch only on the corners. Cells on the boundary have fewer neighbors. To make all cells uniform, one can make the assumption that a cell at an edge of the grid, but away from the corner, has as additional neighbors the corresponding cells on the opposite edge of the grid. Thus, we effectively “glue” opposite edges together, so that the grid is situated on a torus rather than in the plane. Now that all cells have eight neighbors, we establish a rule that determines the evolution of the cells on the grid by determining what the status of a given cell is, depending on the status of its eight neighbors. The rule is quite simple.

• Any live cell with fewer than two live neighbors dies;

• Any live cell with two or three live neighbors stays alive;

• Any live cell with more than three live neighbors dies;

• Any dead cell with three live neighbors comes alive.

Thus, the rules are reminiscent of a population whose survival is affected by under- and overpopulation. If we now initialize this “Game” by assigning a “live” or “dead” status to each of the cells, then we can use this rule to evolve life on this grid by updating the status of all the cells in discrete time steps. The result is a vast array of different dynamics that can be observed, but is largely unpredictable from a particular initialization. There is a rich literature on this topic and many websites with Game of Life simulators. Before continuing, the reader is encouraged to try some of these and explore the question of predicting dynamic behavior from particular initializations.

General agent-based models have many features similar to this set-up. There is a collection of agents that are distributed across a spatial landscape. In the Game of Life, the spatial landscape is the grid, and there is one agent per cell. Each agent can be in one of a (typically finite) number of states, such as “dead” or “alive,” and has a set of rules attached to it that it uses to determine its state, based on the state of those other agents it interacts with at any given time. Beyond the Game of Life, in general agent-based models, agents are able to move around in the spatial landscape, and there are rules that determine the agents’ movement patterns. Typically, the rules are stochastic, rather than deterministic, and are governed by a collection of probabilities. For instance, agents might be predisposed to follow a certain gradient, representing, e.g., nutrient availability, but there is some chance that they might move in a different direction. While there are many other variations and features in particular agent-based models, these few basic features characterize the agent-based modeling framework.

These features are also sufficient to explain the basic differences between agent-based models and equation-based models, such as ordinary differential equations. Agent-based models lend themselves very well to a description of dynamical systems that arise from local interactions of many parts/agents, based only on local rules rather than on the configuration of the entire system at any given time. Also, it is very easy to represent a rich heterogeneous spatial environment that the agents navigate. Thus, the dynamics of the entire system, or its so-called global dynamics, “emerge” from these local interactions by applying the local rules repeatedly. In contrast, a system of differential equations, for instance, explicitly describes the global dynamics of the system up front. Furthermore, all the specifications for an agent-based model are intuitive, in the sense that they are direct computational representations of recognizable features in the actual system. This leads to models that are more faithful to the system to be modeled and that are more accessible to domain experts. With existing software for model building, they can even be built by domain experts directly, without the intervention of a modeler or mathematician. But, as always, there are no free lunches. These advantages come with some significant costs attached.

The reason that agent-based modeling became widespread only in the last 15 years or so is due to the fact that larger models with more features require extensive computational resources that were not available until recently. It is only now possible, barely, to build and analyze models that might have hundreds of millions of agents and tens of millions of spatial locations, with agents being very complex in terms of the states they can take on and the rules they follow. Even moderately complex models require high performance computing facilities for their analysis, which makes it difficult for individual researchers to use them. High computational complexity is compounded by the fact that there are very few mathematical tools available for the analysis of agent-based models. In essence, the only approach to model analysis is model simulation. That is, from given initializations of agent states and environmental parameters, one observes the time evolution of the system and hopes to observe patterns that might help one draw conclusions about, e.g., steady states of the model. Through choosing many initializations and doing many simulation runs from a given initialization in the case of a stochastic model, one aims to obtain global dynamic information about the model. Little else can be done because, in essence, the model consists of a computer program rather than a set of mathematical equations, and there are few things one can do with a computer program other than run it.

The lack of mathematical analysis tools extends in particular to the arena of optimal control. Existing approaches are heuristic in nature, based on domain knowledge. The goal of this chapter is to describe some of these approaches and to outline steps one can take to expand the repertoire of available tools to include techniques based on mathematics. The way to do this is to translate an agent-based model into a mathematical object, such as a system of equations of some sort, that makes it amenable to mathematical analysis tools. There are several possible ways in which to do this, and research is only in its early stages. Thus, the reader should see this chapter as a snapshot of an exciting research area that is evolving rapidly and providing rich opportunities for contributions at all levels. This chapter showcases one possible approach and the steps that have been accomplished on the road to developing mathematical tools for optimal control of agent-based models.

5.2 A First Example

Go to http://ccl.northwestern.edu/netlogo/models/RabbitsGrassWeeds. There you will find an agent-based model of rabbits in a field of grass and weeds. At each time step (or “tick”) the rabbits move in a random direction (they lose energy by moving). If there is grass at their location, they eat it and gain energy. If their energy level climbs above a certain threshold, they give birth (in this model, a new rabbit is spontaneously created at the location of the parent). Upon birth, the parents’ energy is halved, and the offspring is created with this halved energy level. Upon each tick, empty squares (or “patches”) have a certain fixed probability of grass re-generating. Weeds can also be introduced in order to further complicate the dynamics; their behavior is similar to that of the grass.

Near the top of the page you will find an option that allows you to run this model in your web browser. Spend some time reading through the description in order to get a feel for how this model works. Click setup and then go to run the simulation (press go again to stop the simulation). Note that you can speed up or slow down the model by using the slider at the top of the interface. Each time you wish to re-initialize the model and start over, you must click setup again.

In this model, each of the grid squares (henceforth referred to as patches) are agents, and each rabbit is an agent as well. Notice that the rabbits move around randomly, eating grass as they encounter it. Note too that the patches are colored green when grass is present, and black when it is absent. Notice the sliders on the left-hand side: these values can be changed as the simulation proceeds, or prior to starting a simulation. What do you expect to happen to the rabbit population if the grass growth is set to a very low rate? What if the grass grows quickly? What effect would altering the birth threshold have on the amount of grass present at each time step? Do you think it is possible for the rabbit population and grass level to stabilize over time? Play around with the sliders to determine if your predictions are correct. Note that you may need to let the simulation run for several hundred time steps (or “ticks” in Netlogo) in order to observe consistent dynamics. Do the populations stabilize? Do they oscillate?

5.3 Netlogo: An Introduction

Hopefully, the example in Section 5.2 has given you an idea of what an agent-based model is: a computer simulation wherein agents interact with their local environment (possibly including other agents) based on a set of rules. In this section we guide you through several exercises involving agent-based models using Netlogo [6], a software tool developed to work with agent-based models. Netlogo can be downloaded for free at http://ccl.northwestern.edu/netlogo/. There you will find detailed instructions on how to install it. Netlogo is its own programming language, so named because it is a variation of the Logo language. While many key features are unique to Netlogo, users familiar with Logo will likely note similarities. Note too that Netlogo is continually updated and newer versions released. As of the time of this writing, the latest version is Netlogo 5.0. All files and exercises associated with this chapter will be conducted using this version; some adjustment may be necessary for newer (or older) versions. While there are many other software platforms available and in use for agent-based modeling, for the remainder of this chapter we will use Netlogo to introduce and examine agent-based models. It has the convenient advantage of providing the user with an intuitive graphical interface, which we will use to aid our understanding of the models we will examine. In addition, the standard installation comes with a library of models, all of which are open source. Thus we may build models from scratch or we may choose to alter an existing model. You may wish to go through the tutorials found at http://ccl.northwestern.edu/netlogo/docs/. A complete dictionary of programming terms can be found at http://ccl.northwestern.edu/netlogo/docs/dictionary.html. All exercises in this section refer to the “Rabbits Grass Weeds” model introduced in Section 5.2. It should be noted that for Exercises 5.1 and 5.2, the web-based version of the model can be used (via http://ccl.northwestern.edu/netlogo/models/RabbitsGrassWeeds), but Exercises 5.3 and 5.4 require installation of the Netlogo software.

Exercise 5.1

Note the two sliders weeds-grow-rate and weed-energy. By setting weeds-grow-rate to be any nonzero value, you will notice that the landscape of the model has been altered, as there are now patches containing weeds interspersed with the grass (represented as purple patches). What effect does this have on the rabbit population? How about on the grass population? What happens when you increase weed-energy? Set grass-grow-rate and weeds-grow-rateto be equal, and set grass-energy and weed-energy to be equal as well. What do you think will happen to the population levels now? Determine slider values so that the following situations occur:

a. The grass and weeds stay at (roughly) the same level (as shown in the plot window).

b. The weed levels (as shown in the plot window) are higher than the rabbit levels and the rabbits die out.

c. The weed levels (as shown in the plot window) are higher than the rabbit levels and the rabbits do not die out. ∇

Exercise 5.2

Set weed-grow-rate and weed-energy-level to 0, and grass-grow-rate and grass-energy to 5 if they are not already at those levels. Set birth-threshold to 15, and press setup and go to restart the simulation. As the simulation runs, gradually decrease birth-threshold to 10, and then to 5. You will notice in the plot window that the rabbit population oscillates at a higher amplitude as you decrease birth-threshold. Why does this happen? As you further decrease birth-threshold to 2 or 1, the rabbits die out. Why does this happen? ∇

Exercise 5.3

Right-click on the graphical interface and select Edit…. Notice that the boxes labeled ‘World wraps horizontally’ and ‘World wraps vertically’ are checked. This means that when a rabbit moves left from a left-most patch, it will reappear on the corresponding right-most patch (and similarly if the rabbit moves vertically from a top-most patch). If you uncheck those boxes, the rabbits will be bound by the edges of the map (so we can think of them as being “fenced in”). What effect does checking these boxes have on the rabbits? What effect does it have on the grass? ∇

Exercise 5.4

By altering the code in the “Code” tab, change the patches in the model so that there is a river three patches wide that separates the field into two halves (this can be done by altering the code in the grow-grass-and-weeds function). Ensure that grass and weeds cannot grow in the river. Alter the setup function so that rabbits cannot begin in the river, and alter the death function so that a rabbit dies if it goes into the river. What effect does this have on the rabbit population over time? ∇

5.4 An Introduction to Agent-Based Models

Mathematical modeling is a method of encoding relationships and interactions in a natural or engineered system into a formalized system; the models can then be studied and analyzed using a variety of mathematical approaches. Models allow researchers from a wide variety of disciplines to examine systems and their emergent behavior. For example, a model may be used in order to make predictions about the future behavior of a system, or it may be used to solve a complicated problem explicitly. In developing the best drug to administer to treat a particular disease, researchers in the past have relied on trial-and-error methods via repeated experimentation on live subjects. With an accurate model of the subject, however, such experiments can often be faithfully reproduced in silico; that is, they can be run on a computer and analyzed with far less preparation and expense. This highlights another benefit to mathematical modeling: given an accurate model of the system in question, a year’s worth of real time can be simulated in several minutes.

Experimentation remains part of the process - a model will always have a limited ability to predict and must be correlated against empirical data in order to ensure that the models are indeed faithful simulations of the actual physical system. Thus, models are best used to inform in vivo experimentation, which in turn produces results that can be used to calibrate the model further.

Agent-based models are a class of computer models in which entities (referred to as agents) interact with each other and or their local environment. Formally:

Definition 5.1

Definition 5.1 Agent-based model

A computer model that consists of a collection of agents/variables that can take on a typically finite collection of states. The state of an agent at a given point in time is determined through a collection of rules that describe the agent’s interaction with other agents. These rules may be deterministic or stochastic. The agent’s state depends on the agent’s previous state and the state of a collection of other agents with whom it interacts. [7]

Systems (such as the human immune system) are increasingly being implemented in the form of agent-based models (with individual cells as the agents, of which there may be many types) as more and more research involves the use of in silico simulation to study the properties of this and other similarly complex systems.

Agent-based models have the advantage of being well suited for modeling many different types of systems. They have been used to study social interactions among individuals, the spread of disease through populations, scheduling and efficiency of factory processes, how cells react to drug treatments, and many other systems. It is perhaps worth noting that many of the current issues in the scientific community are interdisciplinary. Finding a cure for cancer will involve geneticists, biologists, mathematicians, chemists, and perhaps many other specialists. Agent-based models have an intuitive formulation and can often be examined via a graphical interface. Thus they are a natural tool for promoting interdisciplinary research, as the mathematics underlying the models is hidden in the programming; in other words, it is possible for biologists, chemists, and other researchers to make use of agent-based models without a full background in the mathematics that are involved in creation and analysis of the model. At the same time, the mathematical structure remains and can be explored concurrently by mathematicians.

Even within the scope of mathematical modeling, there are several noteworthy advantages to agent-based modeling. One such advantage is that they are effective for modeling systems wherein many agents follow the same set of rules (e.g., rabbit populations or blood cell types). In particular, models containing spatial heterogeneity can be effectively represented via agent-based models while perhaps not so easily using, for example, ordinary or partial differential equations (ODEs). Altering the spatial dynamics of an agent-based model consists of changing several lines of code or less, while such changes can be difficult (and perhaps even impossible) to implement in an ODE model.

While agent-based models provide a convenient and natural setting for studying complex systems, there are several issues within the research community that are currently unresolved. A 2006 paper [8] written by a large group of researchers identified two main obstacles: the first is the lack of standardization of the description of agent-based models, and the second is a lack of rigorous mathematical formulation of the system itself. Descriptions of agent-based models can vary in different settings, and as of this writing there is no standard definition that is universally agreed upon. Some models are developed to simulate physical processes, and others are developed in the framework of graph theory. In some cases models are developed in order to study only a certain aspect of the given system; thus the model may have more variables pertaining to certain processes than others. A research article may begin with the statement of an objective, or it may begin with a description of the model itself. In some cases, the rules that govern the updating of the agents’ state variables are deterministic, and in other cases they are stochastic. All of these issues would be resolved if there was a standard protocol for describing agent-based models (indeed, one such protocol is proposed in [8]). The need for an agreed-upon structure to be followed is perhaps most clearly felt in the model’s presentation. In particular, the layout of the model presentation ought to be standardized so that a reader immediately knows where to look in the description in order to learn what the model describes and what its rules are. In the current literature models are presented in myriad forms, and the descriptions of the agents, environments, and rules come in no particular order. Thus a reader is required to scour the paper for pertinent details that might otherwise be presented in some standard way.

The second major issue concerns the lack of rigor in the formulation of the model. In many cases, the description of a model is given in several paragraphs, describing in some imprecise manner what the agents are and how they interact with each other. In fact, in order for agent-based models to be implemented on computer software, there are intricate rules embedded in the programming of the models. These rules and equations are often glossed over if not entirely omitted; if they are given, it is typically through a verbal description rather than a strict mathematical formulation. Looking back on the example in Section 5.2, the precise way in which the rabbits move is not described. For example, it is unclear from a simple description whether the rabbits can move diagonally, or whether the distance they move at each time step is variable or constant. In fact, even running the model does not immediately answer this question—it is only made explicitly clear by thorough examination of the computer code. In order to describe such a model rigorously, it is necessary that this information (and other similarly imprecise descriptions) be presented clearly and unambiguously.

In addition to these issues, an author may spend several paragraphs explaining how the model was formulated that could just have easily been given in one or two equations. Short and precise definitions can save time for the reader and also make the author’s intentions explicit. One proposition to overcome this lack of formalization is presented in [9]; this work proposes a rigorous mathematical representation for agent-based models as polynomial dynamical systems. A further description of such systems can be found in [10] and is described in Section 5.8.

5.5 Optimization and Optimal Control

Agent-based models are typically created to simulate some real-world process in order to aid investigation. Once a model has been created, a natural next step is to ask: what are we to do with it? In this section we give a brief overview of optimal control and optimization, and introduce these ideas as they apply to agent-based models.

Optimization is the process of finding the best solution with respect to a particular goal. For example, suppose we have a model of the immune system battling a bacterial infection, and we wish to study the effects of certain drugs on this battle. We may wish to find out which drug does the least amount of tissue damage while curing the infection—this is an optimization problem, because we are searching for the best drug with respect to the stated goal. On the other hand, perhaps our goal is to cure the infection in the shortest time possible, regardless of the tissue damage caused. This would be another optimization problem. It is likely, then, that the solution to the optimization problem depends on the optimization goal. In this scenario, the drug which cures the infection most quickly may consequently do more tissue damage than other drugs (though not necessarily); on the other hand, the drug that causes the least tissue damage might not cure the infection in the shortest possible time. In this example, optimization is a process of minimization: in one case we wish to minimize tissue damage and in the other we wish to minimize the healing time. However, it is also possible that the solution of an optimization problem is a process of maximization: given a model of an immune system fighting a fatal illness, what treatment will enable the patient to survive the longest? In fact, it may be that the goal of the optimization problem is to minimize one value while maximizing another. For example, our optimization goal may be to minimize tissue damage and maximize the expected lifespan of the patient, given that we can only administer a particular drug a fixed number of times. In general, however, optimization is the process of finding the best solution, depending on the objective.

Typically, optimization is a complicated process, and becomes even more so when realistic constraints are put in place. Through the use of agent-based models it may be possible to obtain a solution to an optimization problem that is not feasible in actuality: for example, the solution may exceed monetary limitations, may require actions that are not permitted by health care regulations, or may require interaction with the patient in an impractical way (e.g., if the solution calls for treatment every hour for 100 consecutive hours, or for image of the population to receive vaccination). Nevertheless, optimization remains a natural means of applying mathematics to solve real-world problems. Such problems are often framed as questions of optimization: what is the best outcome that can be produced based on the properties of the model?

Optimal controlis a slightly different notion. In an optimal control problem, we ask the following question: given a particular state that we hope to reach, what is the most efficient way of reaching that state? In other words, we know the state of the system that we hope to reach, and the control problem is to find the solution that steers the system to that state in the best manner. Using a model of the immune system fighting an infection as an example, we may formulate an optimal control problem as follows: given that we wish to eliminate the number of infected cells in one month, what is the best drug treatment schedule we can devise? To summarize: in an optimal control problem we know the state we hope to reach and we search for the best way to reach it, whereas in an optimization problem, a goal is stated and we compare solutions to see which solution maximizes or minimizes the stated goal of the problem.

We now present an example explaining several terms related to optimization and optimal control that will be used in Sections 5.6 and 5.7. We then conclude this section with definitions of said terms. We do this in order to standardize and clarify the terminology within this chapter. Note that while many of these terms are also used in optimal control for continuous systems, there might be subtle differences in their meanings when applied to agent-based models. Furthermore, as this chapter is meant to provide an introduction to the topic, more formal definitions are outside the scope of this text. For a more formal treatment see [11].

Example 5.1

Suppose that we are modeling lung cancer and we wish to study the effect of a certain drug. We formulate our optimal control problem as follows: which treatment schedule should we choose in order to reduce the number of cancer cells so that it remains below some fixed threshold over the course of one year, given that we wish to minimize the number of times the drug is administered and maximize the number of healthy cells? Note here that we use the term “treatment schedule” instead of “treatment” because the drug we are administering is fixed—we want to determine which days the drug should be administered in order to obtain optimal results.

In this case, there will be many variables: the number of healthy cells, the number of cancer cells, the rate at which cancer cells grow, the rate at which healthy cells regenerate, the expected lifespan of the patient, the frequency with which the drug is administered, the type of drug, and so on. Some of these variables will have fixed values: for example, the rate at which healthy cells regenerate (during intervals when no treatment is administered) can be determined through experimental measurements, and in fact this rate helps to define the model itself. Such variables are referred to as model parameters—they are a part of the specification of the model. The repeated interactions of the entities in the model, such as immune cells or rabbits, are referred to as the model dynamics. Note that we will only have direct control over some of the variables, and others we will simply measure by observation. For example, during each day of the simulated treatment we can decide whether or not to administer the drug; thus we have direct control over the value of this variable. We refer to these as control variables, because we have direct control over their values and they exercise control over certain aspects of the model. On the other hand, we might not be able to control over other aspects, such as the number of white blood cells present at the site of an infection. We refer to variables of this type as state variables because they help to describe the state of the system at any given time.

In this example, our only control variable is a binary decision whether or not to administer the drug on a given day, thus there are only two possible values for this control variable at each time step. For any given day, we may represent that the drug was administered that day by assigning that variable the value 1, and represent that the drug was not administered by assigning that variable the value 0. In this situation, then, a treatment schedule is a vector of length 365, of which each entry is either 0 or 1. Thus there are a total of image possible treatment schedules. However, it is likely that not all possible treatment schedules will reduce the number of infected cells below the fixed level. The treatment schedules that do achieve this are solutions to the optimal control problem. The solution space is the set of all such solutions. Note that this space is entirely separate from the state space, which consists of all possible states a patient may be in throughout any simulation of the model.

Recall that we are trying to find the best solution among many candidates. In order to do this, we must have some way of ranking individual solutions. We do this by introducing a cost function. We are attempting to steer the system to a particular state, and each solution achieves that goal at a certain cost. We wish to determine the best solution (i.e., the optimal control); thus we wish to find the solution that minimizes the cost function. Earlier we noted that in the immune system example the best solution was the solution that involved the least number of treatment days throughout the treatment schedule; thus, in this example a reasonable cost function might involve the sum of the entries in the treatment schedule (i.e., the number of days on which the drug was administered). For the purposes of this chapter, the goal of the optimization and the optimal control problems will always be to minimize the associated cost function.

In our example, we wish to minimize T, the total number of days the drug is taken, and maximize I, the number of healthy cells. Then a reasonable cost function for a treatment schedule S which contains image days on which the drug is administered and results in an expected value of image healthy cells might be image. Here we want to maximize image over all treatment schedules S; this is the same as minimizing image (in this way we can always formulate our problem so that the goal is to minimize the cost function). However, it is perhaps more realistic that one of our optimization goals has a higher priority than the other. For example, we may suppose that maximizing the number of healthy cells is more important than minimizing the number of treatment days. In that case, we introduce weighting coefficients to alter the cost function. For example, it may become image. This has the effect of increasing the relative importance of the healthy cell count when evaluating the associated cost of a particular treatment schedule.

In order to use our model to obtain results, we simulate the model a number of times and make observations on the results. We might, for example, administer a treatment every day. This particular solution is represented as a string of 365 consecutive 1’s; we implement this in the agent-based model and count how many healthy cells are there after one year of simulated time. We then evaluate the cost function based on this information. Given that agent-based models are often stochastic in nature (meaning that while the rules are fixed, the model dynamics depend on many random variables), results obtained from one simulation are typically not reliable. We eliminate such variation by simulating a given control schedule many times and using averages for evaluation in the cost function.

Of all the possible image solutions, there must be one that is better (or at least no worse) than every other solution. Strictly speaking, such a solution is referred to as an optimal solution. However, in many cases we cannot simulate all possible solutions because of the monumental amount of computing time involved. Thus, for the purposes of this chapter, we refer to the best solution we are able to find as the optimal solution, with the caveat that there may indeed be a better solution elsewhere in the solution space.

We now define the following terms, each of which have been illustrated in this example.

Definition 5.2

Definition 5.2 Terms

• Model parameters: quantities that are part of the model specification. They have fixed values.

• Model dynamics: the relationships between the state variables in a model. In general, the model dynamics will be affected by the model parameters and the rules that govern the interaction of the variables.

• Control variable: a variable whose value can be specified by the user. Altering the value of a control variable will (in general) have some effect on the resulting model dynamics.

• State variable: a variable whose value is observed but cannot be directly specified by the user (i.e., not a control variable). State variable values affect the model dynamics; they are affected by the value of other state variables, model parameters, and control variable values.

• Solution: a sequence of inputs to the control variables. A full solution assigns a value to each control variable at each time step; a partial solution is a sequence wherein values are either only assigned to some of the control variables, or are assigned to the control variables at only certain time steps.

• Solution space: the set of all possible solutions. If image are the control variables and each parameter image (for image) can take on image possible values, and there are a total of t time steps, then the solution space will consist of

image

solutions (thus each solution is a vector of length t, representing the sequence of inputs to the control variables).

• Population: a subset of the solution space. The population may be the entire solution space or a proper subset.

• Cost function:a function that assigns a value to each possible solution. In general, the cost function will depend upon a combination of state variables and other quantifiable aspects of the model dynamics.

• Optimal solution: in a general optimization problem the optimal solution is a solution that achieves the stated optimization goal in the best way. In an optimal control problem, it is the solution that is associated with the minimum value of the cost function.

Use the modified rabbit and grass model file RabbitsGrass.nlogo at http://admg.vbi.vt.edu/software/rabbitsgrass-netlogo-files/to answer the questions in this section. Once you have opened the file, you will find a description of the interface settings under the Info tab.

Exercise 5.5

On the left-hand side of the model, you will notice sliders for the following values: initial-rabbits, initial-grass, birth-threshold, grass-grow-rate, grass-energy, move-cost, world-size, poison-strength. Are these model parameters or state variables? Explain. ∇

Exercise 5.6

List three state variables and one control variable for this model. ∇

Exercise 5.7

Suppose the control objective is to minimize the number of rabbits while also minimizing the number of days on which poison is used. What is the difference between a solution and the optimal solution? ∇

Exercise 5.8

Click restore-defaults, set poison-strength to 0.5, and then click setup. Now, click poison repeatedly until you have run through the entire simulation time. Note the cost. Now click degrade-poison so that it is in the On position. Click setup and then repeatedly click poison again. What do you notice about the cost this time? Is it higher or lower? How can you explain the difference? ∇

Exercise 5.9

Click restore-defaults, set poison-strength to 0.5, and click setup. Using the buttons poison and don’t poison as you wish, run through the simulation several times, taking note of the cost for each solution. What is the lowest cost you are able to achieve? If you now reduce poison-cost to 5 and increase rabbit-cost to 15, you will notice that the cost when using the same schedule is now different. Is it lower or higher? Why do you think this is? Try to find a schedule that reduces the cost to less than 10,000. How about less than 5000? Turn degrade-poison? to the On position and try to achieve similarly low costs. Do you notice any patterns in the solutions in each case? ∇

Exercise 5.10

Run the same schedule twice (for 1 run each time). You should notice that the costs are different each time. Why does this happen? Explain why this is an important issue, and suggest a method for dealing with this issue. ∇

Exercise 5.11

Click restore-defaults, then setup. Change num-runs to 100, then click go. Note the average cost over these 100 runs. Now change the number of runs to 25, then 3 (note that unchecking the view updates box toward the top of the model interface will increase run time significantly). What do you notice about the cost? Is it stabilizing? What is the least number of runs required in order to achieve a reliable cost? How would you justify your answer mathematically? ∇

Exercise 5.12

What effect does altering poison-cost have on the cost of a fixed schedule? What effect does rabbit-cost have? What do you think are reasonable choices for these values if this were an actual field containing rabbits and grass? Justify your answer. ∇

5.6 Scaling and Aggregation

Our investigation of agent-based models and how to formulate control problems for them motivates this section and the next. Searching for an optimal solution in such models often requires running many thousands of simulations, thus performing such simulations as quickly as possible is a primary concern. In this section, we discuss means of reducing the run time and complexity of agent-based models via scaling and aggregation.

Scaling is a method of shrinking the size of an agent-based model in order to improve run time. In Exercise 5.1, we explored the “Rabbits Grass Weeds” model. The dimensions of this model are image patches for a total of 1935 patches. The default number of rabbits is 150. In an attempt to scale this model, we may reduce the dimensions (and correspondingly, the initial number of rabbits). If we change the dimensions to image for a total of 625 patches, we may choose the initial number of rabbits to be image. Our hope, then, is that the pertinent model dynamics remain the same at this reduced size, since in that case we can run all subsequent trials at this reduced size for a substantial decrease in run time.

The first question we need to answer is exactly what it means for the model dynamics to remain the same, and how we can verify that this is indeed the case? Since we are using the model with a specific control objective in mind, and the value of a solution relies on the associated cost function, this cost function will help us determine how to quantify whether our scaled model retains the pertinent dynamics. In Section 5.5, we used the “Rabbits and Grass” model to determine control schedules for poisoning the rabbits. In that case, our cost function relied on two parameters: the rabbit population, and the number of days in which poison was used. In particular, the day-by-day grass levels are not relevant to the cost function, nor are the energy levels of the rabbits; thus these parameters need not be preserved in the scaled model. In the scaled model, the number of days in which poison is used is unchanged, so this variable is also unaffected by scaling. Then the only parameter we need to preserve is the rabbit population. To be more specific, we need to answer the following question: what are the smallest dimensions we can use in the model (by scaling down the number of rabbits accordingly) so that the average day-by-day rabbit population dynamics in the scaled model follow the same pattern as those dynamics in the original model? We answer this question by simulating many runs at each size and keeping track of the population levels for each. We can then calculate the correlation using any of a number of statistical methods; one such method is now presented.

5.6.1 Correlating Data Sets

Suppose we obtain two sets of data and wish to know how closely related they are. The absolute numbers may not tell the whole story, since the patterns in the data may remain similar even if the magnitude of the values change. Here we describe how to calculate Pearson’s sample correlation coefficient, a real number image, which estimates how closely correlated two data sets are. At image, there is perfect correlation, such as between the ordered data sets {1, 2, 3} and {2, 4, 6}. At image, there is perfect negative correlation, meaning that as the data increase in one set, they decrease by precisely the same proportional amount in the second data set (this value is obtained for data sets {1, 2, 3} and {−8, −9, −10}, for example). At image, there is no connection between the two data sets at all (this value is obtained for data sets {1, 2, 3} and {1, 2, 1}). Naturally, the larger the data sets the more informative the correlation coefficient. We now describe how to calculate r in general and then provide an example.

Definition 5.3

Definition 5.3 Pearson’s sample correlation coefficient

Let image be data sets consisting of n points (labeled sequentially as image and image), and let image and image be the mean value of x and y respectively. Then Pearson’s sample correlation coefficient r is defined as

image

Example 5.2

Let image and image. Then image and image. Then

image

Thus we see that these two sets of data are in fact very closely positively correlated, in keeping with the observation that the values in y are approximately one half of the corresponding values in x.

Since agent-based models are generally stochastic in nature, the data obtained will seldom present a perfect description of the system, because an infinite number of simulations would be required. Thus sample correlation coefficients of 1 or −1 are very highly unlikely. We may choose our desired correlation coefficient r, and when scaling the model we simply select the smallest dimensions that produce data whose correlation coefficient is at or above this level.

5.6.2 Cost Function Analysis When Scaling

Once we have determined how small we can safely scale our model, we must also be cautious about numerical results obtained from this model, as indicated in the following example.

Example 5.3

Let image be the number of rabbits alive on day i, and let image be the control decision on day i (thus if we use poison then image and if not, image). Let image, where n is the total number of simulated days. Suppose our cost function is image, where image are constants. Once we have scaled our model, we attempt to use it to determine the control schedule which minimizes this cost function. When doing so, we must be careful to scale the constants image as well, since otherwise, we may obtain meaningless or misleading results, as the following results suggest.

Example 5.4

Let image. Suppose the average rabbit numbers for image for the 5 simulated days are image and by scaling, we are able to reduce the model size and achieve average rabbit numbers {75, 15, 20, 27, 36}. Using another control schedule image we obtain population levels {150, 200, 40, 8, 10} (and the corresponding scaled population values are {75, 100, 20, 4, 5}). Comparing the cost of the two schedules at the original size, we have:

image

Without scaling coefficients image, we would obtain the following costs using the scaled model:

image

From the original model, we conclude that image is a better solution than image (since the associated cost is lower), but from the reduced model we conclude that in fact image is better than image. This is due to the fact that when scaling the population values, even though the dynamics correlated perfectly, the coefficients now give less weight to the rabbit values, since these numbers are smaller in magnitude. In order to compensate for this, we must account for the rabbit numbers being halved by doubling a. At the same time, we need not scale b because the number of days remains constant at all model sizes. Scaling a and b accordingly gives the following revised costs for the scaled model:

image

Here we obtain essentially the same cost as the original model, and thus eliminate the discrepancy in cost.

The “Rabbits and Grass” model lends itself nicely to scaling because the initial distribution and location of rabbits and grass is random. Thus, when reducing the dimensions, we may still choose which patches have grass at random, and likewise may randomly choose where to place our rabbits at the start of the simulation. But what about models that are not so spatially homogeneous? Suppose the landscape included a river, or a rocky area in the upper right-hand corner of the map? In such cases, we cannot simply reduce dimensions because the spatial layout of the model may be critical to the dynamics. Thus in general, a more sophisticated approach is required for spatially heterogeneous models.

Suppose that in the “Rabbits and Grass” model, the field consists of a hill whose peak is at the center of the field. Going out from the peak of the hill, the altitude decreases; thus at the periphery of the map, the land is flat. Suppose further that we now distinguish between various levels of grass: each patch may have little or no grass, some grass, or a lot of grass. Finally, suppose the grass grows more abundantly at higher altitudes: thus at the peak of the hill there is a lot of grass, and at the periphery there is less. If we wish to model rabbits on such a landscape, it is important to maintain these characteristics as we scale the field.

The first step of our approach is to create a matrix that represents the physical landscape. We may do this by using the values 0, 1, 2, 3 (for example) to represent how much grass a given patch contains (with 3 being the most abundant and 0 representing little or no grass). Suppose our original model is image and has a layout as shown in Figure 5.1.

image

Figure 5.1 Original image grid representing topological landscape.

In order to scale the model, we reduce the landscape using the nearest neighbor algorithm. First, we decide what dimensions we would like our reduced model to have; suppose it is image. We then overlay an evenly spaced grid of image points over the original landscape (see Figure 5.2). Finally, we select values for each point by choosing the value of the neighbor nearest to that point (see Figure 5.3).

image

Figure 5.2 Original image grid with image overlaying points.

image

Figure 5.3 Resulting image reduced grid.

Note that this is only one algorithm that can be used for scaling a spatially heterogeneous model. Other methods include bilinear interpolation and bicubic interpolation; the reader is urged to explore the details of these algorithms on their own as this chapter provides only an introductory look at scaling.

Aggregation is another method of reducing computation and run time by simplification of the agent-based model. Rather than physically scaling the entire model, we may aggregate certain agents into groups and view each group as an agent. Thus there are fewer entities to keep track of, and fewer decisions that need to be made. This strategy is particularly helpful in models consisting of many agents of the same type, or many agents that follow the same set of rules. In modeling seasonal animal migration, for example, we may choose to aggregate a herd of antelope into one agent: the location of this agent would thus represent the average location of each individual in the herd. We can even represent certain antelope dying off and others being born by altering the size of the agent (e.g., as the antelope herd interacts with an aggregated prey agent such as cheetahs or lions, the size of each may expand or contract accordingly). Of course, such methods may not be possible depending on the aim of the model, and certain agents may not be amenable to aggregation. In particular, this strategy tends to be more difficult to implement in models with a high level of spatial heterogeneity or a high level of specification at the agent level.

Whereas scaling requires the dimensions of the model to be reduced (and other model parameters accordingly scaled), aggregation generally requires reconstruction of the model, since the scope of the model is altered as the agent structure is reformulated. In that sense, aggregation can be more involved than scaling. On the other hand, the long-term goal of both techniques is to improve run time and reduce computation, so the extra steps may be well worth the effort. A combination of both techniques can provide substantial decreases in run time and simplification without loss of pertinent model dynamics or detail.

The following exercises refer to the modified Rabbits and Grass model, RabbitsGrass.nlogo, available at http://admg.vbi.vt.edu/software/rabbitsgrass-netlogo-files/. Please read the Info tab to familiarize yourself with the details of this model.

Exercise 5.13

Run the model with the default values for world-size 44,11, 5. In each case, after the simulation ceases, take a snapshot and examine the population plots. What differences do you notice? What is the benefit of decreasing the world size? How would you determine the smallest world size that you could use to obtain reliable results? ∇

Exercise 5.14

Note in the cost function that we multiply the rabbit cost by image. Why is this? Why do we not multiply the poison cost by the same factor? ∇

Exercise 5.15

Turn scale-rabbits? off and run the model several times at various sizes. What differences do you notice in the population graphs? What is the effect of this option? Are results at smaller sizes more or less reliable when scale-rabbits? is off? ∇

Exercise 5.16

When scaling-rabbits is on and the world size is reduced, the rabbits become larger (graphically). Is reducing the number of rabbits an example of scaling or of aggregation? Justify your answer. ∇

Exercise 5.17

What other methods besides those mentioned in this section could be used to improve the run time of this model (i.e., to make it more computationally efficient)? ∇

5.7 A Heuristic Approach

In previous sections we have discussed optimal control as it relates to agent-based models, and techniques for improving the run time of such models. In theory, the process of finding the optimal solution requires only that we evaluate the entire solution space and choose the solution that minimizes the cost function. In practice, however, this remains unfeasible. For one thing, it is quite possible that the solution space is infinite; and even if it is finite, it is often the case that there are far too many solutions to possibly implement them all (in terms of realistic run times), even in models that have been subjected to scaling and aggregation techniques.

For example, a discrete model of the immune system might involve many millions of cells. Each will have its own rules describing its interaction with other cells, and may also have many variables attributed to it. Analytic methods fail in these cases, and exhaustive enumeration by computer is unfeasible due to the limitations of computer processing speeds. In fact, as the processing power of computers grows, so too does the possibility for creating models that increase in complexity, so that it is impossible to be certain that computers will ever be able to “catch up” to the complexity of the models.

For this reason, most of the optimization and optimal control methods currently used in discrete modeling (and with agent-based models in particular) are in the form of heuristic algorithms. An algorithm is a formal set of rules used in order to obtain a solution to a problem. A heuristic algorithm is a specific type of algorithm that conducts a “smart” search of the solution space. It may make use of certain aspects of the problem to avoid having to search through every possible solution, or it may update its search method based on the input it receives from previously found solutions. These algorithms begin with a choice of control input values (i.e., full or partial solutions) and use various methods to refine the values so as to decrease the value of the associated cost function until no better solution can be found. While these methods do not guarantee an optimal solution, they do provide an opportunity for analysis. In particular, if constructed and executed correctly, they are a vast improvement upon random searches of the solution space. One advantage to the heuristic approach is that it can be used with virtually any model. Since heuristic algorithms rely on results from simulation, it is not necessary to transform the model in any way in order to implement them. They provide a “brute force” technique that, while not always optimal, can always be used when other methods may fail. In particular, heuristic algorithms provide a baseline for results obtained via other, more rigorous methods. While a mathematician may be concerned with developing an algorithmic theory for explicitly finding a true optimal solution, in practice scientists and other researchers are often satisfied with a solution that is better than any previously known. As such, the heuristic approach to optimal control is a valuable option.

Of course, every heuristic algorithm has associated risks and advantages, and the particular algorithm that is best suited for a given model or problem will depend on these. As an introduction to the heuristic approach, we describe a so-called genetic algorithm in some detail, in the context of the “Rabbits and Grass” model. We conclude this section with a list of other heuristic algorithms.

5.7.1 Genetic Algorithms

Genetic algorithms (sometimes referred to as evolutionary algorithms) were originally developed as a means of studying the natural evolution process, and have been adapted for use in optimization since the 1960s [1214]. Each solution is viewed as a chromosome. The chromosome is a string of values, or genes, each of which represents the value of one of the parameters. Each chromosome, then, represents an individual solution that can be implemented and whose associated cost can then be evaluated. A typical genetic algorithm functions in the following way: several chromosomes are selected to form a population. The cost of each is then evaluated. The chromosomes are ordered, beginning with the chromosome that produces the minimum cost. The best half (i.e., those with lower associated cost) of the chromosomes are then selected to carry on to the next generation; that is, they will be kept in the list to be evaluated later. Then the process of breeding comes into play: two random chromosomes from those that have been carried over are selected to serve as parents. A “child” chromosome (i.e., a new solution) is then bred from these parents by some method of crossover (uniform crossover is a typical method in which there is an equally likely chance that the child will take each particular gene from either parent). The next step is mutation: each gene has the possibility of being mutated at random, changing from its current value to any admissible value of that gene. The child chromosome produced from such breeding is added to the next generation of solutions. This process is repeated until the remaining half of the new population has been re-populated with new child chromosomes. The entire process is then repeated: the chromosomes are evaluated and the best are set aside, new chromosomes are bred from them, and so on.

The control objective with the “Rabbits and Grass” model was to determine a control schedule that minimized the number of rabbits while also minimizing the number of days on which poison was used. Suppose we wish to achieve this goal over the course of 10 days. Then a solution is a vector of length 10, each entry of which is either 0 or 1. Suppose we begin with two randomly chosen solutions, image. We create a “child” solution by going through each gene (i.e., each entry in the parent solutions) and randomly selecting one of the values. See Figure 5.4 for an example of such a “child” solution. The child solution is then subjected to mutation; see Figure 5.5 for an example.

image

Figure 5.4 Uniform crossover to “breed” a new solution.

image

Figure 5.5 Bold values are subjected to mutation.

The algorithm continues for a pre-determined number of steps, or until a certain condition is met. For example, we may choose to run the algorithm for 50 generations. Another method is to repeat the process until no better solution has been found for, say, ten consecutive generations. When the algorithm terminates, we choose the best current solution as our candidate for an optimal solution (note that there is no guarantee that the best solution found by the algorithm is actually the optimal solution; recall that we use optimal solution to mean the best solution we are able to find).

As with other heuristic algorithms, there are many variations and the one presented here is provided as a standard procedure. We may modify the algorithm, for example, so that the initial chromosomes are selected in a certain way: perhaps we wish to choose them at random, or perhaps we wish to choose chromosomes that are very different from one another (i.e., solutions that come from different regions of the solution space). We may modify the crossover process so that one parent is favored over another, or we may forego the mutation step altogether. The likelihood of mutation is another area where user input is important: a high level of mutation will result in more variation of child chromosomes, and thus will not incorporate the relative fitness of the parent chromosomes as much. On the other hand, if the mutation step is not included then we run a greater risk of our solution converging to some solution that is only locally minimal; that is, it may be better than all of the solutions that are similar to it, but not necessarily better than solutions that are radically different (we may think of these solutions as being farther away in the solution space). The advantage of using a genetic algorithm is that there is inherently some level of stochasticity; that is, there is always the possibility of mutating to a better solution (as long as the mutation rate is nonzero).

For the following exercises, use Netlogo to open the file entitled Rabbits-Grass-GA.nlogo, available at http://admg.vbi.vt.edu/software/rabbitsgrass-netlogo-files/. This file runs a genetic algorithm to attempt to determine the best poison schedule based on the cost function given in the model (the schedule which minimizes the number of rabbits and the days on which poison is used). Read the “Info” tab for information on each of the options. In addition, you may need to examine the code in this model in order to complete all exercises.

Exercise 5.18

Explain the difference between roulette and tournament selection. How would roulette selection be different if we were interested in schedules with the highest cost? ∇

Exercise 5.19

Explain the difference between uniform and 1-point crossover. Describe a control problem for which uniform crossover is more appropriate, and another for which 1-point crossover is more appropriate. ∇

Exercise 5.20

Explain the mutation methods invert and neighbor swap. Explain the advantages and disadvantages of each. ∇

Exercise 5.21

Devise and explain methods for selection, crossover, and mutation other than those available in the model. Describe advantages of each. ∇

Exercise 5.22

The retention slider determines how many of the top solutions should be carried over to the next generation. Describe a potential pitfall of setting this value to 0. Describe a potential pitfall of setting this value too high. ∇

Exercise 5.23

Notice that the default number of runs is 100. What benefit is there to setting this value lower? What is the risk? What are the advantages and disadvantages of setting this value higher? ∇

Exercise 5.24

Click restore-defaults, then click setup. Toward the top of the interface, make sure view updates is unchecked. Run the algorithm (this may take a while). Make note of the best schedule found. Now run it again, only changing the poison so that it degrades. Again, take note of the best schedule found (note that this data should be saved in a .csv file in the folder where the model is saved). What differences do you notice? Why do you think this is? ∇

Exercise 5.25

Make sure that poison-degrade is set to On and that poison-strength is set to 0.75. Choose values for the various sliders and methods on the right-hand side of the interface tab (i.e., the algorithm settings) in an attempt to minimize the cost. Use your intuition as a starting point, then revise the values based on the output (make sure write-to-file? is turned on). What is the minimum cost you are able to achieve? What pattern (if any) do you notice in the best schedule found? ∇

Exercise 5.26

Implement your ideas from Exercise 5.21 into the code and run the genetic algorithm using them. Do they perform better or worse than the original methods?1 ∇

Exercise 5.27

Suppose the objective is simplified so that the goal is to simply minimize the number of rabbits, without regard to the poison cost. What do you think the best solution would be in this case? Alter the cost function in the code accordingly, and run the GA. Does the outcome reflect your intuition? ∇

Exercise 5.28

Determine a new objective and alter the cost function accordingly. Run the GA. Discuss the pattern of the best schedule found, and state whether or not this seems to make sense in light of your cost function. ∇

5.7.2 Other Heuristic Algorithms

Genetic algorithms represent only one class of heuristic algorithms. There are many others, and as mentioned earlier, each have their own advantages and disadvantages. The purpose of this section is to provide you with an overview of how heuristic algorithms can be used as a brute force approach to optimal control of agent-based models. Depending on the nature of the model and the control objective, the reader may also be interested in simulated annealing [15,16], tabu search [1719], ant colony optimization [20,21], and “squeaky wheel” optimization [22,23] (to name just a few). The combinations of these algorithms and the fine-tuning therein provide a large framework from which to apply heuristic algorithms to agent-based models, and new algorithms are constantly being developed. While more rigorous mathematical theory is currently being developed, this approach is sometimes the best available analytical tool.

5.8 Mathematical Framework for Representing Agent-Based Models

As addressed earlier, many agent-based models are too complex to find global optimal control purely by simulation. One option one might pursue in this case is to translate agent-based models into a different type of mathematical object for which more mathematical tools are available. This is similar to the approach pioneered by Descartes and his introduction of a coordinate system. In the plane, for instance, a Cartesian coordinate system allows us to represent lines by linear equations, circles by quadratic equations, etc. If we now want to find out whether two lines in the plane intersect we can either carry out an inspection of the two lines as geometric objects or, alternatively, we can determine whether the resulting system of linear equations has a solution. Translating agent-based models into a formal mathematical framework then opens up the possibilities to use theory from mathematics to analyze them from a different angle rather than just with simulations. One framework that has been studied is that of so-called polynomial dynamical systems (PDSs).

As in our running examples of rabbits and grass, agents in the models we consider here take on a finite number of states, such as a rabbit’s position on the grid or the amount of grass on a patch. This finite set of states can be viewed as the analog of the points that make up a line in the plane, to continue with the analogy of the Cartesian coordinate system. Applying the rules of the model in order to update the states of all the agents can be thought of as a function that maps the collection of discrete states to itself. Since the state sets do not carry any kind of structure we are simply dealing with a function from a finite set to itself, about which we can say little. However, let us now introduce the analog of a Cartesian coordinate system into this set in a way that provides extra tools for us, analogous to the ability to use algebra to decide whether two lines in the plane intersect. We do this by way of an example.

Suppose that our set of states equals image, which we can represent as {0, 1, 2}. We can easily turn this set into a number system by using so-called arithmetic modulo 3. That is, we can add and multiply the elements of this set according to rules that are identical to those used to multiply real numbers. Notice that the numbers in the set are all the remainders one can obtain under division by 3. Now we add and multiply “modulo 3,” that is, 2 + 2 = 1 and image as well, that is the remainder of 2 + 2 = 4 under division by 3 is 1. The number system we obtain in this way is an example of a “finite field,” which we will use for the remainder of the chapter. We denote the finite field with three elements by image, or more generally, the finite field with p elements, where p is prime, by image.

Given rules from an ABM that describe how the agents or variables change their states, we can find for every agent a polynomial that describes the given rule using elements of the finite field such as {0, 1, 2} rather than {low, medium, high}. By constructing a polynomial for every single agent, we obtain a set of polynomials that describes the same behavior as the original ABM. The set is called a polynomial dynamical system.

Definition 5.4

Definition 5.4 Polynomial dynamical system

Let k be a finite field and image be polynomials. Then image is an n-dimensional polynomial dynamical system over k[24].

Here, image denotes the Cartesian product image with n copies of k. image denotes the ring of polynomials in variables image and coefficients in k. For image the function F is evaluated by

image

Example 5.5

Let image and image, where

image

The PDS F maps points in image to other points in image, and iteration of F results in a dynamical system. F has one fixed point, or steady state, namely (1, 0, 2) because image, and note that all calculation are done “modulo 3” because F is over image. Furthermore, F has a limit cycle or oscillation of length five: applying F repeatedly to (0, 2, 1) yields

image

With software packages such as ADAM [25], one can compute the dynamics of a PDS and visualize it.

Most agent-based models can be translated into a polynomial dynamical system of this type. Each variable image represents an agent, a patch, or some other entity in the model. Each element in the finite field k represents a different state or condition of the variables. The corresponding polynomials image encode the behavior of the agent or patch as described in the model. In the rabbit and grass model, one could assign a variable image for each patch. The values of the finite field image then represent how many rabbits and how much grass is currently on the patch. The polynomials image determine the number of rabbits and amount of grass on patch i at the next iteration, given the current number of rabbits and grass. We will explain in more detail how to derive the polynomials for an agent-based model in Section 5.9, however their existence is assured by the following result.

Theorem 5.5

Theorem 5.5 [26]

Let imagebe any function on a finite field k. Then there exists a unique polynomial image, such that image.

Any such mapping over a finite field can be described by a unique polynomial. Using Lagrange interpolation, we can easily determine the polynomial. Let image be any function on k. Then

image (5.1)

is the unique polynomial that defines the same mapping as f.

Example 5.6

Suppose image, and the mapping f is defined on image as follows:

image

Then the polynomial g that defines the same mapping as f is constructed as follows:

image

Converting an agent-based model into a polynomial dynamical system provides us with a conceptual advantage, since rather than being limited to working with a computer simulation as our only means of analysis, methods and theory from abstract algebra and algebraic geometry can be used. For example, one might be interested in the steady states of a model, i.e., all the configurations of the system that do not change over time. Written as a polynomial dynamical system image, these states are exactly the solutions to image, the n-dimensional system of equations image in image[25]. Equivalently, the solutions are the points in the variety image of the ideal generated by the polynomials image. For an introduction to varieties, we recommend [27].

When the polynomials describing the biological system have a special structure, other analysis methods are available. For example, for conjunctive networks, i.e., a PDS over image where each polynomials is a monomial, the dynamics can be completely inferred by looking at the dependency graph or wiring diagram of the PDS [28]. We can determine the fixed point and limit cycle structure of this PDS without using any simulation.

We have mentioned Conway’s Game of Life, a cellular automaton as a special case of agent-based models earlier in this chapter. Cells are agents that die or come to life based on a rule including their eight neighbors [5]. The Game of Life can be translated into a polynomial dynamical system. Each variable image represents a cell on the grid. Each polynomial image depends on image’s eight neighbors and itself and describes whether image will be dead (0) or alive (1) at the next iteration given the values of its neighboring cells. The fixed points of this system correspond to still lives such as blocks and beehives, two cycles to oscillators, e.g., blinkers and beacons. Working with the mathematical representation of the game, one can for example study still lives by using concepts from invariant theory using the symmetry of the rules as group actions.

Exercise 5.29

Using Lagrange’s interpolation formula (5.1), construct the polynomial image describing the behavior of cell image with neighbors image, i.e., the polynomial image should evaluate to 0 or 1 (dead or alive) according to the rules of the Game of Life given the state of the cell image and its eight neighbors. ∇

In the next section, we provide some polynomials for common rules in agent-based models. By providing such rules, we hope to simplify the process of translating an ABM to a PDS. The polynomials can be used as given or as a starting point to construct functions that represent more complex behavior.

5.9 Translating Agent-Based Models into Polynomial Dynamical Systems

This section is authored jointly by Franziska Hinkelmann, Matt Oremland, Hussein Al-Asadi, Atsya Kumano, Laurel Ohm, Alice Toms, Reinhard Laubenbacher

Discrete models, including agent-based models, are important tools for modeling biological systems, but model complexity may hinder complete analysis. Representation as a PDS provides a framework for efficient analysis using theory from abstract algebra. In this section, we provide polynomials that describe common agent interactions. In the previous section we described how to interpolate agent behavior and to generate the appropriate polynomial. However, for a variable with many different states, this method of interpolation results in long and complex polynomials that are difficult to expand, simplify, or alter. Thus we provide some general “shortcut rules” for constructing polynomials that describe key agent and patch interactions present in many ABMs. Each of the following polynomials exists in the finite field image.

Since we are particularly interested in ABMs describing complex biological systems, we use the term concentration to describe the states of a patch variable (for example, concentration of white blood cells on a patch). In this chapter we describe several polynomials that describe both basic movement, and movement according to the state of the neighboring patches.

5.9.1 Basic Movement Function

One can construct various polynomials to describe the movement of an agent on an n-by-n grid where the x- and y-coordinates of patches are numbered 0 to image from left to right with torus topology, i.e., there are no boundaries to the grid, so that if an agent on the left most patch moves to the left, he appears on the right side of the grid, and similarly for top and bottom. By moving forward we mean moving to the right, and potentially “wrapping” around to the left edge of the grid, and by moving backward we mean moving to the left.

For an agent moving forward one patch per time step, we want an agent on patch x to move to patch image unless the agent is on patch image, in which case the agent will move to patch image on the next step due to the torus topology of the grid (see Table 5.1). The polynomial describing this movement is given in Eq. (5.2).

Table 5.1

Movement of an agent on a grid with n patches.

Image

One can construct a similar polynomial for an agent moving backward one step per time step (see Eq. (5.3)), and using this polynomial along with the forward movement one can create a polynomial to describe movement of several steps along the x-axis as specified by a series of elements in image (representing forward, backward, or no movement), (Eq. 5.4). Furthermore, one can generalize these polynomials to describe movement of a fixed step length m, (Eq. 5.5) and (Eq. 5.6).

• Agent moves forward one patch per time step:

image (5.2)

• Agent moves backward one patch per time step:

image (5.3)

• We can use these equations to construct a more general movement function image, where image specifies the direction of the agent by taking image when the agent moves back one step, image when the agent stays as is, and image when it moves one step forward. Note that image for all image.

image (5.4)

• Agent moves forward m patches per time step:

image (5.5)

• Agent moves backward m patches per time step:

image (5.6)

In order to show that Eq. (5.2) is the polynomial over image that describes moving one space forward on an n-by-n grid, we need to show that image for all image and image for image. Note that image and image in image.

• Case: image.

• Case: image:

image

Exercise 5.30

Show that Eqs. (5.3), (5.4), (5.5), (5.6) indeed describe the movements as stated above. ∇

5.9.2 Uphill and Downhill Movement

In many applications, agents can scan their close environment and move towards a desired resource. Netlogo has this behavior implemented as “uphill” and “downhill.” “Uphill” moves an agent to the neighboring patch with the highest value of the desired variable. If no neighboring patch has a higher value than the current patch, the agent stays put. Since the variables are discrete, there may exist a tie between neighboring patches for highest (or lowest) concentration, in which case the agent moves toward the lowest arbitrarily numbered neighboring patch i. The polynomials describing the movement of agent x are the following.

• Uphill:

image (5.7)

• Downhill:

image (5.8)

where the concentration ranges from 0 to image represents the highest possible concentration, image is the concentration level at neighboring patch i, and image is the relative location of patch i from the current patch, see Table 5.2. image is the concentration of the current patch, image are the concentrations of its eight neighbors.

Table 5.2

Relative position of neighbors to agent x.

Image

Next, we show that Eq. (5.7) describes the uphill movement.

image (5.9)

It is straightforward to see that Eq. (5.9) describes the movement to the neighboring patch with the highest concentration level: image is 0 unless at least one of the image, i.e., one of the neighbors’ concentrations level is the highest possible. In this case, image. Indeed, the right hand of the first line evaluates to image for the i such that image (image is image if and only if (image). If there are several neighbors with concentration level image should evaluate to the neighbor with the smallest index. This is assured by multiplying with image, which evaluates to 0, if a neighbor with a smaller index has concentration C. The second and third line in Eq. (5.9) are equivalent to the first row, as they describe movement to patches with concentration levels lower than C. The term image assures that the second summand evaluates to 0 if a patch has a higher concentration than m. The proof for the downhill movement (Eq. 5.8) is similar and left as an exercise.

Exercise 5.31

Based on the uphill and downhill polynomial, construct a polynomial image that evaluates to the maximum concentration of its eight neighbors and itself. ∇

Exercise 5.32

Consider a 13 by 13 grid with torus topology. A rabbit moves two steps up and two to the right at every iteration. Construct a polynomial that describes a rabbit’s movement. Use the polynomial to simulate the movement of a rabbit starting in the center of the grid. ∇

Exercise 5.33

For the rabbit in Exercise 5.32, after how many iterations do you expect it to reach its starting position again? Confirm your answer by evaluating the polynomial. ∇

Exercise 5.34

Construct the polynomial as in Exercise 5.32 for a grid of arbitrary size n by n. ∇

Exercise 5.35

Consider a grid where each patch is covered with a low, medium, or high amount of grass. At each iteration, the rabbit moves to the neighboring patch with the most grass, i.e., to one of the eight neighboring patches or it stays on the same patch. Construct a polynomial describing the rabbit’s movement based on the amount of grass on the neighboring patches. ∇

Exercise 5.36

Consider the grid from Exercise 5.35. Rabbits eat grass, and the amount of grass on a patch decreases by one level for every iteration that a rabbit occupies it, i.e., a patch with high grass changes to medium grass, if occupied by a rabbit, medium to low, and low remains low. Construct a polynomial that describes the amount of grass on a patch. ∇

We provide these general polynomials and simplification techniques to aid in the transformation of an ABM into a PDS. Whereas large agent-based models may be too complex for efficient analysis, we hope that the algebraic structure of a polynomial dynamical system can be used to expedite computation of optimal control.

5.10 Summary

Agent-based models provide a very intuitive and convenient way to model a variety of phenomena in biology. The price we pay for these features is that the models are not explicitly mathematical, so that we lack mathematical tools for model analysis. For instance, many of these phenomena are connected to optimization and optimal control problems, as pointed out in this chapter, but no systematic methods are available for agent-based models to solve these. We have attempted here to do two things. Firstly, we described so-called heuristic local search methods, such as genetic algorithms, which can be applied directly to agent-based models. And we described a way in which one can translate an agent-based model into a mathematical object, in this case a polynomial dynamical system over a finite field. Many computational and theoretical tools are available for such systems. For instance, to compute the steady states of a polynomial system image, one can solve the system of polynomial equations

image

There are several computer algebra systems available to solve such problems. To compute the steady states of an agent-based model, on the other hand, one is limited to extensive simulation, without any guarantee of having found all possible steady states.

The chapter provides a snapshot of ongoing research in the field. The approach via polynomial dynamical systems, for instance, is very promising, but still lacks appropriate algorithms that scale to larger models. In addition to searching for such algorithms, further research in model reduction is taking place, as outlined earlier in the chapter. At the same time, other mathematical frameworks, such as ordinary or partial differential equations and Markov models are being explored for this purpose. Much work remains to be done but, in the end, a combination of better algorithms, improvements in hardware, and dimension reduction methods is likely to provide for us a tool kit that will allow the solution of realistic large-scale optimization and optimal control problems in ecology, biomedicine, and other fields related to the life sciences.

5.11 Supplementary Materials

All supplementary files and/or computer code associated with this article can be found from the volume’s website http://booksite.elsevier.com/9780124157804

References

1. Ledzewicz U, Naghnaeian M, Schattler H. Optimal response to chemotherapy for a mathematical model of tumor-immune dynamics. J Math Biol. 2012;64:557–577.

2. Sontag ED. Mathematical control theory. 2nd ed. New York, NY: Springer; 1998.

3. Iglesias PA, Ingalls BP, eds. Control theory and systems biology. Cambridge, MA: The MIT Press; 2009.

4. Von Neumann J. The general and logical theory of automata. In: New York: John Wiley & Sons; 1951;Jeffres LA, ed. Cerebral mechanisms of behavior – the Hixon symposium. vols. 1–31.

5. Gardner M. The fantastic combinations of John Conway’s new solitaire game life. Sci Am. 1970;223:120–123.

6. Wilensky U. NetLogo Center for connected learning and computer-based modeling. Evanston, IL: Northwestern University; 2009; In: http://ccl.northwestern.edu/netlogo/; 2009.

7. Laubenbacher R, Jarrah AS, Mortveit H, Ravi SS. Mathematical formalism for agent-based modeling. In: Springer 2009;Meyers RA, ed. Encyclopedia of complexity and systems science. vols. 160–176.

8. Grimm Volker, Berger Uta, Bastiansen Finn, et al. A standard protocol for describing individual-based and agent-based models. Ecol Model. 2006;198:115–126.

9. Hinkelmann F, Murrugarra D, Jarrah AS, Laubenbacher R. A mathematical framework for agent based models of complex biological networks. Bull Math Biol 2010.

10. Alan Veliz-Cuba, Jarrah Abdul Salam, Laubenbacher Reinhard. Polynomial algebra of discrete models in systems biology. Bioinformatics. 2010;26:1637–1643.

11. Kirk Donald E. Optimal control theory: an introduction. Englewood Cliffs, New Jersey: Prentice-Hall Inc; 1970.

12. Goldberg DE. Genetic algorithms in search, optimization, and machine learning Reading. MA: Addison-Wesley; 1989.

13. Holland John H. Adaptation in natural and artificial systems. Ann Arbor, Mich.: University of Michigan Press; 1975; [An introductory analysis with applications to biology, control, and, artificial intelligence 51].

14. Koza John R. Evolution and co-evolution of computer programs to control independently-acting agents. In: MIT Press 1991; Proceedings of the First International Conference on Simulation of Adaptive Behavior. vols. 366–375.

15. Kirkpatrick S, Gelatt CD, Vecchi MP. Optimization by simulated annealing. Science. 1983;220:671–680.

16. Pennisi M, Catanuto R, Pappalardo F, Motta S. Optimal vaccination schedules using simulated annealing Bioinformatics. 2008;24:1740–1742.

17. Fred Glover. Tabu search–part I. Informs J Comput. 1989;1:190–206.

18. Fred Glover. Tabu search–part II. Informs J Comput. 1990;2:4–32.

19. Glover Fred. Tabu search: a tutorial. Interfaces. 1990;20:74–94.

20. Dorigo M, Maniezzo V, Colorni A. Ant system: optimization by a colony of cooperating agents Systems. IEEE Trans Syst Man Cybern B Syst Humans. 1996;26:29–41.

21. Dorigo Marco, Caro Gianni Di, Gambardella Luca M. Ant algorithms for discrete optimization. Artif Life. 1999;5:137–172.

22. Joslin David E, Clements David P. Squeaky wheel optimization. J Artif Intell Res. 1999;10:353–373 (electronic).

23. Li Jingpeng, Parkes Andrew J, Burke Edmund K. Evolutionary squeaky wheel optimization: a new analysis framework evolutionary computation; 2011. published online.

24. Stigler B, Jarrah A, Stillman M, Laubenbacher R. Reverse engineering of dynamic networks. Ann NY Acad Sci. 2007;1115:168–177.

25. Hinkelmann Franziska, Brandon Madison, Guang Bonny, et al. ADAM: analysis of discrete models of biological systems using computer algebra BMC. Bioinformatics. 2011;12:295.

26. Laubenbacher Reinhard, Stigler Brandilyn. A computational algebra approach to the reverse engineering of gene regulatory networks. J Theor Biol. 2004;229:523–537.

27. Cox David A, Little John, O’Shea Donal. Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra, 3/e (Undergraduate Texts in Mathematics). Secaucus, NJ, USA: Springer-Verlag New York Inc; 2007.

28. Jarrah Abdul, Laubenbacher Reinhard, Veliz-Cuba Alan. The dynamics of conjunctive and disjunctive boolean network models. Bull Math Biol. 2010;72:1425–1447. doi 10.1007/s11538-010- 9501-z.


1This exercise requires knowledge of Netlogo programming.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset