[3] | 1 | package ai2020.group6;
|
---|
| 2 |
|
---|
| 3 | import java.math.BigDecimal;
|
---|
| 4 | import java.util.Random;
|
---|
| 5 |
|
---|
| 6 | import ai2020.group6.IBiddingStrategy;
|
---|
| 7 | import geniusweb.bidspace.BidsWithUtility;
|
---|
| 8 | import geniusweb.bidspace.Interval;
|
---|
| 9 | import geniusweb.issuevalue.Bid;
|
---|
| 10 | import geniusweb.profile.utilityspace.LinearAdditive;
|
---|
| 11 | import tudelft.utilities.immutablelist.ImmutableList;
|
---|
| 12 |
|
---|
| 13 | /**
|
---|
| 14 | * UtilityBasedBiddingStrategy generates random bids that fall between the
|
---|
| 15 | * thresholds provided by getUpperUtilityThreshold and getLowerUtilityThreshold.
|
---|
| 16 | *
|
---|
| 17 | * @author Group 6
|
---|
| 18 | */
|
---|
| 19 | public abstract class UtilityBasedBiddingStrategy implements IBiddingStrategy {
|
---|
| 20 |
|
---|
| 21 | protected Integer minPower;
|
---|
| 22 | protected Integer maxPower;
|
---|
| 23 |
|
---|
| 24 | public UtilityBasedBiddingStrategy ( Integer minPower, Integer maxPower ) {
|
---|
| 25 | this.minPower = minPower;
|
---|
| 26 | this.maxPower = maxPower;
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | public abstract BigDecimal getUpperUtilityThreshold ( MAState state );
|
---|
| 30 | public abstract BigDecimal getLowerUtilityThreshold ( MAState state );
|
---|
| 31 |
|
---|
| 32 | @Override
|
---|
| 33 | public Bid generateBid(MAState state) {
|
---|
| 34 | BigDecimal upperThreshold = getUpperUtilityThreshold(state);
|
---|
| 35 | BigDecimal lowerThreshold = getLowerUtilityThreshold(state);
|
---|
| 36 | BidsWithUtility bidutils = new BidsWithUtility((LinearAdditive) state.getUtilitySpace());
|
---|
| 37 | ImmutableList<Bid> bids = bidutils.getBids(new Interval(lowerThreshold, upperThreshold));
|
---|
| 38 | if ( bids.size().intValue() == 0 )
|
---|
| 39 | return bidutils.getExtremeBid(true);
|
---|
| 40 | int i = (new Random()).nextInt(bids.size().intValue());
|
---|
| 41 | return bids.get(i);
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | }
|
---|