def _generate_data_set(self, params: DataSetParameters) -> DataSet: if self._verbose: print(params) publishers = [] publisher_size = params.largest_publisher_size publisher_size_decay_rate = (1 if params.num_publishers == 1 else params.largest_to_smallest_publisher_ratio **(1 / float(params.num_publishers - 1))) for publisher in range(params.num_publishers): publishers.append( PublisherData.generate_publisher_data( params.impression_generator_params.generator( **{ "n": publisher_size, "random_generator": self._random_generator, **params.impression_generator_params.params, }), params.pricing_generator_params.generator( **params.pricing_generator_params.params), str(publisher + 1), )) publisher_size = math.floor(publisher_size * publisher_size_decay_rate) overlap_params = {**params.overlap_generator_params.params} if "random_generator" in overlap_params: overlap_params["random_generator"] = self._random_generator return params.overlap_generator_params.generator(publishers, name=str(params), **overlap_params)
def test_generate_publisher_data(self): pdf = PublisherData.generate_publisher_data( HomogeneousImpressionGenerator(3, 5), FixedPriceGenerator(0.01), "test" ) self.assertEqual(pdf.max_reach, 3)