1 | package negotiator.boaframework.sharedagentstate.anac2011;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 |
|
---|
5 | import genius.core.bidding.BidDetails;
|
---|
6 | import genius.core.boaframework.NegotiationSession;
|
---|
7 | import genius.core.boaframework.SharedAgentState;
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * This is the shared code of the acceptance condition and bidding strategy of ANAC 2011 Nice Tit for Tat.
|
---|
11 | * The code was taken from the ANAC2011 Nice Tit for Tat and adapted to work within the BOA framework.
|
---|
12 | *
|
---|
13 | * @author Mark Hendrikx
|
---|
14 | */
|
---|
15 | public class NiceTitForTatSAS extends SharedAgentState{
|
---|
16 |
|
---|
17 | private NegotiationSession negotiationSession;
|
---|
18 |
|
---|
19 | public NiceTitForTatSAS (NegotiationSession negoSession) {
|
---|
20 | negotiationSession = negoSession;
|
---|
21 | NAME = "NiceTitForTat";
|
---|
22 | }
|
---|
23 |
|
---|
24 | public ArrayList<BidDetails> filterBetween(double minU, double maxU, double minT, double maxT) {
|
---|
25 | ArrayList<BidDetails> filterBids = new ArrayList<BidDetails>();
|
---|
26 | for (BidDetails b : negotiationSession.getOpponentBidHistory().getHistory()) {
|
---|
27 | if (minU < b.getMyUndiscountedUtil() &&
|
---|
28 | b.getMyUndiscountedUtil() <= maxU &&
|
---|
29 | minT < b.getTime() &&
|
---|
30 | b.getTime() <= maxT)
|
---|
31 | filterBids.add(b);
|
---|
32 | }
|
---|
33 | return filterBids;
|
---|
34 | }
|
---|
35 |
|
---|
36 | public ArrayList<BidDetails> discountedFilterBetween(double minU, double maxU, double minT, double maxT) {
|
---|
37 | ArrayList<BidDetails> filterBids = new ArrayList<BidDetails>();
|
---|
38 | for (BidDetails b : negotiationSession.getOpponentBidHistory().getHistory()) {
|
---|
39 | if (minU < negotiationSession.getDiscountedUtility(b.getBid(), b.getTime()) &&
|
---|
40 | negotiationSession.getDiscountedUtility(b.getBid(), b.getTime()) <= maxU &&
|
---|
41 | minT < b.getTime() &&
|
---|
42 | b.getTime() <= maxT)
|
---|
43 | filterBids.add(b);
|
---|
44 | }
|
---|
45 | return filterBids;
|
---|
46 | }
|
---|
47 |
|
---|
48 |
|
---|
49 | public ArrayList<BidDetails> filterBetweenTime(double minT, double maxT){
|
---|
50 | return filterBetween(0,1, minT, maxT);
|
---|
51 | }
|
---|
52 |
|
---|
53 | public boolean isDomainBig() {
|
---|
54 | negotiationSession.getUtilitySpace().getDomain().getNumberOfPossibleBids();
|
---|
55 | return negotiationSession.getUtilitySpace().getDomain().getNumberOfPossibleBids() > 10000;
|
---|
56 | }
|
---|
57 | }
|
---|