/**
   * This method is invoked when a round finishes
   *
   * @see gridsim.auction.OneSidedAuction#onClose(int)
   */
  public void onClose(int round) {

    // our implementation of the first price sealed auction has
    // a single round. So, since we are using a reverse auction, the
    // lowest bid is the best one
    MessageBid best = getFirstBid(-1);

    if (best != null) {
      double price = best.getPrice();

      // if the price of the bid is below the reserve price, it means
      // that the broker will accept the offer and will send the job
      // to be executed by the resource provider
      if (price <= super.getReservePrice()) {
        super.setFinalPrice(price);
        super.setWinner(best.getBidder());
      } else {
        super.setFinalPrice(super.getCurrentPrice());
      }
    } else {
      // there is no best bid, what means that no resource provider
      // has bidden to execute the job
      super.setFinalPrice(super.getCurrentPrice());
    }
  }
  /**
   * This method is called when a round is started
   *
   * @see gridsim.auction.OneSidedAuction#onStart(int)
   */
  public void onStart(int round) {
    super.setMinPrice(super.getReservePrice());
    super.setCurrentPrice(super.getReservePrice());

    // Creates a call for proposal that is broadcast to all bidders
    MessageCallForBids msg =
        new MessageCallForBids(
            super.getAuctionID(),
            super.getAuctionProtocol(),
            super.getMinPrice(),
            super.currentRound());

    msg.setAttributes(super.getAttributes());
    super.broadcastMessage(msg);
  }
  /**
   * This method is called when the auction finishes
   *
   * @see gridsim.auction.OneSidedAuction#onStop()
   */
  public void onStop() {
    int winner = super.getWinner();

    // broadcasts a message to all bidders informing about the
    // outcome of the auction
    MessageInformOutcome iout =
        new MessageInformOutcome(
            super.getAuctionID(), super.getAuctionProtocol(), winner, super.getFinalPrice());

    super.broadcastMessage(iout);
  }