Home
USER`S MANUAL - GTI-IA
Contents
1. Ed ile E Ok Let s go children CHAPTER 4 Virtual Organizations 4 1 Overview of THOMAS framework 101 4 2 Programming agents which use THOMAS 109 4 3 Programming Agents that Offer Services 115 4 4 Programming Agents that Request Services 118 4 5 Running THOMAS Example 123 4 6 Programming agents which use organizational MESSAGING ooooooooo morro roo 126 As it has been pointed out in the introduction Magentix2 platform not only has as aims to provide a guaranteed communication mechanism to the programmer but also to provide a complete support for virtual organizations and SOA like services THOMAS Methods Tech niques and Tools for Open Multi Agent Systems framework has been integrated with Ma gentx2 with this purpose 4 1 Overview of THOMAS framework The THOMAS framework tries to communicate agents and SOA like services in a transparent but independent way Agents can offer and invoke services in a transparent way to other agents or entities as well as external entities can interact with our agents through the use of the offered services Different types of virtual organizations are supported by the THOMAS framework Each or ganization can contain others organizations Furthermore diverse
2. content tServiceName tServiceDescription length tServicedescription ESid ESid can be any UNSUBSCRIBE The tracing entity cancelled the subscription to a tracing service t ServiceName coming from the ES entity ESid which can be any if the removed subscription referred to trace events coming from any ES entity which provided it tService UNSUBSCRIBE 2 originEntity Trace Manager entity to which the tracing service request was made content tServiceName ESid ESid can be any UNAVAILABLE TS The specified tracing service ServiceName is no longer available This can be the conse cuence of the origin entity which provided the tracing service terminating its own execution or unpublishing the tracing service It also can be a consecuence of changes in the autho rization graph of the tracing service Receiving this trace event implies unsubscription from the tracing service but no UNSUBSCRIBE trace event is expected tService UNAVAILABLE_TS 3 originEntity system host content tServiceName ESid ESid can be any 3 8 4 2 Agent s lifecycle domain independent tracing services These domain independent tracing services provide tracing information related to agents en tering or leaving the system These tracing services are requestable and thus it is necessary
3. ee 53 Argumentation Protocol 2 o oo ee 63 Data flow for the argumentation process of the helpdesk application 73 First section of the securityUser properties file 77 Second section of the securityUser properties file 77 Third section of the securityUser properties file 78 Fourth section of the securityUser properties file 78 Result of the Keytool command o o o 78 An example of the Settings xml file o o 79 Handled Services demanded and implementations of offered services supported 108 Interaction between user agent and OMS agent through the OMSProxy 110 Interaction between user agent and SF agent through the SFProxy 112 Agent interaction protocol to acquire a role o o 116 Agent interaction protocol to register a service o a 117 Agent interaction protocol to register new providers 117 Agent interaction protocol to acquire role o o o a 118 Agent interaction protocol to search Service o oo o 119 Agent interaction protocol to request a service 04 123 Thomas Example diagram e 125 Organizational messaging Example diagram 127 V 4 12 5 1 6 1 6 2 6 3 6 4 6 5 6 6 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 Agent interaction protocol to acquire
4. 162 VI List of Tables 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 ArgCAgent java methods to manage positions and arguments Methods to compute the distance and similarity between cases Argumentation example packages and classes o o Main ArgCAgent java methods o o e Argumentative agents core packages and classes Main DomainCBR java methods o e e Main ArgCBR java methods o e e Main CBR persistence methods o o e e Methods to implement in the Argumentation Protocol TraceEvent class constructor parameters o Trace Manager error codes o a Tracing service publication and unpublication methods Tracing service subscription and unsubscription methods Tracing services and tracing entities listing methods System related domain independent tracing services Agent s lifecycle related domain independent tracing services Agent s messaging related domain independent tracing services Tracing service publication related domain independent tracing services Agent behavior depending Of its position 000 How visibility and accessibility attributes affect rol
5. lt input Y gt valueY lt inputY gt lt inputs gt In the following example the requester agent tries to make a request of the found service to the agent or organization providers if there are providers list lines 28 51 If there are not agent or organization providers providers list is empty then it tries to obtain the Web Services groundings WSDL documents that provide the service providersGrounding WSDL list lines 52 60 In this case the requester agent has to execute the service by itself using the ServiceTools class provided by THOMAS Requesting the execution of the Addition service get the first service found because it is the most suitable String serviceOWLS sfProxy getService foundServices get 0 get 0 f Oracle oracle new Oracle serviceOWLS get service inputs ArrayList lt String gt servicelnputs oracle getOwlsProfileInputs put the service inputs values HashMap lt String String gt agentInputs new HashMap lt String String gt for String input servicelnputs if input equalsIgnoreCase x agentinputs put Gnu Sin else if input equalsIgnoreCase y agentInputs put input 4 agentInputs put input 0 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 33 54 122 4 4 Programming Age
6. E P talk cProcessorTemplate addTransition BEGIN PROPOS talk cProcessorTemplate registerState new WaitState WAIT 1000 E addTransition PROPOSE WAIT talk cProcessorTemplat ReceiveState RECEIVE new ReceiveState RECEIVE class RECEIVE_Method implements ReceiveStateMethod public String run CProcessor myProcessor ACLMessage messageReceived return FINAL RECEIVE setAcceptFilter null null gt accept any message RECEIVE setMethod new RECEIVE_Method RECEIVE talk cProcessorTemplate registerStat talk cProcessorTemplate addTransition WAIT RECEIVE 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 3 Programming Agents 41 FinalState FINAL new FinalState FINAL class FINAL Method implements FinalStateMethod public void run CProcessor myProcessor ACLMessage responseMessage messageToSend copyFromAsTemplate myProcessor getLastReceivedMessage myProcessor ShutdownAgent FINAL setMethod new FINAL Method talk cProcessorTemplate registerState FINAL talk cProcessorTemplate addTransition RECEIVE FINAL talk cProcessorTemplate addTransition PROPOSE
7. Logger logger Logger getLogger Run class The file logging xml is used to specify what level of log messages are written to the log files for each component Moreover Log4j allows logging requests to print to multiple destinations called appenders Two appenders predefined for Magentix2 are showed in 3 1 and 3 2 figures Specifically the appender 1 figure 3 1 indicates a file as the standard output The appender 2 figure 3 2 indicates the console as the standard output Please to learn more about appenders refer to http logging apache org log43 1 2 index html Ihttp akarta apache org This file is located in directory bin configuration of the Magentix2 installation 20 3 1 Basic classes for building agents BaseAgent and SimpleAgent lt appender name Fil class org apache log4j FileAppender gt lt param name File value logs Magentix2 log gt lt layout class org apache log4j PatternLayout gt lt param name ConversionPattern value t 5p c 2 Sm n gt lt layout gt lt appender gt Figure 3 1 Appender 1 lt appender name Console class org apache log4j ConsoleAppender gt lt layout class org apache log4j PatternLayout gt lt param name ConversionPattern value d 5p t C 2 SF SL SmSn gt lt layout gt lt appender gt Figure 3 2 Appender 2 3 1 4 Connecting to the Qpid Broker A connection to the Qpid b
8. 65 66 67 68 69 70 71 94 3 8 Tracing Service msg setContent GO TO THE PARK msg setReceiver new AgentID Timmy send msg msg setReceiver new AgentID Bobby send msg while Bobby_agree Timmy_agree Lio Thread sleep 1000 catch InterruptedException e e printStackTrace eye Al Thread sleep 1000 catch InterruptedException e e printStackTrace System out println Daddy this getName Ok Let ASO Cc haslkehcen aE public void onTraceEvent TraceEvent tEvent DateFormat formatter new SimpleDateFormat HH mm ss SSS r Calendar calendar Calendar getiInstance calendar setTimeInMillis tEvent getTimestamp ACLMessage msg if tEvent getTracingService contentEquals NEW_AGENT TraceInteract requestTracingService this MESSAGE_SENT_DETAIL new AgentID tEvent getContent DE else if tEvent getTracingService contentEquals MESSAGE_SENT_DETAIL msg ACLMessage fromString tEvent getContent 12 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 3 Programming Agents 95 SVSeCM out Oran tl AS AOS EN AMS formatter format calendar getTime msg getsende nico str In gi0 ES iS qe getPerform
9. Thus an agent can use the following dialogue tactics depending on the weight that it assigns to the elements of the support factor when it selects the best argument to bring up in each step of the argumentation dialogue 56 3 6 Argumentative Agents e Persuasive Tactic the agent selects such arguments which similar argument cases were more persuasive in the past assigns more weight to the persuasiveness degree e Maximise Support Tactic the agent selects such arguments that have higher probability of being accepted at the end of the dialogue assigns more weight to the support degree e Minimise Risk Strategy the agent selects such arguments that have a lower probability of being attacked assigns more weight to the risk degree e Minimise Attack Tactic the agent selects such arguments that have received a lower number of attacks in the past assigns more weight to the attack degree e Maximise Efficiency Tactic the agent selects such arguments that lead to shorter argu mentation dialogues assigns more weight to the efficiency degree e Explanatory Tactic the agent selects such arguments that cover a bigger number of cases or argumentation schemes That is such arguments that are similar to argument cases that have more justification elements assigns more weight to the explanatory power As pointed out before the dialogue strategy that an agent follows determines the locution and content that it puts forwa
10. file mms csr The PASSWORD _MMSKEYSTORE is required Signing the certificate request using CA certificate certutil C d CA_db c MagentixCA a i mms csr o mms crt The PASSWORD_CA is required Importing the certificate into the key store 6 Platform administration 157 keytool import trustcacerts alias MMS file mms crt keystore MMSkeystore jks The PASSWORD_MMSKEYSTORE is required 6 6 5 Exporting the MMS certificate with the public Key This command is used to export the MMS public key into a file It will be sent to users and they will must be imported into his trustores Thereby the security context mutual authentication with the MMS and users will be created keytool export alias MMS file mms crt keystore MMSkeystore jks The PASSWORD _MMSKEYSTORE is required 6 6 6 Importing new trusted third party certificate authority The following command is used to import a new trusted third party certificate authority Thereby all users with certificate issues by these trusted third party can be communicate in a security context mutual authentication with the MMS keytool import trustcacerts alias FNMT A file FNMTClase2CA cer keystore MMSkeystore jks lt alias gt user name identifying lt file gt certificate with user public key The PASSWORD MMSKEYSTORE is required 6 6 7 Tracing Service In the platform only a user authorized can be launch
11. method without parameters An example of the Settings xml file could be lt I Preoyeremes ejpulel lorolkers gt lt entry key host gt localhost lt entry gt lt entry key port gt 5672 lt entry gt lt entry key vhost gt test lt entry gt lt entry key user gt guest lt entry gt lt entry key pass gt guest lt entry gt lt entry key ssl gt false lt entry gt e Specifying all the parameters when calling connect Example AgentsConnection connect localhost 5672 test guest guest false e Specifying only the lt qpidhost gt parameter leaving the rest as default parameters In 99 99 9999 the current example case the default values will be 5672 test guest guest false respectively Example AgentsConnection connect host domain gt This file is located in the directory bin configuration of the Magentix2 installation 22 3 1 Basic classes for building agents BaseAgent and SimpleAgent 3 1 5 Running Agents Once agents are implemented they can be instantiated and launched Please note that the platform do not allow different agents with the same name In order to instantiate an agent an agent ID must be also created as follows e AgentID String Identifier where Identifier is the agent name Examples of creating a new instantiation SenderAgent agentl new SenderAgent new AgentID sender ConsumerAgent a
12. 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 Programming Agents 3 8 6 Daddy class package TraceDaddy import import import import import import import import public class Daddy private boolean private boolean private boolean pub 93 Java text DateFormat Java text SimpleDateFormat Java util Calendar es es SS SS SS Upa s teng pia upv QSic ge i tiar SUPALI Suara lee clan SUP WVIAC Sata UN Olano ge Ea core ACLMessage core AgentID core BaseAgent core TraceEvent tracer brace bntceracty extends BaseAgent finish false super aid Bobby_agree false Timmy_agree false lic Daddy AgentID aid throws Exception TracelInteract requestTracingService this NEW_AGENT System out printin Daddy this getName I want to read the newspaper public void execute ACLMessage msg while finish EVA Thread sleep 1000 catch InterruptedException e e printStackTrace System out printin Daddy this getName Ok I give up Shall we go to the park msg new ACLMessage ACLMessage REQUEST msg setSender this getAid 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
13. 8 Control of the Interactions between Agents Using the ACL file of the Qpid broker the MMS can restrict the communications between agents 6 6 3 Using security in Magentix2 Desktop version If Magentix2 has been installed by means of the desktop version the security is disabled To active the security in the system these simple steps must be followed e Executing MagentixPKI script This script creates a public key infrastructure to support the Magentix Security Infrastructure In order to customize the process the steps of the section 6 6 4 must be followed The commands needed to execute the script are 152 6 6 Configuring security cd Magentix2 bin security sh MagentixPKI sh CA_PASSWORD BROKER_PASSWORD MMS_PASSWORD e Changing the passwords in the properties configurations securityAdmin properties and services xml How to configure these properties files is explained in section 6 6 8 Some aspects must be considered before configure the properties the MMS_PASSWORD is the same to the key store and trust store In the services xml only MMS_PASSWORD is required The TOMCAT_HOME is HOME Magentix2 apache tomcat 7 0 4 e Adding a new trusted third party certificate authority explained in section 6 6 6 e Restarting the Tomcat service executing the commands cd Magentix2 bin Tomcat sh Stop Catalina sh sh Start Catalina sh e Stopping Qpid without security and restart with secu
14. System out println myProcessor getMyAgent getName msg getSender name informs me msg getContent 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 3 Programming Agents 43 We create the message that will be sent in the doRequest method of the conversation msg new ACLMessage ACLMessage REQUEST msg setReceiver new AgentID Sally msg setContent May you give me your phone number msg setProtocol fipa request msg setSender getAid The agent creates the CFactory that creates processors that initiate REQUEST protocol conversations In this example the CFactory gets the name TALK we don t add any additional message acceptance criterion other than the required by the REQUEST protocol CFactory talk new myFIPA_REQUEST newFactory TALK msg 1 this 5000 this addFactoryAsInitiator talk finally the new conversation starts Because it is synchronous the current interaction halts until the new conversation ends this startSyncConversation TALK CFactory templates are useful for reusing code It is possible to create templates of other IP or modify the existing ones in order to adapt them 3 4 4 Creating a CFactory Template This section explains how to implement a new CFactory template In the following example we are g
15. keytool list storetype pkcs12 keystore keystore_fnmt p12 The alias will be displayed in the first place of line for example in the following case the alias is alice Figure 3 16 KEVSicOre cyjoSes US Keystore provider alice 27 sep 2010 Hash of certificate SUN Your keystore contains 5 entries 1321022 Biss SAC SS ZB SIC Ss DS SCs GIRS ING CORDE r 7D 3 IDVA 21874 PrivateKeyEntry MD5 Figure 3 16 Result of the Keytool command 3 Programming Agents 79 lt ooe eS Core loicokeie gt lt entry key host gt localhost lt entry gt lt entry key port gt 5671 lt entry gt lt entry key vhost gt test lt entry gt lt entry key user gt guest lt entry gt lt entry key pass gt guest lt entry gt lt entry key ssl gt true lt entry gt lt Secure apid properties gt lt entry key secureMode gt true lt entry gt lt entry key saslMechs gt EXTERNAL lt entry gt Figure 3 17 An example of the Settings xml file e Settings xml The connection parameters must be specified inside the Settings xml file The Figure 3 17 shows an example of the content of this file Note that the port param eter is where the broker Qpid is listening to the ssl connections and EXTERNAL is the method by default 3 7 6 Running In the secure mode agent connection with the broker is formed automatically in the agent constructor Therefore in the main program
16. qpid apache org books 0 7 AMQP Messaging Broker CPP Book html index html Please note that if two ore more Qpid brokers have to work federated a link between all the broker s amq topic exchange has to be added 6 3 MySQL MySQL is a main component of the THOMAS framework This section explains how to prop erly configure MySQL to work in conjunction with THOMAS If MySQL was installed during the Magentix2 Desktop version installation 1t will not be necessary to follow the steps shown here However if it was not installed together with Magentix2 or MySQL was already installed on the system then this section helps to configure MySQL properly All the information about the organizations created with the THOMAS framework and running on the Magentix2 platform is permanently stored in a MySQL database It is possible to create the database schema and the user employed by the THOMAS framework in MySQL by means of the the execution of the script Import ThomasDB sh This script is located in the directory 6 Platform administration 143 bin MySQL which can be found into the Magentix2 installation folder The commands needed to execute this script are the following from the Magentix2 root directory cd bin MySQL sh Import ThomasDB sh MYSQL_ROOT_PASS However it is also possible to create the THOMAS database infrastructure step by step without using the cited script In this case it is necessary to load into My
17. 3 2 2 Stopping Magentix2 platform cd bin sudo sh Stop Magentix sh Uninstalling Apache Qpid sudo apt get remove qpid Deleting Magentix2 installation directory cd sudo rm rf Magentix2 Installing Magentix2 Java Based Desktop Edition This distribution is based on Java implementation for the Qpid message broker but do not supports the security feature This installation is recommended only for developers and not for the end user applications because the Java broker communications performance is lower than C broker please use Magentix2 Desktop Edition for this purpose This installation is offered both for the Microsoft Windows architecture system and Linux architecture system Please check the appropriate version 2 Quick Start 7 2 2 1 Requirements e Oracle Java Development Kit JDK 6 update 01 or later e Linux Distribution e Microsoft Windows NT XP Vista 7 2 2 2 Installation of Magentix2 Desktop In order to install Magentix2 Desktop the corresponded jar for 32 bits or 64 bits Linux archi tecture or Microsoft Windows must be downloaded firstly Then the JAVA HOME environ ment variable must be defined and JAVA HOME bin directory added in PATH Once Magentix2Desktop jar is downloaded and JAVA_HOME configured properly the follow ing command must be executed e If the architecture system is 32 bits Linux distribution sudo java jar Magentix2Desktop i386_java_version
18. gt Using the prefix op tion when configuring the location where the Qpid binaries are installed can be specified in this example case home hyperion qpid 4 To install a Qpid version with security support please follow at this section 6 6 9 142 6 3 MySQL e make install After a successful installation Qpid can be launched executing the following command inside the folder where Qpid was installed in this example case home hyperion qpid apidad Some values Qpid broker set by default are used by some components of Magentix2 therefore if any of them is changed it is possible that the Settings xml file has to be also modified This file can be found in the configuration directory of Magentix2 distribution folder Specifically the parameters that affect Qpid configuration in the Settings xml file are the following lt entry key host gt localhost lt entry gt lt entry key port gt 5672 lt entry gt lt entry key vhost gt test lt entry gt lt entry key user gt guest lt entry gt lt entry key pass gt guest lt entry gt lt entry key ssl gt false lt entry gt For example if the port which Qpid broker is listening to is modified from the default 5672 to 5671 this change has to be also made on the Settings xml file For those looking to adjust the Qpid broker operation there are plenty of advanced configuration options for further information please refer to http
19. new AgentID Consumer ON Vx Execute the agents x consumerAgent start senderAgent start 40 41 42 43 44 45 16 2 3 Developing and executing a first agent catch Exception e logger error Error getMessage In lines 14 and 15 the logger mechanism is set up Its basic functionality is to show messages at some points of the code This messages have a priority level associated these levels go from info to error It is needed to specify the configuration file for the debugger and the class to debug Main class in this example In line 20 the connection to the broker for all the agents launched in this class is set up In this particuar case it is specified that the QPid broker is running in the same host that the agents The other parameters are the values for a default configuration of the broker From lines 27 to 38 the agents are created specifying an agent id for each one and then they are started If Eclipse is used the example can be run using the run button The result of the execution will appear on the console and it should be something similar to what is shown below Hi I m agent Consumer and I start my execution Hi I m agent Sender and I start my execution Hi I m agent Consumer and I ve received the message Hi I m Sender agent and I m running on Magentix2 CHAPTER 3 Programming Agents 3 1 Basic cl
20. security sub directory includes all required files to launch Magentix2 in secure mode e docs includes javadoc and the Magentix2 documentation in Pdf format e lib includes Magentix2 library an all additional libraries required by Magentix2 How to import this library in projects is explained in section 2 3 e examples includes some examples of Magentix2 agents implementation e src includes Magentix2 sources e thomas includes all services required by THOMAS and Magentix2 platform It also includes an example of a user web service 2Magentix2 is launched without security to enabled security refer to section 6 6 3 140 6 2 Apache Qpid 6 1 2 Possible Errors If MySQL is already installed in system the system informs about it with this error message 101124 16 20 15 mysqld_safe Logging to syslog 101124 16 20 16 mysqld_safe A mysqld process already exists bin mysqladmin connect to server at localhost failed Moreover if the following log is showed and ETC MYSQL directory not exists then an unstable installation of MySQL is in system In this case a new installation of MySQL is recommended In section 6 3 is explained how to install MySQL manually and section 6 1 explain how to import the THOMAS schema in the current MySQL database bin mysqladmin connect to server at localhost failed Gwicores Can t commeci co local MyS0L server iclaicowucla socket tmp mysql sock
21. the method connect explained in section 3 1 4 is not necessary Thus it is only required to complete carefully the previous configurations and import the required libraries in the Java project build path Please note that the platform do not allow agents with the same name and it is case sensitive 3 7 7 Problems The following exceptions can arise when security is used and correct configuration has not be done 1 WSSecurityEngine Callback supplied no password for mms The MMS self signed certificate has not been imported correctly in keystore 2 org apache axis2 AxisFault Error in signature with X509Token The alias parame ter of the security User properties file has not correctly specified The libraries are available in lib security directory 80 3 8 Tracing Service 3 General security error No certificates were found for decryption KeyId The MMS self signed certificate has not been imported correctly in the keystore 4 org apache axis2 AxisFault The certificate used for the signature is not trusted The User certificate with the user public key has not been added in the truststore of ma gentix administrator it is necessary to check that the user certificate have been exported and transfered correctly or contact with the magentix administrator In administrator mode section 6 6 6 explains how to import user certificate 3 8 Tracing Service This section describes the Tracing Service Suppo
22. 1t is required to define a class which extends the class es upv dsic gti_ia core SingleAgent Itis a extended class from BaseA gent The SingleAgent defines a new message reception method receiveACLMessage that per forms blocking reception It receives a new message in blocked mode Then when the agent retrieves the message it is removed form the head of the agent s message queue The following code shows how to implement a new singleAgent with the receiveACLMes sage method public void execute xk This agent has no definite work Wait infinitely the arrival of new messages aay Al xx x receiveACLMessage is a blocking function x its waiting a new ACLMessage x 3 Programming Agents 19 ACLMessage msg receiveACLMessage System out println Mensaje received in this getName agent by receiveACLMessage msg getContent O catch Exception e logger error e getMessage peturi 3 1 3 Initialization Tasks Magentix2 platform uses log4j as a logging facility It was developed by the Apache s Jakarta Project Its speed and flexibility allows log statements to remain in shipped code while giving the user the ability to enable logging at runtime without modifying any of the application binaries Log4j must be initialized inside the main method of each Java application as follows DOMConfigurator configure configuration loggin xml
23. 6 3 2 msg setPerformative ACLMessage REQUEST 3 msg setLanguage ACL 4 6 4 Message send process e Send an organizational message When a message is formed it can send the message using the send method 1 send msg or it reached a state of type send in CFactories 1 class REQUEST_Method implements SendStateMethod 4 public String run CProcessor myProcessor ACLMessage messageToSend 4 Virtual Organizations 20 21 22 23 24 OMSProxy omsProxy new OMSProxy myProcessor ACLMessage msg Strainges tates WATE Tisy al 129 msg omsProxy buildOrganizationalMessage team messageToSend copyFromAsTemplate msg messageToSend setPerformative ACLMessage REQU EST messageToSend setLanguage ACL messageToSend setContent 6 3 catch THOMASException e e printStackTrace state FINAL Otura state CHAPTER 5 HTTP Interface 5 1 Framework oooooooooo o 131 AS 0 AA Nees Bi we SRS a 134 53 Example 2 ccc cece eee eee eee 134 In order to allow interaction between a Magentix2 agent and the outside world an HTTP interface service has been developed The service is automatically started when the StartMa gentix sh script is executed so no special action is required A common use for the HTTP Interface service is a webpage that allows its use
24. 6 1 2 Dialogue Strategies In each step of an argumentation process a Magentix2 argumentative agent can choose a spe cific locution to put forward and a content for it The mechanism that agents follow to make such decisions is known as dialogue strategy In our case based argumentation framework agents select the best locution to bring up depending on the dialogue protocol that they are following and the content of this locution depending on the knowledge that they have in their knowledge resources and the tactic that they follow to argue A Magentix2 argumentative agent will not initially accept any position from a peer This agent will challenge positions of other peers when they are different from its position even if they appear in its list of potential positions to propose Also it will try to generate an answer for any attack that it receives but opposite to open minded agents argumentative agents do not accept the position of the peer that generated the attack if the last wins the debate If an argumentative agent cannot generate positions it will not participate in the dialogue Finally agents will accept arguments from other agents that have a power or authorisation dependency relation over them Depending on its dialogue protocol the agent will choose the next locution to put forward on the dialogue game Then among the potential arguments that the agent may generate it has to select one to propose This implies to select the
25. 8 4 1 System domain independent tracing services System domain independent tracing services provide information which may be necessary for any tracing entity in order to understand the sequence of trace events which it has received These tracing services are not requestable and thus trace events are received by tracing entities as they excute without having previously subscribed to them For instance if a tracing service were not available anymore all those agents which had previously requested it would receive an UNAVAILABLE_TS trace event so that these agents know that the service is not being offered anymore Details on system domain independent tracing services and on the information which their events provide are detailed in Table 3 15 3 Programming Agents 89 Table 3 15 System related domain independent tracing services TRACE_ERROR Generic non determined error in the tracing process tService TRACE_ERROR 0 originEntity system host content Human readable error description SUBSCRIBE The tracing entity requested a tracing service with name tServiceName to an ES entity ESid which can be any to express interest in trace events of that tracing service coming from any of ES entities From that time trace events of that tracing service may be delivered to the tracing entity tService SUBSCRIBE 1 originEntity Trace Manager entity to which the tracing service request was made
26. 8 6 lines 59 to 79 shows an example of trace event handler In this case the received trace event is processed attending to its tracing service 3 8 3 Tracing Services Agents which are interested in sharing their trace events offer them as tracing services Agents publish their available tracing services and other agents can request those tracing services in which they are interested As a consequence only those trace events which have been requested by an agent in the system are traced and agents only receive those trace events which they have previously requested In this way trace event traffic is reduced and agents do not have to process trace events which they are not interested in In order to register available tracing entities and services as well as to manage subscriptions to tracing services the platform must have a Trace Manager running In Magentix2 the Trace Manager is a single agent the TraceManager class inherits from BaseAgent which must be running in a host of the platform however the trace manager is intended to be a distributed entity in future versions of the platform The trace manager can be launched in any host where Magentix2 is running by invoking the corresponding constructor method TraceManager AgentID tmAid An example of how to launch the Trace Manager can be found in the source code of the example in Section 3 8 8 in line number 29 of the main application source code TraceManager tm
27. EAN OD Vik Execute the agents x dadesitare olderSon start youngerSon start catch Exception e logger error Error getMessag O 99 100 3 8 Tracing Service 3 8 9 Results JUNIE WINE EZ MN CAR Daddy MrSmith I want to read the newspaper may le Lam nay eme Ian Y years oleih Bobby I m Bobby and I m 5 years old MrSmith 16 11 06 077 qpid Timmy localhost 8080 said REFUSE NO MrSmith 16 11 07 072 qpid Bobby localhost 8080 said REQUEST Give me your toy MrSmith 16 11 07 077 qpid Timmy localhost 8080 said REFUSE NO MrSmith 16 11 08 075 qpid Bobby localhost 8080 said REQUEST Give me your toy MrSmith 16 11 08 080 qpid Timmy localhost 8080 said REFUSE NO MrSmith 16 11 09 077 qpid Bobby localhost 8080 said REQUEST Give me your toy MrSmith 16 11 09 083 qpid Timmy localhost 8080 said REFUSE NO MrSmith 16 11 10 080 qpid Bobby localhost 8080 said REQUEST Give me your toy MrSmith 16 11 10 094 qpid Timmy localhost 8080 saulols Rue Usias INO MrSmith 16 11 11 082 qpid Bobby localhost 8080 said REQUEST GUAAAAAA MrSmith 16 11 11 087 qpid Timmy localhost 8080 said REFUS NO Daddy MrSmith Ok I give up Shall we go to the park Daddy MrSmith Timmy says AGREE GO TO THE PARK Daddy MrSmith Bobby says AGREE GO TO THE PARK Daddy MrSmith
28. FINAL The template processor is ready We add the factory in this case as a participant one this addFactoryAsInitiator talk Finally Harry starts the conversation ACIMessage response this startSyncConversation TALK System out printin this getAid name Sally tell me response getPerformative response getContent 3 4 3 Using a CFactory Template Defining a CFactory and its CProcessor template can be a laborious task In order to facilitate this a set of CFactories templates are provided in Magentix2 At the moment the templates are e FIPA Request e FIPA Contract net e FIPA Recruiting All of this templates are available in both versions initiator and participant 42 3 4 Advanced conversational agents CAgents The source code of the examples shown in this sections are accessible at the folder examples s rc requestFactory A CFactory template is a java class that has already defined the states and the transitions of the CProcessor template A template can be modified in order to adapt it to any specification Some templates have abstract methods that are necessary to implement by the users Others methods offer a default behaviour that can be modified if needed As an example it is shown how to adapt the FIPA Request Initiator template provided in Magentix2 to a scenario where one agent Harry asks another agent Sally for her phone number In
29. SF and OMS service implementations have to be available as standard web services Moreover Magentix2 offers another service named MMS section 6 6 which is responsible of controlling the user access to the platform This service must be also available as an standard web service Any other user service such as the application examples need also to be available as standard web services As mentioned above Magentix2 uses Apache Tomcat to allow it Apache Tomcat can be downloaded from http tomcat apache org The installa tion instructions can be found at http tomcat apache org tomcat 7 0 doc setup html Once Tomcat is installed packaged libraries of THOMAS services omsservices war sfser vices war have to be copied from Magent ix2 thomas directory to the subdirectory webapss of the Tomcat installation directory Furthermore the packaged library of the MMS service MMS war which is also located at the Magentix2 thomas directory must be copied to the same webapss subdirectory Then the path where web services are deployed is required In order to specify these parame ters the Settings xml file located in the Magentix2 configuration directory will be configured The parameters that affect THOMAS configuration in the Settings xml file are the following lt Properties thomas gt lt entry key OMSServiceDescriptionLocation gt http localhost 8080 omsservices services lt entry g
30. String name int availableConversations CAgent myAgent long timeout CFactory theFactory new CFactory name null availableConversations myAgent Processor template setup CProcessor processor theFactory cProcessorTemplate BEGIN State BeginState BEGIN BeginState processor getState BEGIN BEGIN setMethod new BEGIN_Method PROPOSE State SendState PROPOSE new SendState PROPOSE Gl PROPOSE setMethod new PROPOSE Method processor registerState PROPOSE processor addTransition BEGIN PROPOS E 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 46 3 5 BDI Agents JasonAgents WAIT State WaitState WAIT new WaitState WAIT timeout processor registerState WAIT processor addTransition PROPOSE WAIT RECEIVE State ReceiveState RECEIVE new ReceiveState RECEIVE RECEIVE setMethod new RECEIVE _Method filter new MessageFilter accept any message RECEIVE setAcceptFilter filter LS processor registerState RECEIVE i processor addTransition WAITE RECEIVE FinalState FINAL new FinalState FINAL FINAL setMethod new FINAL Method processor registerState FINAL processor addT
31. Then using the Magentix Certificate Authority the blue one in Figure 6 6 the MMS issues certificates for the agents blue certificates in Figure 6 6 Once an agent gets a valid certificate issued by the Magentix Authority Certificate it can communicate to other agents in a secure way Third Party Certificate Authority sn a z a MMS Certificate Authority CA E m SSL ee Y QPID BROKER ss M AGENTI Certificate B AGENTI f binding_key agent2 BROKER Certificate SSL Qe Agent2 queue AGENT2 Certificate AGENT2 Figure 6 6 Magentix2 Security Infrastructure The Magentix2 communication is based on AMQP standard For supporting this standard the Apache Qpid open source implementation is used So the Qpid broker must be configured in order to support security For this purpose the broker will be use a certificate which issues for the Magentix2 Certificate Authority Thus agents in Magentix2 will communicate with each other in a secure way using their agent certificates which allow to authenticate with the Qpid broker Furthermore this broker can also communicate with them using his certificate This section explains how to create the Magentix2 Certificate Authority and certificates for the Qpid broker and MMS Moreover how to configure MMS is also explained Finally it is explained how to install configure and run the Qpid broker with security support 6 Platform administration 15
32. There are two different ways to request a service depending on the type of the providers If the providers are agents or organizations their parameters entity ID entity type language and performative to make the request are obtained from the OWL S specification using the Oracle class Then the requester agent should properly build the message to make the request and wait for the response of the provider to obtain the result In ServiceTools class it is possible to find the method build ServiceContent which returns an XML description receiving as parameters the inputs and the name of the requested service This description is understood by all THOMAS services and the services of the provided examples If the providers are web services the URL of the WSDL documents are obtained from the OWL S specification using the Oracle class Then the requester agent has to execute the service by itself To perform this task the class ServiceTools of the package es upv dsic gti_ia organization provides the method executeWebService to 4 Virtual Organizations 121 facilitate the execution of web services to the developers This method receives as parameters the url of the service WSDL document to execute it and the inputs of the service The inputs can be specified in two ways in a HashMap giving the name of the input and its value or with an XML string in the following form lt inputs gt lt inputX gt valueX lt inputX gt
33. a new argumentative agent it is necessary to implement the abstract meth ods of the Argumentation Participant protocol The decisions and the actions to perform in each state of the argumentation protocol are codified in these methods The main methods to implement are shown in Table 3 9 Due to the complexity of defining a new argu mentative agent the user should consider to use the ArgCAgent java class of the example as a base to implement the behaviour of a new argumentative agent 3 6 3 3 Example Call Centre Application To date the system is implemented in the domain of a customer support application where several operators represented by software agents argue to provide the best solution for an in cidence also known as ticket received Thus we use this example domain to show how ArgCAgents can be executed Int the current version of the software the example is imple mented in the Argument ation Example package which includes the java files for creating agents Agent sCreation java the template code of the argumentative agent ArgCAgent java a file to create case bases with data about example domain cases and argument cases CreatePartitions java a test file for executing the example TestArgCAgent java 72 3 6 Argumentative Agents Method Description doAccept actions to perform and send an ACLMessage accepting the other agent s position or argument doAssert t
34. aS ey aw A a on ok ee a a 6 6 2 Supported features 2 0 0 E A E E ee 6 6 3 Using security in Magentix2 Desktop version 6 6 4 Creating certificates o ee ee ee 6 6 5 Exporting the MMS certificate with the public Key 6 6 6 Importing new trusted third party certificate authority 6 6 7 Tracing Service gs sb Al ea Sa a ES es a Bt 6 6 8 Magentix2 Management System MMS 6 6 9 Qpid broker with security support 00 Bibliography Ill 131 131 134 134 134 134 137 137 138 140 140 142 145 147 147 149 150 150 151 151 153 157 157 157 159 163 165 List of Figures 2 1 2 2 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 4 10 4 11 Project and package creation 1 2 o e e 11 Programming a first agent with Eclipse o a 12 Appender taa ai br a a sE 20 Appender 2 a fa de E a A ti lee E eS 20 Messages exchange thought QPID Broker in Magentix2 23 Diagram for the QueueAgent class o o 28 CFactory for FIPA Request Interaction Protocol for the initiator agent 35 Global view ofaCAgent o e 36 myFirstCProcessorFactories example o o 38 Example Structure of a Domain Case o a 51 Structure of an Argument Case
35. agent requests a tracing service called MESSAGE_SENT_DETAIL in order to inspect every message that his boy agents Bobby or Timmy send More details on these tracing services and on how to understand the information provided by these trace events are available in Table 3 17 3 8 4 4 Tracing service publication related domain independent tracing ser vices These domain independent tracing services provide information related to tracing services be ing published by tracing entities in the system For instance a generic agent may need to be noticed when a specific tracing service is being offered or when another agent is not shar ing certain tracing information anymore These domain independent tracing services and the information they provide are detailed in Table 3 18 3 Programming Agents 91 Table 3 17 Agent s messaging related domain independent tracing services MESSAGE_SENT A FIPA ACL message was sent from OriginAgent Id to DestinationAgentId tService MESSAGE_SENT 6 originEntity OriginAgentId content DestinationAgent Id MESSAGE_SENT DETAIL A FIPA ACL message was sent from OriginAgentld The difference with MESSAGE_SENT is that MESSAGE_SENT_DETATL trace events include the ACL message they refer to tService MESSAGE_SENT_DETAIL 7 originEntity OriginAgentId content SerializedMessage MESSAGE RECEIVED A FIPA ACL message was received by DestinationAgentId tService MESSAGE REC
36. any direct or indirect authorization 3 8 2 Trace Event Trace events are represented in the platform as instances of the class es upv dsic gti_ia Ccore TraceEvent public class TraceEvent implements Serializable private String tService private long timestamp 82 3 8 Tracing Service private TracingEntity originEntity private String content The different attributes of this class indentify the tracing service to which the trace event be longs the tracing entity which originated the trace event and the time at which it was produced expressed as the amount of milliseconds from 1 Jan 1970 at 00 00 00 Epoch This informa tion can be complemented when needed with extra data stored in the content attribute Trace event instances are created by invoking the constructor of the class Details of the pa rameters are explained in Table 3 10 As it can be seen the t imest amp attribute of the trace event is not stablished by any parameter of the constructor This is because the timestamp of each trace event is internally set to the time at which the constructor of the class was invoked Table 3 10 TraceEvent class constructor parameters TraceEvent String tService AgentID originAid String content tService String identifying the tracing service to which the trace event is associ ated timestamp Time at which the trace event was generated The time is expresed in milliseconds
37. are described in more detail in Table 3 14 In response to any of these requests a list of available tracing entities or available tracing services will be sent to the applicantAgent as an AGREE ACL message The requested list will be included in the content field of the ACL message When a list of avalable tracing entities has been requested the content of the reply message will be structured as follows e Message content list entities lt number of t entities gt lt t entity description list gt 3 Programming Agents 87 Table 3 13 Tracing service subscription and unsubscription methods requestTracingService BaseAgent requesterAgent String serviceName AgentID originEntity requestTracingService AgentID tms_aid BaseAgent requesterAgent String serviceName AgentID originEntity requestTracingService BaseAgent requesterAgent String serviceName requestTracingService AgentID tms_aid BaseAgent requesterAgent String serviceName requestAllTracingServices BaseAgent requesterAgent requestAllTracingServices AgentID tms_aid BaseAgent requesterAgent cancelTracingServiceSubscription BaseAgent requesterAgent String serviceName AgentID originEntity cancelTracingServiceSubscription AgentID tms_aid BaseAgent requesterAgent String serviceName AgentID originEntity cancelTracingServiceSubscription BaseAgent requesterA
38. argument s in the past e Efficiency degree ED is a value that provides an estimation of the number of steps that it took to reach an agreement posing a similar argument in the past e Explanatory Power EP is a value that represents the number of pieces of information that each argument covers It is based on the number of knowledge resources were used to generate each similar argument case retrieved The selection of these specific parameters to estimate the support factor of a position or ar gument has been determined by the nature of the elements of our argument cases Thus the persuasiveness and support degrees take into account the acceptability status stored in the argument cases the attack and risk degrees look at the attacks received by the argument that an argument case represents the efficiency degree makes use of the dialogue graphs stored in the argument cases and the explanatory power computes the number of justification elements that argument cases have Therefore the support factor is computed by using the following formula SF wpp PD wsp SD wrep 1 RD 3 1 wap 1 AD wgp ED wep EP l where w 0 1 5 gt w 1 are weight values that allow the agent to give more or less importance to each parameter of the support factor In Magentix2 argumentative agents these weights can be set by specifying the corresponding parameters in the agent s constructor as will be show in Section 3 6 3
39. assigned to roles when they are created Not all the values are allowed to any type of organization see section 4 1 2 Anytime an agent registers an organization a new role with a creator position is automatically assigned him This position gives permission to register and deregis ter organizations and roles In addition it is possible to assign a creator role using the services offered by the THOMAS API see section 4 2 1 In Table 4 1 a summary of the role behavior taking into account its position is shown e Accessibility This attribute allows controlling who can acquire roles Specifically the permitted values are 4 Virtual Organizations 103 External roles can be acquired by agents who do not play any role in the organiza tion Internal in this case it is necessary participate into the organization that is the requested agent should play some role in the organization e Visibility By means of this attribute it is possible to control what information about roles is provided Concretely the allowed values for this attribute are Public information services always provide the requested information Private the solicited information is provided only if the requested agent belongs to the same organization where the role is registered The relationship between accessibility and visibility attributes can be seen in the table 4 2 4 1 2 Units in THOMAS THOMAS framework gives support for
40. commitment store Also dotted lines represent transitions between states when these incoming messages with their associated locution are received Therefore the transitions between states depend on the locutions that the agent can use in each step of the dialogue The states of the argumentation dialogue are described as follows 1 Begin this is the start state of the argumentation protocol 2 Open when the agent is initialised it remains in this state waiting for an OPENDIA LOGUE locution The agent will move back to this state when the dialogue has finished The OPENDIALOGUE locution inform the agent that a new dialogue to solve a problem has started Also when an agent received the DIE locution in this state it must shutdown its execution 3 Programming Agents 63 no_commit why open_dialogue ie finish_dialogue a accept already E dialogue a open_dialogue perdio Y oe a pas Begin open Propose Central r N withdraw_dialogue y amp i f i t accept 7 withdraw_dialogue J WN I GA P a N e Noa 2 finish_dialogue y E a y query_positions Y I finish_dialogue VA K lt Send et finish_dialogue position positions JP setallpositions timeout a timeout send_position Y 4 Solution so rn gt 7 No Y No i A A A i S timeout accept assert no_commit N x Attack2 reno Sell N Figure 3 10 Argumentation Protocol
41. during the process 5 Inform T F when the previous message was an Agree and the first message was a Query If 6 Inform Result when the previous message was an Agree and the first message was a Query Ref 3 3 2 3 FIPA Contract Net The classes ContractNet implements the behaviour of the protocol of the same name whose operation is the initiator sends a proposal to several responders then evaluates their answers and finally chooses the preferred one or no one The messages exchanged are 1 CFP Call For Proposal it specifyes the action to carry out and when it is appropriate the conditions on the performance 32 3 3 Basic conversational agents QueueAgents 2 Refuse when responders reject their participation 3 Not Understood when there were failings in the communication 4 Propose when a responder makes proposal to the initiator 5 Reject Proposal in the case the initiator evaluates a proposal and reject it 6 Accept Proposal when the initiator evaluates a proposal and accepts it sending this type of message to accept them 7 Failure responder send this type of message when their proposals were accepted and something wrong happened 8 Inform Done this messages is sended by responders when their proposals were ac cepted and the action was performed successfully 9 Inform Results this message is sended by responders when their proposals were ac cepted and they need to inform about th
42. implemented An argumentation scheme consists of a set of premises and a conclusion that is presumed to follow from them Also each argumentation scheme has associated a set of critical questions that represent potential attacks to the conclusion supported by the scheme 50 3 6 Argumentative Agents A case base with domain cases that represent previous problems and their solutions Agents can use this knowledge resource to generate their positions in a dialogue and arguments to support them The position of an agent represents the solution that this agent proposes Also the acquisition of new domain cases increases the knowledge of agents about the domain under discussion A case base with argument cases that store previous argumentation experiences and their fi nal outcome Argument cases have three main objectives they can be used by agents 1 to generate new arguments 2 to select the best position to put forward in view of past argumentation experiences and 3 to store the new argumentation knowledge gained in each agreement process improving the agents argumentation skills Argumentation Schemes The concrete set of argumentation schemes used also depends on the application domain of our argumentation framework The Magentix2 argumentation API only provides a ba sic template for them with the common components of Walton s like argumentation schemes Walton et al 2008 A user that wants to use this knowledge resource must
43. in the root folder of the project in this case workspace MyFirstAgent Then it is necessary to create a new package named agent in the project In figure 2 1 it is shown how Eclipse looks like after taking these actions E Gy o 9 Or 5 sJava i g A Package Explorer 33 aS ARA D El Task List 2 n Y amp MyFirstAgent 37 Berx eb ao sre S All gt Activate gt m JRE System Library JavaSE 1 6 Ex Uncategorized Y m Referenced Libraries gt Ga magentix2 2 01 jar with dependencies zip Y E configuration gt clientrepo i loggin xmt if policy xml B securityUser properties R Settings xml O Connect Mylyn Connect to your task and ALM tools BE Outline 23 Fea An outline is not available E Problems amp gt Javadoc Declaration SSC Oitems Description Resource Path Location Type agent MyFirstAgent sre Figure 2 1 Project and package creation The example shown here consists in two agents Sender and Consumer The agent Sender sends a message to agent Consumer who writes the content of the received message on the console In order to set this example it is required to create three Java classes Sender java 12 2 3 Developing and executing a first agent Consumer java and Main java Sender java and Consumer java will contain the code of the agents Besides Main java will create the connexion to the broker for the agents and start them Now how to program the Sender java cla
44. n del sistema jibboost iostreams1 35 0 1 35 0 BubuntuS Bibliotec A Ee O libboost iostreams1 34 1 1 34 1 15ubuntu3 Bibliotec pcs eevee O pyste 1 34 1 15ubuntu3 Boost Py eee universe O libboost iostreams dev 1 34 1 15ubuntu3 Archivos Bibliotecas i Antiguo KHO _ libboost iostreams1 37 dev 1 37 0 3ubuntu3 Archivos T D Secciones Os libboost python1 34 1 1 34 1 15ubuntu3 Bibliot AA sia ns non msa a h Estado m gt Archivos de desarrollo de la biblioteca Boost lostreams H Origen ge Obtener captura de pantalla 1 Filtros personalizados Parte de la colecci n de bibliotecas Boost de C Resultados de b squeda A I dd i a y 101 paquetes listados 1185 instalados 0 rotos O para instalar actualizar 0 para desinstalar Figure 6 1 Installing libboostiostreams 1 35dev library with Synaptic tool e pkgconfig http pkgconfig freedesktop org wiki 0 21 e uuid 1 21 41 4 e ruby 4 2 e ruby 1 8 In Ubuntu operating systems these packages can be installed using the Synaptic package man agement tool but any other package manager might be valid As an example figure 6 1 shows how to install the libboostiostreams 1 35dev library Once all the required libraries have been installed Qpid broker can be downloaded from http qpid apache org download cgi To install Qpid the following steps must be performed e Uncompressing the donwloaded Qpid file e configure prefix home hyperion qpid
45. of the securityAdmin properties file set the type of algorithm for the signature certificates SigAlg SHA1WithRSA set the validity time for the certificates days Validity 90 Figure 6 10 Second section of the securityAdmin properties file Setting the base path for logging the registers User Agent Figure 6 12 By default 6 Platform administration 161 set the base path for accessing to broker acl ACLPath bin security broker acl Figure 6 11 Third section of the securityAdmin properties file the path is TOMCAT_HOME logs set the base path for log the registers User Agent Userlog logs MMSregisters log Figure 6 12 Fourth section of the securityAdmin properties file Setting the properties for the Magentix Certificate Authority Figure 6 13 set the alias to root certificate aliasCA MagentixCA set the password to root nss db password PASSWORD_CA set the type to root nss db ipyoe Phe sie Figure 6 13 Fight section of the securityAdmin properties file Setting the base path for accessing to the configuration nss file Figure 6 14 set the base path for accessing to configuration file nss pathnsscfg webapps MMS WEB INF classes nss cfg Figure 6 14 Sixth section of the securityAdmin properties file Setting the properties of the Qpid broker Figure 6 15 Setting the values of the certificates Figure
46. or equal than a given threshold Table 3 6 Main DomainCBR java methods cases with the new data acquired Otherwise new argument cases are created and added to the case base The main methods of the Argumentation CBR are shown in Table 3 7 for a detailed explanation of all Argumentation CBR methods see the ArgCBR java associated JavaDoc Method Parameters Description addCase argument case Adds a new argument case to the case base Two cases are considered equal if they have the same domain context social context conclusion and status of acceptability getDegrees argumentProblem Return a list with the degrees at solution allPosi tack efficiency explanatory power tions index persuasiveness support and risk of an argument case getSameDomainAnd premises solution Returns the argument cases with the SocialContextAccepted socialContext same domain and social context that have been accepted in the past Table 3 7 Main ArgCBR java methods The contents of the case bases of the Domain CBR and the Argumentation CBR can be stored as java serialised objects In this way we provide a quick and simple data persistence mecha nism Thus both DomainCBR java and ArgCBR java classes include different methods to load and save information about cases from to data files see Table 3 8 The main functionalities of the argumentative agents generation selection and evaluation of po
47. other agent the agent generates the attack argument The first type of attack that the agent will try to generate is a counter example attack with the method generateCEAttack and if it is not possible the agent will try to generate a distinguishing premise attack with the method generateCEAttack The counter example attack consists on an argument that includes a domain case or an argument case whose conclusion contradicts the conclusion of the attacked argument A distinguishing premise attack consists on an argument that includes a premise or a set that describes the problem and that the attacked agent did not consider to generate its position and its associated support argument or a premise that both agents have but with different data value 3 Programming Agents 61 3 6 2 2 Argumentation Protocol Argumentative agents need a protocol to exchange positions and arguments and engage in the argumentation dialogue The protocol is represented by a set of locutions that the agents use to communicate with each other and a state machine that defines the behaviour of an agent in the argumentation dialogue The state machine has been implemented in the ArgCAgent java class by overwriting the states of the argumentation protocol of the API This proto col has been implemented in the Argumentation_Participant java abstract class of the cAgents protocols package In each state of the protocol the different locutions that can be re
48. overwrite the ArgumentationScheme java class of the Magentix2 argAgents knowledgeResources package Domain Cases The structure of domain cases that an argumentation system that implements our framework depends on the application domain As example Figure 3 8 shows the structure of a possi ble domain case Here an argumentative agent must solve a problem characterised by three premises of different data types P1 P2 and P3 In this example the argumentative agent ArgAgent has found the domain case DCI that matches de description of the problem to solve has all or some of the premises of the problem with the same data values for this premises also including an extra feature P4 Note that here we assume that domain cases also store the value promoted by the solution that they represent see on the arguments structure below for a more detailed explanation This is a design decision that can be replaced by any other assumption Domain cases are implemented in Magentix2 by using the DomainCase java class of the argAgents knowledgeResources package Arguments Arguments in Magentix2 are implemented as java classes concretely in the Argument java class of the Magentix2 argAgents knowledgeResources package In our proposal argu 3 Programming Agents 51 String String String String Float Boolean Description String Value Promoted String Figure 3 8 Example Structure of a Domain Case
49. role specific unit UnitID Identifier of the unit InformUnit Provides unit description UnitID Identifier of the unit InformUnitRoles Used for requesting the list of UnitID Identifier of the unit roles that have been registered inside a unit InformAgentRole Requesting the list of roles and RequestedAgentID Identifier units in which an agent is in a of the agent requested specific moment InformMembers Indicates entities that are mem UnitID Identifier of the unit bers of a specific unit Option RoleID Identifier of the role ally it is possible to specify a PositionID Identifier of the po role and position of this unit so sition inside the unit such as then only members playing this member supervisor or subordi role or position are detailed nate QuantityMembers Provides the number of current UnitID Identifier of the unit members of a specific unit Op tionally if a role and position is indicated then only the quantity of members playing this roles or position is detailed RoleID Identifier of the role PositionID Identifier of the po sition inside the unit such as member supervisor or subordi nate SFProxy provides a developer with a set of methods to manage available services as Table 4 8 shows Table 4 5 OMS Proxy Informative services API M1 Call M2 Request A ae A SFproxy lt M3 Agree b M5 Result SF M4 Inform Figure 4 3 Interaction bet
50. technologies and techniques related to individual agents such as reasoning and learning Thus Magentix2 platform uses technologies with the necessary capacity to cope with the dy namism of the system topology and with flexible interactions which are both natural conse quences of the distributed and autonomous nature of its components In this sense the platform http users dsic upv es grupos ia sma tools Magentix index php 2 1 2 Manual Structure has been extended in order to support flexible interaction protocols and conversations indirect communication and interactions among agent organizations Moreover other important aspects cover by the Magentix2 project are the security issues 1 2 Manual Structure In the following chapters how Magentix2 platform must be installed configured and used for programming agents is explained Specifically chapter 2 clarifies how Magentix2 can be fully installed in only one host in a quickly and easy way Furthermore it is also explained how to develop and to execute simple Magentix2 agents Chapter 3 is about programming aspects in Magentix2 Thus it is possible to consult in this chapter the basic and more advanced classes of agents that the platform provides the main issues related with agent communication how to program agents in a secure environment and finally how agents can share information in an indirect way by means of the tracing service provide by Magentix
51. the agent has taken into account to generate its positions but that other agents did not considered If different attacks can be generated agents select the best attack to rebut the position of another agent by making a query to their argument cases case base extending the characterisation of each case with the current social context In this way agents can gain knowledge about how each potential attack worked to rebut the position of an agent in a past argumentation experience with a similar social context When an agent is able to rebut an attack the opponent agent makes a vote for its position Otherwise the agent must withdraw its position and propose an alternative position if possible 5 The dialogue finishes when no new positions or arguments are generated after a specific time The fester agent is in charge of making queries to the commitment store agent to determine if the dialogue must finish Then this agent retrieves the active positions of the participating agents If all agents agree the solution associated to the agreed position is selected Otherwise the most frequent position wins In case of draw the most voted position in selected If even in this case the draw persists a random choice is made Finally the tester agent communicates the final solution the outcome of the agreement process to the participating agents 3 7 Launching agents with security enabled In order to ensure the integrity confidentiality priva
52. the proponent Otherwise the proponent must withdraw its position from the dialogue with the locution NOCOMMIT and the attacker agent moves back to the state Central Send Position an agent reaches this state when it has received a locution FINISHDI ALOGUE to start the actions to leave the dialogue when it has proposed yet a position Here the agent sends its current position to update the commitment store information and avoid possible inconsistencies After that the agent moves to the state Solution to wait for the final solution applied to solve the problem Solution when the dialogue has finished the final solution to apply is reporter to all dialogue participants When agents receive this information they update their case bases with the data learnt from the dialogue and move back to the state Open Die this is the final state of the argumentation protocol Agents move to this state when they receive the locution DIE and shutdown their execution 66 3 6 Argumentative Agents 3 6 3 Programming Argumentative Agents 3 6 3 1 How to run Magentix2 Argumentative Agents Magentix2 provides a default implementation of an argumentative agent that can be run from the Magentix2 examples bin directory Thus the user can execute the Start Argumentation Example sh script that launches the default argumentation example cd Magentix2 examples bin sh Start ArgumentationExample sh Package Classes Descrip
53. them to the park When both children agree daddy and his sons leave the building and the application finishes e Initialization DADDY Requests to the NEW_AGENT tracing service in order to know when children ar rive Prints on screen that he intends to read the newspaper BOYS Bobby and Timmy Print on screen their name and age e Execution DADDY Each time a NEW_AGENT event is received Daddy requests the tracing service MESSAGE _SENT_DETAIL in order to listen to what that agent says Each time a MESSAGE_SENT_DETAIL trace event is received Daddy prints its content on screen and checks if the content of the message is equal to GUAAAAAA If so Daddy cancels the subscription to MESSAGE_SENT_DETAIL tracing ser vices and sends ACL request messages to both children to propose the go to the park When both childre have replied with an AGREE message Daddy agent prints it on screen and ends its execution BOYS Bobby and Timmy Bobby which is only 5 sends each second an ACL request message to Timmy which is 7 to request him his toy Give me your toy After 5 denials Bobby starts requesting it by crying sending an ACL message with a loud GUAAAAAA Both Boy agents reply NO to any request which does not come from their father and only AGREE when their dad requests them to GO TO THE PARK When dad requests them via an ACL message to go to the park both sons agree and end their execution
54. three types of organizations or units Flat Team and Hierarchy Each type of organization is governed by different structural norms In the Table 4 3 a comparative of these types of units is shown Furthermore there is an organization created by default named Virtual This is a flat unit which represents the THOMAS world and it is the starting point to enter in the system A role named Participant is always available in the Virtual organization This role has the following attributes lt RoleName Participant Position Creator Visibility Public Accessibility External gt Thus an agent who wants to enter in Thomas world only needs to play the role Participant Position Unit Types Behavior Allowed Creator All types Send organizational messages is not allowed Register Deregister units and roles Allocate Deallocate roles to other agents Change the hierarchical relations between organizations Acquire other roles Request information about the roles played by other agents Request information about organizations and its elements Member Flat Team Send organizational messages These messages will be received for all organization members Register deregister roles Allocate deallocate roles to other agents Acquire another role Request information about the roles played by other agents Request information about organizations and its elements Supervisor Hierarc
55. to execute the broker Qpid with security In sbin directory of Qpid installation this command must be executed qpidd auth yes ssl cert db security broker _db ssl cert name broker ssl require client authentication acl file security broker acl lt ssl cert db gt directory where is the broker database broker_db lt ssl cert name gt alias broker lt acl file gt directory where is the broker acl file The PASSWORD_BROKER is required The following log is showed if the process finishes correctly 20101217 Sci 2A norice berceni Om INC port 5672 ZOLO L27 ISsilSs2Ze moras Mistenni Cor SS CommAScciLeme o a WC joc 5671 AQLO L2 17 W35 133724 moviles Rac ACL lle Y bin secui ity role y aci 201012217 1S3 18224 morias Wieoleere Ebano Bibliography Bordini R H bner J and Vieira R 2005 Jason and the Golden Fleece of agent oriented programming Multi Agent Programming pages 3 37 B rdalo L Terrasa A Juli n V and Garc a Fornes A 2010 TRAMMAS A Tracing Model for Multiagent systems In First International Workshop on Infraestructures and Tools for Multiagent Systems pages 42 49 FIPA 2002 FIPA Request Interaction Protocol Specification FIPA Fogu s R L Alberola J M Such J M Espinosa A and Garca Fornes A 2010 To wards Dynamic Agent Interaction Support in Open Multiagent Systems In Proceedings of
56. to section 6 1 to check which are these components When installation ends the script Start Magentix sh must be executed in order to start the services and platform agents this script must be executed as follows cd Magentix2 bin sudo sh Start Magentix sh To check that all is correctly configured and Magentix2 has been successfully installed and running execute the example Start BasicExample sh This script must be executed as follows cd Magentix2 examples bin sudo sh Start BasicExample sh The output of this example should be like the following one gt The installation of any of these components can cause conflicts in the system if already they exists For example if etc mysql directory exists 2 Quick Start 5 Executing I m consumer AMO A AS ES OA SO AIN E O Thread 2 SingleAgent_Example SenderAgent2 Executing I m the sender Executing I m the sender nsaje received in consumer agent by receiveACLMessage Hello I m the sender HearderValue 2 1 3 Magentix2 installation description Once Magentix2 has been installed in the system in the full installation mode the following folders are created e bin includes the executable files and folders required to launch and start the platform and services The main ones are the following which allows users to start and stop the Magentix2 platform Start Magentix sh it launches services Tom
57. 0202 eee 43 3 Provide SELVICES eke tele AA a Be ee 4 4 Programming Agents that Request Services o a 4 4 1 Acquire Role seseo uer o da e Boa A 4 4 2 Service Search Process 2 o o e 4 4 3 Service Request Process o o e eee ee 4 5 Running THOMAS Example 20000000048 4 6 Programming agents which use organizational messaging 4 61 Acquire ROlE 6 os sn Re e a eee Ne a es 4 6 2 Message build process 2 2 00 cee ee 4 6 3 Message complete process o 000002 eee ee eee 4 6 4 Message send process 0 000 eee ee ee ee 5 HTTP Interface Jal ELAMEWOTK ima a Be ca Meas aed ahd SI e A ate te pa Ante Se eke a a ae dee ke ee ee 52A o Masentix2 jS aod atann dah al o Pe ade al a RO 5 2 2 Redirect php saana act ss eo ake ase he ay Eb se ee ee ia 5 37 EXample ie pes eA a Oe BR Oe OPS Ee A A 6 Platform administration 6 1 Custom Installation 0 0 00 0 0 00000002 a a ee 6 1 1 Magentix2 installation description 04 6 1 2 Possible Errors Lidl te eee dl ea bebe Pol GG 6 2 Apache Opid w ac aon ed eed sa eGo Gon She ae dd se ee bate dh dys 6 32 MySQL eos oia baie ee ASE eh dh Bes 6 4 Apache Tomcat oaaao eee 6 5 Platformservices iec a a a a a e a a a a a a e a A 6 5 1 Running Bridge Agents naaa 002000004 6 5 2 Running OMS and SF Agents aoaaa 6 6 Configuring security ooa ee 626 1 Introduction see wet
58. 1 6 6 2 Supported features In order to ensure the security the Magentix2 secure module supports the follow features 1 Authentication The security module allows agents running on the Magentix2 platform to show other agents that effectively they are the agents they claim This characteristic is the basis for all other features 2 Integrity The messages that one agent sends to another can not be manipulated by unauthorized agents while they are transmitted by the network 3 Confidentiality The messages sent thought the network can not be accessible for unau thorized agents 4 Non repudiation If an agent receives a message of the agent B the agent B is respon sible for its message and can not negate a previous commitment or action 5 Privacy The owner of one agent which is executed in Magentix2 is not known by the rest of the agents of the platform excepting the MMS Therefore the agents interact among them without know the user whom they represent 6 Accountability Although it offers privacy about the identities of the users whose agents run in Magentix2 the MMS saves a log with the relationship with the agents and the user owners Therefore if an agent realizes not desirable actions his owner can be known and sanctioned as appropriate 7 Broker Resources Control The MMS is the unique entity that is authorized for admin ister the broker resources The agents only are authorized to access to their queues
59. 2 Check that mysqld is running and that the socket tmp mysql sock exists bin mysqladmin connect to server at ubuntu failed error Lost connection to MySQL server at reading initial communication packet system error 111 ERROR 2002 HY000 Can t connect to local MySQL server through socket tmp mysql sock 2 6 2 Apache Qpid Qpid broker is a main component of Magentix2 In this section is described how it can be installed in case 1t was not desired to install Qpid together with Magentix2 Apache Qpid can be downloaded from http qpid apache org download cgi The following libraries must be installed before building the source distribution of Qpid e libboostiostreams 1 35dev http www boost org 1 35 e e2fsprogs http e2fsprogs sourceforge net 1 39 3If it exists it is recommended to delete it 6 Platform administration 141 er Gestor de paquetes Synaptic eolica ix Archivo Editar Paquete Configuraci n Ayuda D B squeda r pida R Recargar Marcar todas las actualizaciones Aplica Propiedades boost Buscar o E Paquete Versi n instalada ltima versi n Descripci la a sistema 17 libboost1 37 dbg 1 37 0 3ubuntu3 _Bibliotec E Administraci n del sistema z jibboosti3s dbg 1 35 0 8ubuntuS Bibliotec pao del sistema O libboost iostreams1 37 0 1 37 0 3ubuntu3 Bibliotec Administraci
60. 2 Chapter 4 explains the support for virtual organizations provided by the Magentix2 platform In this way this chapter gives details about how the THOMAS Methods Techniques and Tools for Open Multi A gent Systems framework has been integrated with Magentx2 and how Magentix2 agents can use it In order to customize the Magentix2 platform installation or distribute it in diverse hosts the chapter 6 should be consulted Concretely this chapter is about administration and configura tion aspects related with the different components of the platform Apache Qpid the imple mentation of AMQP Advanced Message Queuing Protocol used for agent communication MySQL the database server used to maintain persistent information about the virtual organi zations manage by the platform Apache Tomcat which allows agents to access to and provide standard Java web services Magentix2 platform services such as the services which allows the communications with external agents or with the THOMAS framework and the security module which provides key features regarding security privacy openness and interoperability CHAPTER 2 Quick Start 2 1 Installing Magentix2 Desktop Edition 3 2 2 Installing Magentix2 Java Based Desktop Edition 6 2 3 Developing and executing a first agent 10 2 1 Installing Magentix2 Desktop Edition This distribution is based on C implementation for the Qpid message broker and supports a
61. 3 Enter in this state the agent will retrieve such cases of its domain cases case base which features match the given problem with a similarity degree greater than a given threshold If the agent has been able to retrieve similar domain cases and use their solu tions to propose a solution for the current problem the agent will engage in the dialogue with the locution ENTERDIALOGUE and will go to the state Propose The agent only engages in the dialogue if it has solutions to propose Otherwise the agent can refuse to engage in the dialogue with the locution WITHDRAWDIALOGUE 4 Propose when the agent is in this state it has retrieved a list of similar domain cases to the current problem to propose a solution position to defend If there are several solu tions to propose it will select the most suitable and go to the state Central Otherwise the agent will leave the dialogue with the locution WITHDRAWDIALOGUE 5 Central this is a central state since the agent can try to attack other positions or defend its position from the attacks of other agents First the agent checks if there is any WHY request from other agent This locution is used to ask an argumentative agent to justify its position In that case the agent will go to the state Assert to try to generate a 64 10 3 6 Argumentative Agents support argument for its position If the agent has not received any WHY request before a specified timeout it will go t
62. 4 items selected 92 1 MB A Figure 6 5 Location of web services files war 6 5 Platform services This section explains how to launch platform agents without using the standard methods shown previously on this manual This can be useful when some default parameters have been changed or if the platform runs in a distributed way 6 5 1 Running Bridge Agents Bridge agents are in charge of sending and receiving messages to or from foreign agents For example they allow Magentix2 agents to communicate with Jade agents BridgeAgentInOut manages messages that go from inside the platform to outside whereas BridgeA gentOutIn does 148 6 5 Platform services the opposite Bridge agents can be running on any host they do not have to be in the same host where the QPid broker or other agents are running A Java program has to be written and executed in order to launch bridge agents The following code shows how to launch these agents import es upv dsic gti_ia core AgentsConnection import es upv dsic gti_ia core AgentID import es upv dsic gti_ia core BridgeAgentInOut import es upv dsic gti_ia core BridgeAgentOutIn public class Main public static void main String args throws Exception AgentsConnection connect private BridgeAgentInOut inOutAgent private BridgeAgentOutIn outInAgent inOutAgent new BridgeAgentInOut new AgentID BridgeAgentInOut outInAgent new BridgeAgentOutIn new Agen
63. 6 16 Setting the Rampart configuration properties Figure 6 17 Tomcat must be restarted in order to update changes Therefore the following commands must be executed If Magentix2Desktop is installed The process to create Magentix CA was explained in section 6 6 4 1 162 6 6 Configuring security set the properties of apid broker host localhost port 5671 vhost test Ser quesia passa tesi ssl true saslMechs EXTERNAL Figure 6 15 Seventh section of the securityAdmin properties file set the values of certificates organizationalUnit Magentix organization orgnization Gale yO SICA S Sic ac S country HS Figure 6 16 Eighth section of the security Admin properties file Rampart config set the alias value of certificate for sign the messages alias mms set the password of mmskeystore key PASSWORD_MSSKEYSTORE Figure 6 17 Ninth section of the security Admin properties file cd Magentix2 bin Tomcat sh Stop Catalina sh sh Start Catalina sh In other cases S cd TOMCAT_HOME bin sh shutdown sh sh startup sh 6 Platform administration 163 6 6 9 Qpid broker with security support 6 6 9 1 Installing In this section is explained how to install Qpid with security If the Magentix2Desktop has been installed and Qpid was selected for install it is not needed execute this step In that case i
64. EIVED 8 originEntity DestinationAgentld content OriginAgent ld MESSAGE_RECEIVED DETAIL A FIPA ACL message was received by DestinationAgentld The difference with MESSAGE RECEIVED is that MESSAGE RECEIVED DETAIL trace events include the ACL message they refer to tService MESSAGE RECEIVED DETAIL 9 originEntity DestinationAgentld content SerializedMessage Table 3 18 Tracing service publication related domain independent tracing services PUBLISHED TRACING SERVICE A tracing service ServiceName was published by the tracing entity ESId tService PUBLISHED_TRACING_SERVICE 10 originEntity ESId content ServiceName UNPUBLISHED_TRACING_SERVICE A tracing service ServiceName was unpublished by the tracing entity ESTd tService UNPUBLISHED _TRACING_SERVICE 11 originEntity ESId content ServiceName 3 8 Tracing Service 3 8 5 Example TraceDaddy Simple example of how to use domain independent tracing services to follow other agents activities and to make decisions according to this activity In this case a Daddy agent listens to his sons Boy agents while they are playing and when one of them starts crying he proposes them to take
65. In the implementation of this agent can be found in the es upv dsic gti_ia core BridgeAgentOutIn class The BridgeAgentOutIn routes messages from external agents received via http to Magentix2 agents Therefore BridgeAgentOutIn decodes the http message received and creates an ACLMessage mes sage After that BridgeAgentOutIn sends the new created message to the recipient s mailbox It should be notice that the BridgeAgentInOut and the BridgeAgentOutIn agents must be launched and instantiate to allow external communication This is made together with the rest of platform services and platforms agents by means of the Start Magentix sh command explained in sec tion 2 1 3 Thus the BridgeA gentInOut and the BridgeA gentOutIn agents would be launched at localhost and the agent BridgeA gentOutIn would be listening in the 8081 port For other configurations please refer to section 6 5 1 20 21 22 23 24 26 3 2 Agent Communication Inside Magentix2 external agents are identified to send messages to them by means of an http address that must be used when creating the corresponding AgentID For instance the fol lowing example shows the code which could be added into the execute method of a Magentix2 agent to send a Request message to another agent running into a JADE platform AgentID receiver new AgentID JADE default parameters E receiver name AgentName hostname 1099 JAD Ho
66. Inform tica Mag z ogia Inteligencia Artificial Grupo de Tecnol lt T U Oo l fa O L qiy MINISTERIO UNIVERSITAT E UF z POLITECNICA J f Qro sde t AA DE CIENCIA DE VALENCIA o a 5 E INNOVACI N AGREEMENT TECHNOLOGIES Contents Acknowledgments 1 Introduction Motivation s aaae a hi BE a ae nes we Ae Ge ae ae te ee 1 1 2 Quick Start Installing Magentix2 Desktop Edition 000 2 1 2 2 2 1 1 2 1 2 2 1 3 2 1 4 Requirements semia A wate seat ee ae dyes Installation of Magentix2 Desktop Magentix2 installation description o o Unistalling Magentix2 Desktop Edition Installing Magentix2 Java Based Desktop Edition 2 2 1 2 2 2 2 2 3 2 2 4 Requirements 2 e e E e e E a a a a E e e Installation of Magentix2 Desktop oaoa Magentix2 installation descripti0n o Unistalling Magentix2 Desktop Edition 2 3 Developing and executing a first agent o o 3 Programming Agents Basic classes for building agents BaseAgent and SimpleAgent 3 1 3 2 3 1 1 3 1 2 3 1 3 3 1 4 3 1 5 3 1 6 3 1 7 BaseA gent le iS a a ea Ba aa A SimpleAgent iii go ae a ek ede ed hs Initialization Tasks 2 oaa ee Connecting to the Qpid Broker o oo Running Agents e Optional Meth
67. JasonAgent new AgentID bob src test java jasonTest_1 demo asl arch agent start In the code shown above first an instance of MagentixAgArch class called arch is created then a JasonAgent called agent is created in order to create a JasonAgent it is necessary to specify its AgentID the file with the AgentSpeak L program that the interpreter will execute and the agent architecture the agent will use in this case a standard MagentixAgArch Finally start the execution of the agent starts It is possible to modify the agent architecture in the following example the MagentixAgArch default architecture will not be used instead a new one is created which extends from Magen tixAgArch public class SimpleArchitecture extends MagentixAgArch this method just adds some perception to the agent Override public List lt Literal gt perceive List lt Literal gt 1 new ArrayList lt Literal gt l add Literal parseLiteral x 10 return 1 This new architecture called SimpleArchitecture just adds a perception to the agent overriding the method perceive of the MagentixAgArch class As said before usually the architecture is modified in order to add new actions to the agent this could be done just overriding the method act ActionExec action List lt ActionExec gt feedback of the archi tecture This method receives an action as an argument and a list of action executions called fe
68. SQL the complete structure of the database from the Thomas sqI file This file is also located into the directory bin MySQL In order to load this file the MySQL Administrator tool should be opened and then the Restore Backup option must be selected choosing the Thomas sq backup file to be restored An exam ple of this procedure can be shown in the figure 6 2 File Edit View Tools MySQL Enterprise Help Ef Server Information o Service Control pr Startup Parameters 8a User Administration amp Server Connections g Replication Status Catalogs Backup File to Restore gt thomas home joabelfa workspace j THOMASMAGENTIX2 thoma Change Path Replication not enabled Figure 6 2 Restoring the Thomas sql backup file in the Restore Backup option of the MySQL Administrator The next required step is to add a new user to the THOMAS schema in the User Administration option of the MySQL Administrator tool see Figure 6 3 The required fields must be fulfilled with the following information User thomas Password thomas 144 File Edit View Tools MySQL Enterprise Help Bf server Information 6 3 MySQL User Information Schema Privileges Resource Limits ea Service Control P new_user E Startup Parameters 2 Login Information g Server Connections B Haai MySQL User Er Server Logs New Password G Backup Restore Backup Confirm Password g Replication Status Login
69. Stop Magentix bat 2 Deleting Magentix2 installation directory gt cd gt rmdir Magentix2 2 3 Developing and executing a first agent This section explains step by step how to program a Magentix2 agent The images shown here correspond to the Eclipse IDE but everything should be similar in any other IDE Magentix2 li brary works with jdk1 6 which is available at http www oracle com technetwork java javase downloads index html 2 Quick Start 11 The first step is to start Eclipse and create a new project MyFirstAgent The java library magentix2 2 01 jar with dependencies zip has to be included in the project as a referenced li brary Magentix2 platform and the agents running on it need a configuration folder with two files Settings xml and loggin xml Settings xml configures all the parameters related to the platform functionality like mySQL parameters or how agents connect to QPid broker Loggin xml is the configuration file for the Magentix2 logger in which is speci fied where log messages are displayed Magentix2 uses log4j as debugger for more informa tion about this software please refer to http logging apache org log43 1 2 manual html There is a valid configuration folder for any Magentix2 project in the bin sub folder of Magen tix2 installation folder In this example project this configuration folder will be used Thus it is only necessary to copy the folder Magentix2 bin configuration
70. What agents can regis ter deregister roles Any agent from this organization Creator What agents can allo cate deallocate roles Agents from other organizations Any agent from this organization Agents from this organization with Position Creator or Position Supervisor What agents can re quest public informa tion Any agent from any organization What agents can re quest private infor mation Any agent from this organization What agents can re quest information about organizations Any agent from any organization What agents can re quest information about attributes of the roles Any agent from this organization or any agent from its parent unit What agents can ac quire roles with acces sibility external Any agent from any organization Any agent from any organization But it is not allowed to acquire a role with Position Creator or Position Supervisor if the agent already plays a role with Position Subordinate in the organization What agents can ac quire roles with acces sibility internal in the organization Any agent from this organization or any agent from its parent unit Any agent from this organization or any agent from its parent unit But it is not al lowed to acquire a role with Position Cre ator or Position Supervisor if the agent already plays a role with Position Subor dinate in the organizati
71. a trace manager agent TM explained in section 3 8 to avoid the supplanting of this user agent The functionality of MMS has been SFor example to accept users issues for the Fabrica Nacional de Moneda y Timbre FNMT download and im port this certificate http www cert fnmt es index php cha cit amp sec 4 amp page 139 amp lang es 158 6 6 Configuring security limited in order to not issue a certificates for a TM user Therefore the certificate for TM agent will be created manually by means of the following steps e Importing the CA certificate in to the key store needed for client authentication keytool import trustcacerts alias MagentixCA file CA_db rootca crt keystore keystore jks The PASSWORD_USERKEYSTORE is required lt file gt the rootca crt Section 6 6 4 1 shows how to obtain this file e Generating keys for the TM certificate keytool genkey alias TM keyalg RSA dname CN TM O Magentix keystore keystore jks Pressing enter when prompted for the password to select the same password as the key store The PASSWORD_USERKEYSTORE is required e Creating a certificate request keytool certreq alias TM keystore keystore jks file tm csr The PASSWORD_USERKEYSTORE is required e Signing the certificate request using a CA certificate certutil C d CA_db c MagentixCA a i tm csr 0 EMCEE The PASSWORD_CA
72. also sends a reject message to the rest of the dealers 3 4 Advanced conversational agents CAgents CAgents facilitate the use and management of conversations CAgents use CFactories and CProcessors these two components control ongoing conversation and create new ones On the one hand CFactories act as Interaction Protocols IPs and are in charge of creating new CPro cessors On the other hand CProcessors act as instances of CFactories that is conversations CFactories have a graph made up of states and arcs A graph specifies the sequence of actions that a conversation which is following that protocol has to take Each state represents a specific action and each arc represents a possible transition between two states A collection of states actions has been defined e Begin This state represent that the agent starts the conversation e Final This state represent that the agent ends the conversation e Send In this state the agent sends a message e Wait When a agent reaches this state the conversation halts until a message is assigned to the conversation Then according to the type of the arrived message an specific subsequent Receive state is executed The type of the message is defined by its header e Receive This state must be preceded by a Wait state In this state the agent receives a message Each Receive state manages messages with a specific set of headers CFactories can be initiator or participant the use of ea
73. an use the SearchService service to find required services The method SearchService of the SFproxy makes a request to this service with the following parameters 4 Virtual Organizations 119 List of inputs of the service to search These inputs has to be specified as types of an ontology In ServiceTools class the main types integer float double string boolean are specified as constants to be easier to the developer List of outputs of the service to search These inputs has to be specified as types of an ontology as the inputs explained before List of keywords of the text description of the service to search Each String added to this list will compute to find it in the text description of the service profiles registered in the SF SearchService inputs outputs keywords profile similarity Agent ServiceProfile 1 0 Vv ServiceProfile2 0 75 Figure 4 8 Agent interaction protocol to search service The following example shows how to search for a service The desired service should have the word addition in its description two double inputs an one double output 2 ArrayList lt String gt searchInputs new ArrayList lt String gt 3 ArrayList lt String gt searchOutputs new ArrayList lt String gt 4 ArrayList lt String gt searchKeywords new ArrayList lt String gt 6 searchInputs add ServiceTools OntologicalTypesConstants DOUBLE 7 searchInputs add Se
74. and additional information on the user Additional Information The user will have to enter this MySQL username to connect to the MySQL server Type in a new password if you want to set a new value thomas seek ep Type the new password again to confirm The user s full name Additional description of the user The user s email address Optional messager information tel fax ICQ etc A Icon assigned to the user Change L _ Full Name User Accounts Ao scription 4 debian sys maint Email 3 root Contact Information thomas 20 Icon Processing backup file dh New User Discard Changes Apply Changes Figure 6 3 Adding the necessary user information into the THOMAS schema in the User Administrator option of the MySQL Administrator tool The ServerName databaseName use rName and password entries must be also configured in the Settings xml file located in the Magentix2 configuration directory The parame ters that affect MySQL configuration in the Settings xml file are the following lt Properties mysql gt lt entry key serverName gt localhost lt entry gt lt entry key databaseName gt thomas lt entry gt lt entry key userName gt thomas lt entry gt lt entry key password gt thomas lt entry gt On the other hand the THOMAS framework uses Apache Jena for manage the semant
75. ard those premises that match the problem to solve and other extra premises that do not appear in the description of this problem but that have been also considered to draw the conclusion of the argument and optionally any knowl edge resource used by the proponent to generate the argument domain cases argument cases and argumentation schemes This type of argument is called a support argument On the other 52 3 6 Argumentative Agents hand if the argument attacks the argument of an opponent the support set can also include any of the allowed attack elements of our framework These are distinguishing premises counter examples or critical questions This other type of argument is called an attack argument Definition 3 6 1 Distinguishing Premise A distinguishing premise is a premise that does not appear in the description of the problem to solve and has different values for two cases or a premise that appears in the problem description and does not appear in one of the cases Definition 3 6 2 Counter Example A counter example for a case is a previous case i e a domain case or an argument case that was deemed acceptable where the problem description of the counter example matches the current problem to solve and also subsumes the problem description of the case but proposing a different solution Definition 3 6 3 Critical Question A critical question is a question associated to an argu mentation scheme that represents a
76. asses for building agents BaseA gent and SimpleAgent oooooooo o oo 17 3 2 Agent Communication 66 23 3 3 Basic conversational agents QueueAgents 27 3 4 Advanced conversational agents CAgents 34 3 5 BDI Agents JasonAgents 46 3 6 Argumentative AgeNMtS 49 3 7 Launching agents with security enabled 74 3 8 Tracing ServiC oo ooooooo o o 80 3 1 Basic classes for building agents BaseAgent and Sim pleAgent 3 1 1 BaseAgent In order to create a basic Magentix2 agent it is necessary to define a class which extends the class es upv dsic gti_ia core BaseAgent A unique identifier with a new instance of Agen tID class must be associated to the agent and it is also necessary to implement the logic of the agent in the execute method The following code shows how to implement a new BaseA gent class named SenderA gent This agent only shows its name by the screen 17 18 3 1 Basic classes for building agents BaseAgent and SimpleAgent import es upv dsic gti_ia core ACLMessage import es upv dsic gti_ia core AgentID import es upv dsic gti_ia core BaseAgent public class SenderAgent extends BaseAgent public SenderAgent AgentID aid throws Exception super aid public void execute System out println Executing I m getName 3 1 2 SimpleAgent In order to create a simple Magentix2 agent
77. at Stop Magentix it stops services Tomcat MySQL Qpid and HTTPInterface and platform agents OMS SF TM and bridge agents The commands needed to exe cute this script are cd Magentix2 bin sudo sh Stop Magentix sh In Windows architecture systems the instructions are gt cd c Magentix2 bin gt Stop Magentix bat In addition also the following sub directory is included in bin configuration sub directory includes the Settings xml and loggin xml configura tion files which are necessary to launch Magentix2 user agents e docs includes javadoc and the Magentix2 documentation in Pdf format e lib includes Magentix2 library an all additional libraries required by Magentix2 How to import this library in projects is explained in section 2 3 10 2 3 Developing and executing a first agent e examples includes some examples of Magentix2 agents implementation e src includes Magentix2 sources e thomas includes all services required by THOMAS and Magentix2 platform It also includes a user web service example 2 2 4 Unistalling Magentix2 Desktop Edition Magentix2 is very simple to remove from one system The steps to uninstall are 1 Stopping Magentix2 platform cd bin sudo sh Stop Magentix sh 2 Deleting Magentix2 installation directory S cd sudo rm rf Magentix2 In Windows architecture systems the instructions are 1 Stopping Magentix2 platform gt cd bin gt
78. ath domCBRindex domCBRthreshold iniArgCasesFilePath finArgCasesFilePath wPD wSD wRD WAD WED wEP agent start where socialEntity represents the social entity name role preference values created for this agent friendsList is an ArrayList with the social entities that represent the friends of the agent the agents that it knows depenRelsList is an ArrayList that represents the de pendency relations that the agent has with the rest of agents of the system group represents the group that the agent belongs and commitmentStorelD represents the identifier of the com 68 3 6 Argumentative Agents mitment store resource There are also two ArrayList called iniDomainCasesFilePath and finDomainCasesFilePath with the file paths that store the initial and final domain cases case bases In addition domCBRindex establishes an index in the sense of a HashTable index to retrieve cases from the domain cases case base and domCBRthreshold establishes a threshold over which two cases are considered as similar The iniArgCasesFilePath and finArgCases FilePath ArrayLists represent the file paths that store the initial and final argument cases case bases Finally the wPD wSD wRD wAD wED and wEP are the weights assigned to the parameters to compute the supportFactor Different combinations of these weight allow argumentative agents to follow different argumentation strategies 3 6 3 2 How to create your own Magentix2 Arg
79. ative msg getContent if msg getContent contentEquals GUAAAAAA TraceInteract cancelTracingServiceSubscription this MESSAGE_SENT_DETAIL new AgentID Timmy TraceInteract cancelTracingServiceSubscription this MESSAGE _SENT_DETAIL new AgentID Bobby finish true public void onMessage ACLMessage msg if msg getPerformativelnt ACLMessage AGREE amp amp msg getContent contentEquals GO TO THE PARK System out printin Daddy this getName MS gg ets endo nano aS AS IS Ges getPerformative msg getContent if msg getSender getLocalName contentEquals Bobby A Bobby_agree true if msg getSender getLocalName contentEquals Timmy wD Timmy_agree true 3 8 7 Boy class package TraceDaddy import es upv dsic gti_ia core ACLMessage 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 96 3 8 Tracing Service import es upv dsic gti_ia core AgentID import es upv dsic gti_ia core BaseAgent public class Boy extends BaseAgent private int age private boolean finish false AgentID dad public Boy AgentID aid int age AgentID dad throws Exception super aid this age age this dad dad SUSE SMS OLEA A A ES SEN Mi Wipe hrs Sis getName an
80. cat MySQL Qpid and HTTPInter face and platform agents OMS SF TM and bridge agents The commands needed to execute this script are cd Magentix2 bin sudo sh Start Magentix sh Stop Magentix sh it stops services Tomcat MySQL Qpid and HTTPInterface and platform agents OMS SF TM and bridge agents The commands needed to execute this script are cd Magentix2 bin sudo sh Stop Magentix sh In addition also the following sub directories are included in bin configuration sub directory includes the Settings xml and loggin xml configura tion files necessary to launch Magentix2 user agents security sub directory includes all required files to launch Magentix2 in secure mode Magentix2 is launched without security to enabled security refer to section 6 6 3 2 2 Installing Magentix2 Java Based Desktop Edition docs includes javadoc and the Magentix2 documentation in Pdf format lib includes Magentix2 library an all additional libraries required by Magentix2 How to import this library in projects is explained in section 2 3 examples includes some examples of Magentix2 agents implementation sre includes Magentix2 sources thomas includes all services required by THOMAS and Magentix2 platform It also includes a user web service example 2 1 4 Unistalling Magentix2 Desktop Edition Magentix2 is very simple to remove from one system The steps to uninstall are 1 2
81. ce specification to analyze it as a parameter in the constructor of the class see the example This specification can be obtained with the method Get Service of the SFProxy class Once the service specification is obtained the oracle can be asked about any field in the ser vice specification The available methods for the Oracle class can be found in the Javadoc documentation of the project obtain the the service OWL S specification String serviceOWLS sfProxy getService ServiceProfile load in the oracle the service OWL S specification and parse it Oracle oracle new Oracle serviceOWLS access to the service OWL S information through the oracle ArrayList lt String gt service_inputs oracle getOwlsProfileInputs ArrayList lt Provider gt providers oracle getProviders ArrayList lt String gt providersGroundingWSDL oracle getProvidersGroundingWSDL 4 3 Programming Agents that Offer Services This section describes how an agent that offers services to the other agents inside the organiza tion can register announce and provide its services 4 3 1 Acquire Role e Registration of an agent on the platform The agents request to be registered as a participant of the THOMAS platform using the AcquireRole service 116 4 3 Programming Agents that Offer Services AcquireRole participant virtual OMSproxy Agent Figure 4 4 Agent interaction protocol to ac
82. ceived and generated are taken into account to act in consequence and move to the next state Inside each state the corresponding actions are performed using the necessary calls to the different functions of the agent shown in Table 3 9 of Section 3 6 3 2 Also argumen tative agents can make queries to the commitment store and retrieve information about their argumentation dialogue Recall that since argumentative agents are a special type of Magen tix2 cAgents agents queue messages and send or receive them in the corresponding send and receive states see Section 3 4 The behaviour of the commitment store resource has been implemented by overwriting the abstract class CommitmentStore_Protocol java of the cAgents protocols package in the Commitment Store java class The set of allowed locutions of our argumentation protocol are codified as constants in the Argumentation Participant protocol of the cAgents protocols package These locutions are the following e OPENDIALOGUE with this locution an agent opens the argumentation dialogue ask ing other agents to collaborate or negotiate to solve a problem that it has been presented with e ENTERDIALOGUE with this locution an agent engages in the argumentation dialogue to solve the problem e WITHDRAWDIALOGUE with this locution an agent leaves the argumentation dia logue e ADDPOSITION with this locution an agent puts forward its position as its proposed solution to solve th
83. ch type depends on the role the agent will play in the conversations On the one hand initiator CFactories start conversations when directed by agent s logic i e they do not depend on external stimuli in order to start a new conversation On the other hand participant CFactories start a CProcessor when they receive a message with the appropriate message parameters These parameters are specified using a message filter associated to the participant CFactory The transition between two states occurs when the agent receives or sends a message related to that specific conversation CProcessors are in charge of making these transitions as well as executing the actions of each state of the conversation 3 Programming Agents 35 Receive Failure Receive Inform done Figure 3 5 CFactory for FIPA Request Interaction Protocol for the initiator agent When a CProcessor is created it has a copy of the graph specified in the CFactory that created the CProcessor During the conversation the CProcessor will execute the actions of the state the conversation is currently at and it will change the state of the conversation as new messages are sent and received As each CProcessor has its own graph an ongoing conversation can be dynamically modified without affecting the IP the conversation is following or other ongoing conversations which follows that IP In figure 3 5 an example of an IP transformed into a graph associated to a CFactory i
84. city no repudiation and mutual authentica tion of the agent comunications a security module for Magentix2 platform was implemented If the security module is enabled in the platform in which will connect setting the public key infraestructure and configuring the security properties are necessary The basic elements of this public key infrastructure are e Asymetrical key pair This is used to sign and encrypt information messages 3 Programming Agents T5 e X 509 Certificate This is a self signed certificate with the information of the user which guarantees the user identity e keystore Itis a file that contains the X 509 User Certificates which is needed to connect with the platform The keystore is protected by a password hence this file must never be disclosed to others e Trustore It is a file that contains a list of trusted parties The trusted parties will be the Magentix2 platform to which the user connect 3 7 1 Creating key pair If a key pair and a certificate issued by a public entity must be trusted for the platform is available the explanation continues in the section 3 7 3 if not the next steps must be followed For generating the key pair this command must be executed in a linux terminal keytool genkey alias alias_name keyalg RSA YA dname CN alias_name O Magentix storepass mysecretpassword keypass mysecretpassword keystore keystore jks The result of this command is a new
85. content of the locution to assert the argument To make this selection Magentix2 argumentative agents can use different tactics From our point of view a tactic consist on assigning more or less weight to the elements of an argument support factor used to select positions and arguments The support factor estimates how suitable a current position or argument is in view of the suitability of similar arguments to support or attack similar positions or arguments put forward in previous argumentation di alogues which are stored in the agent s case base of argument cases In this way the agent can select the most suitable position or argument to propose next The support factor is computed by a linear combination of several parameters e Persuasiveness Degree PD is a value that represents the expected persuasive power of an argument by checking how persuasive an argument case with the same problem description and conclusion was in the past 3 Programming Agents 55 e Support Degree SD is a value that provides an estimation of the probability that the conclusion of the current argument was acceptable at the end of the dialogue e Risk Degree RD is a value that estimates the risk for an argument to be attacked in view of the attacks received for an argument s with the same problem description and conclusion in the past e Attack degree AD is a value that provides an estimation of the number of attacks received by a similar
86. create a CProcessor first it is necessary to define the states and the transitions that compose the graph associated to the CProcessor This can be done in the execution method of the agent Every conversation starts with a begin state called BEGIN In the first line of the code below a new CFactory is created The parameters passed to the constructor are the CFac tory s name a message filter that will determine which messages will make this CFactory to start a new CProcessor acting as a conversation how many CProcessors this CFactory can man age simultaneously and finally a reference to the agent which owns the CFactory Specifically this CFactory called TALK will create the CProcessor when the agent receives messages with propose performative and it can only manage one CProcessor at a time When a CFactory is created it has already a CProcessor template predefined by default This template is from new instances of CProcessor will be created This default CProcessor template has to be mod ified by the user in order to create its own IPs The begin state of the CProcessor template is defined by default It starts creating a new IP modifying this predefined begin state In line 8 this begin state is got from the template In the lines below a new method for this state is cre ated This method will be executed when the conversation reaches this begin state Therefore this method will be executed when the conversation starts Ever
87. d I m this age years old public void execute ACLMessage msg int counter 5 while finish if this age lt 5 msg new ACLMessage ACLMessage REQUEST msg setSender this getAid E OUR CI ON msg setContent Give me your toy elsef msg setContent GUAAAAAA COUNTS y msg setReceiver new AgentID qpid Timmy localhost SOCOM Mee send msg Dry Thread sleep 1000 catch InterruptedException e e printStackTrace 42 43 44 45 46 47 48 49 50 St 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 3 Programming Agents 97 public void onMessage ACLMessage msg if msg getSender getLocalName contentEquals dad getLocalName Daddy if msg getPerformativelnt ACLMessage REQUEST if msg getContent contentEgquals GO TO THE PARK finish true ACLMessage response_msg new ACLMessage ACLMessag AGREE response_msg setSender this getAid T response_msg setContent GO TO THE PARK response_msg setReceiver msg getSender send response_msg else You no daddy if msg getPerformativelnt ACLMessage REQUEST ACIMessage response_msg new ACLMessage ACLMessag REFUSE response_m
88. d for CA is introduced Afterwards it will be referenced as PASSWORD_CA e Creating a Self signed Root CA certificate specifying the subject name for the cer tificate MagentixCA certutil S d CA_db n MagentixTheCA s CN MagentixCA O Magentix t CT x 2 For this purpose certutil http www mozilla org projects security pki nss tools certutil html and keytool http download oracle com javase 1 3 docs tooldocs win32 keytool htm1 commands are used 154 6 6 Configuring security The PASSWORD_CA is required The system asks about same aspects and the following answers must be proportioned 66 99 Typing y for Is this a CA certificate y N Pressing enter for Enter the path length constraint enter to skip lt 0 for unlimited path Typing n for Is this a critical extension y N e Extracting to a file the CA certificate from the CAs certificate database certutil L d CA_db n MagentixCA a o CA_db rootca crt 6 6 4 2 Qpid broker A certificate identifies the broker which will be signed by the Magentix CA The following steps show how to create Qpid certificates e Creating a certificate database for the Qpid Broker S mkdir broker_db S certutil N d broker_db In this step the password for the Qpid broker is introduced Afterwards it will be refer enced as PASSWORD_BROKER e Importing the CA certificate into the brokers cert
89. d in the directory opt qpid and 5672 is the port configured to receive connections 6 1 1 Magentix2 installation description The following folders are created in the selected installation directory by default 7Magentix2 both when full or custom installation mode is selected depending on the selected packages e bin includes the executable files and folders required to launch and start the platform and services These are 6 Platform administration 139 Start Magentix sh it launches services and base agents of the platform 7 Execute this script is not necessary the first time because the installer program do it Stop Magentix sh it stops services and agents of the platform Launch MagentixA gents sh it launches the Magentix2 base agents OMS SF TM and bridge agents Stop MagentixAgents sh it stops the Magentix2 base agents This services can be managed separately existing a subdirectory per each service MySQL start stop and configure MySQL service scripts Tomcat start and stop Apache Tomcat service scripts Qpid start and stop Apache Qpid service Note All the commands could been executed as follows cd Magentix2 bin or Magentix2 bin subdirectory sh script_name sh In addition also the following sub directories are included configuration sub directory includes the Settings xml and loggin xml configura tion files necessary to launch Magentix2 user agents
90. d similarity threshold If one or more valid solutions can be generated from the selected domain cases the agent will be able to defend a position in the dialogue We consider a valid solution any domain case from the domain CBR with one or more solutions and with a similarity degree greater than the given threshold Moreover the agent makes a query to its argumentation CBR for each possible position to defend With these queries the suitability degree of the positions is obtained This degree represents if a position will be easy to defend based on past similar argumentation experiences Then all possible positions to defend are ordered from less to more suitability degree 3 When the agents have a position to defend a proposed solution these positions are stored by the commitment store such that other agents can check the positions of all dialogue participants Every agent tries to attack the positions that are different from its 74 3 7 Launching agents with security enabled position 4 The argumentation process consists on a series of steps by which agents try to defend its positions by generating counter examples and distinguishing premises for the positions and arguments of other agents A counter example for a case is generated by retrieving from the domain case base another case that matches the features of the former but has a different conclusion Similarly distinguishing premises are computed by selecting such premises that
91. e AgentID tms_aid BaseAgent applicantAgent String serviceName String description unpublishTracingService BaseAgent applicantAgent String serviceName unpublishTracingService AgentID tms_aid BaseAgent applicantAgent String serviceName tms aid AgentlID of the Trace Manager which will process the request If not specified the request is directed to the default Trace Manager TM applicantAgent Agent which is publishing the tracing service serviceName String identifying the tracing service which is being published or un published description Human readable description of the tracing service which is being pub lished where the running agent this publishes a tracing service called TracingService_1 which is described as An example of tracing service Once the running agent is done sharing these trace events it can unpublish the tracing service by invoking the corresponding method referring to the already published tracing service unpublishTracingService this TracingService_1 3 8 3 2 Tracing service subscription Before receiving any trace event agents have to request the corresponding tracing service by invoking requestTracingService This subscription can be cancelled later by invoking cancelTracingServiceSubscription It is also possible to subscribe to all available tracing services offered by any tracing entity in the system by invoking the method requestAl
92. e code the result of the conversation is shown on the console filter new MessageFilter performative PROPOSE CFactory talk new CFactory TALK filter 1 this A CProcessor always starts in the predefined state BEGIN We have to associate this state with a method that will be executed at the beginning of the conversation BeginState BEGIN BeginState talk cProcessorTemplate getState BEGIN class BEGIN_Method implements BeginStateMethod 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 40 3 4 Advanced conversational agents CAgents public String run CProcessor myProcessor ACLMessage msg In this example there is nothing more to do than continue to the next state which will send the messag return PROPOSE al y BEGIN setMethod new BEGIN_Method SendState PROPOSE new SendState PROPOSE class PROPOSE Method implements SendStateMethod public String run CProcessor myProcessor ACLMessage messageToSend messageToSend setContent Would you like to come with me to Phere Memarcns E messageToSend setReceiver new AgentID Sally messageToSend setSender myProcessor getMyAgent getAid return WAIT PROPOSE setMethod new PROPOSE Method talk cProcessorTemplate registerStat ROPOSE
93. e correct one to apply to solve the problem at hand The position generation is made in two steps First the agent retrieves from its Domain CBR the most similar domain cases to the current problem to solve by using the retrieve method of the DomainCBR java class With them the agent is able to propose its position in view of the solutions applied to similar problems in the past Then the agent evaluates the suitability of each position by using its Argumentation CBR to compute the support factor pa rameters by using the method get Degrees of the ArgCBR java class Then each position 58 3 6 Argumentative Agents Method Description addPosition Returns an ACLMessage with the locution ADDPOSITION and a Position to send to the Commitment Store createMessage Creates and returns an ACLMessage with the message arguments Messages are managed by the main execution method of cAgents and are sent and received in the corresponding send and receive states see Section 3 4 generateAttackArgument Returns an attack Argument against the given argument of the given agent identifier generateCEAttack Returns a counter example attack Argument against the agent of the given agent identifier and its given premises generateDPAttack Returns a distinguishing premises attack Argument against the agent of the given agent identifier and its given premises generatePositions Returns an ArrayList of Position with all generated pos
94. e problem under discussion in the argumentation dialogue e WHY with this locution an agent challenges the position or the argument of another agent asking it for a support argument 62 3 6 Argumentative Agents e NOCOMMIT with this locution an agent withdraws its position as a solution for the problem under discussion in the argumentation dialogue e ASSERT with this locution an agent sends to another agent an argument that supports its position e ACCEPT with this locution an agent accepts the argument or the position of another agent e ATTACK with this locution an agent challenges the argument of another agent Also there are other allowed locutions to manage the life cycle of argumentative agents and get information from the commitment store e FINISHDIALOGUE is a locution to inform an agent that it must perform the necessary actions if any before withdrawing from the dialogue e DIE is a locution to inform an agent that it must shutdown its execution e GETALLPOSITIONS is a locution to request the commitment store the list of available positions at a certain step of the dialogue The commitment store uses the same locution to answer this request Figure 3 10 shows the state machine that defines the behaviour of an agent that follows the Magentix2 Argumentation_Participant protocol In the figure dotted states repre sent wait states where the argumentative agent waits for messages from other agents or the
95. e results of the operation performed The initiator ContractNetInitiator has two main methods the handlePropose method which is called each time a response is received and the handleAllResponses method which is called when all responses are received or the timeout is exceeded The responder agent has the han dleAcceptProposal and handleRejectProposal methods which are called depending on whether the proposal was accepted or not and their main characteristic is that both of them receive as input parameters all the messages exchanged by both agents so far 3 3 3 Running QueueAgents Once defined the protocol we have to create a new instance and add it to the agent tasks method addTask In the initiator role it is necessay to create and fill in the appropriate message for the desired protocol For example for the protocol request ACLMessage msg new ACLMessage ACLMessage REQUEST msg setReceiver new AgentID HospitalAgent msg setProtocol InteractionProtocol FIPA_REQUEST MsG seuconeent accident stor Ya VOM mt msg setSender this getAid 3 Programming Agents 33 this addTask new FIPARequestInitiator this msg For the responder it is needed to create a template with the desired protocol MessageTemplate template new MessageTemplate InteractionProtocol FIPA REQUEST this addTask new FIPARequestResponder this template When a ta
96. e tracing service UNPUBLISH_ERROR Impossible to unpublish the tracing service SUBSCRIPTION_ERROR Impossible to subscribe to the tracing service UNSUBSCRIPTION_ ERROR Impossible to unsubscribe from the tracing service AUTHORIZATION ERROR Unauthorized to do so Some of the methods available in es upv dsic gti_ia trace TraceInteract assume that a default trace manager called TM is running while others allow specifying the Trace Manager to which requests are to be directed Actions related to tracing services can be classified in three main groups which are explained in more detail in the following sections Publication Unpublication of tracing services Section 3 8 3 1 subscription unsubscription to from tracing services Section 3 8 3 2 and listing of tracing entities or services Section 3 8 3 3 3 8 3 1 Tracing service publication In order to publish and unpublish tracing services agents have to use respectively the meth ods publishTracingService and unpublishTracingService These methods are de scribed in more detail in Table 3 12 An example of tracing service publication can be publishTracingService this TracingService_1 An example of tracing service 3 Programming Agents 85 Table 3 12 Tracing service publication and unpublication methods publishTracingService BaseAgent applicantAgent String serviceName String description publishTracingServic
97. eces em sit nad then we can set the return type of the doRequest method to String and use it as a return value for this method return WAIT We want the user to implement his her method here protected abstract void doReceive CProcessor myProcessor ACLMessage msg class RECEIVE _Method implements ReceiveStateMethod public String run CProcessor myProcessor ACLMessage messageReceived doReceive myProcessor messageReceived return FINAL 40 41 42 43 44 45 46 47 48 49 50 3 Programming Agents 45 protected void doFinal CProcessor myProcessor ACLMessage messageToSend messageToSend myProcessor getLastSentMessage class FINAL Method implements FinalStateMethod public void run CProcessor myProcessor ACLMessage messageToSend doFinal myProcessor messageToSend Once all the states are defined the next step is to create a method that returns a new CFactory In this method new states are created and the methods defined before are assigned to them The transitions between the states are also defined in this method Depending on the IP some parameters will be needed In this case it is only necessary to specify the name of the CFactory the maximum number of simultaneous conversations the agent who owns the CFactory and the timeout for the wait state The code of this method is shown below public CFactory newFactory
98. ecture package Within all of the protocols implemented agents can play both initiator and responder role These roles implement different behaviors The initiators are executed once while responders are executed cyclically so they will return to its initial state after reaching the final one The set of classes in the es upv dsic gti ia architecture package have been designed so that programmers do not need to deal with neither message sending nor protocol status monitoring Thus programmers only have to define what should be done in each state of the protocol and prepare messages before sending The actions performed in each state are defined by handlers for initiator roles and preparers for responder roles e Handlers A handler is a method which is executed when a specific protocol state 1s reached for agents playing initiator roles Each protocol has a handler per each state it can 3 Programming Agents 29 reach Although there are default handlers which do nothing defined for each protocol agent programmers can overload each handler with the functionality they require in each protocol state 1 protected void handleAgree ACLMessage agree 2 logger info Good news 3 e Preparers Preparers are similar to handlers but are executed when the agent plays the responder role in the protocol Messages must be filled carefully because leaving a field empty can interrupt the entire protocol Therefore we encourage the use of
99. edback In the code below it is shown how to manage a new external action of the agent 48 3 5 BDI Agents JasonAgents called doAction Override public void act ActionExec action List lt ActionExec gt feedback getTS getLogger info Agent getAgName is doing action getActionTerm if action getActionTerm equals doAction perform the action set the result for example always true action setResult true add the executed action to the list of action executions feedback add action The code in AgentSpeak L is written in a different file the path to the file is passed as an argument to the constructor of the JasonAgent class A sample code of an AgentSpeak L program is shown below vall VALED v1 X source Ag Ag self lt print Received tell vl X from Ag goto X Y source Ag true lt printlin Received achieve goto X Y from Ag ee Oe BNL NE lt lt 6 SO NES kqml_received Sender askOne fullname ReplyWith true lt send Sender tell Maria dos Santos ReplyWith send the answer 3 Programming Agents 49 3 6 Argumentative Agents This section describes the argumentative agents API of Magentix2 This API allows agents to engage in argumentation dialogues to reach agreements about the best solution for a problem that must be solved First we introduce the theory of the a
100. egatively to REFUSE NOT_UNDERSTOOD or FAIL URE performative The following code shows how to implement a responder rol public class Responder extends FIPARequestResponder public Responder QueueAgent agent super agent new MessageTemplate InteractionProtocol FIPA_REQUEST protected ACLMessage prepareResponse ACIMessage msg protected ACLMessage prepareResultNotification ACLMessage inmsg ACLMessage outmsg 1 The following code shows how to implement an initiator rol class Initiator extends FIPARequestInitiator public Initiator QueueAgent a ACLMessage msg 3 Programming Agents pro pro pro pro pro 3 3 2 2 FIPA Query ESE eS SS USC ESE 31 super a msg ted void handleAgree ACLIMessage agree ted void handleRefuse ACLMessage refuse ted void handleNotUnderstood ACLMessage notUnderstood ted void handleInform ACLMessage inform ted void handleFailure ACLMessage failure This protocol allows agents to request other agents to query whether a particular proposition is true or false query if and to query for some identified objects query ref Depending on the type of request the messages can be 1 Query If or Query Ref it contents the request 2 Agree when the agent accepts the request 3 Refuse in the case the agent rejects the request 4 Failure in the case an error occurred
101. ence order and for each 3 Programming Agents group of positions that promote the same value agents sort them by their suitability degree The most suitable position is selected as the one that the agent is going to propose and defend first The argumentation API of Magentix2 includes several similarity algorithms to compute the similarity degree SimD in the SimilarityAlgorithms java class Also the Metrics java class includes several metrics to compute distances between cases which are used in the similarity algorithms Table 3 2 shows these methods which belong to the argAgents package Class Method Description Metrics java doDist This method decides about which is the data type of its attributes and return the distance between them Metrics java dist This method calculates the distance between a pair of attributes Sililarity Algorithms java normalizedEuclideanSimilarity Returns a list of the candidate domain cases with a similarity degree to the given domain cases The similarity is calculated using normalized Euclidean distance among the premises Sililarity Algorithms java weightedEuclideanSimilarity Returns a list of the candidate domain cases with a similarity degree to the given domain cases The similarity is calculated using weighted Euclidean distance among the premises Sililarity Algorithms java normalizedTverskySimilarity Returns a list of the candida
102. ength gt lt service description gt Table 3 14 Tracing services and tracing entities listing methods listTracingEntities BaseAgent requesterAgent listTracingEntities AgentID tms aid BaseAgent requesterAgent listTracingServices BaseAgent requesterAgent listTracingServices AgentID tms_aid BaseAgent requesterAgent tms_aid Agent ID of the Trace Manager which will process the request If not specified the request is directed to the default Trace Manager TM requesterAgent Agent which is requesting the list of available tracing entities and ser vices 3 8 4 Domain Independent Tracing Services The platform offers a set of domain independent tracing services Some of them can be re quested by agents in order to receive the corresponding trace events while others are not re questable and the corresponding trace events are received even without having requested them previously this can be seen as a default subscription to the tracing service The rest of the section will describe them as well as how to interpret their correspoding trace events according to the TraceEvent class and its attributes previously described in Section 3 8 2 Domain independent tracing services can be classified in four main groups System agent s lifecycle messaging and tracing service publication These tracing services are included in the class es upv dsic gti_ia coreTracingService 3
103. es Differences among the diverse organization types OMS Proxy Structural services API o ooo OMS Proxy Informative services API oo o o OMS Proxy Dynamic services API oo o OMS Proxy Organizational messaging service API SE Proxy API d ra on Sate a e Sk GM ek St eh oh SS VII Acknowledgments Financial support from the Ministerio de Ciencia e Innovaci n of the Spanish Government under TIN2008 04446 project and under Consolider Ingenio CSD2007 00022 grant is kindly acknowledged IX CHAPTER 1 Introduction 1 1 Motivation lt lt ce ee eee ee eee 1 1 2 Manual Structure ccc cee eee 2 1 1 Motivation Magentix2 is an agent platform for open Multiagent Systems Its main objective is to bring agent technology to real domains business industry logistics e commerce health care etc Magentix2 platform is proposed as a continuation of the Magentix platform The final goal is to extend the functionalities of Magentix providing new services and tools to allow the se cure and optimized management of open Multiagent Systems Nowadays Magentix2 provides support at three levels e Organization level technologies and techniques related to agent societies e Interaction level technologies and techniques related to communications between agents e Agent level
104. esource Path Location Type Y Errors 1item Implicit super constructor BaseAgent is und Senderjava MyFirstAgent src a line7 Java Problem writable Smart Insert 13 1 Figure 2 2 Programming a first agent with Eclipse A Magentix2 agent has three main methods init execute and finalize They are executed in the cited order In the method init the code that has to be executed at the beginning of the agent execution is added The method execute is the main method of the agent and finalize is executed just before the agent ends its execution and it is destroyed In this specific example it is only needed to implement code in the method execute The code of the agent is shown below package agent import es upv dsic gti_ia core ACLMessage 20 21 22 2 Quick Start 13 import es upv dsic gti_ia core AgentID import es upv dsic gti_ia core BaseAgent public class Sender extends BaseAgent public Sender AgentID aid throws Exception super aid public void execute System out printin Hi I m agent this getName and I start my execution ACLMessage msg new ACLMessage ACLMessage INFORM msg setSender this getAid msg addReceiver new AgentID Consumer msg setContent Hi I m Sender agent and I m running on Magentix2 this send msg Following there is an explanation of all the code in the previously shown execute method line by line The agent sa
105. from 1 Jan 1970 at 00 00 00 Epoch originAid Agent ID of the agent which originated the trace event Internally the constructor converts originAidtoa TracingEntity content Any extra data which could be necessary to complement or understand the meaning of the trace event This attribute can be empty Once created trace events can be sent by means of the public method sendTraceEvent TraceEvent tEvent included in the class es upv dsic gti_ia core BaseAgent This method does not create the instance of the trace event and thus it is necessary to invoke the TraceEvent constructor before sending it For instance if an agent wants to create a trace event for a service called SIMPLE_SERVICE it could be made in this way x Creation of the trace event x TraceEvent tEvent new TraceEvent SIMPLE_SERVICE this getAid This is a simple trace event provided by a simple tracing Seale Gu ee Sending the event x send tEvent 3 Programming Agents 83 The class es upv dsic gti_ia core BaseAgent includes a trace event handler method similar to the ACL message handler onTraceEvent TraceEvent tEvent This method executes automatically each time a trace event is received by the agent however it is empty This means that the developer has to write the source code to process trace events The source code in Section 3
106. gent String serviceName cancelTracingServiceSubscription AgentID tms_aid BaseAgent requesterAgent String serviceName tms_aid Agent ID of the Trace Manager which will process the request If not specified the request is directed to the default Trace Manager TM requesterAgent Agent which is subscribing unsubscribing to the tracing service serviceName String identifying the tracing service to which the request refers originEntity Agent ID of the specific agent which offers the tracing service If not specified the subscription unsubscription request is considered to refer to tracing services offered by any tracing entity in the system e lt t entity description list gt List of concatenated tracing entity descrip tions each of which is structured as follows lt entity type gt lt entity identifier length gt lt entity identifier gt e lt entity type gt 0 1 2 meaning agent artifact or aggregation When a list of tracing services has been requested the content of the reply message will be structured as follows e Message content list services lt number of t services gt lt t service description list gt e lt t service description list gt List of concatenated tracing service descrip tions each of which is structured as follows 88 3 8 Tracing Service lt service name length gt lt service name gt lt service description l
107. gent2 new ConsumerAgent new AgentID consumer Once instantiated agents can be launched by calling to their start method Examples agent ESTATE agent2 start 3 1 6 Optional Methods The init and finalize methods are also defined in the es upv dsic gti_ia core BaseAgent Class These methods are automatically executed before and after the execute method The programmer can overwrite these methods in order to include initialization or termination tasks 3 1 7 Running Examples In the examples folder of the Magentix2 package there are some basic examples of Magentix agents e BaseAgent_Example this is an example of sender consumer agents The sender agent sends an ACLMessage to the consumer agent When the ACLMessage arrives to the consumer agents a message is shown 3 Programming Agents 23 SA preparesthe message to the CA CA gets the message from a its message queue FIPA ACL Message Consumer Agent CA Sender Agent SA 8 SA sends the message to the CA ZA FIPA ACL Message QPID Broker Figure 3 3 Messages exchange thought QPID Broker in Magentix2 e SingleAgent_ Example this is an example of sender consumer agents The sender agent sends an ACLMessage to the consumer agent When the ACLMessage arrives to the consumer agents a message is shown The consumer is in blocked state waiting the message 3 2 Agent Communication In Magentix2 each agent has a message
108. he information that the target agent will manage When the HTTP Interface gets the HTTP POST request it reads the JSON object included in the message body of the HTTP POST request The HTTP Interface extracts from the JSON ob ject the field agent_name The content of this field specifies the target agent The content of the field conversation_id of the JSON object will be used as the conversation_id of the ACLMessage that will be sent to the target message Finally the entire JSON is used as the content of the ACLMessage Please note that the entire JSON is used as content therefore the target agent has to be capable to deal with the fields agent _name and conversation_id Magentix2 includes the XStream library which is able to manage JSON objects in java For more information about XStream and JSON please go to http xstream codehaus org json tutorial html For better understanding an example of a valid JSON obect is given below In this example a web page allows users to ask for supermarket products to an agent The user has to specify the type of the product and the maximum price she is willing to pay 5 HTTP Interface 133 Eragent name re MC es GON VS Saito nO VANE ONES E NA A AE CAZAS 08d The HTTP interface does not send the ACLMessage directly to the target agent instead it creates a dummy agent that will send the ACLMessage This functionality allows the HTTP interface to manage multiple and concurrent HTTP POST re
109. he MagentixCA public key to obtain this file please contact with the Magentix2 platform administrator 3 7 5 Configuration The security parameters must be indicated inside the security User properties file and the config uration of the broker connection inside the Settings xml These files are inside the configuration directory e securityUser properties The security User Properties is divided into four sections In the first section the keystore and truststore is configured hence the path and password must be specified as it can be shown in the following example Figure 3 12 3 Programming Agents 77 SS CIS SOS iio gt set the base path for accessing keystore user KeyStorePath full_path keystore jks set the password to keystore KeyStorePassword password set the base path for accessing truststore user TrustStorePath full_path truststore jks set the password to truststore TrustStorePassword password Figure 3 12 First section of the security User properties file In the second section it is indicated if the user certificate used has been issued by a public certificate autorithy in this case the parametre type is others or have been created by the user the type is own If the type selected is others then it is required to configuring the parameters that will be find below the type parameter Again an example is shown below Figure 3 13 set the type of certificates ow
110. hy Send organizational messages These messages will be received for all organization members Register Deregister units and roles Allocate Deallocate roles to other agents Change the hierarchical relations between organizations Acquire other roles Request information about the roles played by other agents Request information about organizations and its elements Subordinate Hierarchy Send organizational messages These messages will be received for all supervisor agents of the organization Acquire other roles Request information about the roles played by other agents Request information about organizations and its elements Table 4 1 Agent behavior depending of its position Visibility Accessibility Behavior Public External Role fully accessible and transparent The role is visible throughout the system External any agent can acquire this role Public any agent can request information about the role Public Internal Role with restricted access although visible throughout the system Internal in order to acquire this role agents must participate in the organization in which the role was registered or in its Parent Organiza tion Public any agent can request information about the role Private External Role fully accessible but with limited visibility External any agent can acquire this role Private information about the role is o
111. ic de scription of the services In order to specify the required parameters for Jena the Settings xml file located in the Magentix2 conf figuration directory will be configured The param eters that affect Jena configuration in the Settings xml file are the following 6 Platform administration 145 lt Properties jena gt lt entry key dbURL gt jdbc mysql localhost thomas lt entry gt lt entry key dbType gt MySQL lt entry gt lt entry key dbDriver gt com mysql jdbc Driver lt entry gt Check if the direction where agents OMS and SF are running is different host from where the MySQL is configured with the data base schema employed by the THOMAS framework If the OMS and SF are running in the same host the configuration by default is correctly Finally all available privileges for THOMAS tables must be assigned to the thomas user Figure 6 4 File Edit View Tools MySQL Enterprise Help Ef Server Information User information Schema Privileges Resource Limits Q Service Control gt 2 thomas anywhere CH Startup Parameters Schema database privileges assigned to the user BlUser Administration Schema Assigned Privileges Available Privileges Server Connections HET S RA SELECT Grants the SELECT privile UJ Health E information R INSERT Grants the INSERT privile Ey Server Logs 8 mysql A UPDATE Grants the UPDATE privil G Backup Ej thoma
112. ificate database and marking it trusted for issuing certificates for SSL client and server authentication certutil A d broker_db n MagentixCA t TC a i CA_db rootca crt The PASSWORD BROKER is required e Creating the server certificate request specifying the subject name for the server certificate certutil R d broker_db s CN broker O Magentix a 0o broker_db server req 6 Platform administration 155 The PASSWORD_BROKER is required Note that this step generates the servers private key so it must be done in the servers database directory e This step simulates the CA signing and issuing a new server certificate based on the servers certificate request certutil C d CA_db c MagentixCA a i broker_db server req o broker_db server crt 2 6 The new certificate is signed with the CAs private key so this operation uses the CAs databases The PASSWORD CA is required For leaving the new certificates of the servers in a file the following actions must be performed Selecting O Server Auth at the prompt Pressing 9 at the prompt Typing n for Is this a critical extension y N Typing n for Is this a CA certificate y N Entering 1 for Enter the path length constraint enter to skip lt 0 for unlimited path gt Typing n for Is this a critical extension y N e Importing adding the ne
113. ile please see section 6 Notice that this is the recommended option private OMSProxy omsProxy new OMSProxy this On the contrary in the second option the url where OMS services are deployed war should be specified in the constructor if the user does not want to use the default url from the settings xml configuration file private OMSProxy omsProxy new OMSProxy this url OMSProxy provides a developer with a set of methods to manage available services this ser vices are divided into different types and sub types Tables 4 4 4 5 4 6 and 4 7 show respec tively these sub types M1 Call M2 Request A Y ET OMSproxy lt M3 Agree eer ee M5 Result OMS M4 Inform Figure 4 2 Interaction between user agent and OMS agent through the OMSProxy 4 2 1 2 SFProxy We can find the SFProxy inside the package es upv dsic gti_ia organization To use its functionality a new instance of the SFProxy class must be created to access the methods contained in the SF In the constructor the agent who executes the service has to be specified There are two options In the first one the url where SF services are deployed is taken from the settings xml configuration file see section 6 Notice that this is the recommended option private SFProxy sfProxy new SFProxy this 4 Virtual Organizations OMS Service Description Parameters RegisterRole Creates a new role within a unit RoleID role U
114. ils of the implementation can be found in the JavaDoc of the files of the package In order to show how the developed system works the data flow for the problem solving pro cess or argumentation process to solve each problem is shown in Figure 3 11 and described below arrows in the figure are labelled with the number of the data flow step that they repre sent 1 First we have some argumentation agents running in the platform and representing the technicians of the call centre The tester agent sends the problem to solve also known as ticket in the common call centre terminology to the group of agents 3 Programming Agents 73 Operators amp Experts Commitment Store Figure 3 11 Data flow for the argumentation process of the helpdesk application 2 Each agent evaluates individually if it can engage in the dialogue offering a solution To do that the agent makes a query to its domain CBR to obtain potential solutions to the ticket based on previous solutions applied to similar tickets To compute such similarity agents use a weighted Euclidean algorithm that searches their domain cases case bases for previous problems that semantically match the category of the current ticket to solve Thus the algorithm retrieves all problems of the same category and of related categories and select those that syntactically match assign the same values to the attributes that match the ticket attributes and overpass a define
115. ilter specifies which messages can be managed by this receive state In this example the filter is set to null therefore this receive state accepts any message The code defining the receive state named RECEIVE starts at line 34 Finally it is defined the final state of the protocol at line 46 Every protocol has to finish in a final state Final states methods can use the responseMessage variable passed as argument as a mean to return a value of the conversation Once the method that will be executed by this state is defined the transitions from other states to this one are added and the state registered in the CProcessor There is only one thing left to finish the CAgent it is necessary to add the CFactory to the set of CFactories of the agent It is possible to add a CFactory as an initiator one or as a pariticipant one depending on the role the agents will play on the conversations generated by the CFactory In this case the CFactory is added as an initiator one Once the CFactory has been added it can create new CProcessors In line 63 the agent starts a synchronous conversation this is the execution of the agent will halt until the conversation ends The method startSyncConver sation is used in order to start a synchronous conversation This method requires the name of the initiator CFactory which will create a new conversation as a parameter The result of the conversation is stored in the variable response In the last line of th
116. ion WHY from these positions that are different to its own Otherwise if there are no positions to challenge and ask for a justification the agent moves back to the state Central Wait Assert in this state the agent that has challenged a position waits for a response from the challenged agent If it receives such a response with the locution ASSERT it tries to rebut the position of the challenged agent and moves to the state Attack Otherwise if the challenged agent cannot provide a justification for its position it must withdraw such position from the dialogue with the locution NOCOMMIT and the chal lenger moves back to the state Central Also if the agent does not receive any response before a specified timeout it will move again to the state Central Attack in this state if an agent has received a justification for a challenged position it tries to generate an attack with the locution ATTACK In this case the agent moves to the state Attack2 However if it is not able to attack the position it will accept it with the locution ACCEPT and move back to the state Central Attack2 once an agent has generated an attack for the position of a proponent agent it waits in this state for the answer of the proponent Thus if the proponent is able to counter attack and sends a locution ATTACK the agent will move back to the state At tack to try to generate a new attack to rebut the position of
117. irect our HTTP POST to our HTTP interface Data is the JSON object previously shown The next parameter is the function that will be executed when we receive the reply to our request in this case we will show the result The last parameter is the type of the data For more information about jquery and the method jquery post please refer to http jquery com MarketA gent is a very simple agent it receives a query from our webpage and sends a product 136 5 3 Example encapsulated in a JSON object In the following code the MarketAgent receives the JSON containing the query and transforms it into a Java object ACLMessage msg receiveACLMessage XStream xstream new XStream new JettisonMappedXmlDriver xstream alias jsonObject JSONMessage class JSONMessage query JSONMessage xstream fromXML msg getContent Once the JSON object is a Java object it is possible to work easily with it The MarketA gent does some calculations with the input data and prepares the response XStream xstream2 new XStream new JsonHierarchicalStreamDriver Override public HierarchicalStreamWriter createWriter Writer writer return new JsonWriter writer JsonWriter DROP_ROOT_MODE String result xstream2 toXML product response setContent result this send response This time the MarketAgent transforms a Java object into a JSON object As in the previous step it uses the libra
118. is class the user can modify the initial data given to the agents the number of agents to execute the number of problems to solve and the weights of the argumentative agents to perform different argumentation strate gies The behaviour of the argumentative agents can be changed modifying the default actions of the methods in the ArgCA gent java class see Table 3 4 Furthermore in the argumentation example provided we assume the existence of a tester agent that is in charge of requesting a group of ArgCAgents to solve a problem This agent implemented in the Magentix2 argu mentation API with the class TesterArgCAgent extends a Magentix2 SingleAgent Also it is in charge of gathering information at the end of the protocol and convey the final solution proposed Method Parameters Description generateAttackArgument incomingArgument op Defends and attacks other ponentID agents positions generatePositions problem Evaluates if it can propose a po sition generateSupportArguments myPosition opponentID Defends its position updateCBs solution Stores generated data in the dia logue Table 3 4 Main ArgCA gent java methods A standard argumentative agent can be created and executed by using these commands ArgCAgent agent new ArgCAgent new AgentID qpid agentName localhost 8080 socialEntity friendsList depenRelsList group commitmentStoreID iniDomainCasesFilePath finDomainCasesFileP
119. is required e Importing the certificate into the key store keytool import trustcacerts alias TM file tm crt keystore keystore jks The PASSWORD USERKEYSTORE is required 6 Platform administration 159 6 6 8 Magentix2 Management System MMS The MMS is distributed as a war project Web Application aRchive In webapps directory where it is deployed exists a MMS folder In this folder the configuration files are located Once the certificate infrastructure has been created the properties files will have to be con figured correctly If the Magentix2 Desktop version has been installed default options are correctly configured It should be remember that the root directory is TOMCAT_HOME bin for the relative path e nss cfg This file is in the folder TOMCAT_HOME webapps MMS WEB INF classes In this file the path of Magentix2 Certificate Authority CA_db is represented Only change the nnsSecmondDirectory if the CA_db is in other path than Magentix2 bin security as it can be shown in the following example Figure 6 7 name NSSkeystor nssLibraryDirectory usr lib nssSecmodDirectory bin security CA_db nssModule keystore Figure 6 7 An example of the nss cfg file e services xml This file is in TOMCAT_HOME webapps MMS WEB INF services MMS META INF In this file the rampart properties are configured The Figure 6 8 shows an example of this file securityAdmin p
120. itions and arguments to propose Thus argument cases store information related to the domain and the social context where previous arguments and their associated positions were used The information about the domain consists of a set of fea tures premises to compare cases and information about the social context where the proposed solution was applied e g the agents that participated in the dialogue to solve the problem their roles or their value preferences The latter information can determine if certain positions and arguments are more persuasive than others for a particular social context and hence agents can select the best ones to propose in the current situation As for the domain cases case base if the argument cases created during the problem solving process are similar enough to previ ous argument cases stored in the argument cases case base the update algorithm updates those 70 3 6 Argumentative Agents Method Parameters Description addCase domain case Adds a new domain case to domain case base Otherwise if the same domain case exists in the case base adds the relevant data to the existing domain case getPremisesSimilarity premisesl premises2 Obtains the similarity between two HashMap of premises using the simi larity algorithm specified in the config uration of this class retrieve premises threshold Retrieves the most similar domain cases to the given premises with a sim ilarity degree greater
121. itions to solve the specified problem ordered from more to less suitability degree to the problem generateSupportArguments Returns an ArrayList of support Argument for the given Position against the given agent identifier getDifferentPositions Returns an ArrayList of positions that are different from the defended position and also are not asked yet getDistinguishingPremises Returns an ArrayList with distinguishing premises between the HashMaps given as arguments getUsefulPremises Returns a HashMap of the useful premises of the agent of the current problem to solve the premises of the Position that are specified in the problem characterisation updateCBs Adds the final solution to the current problem and adds it in the domain cases case base Also stores all the generated argumentation data in the argument cases case base Finally makes a cache of the domain CBR and the argumentation CBR Table 3 1 ArgCAgent java methods to manage positions and arguments is assigned a suitability degree by using the formula Suitability Wsimp SimD wsp SF 3 2 where w 0 1 gt gt w 1 are weight values that allow the agent to give more or less importance to the similarity degree with the domain cases used to generate its position or the support factor these weights can be set in the agent s constructor Agents sort their potential positions from most to less suitable depending on their value prefer
122. ix2 has been successfully installed and running execute the example Start BasicExample This exampe must be execute as follows in Linux distributions cd Magentix2 examples bin sudo sh Start BasicExample sh On the other hand in Windows architecture systems the example must be executed as follows gt cd c Magentix2 examples bin gt Start BasicExample bat The output of this example should be like the following one Executing I m consumer AO IES AOS INE O Thread 2 SingleAgent_Example SenderAgent2 Executing I m the sender Executing I m the sender nsaje received in consumer agent by receiveACLMessage Hello I m the sender HearderValue 2 Quick Start 9 2 2 3 Magentix2 installation description Once Magentix2 has been installed in the system in the full installation mode the following folders are created e bin includes the executable files and folders required to launch and start the platform and services The main ones are the following which allows users to start and stop the Magentix2 platform Start Magentix it launches services Tomcat MySQL Qpid and HTTPInterface and platform agents OMS SF TM and bridge agents The commands needed to execute this script are cd Magentix2 bin sudo sh Start Magentix sh Otherwise in Windows architecture systems command needed is gt cd c Magentix2 bin gt Start Magentix b
123. jar e If the architecture system is 64 bits Linux distribution sudo java jar Magentix2Desktop x64_java_version jar e Ifthe architecture system is Windows gt java jar Magentix2Desktop windows_version jJar Note that this commands uses superuser root privileges Then a graphical interface for the installation is provided This interface guides the user through the installation process It is possible to make a full installation or customize it A full installation installs all of the components that Magentix2 needs to run appropriately Cus tom installation is recommended only when any of these components have been installed 7 in the system Please refer to section 6 1 to check which are these components Shttp www oracle com technetwork java archive 139210 html The latest installable version is in http users dsic upv es grupos ia sma tools magentix2 downloads php The installation of any of these components can cause conflicts in the system if already they exists For example if etc mysql directory exists 8 2 2 Installing Magentix2 Java Based Desktop Edition When installation ends the script Start Magentix must be executed in order to start the services and platform agents this script must be executed as follows cd Magentix2 bin sudo sh Start Magentix sh If the architecture system is Windows gt cd c Magentix2 bin gt Start Magentix bat To check that all is correctly configured and Magent
124. keystore with an asymmetrical key pair user and X 509 Certificate 3 7 2 Exporting User Certificate For one mutual authentication between the user and platform a self signed certificate that contains the user public key must be exported keytool export keystore keystore storepass mysecretpassword alias alias_name file user crt The file user crt will be transfered to the Magentix2 platform administrator by http ftp e mail etc in order that he adds in it his trusted store gt For this purpose the command keytool included in Java Sun JDK is used 76 3 7 Launching agents with security enabled 3 7 3 Importing MMS Certificate This command append the Magentix Manager Service MMS trusted certificate in the key store keytool import trustcacerts noprompt alias MMS A file mms crt storepass mysecretpassword keystore keystore The file mms crt contains the MMS public key to obtain this file please contact with the Magentix2 administrator 3 7 4 Creating and importing truststore If the MagentixCA self signed certificate is not included in the truststore the connections with the platform will be rejected The following command creates a truststore and appends the MagentixCA trusted certificate keytool import trustcacerts noprompt alias MagentixCA file rootca crt storepass mysecretpassword keystore truststore jks The root crt file contains t
125. lTracingServices The Trace Manager only alows for subcribing to all available has to be launched in monitorization mode Thus the following code would not work and the requester agent would receive a REFUSE ACL message with an AUTHORIZATION_ERROR error code TraceManager tm new TraceManager new AgentID TM 86 3 8 Tracing Service More code here This will NOT work x requestAllTracingServices this Launching the Trace Manager with the monitorization flag set to true like in the example would do the job TraceManager tm new TraceManager new AgentID TM true More code here es LS aa oa e requestAllTracingServices this All these methods related to the subscription and unsubscription processes are described in more detail in Table 3 13 An example of tracing service subscription can be found in Section 3 8 6 in line number 20 where the agent subscribes to the NEW_AGENT tracing service Line number 68 also shows an example of subscription to a tracing service called MESSAGE_SENT_DETAIL offered by a specific origin entity Later in that source code in lines 74 and 75 it can be observed how the agent unsubscribes from these tracing services 3 8 3 3 Listing The Trace Manager allows for listing tracing entities and tracing services available in the sys tem by invoking listTracingEntities and listTracingServices respectively These two methods
126. ll features of Magentix2 it is recommended both for developers and end user applications This installation is offered only for Ubuntu Linux version In order to use in other systems please refer to section 2 2 2 1 1 Requirements e Oracle Java Development Kit JDK 6 update 01 or later e Ubuntu Linux version 9 10 or later 2 1 2 Installation of Magentix2 Desktop In order to install Magentix2 Desktop the corresponded jar for 32 bits architecture or 64 bits architecture must be downloaded firstly Once Magentix2Desktop jar is downloaded the http www oracle com technetwork java archive 139210 html The latest installable version is in http users dsic upv es grupos ia sma tools magentix2 downloads php 4 2 1 Installing Magentix2 Desktop Edition following command must be executed e If the architecture system is 32 bits sudo java jar Magentix2Desktop i386 Jjar e If the architecture system is 64 bits sudo java jar Magentix2Desktop x64 jar Note that this commands uses superuser root privileges Then a graphical interface for the installation is provided This interface guides the user through the installation process It is possible to make a full installation or customize it A full installation installs all of the components that Magentix2 needs to run appropriately Cus tom installation is recommended only when any of these components have been installed gt in the system Please refer
127. lustrate this section It is formed by the sender agent that acquires role member in the unit team and two receivers agents with the role member in the unit team Figure 4 11 The unit virtual is parent of the unit team 4 Virtual Organizations 127 buildOrganizationalMessage team Figure 4 11 Organizational messaging Example diagram 4 6 1 Acquire Role e Registration of an agent on the platform The agents request to be registered as a participant of the THOMAS platform using the AcquireRole service AcquireRole participant virtual OMSproxy Figure 4 12 Agent interaction protocol to acquire role OMS 1 omsProxy acquireRole participant virtual e Registration of an agent inside the unit The agents request to be registered as a member inside the unit team 128 4 6 Programming agents which use organizational messaging 1 2 omsProxy acquireRole member team 4 6 2 Message build process e Build an organizational message Once the agent is inside the unit with an specific role it has to use the buildOrganizationalMessage to obtain the required organizational message specifying the identifier of the organization 1 ACIMessage msg omsProxy buildOrganizationalMessage team 4 6 3 Message complete process e Add ACL message fields After the message is built it can add the fields of an ACLMes sage such as content performative or language 1 msg setContent
128. ments that agents interchange have the following structure public Argument long id Conclusion conclusion int timesUsedConclusion String promotedValue SupportSet supportSet DependencyRelation proponentDepenRelation where conclusion is the conclusion of the argument timesUsedConclusion stores the number of times that this conclusion has been used promotedValue is the value that the agent wants to promote with this argument support Set is a set of elements that justify the argument and proponentDepenRelat ion is the dependency relation power authori sation or charity established between the proponent of the argument and the opponent that the argument is addressed Thus in our case based argumentation framework arguments promote values These values can be personal goods e g efficiency accuracy etc or also social goods inherited from the agents dependency relations Preferences over values can determine the reasons that lead an agent to propose a specific argument or to accept or refuse an argument from another agent The support set is a knowledge resource of the Magentix2 argAgents knowledgeResources package represented by the Support Set java class and can consist of different elements depending on the argument purpose On one hand if the argument justifies a potential solution for a problem the support set is the set of features premises that represent the context of the domain where the argument has been put forw
129. n 3 Programming Agents 53 ARGUMENT CASE _ _ _ SOLUTION Argument Type JUSTIFICATION PROBLEM Conclusion n a Value ney a Acceptability Status SOCIAL CONTEXT DOMAIN CONTEXT Dependency Relation Premises RECEIVED ATTACKS CASE Dd A AAA uA a A PROPONENT OPONENT ID ID CRITICAL COUNTER ARGUMENTATION Role Role QUESTIONS EXAMPLES SCHEMES ValPref ValPref AAA DISTINGUISHING po PREMISES Role ValPref Figure 3 9 Structure of an Argument Case the system Finally the dependency relation between the proponent s and the opponent s roles is also stored In our framework we consider three types of dependency relations power when an agent has to accept a request from another agent because of some pre defined domination relationship between them authorisation when an agent has signed a contract with another agent to provide it with a service and hence the contractor agent is able to impose its authority over the contracted agent and charity when an agent is willing to answer a request from another agent without being obliged to do so In the solution part the conclusion of the case the value promoted and the acceptability status of the argument at the end of the dialogue are stored The acceptability status shows if the a
130. n or others FNMT ACCV o type own ser ths base patni io access CO corilsor keystore othersPath full_path keystore_fnmt p12 set the pin of the smartcard or password of your keystore othersPin password set the type of the keystore othersType PKCS12 Figure 3 13 Second section of the securityUser properties file In the section three Figure 3 14 the MMS direction path is indicated For this pur pose it is necessary to consult with the Magentix2 administrator to provide the direction protocol host port path where the MMS service is deployed The purpose of last section is to indicate the user alias certificate Figure 3 15 78 3 7 Launching agents with security enabled set the connection protocol to be used to access services protocol http set the name of the service host host localhost set the port for accessing the services port 8080 set the base path for accessing to services path MMS services MMS Figure 3 14 Third section of the securityUser properties file set the alias to user certificate This alias is ta PrivateKeyEntry alias User_alias Figure 3 15 Fourth section of the securityUser properties file If the name of the alias certificate is not know then it can be consulted with the following command keytool list keystore keystore jks In the case the certificate store is not a jks type
131. new CProcessor and two conversations which follows the same IP This conversations will be managed simultaneously the previous Conv2 and the new conversation For more information about CAgents please refer to Fogu s et al 2010 In the next sections some examples of CAgents are explained All the code of these examples are available in the examples directory of Magentix2 platform 3 4 1 Hello World CAgent The code shown in this section corresponds to the code located in examples src myFirstCA gent HelloWorldA gent java In the code below the method execution is where the user has to implement the main code of the agent In this hello world agent the main behaviour of the agent is just to say hello world The method finalize is executed when the agent is just about to finish its execution thus here is where the user has to implement ending actions of the agent class HelloWorldAgentClass extends CAgent public HelloWorldAgentClass AgentID aid throws Exception super aid 20 21 22 23 24 25 26 27 28 29 30 31 3 Programming Agents 37 user must this method The platform starts a conversation with each agent that has been just created by sending it a welcome messag This sending creates the first CProcessor of the agent In order to manage this message th implement the execution method defined by the class CAgent will be exec
132. new TraceManager new AgentID TM Agents communicate with the Trace Manager using the methods available in the class es upv dsic gti_ia trace TraceInteract These methods internally send an ACL message to the Trace Manager This message will be processed by the Trace Manager which responds to these requests via ACL messages to requester agents When the request sent to the Trace Manager an error ACL message is sent to the requester tracing entity with an error code in order to let the tracing entity know the reason why the request was rejected These error codes are available in the class es upv dsic gti_ia trace TraceError and their meaning is 84 3 8 Tracing Service described in Table 3 11 Table 3 11 Trace Manager error codes TRACE_ERROR Undefined trace error ENTITY_NOT_FOUND Tracing entity not present in the system PROVIDER_NOT_FOUND Provider is not offering the tracing service SERVICE_NOT_FOUND Tracing service not offered by any tracing entity in the system SUBSCRIPTION_NOT_FOUND Subscription to the tracing service not found ENTITY DUPLICATE Tracing entity already present in the system SERVICE_DUPLICATE Tracing service already offered by the tracing entity SUBSCRIPTION_DUPLICATE Subscription already exists BAD ENTITY Tracing enity not correct BAD_SERVICE Tracing service not correct PUBLISH_ERROR Impossible to publish th
133. nitID Identifier of the organi zational unit Accessibility Considers two types of roles internal or exter nal Visibility Is defined public or from inside private Position Position inside the unit such as member supervisor or subordinate Identifier of the new DeregisterRole Removes a specific role from a unit scription from a unit RolelD Identifier of the role UnitID Identifier of the unit RegisterUnit Creates a new unit within a spe cific organization UnitID Identifier of the new unit Type Indicates the topology of the new unit 1 Hierarchy ii Team iii Flat ParentUnit parent unit Creator The name of the new creator role Identifier of the DeregisterUnit Removes a unit from an organi zation UnitID Identifier of the unit JointUnit Updates the parent unit UnitID Identifier of the unit ParentUnit Identifier of the new parent unit Table 4 4 OMS Proxy Structural services API 111 On the contrary in the second option the url where SF services are deployed war should be specified in the constructor if the user does not want to use the default url from the settings xml configuration file private SFProxy sfProxy new SFProxy this url 112 4 2 Programming agents which use THOMAS OMS Service Description Parameters InformRole Provides a role description of a RoleID Identifier of the
134. nly provided if requested agents participate in the organization in which the role was registered or in its Parent Organization Private Internal Maximum protection of the role The unit acts like a black box for these roles Internal agents must participate in the organization or in its parent organization to acquire the role Private agents can request information about the role if they partici pate in the organization in which the role was registered or in its Parent Organization Table 4 2 How visibility and accessibility attributes affect roles FLAT TEAM HIERARCHY Allowed role Creator Creator positions Member Supervisor Subordinate What agents can Any agent from this organization except those who only play roles with Position Creator send organizational messages What agents can re Any agent from this organization except who Supervisors receive all messages Subordi ceive organizational what only play roles with Position Creator nates only receive messages sent by Super messages visors Creators do not receive messages What agents can regis ter deregister organiza tions Any agent from this organization which plays roles with Position Creator What agents can join an organization to an other Any agent from this organization which plays both a role with Position Creator and a role with Position Creator in the new Parent organization
135. ntic services another important data is the ontology used in the service When the service description is accessed any entity has all the needed information available to interact with the service Services registered and discovered by SF in THOMAS are demanded or offered by some agent or organization Figure 4 1 Demanded services are services which are wished by autonomous entities but no agent or organization provides them Offered services are provided and regis tered in the THOMAS environment by agents or organizations The final execution of this services will be finally made by a web service an internal behavior of an agent or an agent internal call to a web service The set of services provided by the SF to manage the services of the platform meta services are Classified in 3 categories e Registration they allow adding and removing services from the SF directory Regis terService DeregisterService e Affordability they allow managing the association between providers and their services 108 4 1 Overview of THOMAS framework Type Offered by Implementation o A Agent Behaviour Figure 4 1 Handled Services demanded and implementations of offered services supported Offered RemoveProvider e Discovery services in charge of searching and composing services as an answer to user requirements SearchService GetService 4 1 4 Organization Manager Service This component is in charge of organizati
136. nts that Request Services agents or organizations providers ArrayList lt Provider gt providers oracle getProviders web services providers ArrayList lt String gt providersGroundingWSDL oracle getProvidersGroundingWsDL if providers isEmpty System out println this getName Requesting Addition Service 3 4 Building the ACL message ACLMessage msg new ACLMessage msg setReceiver new AgentID providers get 0 getEntityID msg setLanguage providers get 0 getLanguage msg setPerformative providers get 0 getPerformative msg setSender getAid Building the content of the message in XML String content st buildServiceContent oracle getServiceName agentInputs ACL message content is formed by XML format with service name and inputs msg setContent content this send_request msg ServiceTools st new ServiceTools HashMap lt String String gt outputs new HashMap lt String String gt 0 st extractServiceContent requestResult outputs resultEquation outputs get Result else if providersGroundingWSDL isEmpty System out println this getName Executing addition Service SR 55 56 57 58 59 60 61 62 4 Virtual Organizations 123 HashMap lt String Object gt resultExecution st xecuteWebService pr
137. o the state Query Positions to challenge the positions of other agents Also an agent can be reported by other agent that the latter ACCEPTs its position Alternatively the agent can receive a FINISHDIALOGUE locution in this state and it will go to the state Send Position to start the actions to leave the dialogue when it has proposed yet a position Assert the agent that received the WHY request will ASSERT a support argument to the opponent if it can This implies going to the state Wait Attack and wait for incoming attack arguments If the agent is not able to provide a support argument to defend its position it must move back to the state Propose with the locution NOCOMMIT to withdraw its position from the dialogue and if possible propose another generated posi tion Also argumentative agents do not respond to the same WHY query from the same opponent agent twice In this case the argumentative agent will move back to the state Central and ignore the repeated WHY request Wait Attack in this state the agent that has put forward a support argument for its position waits for an ATTACK or an ACCEPT locution In the case that an ATTACK is received the agent will go to the state Defend to try to rebut the attack If the agent receives an ACCEPT it means that the opponent agent has accepted its position and the proponent agent will move back to state Central Defend in this state an agen
138. ocol provides the basic message exchange between two agents for a given type of conversation a request a query etc In order to implement these protocols a new agent template called QueueA gent has been defined This template extends BaseAgent and can be found in the package es upv dsic gti_ia architecture The figure 3 4 shows a UML class diagram for the QueueA gent class In order to use protocols agents must extend the QueueA gent class and redefine its constructor For instance import es upv dsic gti_ia architecture QueueAgent import es upv dsic gti_ia core AgentID public class agent extends QueueAgent public agent AgentID aid throws Exception super aid 28 3 3 Basic conversational agents QueueAgents BaseAgent init onMessage message ACLMessage terminate send in Message ACLMessage QueueAgent A A _ E gt I A 2 __ E EE KT tc AE addTask Object receiveACLMessage template MessageTemp late 1 ACLMessage de Threadinitiator ThreadResponder AA Pe ee el run run Figure 3 4 Diagram for the QueueA gent class 3 3 1 Communication Protocols on Magentix2 platform Three interaction protocols specified by FIPA Request Query and the Contract Net have been implemented in the Magentix2 basic conversational protocol For this purpose a set of classes have been implemented and they can be found into the es upv dsic gti ia archit
139. ods o e e e Running Examples o e e e Agent Communication 2 aere A e g ee 3 2 1 3 2 2 FIPA ACL Language 0000000 ee Sending Messages e Ix 3 2 3 Receiving Messages cee ee ee 24 3 2 4 External Communication o e 25 3 3 Basic conversational agents QueueAgents o o 27 3 3 1 Communication Protocols on Magentix2 platform 28 3 3 2 How to implement a FIPA Protocol o 29 3 3 3 Running QueueAgents e o 32 333 4 CExamples 4s bo ad gar Gade ia Be 33 3 4 Advanced conversational agents CAgents o o 34 3 4 1 Hello World CAgent o a 36 3 4 2 Creating a CFactory and its CProcessor o o 38 3 4 3 Using a CFactory Template o 41 3 44 Creating a CFactory Template o 43 3 5 BDI Agents JasonAgents o 0 0000 0 eee ee eee 46 3 6 Argumentative Agents e 49 3 6 1 Argumentation Framework o o e e 49 3 6 2 Argumentation API o e e 56 3 6 3 Programming Argumentative Agents 66 3 7 Launching agents with security enabled o o o 74 3 1 1 Creating Key pair aa meai a a AA eae al ee a 75 3 7 2 Exporting User Certificate o o e 75 3 7 3 Imp
140. oing to implement a template for the CFactory shown in section 3 4 2 First the states are defined it is in this moment when it is possible to define default methods and choose which methods are abstract and therefore mandatory to implement for the user The definition of the states is shown below public abstract class MyTemplate We can define a set of static values for referencig sates public static String BEGIN BEGIN 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 oF 38 39 44 3 4 Advanced conversational agents CAgents public static String PROPOSE PROPOSE public static String WAIT WAIT public static String RECEIVE RECEIVE public static String RECEIVI FINAL E E protected void doBegin CProcessor myProcessor ACLMessage msg System out println This is the begin state class BEGIN_Method implements BeginStateMethod public String run CProcessor myProcessor ACLMessage msg doBegin myProcessor msg return PROPOSE y E We want the user to implement his her method here protected abstract void doPropose CProcessor myProcessor ACLMessage messageToSend class PROPOSE Method implements SendStateMethod public String run CProcessor myProcessor ACLMessage messageToSend doPropose myProcessor messageToSend ji TOTES LP eS SOs Simple anc hasnime nye enO1
141. on Table 4 3 Differences among the diverse organization types 4 Virtual Organizations 107 4 1 3 Service Facilitator The SF is a support mechanism used by organizations and agents to offer and discover ser vices The SF provides an environment in which the autonomous entities can register service descriptions as directory entries The SF acts as a gateway to access the THOMAS framework The SF can find services search ing for a given service profile This is done using matchmaking mechanisms over the inputs outputs and keywords of the services to search The SF also acts as a yellow pages manager and in this way it can also find which entities provide a given service Services may have some pre conditions that have to be true before the service can be executed They exchange one or more input and output messages A successful service execution has some effects on its environment This parameters are called IOPE in put output preconditions effects Moreover there could be additional parameters which are independent of the service functionality non functional parameters such as quality of service deadlines and security protocols among others A service represents an interaction between two entities which are modelled as communica tions among independent processes In our case the Multi agent Technology provides us with FIPA communication protocols Taking into account that we are dealing with sema
142. ons and demand the other their services This agent acquires the role Student of the School organizations It looks for the different services it needs Addition Product and Square to calculate a simple mathematical operation Then either ask the service providers in carrying out such services or run them directly if no provider Services in the THOMAS example are deployed in the webapps folder of the Apache Tomcat in Magentix2 installation folder The OWL S specifications are located in webapps testSFservices testSFservices owl owls The WSDL documents can be found in webapps testSFservices WEB INF services service_name META INF service_name wsdl The following services are used in the THOMAS example Product This service multiplies two input numbers doubles and returns the product double It is provided by an agent behavior Addition This service adds two input numbers doubles and returns the addition dou ble It is provided by agent that calls to a web service Square This service squares an input number double and returns the result double It is provided by a web service Following we briefly explain the actions of the THOMAS example shown in the diagram of Figure 4 10 4 Virtual Organizations 125 5 Request Addition Service 5 Request Product Service 3 RegisterService ddition 2 AcquireRol operation ca Product Square 6 Deregiste
143. ons life cycle management including specification and administration of their structural components roles organizative and units and their ex ecution components participant agents and the roles they play and active units in each mo ment OMS offers all services needed for a suitable organization performance These services are classified as e Structural services that modify the structural organization specification e Dynamical services that allow agents to entry or leave the organization dynamically as well as role adoption By means of the publication of the structural services OMS allows modifying in execution time some aspects related to the organization structure functionality or normativity Some 4 Virtual Organizations 109 of these services should be restricted to internal roles of the system which have enough per mission to do this kind of operations i e a supervisor role Dynamic services manage the creation registration of new agents in the organization entry or exit of unit members and role adoption These services are always published in the SF The OMS provides agents with a set of services for organization life cycle management Val et al 2009 classified in e Structural services which modify the structural organization specification i e roles and organizational units RegisterRole DeregisterRole RegisterUnit DeregisterUnit JointUnit e Informative services that give information of
144. orting MMS Certificate o o 76 3 7 4 Creating and importing truststore o 76 JTS Configuration oi a Se Ge be a Grea a a oa 76 SAO CRUDA A Bae 79 SATa Problems sr sagaca e a ai 79 3 8 Tracing Service as angel ase ab bea ge Saeed ee a e 80 3 8 1 Trace Model and Features o e e 80 3 8 2 Trace Event ooo ie ona ed a e ew es 81 3 8 3 Tracing ServiceS eo scores de ee 83 3 8 4 Domain Independent Tracing Services o 88 3 8 5 Example TraceDaddy o o e e 92 3 807 Daddiycclass sak os se ee wh ek lt ade ee Biche le arte oe 93 OL BOAS SAn ee ee SS Sena he bene Seid ec adh Sek BO Sa OE Sec 95 3 8 8 Main application sourcecode o o e e 97 338 9 RESUS ahs eae a al ape ns Ee ae hime E A O AE As 100 Virtual Organizations 101 4 1 Overview of THOMAS framework o e 101 471 1 Roles THOMAS e fo ee de a a a 102 4 1 2 Unitsin THOMAS oan ald sean lad a cael AAA a ee 103 4 1 3 gt Service Facilitators s oora u wd ne a hbase dB aioe aad A ae aoe 107 4 1 4 Organization Manager Service o e 108 4 2 Programming agents which use THOMAS o e 109 4 2 1 Magentix2 API for THOMAS e a 109 4 3 Programming Agents that Offer Services o o 115 II 43 31 Acquire Role E A th een Gad 4 3 2 Service Registration 2 ak 20 00 00
145. ovidersGroundingWSDL get 0 Doub be agentInputs le resultDouble Double resultExecution get Result resul tEquation resultDouble toString else no providers for this service Sy stemtout printing een ame wy e INS providers found for Addition Service 3 4 Requester Agent Service Request 4 5 Runni GetService serviceProfile OWL S specification lt h Provider Agent Service Result Figure 4 9 Agent interaction protocol to request a service ng THOMAS Example The examples folder of the Magentix2 packages contains a basic THOMAS example In this example there are four agents e Initiator This agent build the organizational framework needed First it registers the Calculator and School organizations Then it registers the roles needed in each organi 124 4 5 Running THOMAS Example zation As this agent register each unit it also plays the role Creator of them At the end of the example it deallocates all roles and deregister all units roles and services Addition This agent acquires the role Operation of the Calculator organization It also registers and provides the service Addition Product This agent acquires the role Operation of the Calculator organization It also registers the services Product and Square It only provides the service Product James It represents an student which needs computing some operati
146. page Magentix2 js and Redirect php This tools can be obtained from the examples folder of the Magentix2 distribution 5 2 1 Magentix2 js Magentix2 js is a Javascript library that facilitates the creation of JSON objects that are ac cepted by the HTTP interface The two main functions of the library are createJSONOb ject agent_name conversation_id content and createJSONObject agent_name content The first one returns a JSON object with the conversation_id field set to the value passed as parame ter The second one returns a JSON object with a new conversation_id this id is a UUID The parameter content has to be an associative array of elements that will be used as the content of the resulting JSON object 5 2 2 Redirect php This php can redirect an HTTP POST request to any address You can use it to redirect HTTP POST requests to your HTTP interface This php requires the Pear HTTP_Request2 library you can get this library from http pear php net package HTTP_Request2 redirected 5 3 Example In this section only a brief explanation of how to interact with a Magentix2 agent from a webpage is shown For the complete example please refer to the folder examples httpinterface of your Magentix2 distribution The example is composed by two parts e example html This web page contains a form The user specifies a type of product and a maximum prize The user will get a product that satisfies her specifications ht
147. potential way in which the conclusion drawn from the scheme can be attacked Therefore if the opponent asks a critical question the argument that supports this argumentation scheme remains temporally rebutted until the question is conve niently answered Argument Cases Argument cases are the main structure that we use to computationally represent argumenta tion knowledge in Magentix2 concretely in the ArgumentCase java class of the Magen tix2 argAgents knowledgeResources package Their structure is generic and domain independent Figure 3 9 shows the generic structure of an argument case Argument cases have the three possible types of components that usual cases of CBR systems have the description of the state of the world when the case was stored Problem the solution of the case Conclusion and the explanation of the process that gave rise to this conclusion Justification The problem description has a domain context that consists of the premises that characterise the argument In addition if we want to store an argument and use it to generate a persuasive argument in the future the features that characterise its social context must also be kept The social context of the argument case includes information about the proponent and the opponent of the argument and about their group Moreover we also store the preferences ValPref of each agent or group over the set of possible values that arguments can promote pre defined i
148. quests The name of a dummy agent is InterfaceAgentX where X will be a number As an example the receiver conversa tion id sender and content fields of the ACLMessage that the target agent would recive after the HTTP interface would receive the previous JSON object would be the following ACIMessage receiver Mik ACLMessage conversation_id convl ACLMessage sender InterfaceAgentl ACLMessage content agent_name Mike conversation_id ANCORA Meroe ernie O vs N Maelo MA ES UD Shs Olin The target agent can respond to the HTTP request sending an ACLMessage to the Inter faceAgent that sent the ACLMessage with the HTTP request The content of the ACLMessage sent to the InterfaceAgent will be used as the message body of the reply to the HTTP request Continuing with the previous example the ACLMessage that the agent Mike would send to the InterfaceAgent1 could be ACLMessage receiver InterfaceAgentl ACLMessage conversation_id convl ACLMessage sender Mik ACLMessage content name Banana id 123 price Cea jh As you may note the content of this message is a JSON object but it does not follow the guideline explained previously This is not a problem the reply content is free and may contain any type of data 134 5 2 Tools 5 2 Tools Magentix2 provides two tools to facilitate the communication between Magentix2 agents and a web
149. queue on the Qpid broker where other agents can post messages addressed to her The Figure 3 3 illustrates how a sender agent posts a message in a queue Then a consumer agent is able to read this message 3 2 1 FIPA ACL Language Messages exchanged by Magentix2 agents have the format specified by the ACL language defined by the FIPA international standard for agent interoperability This format comprises a number of fields such as e Sender of the message e A list of receivers http www fipa org 24 3 2 Agent Communication e Performative REQUEST INFORM QUERY JF CFP PROPOSE ACCEPT PROPOSAL REJECT_PROPOSAL etc e Content e Content Language e Content Ontology e Conversation id reply with in reply to reply by etc A message in Magentix2 is implemented as an instance of the es upv dsic gti_ia core ACLMessage class that provides get and set methods for handling all the fields of a message 3 2 2 Sending Messages To send a message to another agent the programmer must fill the fields of an ACLMessage object and then call the send method of the es upv dsic gti_ia core class BaseAgent The code below informs an agent whose identifier is receiver with the text Hello I m sender Building a ACLMessage ACLMessage msg new ACLMessage ACLMessage REQUEST msg setReceiver receiver msg setSender this getAid msg setLanguage ACL msg
150. quire a role 2 omsProxy acquireRole participant virtual 4 3 2 Service Registration e Registering a new service An agent wants to register 1ts own service in the SF Figure 4 5 The OWL S specification of the service must be available in a url This specifica tion has to follow the OWL S standard having the profile and process of the service It also needs to specify the provider or providers of the service in the following way If the provider is an agent or an organization the profile has to be specified as a provider in the OWL S specification The provider is defined following the provider owl ontology located in the webapps folder of the Apache Tomcat in Ma gentix2 installation folder concretely in webapps ontologies The parameters of the provider are entity id entity type agent or organization communication lan guage performative to use in the petition An example of this structure is shown below 1 2 lt profile contactInformation gt 3 lt provider Provider rdf ID AdditionAgent gt 4 lt provider entityID rdf datatype xsd string gt AdditionAgent lt provider entityID gt 5 lt provider entityType rdf datatype xsd string gt Agent lt provider entityType gt 6 lt provider language rdf datatype xsd string gt FIPA ACL lt provider language gt 7 lt provider performative rdf datatype xsd string gt REQUEST lt provider performative gt 8 lt provider Provider g
151. rService 4 SearchService GetService Initiator Agent 1 RegisterUnit RegisterRole 6 DeregisterUnit DeregisterRole DeallocateRole Figure 4 10 Thomas Example diagram 1 The Initiator acquires the role participant of the default unit virtual Then it registers the organizations Calculator and School Calculator is a team unit its parent unit is virtual and the name of the default role is creator On the other hand the unit School is a flat organization its parent unit is virtual and the name of the default role is also creator Once the agent registers the units it also creates the roles needed So first the Initiator agent registers a role named operator member public and external inside the unit Calculator Secondly it registers a role named student member public and external inside the unit School 2 The Addition agent and the Product agent acquire the role operation of the Calculator organization Also the James agents acquires the role student of the School organization 3 The Addition agent registers the Addition service in the SF Also the Product agent registers the Product and Square services in the SF 126 4 6 Programming agents which use organizational messaging 4 The James agent wants to calculate the equation 5 3 4 Firstly it searches for a service to add two numbers and it finds the Addition service It makes a GetService of this service to obtain the required information to request i
152. ransition RECEIVE FINAL return theFactory hi How to use a CFactory template is shown in the previous section 3 4 3 For this specific tem plate the instructions are the same 3 5 BDI Agents JasonAgents Jason Bordini et al 2005 is an interpreter for an extended version of AgentSpeak L Rao 1996 and implements the operational semantics of that language It has been developed by Jomi F Hiibner and Rafael H Bordini Jason has been integrated in Magentix2 platform therefore we can program agents in AgentSpeak and run them on Magentix2 platform For examples and demos of how to program in AgentSpeak L please refer to the webpage of the Jason project http jason sourceforge net Jason Jason html Magentix2 integrates Jason providing two classes JasonAgent and MagentixAgArch Ma gentixAgArch manages the AgentSpeak L interpreter the reasoning cycle of the agent and how the agent acts and perceives to from the environment The JasonAgent class acts as a link 3 Programming Agents 47 between the AgentSpeak L interpreter and the platform Both classes can be modified and adapted to the desired needs but usually only MagentixAgArch would need to be modified in order to add external actions to the agent external actions are actions which affect the agent environment The code of how to create and execute a basic JasonAgent is shown below MagentixAgArch arch new MagentixAgArch JasonAgent agent new
153. rd in each step of the dialogue Thus different strategies can be more or less suitable depending on the other agents that participate in the dialogue the tactics that they follow and their available knowledge resources 3 6 2 Argumentation API In this section we define the different modules that implement the argumentation API of the Magentix2 platform and their functionality For a tutorial on how to use these modules for programming argumentative agents see Section 3 6 3 e Domain CBR module consists of a CBR module with domain dependent data previ ous problem solving experiences stored in the form of domain cases This CBR has to be initialised with data of the application domain e Argumentation CBR module consists of a CBR module with argumentation data pre vious arguments stored in the form of argument cases Once an agent has a list of po tential solutions for a current problem it has to select the best position to put forward among them Also the agent can generate arguments to support its position and attack 3 Programming Agents 57 another agent s arguments and positions Then this module is used to look for previ ous argumentation experiences and use this knowledge to select the best positions and arguments to propose e Argumentative agent is an agent with a Domain CBR and an Argumentation CBR able to engage in an argumentation dialogue to solve a problem This agent learns about the domain problem and
154. register new providers 118 4 4 Programming Agents that Request Services 4 3 3 Provide services In THOMAS there are different ways of providing a service as represented in Figure 4 1 On the one hand in the cases that the providers are registered in the SF as agents or organizations the requests to that services will be sent to the corresponding agent or organization as specified in the OWL S registered in the SF The agents or organizations can execute their service as an internal behaviour or as a web service but this is not visible to the requester On the other hand if the providers of a service are registered in the SF as web services ground ings the requester of these services will have to execute the service by itself using the class ServiceTools of the package es upv dsic gti_ia organization see Section 4 4 3 4 4 Programming Agents that Request Services This section describes how an agent that requires services from other agents can search and request services in THOMAS 4 4 1 Acquire Role e Registration of an agent on the platform The agents request to be registered as a participant of the THOMAS platform using the AcquireRole service AcquireRole participant virtual OMSproxy gt Figure 4 7 Agent interaction protocol to acquire role 1 omsProxy acquireRole participant virtual 4 4 2 Service Search Process e Search of a service Once the agent is registered it c
155. rgument was deemed acceptable unacceptable or undecided in view of the other arguments that were put forward in the agreement process Therefore an argument is deemed acceptable if it remains undefeated at the end of the argumentation dialogue unacceptable if it was defeated during the dialogue and undecided if its acceptability status cannot be determined with the current information about the dialogue In addition the conclusion part includes information about the possible attacks that the argument received during the process These attacks could represent the justification for an argument to be deemed unacceptable or else reinforce the persuasive power of an argument that despite being attacked was finally accepted Finally the justification part of an argument case stores the information about the knowledge resources that were used to generate the argument represented by the argument case the set of domain cases and argument cases In addition the justification of each argument case has a dialogue graph or several associated which represents the sequence of arguments that form the dialogue where the argument was proposed In this way the complete conversation is stored 54 3 6 Argumentative Agents as a directed graph that links argument cases that represent the arguments of the dialogue This graph can be used later to improve the efficiency in an argumentation dialogue in view of a similar dialogue that was held in the past 3
156. rgumentation framework that Magentix2 argumentative agents implement Then the implementation details of the API are shown Finally a guide to run argumentative agents and an example of a call centre application are provided 3 6 1 Argumentation Framework Argumentative agents implement a case based argumentation framework to generate argu ments to select the best argument to put forward taking into account their social context and to evaluate arguments in view of other arguments proposed in the dialogue Also they can use different dialogue strategies to exchange information and engage in the argumentation process In this section we briefly introduce the framework and the dialogue strategies that Magentix2 argumentative agents use For a more detailed explanation we refer the reader to Heras 2011 3 6 1 1 Framework Architecture Magentix2 argumentative agents can use a computational case based argumentation frame work to manage argumentation processes This section outlines the main components of this framework We have three types of knowledge resources that the agents can use to generate select and evaluate arguments by using our framework These resources are implemented in Magentix2 as java clases see 3 6 2 A database of argumentation schemes with a set of schemes with the structure proposed in Walton et al 2008 which represent stereotyped patterns of common reasoning in the application domain where the framework is
157. ribes its implementation If one or more providers agents or organization are specified in the profile contactInformation of the service it means that the service is provided by agents or and organizations If there is one or more groundings it means that the service is provided by a web service The Register Service returns a response describing if the service has been entirely registered or the number of providers and groundings added to an already registered service profile In all cases it returns a description of what is registered or not and an OWL S specification of the registered services or all data of the already registered service An agent can register its own implementation of an existing profile or create a new service from the scratch In all cases the OWL S specification must have the profile and the process and the Register Service will detect if the profile is already registered In this case the providers agents organizations or groundings web services of the new specification will be added to the registered service in the SF database 4 Virtual Organizations 115 4 2 1 4 Oracle extracting information from OWL S The Oracle is a class that allows developers to parse the profile of a semantic service spec ified in OWL S in order to extract the required information such as service inputs outputs providers list of roles or organizational units Oracle needs just the OWL S string containing the servi
158. rity executing the commands cd Qpid sh Stop Qpid sh sh Start QpidWithSecurity sh The following log is showed if the process has been done correctly 2010 12 17 13189224 norice Liscemime Om WCE orc 5072 2010 12 17 13 18 24 notice Listening for SSL connections om We jowe 5671 ZOMOS SiS 24 motes INSacl INCI ira le uo flsslin security oroler ac ALO L221L7 ISS moras Bolos CUAN gt If Magentix2 desktop installation directory is HOME Magentix2 and the passwords are the same of the script only restart Qpid with security is necessary Qpid was executing on background 6 Platform administration 153 6 6 4 Creating certificates In this section how to create a Magentix2 Public Key Infrastructure manually is explained These steps can make a more custom configuration process indicating the type of algorithm duration of validity etc The basic components that can be configured are e Magentix Certificate Authority MagentixCA e Qpid broker e Magentix2 Management Service MMS Firstly it is recommended to create the PKI infrastructure in a new folder but it is optional mkdir security cd security 6 6 4 1 Magentix Certificate Authority MagentixCA The following steps show how to create MagentixCA certificates e Creating a new certificate database in the CA_db directory S mkdir CA_db S certutil N d CA_db In this step the passwor
159. roker must be established before launching any agent This con nection will be used by agents to communicate with each other At this point it is assumed that users have a Qpid broker running properly and the agents are launched without security To employ connections with the security mode enabled please refer to section 3 7 The following parameters must be specified in any connection to the broker lt QpidHost gt the host or ip address to connect to defaults to localhost e lt QpidPort gt refers to the port to connect to defaults to 5672 e lt QpidVhost gt allows an Qpid virtual host to be specified for the connection defaults to test e lt QpdidUser gt user name to access Qpid e lt QpidPassword gt password to access Qpid e lt QpidSSL gt indicates if SSL is used during the connection its value is always false when security is not enabled 3 Programming Agents 21 There are three different ways to establish a connection to the Qpid broker using the connect method implemented in the es upv dsic gti_ia core AgentsConnection class e Calling connect without parameters In this case the parameters are gathered from the Settings xml file For example AgentsConnection connect Thus it is possible to specify the connection parameters inside the Settings xml file Note that if all the parameters are not specified in the Settings xml file it is not feasible to use the connect
160. role o o o 127 HTTP Interface framewok 0 o e e e 132 Installing libboostiostreams 1 35dev library with Synaptic tool 141 Restoring the Thomas sql backup file in the Restore Backup option of the MySQL AGMINISIFALOR a ia a a ab ad a Claud es 143 Adding the necessary user information into the THOMAS schema in the User Administrator option of the MySQL Administrator tool 144 Assigning privileges to the thomas user in the User Administration option of the MySQL Administration tool asoa aaua aaa 145 Location of web services files war o a 147 Magentix2 Security Infrastructure o e e 150 An example of the nss cfg file o o ee ee 159 An example of the services xml file o o o oo 160 First section of the securityAdmin properties file 160 Second section of the security Admin properties file 160 Third section of the security Admin properties file 161 Fourth section of the security Admin properties file 161 Fight section of the security Admin properties file 161 Sixth section of the security Admin properties file 161 Seventh section of the security Admin properties file 162 Eighth section of the securityAdmin properties file 162 Ninth section of the security Admin properties file
161. roles can be assigned to 101 102 4 1 Overview of THOMAS framework each organization These roles are characterized by some attributes which restrict its behavior regarding THOMAS framework Thus agent must play those roles in order to belong to an organization In addition Magentix2 offers a new communication mechanism based on the virtual organiza tions structure Thus this organizational messaging allows mass communication among agents of an organization taking into account the type of roles agents play THOMAS framework consists of a set of modular services Agents have access to the infras tructure offered by THOMAS through a set of services including on two main components Service Facilitator SF This component offers a yellow page service and also a service de scriptor in charge of providing a green page service Organization Manager Service OMS It is mainly responsible of the management of the organizations and their entities Thus it allows the creation and the management of any organization and the roles the agents play 4 1 1 Roles in THOMAS Roles in THOMAS are defined with a RoleName that acts as an identifier Furthermore each role is always associated with a particular organizational unit Also each role has the following attributes lt Position Accessibility Visibility gt e Position The possible values that can take are Member Supervisor subordinate or Creator This value must be
162. roperties This file is in the directory TOMCAT_HOME webapps MMS WEB INF classes Setting the path and password to MMS key and trust store Figure 6 9 Changing the algorithm type for encryption and validity time in days for the cer tificates Figure 6 10 Setting the base path for accessing to the ACL broker Figure 6 11 How to create the MMS keystore and trustore was explained in section 6 6 4 3 160 6 6 Configuring security lt ramp signatureCrypto gt lt ramp crypto provider org apache ws security components Crypto Merlin gt lt ramp property name org apache ws security crypto merlin keystore type gt JKS lt ramp property gt lt ramp property name org apache ws security crypto merlin file gt bin security MMSkeystore jks lt ramp property gt lt ramp property name org apache ws security crypto merlin keystore password gt MMS_ PASSWORD lt ramp property gt lt ramp crypto gt lt ramp signatureCrypto gt Figure 6 8 An example of the services xml file lt lo Oniy NNS Acministracog gt set the base path for accessing keystore user KeyStorePath bin security MMSkeystore jks set the password to keystore KeyStorePassword MMS_PASSWORD set the base path for accessing truststore user TrustStorePath bin security MMStruststore jks set the password to truststore TrustStorePassword MMS_PASSWORD Figure 6 9 First section
163. rs to monitor and interact with the agents run ning in Magentix2 The examples in this section show how to interact with Magentix2 agents using a web page and using Javascript and PHP However the use of the HTTP interface is not exclusive for web pages and can be used in other scenarios 5 1 Framework The functionality of the HTTP Interface service is quite simple It listens to the port 8081 and expects to get an HTTP POST request The HTTP interface extracts the target agent from the HTTP POST body message and sends that body message as the content of an ACLMessage to the target agent The information that the HTTP POST request contains must be a well formed JSON object Besides the JSON object has to obbey to the following guideline Inttp en wikipedia org wiki JSON 131 132 5 1 Framework Web Server HTTP Post JSON HTTP Post JSON HTTP Response Web Application HTTPInterface Magentix 2 Figure 5 1 HTTP Interface framewok The JSON object must contain a field called agent_name The content of this field is the name of the target agent that will receive the content of the HTTP request The object must contain a field called conversation_id The content of this field should be a unique identifier This identifier will be used in the messages sent between the HTTP interface service and the target agent The object must also contain a field called content The content of this field is t
164. rt available in Magentix2 This Tracing Ser vice Support allows agents in a Multiagent System MAS share information in an indirect way by means of trace events Before describing the API provided by Magentix2 to share tracing information the following sections will present TRAMMAS the trace model which was followed to incorporate event tracing facilities to Magentix2 3 8 1 Trace Model and Features The trace event model incorporated to Magentix is described in detail in Burdalo et al 2010 This section will comment briefly the main characteristics of the model and those of its features which have been incorporated to the platform The trace model described in Burdalo et al 2010 offers any entity in the system active or passive the possibility to share information in the form of trace events with other entities in the system From the point of view of the trace model entities in the system are seen as tracing entities this is entities which are able to generate and or receive trace events Trace events are offered by tracing entities as different tracing services which can be requested by interested tracing entities when they want to receive these trace events 3 8 1 1 Supported Features The present version of Magentix2 does not support all of the tracing features considered in the model Those which are not yet supported will be incorporated in future versions of the 1 2 3 3 Programming Agents 81 pla
165. rvic method of the SFProxy class is invoked The following code shows how to register it in the organization ArrayList lt String gt resultRegister sfProxy registerServic Minas localhost 8080 testSFservices testSFservices owl owls Addition OE E 114 4 2 Programming agents which use THOMAS Type Service Description Inputs Output Registration Register Registers a ser Service URL Description of what Service vice or part of it is registered and com plete OWL S specifi cation Deregister Deregisters Service profile Ok if it is deregistered Service a complete Else error description service Affordability Remove Removes a Service profile Ok if it is removed Provider provider agent provider name Else error description organization or or grounding web service of ID a service Discovery Get Ser Gets the OWL Service profile OWL S specification vice S description of of the service or error the service description Search Searches a ser Inputs Out Weighted services list Service vice puts Key or error description words Table 4 8 SF Proxy API The Register Service tries to register the service that is specified as parameter The parameter is the original URL of the OWL S specification of the service The contents of the OWL S specification of a service must have the profile that describes the service and the process that desc
166. rviceTools OntologicalTypesConstants DOUBLE 9 searchOutputs add ServiceTools OntologicalTypesConstants DOUBLE r 1 searchKeywords add addition 3 ArrayList lt ArrayList lt String gt gt foundServices 5 do 6 Waiting for services 7 A 8 Thread sleep 2 1000 120 20 21 22 23 24 25 4 4 Programming Agents that Request Services catch InterruptedException e e printStackTrace foundServices sfProxy searchService searchInputs searchOutputs searchKeywords while foundServices isEmpty 4 4 3 Service Request Process e Request a service After the agent has found the desired service it has to get the main information of this service to make a request So the agent has to use the GetService to obtain the required data to specify the inputs of the service and to know the provider to ask and its parameters In the obtained OWL S specification with GetService is specified the providers of the service and their parameters To make a request of the service the provider has to be an agent or organization In case that the providers are web services with a grounding in the specification the service has to be executed by the requester agent Using the Oracle class provided in the package es upv dsic gti_ia organization the OWL S specification is parsed to obtain the information of the service including its inputs and its providers
167. rwise a new domain case is created and added to the case base The main methods of the Domain CBR are shown in Table 3 6 for a detailed explanation of all Domain CBR methods see the DomainCBR java associated JavaDoc 3 Programming Agents 69 Package Classes Description argCBR ArgCBR java This CBR stores argument cases that represent past argumenta tion experiences and their final argAgents outcome CommitmentStore java Agent that stores all the informa tion about the argumentation di alogues Configuration java Configuration parameters domCBR DomainCBR java This CBR stores domain knowl edge of previously solved prob lems knowledgeResources Package that contains the classes needed to manage the data of the CBRs and arguments Metrics java Used by the CBRs to measure the similarity between case at tributes based on their distance SimilarityAlgorithms java Contains algorithms to calcu late similarity measures between cases Argumentation Participant java Abstract class that defines the ar gumentation participant protocol to be followed by the CAgents CommitmentStore Protocol java Abstract class that defines the protocol that the Commitment Store follows to attend the peti tions of the agents cAgents protocols Table 3 5 Argumentative agents core packages and classes The Argumentation CBR can be used to look for previous argumentation experiences and use this knowledge to select the best pos
168. ry XStream Finally we assign the JSON object as the content of the response message Before we can test this example it is important to make sure that the example html file and the redirect php script are both in the same web server By security reasons cross commu nication between different hosts is forbidden Besides we have to specify in redirect php the address where our HTTP interface service is running We can indicate the address modifying the following line in redirect php Srequest new HTTP_Request2 http localhost 8081 HTTP_Request2 ME HODES PO Say In this example the HTTP interface is running in the localhost CHAPTER 6 Platform administration 6 1 Custom Installation 137 6 2 Apache Qpid cee eee eee eee 140 6 3 MYSQL crm eS es 4 ae OE eee aie 142 6 4 Apache TomMcat oooooooo o o o 145 6 5 Platform services oooo oooooo o o 147 6 6 Configuring security 150 6 1 Custom Installation The custom type installation allows selecting or un selecting individually packages to be in stall in the system If any of the following software have been installed in the system it is necessary to unselect these packages for installation Once the installation process finished the instructions cited here per each particular software must be followed e MySQL In order to work correctly with THOMAS it is nece
169. ry to assert a support argument to respond to the WHY received previously doAttack actions to perform to generate an attack argument against an attack or assert received doDie actions to perform when the message with locution DIE is received doEnterDialogue evaluates if the agent can enter in the dialogue offering a solution doFinishDialogue actions to be executed when the dialogue has to finish doGetPositions get the positions of the agents in the dialogue sent by the Commitment Store as an object doMyPositionAccepted actions to perform when the position of the agent has been accepted doNoCommit creates an ACLMessage to send with the locution NOCOMMIT doOpenDialogue takes the domain case to solve and the dialogue ID from the received ACLMessage given doPropose proposes a position to defend in the dialogue If it can not it does a WITHDRAWDIALOGUE doQueryPositions creates a message to send to the Commitment Store with locution GETALLPOSITIONS to obtain all the positions of the dialogue doSendPosition sends an ACLMessage with the position defended by the agent doSolution actions to perform when the final solution to the current problem to solve arrives in an ACLMessage doWhy choose a position to send a WHY message if it can Table 3 9 Methods to implement in the Argumentation Protocol and a file with a template of the tester agent TesterArgCAgent java In this section we provide a brief explanation of this example Deta
170. s R DELETE Grants the DELETE privil G Restore Backup R CREATE Grants the CREATE privil Replication status R DROP Grants the DROP privileg Catalogs R GRANT Grants the GRANT privile 4 y REFERENCES Grants the REFERENCES User Accounts IR INDEX Grants the INDEX privilec Anal ALTER Grants the ALTER privilec amp debian sys maint CREATE_TMP_TABLE Grants the CREATE_TMP 32 mot A LOCK_TABLES Grants the LOCK_TABLES anomie CREATE_VIEW Grants the CREATE_VIEW 20 R SHOW_VIEW Grants the SHOW_VIEW _ A CREATE ROUTINE Grants the CREATE_ROU A ATER ROUTINE be lt n B A i Ma sl DP Note grayed privileges mean they are provided through Global Privileges b New User eS Discard Changes Apply Changes Processing backup file Figure 6 4 Assigning privileges to the thomas user in the User Administration option of the MySQL Administration tool 6 4 Apache Tomcat Apache Tomcat is a main component of Magentix2 because it allows to access to standard Java web services If Apache Tomcat was installed during the Magentix2 Desktop version 146 6 4 Apache Tomcat installation it will not be necessary to follow the steps shown here On the contrary in case Apache Tomcat was not installed together with Magentix2 or Apache Tomcat was already installed on the system this section helps to configure it properly THOMAS platform is based on services chapter 4 so
171. s shown This IP corresponds to the FIPA Request Interaction Protocol FIPA 2002 for the initiator role In figure 3 6 a global view of a CAgent is shown In this figure the agent shown has three CFac tories two of them are participant and the third one is initiator At the same time the agent has two ongoing CProcessors that manage two conversations Conv1 and Conv2 The first one has been created by the initiator CFactory 1 the other one by the participant CFactory 1 The initiator CFactory 1 created the CProcessor managing Conv1 because the execution of the agent dictates that instead the Conv2 was created by the participant CFactory 1 because the agent received an inform message From this moment on every message with the message parameter conversation_id set to Conv1 will be automatically assigned to the CProcessor managing that conversation The same will occur with Conv2 messages If in the future the agent receives a request message the participant CFactory 2 will create a new CProcessor which will manage the new conversation Other possibility is that the agent receives an in 36 3 4 Advanced conversational agents CAgents Agent we Participant Factory pe l 4 Infprm Participant Factory 2 Initiator Factory 1 Request lt lt _ _ gt Figure 3 6 Global view of a CAgent form message with an unknown conversation_id In that case the participant CFactory 1 will create a
172. s upv dsic gti_ia organization OMS import es upv dsic gti_ia organization SF import es upv dsic gti_ia core AgentID public class Main public static void main String args throws Exception AgentsConnection connect OMS agentOMS OMS getOMS SE Agen USE eo bg Ste agentOMS start agentSF start In the code shown above the agents OMS and SF are created lines 11 12 The creation of these agents does not require any parameter In line 10 the connection of the agents to the platform is set using the method Agent sConnec tion connect The parameters for this connection are specified in the configuration file Settings xml The method AgentsConnection connect should not be called if the platform security is enabled Once the agents have been created with the desired parameters both are started lines 13 amp 14 This Java program has to be manually executed when starting Magentix2 platform 150 6 6 Configuring security 6 6 Configuring security 6 6 1 Introduction Figure 6 6 shows an overview of the Magentix2 security infrastructure Magentix2 Manage ment Service MMS is a entity of Magentix2 that manages a part of the security of the plat form is located at the right of Figure 6 6 In fact MMS is responsible of controlling the user accesses to the platform Users will be present a certificate issued by a trusted third party cer tificate authority the red one in Figure 6 6
173. setContent Hello I m getName Sending a ACLMessage send msg 3 2 3 Receiving Messages Whenever a message is posted in the message queue of an agent this agent is notified by the onMessage ACLMessage msg method This method allows agents to receive any message 3 Programming Agents 25 automatically Note that agents can also keep all received messages in an internal list or queue for reading them later Agent programmers must overwrite the onMessage method when implementing a new agent in order to process received messages For instance public void onMessage ACLMessage msg When a message arrives it is shown in the screen logger info Mensaje received in this getName agent by onMessage msg getContent 3 2 4 External Communication An external agent is any agent not running over Magentix2 platform but communicating to any of the agents running on Magentix2 In this sense Magentix2 implements the FIPA HTTP message transport protocol by means of two special Magentix2 agents e BridgeAgentInOut this agent is implemented in the es upv dsic gti_ia core BridgeAgentInOut class This agent is in charge of receiving all the messages sent by Magentix2 agents in which the recipient are agents running on another platform that uses http as communication protocol Then the BridgeAgentInOut encapsulates the entire message and sends it via http e BridgeAgentOut
174. sg setSender this getAid response_msg setContent NO response_msg setReceiver msg getSender send response_msg 3 8 8 Main application source code package TraceDaddy import org apache log4j Logger 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 98 import import import import 3 8 Tracing Service org apache log43 xml DOMConfigurator es upv dsic gti_ia core AgentID es upv dsic gti_ia core AgentsConnection es upv dsic gti_ia trace TraceManager public class Run public ES tabi svordemarn String lll args 4 Boy olderSon youngerSon Daddy dad Vx Setting the Logger DOMConfigurator configure configuration loggin xml Logger logger Logger getlogger Run class xx Connecting to Opid Broker AgentsConnection connect ena Al xx x Instantiating the Trace Manager TraceManager tm new TraceManager new AgentID TM System out println INITIALIZING xx Instantiating Dad x dad new Daddy new AgentID qpid MrSmith localhost OOS OMe aye x Instantiating sons x olderSon new Boy new AgentID qpid Timmy localhost 28080 7 dad getAid 42 43 44 45 46 47 48 49 50 51 52 53 54 3 Programming Agents youngerSon new Boy new AgentID qpid Bobby localhost SD O dad EGE
175. sitions and arguments are specified as methods to facilitate a better understanding of 3 Programming Agents 71 Method Description doCache Stores the current domain cases case base in a specified file path doCachelInc Stores the current domain cases case base in a specified file path but keeping the contents of that file loadCaseBase Loads a case base stored in a specified file path Table 3 8 Main CBR persistence methods the code and to facilitate modifications and updates The main method of the argumenta tive agents is the execution method This method overwrites the execution method of the Magentix2 CAgent implementing the argumentative functions of the agent Inside the execution method the myArgumentation class extends the argumentation protocol of Magentix2 Concretely the argumentation API of Magentix2 includes two special proto cols that allow agents to argue the Argumentation_Participant protocol and the CommitmentStore_Protocol Both are abstract classes of the cAgents protocols package that argumentative agents and the commitment store extend respectively These classes provide a template for the behaviour of the argumentative agents and the commitment store Each one implements a new CFactory see CAgent JavaDoc for more information with the graph that specifies the sequence of states and transitions among them that agents can pass through during the argumentation dialogue Therefore to create
176. sk is added a new thread is created for the agent Therefore it is necessary to be careful which the main thread of the agent is not finished For instance a monitor can be used to wait for the completion of the roles import es upv dsic gti_ia architecture Monitor private Monitor monitor new Monitor protected void execute this addTask new FIPARequestInitiator this msg monitor waiting 3 3 4 Examples In the examples folder of the Magentix2 packages there are some basic interaction protocols examples e Request this example follows the FIPA Request protocol In this example two agents are created One agent plays the responding role by simulating a hospital which listens emergency calls The other agent simulates an accident witness When the witness see an accident sends a help message to the hospital The hospital checks if the accident is placed in the action area and if it could attend it e ContractNet this is an example where the FIPA ContractNet protocol is followed In this example two types of agents are created One type of agents plays the responding 34 3 4 Advanced conversational agents CAgents role dealers The other type a single agent plays the initiator role buyer The buyer sends a purchase request to each dealer agent Each dealer agent answers the bid accord ing her preferences and waits for the buyer decision The buyer chooses one offer and informs the specific dealer and
177. ss is shown This class has to extend BaseAgent class 3 1 1 Therefore it is necessary to import some classes from magentix2 2 01 jar with dependencies zip Once the library is included Eclipse suggests you to import the necessary classes that library Figure 2 2 shows Sender java at that moment As it can be seen in the figure the code of the agent has an error because it lacks a constructor So a basic constructor which calls the constructor of the base class is created a 6 ui so G sy PB a m fir gr e e 5 laava i Package Explorer 33 E CAR M Main java O Task List 2 le Y ge MyFirstAgent package agent Mer xog ee gt import es upv dsic gti_ia core ACLMessage PE Y l agent import es upv dsic gti_ia core Agent1D Ss i Consumerjava import es upv dsic gti_ia core Baseagent Uncategorized gt D Mainjava E public class Sender extends BaseAgent a gt m JRE System Library JavaSE 1 6 Y m Referenced Libraries gt Gi magentix2 2 01 jar with dependencies zip H y Y configuration clientrepo i loggin xml Connect Mylyn Xx policy xml Connect to your task and ALM A securityUser properties R Settings xml BE Outline E 20 4 arte Xx agent Y import declarations 4 es upv dsic gti_ia core ACLMes 4 es upv dsic gti_ia core AgentID es upv dsic gti_ia core BaseAge e El Problems 2 Javadoc Declaration 1 error O warnings O others Description R
178. ssary to add a new user called thomas and to create the THOMAS schema in the MySQL database The following command must be executed cd Magentix2 bin MySOL sh Import ThomasDB sh MYSQL _ROOT_PASS This command creates The installation of any of these software components can cause conflicts in the system if already they exists 137 138 6 1 Custom Installation User thomas with password thomas THOMAS schema This contains all database tables and relationships needed for the THOMAS system e Apache Tomcat To configure Apache Tomcat to work properly with Magentix2 it is needed to move the content from the THOMAS directory to the current webapps tomcat directory S cd Magentix2 thomas mv tomcat_directory webapps e Apache Qpid The broker Qpid must be running in the system in order to connect agents cd SQPID_INSTALLATION sbin qpidd On the other hand if any of these components were installed during the Magentix2 Desktop version installation they would be configured as follows e MySQL it would be installed in the directory mysql By default mysql root password is mypassword this can be change in any moment e Apache Tomcat it would be installed in the directory apache tomcat 7 0 4 and 8080 1s the port configured to receive services petitions The Catalina out is a log for tomcat it can be found in log tomcat directory e Apache Qpid it would be installe
179. st in which the JADE agent is running receiver host hostname domain JADE default port for ACC receiver port 7778 Default protocol receiver protocol http xx x Building a ACLMessage x New Request messag ACLMessage msg new ACLMessage ACLMessage REQUEST The JAD msg setReceiver receiver E agent is added as a receiver of the message The Magentix2 agent sends the message send msg In a similar way the following example shows how an external JADE agent sends a message to a MAgentix2 agent from the JADE platform JADE source code AID receiver new AID agentname hotsname of the Magentix2 platform in which the agent SEUA Aen y receiver setName Consumer hostname 3 Programming Agents 27 Host in which the BridgeAgentOutIn agent is been executed and the port jnewhalchy ait assy dsitstened receiver addAddresses http host domain 8081 Creation of a Request Messag ACIMessage msg new ACLMessage ACLMessage REQUEST Addition of the receiver of the message msg addReceiver receiver Sending the message send msg 3 3 Basic conversational agents QueueAgents Magentix2 supports the set of basic interaction protocols defined by FIPA Thereby agents can communicate to each other by means of different protocols explained in this section Each implemented prot
180. t lt entry key SFServiceDescriptionLocation gt http localhost 8080 sfservices services lt entry gt Check if the direction where agents OMS and SF are running is different host from where the services OMS and SF are deployed or if the port is different If the OMS and SF are running in the same host that web services are deployed the configuration by default is correctly In the same way in order to run any developed web service from Tomcat it is necessary to copy the packaged library serviceName war to the subdirectory webapss of the Tomcat installa tion directory In Magentix2 Desktop Version there is an example of a user web service called 6 Platform administration 147 SearCheapHotel It is possible to run this example by means of coping the packaged library SearchCheapHotel war located at the Magentix2 thomas directory to the subdirectory webapss of Tomcat Once all the necessary services have been properly copied to the webapss directory Tomcat can be started running the startup sh file on the bin subdirectory of the Tomcat installation directory webapps File Browser File Edit View Go Bookmarks Tabs Help lt qBack v Forward v tj A a Location Magentix2 apache tomcat 7 0 4 webapps d Q 100 Q IconView docs examples host manager manager MMS omsservices ROOT SearchCheapHotel sfservices omsservices war SearchCheapHotel sfservices war war
181. t 9 lt profile contactInformation gt 4 Virtual Organizations 117 If the provider is a web service the corresponding grounding has to be specified as standard specification of the OWL S services including its WSDL document URL to execute the service RegisterService http url service owl Service Registered http url service owl ServiceProfile Agent Figure 4 5 Agent interaction protocol to register a service Thus the agent can make a call to register a service specifying the url of the service OWL S specification as we can see in this code example 2 ArrayList lt String gt resultRegister sfProxy registerService http localhost 8080 testSFservices testSFservices owl owls Addition owl e Registering new providers When a service is already registered it is possible to add new providers agents organizations or web services The RegisterService of the SF detects automatically if the profile of the given OWL S specification is already regis tered in the SF and just adds the new providers to the SF database The given OWL S specification must have the same profile so the SF recognize that is the same service and it associates the new providers to the registered service see Figure 4 6 RegisterService http url service2 owl 0 groundings and 2 providers registered to service profile Agent http url service2 owl ServiceProfile Figure 4 6 Agent interaction protocol to
182. t It also searches for a service to make the product and another one to square In these cases it finds the Product service and the Square service It makes a GetService of the two services to obtain their information 5 The James agent requests the Addition service to add 3 and 4 Then with this result requests the Product service to multiply it by 5 Finally the result of this operation is used to square it with the Square service that is provided by a web service This implies that the James agent has to execute it itself by using the Service Tools provided in the Magentix2 API The James agent has obtained the final result of the equation that it wanted to solve Then it sends a message to the Initiator agent to inform that the example has ended 6 The Initiator agent receives the message informing that the example has ended It deal locates all the roles and deregisters all services roles and units To run the example the user has to enter in the Magentix2 examples folder where it has been installed Then the user has to execute the Start ThomasExample sh script with administrator privileges cd Magentix2 examples bin sudo sh Start ThomasExample sh 4 6 Programming agents which use organizational messag ing This section describes how an agent that wants to send a message to an organization can build fill the fields of an ACLMessage and send the organizational message The following example is used in order to il
183. t is only necessary to execute the script bin Qpid Start QpidWithSecurity sh in order to execute Qpid with security For installing the Qpid dependencies please refer to the section 6 2 Once the basic dependen cies are resolved follow the next steps 1 Installing the following libraries before building the source distribution of Qpid with security SSL and SASL must be installed e libnss3 1d e libnspr dev e libnss3 dev e libnss3 tools e libsasl2 dev e sasl2 bin On Ubuntu operating systems these packages can be installed using the Synaptic package management tool but any other package manager might be valid 2 Downloading the 919487 Qpid revision which already supports the security EXTER NAL mechanism svn r 922479 co http svn apache org repos asf qpid trunk 3 Accessing to trunk qpid cpp directory 4 Executing the bootstrap command bootstrap 11 To install subversion the following command should be used sudo apt get install subversion 12 Autoconf and libtool are required 164 6 6 Configuring security 5 Configuring the package configure prefix QPID_INSTALL_DIR with ssl with sasl lt prefix gt Selecting the directory where Qpid will be installed 6 Compiling and installing the package S make install 6 6 9 2 Executing Once the infrastructure of certificates is correctly configured and Qpid broker is installed with security support only it remains
184. t but from SingleAgent section 3 1 2 this allows using the receiveACLMessage method This method halts the agent execution until it receives a message The method execute of the Consumer agent does nothing but wait until the agent receives a message When the agent receives a message it assigns the message to the variable msg and then it shows the message content on the console Once both agents are programmed the Main java class should be programmed This class is in charge of connecting the agents to the broker and starting their execution The code of this class is shown below package agent 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 2 Quick Start 15 import import import import org apache log43 Logger org apache log43 xml DOMConfigurator es upv dsic gti_ia core AgentID es upv dsic gti_ia core AgentsConnection public class Main public static void main String args xx x Setting the Logger DOMConfigurator configure configuration loggin xml Logger logger Logger getLogger Main class ee Connecting to Qpid Broker AgentsConnection connect localhost 5672 test guest guest false try Vice x Instantiating a sender agent x Sender senderAgent new Sender new AgentID Sender Instantiating a consumer agent Consumer consumerAgent new Consumer
185. t that has received an ATTACK from an opponent agent tries to reply with another ATTACK In this case the proponent agent will move back to the state Wait Attack to wait for the response of the opponent agent However if the proponent agent is not able to counter attack it must move back to the state Propose with the locution NOCOMMIT to withdraw its position from the dialogue and if possible propose another generated position Query Positions in this state the agent that has decided to challenge the positions of other agents requests the commitment store the list of current positions proposed in the dialogue with the locution GETALLPOSITIONS Get Positions the agent that has requested the commitment store for active positions in the dialogue moves to this state to wait for an answer Here the agent can receive the list of positions with the same locution GETALLPOSITIONS Alternatively the agent can receive a FINISHDIALOGUE locution in this state and it will go to the state Send Position to start the actions to leave the dialogue when it has proposed yet a position 3 Programming Agents 65 11 12 13 14 15 16 17 Also if the agent does not receive any response before a specified timeout it will move back again to the state Central Why in this state the agent that has received a list of potential positions to challenge makes a random choice to challenge one of them with the locut
186. tID BridgeAgentOutIn inOutAgent start outInAgent start In the code shown above when the bridge agents are created lines 11 12 they receive a new AgentID as argument This new AgentID gets only one argument the name of the agent Platform agents like bridge agents must always have a well known name For bridge agents the names must be BridgeAgentInOut and BridgeAgentOutIn respectively In line 8 the connection of the agents to the platform is set using the method Agent sConnec tion connect The parameters for this connection are specified in the configuration file Settings xml The method Agent sConnection connect should not be called if the platform security is enabled Once the agents have been created with the desired parameters both are started lines 13 amp 14 This Java program has to be manually executed when starting Magentix2 platform 6 Platform administration 149 6 5 2 Running OMS and SF Agents OMS and SF agents provide all the services of Thomas framework These agents can be run ning on any host they don t have to be in the same host where the QPid broker or other agents are running A Java program has to be written and executed in order to launch OMS and SF agents The following code shows how to launch these agents import es upv dsic gti_ia architecture Monitor import es upv dsic gti_ia core AgentID import es upv dsic gti_ia core AgentsConnection import e
187. te domain cases with a similarity degree to the given domain cases The similarity is calculated using normalized Tversky distance among the premises Table 3 2 Methods to compute the distance and similarity between cases The specific algorithm that an argumentative agents uses to compute the similarity degree be 60 3 6 Argumentative Agents tween two cases can be set in the configuration xml file of the configuration pack age shown below lt root gt lt domaincbr gt lt similarity gt normalizedEuclidean lt similarity gt lt normalizedEuclidean or weightedEuclidean or normalizedTversky gt lt domaincbr gt lt root gt SUPPORT ARGUMENTS MANAGEMENT A list of possible support arguments is generated with the method generateSupportArgument s by using different combinations of the available support elements in the support set This list is ordered by using the suitability degree explained before and the argument that has the higher degree is proposed first as support argument to justify the agent s position ATTACK ARGUMENTS MANAGEMENT To generate an attack argument the premises that the argument to attack has and the social context between the agents that are arguing are taken into account With this information ar gumentative agents extract the argument cases that match with the current position and have a similar social context Then if the dependency relation allows to attack the
188. tform e Tracing Entities Although the model considers not only agents but also non agent entities or aggrega tions event tracing facilities incorporated to the present version of Magentix2 platform only consider agents Artifacts and aggregations will be included in future versions of the platform Publication and Subscription Publication and unpublication of trace events is completely supported in the present ver sion of the platform so tracing entities can dynamically at run time publish the event types which they can throw and unpublish them when they do not want to share that information anymore In the same way tracing entities can dynamically subscribe to trace events in which they are interested and unsubscribe from them whenever they do not want to receive these trace events anymore However although the model lets tracing entities filtering trace events according to many parameters the present version of Magentix2 only allows agents to filter trace events according to the event type and the agent which threw the event Tracing services composition has also been postponed for later platform releases and thus it is not supported in the present version of Magentix2 Authorization Security issues addressed by the model have also been postponed for future versions of the platform and they are not considered in this version Thus any agent in the system can request trace events from any other agent without needing
189. the 13th International Conference of the Catalan Association for Artificial Intelligence volume 220 pages 89 98 IOS Press Heras S 2011 Case Based Argumentation Framework for Agent Societies PhD thesis De partamento de Sistemas Inform ticos y Computaci n Universitat Polit cnica de Val ncia http hdl handle net 10251 12497 Rao A S 1996 Agentspeak 1 Bdi agents speak out in a logical computable language In Modelling Autonomous Agents in a Multi Agent World MAAMAW pages 42 55 Springer Verlag Val E D Criado N Rebollo M Argente E and Julian V 2009 Service Oriented Framework for Virtual Organizations In International Conference on Artificial Intelli gence ICAI volume 1 pages 108 114 CSREA Press Walton D Reed C and Macagno F 2008 Argumentation Schemes Cambridge University Press 165
190. the argumentation dialogue adding and updating cases into the domain and argumentation case bases in each CBR run e Commitment Store is a resource of the argumentation framework that stores all the information about the agents participating in the problem solving process argumentation dialogues between them positions and arguments By making queries to this resource every agent of the framework can read the information of the dialogues that it is involved in To facilitate the communication among argumentative agents and the commitment store this resource has been implemented as a Magentix2 CAgent 3 6 2 1 Argumentative Agents ArgCAgent Class With the class ArgCAgent java Magentix2 distribution includes an implementation of an ar gumentative agent This agent is an extension of the Magentix2 conversational agent CAgent see Section 3 4 Argumentative agents have two CBR modules Domain CBR and Argumen tation CBR The main functionalities of the argumentative agents are the generation selection and evaluation of positions and arguments These are specified as methods to facilitate a better understanding of the code and to facilitate modifications and updates Table 3 4 provides an overview of the main methods used to manage positions and arguments in the ArgCAgent java class Next we explain how argumentative agents can manage positions and arguments POSITION MANAGEMENT A position is a solution that defends an agent as th
191. the current state of the organization In formRole InformUnit InformUnitRoles InformAgentRole InformMembers Quanti tyMembers e Dynamic services that allow managing role enactment and dynamic entry exit of agents AcquireRole LeaveRole AllocateRole DeallocateRole 4 2 Programming agents which use THOMAS 4 2 1 Magentix2 API for THOMAS SF and OMS have been defined as two types of intermediary agents in order to address the translation between Magentix2 agents or any external agent that implement FIPA commu nication and the services they provide Services requests through FIPA request protocol were received by this type of agents To ease the interaction among user agents and OMS and SF agents two classes are provided OMSProxy and SFProxy They work as a proxy for OMS and SF respectively encapsulating and hiding the details of the underlying communication protocol By doing this the developer can interact with OMS and SF using simple function calls 4 2 1 1 OMSProxy The OMSProxy can be found in the package es upv dsic gti_ia organization To use its functionality a new instance of the OMSProxy class must be created to access the 1 110 4 2 Programming agents which use THOMAS methods contained in the OMS In the constructor the agent who executes the service has to be specified There are two options In the first one the url where OMS services are deployed is taken from the settings xml configuration f
192. the method createReply included in ACLMessage messages This method produces a new answer to the original message with the required fields covered so only required ones need to be modified 1 protected ACLMessage prepareResultNotification ACLMessage inmsg 2 ACLMessage outmsg 3 4 ACLMessage msg inmsg createReply 5 return msg 6 3 3 2 How to implement a FIPA Protocol Following some explanations of how the FIPA Protocols proportionated by Magentix2 have been implemented are proportioned in order to illustrate how new protocols could be imple mented 3 3 2 1 FIPA Request This protocol allows agents to request other agents to perform an action and it is identified in the protocol parameter of the message with the FIPA request value The messages exchanged are 1 Request which contents the request 30 3 3 Basic conversational agents QueueAgents 2 Agree or Refuse when the agent accepts the request or rejects it respectively 3 Failure when the previous message was an Agree and an error happened during the process 4 Inform done when the previous message was an Agree and the process ends success fully 5 Inform result when the previous message was an Agree the process ends successfully and there is also a result The protocol early terminates if e The initiator send to the responder a message explicitly CANCEL instead of the next initiator e The responder responds n
193. this case it is necessary to create a new class that extends the template FIPA REQUEST Ini tiator lines 6 12 This class has an abstract method that is mandatory to implement the doInform method lines 7 11 This method is executed when the initiator receives the results of what it requested All the other methods for the other states have a default behaviour that can be modified in this example it is not necessary to do so The message that contains the request is created lines 17 21 Afterwards a CFactory from the template is created line 29 During the creation it is required to specify the name of the new CFactory the request message the agent owner of the CFactory and the time in milliseconds that the agent will wait for the inform or failure message Once the CFactory template is defined it is possible to create a new instance from it Finally the just created CFactory is added to the agent line 30 and in the last line of the code a synchronous conversation from this CFactory is started In this example the agent is going to act as the initiator in the REQUEST protocol defined by FIPA In order to do so she has to extend the class FIPA_REQUEST_Initiator implementing the method that receives results of the request dolnform class myFIPA_REQUEST extends FIPA_REQUEST_Initiator protected void dolnform CProcessor myProcessor ACLMessage msg We
194. tion AgentsCreation java This class has different methods to create groups of agents and Argumentation Example some of their parameters ArgCA gent java This class implements the argu mentative agent as a CAgent It can engage in an argumentation dialogue to solve a problem CreatePartitionsjava This class creates different partitions of domain cases and argument cases to make tests TestArgCA gent java This class launches a test with argumentative agents including the commitment store and a tester agent that acts as initiator of the dialogue TesterArgCAgent java This class represents a tester agent in charge of sending the test domain case to solve to a group of agents and acts as the initiator of the dialogue TestArgumentation datafiles partitionsInc Folder with the data files to per form tests Table 3 3 Argumentation example packages and classes If the user wants to use a different configuration of the parameters of the example it is nec essary to modify the source code of the example see Table 3 3 To do it the user has to use the source code from the Magentix2 src directory and create a project to modify the code The Magentix2 library must be included in the project The steps to perform this task are explained 3 Programming Agents 67 in Section 2 3 In this case the code to modify is located in the Argumentation_Example pack age The main class to execute tests is TestArgCAgent java In th
195. to subscribe to them before receiving any trace event they may provide An example of use of these tracing services can be observed in Section 3 8 6 in line number 20 The daddy agent requests the tracing service NEW_AGENT in order to receive a trace event each time a new agent 90 3 8 Tracing Service enters the system These events are later processed in the event handler in line number 67 More details on these tracing services and on how to understand the information provided by these trace events are available in Table 3 16 Table 3 16 Agent s lifecycle related domain independent tracing services NEW_AGENT A new agent Agent Id executing in a host host was registered in the system tService NEW_AGENT 4 originEntity system host content AgentId AGENT DESTROYED An agent Agent 1d executing in a host host was destroyed tService AGENT_DESTROYED 5 originEntity system host content AgentId 3 8 4 3 Messaging related domain independent tracing services These domain independent tracing services provide information related to message based agent communication These tracing services are also requestable and thus it is also necessary to sub scribe to them before receiving any trace event they may provide An example of use of these tracing services can be observed in Section 3 8 6 in line number 68 where the daddy
196. tp en wikipedia org wiki Universally_unique_identifier 5 HTTP Interface 135 e MarketAgent This agent receives the request from the web page example html and re turns an appropriate product The example html webpage uses several javascript libraries in order to send the HTTP POST request asynchronously These libraries are included in the head section of the html code The html file also uses our javascript library Magentix2 js When the user submits the form the javascript function transformData is called function transformData var pp f1 serializeArray var data createJSONOb ject MarketAgent pp requestAppData data This function takes every input of the form and constructs an associative array with them Then it calls to the function createJSONObject of the Magentix2 js library The parameters are MarketA gent the name of our agent and the array with the content of the form The resulting JSON object will be something like this agent_name MarketAgent conversation_id 5ala2c78 91b2 465c SS ASS a O COME SM EY SU A o EUA Finally the transformData calls the function requestAppData with the JSON object as parame ter function requestAppData data mposta redirect php data functeson result etalkentk Data Loaded JSON parse result json This function calls the jquery function post with the following parameters Redirect php is the php script that will red
197. umentative Agent Magentix2 provides the core of the argumentation protocol the Domain CBR the Argumen tation CBR and the knowledge resources see Table 3 5 needed to crete your own argumenta tive agent and not directly using the default argumentative agent provided in the Argumenta tion_Example The main tasks to perform to create an argumentative agent are e To use the Domain CBR to store and retrieve domain knowledge e To use the Argumentation CBR to store and retrieve argumentation knowledge e To implement the argumentation protocol methods and thus specify how to perform the actions of the argumentative agent in the states of the designed argumentation protocol The Domain CBR can be used to generate and select positions to defend in the argumentation dialogue To make a query to the domain CBR the user has to provide a problem codified as a list of premises or a domain case without solution and a threshold of similarity The domain CBR module searches the domain case base and returns a list of similar domain cases to the given problem In addition with every request attended and every CBR cycle performed the module adds modifies or deletes one or more domain cases of the domain case base In the current version of the API if the problem that has been solved is similar enough over certain similarity threshold to a case of the domain cases case base the update algorithm updates this case with the new data acquired Othe
198. uted by the first CProcessor It is also in this method where all other actions and behaviours of the agent has to be implemented protected void execution CProcessor myProcessor welcomeMessage ACLMessage System out printin myProcessor getMyAgent getName op ls welcome abe Ws i System out println myProcessor getMyAge teh messag inevitably I have to say hello ShutdownAgent method initialize the finalize the active conversations of the agent W the platform fe myProcessor ShutdownAgent sends a finalize message to the agen welcomeMessage getContent nt getName WO molt es process which will hen this process ends the user has to In order to manage the finalization mes implement the finalize method defined by the protected void finalize CProcessor myProce finalizeMessage Sage CAgent class ssor ACLMessage System out printin myProcessor getMyAgent getName the finalize message is fin O alizeMessage getContent 38 3 4 Advanced conversational agents CAgents 3 4 2 Creating a CFactory and its CProcessor The code shown in this section corresponds to the code located in examples src myFirstCPro cessorFactories Harry java The CFactory shown here corresponds to the one shown in figure 3 7 Send Purpose Wait Receive Final OPRA AO Figure 3 7 myFirstCProcessorFactories example In order to
199. w server certificate to the brokers certificate database in the server_db directory with the broker nickname S certutil A d broker_db n broker a i broker_db server crt t e Verifying if the certificate is valid certutil V d broker_db u V n broker At the end the following message must be showed certificate is valid 156 6 6 Configuring security 6 6 4 3 Magentix2 Management Service This certificate identifies the MMS which will be signed by the Magentix CA In this section how to create a new MMS keystore and trustore is explained Importing the CA certificate in to the trust store and import the CA certificate in to the key store need for client authentication keytool import trustcacerts alias MagentixCA file CA_db rootca crt keystore MMSkeystore jks keytool import trustcacerts alias MagentixCA file CA_db rootca crt keystore MMStruststore jks In this step the password for key store and trust store are introduced Afterwards will be referenced as PASSWORD_MMSKEYSTORE and PASSWORD_MMSTRUSTSTORE re spectively Generating keys for the MMS certificate keytool genkey alias MMS keyalg RSA dname CN MMS O Magentix keystore MMSkeystore jks Press enter when prompted for the password to select the same password as the key store Creating a certificate request keytool certreq alias MMS keystore MMSkeystore jks
200. ween user agent and SF agent through the SFProxy 4 Virtual Organizations cific role OMS Service Description Parameters AcquireRole Requests the adoption of a spe RoleID Identifier of the role cific role within a unit UnitID Identifier of the unit LeaveRole Requests to leave a role RoleID Identifier of the role UnitID Identifier of the unit AllocateRole Forces an agent to acquire a spe RoleID Identifier of the role cific role UnitID Identifier of the unit TargetAgentID Identifier of the agent DeallocateRole Forces an agent to leave a spe RoleID Identifier of the role UnitID Identifier of the unit TargetAgentID Identifier of the agent Table 4 6 OMS Proxy Dynamic services API OMS Service Description Parameters buildOrganizationalMessage Builds a new orga nizational message OrganizationID Identifier of the organization Table 4 7 OMS Proxy Organizational messaging service API 4 2 1 3 Basic Service Management 113 Services are composed by a profile which is a semantic description of the service useful for customers to locate appropriate service and a process which details how to interact with the service Different agents can provide different processes different implementations to the same service profile general description When an agent needs to register a new service in the organization the RegisterSe
201. y method in a conversation state has to return the name of the state the CProcessor will travel to In this examples the begin state always travels to the state called PROPOSE In line 16 the method just defined is associated to the begin state Starting at line 18 a new send state is defined called PROPOSE Once the state is created it is necessary to define a method for this state A method for a send state has to return the name of the next state and also has to assign a value to the variable messageToSend which is passed to the method as an argument As can be seen the message is going to be sent to agent Sally and the objective of the message is to propose Sally to go to the cinema Once the state PROPOSE has been created registered and all the transitions to it have been 3 Programming Agents 39 added In line 31 a new wait state called WAIT is created This type of states does not need a method to execute During its creation it is necessary to define the name of the state and the timeout in this case 1000ms It is possible to define a wait state that will wait an unlimited amount of time until a message is received if the timeout is set to 0 A transition from PROPOSE state to this wait state is added After a wait state it is mandatory to define one or more receive states In this example it is only defined one receive state A receive state needs a method to execute and a message filter This f
202. ys hello and shows its name on the console line 14 A new ACLMessage called msg is created line 15 The performative of this message is Inform This agent Sender agent is set as the sender of the message line 16 The Consumer agent is added as a receiver of the agent line 17 The content of the message msg is specified line 18 Finally the agent sends the message and with this ends its execution line 19 Now it is time to program the Consumer agent This agent will wait until it receives the message from the Sender agent Then it will show the content of the message on the console and it ends its execution The code of the Consumer agent is shown below 20 21 22 23 24 25 1 14 2 3 Developing and executing a first agent package agent import es upv dsic gti_ia core ACLMessage import es upv dsic gti_ia core AgentID import es upv dsic gti_ia core SingleAgent public class Consumer extends SingleAgent boolean gotMsg false public Consumer AgentID aid throws Exception super aid public void execute System out println Hi I m agent this getName and I start my execution ACIMessage msg null try msg this receiveACLMessage catch InterruptedException e e printStackTrace System out printin Hi I m agent this getName and I ve received the message msg getContent This agent does not extend from BaseAgen
Download Pdf Manuals
Related Search
Related Contents
Supermicro P4SCE motherboard PDFカタログ JVC 120000 User's Manual WCS-6006 english user manual D.lgs. 9 aprile 2008, n. 81 Medusa DVR User Manual - CCTV Ireland CCTV Ireland PS6S1800M User Guide - Pdfstream.manualsonline.com Copyright © All rights reserved.
Failed to retrieve file