Docstoc

Intelligent Architectures for Electronic Commerce Home

Document Sample
Intelligent Architectures for Electronic Commerce Home Powered By Docstoc
					       Intelligent
     Architectures
     for Electronic
      Commerce
Prolog/JADE Tutorial
                             Overview
1. JADE
2. CIAO Prolog
3. Prolog and JADE




         Intelligent Architectures for Electronic Commerce   2
           Timothy J Norman and Wamberto Vasconcelos
                                  1. JADE
• Standard platform for agent communication
• Provides useful services:
  – Visualisation of messages;
  – Sending/receiving messages manually;
  – GUI, etc.
• We need to use some such platform to run our
  agents, otherwise how would we test them?




            Intelligent Architectures for Electronic Commerce   3
              Timothy J Norman and Wamberto Vasconcelos
                                  1. JADE



Container

 Agent




            Intelligent Architectures for Electronic Commerce   4
              Timothy J Norman and Wamberto Vasconcelos
                         2. CIAO Prolog
• Efficient, free implementation of Prolog
• Higher-level than Java, C++, Delphi:
  – Allows symbolic reasoning
  – Terse syntax
• Common complaints:
  –   Non-intuitive and outlandish
  –   Difficult to understand
  –   Inefficient
  –   Odd choice for a programming language (if it is
      not Java it is simply not cool…)
            Intelligent Architectures for Electronic Commerce   5
              Timothy J Norman and Wamberto Vasconcelos
                 3. Prolog and JADE
• Means to “agentify” Prolog programs
• Prolog programs may then:
  – Send messages to other agents
  – Receive messages from other agents
• Prolog can then “talk” to any other languages
  – Current examples are all Prolog agents
• Our Prolog agents were isolated from the rest
  of the world!



         Intelligent Architectures for Electronic Commerce   6
           Timothy J Norman and Wamberto Vasconcelos
            3.1 Connecting Prolog/Jade
• JADE is for Java, not Prolog….
• One solution:
  – Prolog process has a “proxy” Java agent in JADE
  – Prolog process sends and receives messages via
    proxy agent
  – Diagrammatically
      Ag1      Ag2       Ag3      Ag4                    Prolog


                 JADE
            Intelligent Architectures for Electronic Commerce     7
              Timothy J Norman and Wamberto Vasconcelos
                      3.2 Proxy Agent
• Proxy agent is a simple Java program
• Reads from/writes to a socket open on a port
• Prolog program sends a message via proxy:
  – Writes term onto socket
  – Term must be in a specific format (more later…)
• Proxy agent reads in Prolog term (message to
  be sent) and translates it onto FIPA-ACL
• Creation and registration of proxy agents is
  performed via StarterAgent

          Intelligent Architectures for Electronic Commerce   8
            Timothy J Norman and Wamberto Vasconcelos
                 3.3 StarterAgent (1)
• Each Prolog process needs a proxy agent
• Prolog cannot start an agent in JADE
• Solution: an agent inside JADE who is
  responsible for starting up proxy agents!
• This is what StarterAgent is




          Intelligent Architectures for Electronic Commerce   9
            Timothy J Norman and Wamberto Vasconcelos
                3.3 StarterAgent (2)
• Started up manually using JADE’s service:




         Intelligent Architectures for Electronic Commerce   10
           Timothy J Norman and Wamberto Vasconcelos
                   3.3 StarterAgent (3)
• Then you should type on the pop-up window:
Name of the Starter Agent                            JAVA Class




    Parameters: Port Number and “verbose” option
            Intelligent Architectures for Electronic Commerce     11
              Timothy J Norman and Wamberto Vasconcelos
                3.3 StarterAgent (4)




Look!!




         Intelligent Architectures for Electronic Commerce   12
           Timothy J Norman and Wamberto Vasconcelos
                  3.3 StarterAgent (5)
• How to get hold of StarterAgent:
   1.Copy folder JADE-InterAgent into your jade folder
   2.Add
         c:\jade\JADE-InterAgent
     to your CLASSPATH
• You can now start up your StarterAgent as
  before
• Choose a port which is not being used to use
  as a parameter when starting the agent

           Intelligent Architectures for Electronic Commerce   13
             Timothy J Norman and Wamberto Vasconcelos
              3.4 The Prolog Part (1)
• Download file agent.pl
• Load it in CIAO Prolog
• Type in
?- connect_to_jade(1450,ag1,starterAgentCool).




           Intelligent Architectures for Electronic Commerce   14
             Timothy J Norman and Wamberto Vasconcelos
               3.4 The Prolog Part (3)
1. Prolog connects to port 1450
2. Sends a request to the StarterAgent in the form
  request(Me,[StarterAg],register(Me)))

3. Receives a message with the port of the Proxy
   agent
inform(StarterAg,[Me],registered(Me,NewPort)))

3. Connects to the NewPort port
4. And that’s all!
            Intelligent Architectures for Electronic Commerce   15
              Timothy J Norman and Wamberto Vasconcelos
   3.4 The Prolog Part (5)




Intelligent Architectures for Electronic Commerce   16
  Timothy J Norman and Wamberto Vasconcelos
            3.4 The Prolog Part (6)



Look!!




         Intelligent Architectures for Electronic Commerce   17
           Timothy J Norman and Wamberto Vasconcelos
              3.4 The Prolog Part (7)
• After process connects to the port, it can send
  and receive messages via its proxy agent in
  JADE.
• You can, for instance, send a message using
  the JADE service, in order to test your Prolog
  agent.




           Intelligent Architectures for Electronic Commerce   18
             Timothy J Norman and Wamberto Vasconcelos
Intelligent Architectures for Electronic Commerce   19
  Timothy J Norman and Wamberto Vasconcelos
  3.4 The Prolog Part (10)




Intelligent Architectures for Electronic Commerce   20
  Timothy J Norman and Wamberto Vasconcelos
              3.4 The Prolog Part (11)
• There are predicates defined to send and
  receive messages.
• Messages must be in the format
 perf-name(id-sender,ListOfRecs, contents)
  where ListOfRecs is a list of recipients’s id
• Please read the documentation in the file
  agent.pl


            Intelligent Architectures for Electronic Commerce   21
              Timothy J Norman and Wamberto Vasconcelos
                            4. Final Words
• No standard connection:
   – We’re free to create and propose solutions
   – How would you connect Prolog to JADE?
• This is state-of-the-practice stuff
   – There might be problems…
   – Let me know and I will try to help!
• Enjoy it!



              Intelligent Architectures for Electronic Commerce   22
                Timothy J Norman and Wamberto Vasconcelos

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:54
posted:11/1/2012
language:English
pages:22