source: src/main/java/agents/anac/y2018/condagent/ConDAgent.java

Last change on this file was 345, checked in by Tim Baarslag, 4 years ago

Fixed agent 2018 descriptions

File size: 3.8 KB
Line 
1package agents.anac.y2018.condagent;
2
3import java.util.List;
4
5import genius.core.AgentID; //Unique ID for an agent
6import genius.core.Bid; //modified copies using putValue(int, Value)
7import genius.core.actions.Accept;
8import genius.core.actions.Action;
9import genius.core.actions.Offer;
10import genius.core.parties.AbstractNegotiationParty;
11import genius.core.parties.NegotiationInfo;
12import genius.core.timeline.Timeline; //A time line, running from t = 0 (start) to t = 1 (deadline).
13import genius.core.utility.AdditiveUtilitySpace; // couples all objectives to weights and evaluators
14
15
16public class ConDAgent extends AbstractNegotiationParty {
17
18 BayesianOpponentModel OMone;
19 BayesianOpponentModel OMtwo;
20 IssueManager IM;
21 private Bid lastReceivedBid = null;
22 AgentID agentOne=null;
23 AgentID agentTwo=null;
24
25
26 public void init(NegotiationInfo info) {
27
28 //arxikopoihsh olwsn twn metavlitwn mou
29 super.init(info);
30
31 try{
32
33 //kanei intiallize to opponent model me vasi to utilspace kai to timeline
34 this.OMone = new BayesianOpponentModel((AdditiveUtilitySpace) this.utilitySpace);
35 this.OMtwo = new BayesianOpponentModel((AdditiveUtilitySpace) this.utilitySpace);
36
37 //kanei intiallize to issue manager me vasi to utilspace to timeline kai to opponent model
38 this.IM = new IssueManager((AdditiveUtilitySpace)this.utilitySpace, (Timeline) this.timeline);
39
40 }catch(Exception e){
41 e.printStackTrace();
42 }
43 }
44
45 //epeksergaia twn bids olwn twn paiktwn
46
47 public void receiveMessage(AgentID sender, Action action) {
48
49 super.receiveMessage(sender, action);
50
51 if (lastReceivedBid == null){
52 agentOne = sender;
53 IM.agentA = agentOne;
54 }
55
56 if (sender!= agentOne){
57
58 sender = agentTwo;
59 IM.agentB = agentTwo;
60 }
61
62 if (action instanceof Offer){ //exw neo offer
63
64 //ta offer pou ginodai
65 lastReceivedBid = ((Offer) action).getBid(); //gia kathe bid
66
67
68 try {
69 IM.ProcessBid(sender, this.lastReceivedBid);
70 } catch (Exception var2_2) {}
71
72 //kanw update to poso simadiko einai gia ton adipalo
73 try {
74 if(sender==agentOne){
75 OMone.updateBeliefs(this.lastReceivedBid);
76 IM.LastAgentOneBid = lastReceivedBid;
77 }else{
78 OMtwo.updateBeliefs(this.lastReceivedBid);
79 IM.LastAgentTwoBid = lastReceivedBid;
80 }
81
82 } catch (Exception var2_2) {}
83 }
84
85 }
86
87 // dialegw to action mou -> accept h offer. an paizw prwtos mono offer
88
89 public Action chooseAction(List<Class<? extends Action>> validActions){
90
91 Bid myBid;
92 //an paizw prwtos
93 if (lastReceivedBid == null){
94
95 return new Offer(this.getPartyId(), IM.GetMaxBid());
96
97 }else{ //an den paizw prwtos
98
99 try{
100 //dexetai an to utility einai panw apo 0,95
101 if (this.utilitySpace.getUtility(this.lastReceivedBid) > 0.95) {
102 return new Accept(getPartyId(), lastReceivedBid);
103 }
104
105 //pairnei to threshold
106 double threshold = this.IM.CreateThreshold();
107
108 //dexetai an to utillity pou tou proteinete einai megalutero apto threshold tou
109 if (this.lastReceivedBid != null && this.utilitySpace.getUtility(this.lastReceivedBid) >= threshold) {
110 return new Accept(this.getPartyId(), lastReceivedBid);
111 }
112 }catch(Exception e){
113 e.printStackTrace();
114 }
115
116 double mythreshold = 1.0;
117 try {
118 mythreshold = this.IM.CreateThreshold();
119 } catch (Exception e) {
120 // TODO Auto-generated catch block
121 e.printStackTrace();
122 }
123 IM.numOfMyCommitedOffers++;
124 myBid = this.IM.GenerateBidWithAtleastUtilityOf(mythreshold);
125
126
127 return new Offer(this.getPartyId(), myBid);
128 }
129 }
130
131
132
133 @Override
134 public String getDescription() {
135 return "ANAC2018";
136 }
137
138 }
Note: See TracBrowser for help on using the repository browser.