def analyze(self, product): # WRITE YOUR INTELLIGENT CODE HERE # You can use following functions to make decision # my_revenue # my_expenses # my_profit # user_sentiment # # You need to return the type of advert you want to publish and at what scale # GoogleAds.advert_price[advert_type] gives you the rate of an advert if GoogleAds.user_coverage(product) < 0.5: advert_type = GoogleAds.ADVERT_BASIC else: advert_type = GoogleAds.ADVERT_TARGETED logging.info('[CEO]: (%s,%d) CEO wallet %d ads price %d', self.seller.name, self.seller.tick_count, self.seller.wallet, GoogleAds.advert_price[advert_type]) scale = self.seller.wallet // GoogleAds.advert_price[ advert_type] // 10 # not spending everything # scale = 5 logging.info( '[CEO]: (%s,%d) CEO selected advert_type as %s with scale of %d for %s', self.seller.name, self.seller.tick_count, advert_type, scale, product.product_name) return advert_type, scale
def CEO(self): """ Choose advertisement types and scales for each product based on revenue and user_coverage. If user_coverage is less than target, choose basic ads, otherwise choose targeted ads. Set total advertisement budget less than a percentage of revenue or wallet money, to avoid bankrupt Scale (number of ads to put) equals to budget divided by advert price. :return: none """ # initilize empty variable advert_type = {} expense = {} ads_type = GoogleAds.ADVERT_BASIC # set advertising budget as a percentage of total revenue or total money in wallet ads_percent = 0.5 max_budget = self.wallet * 0.2 # decide individual advertising strategy for each product for product in self.products_list: # get the latest revenue to decide ads budget revenue = self.revenue_history[-1][product] #avoid bankrupt by setting advertisment budget ads_budget = max(ads_percent * revenue, max_budget) coverage = GoogleAds.user_coverage(product) # check if user_coverage is more than half of GoogleAds users if coverage > 0.5: ads_type = GoogleAds.ADVERT_TARGETED scale = min(int(ads_budget / GoogleAds.advert_price[ads_type]), 500) # perform the actions and view the expense advert_type.update({product: (ads_type, scale)}) # obtain expense from GoogleAds expense.update({product: GoogleAds.post_advertisement(self, product, ads_type, scale)}) # store advertisement types and scales, and expense history self.advert_history.append(advert_type) self.expense_history.append(expense) return
def CEO(self): # WRITE YOUR INTELLIGENT CODE HERE # You can use following functions to make decision # my_revenue # my_expenses # my_profit # user_sentiment # # You need to return the type of advert you want to publish and at what scale # GoogleAds.advert_price[advert_type] gives you the rate of an advert if (GoogleAds.user_coverage(self.product.name) < 0.5): advert_type = GoogleAds.ADVERT_BASIC else: advert_type=GoogleAds.ADVERT_TARGETED scale = self.wallet // GoogleAds.advert_price[advert_type] // 2 #not spending everything logging.info ('[Seller]: (%s,%d) CEO selected advert_type as %s with scale of %d for %s', self.name,self.tickcount,advert_type,scale,self.product.name) return advert_type, scale