source: src/main/java/agents/UncertaintyAgentExample.java@ 126

Last change on this file since 126 was 126, checked in by Aron Hammond, 6 years ago

Added function to calculate opposition to MultiLateralAnalysis.java

Moved code to add RLBOA listeners to RLBOAUtils is misc package

Added input for strategyParameters to SessionPanel (gui)

!! close SessionInfo after tournament; this caused /tmp/ to fill up with GeniusData files

Our own package:

  • Added opponents and strategies that are mentioned in the report
  • Change class hierarchy, agents can now extend from RLBOAagentBilateral to inherit RL functionality.
  • States extend from AbstractState
File size: 2.4 KB
Line 
1package agents;
2
3import java.util.List;
4
5import genius.core.Bid;
6import genius.core.actions.Accept;
7import genius.core.actions.Action;
8import genius.core.actions.Offer;
9import genius.core.parties.AbstractNegotiationParty;
10import genius.core.uncertainty.AdditiveUtilitySpaceFactory;
11import genius.core.uncertainty.ExperimentalUserModel;
12import genius.core.utility.AbstractUtilitySpace;
13
14public class UncertaintyAgentExample extends AbstractNegotiationParty
15{
16
17 @Override
18 public Action chooseAction(List<Class<? extends Action>> possibleActions)
19 {
20 log("This is the UncertaintyAgentExample.");
21 log("The user model is: " + userModel);
22 log("The default estimated utility space is: " + getUtilitySpace());
23
24 Bid randomBid = getUtilitySpace().getDomain().getRandomBid(rand);
25 log("The default estimate of the utility of a random bid + " + randomBid + " is: " + getUtility(randomBid));
26
27 if (userModel instanceof ExperimentalUserModel)
28 {
29 log("You have given the agent access to the real utility space for debugging purposes.");
30 ExperimentalUserModel e = (ExperimentalUserModel) userModel;
31 AbstractUtilitySpace realUSpace = e.getRealUtilitySpace();
32
33 log("The real utility space is: " + realUSpace);
34 log("The real utility of the random bid is: " + realUSpace.getUtility(randomBid));
35 }
36
37 // Sample code that accepts offers that appear in the top 10% of offers in the user model
38 if (getLastReceivedAction() instanceof Offer)
39 {
40 Bid receivedBid = ((Offer) getLastReceivedAction()).getBid();
41 List<Bid> bidOrder = userModel.getBidRanking().getBidOrder();
42
43 // If the rank of the received bid is known
44 if (bidOrder.contains(receivedBid))
45 {
46 double percentile = (bidOrder.size() - bidOrder.indexOf(receivedBid)) / (double) bidOrder.size();
47 if (percentile < 0.1)
48 return new Accept(getPartyId(), receivedBid);
49 }
50 }
51
52 // Otherwise, return a random offer
53 return new Offer(getPartyId(), generateRandomBid());
54 }
55
56 private void log(String s)
57 {
58 System.out.println(s);
59 }
60
61 /**
62 * With this method, you can override the default estimate of the utility space given uncertain preferences specified by the user model.
63 * This example sets every value to zero.
64 */
65 @Override
66 public AbstractUtilitySpace estimateUtilitySpace()
67 {
68 return new AdditiveUtilitySpaceFactory(getDomain()).getUtilitySpace();
69 }
70
71
72 @Override
73 public String getDescription()
74 {
75 return "Example agent that can deal with uncertain preferences";
76 }
77
78}
Note: See TracBrowser for help on using the repository browser.