def bisection_method(traffic, max_latency, active_servers, capacity, least_error): lower = 1 upper = traffic flag = False while (lower + least_error) <= upper: mid = (lower + upper) / 2 total_latency = m_m_c_latency(active_servers, mid, capacity) if total_latency <= max_latency: flag = True lower = mid else: upper = mid if flag: return lower else: return -1
def vehicle_communication_latency(self, traffic): return m_m_c_latency(1, traffic, self.vehicle_transmission_rate)
def computation_latency(self, traffic, used_vehicles): return m_m_c_latency(used_vehicles, traffic, self.capacity)
def fog_communication_latency(self, traffic): return m_m_c_latency(1, traffic, self.fog_transmission_rate)
def computation_latency(self, traffic, active_servers): # check number of servers constraint if active_servers <= self.max_servers: return m_m_c_latency(active_servers, traffic, self.capacity) else: return -1
def case_2_latenct(x, args): return args[1] - (m_m_c_latency(x[0], x[1] * args[2], args[0]) + m_m_c_latency(1, x[1] * args[2], 1250) + m_m_c_latency(1, x[1] * args[2] * 0.01, 1250))
def case_1_latenct(x, args): return args[1] - m_m_c_latency( x[0], args[2] - sum([args * x_i for x_i in x[1:]]), args[0])