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

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

UF_CloseToQuantity

Accept(Offer agreement)

File size: 3.9 KB
RevLine 
[268]1package onetomany.bargainingchipsgame;
2
[269]3import java.util.concurrent.BlockingQueue;
4import java.util.concurrent.LinkedBlockingQueue;
5
6import onetomany.bargainingchipsgame.interactions.Offer;
[287]7import onetomany.bargainingchipsgame.players.Agent;
[300]8import onetomany.bargainingchipsgame.players.BoulwareNegotiationParty;
[278]9import onetomany.bargainingchipsgame.players.CoordinationMessage;
[279]10import onetomany.bargainingchipsgame.players.Coordinator;
[278]11import onetomany.bargainingchipsgame.players.NegotiationStatusMessage;
[302]12import onetomany.bargainingchipsgame.players.utilityfunction.UF_CloseToQuantity;
[301]13import onetomany.bargainingchipsgame.players.utilityfunction.UtilityFunction;
[269]14
[268]15/**
16 * This package describes all the fundamental concepts in Bargaining Chips Game (BCG).
17 *
18 * BCG rules are based on a non-alternating offer protocol in each bilateral negotiation thread.
19 * Multiple deals via simultaneous threads in the BCG one-to-many negotiation need to be coordinated.
20 * So the players are equipped with two modules, one coordinator and multiple negotiators one per each thread.
[272]21 *
22 * One-to-Many package is dedicated to one-to-many negotiation which is a kind of negotiation different from bilateral and multilateral settings.
23 * It is between a party which, in parallel, negotiates with many counter parties, opponents, on multiple multi-issue items.
24 * Of course each opponent, in turn, could be in one-to-many negotiation with its own opponents including this party.
25 *
26 * 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.
27 * So, the whole negotiation could reach multiple deals.
28 *
29 * 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.
30 *
31 * Bargaining Chips Game, is a testbed dealing with these complexities.
32 * The fundamental elements of its domain is in a package with this name (bargainingchipsname).
33 * The players and the rules for their interactions are in packages `players' and 'interactions', respectively.
34 *
[268]35 *
36 */
37public class BargainingChips
38{
[269]39 public static void main(String[] args) throws InterruptedException
[268]40 {
[302]41// Domain domain = new Domain();
42// domain.add("Red"); domain.add("Green"); domain.add("Blue");
43// OutcomeSpace outcomeSpace = new OutcomeSpace(domain);
[285]44
[269]45 BlockingQueue<Offer> in = new LinkedBlockingQueue<Offer>();
46 BlockingQueue<Offer> out = new LinkedBlockingQueue<Offer>();
[268]47
[279]48 BlockingQueue<CoordinationMessage> cin = new LinkedBlockingQueue<CoordinationMessage>();
[278]49 BlockingQueue<NegotiationStatusMessage> cout = new LinkedBlockingQueue<NegotiationStatusMessage>();
50
[302]51 BlockingQueue<CoordinationMessage> dummyin = new LinkedBlockingQueue<CoordinationMessage>();
52 BlockingQueue<NegotiationStatusMessage> dummyout = new LinkedBlockingQueue<NegotiationStatusMessage>();
53
[288]54 // Bob
55 WishList wishlist = new WishListBuilder().addWish("Green", 2).build();
[302]56 UtilityFunction u = new UF_CloseToQuantity(wishlist);
[300]57 Agent bob1 = new BoulwareNegotiationParty("Bob 1", u, in, out, cin, cout);
[281]58
[300]59 System.out.println(bob1.toDescription());
[302]60 System.out.println("vs");
[300]61
[284]62 Coordinator c = new Coordinator(wishlist, cout, cin);
[268]63
[288]64 // Sam
[302]65 WishList wishlistSam = new WishListBuilder().addWish("Green", 10).build();
66 UtilityFunction uSam = new UF_CloseToQuantity(wishlistSam);
67 Agent sam = new BoulwareNegotiationParty("Sam 1", uSam, out, in, dummyin, dummyout);
[288]68
[302]69 System.out.println(sam.toDescription());
70
[273]71 Thread threadBuyer = new Thread(bob1);
72 threadBuyer.start();
[269]73
[273]74 Thread threadSeller = new Thread(sam);
75 threadSeller.start();
[279]76
77 Thread threadCoordinator = new Thread(c);
78 threadCoordinator.start();
[268]79 }
80
81}
Note: See TracBrowser for help on using the repository browser.