예제 #1
0
  public int getCurrentSurplus(InformationState s) {
    double[] currentBid = s.getCurrentBidPrice();
    int[] currentWinning = s.getCurrentBidWinning();

    BitSet bs = new BitSet();
    int cost = 0;
    for (int i = 0; i < NUM_GOODS; i++) {
      if (currentWinning[i] == index) {
        bs.set(i);
        cost += currentBid[i];
      }
    }
    int value;
    value = typeDist.get(bs) != null ? typeDist.get(bs).intValue() : 0;
    return (value - cost);
  }
예제 #2
0
  public double[] bid(InformationState s) {
    double[] newBid = new double[NUM_GOODS];
    int[] rank = new int[NUM_GOODS];
    double[] currentBid = s.getCurrentBidPrice();
    double[] sortedPrice = new double[NUM_GOODS];
    int[] currentWinning = s.getCurrentBidWinning();
    double[] currentPrediction = new double[NUM_GOODS];

    for (int i = 0; i < NUM_GOODS; i++) {
      sortedPrice[i] = currentBid[i];
    }
    Arrays.sort(sortedPrice);
    int count = 0;
    for (int i = 0; i < NUM_GOODS; i++) {
      if (i != 0 && sortedPrice[i] > sortedPrice[i - 1]) count++;
      for (int j = 0; j < NUM_GOODS; j++) {
        if (currentBid[j] == sortedPrice[i]) {
          rank[j] = count;
        }
      }
    }

    // Initially play SB
    for (int i = 0; i < NUM_GOODS; i++) {
      if (this.isSingleUnitDemand) {
        currentPrediction[i] = (currentWinning[i] == index) ? currentBid[i] : currentBid[i] + 1;
      } else {
        currentPrediction[i] =
            (currentWinning[i] == index)
                ? currentBid[i] + KAPPA * rank[i]
                : currentBid[i] + 1 + KAPPA * rank[i];
      }
    }
    System.out.print("Agent " + index + "'s prediction : ");
    for (int i = 0; i < NUM_GOODS; i++) {
      System.out.print(currentPrediction[i] + " ");
    }
    System.out.println();

    double max_surplus = Double.MIN_VALUE;
    BitSet maxSet = new BitSet();
    for (BitSet bs : bitVector) {
      int value = typeDist.get(bs).intValue();

      double cost = 0.0;
      for (int j = 0; j < bs.length(); j++) {
        if (bs.get(j)) cost += currentPrediction[j];
      }
      double surplus = (double) value - cost;
      if (surplus > max_surplus) {
        max_surplus = surplus;
        maxSet = bs;
      }
    }
    for (int i = 0; i < NUM_GOODS; i++) {
      if (maxSet.get(i) && max_surplus > 0) {
        if (currentWinning[i] == index) {
          newBid[i] = currentBid[i];
        } else {
          if (currentBid[i] < VALUE_UPPER_BOUND) newBid[i] = currentBid[i] + 1;
          else newBid[i] = VALUE_UPPER_BOUND;
        }
      } else newBid[i] = 0;
    }
    return newBid;
  }