[268] | 1 | package onetomany.bargainingchipsgame;
|
---|
| 2 |
|
---|
[269] | 3 | import java.util.concurrent.BlockingQueue;
|
---|
| 4 | import java.util.concurrent.LinkedBlockingQueue;
|
---|
| 5 |
|
---|
| 6 | import onetomany.bargainingchipsgame.interactions.Offer;
|
---|
[287] | 7 | import onetomany.bargainingchipsgame.players.Agent;
|
---|
[309] | 8 | import onetomany.bargainingchipsgame.players.BoulwareAgent;
|
---|
[278] | 9 | import onetomany.bargainingchipsgame.players.CoordinationMessage;
|
---|
[279] | 10 | import onetomany.bargainingchipsgame.players.Coordinator;
|
---|
[278] | 11 | import onetomany.bargainingchipsgame.players.NegotiationStatusMessage;
|
---|
[302] | 12 | import onetomany.bargainingchipsgame.players.utilityfunction.UF_CloseToQuantity;
|
---|
[301] | 13 | import onetomany.bargainingchipsgame.players.utilityfunction.UtilityFunction;
|
---|
[269] | 14 |
|
---|
[268] | 15 | /**
|
---|
[310] | 16 | * This main class describes the fundamental concepts in the Bargaining Chips game.
|
---|
[268] | 17 | *
|
---|
[310] | 18 | * Bargaining Chips is based on an asynchronous offer protocol in each bilateral negotiation thread.
|
---|
| 19 | * Multiple deals in simultaneous threads of one-to-many negotiation need to be coordinated; therefore,
|
---|
| 20 | * the buyer is equipped with two modules, one coordinator and multiple negotiators one per each thread.
|
---|
[272] | 21 | *
|
---|
[310] | 22 | * Each of the individual negotiations is itself a bilateral negotiation over multiple items and multiple
|
---|
| 23 | * issues, i.e. a multi-issue multi-item thread. As each thread could reach a deal, the whole negotiation
|
---|
| 24 | * could reach multiple deals.
|
---|
[272] | 25 | *
|
---|
[310] | 26 | * Negotiating in this setting needs some coordination efforts to synchronize threads according to the
|
---|
| 27 | * progress of each individual negotiation as well as the multiple deals compared with the party's preference.
|
---|
[272] | 28 | *
|
---|
[310] | 29 | * Bargaining Chips is a testbed for evaluating agents in such settings.
|
---|
[268] | 30 | *
|
---|
| 31 | */
|
---|
| 32 | public class BargainingChips
|
---|
| 33 | {
|
---|
[269] | 34 | public static void main(String[] args) throws InterruptedException
|
---|
[268] | 35 | {
|
---|
[269] | 36 | BlockingQueue<Offer> in = new LinkedBlockingQueue<Offer>();
|
---|
| 37 | BlockingQueue<Offer> out = new LinkedBlockingQueue<Offer>();
|
---|
[268] | 38 |
|
---|
[279] | 39 | BlockingQueue<CoordinationMessage> cin = new LinkedBlockingQueue<CoordinationMessage>();
|
---|
[278] | 40 | BlockingQueue<NegotiationStatusMessage> cout = new LinkedBlockingQueue<NegotiationStatusMessage>();
|
---|
| 41 |
|
---|
[309] | 42 | NegotiationContext context = new NegotiationContext();
|
---|
[302] | 43 |
|
---|
[288] | 44 | // Bob
|
---|
| 45 | WishList wishlist = new WishListBuilder().addWish("Green", 2).build();
|
---|
[302] | 46 | UtilityFunction u = new UF_CloseToQuantity(wishlist);
|
---|
[309] | 47 | Agent bob1 = new BoulwareAgent("Bob 1", u, context, in, out, cin, cout);
|
---|
[281] | 48 |
|
---|
[310] | 49 | // Coordinator
|
---|
[284] | 50 | Coordinator c = new Coordinator(wishlist, cout, cin);
|
---|
[268] | 51 |
|
---|
[288] | 52 | // Sam
|
---|
[302] | 53 | WishList wishlistSam = new WishListBuilder().addWish("Green", 10).build();
|
---|
| 54 | UtilityFunction uSam = new UF_CloseToQuantity(wishlistSam);
|
---|
[310] | 55 | Agent sam = new BoulwareAgent("Sam 1", uSam, context, out, in);
|
---|
[288] | 56 |
|
---|
[310] | 57 | // Start threads
|
---|
| 58 | System.out.println(bob1.toDescription());
|
---|
| 59 | System.out.println("vs");
|
---|
[302] | 60 | System.out.println(sam.toDescription());
|
---|
| 61 |
|
---|
[273] | 62 | Thread threadBuyer = new Thread(bob1);
|
---|
| 63 | threadBuyer.start();
|
---|
[269] | 64 |
|
---|
[273] | 65 | Thread threadSeller = new Thread(sam);
|
---|
| 66 | threadSeller.start();
|
---|
[279] | 67 |
|
---|
| 68 | Thread threadCoordinator = new Thread(c);
|
---|
| 69 | threadCoordinator.start();
|
---|
[268] | 70 | }
|
---|
| 71 |
|
---|
| 72 | }
|
---|