1 | package genius.core.events;
|
---|
2 |
|
---|
3 | import genius.core.Agent;
|
---|
4 | import genius.core.actions.Action;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * This class records details about an action of an agent. It is passed as event
|
---|
8 | * to interested parties (currently the logger&data display GUI). This is
|
---|
9 | * exclusively used for bilateral negotiation events.
|
---|
10 | *
|
---|
11 | *
|
---|
12 | * If there is a time-out or other protocol error, an additional EndNegotiation
|
---|
13 | * action will be created by the NegotiationManager and sent to listener.
|
---|
14 | *
|
---|
15 | * @author wouter
|
---|
16 | *
|
---|
17 | */
|
---|
18 | public class ActionEvent implements NegotiationEvent {
|
---|
19 | private static final long serialVersionUID = -7118939924897219697L;
|
---|
20 | Agent actor;
|
---|
21 | Action act; // Bid, Accept, etc.
|
---|
22 | int round; // integer 0,1,2,...: round in the overall bidding.
|
---|
23 | long elapsedMilliseconds; // milliseconds since start of nego. Using
|
---|
24 | // System.currentTimeMillis();
|
---|
25 | double time; // [0, 1] using Timeline
|
---|
26 | double normalizedUtilityA;
|
---|
27 | double normalizedUtilityB;
|
---|
28 | double utilADiscount;
|
---|
29 | double utilBDsicount;
|
---|
30 | String errorRemarks; // errors
|
---|
31 | /**
|
---|
32 | * Indicates whether it was the last actionevent of the negotiation session,
|
---|
33 | * so then we receiveMessage the table through {@link TournamentProgressUI2}
|
---|
34 | */
|
---|
35 | boolean finalActionEvent;
|
---|
36 |
|
---|
37 | public ActionEvent(Agent actorP, Action actP, int roundP, long elapsed, double t, double utilA, double utilB,
|
---|
38 | double utilADiscount, double utilBDsicount, String remarks, boolean finalActionEvent) {
|
---|
39 | actor = actorP;
|
---|
40 | act = actP;
|
---|
41 | round = roundP;
|
---|
42 | elapsedMilliseconds = elapsed;
|
---|
43 | time = t;
|
---|
44 | normalizedUtilityA = utilA;
|
---|
45 | normalizedUtilityB = utilB;
|
---|
46 | this.utilADiscount = utilADiscount;
|
---|
47 | this.utilBDsicount = utilBDsicount;
|
---|
48 | errorRemarks = remarks;
|
---|
49 | this.finalActionEvent = finalActionEvent;
|
---|
50 | }
|
---|
51 |
|
---|
52 | public double getUtilADiscount() {
|
---|
53 | return utilADiscount;
|
---|
54 | }
|
---|
55 |
|
---|
56 | public double getUtilBDsicount() {
|
---|
57 | return utilBDsicount;
|
---|
58 | }
|
---|
59 |
|
---|
60 | public String toString() {
|
---|
61 | return "ActionEvent[" + actor + "," + act + "," + round + "," + elapsedMilliseconds + "," + normalizedUtilityA
|
---|
62 | + "," + normalizedUtilityB + "," + errorRemarks + "]";
|
---|
63 | }
|
---|
64 |
|
---|
65 | public Agent getActor() {
|
---|
66 | return actor;
|
---|
67 | }
|
---|
68 |
|
---|
69 | public Action getAct() {
|
---|
70 | return act;
|
---|
71 | }
|
---|
72 |
|
---|
73 | public int getRound() {
|
---|
74 | return round;
|
---|
75 | }
|
---|
76 |
|
---|
77 | public long getElapsedMilliseconds() {
|
---|
78 | return elapsedMilliseconds;
|
---|
79 | }
|
---|
80 |
|
---|
81 | public double getTime() {
|
---|
82 | return time;
|
---|
83 | }
|
---|
84 |
|
---|
85 | public double getNormalizedUtilityA() {
|
---|
86 | return normalizedUtilityA;
|
---|
87 | }
|
---|
88 |
|
---|
89 | public String getAgentAsString() {
|
---|
90 | return actor == null ? "null" : actor.getName();
|
---|
91 | }
|
---|
92 |
|
---|
93 | public double getNormalizedUtilityB() {
|
---|
94 | return normalizedUtilityB;
|
---|
95 | }
|
---|
96 |
|
---|
97 | public String getErrorRemarks() {
|
---|
98 | return errorRemarks;
|
---|
99 | }
|
---|
100 |
|
---|
101 | public boolean isFinalActionEvent() {
|
---|
102 | return finalActionEvent;
|
---|
103 | }
|
---|
104 | }
|
---|