12.2 What is Agent-Oriented Programming?

12.2 What is Agent-Oriented Programming?

Agent-oriented programming is the process of assigning the work a program has to one or more agents. The WBS (Work Breakdown Structure) consists only of agents. If all the work that a program does can be assigned to one or more agents, then it is a pure agent-oriented program and all of the design and development involved only requires agent-oriented programming. In many situations, agents will be involved with other kinds of objects and systems that are not agent-oriented and therefore the entire programming effort is not called agent-oriented programming, which is often the case when agents are involved with database servers, application servers, and other types of object-oriented systems. Whether producing software systems that are completely agent-oriented or only partially agent-oriented, agent-oriented programming produces rational object-oriented software components .

12.2.1 Why Agents Work for Distributed Programming

Practical distributed programs rise out of necessity. Typically, there is some resource located on another computer or network separated from the program that needs it. These resources often take the form of databases, Web servers, e-mail servers, application servers, printers, and large storage devices. The resources are usually managed by a piece of software called a server. The software that needs access to the resources is referred to a client. The fact that the resources are located on different computers than the client leads to distributed architectures. In most cases, it does not make sense to attempt to combine these programs into one large program that runs on a single computer and in a single address space. Furthermore, there are many programs developed at different times, by different developers, and for different purposes that end up taking advantage of each other's services. The application that uses these programs evolved over time and the result was a distrusted application. Since these programs are separate, they will each have their own address space and resources. When these programs are used together to form a single application or collectively solve a program they form a distributed program. It turns out that the distributed program architecture provides very flexible architectures that can be used for large-scale applications. In so many practical applications, the requirements for distribution are discovered after the fact. However, good software engineering and design techniques can be used to identify when applications should be distributed. Once you know that you need to develop a distributed application, the next question is how it should be distributed. What model should be used? Although there are very many different client-server and peer-to-peer models available in this book, we focus on only two: blackboard architectures and multiagent architectures.

Both of these architectures can take advantage of agents because agents are inherently self-contained, autonomous, and rational software structures. Because agents are rational it means they know their purpose. Regular objects have a purpose and agents know what that purpose is. Identifying the purpose of each aspect of a piece of software is a natural process. It is straightforward to recognize the purpose of a piece of software during the design phase. Assigning that purpose to an agent is an easy form of software decomposition. The WBS becomes a matter of which class of agent to delegate the work to. Since the agent is the unit of modularity in an AOP (agent-oriented program), the work of distribution is reduced to finding means for multiple agents to communicate. The process of designing the original agent class hides the effort required for identifying the WBS of a distributed program. Once we get over the hurdles that agents are really rational objects, we can then take advantage of the CORBA specification to design truly distributed multiagent systems. CORBA hides the complexity of distributed programming and communication over networks, intranets , and the Internet. Chapter 8 contains a simple overview of distributed programming using CORBA. Since agents are objects, the entire discussion of CORBA is applicable . Chapter 6 introduces the PVM (Parallel Virtual Machine). PVM can also be used to greatly simplify the communication between agents executing on different processes or on different computers. Agents can be implemented as CORBA objects, or they can be assigned to separate PVM processes. In both cases, the communication is simple and straightforward. When two or more agents are involved within a single application they are multiagent systems. The agents may still use CORBA, PVM, or the MPI (Message Passing Interface) to communicate if they are on the same computer. Agents within different processes may also use traditional methods of IPC such as fifos, shared memory, and pipes to communicate. There are three fundamental challenges in distributed programming:

  1. Identifying the WBS of the distributed solution

  2. Implementing effective and efficient communication between the distributed components

  3. Dealing with exceptions, errors, and partial failures

While there is nothing inherent within the notion of an agent class to deal with item 2, items 1 and 3 are almost implicit in the agent design itself. Each agent's rationality defines its purpose and thereby the part that it is to play in the software solution. Since agents are self-contained and autonomous, a good agent class design will include the necessary fault tolerance.

12.2.2 Agents and Parallel Programming

Agents deployed in an environment where multiple processors or concurrently executing threads offer the same advantages as they do in distributed programming, with the addition that cooperation between agents is much easier to program. The PVM and MPI environments can also be used for message passing between agents that are collectively solving some kind of problem. Again, the rationality of the agents makes it easier to understand to design the WBS for parallelism. The common obstacles encountered in parallel programming are:

  1. Dividing the work effectively and efficiently between two or more software components

  2. Coordinating the concurrently executing software components

  3. Designing appropriate communication (where needed) between the components

  4. Dealing with exceptions, errors, and partial failures (if the agents are on separate computers)

Multiagent parallel architectures tend to be loosely coupled , that is, the communication and the interdependency is minimal. Each agent knows its purpose and has methods to accomplish its purpose. Whereas obstacle 3 is not inherently dealt with by the agent class, obstacles 1, 2, and 4 are easily managed by the implicit capabilities of the agent classes. For example, the impact of obstacle 2 is reduced because each agent is rational, has a purpose, and has the ways and means to accomplish its purpose. So the responsibility is shifted away from some coordination and control algorithm to the actions of each agent. The impact of obstacle 4 is reduced because agents are self-contained, rational, and autonomous and a good class design will include the necessary fault tolerance. Since the agent's state is encapsulated, the responsibility to protect critical sections within the agent object is the responsibility of the agent class. The agent will enforce its own data access policies. Table 12-2 shows the state access polices from which agents can choose.

Table 12-2. State Access Policies

Read-Write Algorithm Types

Meaning

EREW

Exclusive Read Exclusive Write

CREW

Concurrent Read Exclusive Write

ERCW

Exclusive Read Concurrent Write

CRCW

Concurrent Read Concurrent Write

Each agent's class will determine which access policy is acceptable in a multiagent environment. In some cases, combinations of the access policies in Table 12-2 are implemented. This makes the parallel programming easier. The developer can work at a higher level without having to worry about mutexes , semaphores, and so on. Multiagent solutions allow the developer to work at a higher level without getting bogged down with the minutia of coordinating every function call and data access. Each agent has a purpose. Each agent is rational and therefore has a logic for achieving its purpose. The programming process looks alot more like task delegation as opposed to the typical task coordination paradigms for traditional parallel programming. Since agent-oriented programming is a specific kind of object-oriented programming, agents use a more declarative mode of parallel programming than the traditional procedural-based programming that is often implemented in languages such as Fortran or C. The developer specifies what needs to be done and which agents should do it and the parallelism almost takes care of itself. There is always some amount of coordination and communication programming required, but agent-oriented programming keeps it to a minimum. However, all these advantages depend on the existence of agent classes. Someone has to design and code the agent classes. Let's now look at what an agent class will contain.



Parallel and Distributed Programming Using C++
Parallel and Distributed Programming Using C++
ISBN: 0131013769
EAN: 2147483647
Year: 2002
Pages: 133

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net