Class LongAgentsEnvironment<N extends LongAgentGraphNode,A extends LongAgentGraphArc,K extends LongAgentWeightKey>
java.lang.Object
com.amalgamasimulation.graphagent.GraphEnvironment<N,A,LongAgentWeightKey>
com.amalgamasimulation.graphagent.LongAgentsEnvironment<N,A,K>
- Type Parameters:
N- type of graph node valuesA- type of graph arc valuesK- type of keys that are used when determining agent-dependent weight of graph arcs and nodes
- Direct Known Subclasses:
TrainsEnvironment
public class LongAgentsEnvironment<N extends LongAgentGraphNode,A extends LongAgentGraphArc,K extends LongAgentWeightKey>
extends GraphEnvironment<N,A,LongAgentWeightKey>
Environment for long agents (see
LongAgent class). Supports
collisions tracking and spatial constraints for long agents. Long agents can
live only in this type of environments.- Author:
- Andrey Malykhanov
-
Field Summary
FieldsModifier and TypeFieldDescriptionFields inherited from class com.amalgamasimulation.graphagent.GraphEnvironment
agents, barrierArcsCache, barrierArcsEnabled, cachedMinTreesWithAgents, cachedMinTreesWithoutAgents, cachedShortestPathsWeights, cachedShortestPathsWithAgents, cachedShortestPathsWithoutAgents, callbackPositionsEnabled, collisionsTrackingEnabled, graph, minTreeCacheEnabled, pathsCacheEnabled, pathsCalculated, pathsCalculatedFromDijkstra, pathsCalculatedFromTree, pathsGotFromCache -
Constructor Summary
ConstructorsConstructorDescriptionLongAgentsEnvironment(boolean collisionsTrackingEnabled, boolean callbackPositionsEnabled, boolean pathsCacheEnabled, boolean minTreeCacheEnabled, boolean barrierArcsEnabled) -
Method Summary
Modifier and TypeMethodDescriptionbooleangetAgentsOverlay(GeometricGraphPath<N, A> expectedOverlayPath) doublegetArcWeight(A arcValue, LongAgentWeightKey weightKey) Returns the weight of the specified arc used when calculating the shortest paths for agents' movements.doublegetNodeWeight(N nodeValue, LongAgentWeightKey weightKey) Returns the weight of the specified node used when calculating the shortest path for agents' movements.getShortestPath(GeometricGraphPosition<N, A> sourcePosition, GeometricGraphPosition<N, A> destPosition, GraphAgent<N, A> agent) Returns the shortest path from the specified source position to the specified destination position for the specified agent, ornullif no such path exists.voidvoidbooleanweightKey(GraphAgent<N, A> agent) Returns the key that is used as additional parameter when calculating weights of nodes and arcs for the purposes of shortest paths calculation for the specified agent.Methods inherited from class com.amalgamasimulation.graphagent.GraphEnvironment
addAgentInternal, addArc, addArc, addNode, calculatePathWeight, clearCache, getAgents, getArcs, getArcValues, getClosestNodes, getClosestNodes, getClosestNodes, getClosestNodes, getClosestNodes, getClosestNodes, getClosestNodes, getClosestNodes, getClosestNodes, getCurrentCacheFactor, getCurrentDijsktraFactor, getDestsAndWeights, getGraph, getGraphArc, getGraphNode, getNodes, getNodeValues, getPartialArcWeight, getSameOrReverseArcPath, getShortestPath, getShortestPath, getShortestPath, getShortestPath, getShortestPath, getShortestPath, getShortestPath, getShortestPathBetweenNodesInternal, getShortestPathToClosest, getSourcesAndWeights, isCallbackPositionsEnabled, isCollisionsTrackingEnabled, onArcWeightChanged, pathsCacheEnabled, removeAgentInternal, tryGetZeroLengthPathBetweenAdjacentPositions
-
Field Details
-
arcsToSeizingAgents
protected Map<Graph<N extends LongAgentGraphNode,A extends LongAgentGraphArc>.Arc, arcsToSeizingAgentsLongAgent<N extends LongAgentGraphNode, A extends LongAgentGraphArc>> -
arcsToWaitingAgents
protected Map<Graph<N extends LongAgentGraphNode,A extends LongAgentGraphArc>.Arc, arcsToWaitingAgentsList<LongAgent<N extends LongAgentGraphNode, A extends LongAgentGraphArc>>>
-
-
Constructor Details
-
LongAgentsEnvironment
public LongAgentsEnvironment() -
LongAgentsEnvironment
public LongAgentsEnvironment(boolean collisionsTrackingEnabled, boolean callbackPositionsEnabled, boolean pathsCacheEnabled, boolean minTreeCacheEnabled, boolean barrierArcsEnabled)
-
-
Method Details
-
getArcWeight
Description copied from class:GraphEnvironmentReturns the weight of the specified arc used when calculating the shortest paths for agents' movements. Can be overridden in subclasses. The default implementation returns the length of the specified arc, i.e.:return arcValue.getLength();- Overrides:
getArcWeightin classGraphEnvironment<N extends LongAgentGraphNode,A extends LongAgentGraphArc, LongAgentWeightKey> - Parameters:
arcValue- specified arcweightKey- an additional parameter used to parameterize the calculation if necessary. For example, can be agent if the paths should be calculated differently for each agent- Returns:
- weight of this arc, must be non-negative
-
getNodeWeight
Description copied from class:GraphEnvironmentReturns the weight of the specified node used when calculating the shortest path for agents' movements. Can be overridden in subclasses. The default implementation returns 0, so by default nodes do not contribute to paths' weights.The default implementation is to return zero, i.e.:
return 0;- Overrides:
getNodeWeightin classGraphEnvironment<N extends LongAgentGraphNode,A extends LongAgentGraphArc, LongAgentWeightKey> - Parameters:
nodeValue- specified nodeweightKey- an additional parameter used to parameterize the calculation if necessary. For example, can be agent if the paths should be calculated differently for each agent- Returns:
- weight of this node, must be non-negative
-
weightKey
Description copied from class:GraphEnvironmentReturns the key that is used as additional parameter when calculating weights of nodes and arcs for the purposes of shortest paths calculation for the specified agent. Can be overridden in subclasses. Default implementation returnsnull, so all the agents have the same context while calculating their paths.An example of weight key can be some type of agent if paths need to be calculated differently for agent of different types
- Overrides:
weightKeyin classGraphEnvironment<N extends LongAgentGraphNode,A extends LongAgentGraphArc, LongAgentWeightKey> - Parameters:
agent- specified agent- Returns:
- weight key
-
barrierArcsCacheEnabled
public boolean barrierArcsCacheEnabled() -
onSeizedArcEntrance
-
onReleasedArcEntrance
-
tryEnterArc
-
getShortestPath
public AgentGraphPath<N,A> getShortestPath(GeometricGraphPosition<N, A> sourcePosition, GeometricGraphPosition<N, A> destPosition, GraphAgent<N, A> agent) Description copied from class:GraphEnvironmentReturns the shortest path from the specified source position to the specified destination position for the specified agent, ornullif no such path exists.Shortest path is determined using the weights provided in the methods:
The default implementation of these methods returns simple distance-based weights, however these methods can be overridden to customize the path finding logic.- Overrides:
getShortestPathin classGraphEnvironment<N extends LongAgentGraphNode,A extends LongAgentGraphArc, LongAgentWeightKey> - Parameters:
sourcePosition- the origin of path findingdestPosition- the destination of path findingagent- the agent for which the path is being searched- Returns:
- an instance of
AgentGraphPathrepresenting the shortest path, ornull
-
getAgentsOverlay
protected List<Pair<LongAgent<?,?>, getAgentsOverlayGeometricGraphPath<N, A>>> (GeometricGraphPath<N, A> expectedOverlayPath)
-