1 | package negotiator.boaframework.sharedagentstate.anac2011;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 | import java.util.Collections;
|
---|
5 |
|
---|
6 | import genius.core.bidding.BidDetails;
|
---|
7 | import genius.core.boaframework.NegotiationSession;
|
---|
8 | import genius.core.boaframework.SharedAgentState;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * This is the shared code of the acceptance condition and bidding strategy of ANAC 2011 HardHeaded.
|
---|
12 | * The code was taken from the ANAC2011 HardHeaded and adapted to work within the BOA framework.
|
---|
13 | *
|
---|
14 | * @author Mark Hendrikx
|
---|
15 | */
|
---|
16 | public class HardHeadedSAS extends SharedAgentState{
|
---|
17 |
|
---|
18 | private NegotiationSession negotiationSession;
|
---|
19 | private double lowestYetUtility;
|
---|
20 |
|
---|
21 | public HardHeadedSAS(NegotiationSession negoSession) {
|
---|
22 | negotiationSession = negoSession;
|
---|
23 |
|
---|
24 | NAME = "HardHeaded";
|
---|
25 | lowestYetUtility = 1;
|
---|
26 | }
|
---|
27 |
|
---|
28 | public double getLowestYetUtility() {
|
---|
29 | return lowestYetUtility;
|
---|
30 | }
|
---|
31 |
|
---|
32 | public void setLowestYetUtility (double util) {
|
---|
33 |
|
---|
34 | lowestYetUtility = util;
|
---|
35 | }
|
---|
36 |
|
---|
37 | public double getLowestDiscountedUtilityYet(){
|
---|
38 | double lowestYetDiscountedUtility;
|
---|
39 | if (negotiationSession.getOwnBidHistory().getHistory().size() > 0) {
|
---|
40 | ArrayList<BidDetails> sortedOwnBids = (ArrayList<BidDetails>) negotiationSession.getOwnBidHistory().getHistory();
|
---|
41 | Collections.sort(sortedOwnBids);
|
---|
42 | BidDetails bid = sortedOwnBids.get(sortedOwnBids.size() - 1);
|
---|
43 | lowestYetDiscountedUtility = negotiationSession.getDiscountedUtility(bid.getBid(), bid.getTime());
|
---|
44 | if(bid.getTime() == -1.0)
|
---|
45 | System.out.print("error bid of bid is -1");
|
---|
46 | } else {
|
---|
47 | lowestYetDiscountedUtility = 1;
|
---|
48 | }
|
---|
49 | return lowestYetDiscountedUtility;
|
---|
50 |
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 | public double getLowestUtilityYet(){
|
---|
55 | double lowestYetUtility;
|
---|
56 | if (negotiationSession.getOwnBidHistory().getHistory().size() > 0) {
|
---|
57 | ArrayList<BidDetails> sortedOwnBids = (ArrayList<BidDetails>) negotiationSession.getOwnBidHistory().getHistory();
|
---|
58 | Collections.sort(sortedOwnBids);
|
---|
59 | lowestYetUtility = sortedOwnBids.get(sortedOwnBids.size() - 1).getMyUndiscountedUtil();
|
---|
60 | } else {
|
---|
61 | lowestYetUtility = 1;
|
---|
62 | }
|
---|
63 | return lowestYetUtility;
|
---|
64 |
|
---|
65 | }
|
---|
66 | }
|
---|