Exemplo n.º 1
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.º 2
0
  /*
   * genarates the campaign queries relevant for the specific campaign, and assign them as the campaigns campaignQueries field
   */
  private void genCampaignQueries(CampaignData campaignData) {
    Set<AdxQuery> campaignQueriesSet = new HashSet<AdxQuery>();
    for (String PublisherName : w.publisherNames) {
      campaignQueriesSet.add(
          new AdxQuery(PublisherName, campaignData.targetSegment, Device.mobile, AdType.text));
      campaignQueriesSet.add(
          new AdxQuery(PublisherName, campaignData.targetSegment, Device.mobile, AdType.video));
      campaignQueriesSet.add(
          new AdxQuery(PublisherName, campaignData.targetSegment, Device.pc, AdType.text));
      campaignQueriesSet.add(
          new AdxQuery(PublisherName, campaignData.targetSegment, Device.pc, AdType.video));
    }

    campaignData.campaignQueries = new AdxQuery[campaignQueriesSet.size()];
    campaignQueriesSet.toArray(campaignData.campaignQueries);
    System.out.println(
        "!!!!!!!!!!!!!!!!!!!!!!"
            + Arrays.toString(campaignData.campaignQueries)
            + "!!!!!!!!!!!!!!!!");
  }