source: src/main/java/agents/anac/y2017/farma/etc/NegoHistory.java

Last change on this file was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 2.5 KB
Line 
1package agents.anac.y2017.farma.etc;
2
3import java.util.HashMap;
4import java.util.Map;
5
6import genius.core.list.Tuple;
7import genius.core.parties.NegotiationInfo;
8import genius.core.persistent.PersistentDataContainer;
9import genius.core.persistent.PersistentDataType;
10import genius.core.persistent.StandardInfo;
11import genius.core.persistent.StandardInfoList;
12
13/**
14 * Created by tatsuya_toyama on 2017/05/16.
15 */
16
17public class NegoHistory {
18 private NegotiationInfo info;
19 private StandardInfoList history;
20 private boolean historyAnalyzed = false;
21
22 private boolean isPrinting = false; // デバッグ用
23 private boolean isPrinting_History = false;
24
25 /**
26 * @param info
27 * @param isPrinting
28 * @param pData
29 * public PersistentDataContainer getData(): persistent data
30 */
31 public NegoHistory(NegotiationInfo info, boolean isPrinting, PersistentDataContainer pData) {
32 this.info = info;
33 this.isPrinting = isPrinting;
34
35 // PersistentDataType が Standard の場合
36 if (pData.getPersistentDataType() == PersistentDataType.STANDARD) {
37 history = (StandardInfoList) pData.get();
38
39 if (!history.isEmpty()) {
40 // example of using the history. Compute for each party the
41 // maximum
42 // utility of the bids in last session.
43 Map<String, Double> maxutils = new HashMap<String, Double>();
44 StandardInfo lastinfo = history.get(history.size() - 1);
45 for (Tuple<String, Double> offered : lastinfo.getUtilities()) {
46 String party = offered.get1();
47 Double util = offered.get2();
48 maxutils.put(party, maxutils.containsKey(party) ? Math.max(maxutils.get(party), util) : util);
49 }
50 System.out.println(maxutils); // notice tournament suppresses
51 // all
52 // output.
53 }
54 }
55
56 if (this.isPrinting) {
57 System.out.println("[isPrinting] NegoHistory: success");
58 }
59
60 }
61
62 public void analyzeHistory() {
63 historyAnalyzed = true;
64
65 // from recent to older history records
66 for (int h = history.size() - 1; h >= 0; h--) {
67
68 System.out.println("History index: " + h);
69
70 StandardInfo lastinfo = history.get(h);
71
72 int counter = 0;
73 for (Tuple<String, Double> offered : lastinfo.getUtilities()) {
74 counter++;
75
76 String party = offered.get1(); // get partyID -> example:
77 // ConcederParty@15
78 Double util = offered.get2(); // get the offer utility
79
80 System.out.println("PartyID: " + party + " utilityForMe: " + util);
81 System.out.println();
82 // just print first 3 bids, not the whole history
83 if (counter == 3)
84 break;
85 }
86
87 System.out.println("\n");
88
89 }
90
91 }
92}
Note: See TracBrowser for help on using the repository browser.