1 | package negotiator.boaframework.offeringstrategy.anac2012;
|
---|
2 |
|
---|
3 | import java.util.Map;
|
---|
4 |
|
---|
5 | import agents.anac.y2012.AgentLG.OpponentBids;
|
---|
6 | import genius.core.Bid;
|
---|
7 | import genius.core.bidding.BidDetails;
|
---|
8 | import genius.core.boaframework.NegotiationSession;
|
---|
9 | import genius.core.boaframework.NoModel;
|
---|
10 | import genius.core.boaframework.OMStrategy;
|
---|
11 | import genius.core.boaframework.OfferingStrategy;
|
---|
12 | import genius.core.boaframework.OpponentModel;
|
---|
13 | import negotiator.boaframework.opponentmodel.DefaultModel;
|
---|
14 | import negotiator.boaframework.sharedagentstate.anac2012.AgentLGSAS;
|
---|
15 |
|
---|
16 | public class AgentLG_Offering extends OfferingStrategy {
|
---|
17 |
|
---|
18 | private Bid myLastBid = null;
|
---|
19 | private OpponentBids oppenentsBid;
|
---|
20 | private boolean bidLast = false;
|
---|
21 |
|
---|
22 | public AgentLG_Offering() {
|
---|
23 | }
|
---|
24 |
|
---|
25 | public AgentLG_Offering(NegotiationSession negoSession, OpponentModel model, OMStrategy oms) throws Exception {
|
---|
26 | init(negoSession, model, oms, null);
|
---|
27 | }
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Init required for the Decoupled Framework.
|
---|
31 | */
|
---|
32 | @Override
|
---|
33 | public void init(NegotiationSession negoSession, OpponentModel model, OMStrategy oms,
|
---|
34 | Map<String, Double> parameters) throws Exception {
|
---|
35 | if (model instanceof DefaultModel) {
|
---|
36 | model = new NoModel();
|
---|
37 | }
|
---|
38 | oppenentsBid = new OpponentBids(negoSession.getUtilitySpace());
|
---|
39 | negotiationSession = negoSession;
|
---|
40 | helper = new AgentLGSAS(negotiationSession, oppenentsBid, model, oms);
|
---|
41 | }
|
---|
42 |
|
---|
43 | @Override
|
---|
44 | public BidDetails determineOpeningBid() {
|
---|
45 | if (!negotiationSession.getOpponentBidHistory().isEmpty())
|
---|
46 | oppenentsBid.addBid(negotiationSession.getOpponentBidHistory().getLastBid());
|
---|
47 | myLastBid = negotiationSession.getMaxBidinDomain().getBid();
|
---|
48 | return negotiationSession.getMaxBidinDomain();
|
---|
49 | }
|
---|
50 |
|
---|
51 | @Override
|
---|
52 | public BidDetails determineNextBid() {
|
---|
53 |
|
---|
54 | oppenentsBid.addBid(negotiationSession.getOpponentBidHistory().getLastBid());
|
---|
55 |
|
---|
56 | BidDetails currentAction = null;
|
---|
57 | try {
|
---|
58 | double time = negotiationSession.getTime();
|
---|
59 |
|
---|
60 | if (bidLast) {
|
---|
61 | // System.out.println("Decoupled Last Bid");
|
---|
62 | currentAction = negotiationSession.getOwnBidHistory().getLastBidDetails();
|
---|
63 | }
|
---|
64 | // there is lot of time ->learn the opponent and bid the 1/4 most
|
---|
65 | // optimal bids
|
---|
66 | else if (time < 0.6) {
|
---|
67 | if (!negotiationSession.getOpponentBidHistory().isEmpty())
|
---|
68 | currentAction = ((AgentLGSAS) helper).getNextOptimicalBid(time);
|
---|
69 | myLastBid = negotiationSession.getOwnBidHistory().getLastBid();
|
---|
70 | } else {
|
---|
71 | // the time is over -> bid the opponents max utility bid for me
|
---|
72 | if (time >= 0.9995) {
|
---|
73 | myLastBid = negotiationSession.getOpponentBidHistory().getBestBidDetails().getBid();
|
---|
74 | if (negotiationSession.getUtilitySpace().getUtilityWithDiscount(myLastBid,
|
---|
75 | time) < negotiationSession.getUtilitySpace().getReservationValueWithDiscount(time))
|
---|
76 | myLastBid = ((AgentLGSAS) helper).getMyminBidfromBids();
|
---|
77 | currentAction = new BidDetails(myLastBid,
|
---|
78 | negotiationSession.getUtilitySpace().getUtility(myLastBid));
|
---|
79 | } else {
|
---|
80 | // Comprise and chose better bid for the opponents that
|
---|
81 | // still good for me
|
---|
82 | currentAction = ((AgentLGSAS) helper).getNextBid(time);
|
---|
83 | }
|
---|
84 | }
|
---|
85 | if (oppenentsBid.getOpponentsBids().contains(currentAction.getBid())) {
|
---|
86 | bidLast = true;
|
---|
87 | }
|
---|
88 |
|
---|
89 | } catch (Exception e) {
|
---|
90 | System.out.println("Error and thus accept: " + e);
|
---|
91 | // currentAction = new Accept(getAgentID());
|
---|
92 | }
|
---|
93 |
|
---|
94 | return currentAction;
|
---|
95 | }
|
---|
96 |
|
---|
97 | @Override
|
---|
98 | public String getName() {
|
---|
99 | return "2012 - AgentLG";
|
---|
100 | }
|
---|
101 | } |
---|