Last change
on this file was 127, checked in by Wouter Pasman, 6 years ago |
#41 ROLL BACK of rev.126 . So this version is equal to rev. 125
|
File size:
793 bytes
|
Rev | Line | |
---|
[127] | 1 | package agents.anac.y2010.AgentFSEGA;
|
---|
| 2 |
|
---|
| 3 | import genius.core.Bid;
|
---|
| 4 | import genius.core.utility.AdditiveUtilitySpace;
|
---|
| 5 |
|
---|
| 6 | public class ReverseBidComparator implements java.util.Comparator<Bid>
|
---|
| 7 | {
|
---|
| 8 | private AdditiveUtilitySpace usp;
|
---|
| 9 | private final boolean TEST_EQUIVALENCE = false;
|
---|
| 10 |
|
---|
| 11 | public ReverseBidComparator(AdditiveUtilitySpace pUsp)
|
---|
| 12 | {
|
---|
| 13 | usp = pUsp;
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | public int compare(Bid b1, Bid b2)
|
---|
| 17 | {
|
---|
| 18 | try
|
---|
| 19 | {
|
---|
| 20 | double u1 = usp.getUtility(b1);
|
---|
| 21 | double u2 = usp.getUtility(b2);
|
---|
| 22 | if (TEST_EQUIVALENCE) {
|
---|
| 23 | if (u1 == u2) {
|
---|
| 24 | return String.CASE_INSENSITIVE_ORDER.compare(b1.toString(), b2.toString());
|
---|
| 25 | }
|
---|
| 26 | }
|
---|
| 27 | if(u1 > u2)
|
---|
| 28 | return -1; // ! is reversed
|
---|
| 29 | else if(u1 < u2)
|
---|
| 30 | return 1;
|
---|
| 31 | else
|
---|
| 32 | return 0;
|
---|
| 33 | }
|
---|
| 34 | catch(Exception e)
|
---|
| 35 | { return -1; }
|
---|
| 36 | }
|
---|
[1] | 37 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.