Exemplo n.º 1
0
  private void handleICampaignOpportunityMessage(CampaignOpportunityMessage com) {

    w.day = com.getDay();

    d.pendingCampaign = new CampaignData(com);
    System.out.println("Day " + w.day + ": Campaign opportunity - " + d.pendingCampaign);

    // -------------Leela Campaign Bid--------------
    long cmpBidMillis = ca.bidValue(com);
    System.out.println("Day " + w.day + ": Campaign total budget bid (millis): " + cmpBidMillis);

    if (d.dailyNotification != null) {

      d.ucsBid = ua.bidValue();
      d.lastUCS = d.ucsBid;
      System.out.println(
          "Day " + w.day + ": ucs level reported: " + d.dailyNotification.getServiceLevel());
    } else {
      System.out.println("Day " + w.day + ": Initial ucs bid is " + d.ucsBid);
    }
    /* Note: Campaign bid is in millis */
    AdNetBidMessage bids;
    /*if(shouldBid){
        bids = new AdNetBidMessage(ucsBid, d.pendingCampaign.id, cmpBidMillis);
    }
    else{
        bids = new AdNetBidMessage(0.1, d.pendingCampaign.id, cmpimps);
        System.out.println("DID NOT BID! OVERLAP!!");
    }*/
    // cmpBidMillis=(long)(cmpimps*0.1);
    bids = new AdNetBidMessage(d.ucsBid, d.pendingCampaign.id, cmpBidMillis);
    sendMessage(demandAgentAddress, bids);
  }
Exemplo n.º 2
0
  @Override
  protected void simulationSetup() {

    w.day = 0;
    d.bidBundle = new AdxBidBundle();

    /* initial bid between 0.1 and 0.2 */
    d.ucsBid = 0.2;

    d.campaigns = new HashMap<Integer, CampaignData>();
    log.fine("AdNet " + getName() + " simulationSetup");
  }
Exemplo n.º 3
0
  /**
   * On day n ( > 0), the result of the UserClassificationService and Campaign auctions (for which
   * the competing agents sent bids during day n -1) are reported. The reported Campaign starts in
   * day n+1 or later and the user classification service level is applicable starting from day n+1.
   */
  private void handleAdNetworkDailyNotification(AdNetworkDailyNotification notificationMessage) {

    d.dailyNotification = notificationMessage;

    System.out.println(
        "Day "
            + w.day
            + ": Daily notification for campaign "
            + d.dailyNotification.getCampaignId());

    String campaignAllocatedTo = " allocated to " + notificationMessage.getWinner();

    if ((d.pendingCampaign.id == d.dailyNotification.getCampaignId())
        && (notificationMessage.getCostMillis() != 0)) {

      /* add campaign to list of won campaigns */
      d.pendingCampaign.setBudget(notificationMessage.getCostMillis() / 1000.0);
      d.currCampaign = d.pendingCampaign;
      genCampaignQueries(d.currCampaign);
      d.campaigns.put(d.pendingCampaign.id, d.pendingCampaign);
      for (int i = (int) d.pendingCampaign.dayStart; i <= (int) d.pendingCampaign.dayEnd; i++) {
        d.campTrack.get(i).add(d.pendingCampaign.id);
      }

      campaignAllocatedTo = " WON at cost (Millis)" + notificationMessage.getCostMillis();
      em.pastQBWon.add(
          notificationMessage.getQualityScore()
              / (notificationMessage.getPrice() / d.currCampaign.reachImps));
    } else {
      em.pastQBLost.add(
          notificationMessage.getQualityScore()
              / (notificationMessage.getPrice() / d.pendingCampaign.reachImps));
      for (int i = (int) d.pendingCampaign.dayStart; i <= (int) d.pendingCampaign.dayEnd; i++) {
        d.otherCampTrack.get(i).add(d.pendingCampaign.id);
      }
    }

    System.out.println(
        "Day "
            + w.day
            + ": "
            + campaignAllocatedTo
            + ". UCS Level set to "
            + notificationMessage.getServiceLevel()
            + " at price "
            + notificationMessage.getPrice()
            + " Quality Score is: "
            + notificationMessage.getQualityScore());
  }
Exemplo n.º 4
0
  public void handleInitialCampaignMessage(InitialCampaignMessage campaignMessage) {
    System.out.println(campaignMessage.toString());
    /**
     * ***********************************Open and read the camplog
     * file******************************************************
     */
    String str = null;
    try {
      //  int count = 0;
      FileReader file = new FileReader("camLog.txt");
      BufferedReader reader = new BufferedReader(file);

      str = reader.readLine();

      campaignData.count = Integer.parseInt(str);

    } catch (IOException e) {

    }

    System.out.println("********^^^^^^^^^^^^^^^^^^^^******************" + campaignData.count);

    /**
     * ***********************************end
     * file****************************************************************************
     */
    w.day = 0;

    initialCampaignMessage = campaignMessage;
    demandAgentAddress = campaignMessage.getDemandAgentAddress();
    adxAgentAddress = campaignMessage.getAdxAgentAddress();

    CampaignData campaignData = new CampaignData(initialCampaignMessage);
    campaignData.setBudget(initialCampaignMessage.getBudgetMillis() / 1000.0);
    d.currCampaign = campaignData;
    initTotalPopularity(campaignData);
    genCampaignQueries(campaignData);

    /*
     * The initial campaign is already allocated to our agent so we add it
     * to our allocated-campaigns list.
     */
    System.out.println("Day " + w.day + ": Allocated campaign - " + campaignData);
    d.campaigns.put(initialCampaignMessage.getId(), campaignData);
    for (int i = 0; i < 60; i++) {
      d.campTrack.add(new ArrayList<Integer>());
      d.otherCampTrack.add(new ArrayList<Integer>());
    }
    for (int i = (int) d.currCampaign.dayStart; i <= (int) d.currCampaign.dayEnd; i++) {
      d.campTrack.get(i).add(d.currCampaign.id);
    }
  }
Exemplo n.º 5
0
 @Override
 protected void simulationFinished() {
   campaignReports.clear();
   d.bidBundle = null;
 }