def __init__(self, weights): Benchmark.__init__(self, len(weights)) self.weights = weights self.components = [swarm.TrailComponent((i, j), value=(1 / weights[i][j])) for i, j in itertools.permutations(range(len(weights)), 2)] self.bias = 0.5 self.bounder = ec.DiscreteBounder([i for i in range(len(weights))]) self.maximize = True self._use_ants = False
def __init__(self, capacity, items, duplicates=False): Benchmark.__init__(self, len(items)) self.capacity = capacity self.items = items self.components = [swarm.TrailComponent((item[0]), value=item[1]) for item in items] self.duplicates = duplicates self.bias = 0.5 if self.duplicates: max_count = [self.capacity // item[0] for item in self.items] self.bounder = ec.DiscreteBounder([i for i in range(max(max_count)+1)]) else: self.bounder = ec.DiscreteBounder([0, 1]) self.maximize = True self._use_ants = False