1 | package agents.anac.y2014.E2Agent.myUtility;
|
---|
2 |
|
---|
3 | import java.io.Serializable;
|
---|
4 | import java.util.ArrayList;
|
---|
5 | import java.util.Collection;
|
---|
6 | import java.util.Collections;
|
---|
7 | import java.util.Comparator;
|
---|
8 | import java.util.HashMap;
|
---|
9 | import java.util.List;
|
---|
10 | import java.util.Random;
|
---|
11 |
|
---|
12 | import agents.anac.y2011.TheNegotiator.BidsCollection;
|
---|
13 | import agents.anac.y2012.MetaAgent.agents.WinnerAgent.opponentOffers;
|
---|
14 | import genius.core.Agent;
|
---|
15 | import genius.core.Bid;
|
---|
16 | import genius.core.NegotiationResult;
|
---|
17 | import genius.core.actions.Accept;
|
---|
18 | import genius.core.actions.Action;
|
---|
19 | import genius.core.actions.Offer;
|
---|
20 | import genius.core.issue.Issue;
|
---|
21 | import genius.core.issue.IssueInteger;
|
---|
22 | import genius.core.issue.Value;
|
---|
23 | import genius.core.issue.ValueInteger;
|
---|
24 | import genius.core.timeline.Timeline;
|
---|
25 | import genius.core.utility.*;
|
---|
26 |
|
---|
27 | public class SessionData implements Serializable {
|
---|
28 | private static final long serialVersionUID = 1L;
|
---|
29 |
|
---|
30 | ArrayList<BidStorageList> sessionsBitStorageList = null;
|
---|
31 | ArrayList<Boolean> agreementList = null;
|
---|
32 | ArrayList<BidStorage> lastBidList = null;
|
---|
33 | ArrayList<Double> discountedUtilList = null;
|
---|
34 |
|
---|
35 | public SessionData(int sessionTotal) {
|
---|
36 | sessionsBitStorageList = new ArrayList<BidStorageList>(sessionTotal);
|
---|
37 | agreementList = new ArrayList<Boolean>(sessionTotal);
|
---|
38 | lastBidList = new ArrayList<BidStorage>(sessionTotal);
|
---|
39 | discountedUtilList = new ArrayList<Double>();
|
---|
40 | }
|
---|
41 |
|
---|
42 | public void save(int sessionNr, BidStorageList bidList,
|
---|
43 | NegotiationResult result, double utility, double time) {
|
---|
44 | sessionsBitStorageList.add(bidList);
|
---|
45 | agreementList.add(result.isAgreement());
|
---|
46 | System.out.println(result.isAgreement());
|
---|
47 | lastBidList.add(new BidStorage(result.getLastBid(), utility, time));
|
---|
48 | discountedUtilList.add(result.getMyDiscountedUtility());
|
---|
49 | }
|
---|
50 |
|
---|
51 | public Parameters getParamters(double res, double dis) {
|
---|
52 | double u = 0;
|
---|
53 | double t = 0;
|
---|
54 | double agreementCount = 0;
|
---|
55 |
|
---|
56 | int size = lastBidList.size();
|
---|
57 | Parameters p = null;
|
---|
58 | for(int i=0; i<size; ++i) {
|
---|
59 | if(agreementList.get(i)) {
|
---|
60 | agreementCount += 1;
|
---|
61 | u += lastBidList.get(i).getUtility();
|
---|
62 | t += lastBidList.get(i).getTime();
|
---|
63 | }
|
---|
64 | }
|
---|
65 | if(agreementCount>0) {
|
---|
66 | p = new Parameters(u/agreementCount, t/agreementCount,
|
---|
67 | 2.5*(2/(1+dis)), 2, 0.2*(1-dis));
|
---|
68 | } else {
|
---|
69 | p = new Parameters(1, 0,
|
---|
70 | 2.5*(2/(1+dis)), 2, 0.2*(1-dis));
|
---|
71 | }
|
---|
72 |
|
---|
73 | p.g *= Math.pow(1.1, size-agreementCount);
|
---|
74 | if(size > 0 && agreementList.get(size-1)==false) {
|
---|
75 | int count = 0;
|
---|
76 | for(int i=size-1; i>=0; --i) {
|
---|
77 | if(agreementList.get(i)) {
|
---|
78 | break;
|
---|
79 | }
|
---|
80 | count += 1;
|
---|
81 | }
|
---|
82 | p.beta *= Math.pow(0.9, count);
|
---|
83 | }
|
---|
84 |
|
---|
85 | return p;
|
---|
86 | }
|
---|
87 | }
|
---|