Presentation on theme: "G54DIA TUTORIAL – Multi Agent Solutions Julian Zappala."— Presentation transcript:
G54DIA TUTORIAL – Multi Agent Solutions Julian Zappala
Tutorial Overview This tutorial considers multi agent solutions: Design/Conceptual Challenges Teamwork Concurrency/Fallibility of actions Technical Considerations Serial (iterative) implementation Parallel (multi-threaded) implementation Example Upgrading the DemoSimulator Upgrading the TankerViewer
Thinking about Teamwork #1 Size: How many agents? When does cooperation become competition? May require experimentation/calculation Composition: What kind of agents? Homogeneous: All agents are the same Heterogeneous: Agents have different abilities What types of roles might agents take? Communication #1: How is information exchanged? Shared memory? Messaging: Pheromones? Point to point? Broadcast? Face to face?
Thinking about Teamwork #2 Communication #2: What information is shared? About the environment? About tasks? About this agent? Team structure: Who's in charge? Anarchy: No control structure Despotic: A “manager” agent Democratic: Agents share choices Cooperation: How are tasks completed? One agent per task? More than one agent per task? Implications for exploration and exploitation? Other Ideas?
Concurrency/Fallibility of Actions Can more than one agent be in the same cell concurrently? be at the same well/station/fuel pump? If "No" then How are these constraints enforced fairly? What happens if an action fails? Resource contention and starvation: Which agent gets to refuel? Does agent X ever get to refuel? If "Yes" then what are the consequences? e.g. “double deliveries” Other Ideas?
Technical Considerations Serial Implementation Iterate over a collection of agents agents perform actions in series perhaps more straight forward arguably less "realistic" Parallel Implementation agents perform actions in parallel deadlock - mutually waiting processes race conditions - i.e operations on shared resources synchronisation – atomic processing library code may not be thread-safe Choice - there's nothing which can be done in one way which can't be done the other way!
A Simple Example Extends the demo package with multiple tankers This example illustrates the iterative (serial) approach one way to upgrade the user interface Is indicative of the classes you may need to adapt one of many ways in which this could be achieved Gives some hints and code fragments but is not a full solution assumes a “Fleet” class: a collection of tankers
Upgrading DemoSimulator Calling senseAndAct for each Tanker in the Fleet
Graphical User Interface Upgrading the GUI is optional but it may be useful for debugging etc... Possible upgrades include: Selecting which agent to view Showing other agents in the view Other ideas? You'll need some familiarity with Java Swing libraries, e.g: http://download.oracle.com/javase/tutorial/uiswing/index.html http://download.oracle.com/javase/tutorial/uiswing/index.html http://download.oracle.com/javase/6/docs/api/javax/swing/package- summary.html http://download.oracle.com/javase/6/docs/api/javax/swing/package- summary.html
Understanding TankerViewer #1 TankerViewer itself extends JFrame The main view is a JLayeredPane lp Child of Container c (ContentPane from JFrame) One layer for the environment (Layer 0) One layer for the tanker (Layer 1) The environment is drawn using: JPanel p (child of lp) JLabel cells (children of p)
Understanding TankerViewer #2 The tanker is drawn using: JLabel tankerlabel (child of lp) Never redrawn The information panel JPanel infop (child of c) Has many JLabel children: water/fuel/location/score etc:
TankerViewer: Selecting a tanker (JComoBox) TankerViewer will need to implement the ActionListener Interface
TankerViewer: Show Other Tankers #1 Here we create a transparent grid of hidden tanker icons
TankerViewer: Show Other Tankers #2 Here we update the tick method so that it will show/hide tanker icons as appropriate