220 likes | 331 Views
Intelligent Architectures for Electronic Commerce. Prolog/JADE Tutorial. Overview. JADE CIAO Prolog Prolog and JADE. 1. JADE. Standard platform for agent communication Provides useful services: Visualisation of messages; Sending/receiving messages manually; GUI, etc.
E N D
Intelligent Architectures for Electronic Commerce Prolog/JADE Tutorial
Overview • JADE • CIAO Prolog • Prolog and JADE Intelligent Architectures for Electronic Commerce 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 Timothy J Norman and Wamberto Vasconcelos
1. JADE Container Agent Intelligent Architectures for Electronic Commerce 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 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 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 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 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 Timothy J Norman and Wamberto Vasconcelos
3.3 StarterAgent (2) • Started up manually using JADE’s service: Intelligent Architectures for Electronic Commerce 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 Timothy J Norman and Wamberto Vasconcelos
3.3 StarterAgent (4) Look!! Intelligent Architectures for Electronic Commerce Timothy J Norman and Wamberto Vasconcelos
3.3 StarterAgent (5) • How to get hold of StarterAgent: • Copy folder JADE-InterAgent into your jade folder • 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 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 Timothy J Norman and Wamberto Vasconcelos
3.4 The Prolog Part (3) • Prolog connects to port 1450 • Sends a request to the StarterAgent in the form request(Me,[StarterAg],register(Me))) • Receives a message with the port of the Proxy agent inform(StarterAg,[Me],registered(Me,NewPort))) • Connects to the NewPort port • And that’s all! Intelligent Architectures for Electronic Commerce Timothy J Norman and Wamberto Vasconcelos
3.4 The Prolog Part (5) Intelligent Architectures for Electronic Commerce Timothy J Norman and Wamberto Vasconcelos
3.4 The Prolog Part (6) Look!! Intelligent Architectures for Electronic Commerce 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 Timothy J Norman and Wamberto Vasconcelos
Intelligent Architectures for Electronic Commerce Timothy J Norman and Wamberto Vasconcelos
3.4 The Prolog Part (10) Intelligent Architectures for Electronic Commerce 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 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 Timothy J Norman and Wamberto Vasconcelos