1 | package agents.anac.y2017.tangxun;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | import genius.core.AgentID;
|
---|
7 | import genius.core.Bid;
|
---|
8 | import genius.core.actions.Accept;
|
---|
9 | import genius.core.actions.Action;
|
---|
10 | import genius.core.actions.Offer;
|
---|
11 | import genius.core.parties.AbstractNegotiationParty;
|
---|
12 | import genius.core.parties.NegotiationInfo;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * This is your negotiation party.
|
---|
16 | */
|
---|
17 | public class taxibox extends AbstractNegotiationParty {
|
---|
18 | private double emax, target, shiwang, taxi, target1, target2, A, wangu1, B,
|
---|
19 | avg, P, Z, Y, M, C, zishen, yingxiang, target3, x, wangu;
|
---|
20 | private Bid lastReceivedBid = null;
|
---|
21 |
|
---|
22 | @Override
|
---|
23 | public void init(NegotiationInfo info) {
|
---|
24 | double t = info.getTimeline().getTime();
|
---|
25 | super.init(info);
|
---|
26 |
|
---|
27 | List<Double> arr = new ArrayList<Double>();// 收集对手提案在我方的效用值
|
---|
28 | for (int i = 0; i <= 1000; i++) {
|
---|
29 | if (i < 1) {
|
---|
30 | B = 0.1;
|
---|
31 | } else
|
---|
32 |
|
---|
33 | arr.add(B);
|
---|
34 | if (i > 0) {
|
---|
35 | P = arr.get(i - 1);
|
---|
36 | }
|
---|
37 | System.out.println(B);
|
---|
38 | }
|
---|
39 | double sum = 0;
|
---|
40 |
|
---|
41 | for (int i = 0; i < arr.size(); i++) {
|
---|
42 | sum = sum + arr.get(i);
|
---|
43 |
|
---|
44 | avg = sum / arr.size();// 对手提案在我方的效用值的平均值
|
---|
45 | if (i > 0) {
|
---|
46 | A = avg;
|
---|
47 | }
|
---|
48 |
|
---|
49 | }
|
---|
50 | wangu = B - P;
|
---|
51 | wangu1 = Math.abs(B - P);
|
---|
52 |
|
---|
53 | emax = A + (1 - A) * wangu1;
|
---|
54 | target = 1 - (1 - emax) * Math.pow(t, 3);
|
---|
55 | // 例:時間依存の線形な譲歩関数
|
---|
56 |
|
---|
57 | shiwang = target - B;
|
---|
58 | target1 = 1 - (1 - emax) * Math.pow(t, (2.7 + shiwang - t));
|
---|
59 |
|
---|
60 | System.out.println(target1);
|
---|
61 |
|
---|
62 | info.getUtilitySpace().getDomain().getIssues().size();
|
---|
63 |
|
---|
64 | // if you need to initialize some variables, please initialize them
|
---|
65 | // below
|
---|
66 |
|
---|
67 | }
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Each round this method gets called and ask you to accept or offer. The
|
---|
71 | * first party in the first round is a bit different, it can only propose an
|
---|
72 | * offer.
|
---|
73 | *
|
---|
74 | * @param validActions
|
---|
75 | * Either a list containing both accept and offer or only offer.
|
---|
76 | * @return The chosen action.
|
---|
77 | */
|
---|
78 |
|
---|
79 | @Override
|
---|
80 | public Action chooseAction(List<Class<? extends Action>> validActions) {
|
---|
81 | double t = timeline.getTime();
|
---|
82 | List<Double> arr = new ArrayList<Double>();// 收集对手提案在我方的效用值
|
---|
83 | for (int i = 0; i <= 1000; i++) {
|
---|
84 | if (i < 1) {
|
---|
85 | B = 0.1;
|
---|
86 | } else
|
---|
87 |
|
---|
88 | arr.add(B);
|
---|
89 | if (i > 0) {
|
---|
90 | P = arr.get(i - 1);
|
---|
91 | }
|
---|
92 | System.out.println(B);
|
---|
93 | }
|
---|
94 | double sum = 0;
|
---|
95 |
|
---|
96 | for (int i = 0; i < arr.size(); i++) {
|
---|
97 | sum = sum + arr.get(i);
|
---|
98 |
|
---|
99 | avg = sum / arr.size();// 对手提案在我方的效用值的平均值
|
---|
100 | if (i > 0) {
|
---|
101 | A = avg;
|
---|
102 | }
|
---|
103 |
|
---|
104 | }
|
---|
105 | wangu = B - P;
|
---|
106 | wangu1 = Math.abs(B - P);
|
---|
107 |
|
---|
108 | emax = A + (1 - A) * wangu1;
|
---|
109 | target = 1 - (1 - emax) * Math.pow(t, 3);
|
---|
110 | // 例:時間依存の線形な譲歩関数
|
---|
111 |
|
---|
112 | shiwang = target - B;
|
---|
113 | target1 = 1
|
---|
114 | - (1 - emax) * Math.pow(0.8 * t, (3 + 2 * shiwang - 0.8 * t));
|
---|
115 |
|
---|
116 | System.out.println(target1);
|
---|
117 |
|
---|
118 | // with 50% chance, counter offer
|
---|
119 | // if we are the first party, also offer.
|
---|
120 |
|
---|
121 | if (getUtility(lastReceivedBid) >= target1
|
---|
122 | && validActions.contains(Accept.class)) {
|
---|
123 | return new Accept(getPartyId(), lastReceivedBid);
|
---|
124 | }
|
---|
125 | Bid newBid = generateRandomBid();
|
---|
126 | int i = 999;
|
---|
127 |
|
---|
128 | while (i > 0 || lastReceivedBid != null || lastReceivedBid == null) {
|
---|
129 | newBid = generateRandomBid();
|
---|
130 |
|
---|
131 | if (getUtility(newBid) >= target1)
|
---|
132 | break;
|
---|
133 |
|
---|
134 | i--;
|
---|
135 |
|
---|
136 | }
|
---|
137 | return new Offer(getPartyId(), newBid);
|
---|
138 | }
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * All offers proposed by the other parties will be received as a message.
|
---|
142 | * You can use this information to your advantage, for example to predict
|
---|
143 | * their utility.
|
---|
144 | *
|
---|
145 | * @param sender
|
---|
146 | * The party that did the action. Can be null.
|
---|
147 | * @param action
|
---|
148 | * The action that party did.
|
---|
149 | */
|
---|
150 | @Override
|
---|
151 | public void receiveMessage(AgentID sender, Action action) {
|
---|
152 | super.receiveMessage(sender, action);
|
---|
153 | if (action instanceof Offer) {
|
---|
154 | lastReceivedBid = ((Offer) action).getBid();
|
---|
155 | }
|
---|
156 | }
|
---|
157 |
|
---|
158 | @Override
|
---|
159 | public String getDescription() {
|
---|
160 | return "ANAC2017";
|
---|
161 | }
|
---|
162 |
|
---|
163 | }
|
---|