{
"DeviceWidth" : 768,
"DefaultUnitSet" : "SI",
"CaseName" : "Predator",
"Version" : 1.201,
"UserUnits" : [],
"RootModel" : {
"HideInfo" : "n",
"diagramY" : -16.33333,
"name" : "Root",
"diagramX" : -12,
"Notes" : "This example illustrates the use of the ODE solver simulate the classic predator/prey relationship as characterized by the Lotka-Volterra model.\n\nSee http://wikipedia.org/wiki/Lotka-Volterra_equation.\n\nThe calculation is contained in the Population model, with the results illustrated in the two Plot objects.\n\nMathworks has a published demonstration of this problem (look for \"Numerical Integration of Differential Equations\" in the demos section of the mathworks.com website). The Math Minion solution to this problem is reproduced in the MatlabExample model.",
"Objects" : [
{
"HideInfo" : "n",
"diagramY" : -26.21469,
"name" : "MatlabExample",
"Type" : "Model",
"Notes" : "This model solves the Mathworks demonstration problem named \"Numerical Integration of Differential Equations\" in the demos section of the mathworks.com website.\n\nThey formulate the problem as:\n\ny1' = (1 - alpha)*y2)*y1\ny2' = (-1+ beta*y1)*y2\n\nalpha = 0.01 and beta = 0.02 and the initial values y1 = y2 = 20.\n\nThis problem is solved as stated by the ode object.\n\nA little algebra can transform these equations into the form used by our population model,with:\n\nPreyGrowth = 1\nPreyDeath = 0.01\nPredDeath = 1\nEfficiency = 2\n\nPlugging these values into a copy of our Population model along with the appropriate initial values and duration, results in an equivalent solution.",
"Objects" : [
{
"dyFormula" : {
"Formula" : "dy"
},
"endTFormula" : {
"Formula" : "15"
},
"recFormulas" : [
{
"Formula" : "$.t"
},
{
"Formula" : "$.y[1]"
},
{
"Formula" : "$.y[2]"
}
],
"absTolFormula" : {
"Formula" : "1.0e-10"
},
"y0Formula" : {
"Formula" : "y0"
},
"Type" : "ODE Solver",
"DiagramX" : 115,
"AutoRun" : "y",
"nextTFormula" : {
"Formula" : "$.t + 0.1"
},
"name" : "ode",
"DiagramY" : 70,
"relTolFormula" : {
"Formula" : "1.0e-5"
}
},
{
"Type" : "Expression",
"name" : "y0",
"Formula" : {
"Formula" : "{concat 20,20}"
},
"DiagramY" : 70,
"DiagramX" : 10
},
{
"DiagramX" : 115,
"columnCount" : "1",
"name" : "dy",
"Type" : "Matrix",
"DiagramY" : 110,
"rowCount" : "2",
"CellInputs" : {
"2_1" : "(-1 + beta*ode.y[1])*ode.y[2]",
"1_1" : "(1 - alpha * ode.y[2])*ode.y[1]",
"0_0" : "0"
}
},
{
"Type" : "Expression",
"name" : "alpha",
"Formula" : {
"Formula" : "0.01"
},
"DiagramY" : 90,
"DiagramX" : 10
},
{
"Type" : "Expression",
"name" : "beta",
"Formula" : {
"Formula" : "0.02"
},
"DiagramY" : 110,
"DiagramX" : 10
},
{
"Type" : "Graph/Table",
"name" : "plot",
"X1" : {
"vmax" : "",
"Y2" : {
"vmax" : "350",
"lineType" : 0,
"v" : "ode.r3'predator",
"vmin" : "0"
},
"Y1" : {
"vmax" : "350",
"lineType" : 0,
"v" : "ode.r2'prey",
"vmin" : "0"
},
"v" : "ode.r1'time",
"vmin" : ""
},
"DiagramY" : 70,
"DiagramX" : 200
},
{
"Type" : "Graph/Table",
"name" : "plot2",
"X1" : {
"vmax" : "200",
"Y1" : {
"vmax" : "350",
"lineType" : 0,
"v" : "ode.r3'predator",
"vmin" : "0"
},
"v" : "ode.r2'prey",
"vmin" : "0"
},
"DiagramY" : 95,
"DiagramX" : 200
},
{
"HideInfo" : "n",
"diagramY" : 19.49153,
"name" : "Population",
"Type" : "Model",
"Notes" : "A copy of the parent Population model, with parameters equivalent to the Mathworks example.\n\nSimulates the classic predator/prey relationship as characterized by the Lotka-Volterra model.\n\nSee http://wikipedia.org/wiki/Lotka-Volterra_equation.\n\nFor our purposes this can be stated as:\n\ndR/dt = a*R - b*R*F\ndF/dt = e*b*R*F - cF\n\nwhere:\n\nt = time\nR = prey population (R for rabbit)\nF = predator population (F for fox)\na = the growth rate of prey in the absence of predators.\nb = the death rate of prey per predator encounter.\nc = death rate of predators with no prey.\ne = efficiency of turning prey into predators.\n\nThese variables are all represented as input expressions with more descriptive names and the resulting time versus population arrays are available as output expressions.",
"Objects" : [
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "PreyGrowth",
"Type" : "Expression",
"Notes" : "Prey growth in absence of predators",
"Formula" : {
"Formula" : "1"
},
"DiagramY" : 85,
"DiagramX" : 35
},
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "PreyDeath",
"Type" : "Expression",
"Notes" : "Death rate of prey per encounter with predator",
"Formula" : {
"Formula" : "0.01"
},
"DiagramY" : 105,
"DiagramX" : 35
},
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "PredDeath",
"Type" : "Expression",
"Notes" : "Death rate of predator in a absence of food",
"Formula" : {
"Formula" : "1"
},
"DiagramY" : 125,
"DiagramX" : 35
},
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "Efficiency",
"Type" : "Expression",
"Notes" : "Efficiency of turning prey into predators.",
"Formula" : {
"Formula" : "2"
},
"DiagramY" : 145,
"DiagramX" : 35
},
{
"dyFormula" : {
"Formula" : "dp"
},
"endTFormula" : {
"Formula" : "Duration"
},
"recFormulas" : [
{
"Formula" : "$.t"
},
{
"Formula" : "p[1]"
},
{
"Formula" : "p[2]"
}
],
"absTolFormula" : {
"Formula" : "1.0e-10"
},
"y0Formula" : {
"Formula" : "{concat InitialPrey,InitialPred}"
},
"Type" : "ODE Solver",
"DiagramX" : 185,
"Notes" : "The InitialPrey an InitialPred values are concatenated into a two value array for the Y0 initial values. This determines that the solver will be integrating two equations simultaneously and that its Y output parameter will also be an array of length two.\n\nThe derivative values are the array, also length two, calculated in the dp object.\n\nThe stop time is taken from the Duration input expression.\n\nThe Next T formula calculates the time that the next set of values should be recorded and saved for viewing once the integration is complete. In this case the formula:\n\n$.t + Duration/500\n\nis used. The $ always refers to the object owning a formula, so in this case the integrate object itself. The t parameter of an ODE solver is always the current time as the solver proceeds through the calculation.\n\nAll the requested recorded values are evaluated at time t=0 and then this formula is evaluated to determine the next time to record things. When that occurs, it is again evaluated with the new time to determine the next record time and so forth.\n\nIn this case we are using fixed steps equal to 1/500th of the total specified duration. Note that this does. It determine the integration step size, which is independently determined to meet the required error tolerances, other than it might be shortened to match a record time when necessary.\n\nFor most problems, the tolerances can be left at the default values, as the are here.\n\nThree recorded values are defined:\n\n$.t - the time of the recording\np[1] - the prey population at that time\nP[2]- the predator population at that time\n\n ",
"AutoRun" : "y",
"nextTFormula" : {
"Formula" : "$.t + Duration/500"
},
"name" : "integrate",
"DiagramY" : 25,
"relTolFormula" : {
"Formula" : "1.0e-5"
}
},
{
"HideInfo" : "n",
"CellInputs" : {
"2_1" : "Efficiency*PreyDeath*p[1]*p[2] - PredDeath*p[2]",
"1_1" : "PreyGrowth*p[1] - PreyDeath*p[1]*p[2]",
"0_0" : "0"
},
"columnCount" : "1",
"name" : "dp",
"Type" : "Matrix",
"Notes" : "This two cell matrix has the formula for the derivative of prey population wrt time in the row one cell and for the predator derivative in the row two cell.\n\nThus this is the derivative array for the integrator.\n ",
"DiagramY" : 145,
"rowCount" : "2",
"DiagramX" : 125
},
{
"HideInfo" : "n",
"name" : "p",
"Type" : "Expression",
"Notes" : "This is the calculated prey and predator populations, with the values being in rows one and two respectively.",
"Formula" : {
"Formula" : "integrate.y"
},
"DiagramY" : 100,
"DiagramX" : 195
},
{
"HideInfo" : "n",
"isOutput" : "y",
"name" : "PreyPop",
"Type" : "Expression",
"Notes" : "Population of prey at each recorded time.",
"Formula" : {
"Formula" : "integrate.r2"
},
"DiagramY" : 45,
"DiagramX" : 275
},
{
"HideInfo" : "n",
"isOutput" : "y",
"name" : "PredPop",
"Type" : "Expression",
"Notes" : "Population of predators at each recorded time.",
"Formula" : {
"Formula" : "integrate.r3"
},
"DiagramY" : 65,
"DiagramX" : 275
},
{
"HideInfo" : "n",
"isOutput" : "y",
"name" : "Time",
"Type" : "Expression",
"Notes" : "The recorded integration times.",
"Formula" : {
"Formula" : "integrate.r1"
},
"DiagramY" : 25,
"DiagramX" : 275
},
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "InitialPrey",
"Type" : "Expression",
"Notes" : "Initial number of prey",
"Formula" : {
"Formula" : "20"
},
"DiagramY" : 25,
"DiagramX" : 35
},
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "InitialPred",
"Type" : "Expression",
"Notes" : "Initial number of predators",
"Formula" : {
"Formula" : "20"
},
"DiagramY" : 45,
"DiagramX" : 35
},
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "Duration",
"Type" : "Expression",
"Notes" : "Length of time to calculate",
"Formula" : {
"Formula" : "15"
},
"DiagramY" : 65,
"DiagramX" : 35
}
],
"diagramScale" : 2.298542,
"DiagramY" : 165,
"diagramX" : -23.72881,
"DiagramX" : 80
},
{
"Type" : "Graph/Table",
"name" : "plotCopy",
"DiagramX" : 175,
"X1" : {
"vmax" : "",
"Y2" : {
"vmax" : "350",
"lineType" : 0,
"v" : "Population.PredPop'Predator",
"vmin" : "0"
},
"Y1" : {
"vmax" : "350",
"lineType" : 0,
"v" : "Population.PreyPop'Prey",
"vmin" : "0"
},
"v" : "Population.Time",
"vmin" : ""
},
"DiagramY" : 165,
"Notes" : "Plots the prey and predator populations versus time.\n\nYou may want to adjust the two y axis maximums if you adjust the Population object input values such that the current ranges aren't appropriate."
},
{
"Type" : "Graph/Table",
"name" : "plot2Copy",
"DiagramX" : 175,
"X1" : {
"vmax" : "200",
"Y1" : {
"vmax" : "350",
"lineType" : 0,
"v" : "Population.PredPop'Predator",
"vmin" : "0"
},
"v" : "Population.PreyPop'Prey",
"vmin" : "0"
},
"DiagramY" : 185,
"Notes" : "Plots the prey verus predator populations.\n\nYou may want to adjust the axis maximums if you adjust the Population object input values such that the current ranges aren't appropriate."
}
],
"diagramScale" : 2.75825,
"DiagramY" : 100,
"diagramX" : 0.3531073,
"DiagramX" : 20
},
{
"HideInfo" : "n",
"diagramY" : 19.49153,
"name" : "Population",
"Type" : "Model",
"Notes" : "Simulates the classic predator/prey relationship as characterized by the Lotka-Volterra model.\n\nSee http://wikipedia.org/wiki/Lotka-Volterra_equation.\n\nFor our purposes this can be stated as:\n\ndR/dt = a*R - b*R*F\ndF/dt = e*b*R*F - cF\n\nwhere:\n\nt = time\nR = prey population (R for rabbit)\nF = predator population (F for fox)\na = the growth rate of prey in the absence of predators.\nb = the death rate of prey per predator encounter.\nc = death rate of predators with no prey.\ne = efficiency of turning prey into predators.\n\nThese variables are all represented as input expressions with more descriptive names and the resulting time versus population arrays are available as output expressions.",
"Objects" : [
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "PreyGrowth",
"Type" : "Expression",
"Notes" : "Prey growth in absence of predators",
"Formula" : {
"Formula" : "1"
},
"DiagramY" : 85,
"DiagramX" : 35
},
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "PreyDeath",
"Type" : "Expression",
"Notes" : "Death rate of prey per encounter with predator",
"Formula" : {
"Formula" : "0.003"
},
"DiagramY" : 105,
"DiagramX" : 35
},
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "PredDeath",
"Type" : "Expression",
"Notes" : "Death rate of predator in a absence of food",
"Formula" : {
"Formula" : "2"
},
"DiagramY" : 125,
"DiagramX" : 35
},
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "Efficiency",
"Type" : "Expression",
"Notes" : "Efficiency of turning prey into predators.",
"Formula" : {
"Formula" : "1"
},
"DiagramY" : 145,
"DiagramX" : 35
},
{
"dyFormula" : {
"Formula" : "dp"
},
"endTFormula" : {
"Formula" : "Duration"
},
"recFormulas" : [
{
"Formula" : "$.t"
},
{
"Formula" : "p[1]"
},
{
"Formula" : "p[2]"
}
],
"HideInfo" : "n",
"absTolFormula" : {
"Formula" : "1.0e-10"
},
"y0Formula" : {
"Formula" : "{concat InitialPrey,InitialPred}"
},
"Type" : "ODE Solver",
"DiagramX" : 185,
"Notes" : "The InitialPrey an InitialPred values are concatenated into a two value array for the Y0 initial values. This determines that the solver will be integrating two equations simultaneously and that its Y output parameter will also be an array of length two.\n\nThe derivative values are the array, also length two, calculated in the dp object.\n\nThe stop time is taken from the Duration input expression.\n\nThe Next T formula calculates the time that the next set of values should be recorded and saved for viewing once the integration is complete. In this case the formula:\n\n$.t + Duration/500\n\nis used. The $ always refers to the object owning a formula, so in this case the integrate object itself. The t parameter of an ODE solver is always the current time as the solver proceeds through the calculation.\n\nAll the requested recorded values are evaluated at time t=0 and then this formula is evaluated to determine the next time to record things. When that occurs, it is again evaluated with the new time to determine the next record time and so forth.\n\nIn this case we are using fixed steps equal to 1/500th of the total specified duration. Note that this does. It determine the integration step size, which is independently determined to meet the required error tolerances, other than it might be shortened to match a record time when necessary.\n\nFor most problems, the tolerances can be left at the default values, as the are here.\n\nThree recorded values are defined:\n\n$.t - the time of the recording\np[1] - the prey population at that time\nP[2]- the predator population at that time\n\n ",
"AutoRun" : "y",
"nextTFormula" : {
"Formula" : "$.t + Duration/500"
},
"name" : "integrate",
"DiagramY" : 25,
"relTolFormula" : {
"Formula" : "1.0e-5"
}
},
{
"HideInfo" : "n",
"CellInputs" : {
"2_1" : "Efficiency*PreyDeath*p[1]*p[2] - PredDeath*p[2]",
"1_1" : "PreyGrowth*p[1] - PreyDeath*p[1]*p[2]",
"0_0" : "0"
},
"columnCount" : "1",
"name" : "dp",
"Type" : "Matrix",
"Notes" : "This two cell matrix has the formula for the derivative of prey population wrt time in the row one cell and for the predator derivative in the row two cell.\n\nThus this is the derivative array for the integrator.\n ",
"DiagramY" : 145,
"rowCount" : "2",
"DiagramX" : 125
},
{
"HideInfo" : "n",
"name" : "p",
"Type" : "Expression",
"Notes" : "This is the calculated prey and predator populations, with the values being in rows one and two respectively.",
"Formula" : {
"Formula" : "integrate.y"
},
"DiagramY" : 100,
"DiagramX" : 195
},
{
"HideInfo" : "n",
"isOutput" : "y",
"name" : "PreyPop",
"Type" : "Expression",
"Notes" : "Population of prey at each recorded time.",
"Formula" : {
"Formula" : "integrate.r2"
},
"DiagramY" : 45,
"DiagramX" : 275
},
{
"HideInfo" : "n",
"isOutput" : "y",
"name" : "PredPop",
"Type" : "Expression",
"Notes" : "Population of predators at each recorded time.",
"Formula" : {
"Formula" : "integrate.r3"
},
"DiagramY" : 65,
"DiagramX" : 275
},
{
"HideInfo" : "n",
"isOutput" : "y",
"name" : "Time",
"Type" : "Expression",
"Notes" : "The recorded integration times.",
"Formula" : {
"Formula" : "integrate.r1"
},
"DiagramY" : 25,
"DiagramX" : 275
},
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "InitialPrey",
"Type" : "Expression",
"Notes" : "Initial number of prey",
"Formula" : {
"Formula" : "200"
},
"DiagramY" : 25,
"DiagramX" : 35
},
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "InitialPred",
"Type" : "Expression",
"Notes" : "Initial number of predators",
"Formula" : {
"Formula" : "200"
},
"DiagramY" : 45,
"DiagramX" : 35
},
{
"HideInfo" : "n",
"isInput" : "y",
"name" : "Duration",
"Type" : "Expression",
"Notes" : "Length of time to calculate",
"Formula" : {
"Formula" : "10"
},
"DiagramY" : 65,
"DiagramX" : 35
}
],
"diagramScale" : 2.298542,
"DiagramY" : 50,
"diagramX" : -23.72881,
"DiagramX" : 20
},
{
"HideInfo" : "n",
"X1" : {
"vmax" : "",
"Y2" : {
"vmax" : "2000",
"lineType" : 0,
"v" : "Population.PredPop'Predator",
"vmin" : "0"
},
"Y1" : {
"vmax" : "2000",
"lineType" : 0,
"v" : "Population.PreyPop'Prey",
"vmin" : "0"
},
"v" : "Population.Time",
"vmin" : ""
},
"name" : "plot",
"Type" : "Graph/Table",
"Notes" : "Plots the prey and predator populations versus time.\n\nYou may want to adjust the two y axis maximums if you adjust the Population object input values such that the current ranges aren't appropriate.",
"DiagramY" : 50,
"DiagramX" : 115
},
{
"HideInfo" : "n",
"X1" : {
"vmax" : "2000",
"Y1" : {
"vmax" : "2000",
"lineType" : 0,
"v" : "Population.PredPop'Predator",
"vmin" : "0"
},
"v" : "Population.PreyPop'Prey",
"vmin" : "0"
},
"name" : "plot2",
"Type" : "Graph/Table",
"Notes" : "Plots the prey verus predator populations.\n\nYou may want to adjust the axis maximums if you adjust the Population object input values such that the current ranges aren't appropriate.",
"DiagramY" : 70,
"DiagramX" : 115
}
],
"diagramScale" : 2.921875,
"DiagramY" : -12321,
"DiagramX" : -12321
},
"Program" : "Rtm"
}