source: src/main/java/onetomany/bargainingchipsgame/BargainingChips.java@ 310

Last change on this file since 310 was 310, checked in by Tim Baarslag, 5 years ago
File size: 3.0 KB
Line 
1package onetomany.bargainingchipsgame;
2
3import java.util.concurrent.BlockingQueue;
4import java.util.concurrent.LinkedBlockingQueue;
5
6import onetomany.bargainingchipsgame.interactions.Offer;
7import onetomany.bargainingchipsgame.players.Agent;
8import onetomany.bargainingchipsgame.players.BoulwareAgent;
9import onetomany.bargainingchipsgame.players.CoordinationMessage;
10import onetomany.bargainingchipsgame.players.Coordinator;
11import onetomany.bargainingchipsgame.players.NegotiationStatusMessage;
12import onetomany.bargainingchipsgame.players.utilityfunction.UF_CloseToQuantity;
13import onetomany.bargainingchipsgame.players.utilityfunction.UtilityFunction;
14
15/**
16 * This main class describes the fundamental concepts in the Bargaining Chips game.
17 *
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.
21 *
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.
25 *
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.
28 *
29 * Bargaining Chips is a testbed for evaluating agents in such settings.
30 *
31 */
32public class BargainingChips
33{
34 public static void main(String[] args) throws InterruptedException
35 {
36 BlockingQueue<Offer> in = new LinkedBlockingQueue<Offer>();
37 BlockingQueue<Offer> out = new LinkedBlockingQueue<Offer>();
38
39 BlockingQueue<CoordinationMessage> cin = new LinkedBlockingQueue<CoordinationMessage>();
40 BlockingQueue<NegotiationStatusMessage> cout = new LinkedBlockingQueue<NegotiationStatusMessage>();
41
42 NegotiationContext context = new NegotiationContext();
43
44 // Bob
45 WishList wishlist = new WishListBuilder().addWish("Green", 2).build();
46 UtilityFunction u = new UF_CloseToQuantity(wishlist);
47 Agent bob1 = new BoulwareAgent("Bob 1", u, context, in, out, cin, cout);
48
49 // Coordinator
50 Coordinator c = new Coordinator(wishlist, cout, cin);
51
52 // Sam
53 WishList wishlistSam = new WishListBuilder().addWish("Green", 10).build();
54 UtilityFunction uSam = new UF_CloseToQuantity(wishlistSam);
55 Agent sam = new BoulwareAgent("Sam 1", uSam, context, out, in);
56
57 // Start threads
58 System.out.println(bob1.toDescription());
59 System.out.println("vs");
60 System.out.println(sam.toDescription());
61
62 Thread threadBuyer = new Thread(bob1);
63 threadBuyer.start();
64
65 Thread threadSeller = new Thread(sam);
66 threadSeller.start();
67
68 Thread threadCoordinator = new Thread(c);
69 threadCoordinator.start();
70 }
71
72}
Note: See TracBrowser for help on using the repository browser.