Exemplo n.º 1
0
 def get_edge_cost(self, edge: Edge):
     edge.bandWidth = 0
     edge.cost = 0
     if len(edge.requests) == 0:
         return
     for r in edge.requests:
         r: Request
         edge.bandWidth += r.bandwidth
     edge.cost = edge.bandWidth * edge.unitprice
     gain = self.link_gain(edge)
     edge.bandWidth *= (1 - gain / edge.cost)
     edge.cost -= gain
Exemplo n.º 2
0
 def link_gain(self, e: Edge) -> float:
     if len(e.requests) == 0:
         return 0
     multiplex_seq = [0 for _ in range(config.DURATION)]
     maxband = 0
     for r in e.requests:
         r: Request
         for i in range(config.DURATION):
             multiplex_seq[i] += r.bandSeq[i]
         maxband += r.bandwidth
     gain_band = sys.maxsize
     for i in range(config.DURATION):
         gain_band = min(gain_band, maxband - multiplex_seq[i])
     e.bandWidth = maxband - gain_band
     return gain_band * e.unitprice