Practical works on Multi-Agent Oriented Programming

A possible partial implementation of the applications is available as a tutorial of the jacamo platform available at http://jacamo.sourceforge.net. You can use it as starting point.

Building House

In this exercise, you will develop the multi-agent system for managing and executing the general workflow describing the tasks to build an house.

Artifact-Based Auction House

  • Let's develop a MAS where agents use an artifact to execute an auction protocol to allocate a set of tasks between them. You can get here the specification of the global application.
  • The contractor agent, "giacomo" creates an artifact of this type for each of the tasks it needs to allocate the tasks to "company" agents: e.g. one auction artifact for building the walls, another one for setting the floors, …
  • The "company" agents observe the artifacts that propose a task compatible with goals and skills. They use these artifacts for bidding according to their own strategies.

Auction Artifact

  • The "AuctionArt" artifact has the following observable properties:
    • "task": task description,
    • "maxValue": maximum payment value,
    • "currentBid": current best bid (lower service price),
    • "currentWinner": current winning agent ID
  • It has the following operations:
    • "bid(p)": places a new bid for doing the task for price "p". If the bid is better than the previous one, the "currentBid" and the "currentWinner" are updated.
    • "init(task,maxp)": initializes the artifact with the task description "task" that will be auctionned and the maximum value for the bid "maxp".

How to get the agent executing an action:

  • In an artifact, to obtain the agent that has launched the execution of an action, use the "getOpUserName" method
  • Exercise: Auction Artifact
    • Create a Jason project called "auction".
    • Write the "AuctionArt" artifact

Owner Agent

  • The "giacomo" agent is in charge of creating the auction house, i.e. to create an artifact of the type "AuctionArt" for each of the tasks to allocate.
  • It is also in charge of driving and managing the auctions (the creation of an auction artifact consists in declaring the task that is managed by the artifact and the maximum possible price for it).
  • The agent waits for a certain amount of time for the bids. At the fixed time, the agent gets the winner for each of the tasks.
  • Exercise: Owner Agent
    • Complete the "giacomo" agent for managing the auctions as described above
    // Agent giacomo
    
    /* Initial beliefs and rules */
    my_task("SitePreparation").
    my_task("Floors").
    my_task("Walls").
    
    my_max_bid("SitePreparation",2000).
    my_max_bid("Floors",1000).
    my_max_bid("Walls",3000).
    
    /* Initial goals */
    
    !contract.
    
    /* Plans */
    
    +!contract : true <- 
            !create_auction_house;
            !wait_for_bids.
    
     +!create_auction_house <-
            for (my_task(Task) & my_max_bid(Task,MaxPrice)) {
                    !create_auction_artifact(Task,MaxPrice);
                    .println("creating an auction artifact for ",Task);     
            }.
            
    +!create_auction_artifact(Task,MaxPrice) <-
            makeArtifact(Task,"easss.auction.AuctionArt",[Task,MaxPrice],ArtId);
            focus(ArtId).
    
    -!create_auction_artifact(Task,MaxPrice)[error_code(Code)] <-
            .print("Error creating auction artifact ",Code).
    
    +!wait_for_bids <-
            .print("Waiting for bids for 5 seconds ...");
            .wait(5000);
            !show_winners.
    ...
    

Iteration implementation

  • The implementation of the iteration on the auction artifacts can be done using the for construct:
Implementation of for.

Syntax:
  for ( logical formula ) {
     plan_body
  }

for all unifications of logical formula, the plan_body is executed.

Example:

+event : context
  <- ....
     for ( vl(X) ) {
        .print(X);     // print all values of X
     }
     for ( .member(X,[a,b,c]) ) {
        .print(X);    // print all members of the list
     }
     for ( .range(I,1,10) ) {
        .print(I);    // print all values from 1 to 10
     }
     ....

The unification resulting from the evaluation of the logical formula is used only inside the loop, i.e., the unification after the for is the same as before. 

Company Agents

  • The company agents discover the auction artifacts corresponding to the tasks they are interested in. They build the bids according to their own strategies.
  • Exercise: Company agents
    • Write a "company_blind" agent interested in the tasks "sitePreparation", "Floors", "Walls" having a "blind" strategy for bidding: it decreases the current bid by a constant value until his/her lowest limit is reached.
    • Write a "company_strategies" agent having multiple strategies for each task (choose which strategy to use)
    • Write a "company_coordinated" agent having a maximum value for all the tasks it bids for (i.e. coordination of the bids it realizes on each task)
  • How to make agents aware that it is winning an auction
    • You can use the following code for making an agent aware that it is winning or not an auction:
    i_am_winning(Art)   // check if I placed the current best bid on auction artifact Art
       :- currentWinner(W)[artifact_id(Art)] & .my_name(Me) & .term2string(Me,MeS) & W == MeS.
    
    • You can use the following code for summing all the current bids placed by the agent
    sum_of_my_offers(S) :- 
       .my_name(Me) & .term2string(Me,MeS) &
       .findall( V,      // artifacts/auctions I am currently winning
                 currentWinner(MeS)[artifact_id(ArtId)] &
                          currentBid(V)[artifact_id(ArtId)], 
                 L) & 
       S = math.sum(L).
    

Managing Workflow based on the signed Contract

  • Let's now develop the second part of the building house multi-agent system aiming at managing the execution of the general workflow describing the tasks to build an house (see eop practical lesson.
  • A possible partial implementation of this application is available as a tutorial of the jacamo platform available at http://jacamo.sourceforge.net. You can use it as starting point (you already have started to develop this application while building the auction house).
  • The description of the steps and design choices are available here.

Exercise:

  • Develop an agent that tries to adopt roles related to tasks he/she is not supposed to (malevolent agent)
  • Develop an agent that does not fulfill the tasks
  • Change the Giacomo agent so that it is able to monitor the building of the house and check whether the tasks are being done appropriately: reacting to the norm violation, to the norm fulfillement.
  • Add any improvement you wish.

Metal Manufacture

ToBeCompleted

Conference Management

Coming Soon

Request for Tender

Coming Soon

Auctions

A Oriented Programming version

Coming Soon

AE Oriented Programming version

Coming Soon

AO Oriented Programming version

Coming Soon

AEO Oriented Programming version

Coming Soon

Writing Paper

AO Oriented Programming version

Coming Soon

AEO Oriented Programming version

Coming Soon


Olivier Boissier, Rafael Bordini, Jomi Hubner, Alessandro Ricci, June 2014