source: ai2020/group6/UtilityBasedBiddingStrategy.java@ 5

Last change on this file since 5 was 3, checked in by wouter, 4 years ago

#1925 added group6 code.

File size: 1.5 KB
Line 
1package ai2020.group6;
2
3import java.math.BigDecimal;
4import java.util.Random;
5
6import ai2020.group6.IBiddingStrategy;
7import geniusweb.bidspace.BidsWithUtility;
8import geniusweb.bidspace.Interval;
9import geniusweb.issuevalue.Bid;
10import geniusweb.profile.utilityspace.LinearAdditive;
11import 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 */
19public 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}
Note: See TracBrowser for help on using the repository browser.