1 | package agents.anac.y2019.authenticagent.opponentmodeling;
|
---|
2 |
|
---|
3 | import agents.anac.y2019.authenticagent.dataclasses.LastReceivedOffer;
|
---|
4 | import agents.anac.y2019.authenticagent.serviceclasses.SafeBidUtilityService;
|
---|
5 | import genius.core.Bid;
|
---|
6 | import genius.core.uncertainty.UserModel;
|
---|
7 | import genius.core.utility.UtilitySpace;
|
---|
8 |
|
---|
9 | import java.util.ArrayList;
|
---|
10 | import java.util.HashMap;
|
---|
11 |
|
---|
12 | public class OpponentModelingByNNearestBids extends AbstractOpponentModeling {
|
---|
13 | private HashMap<String, NNearestBidsForOpponentParty> opponentParties;
|
---|
14 |
|
---|
15 | public OpponentModelingByNNearestBids(UtilitySpace us, UserModel um){
|
---|
16 | super(us, um);
|
---|
17 | opponentParties = new HashMap<>();
|
---|
18 | }
|
---|
19 |
|
---|
20 | @Override
|
---|
21 | public ArrayList<Bid> getRecommendedBids(){
|
---|
22 | if(LastReceivedOffer.bid == null)
|
---|
23 | return new ArrayList<>();
|
---|
24 | double utility = SafeBidUtilityService.getUtility(LastReceivedOffer.bid);
|
---|
25 | ArrayList<Bid> result;
|
---|
26 | NNearestBidsForOpponentParty NNearestBidsForOpponentParty = opponentParties.get(LastReceivedOffer.agentId);
|
---|
27 | if(NNearestBidsForOpponentParty == null)
|
---|
28 | {
|
---|
29 | return new ArrayList<>();
|
---|
30 | }
|
---|
31 | NNearestBidsForOpponentParty.insertReceivedBid(utility, LastReceivedOffer.bid);
|
---|
32 | result = NNearestBidsForOpponentParty.findBidsNear(utility);
|
---|
33 | return result;
|
---|
34 | }
|
---|
35 |
|
---|
36 | @Override
|
---|
37 | public void addNewOpponentIfNotExists(String agentId){
|
---|
38 | if(opponentParties.containsKey(agentId))
|
---|
39 | return;
|
---|
40 | NNearestBidsForOpponentParty NNearestBidsForOpponentParty = new NNearestBidsForOpponentParty();
|
---|
41 | opponentParties.put(agentId, NNearestBidsForOpponentParty);
|
---|
42 | double utility = SafeBidUtilityService.getUtility(LastReceivedOffer.bid);
|
---|
43 | opponentParties.get(agentId).insertReceivedBid(utility,LastReceivedOffer.bid);
|
---|
44 | }
|
---|
45 | }
|
---|