source: src/test/java/uncertaintyexample/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 uncertaintyexample;
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 @Override
17 public Action chooseAction(List<Class<? extends Action>> possibleActions) {
18 log("This is the UncertaintyAgentExample.");
19 log("The user model is: " + userModel);
20 log("The default estimated utility space is: " + getUtilitySpace());
21
22 Bid randomBid = getUtilitySpace().getDomain().getRandomBid(rand);
23 log("The default estimate of the utility of a random bid + " + randomBid
24 + " is: " + getUtility(randomBid));
25
26 if (userModel instanceof ExperimentalUserModel) {
27 log("You have given the agent access to the real utility space for debugging purposes.");
28 ExperimentalUserModel e = (ExperimentalUserModel) userModel;
29 AbstractUtilitySpace realUSpace = e.getRealUtilitySpace();
30
31 log("The real utility space is: " + realUSpace);
32 log("The real utility of the random bid is: "
33 + realUSpace.getUtility(randomBid));
34 }
35
36 // Sample code that accepts offers that appear in the top 10% of offers
37 // in the user model
38 if (getLastReceivedAction() instanceof Offer) {
39 Bid receivedBid = ((Offer) getLastReceivedAction()).getBid();
40 List<Bid> bidOrder = userModel.getBidRanking().getBidOrder();
41
42 // If the rank of the received bid is known
43 if (bidOrder.contains(receivedBid)) {
44 double percentile = (bidOrder.size()
45 - bidOrder.indexOf(receivedBid))
46 / (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 System.out.println(s);
58 }
59
60 /**
61 * With this method, you can override the default estimate of the utility
62 * space given uncertain preferences specified by the user model. This
63 * example sets every value to zero.
64 */
65 @Override
66 public AbstractUtilitySpace estimateUtilitySpace() {
67 return new AdditiveUtilitySpaceFactory(getDomain()).getUtilitySpace();
68 }
69
70 @Override
71 public String getDescription() {
72 return "Example agent that can deal with uncertain preferences";
73 }
74
75}
Note: See TracBrowser for help on using the repository browser.