AgentMaps/docs/Agent.html
noncomputable c3e2880d79 Updates
2018-08-31 17:08:36 -04:00

2143 lines
28 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Agent</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: Agent</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>Agent<span class="signature">(lat_lng, options, agentmap)</span><span class="type-signature"></span></h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Agent"><span class="type-signature"></span>new Agent<span class="signature">(lat_lng, options, agentmap)</span><span class="type-signature"></span></h4>
<div class="description">
Constructor for the Agent class, using Leaflet class system.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>lat_lng</code></td>
<td class="type">
<span class="param-type"><a href="global.html#LatLng">LatLng</a></span>
</td>
<td class="description last">A pair of coordinates to place the agent at.</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">An array of options for the agent, namely its layer.</td>
</tr>
<tr>
<td class="name"><code>agentmap</code></td>
<td class="type">
<span class="param-type"><a href="Agentmap.html">Agentmap</a></span>
</td>
<td class="description last">The agentmap instance in which the agent exists.</td>
</tr>
</tbody>
</table>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>feature.AgentMap_id</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The agent's instance id, so it can be accessed from inside the Leaflet layer. To avoid putting the actual instance inside the feature object.</td>
</tr>
<tr>
<td class="name"><code>agentmap</code></td>
<td class="type">
<span class="param-type"><a href="Agentmap.html">Agentmap</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The agentmap instance in which the agent exists.</td>
</tr>
<tr>
<td class="name"><code>place</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Place">Place</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">A place object specifying where the agent is currently at.</td>
</tr>
<tr>
<td class="name"><code>steps_made</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
0
</td>
<td class="description last">The number of steps the agent has moved since the beginning.</td>
</tr>
<tr>
<td class="name"><code>this.trip</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">Properties detailing information about the agent's trip that change sometimes, but needs to be accessed by future updates.
<h6>Properties</h6>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>moving</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
</td>
<td class="description last">Whether the agent currently moving.</td>
</tr>
<tr>
<td class="name"><code>paused</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
</td>
<td class="description last">Whether the agent should be allowed to move along its trip.</td>
</tr>
<tr>
<td class="name"><code>current_point</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Point">Point</a></span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last">The point where the agent is currently located.</td>
</tr>
<tr>
<td class="name"><code>goal_point</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Point">Point</a></span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last">The point where the agent is traveling to.</td>
</tr>
<tr>
<td class="name"><code>lat_dir</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last">The latitudinal direction. -1 if traveling to lower latitude (down), 1 if traveling to higher latitude (up).</td>
</tr>
<tr>
<td class="name"><code>lng_dir</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last">The longitudinal direction. -1 if traveling to lesser longitude (left), 1 if traveling to greater longitude (right).</td>
</tr>
<tr>
<td class="name"><code>speed</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last">The speed that the agent should travel, in meters per tick.</td>
</tr>
<tr>
<td class="name"><code>angle</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last">The angle between the current point and the goal.</td>
</tr>
<tr>
<td class="name"><code>slope</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last">The slope of the line segment formed by the two points between which the agent is traveling at this time during its trip.</td>
</tr>
<tr>
<td class="name"><code>path</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="attributes">
</td>
<td class="description last">A sequence of LatLngs; the agent will move from one to the next, popping each one off after it arrives until the end of the street; or, until the trip is changed/reset.</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>controller</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="default">
</td>
<td class="description last">User-defined function to be called on each update (each tick).</td>
</tr>
<tr>
<td class="name"><code>fine_controller</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="default">
</td>
<td class="description last">User-defined function to be called before & after each movemnt (on each step an agent performs during a tick).</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agents.js.html">agents.js</a>, <a href="agents.js.html#line24">line 24</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".checkSpeed"><span class="type-signature">(static) </span>checkSpeed<span class="signature">(speed)</span><span class="type-signature"></span></h4>
<div class="description">
Check whether a given speed is greater than the minimum.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>speed</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">A number representing the speed of an agent in meters per second.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agents.js.html">agents.js</a>, <a href="agents.js.html#line484">line 484</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".increaseSpeed"><span class="type-signature">(static) </span>increaseSpeed<span class="signature">(magnitude)</span><span class="type-signature"></span></h4>
<div class="description">
Increase the speed the agent moves along its currently scheduled path by a constant.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>magnitude</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">The number to add to the agent's scheduled speed.
All scheduled speeds must be >= .1</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agents.js.html">agents.js</a>, <a href="agents.js.html#line465">line 465</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".moveIt"><span class="type-signature">(static) </span>moveIt<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Make the agent proceed along its trip.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agents.js.html">agents.js</a>, <a href="agents.js.html#line635">line 635</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".multiplySpeed"><span class="type-signature">(static) </span>multiplySpeed<span class="signature">(multiplier)</span><span class="type-signature"></span></h4>
<div class="description">
Multiply the speed the agent moves along its currently scheduled path by a constant.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>multiplier</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">The number to multiply the agent's scheduled speed by.
All scheduled speeds must be >= .1.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agents.js.html">agents.js</a>, <a href="agents.js.html#line445">line 445</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".pauseTrip"><span class="type-signature">(static) </span>pauseTrip<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Stop the agent where it is along its trip.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agents.js.html">agents.js</a>, <a href="agents.js.html#line103">line 103</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".resetTrip"><span class="type-signature">(static) </span>resetTrip<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Reset all the properties of its trip, but don't change whether it's allowed to be traveling or not.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agents.js.html">agents.js</a>, <a href="agents.js.html#line77">line 77</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".resumeTrip"><span class="type-signature">(static) </span>resumeTrip<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Have the agent continue from where it was left off along its trip.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agents.js.html">agents.js</a>, <a href="agents.js.html#line112">line 112</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".setSpeed"><span class="type-signature">(static) </span>setSpeed<span class="signature">(speed)</span><span class="type-signature"></span></h4>
<div class="description">
Set a new, constant speed for the agent to move along its currently scheduled path.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>speed</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">The speed (in meters per tick) that the agent should move. Must be >= .1.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agents.js.html">agents.js</a>, <a href="agents.js.html#line424">line 424</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".setTravelToPlace"><span class="type-signature">(static) </span>setTravelToPlace<span class="signature">(goal_lat_lng, goal_place, speed<span class="signature-attributes">opt</span>, move_directly<span class="signature-attributes">opt</span>, replace_trip<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
Schedule the agent to travel directly from any point (e.g. of a street or unit) to a point (e.g. of another street or unit).
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>goal_lat_lng</code></td>
<td class="type">
<span class="param-type"><a href="global.html#LatLng">LatLng</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The point within the place to which the agent is to travel.</td>
</tr>
<tr>
<td class="name"><code>goal_place</code></td>
<td class="type">
<span class="param-type"><a href="global.html#Place">Place</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">The place to which the agent will travel.</td>
</tr>
<tr>
<td class="name"><code>speed</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
1
</td>
<td class="description last">The speed in meters per tick that the agent should try to travel. Must be >= .1.</td>
</tr>
<tr>
<td class="name"><code>move_directly</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">Whether to ignore the streets & roads and move directly to the goal.</td>
</tr>
<tr>
<td class="name"><code>replace_trip</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">Whether to empty the currently scheduled path and replace it with this new trip; false by default (the new trip is
simply appended to the current scheduled path).</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agents.js.html">agents.js</a>, <a href="agents.js.html#line189">line 189</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".startTrip"><span class="type-signature">(static) </span>startTrip<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Set the agent up to start traveling along the path specified in the agent's trip..
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="agents.js.html">agents.js</a>, <a href="agents.js.html#line92">line 92</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Agent.html">Agent</a></li><li><a href="Agentmap.html">Agentmap</a></li></ul><h3>Tutorials</h3><ul><li><a href="tutorial-quickstart.html">quickstart</a></li></ul><h3>Global</h3><ul><li><a href="global.html#agent">agent</a></li><li><a href="global.html#agentmap">agentmap</a></li><li><a href="global.html#getIntersections">getIntersections</a></li><li><a href="global.html#isPointCoordinates">isPointCoordinates</a></li><li><a href="global.html#pointToCoordinateArray">pointToCoordinateArray</a></li><li><a href="global.html#reversedCoordinates">reversedCoordinates</a></li><li><a href="global.html#setupStreetFeatures">setupStreetFeatures</a></li><li><a href="global.html#setupUnitFeatures">setupUnitFeatures</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Aug 31 2018 17:05:58 GMT-0400 (Eastern Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>