Ejemplo n.º 1
0
def fitnessOrder(order):
    neededW = []
    neededProducts = order.products[:]
    for w in order.warehouses:
        if (len(neededProducts) == 0):
            break
        else:
            wProducts = [p.productID for p in w.products]
            tempNeededProducts = neededProducts
            for neededP in neededProducts:
                if neededP in wProducts:
                    tempNeededProducts.remove(neededP)
                    wProducts.remove(neededP)
            neededProducts = tempNeededProducts
            neededW.append(w)
    fitness = 0
    for w in neededW:
        fitness += utils.squaredDistance(order.x, order.y, w.x, w.y)
    return order.weight * fitness
Ejemplo n.º 2
0
def fitnessOrder(order):
    neededW = []
    neededProducts = order.products[:]
    for w in order.warehouses:
        if (len(neededProducts) == 0):
            break
        else:
            wProducts = [p.productID for p in w.products]
            tempNeededProducts = neededProducts
            for neededP in neededProducts:
                if neededP in wProducts:
                    tempNeededProducts.remove(neededP)
                    wProducts.remove(neededP)
            neededProducts = tempNeededProducts
            neededW.append(w)
    fitness = 0
    for w in neededW:
        fitness += utils.squaredDistance(order.x, order.y, w.x, w.y)
    return order.weight * fitness
Ejemplo n.º 3
0
 def getFitnessForOrder(self, order):
     #TODO
     return -utils.squaredDistance(order.x, order.y, self.x, self.y)
Ejemplo n.º 4
0
 def getFitnessForOrder(self, order):
     #TODO
     return -utils.squaredDistance(order.x, order.y, self.x, self.y)