source: src/main/java/agents/anac/y2010/AgentSmith/BidComparator.java

Last change on this file was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 1.2 KB
RevLine 
[1]1package agents.anac.y2010.AgentSmith;
2import java.util.Comparator;
3
4import genius.core.Bid;
5
6/*
7 * The BidComparator compares two given bids. This class is used to slowly descent to the opponent while
8 * staying above the given threshold (OWN_UTILITY_WEIGHT), which determines how much he values his
9 * own interest or wants to give in a lot to the opponent to make him 'happy'.
10 */
11public class BidComparator implements Comparator<Bid> {
12 private PreferenceProfileManager fPreferenceProfile;
13
14
15
16 public BidComparator(PreferenceProfileManager pProfile) {
17 this.fPreferenceProfile = pProfile;
18 }
19
20 /*
21 * returns 1 if his own bid is better than the opponents, -1 otherwise
22 */
23 public int compare(Bid b1, Bid b2) {
24 return getMeasure(b2) > getMeasure(b1) ? -1 : 1;
25 }
26
27 /*
28 * returns a double that represents the value of a value of a bid, taking into account both the agents
29 * own and opponents' utility.
30 */
31 public double getMeasure(Bid b1) {
32 double a = (1 - this.fPreferenceProfile.getMyUtility(b1));
33 double b = (1 - this.fPreferenceProfile.getOpponentUtility(b1));
34
35 double alpha = Math.atan(b/a);
36
37 return a + b + (0.5*Math.PI / alpha) * 0.5*Math.PI;
38 }
39
40}
Note: See TracBrowser for help on using the repository browser.