Skip to content

Generating a random bid with a utility threshold

Taha Doğan Güneş edited this page Oct 24, 2017 · 1 revision

Beware that if utilityThreshold is really high (e.g. 0.9), there might not be a possible offer in given preference profile.
To be safe, compare your utilityThreshold with this.utilitySpace.getMaxUtilityBid().

public Bid generateRandomBidWithUtility(double utilityThreshold) {
      Bid randomBid;
      double utility;
      do {
          randomBid = generateRandomBid();
          try {
              utility = utilitySpace.getUtility(randomBid);
          } catch (Exception e)
          {
              utility = 0.0;
          }
      }
      while (utility < utilityThreshold);
      return randomBid;
  }
Clone this wiki locally