Thanks to visit codestin.com
Credit goes to github.com

Skip to content

hangouby/agents

 
 

Repository files navigation

Playing Around with Jade (http://jade.tilab.com/)
=================================================
This project is to illustrate and document the basic patterns of usage of Jade.

The initial setup is Windows specific. This is because I am trying to do this on a Saturday
and Jade installs and works better out of the box on my Windows laptop than my mbp.

Setting up Jade
---------------
Follow instructions on web page then create setenv.bat

Creating Jade agents
--------------------
Create a class
Put it in a jar file
Add jar file to classpath

Typical Usages
--------------
java jade.Boot -agents John:examples.peter.PeterAgent

Args are inside (). Claims to support space separated args but on ever reports 1 arg
Fails if no "". Condenses to single arg if there are ""
java  jade.Boot -agents "John:examples.peter.PeterAgent(arg1 arg2 arg3)"

BookTrading examples
--------------------
Each instance running on same computer needs to use a different port. Will try counting backwards
from defautl port 1099

C:\java\jade>java jade.Boot -agents "Big-Bad-John:examples.bookTrading.BookBuyerAgent(War-and-Peace)"
....
Hallo! Buyer-agent [email protected]:1099/JADE is ready.
Target book is War-and-Peace

java jade.Boot -agents "Gentleman-Jim:examples.bookTrading.BookSellerAgent(War-and-Peace)"


Second buyer

java jade.Boot -port 1098 -agents "Big-Bad-John:examples.bookTrading.BookBuyerAgent(War-and-Peace)"

Seller

java jade.Boot -port 1097 -agents "Gentleman-Jim:examples.bookTrading.BookSellerAgent(War-and-Peace)"

Running multiple agents
=======================
java jade.Boot -agents Buyer1:examples.bookTrading.BookBuyerAgent(xyz);Buyer2:examples.bookTrading.BookBuyerAgent(xyz);Buyer3:examples.bookTrading.BookBuyerAgent(xyz);Seller1:examples.bookTrading.BookSellerAgent;Seller2:examples.bookTrading.BookSellerAgent;Seller3:examples.bookTrading.BookSellerAgent

Found the following 3 seller agents:
[email protected]:1099/JADE
[email protected]:1099/JADE
[email protected]:1099/JADE
Found the following 3 seller agents:
[email protected]:1099/JADE
[email protected]:1099/JADE
[email protected]:1099/JADE
Found the following 3 seller agents:
[email protected]:1099/JADE
[email protected]:1099/JADE
[email protected]:1099/JADE
xyz sold to agent [email protected]:1099/JADE
xyz successfully purchased from agent [email protected]:1099/JADE
Price = 20
Attempt failed: xyz not available for sale
Buyer-agent [email protected]:1099/JADE terminating.
Attempt failed: xyz not available for sale
xyz inserted into catalogue. Price = 10
xyz inserted into catalogue. Price = 5
Trying to buy 'xyz'
Found the following 3 seller agents:
[email protected]:1099/JADE
[email protected]:1099/JADE
[email protected]:1099/JADE
Trying to buy 'xyz'
xyz sold to agent [email protected]:1099/JADE
Found the following 3 seller agents:
[email protected]:1099/JADE
[email protected]:1099/JADE
[email protected]:1099/JADE
xyz successfully purchased from agent [email protected]:1099/JADE
Price = 5
xyz sold to agent [email protected]:1099/JADE
Buyer-agent [email protected]:1099/JADE terminating.
xyz successfully purchased from agent [email protected]:1099/JADE
Price = 10
Buyer-agent [email protected]:1099/JADE terminating.





Yellow Pages??? Does not work!!
------------
java jade.Boot -port 1095 -jade_core_nodeMonitoring_UDPNodeMonitoringService_port 5555 -agents "Gentleman-Jim:examples.bookTrading.BookSellerAgent(War-and-Peace)"

Working Code!!
--------------
run_test4.bat
c:\java\jade>java -cp \java\jade\lib\jade.jar;\java\jade\lib\jadeTools.jar;\java\jade\lib\iiop.jar;\java\jade\lib\commons-codec\commons
ar  jade.Boot -agents Buyer1:examples.ordering.BuyerAgent(order2.csv);Seller1:examples.ordering.SupplierAgent(catalog1.csv)
...
Reading catalog from 'catalog1.csv'
Buyer agent [email protected]:1099/JADE is starting.
Reading order from 'order2.csv'
Read catalog1.csv 5 lines ------------------------
Read order2.csv 5 lines ------------------------
Order string is 'bricks,100,0.0;cement,1,0.0;wood,10,0.0;sand,2,0.0;nails,500,0.0;'
Catalog has 5 rows worth $525.0
Starting Supplier Agent [email protected]:1099/JADE
Trying to buy 'bricks,100,0.0;cement,1,0.0;wood,10,0.0;sand,2,0.0;nails,500,0.0;'
Found the following 1 supplier agents:
[email protected]:1099/JADE
'bricks,100,0.0;cement,1,0.0;wood,10,0.0;sand,2,0.0;nails,500,0.0;' sold to agent [email protected]:1099/JADE
bricks,100,0.0;cement,1,0.0;wood,10,0.0;sand,2,0.0;nails,500,0.0; successfully purchased from agent [email protected]:1099/JADE
Price = 55.0
Buyer-agent [email protected]:1099/JADE terminating.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published