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

Last change on this file since 290 was 288, checked in by Tim Baarslag, 5 years ago

Everything works with general Agents now

File size: 3.5 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.CoordinationMessage;
9import onetomany.bargainingchipsgame.players.Coordinator;
10import onetomany.bargainingchipsgame.players.NegotiationStatusMessage;
11import onetomany.bargainingchipsgame.players.SimpleBuyer;
12import onetomany.bargainingchipsgame.players.SimpleSeller;
13import onetomany.bargainingchipsgame.players.utilityfunction.UF_AllOrNothing;
14import onetomany.bargainingchipsgame.players.utilityfunction.UF_IWantColorAndQuantity;
15
16/**
17 * This package describes all the fundamental concepts in Bargaining Chips Game (BCG).
18 *
19 * BCG rules are based on a non-alternating offer protocol in each bilateral negotiation thread.
20 * Multiple deals via simultaneous threads in the BCG one-to-many negotiation need to be coordinated.
21 * So the players are equipped with two modules, one coordinator and multiple negotiators one per each thread.
22 *
23 * One-to-Many package is dedicated to one-to-many negotiation which is a kind of negotiation different from bilateral and multilateral settings.
24 * It is between a party which, in parallel, negotiates with many counter parties, opponents, on multiple multi-issue items.
25 * Of course each opponent, in turn, could be in one-to-many negotiation with its own opponents including this party.
26 *
27 * Each of these individual negotiations is itself a bilateral negotiation over multiple items and multiple issues, a multi-issue multi-item thread. Each thread could reach a deal.
28 * So, the whole negotiation could reach multiple deals.
29 *
30 * Negotiating in this atmosphere needs some coordination efforts to synchronize threads according to the progress of each individual negotiation as well as the multiple deals compared with the party's preference.
31 *
32 * Bargaining Chips Game, is a testbed dealing with these complexities.
33 * The fundamental elements of its domain is in a package with this name (bargainingchipsname).
34 * The players and the rules for their interactions are in packages `players' and 'interactions', respectively.
35 *
36 *
37 */
38public class BargainingChips
39{
40 public static void main(String[] args) throws InterruptedException
41 {
42 Domain domain = new Domain();
43 domain.add("Red"); domain.add("Green"); domain.add("Blue");
44
45 OutcomeSpace outcomeSpace = new OutcomeSpace(domain);
46
47 BlockingQueue<Offer> in = new LinkedBlockingQueue<Offer>();
48 BlockingQueue<Offer> out = new LinkedBlockingQueue<Offer>();
49
50 BlockingQueue<CoordinationMessage> cin = new LinkedBlockingQueue<CoordinationMessage>();
51 BlockingQueue<NegotiationStatusMessage> cout = new LinkedBlockingQueue<NegotiationStatusMessage>();
52
53 // Bob
54 WishList wishlist = new WishListBuilder().addWish("Green", 2).build();
55 UF_AllOrNothing u = new UF_AllOrNothing(wishlist, 20.0);
56 Agent bob1 = new SimpleBuyer("Bob 1", u, in, out, cin, cout);
57
58 Coordinator c = new Coordinator(wishlist, cout, cin);
59
60 // Sam
61 UF_IWantColorAndQuantity uSam = new UF_IWantColorAndQuantity("Green", 2);
62 Agent sam = new SimpleSeller("Sam", uSam, out, in);
63
64 Thread threadBuyer = new Thread(bob1);
65 threadBuyer.start();
66
67 Thread threadSeller = new Thread(sam);
68 threadSeller.start();
69
70 Thread threadCoordinator = new Thread(c);
71 threadCoordinator.start();
72 }
73
74}
Note: See TracBrowser for help on using the repository browser.