Class MapRepresentation

java.lang.Object
eu.su.mas.dedale.mas.agent.knowledge.MapRepresentation
All Implemented Interfaces:
java.io.Serializable

public class MapRepresentation
extends java.lang.Object
implements java.io.Serializable
This simple topology representation only deals with the graph, not its content.

The knowledge representation is not well written (at all), it is just given as a minimal example.

The viewer methods are not independent of the data structure, and the dijkstra is recomputed every-time.

Author:
hc
See Also:
Serialized Form
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  MapRepresentation.MapAttribute
    A node is open, closed, or agent
  • Constructor Summary

    Constructors 
    Constructor Description
    MapRepresentation()  
  • Method Summary

    Modifier and Type Method Description
    void addEdge​(java.lang.String idNode1, java.lang.String idNode2)
    Add an undirect edge between idNode1 and idNode2 if not already existing.
    boolean addNewNode​(java.lang.String id)
    Add a node to the graph.
    void addNode​(java.lang.String id, MapRepresentation.MapAttribute mapAttribute)
    Add or replace a node and its attribute
    java.util.List<java.lang.String> getOpenNodes()  
    dataStructures.serializableGraph.SerializableSimpleGraph<java.lang.String,​MapRepresentation.MapAttribute> getSerializableGraph()  
    java.util.List<java.lang.String> getShortestPath​(java.lang.String idFrom, java.lang.String idTo)
    Compute the shortest Path from idFrom to IdTo.
    java.util.List<java.lang.String> getShortestPathToClosestOpenNode​(java.lang.String myPosition)  
    boolean hasOpenNode()  
    void loadSavedData()
    After migration we load the serialized data and recreate the non serializable components (Gui,..)
    void mergeMap​(dataStructures.serializableGraph.SerializableSimpleGraph<java.lang.String,​MapRepresentation.MapAttribute> sgreceived)  
    void prepareMigration()
    Before the migration we kill all non serializable components and store their data in a serializable form

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • addNode

      public void addNode​(java.lang.String id, MapRepresentation.MapAttribute mapAttribute)
      Add or replace a node and its attribute
      Parameters:
      id - unique identifier of the node
      mapAttribute - attribute to add
    • addNewNode

      public boolean addNewNode​(java.lang.String id)
      Add a node to the graph. Do nothing if the node already exists. If new, it is labeled as open (non-visited)
      Parameters:
      id - id of the node
      Returns:
      true if added
    • addEdge

      public void addEdge​(java.lang.String idNode1, java.lang.String idNode2)
      Add an undirect edge between idNode1 and idNode2 if not already existing.
      Parameters:
      idNode1 - unique identifier of node 1
      idNode2 - unique identifier of node 2
    • getShortestPath

      public java.util.List<java.lang.String> getShortestPath​(java.lang.String idFrom, java.lang.String idTo)
      Compute the shortest Path from idFrom to IdTo. The computation is currently not very efficient
      Parameters:
      idFrom - id of the origin node
      idTo - id of the destination node
      Returns:
      the list of nodes to follow, null if the targeted node is not currently reachable
    • getShortestPathToClosestOpenNode

      public java.util.List<java.lang.String> getShortestPathToClosestOpenNode​(java.lang.String myPosition)
    • getOpenNodes

      public java.util.List<java.lang.String> getOpenNodes()
    • prepareMigration

      public void prepareMigration()
      Before the migration we kill all non serializable components and store their data in a serializable form
    • getSerializableGraph

      public dataStructures.serializableGraph.SerializableSimpleGraph<java.lang.String,​MapRepresentation.MapAttribute> getSerializableGraph()
    • loadSavedData

      public void loadSavedData()
      After migration we load the serialized data and recreate the non serializable components (Gui,..)
    • mergeMap

      public void mergeMap​(dataStructures.serializableGraph.SerializableSimpleGraph<java.lang.String,​MapRepresentation.MapAttribute> sgreceived)
    • hasOpenNode

      public boolean hasOpenNode()
      Returns:
      true if there exist at least one openNode on the graph