Line | |
---|
1 | package geniusweb.profile.utilityspace;
|
---|
2 |
|
---|
3 | import java.math.BigDecimal;
|
---|
4 |
|
---|
5 | import org.eclipse.jdt.annotation.NonNull;
|
---|
6 |
|
---|
7 | import geniusweb.issuevalue.Bid;
|
---|
8 | import geniusweb.profile.FullOrdering;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * A utilityspace defines a profile in terms of a utility of a bid. Bids with
|
---|
12 | * higher utility are preferred over bids with less utility.
|
---|
13 | */
|
---|
14 | public interface UtilitySpace extends FullOrdering {
|
---|
15 | @NonNull
|
---|
16 | /**
|
---|
17 | * @param bid the {@link Bid} to be evaluated
|
---|
18 | * @return the utility value of this bid. This MUST return a number in the
|
---|
19 | * range [0,1]. 0 means preferred the least and 1 means preferred
|
---|
20 | * the most.
|
---|
21 | */
|
---|
22 | BigDecimal getUtility(final @NonNull Bid bid);
|
---|
23 |
|
---|
24 | @Override
|
---|
25 | default boolean isPreferredOrEqual(final @NonNull Bid bid1,
|
---|
26 | final @NonNull Bid bid2) {
|
---|
27 | if (bid1 == null || bid2 == null)
|
---|
28 | throw new NullPointerException("bid1, bid2 must be not null");
|
---|
29 | return getUtility(bid1).compareTo(getUtility(bid2)) >= 0;
|
---|
30 | }
|
---|
31 |
|
---|
32 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.