source: src/main/java/agents/anac/y2017/tangxun/taxibox.java@ 46

Last change on this file since 46 was 46, checked in by Tim Baarslag, 6 years ago

agents get their getUtilitySpace() from the API, not the info object anymore

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