def simulate(self, vneAlgorithm, objFunction):
     c = 0
     while self.priorityQueue.empty() != True:
         c = c + 1
         #Get the first event in the Queue
         event = self.priorityQueue.get()
         #print "_--------------------------------------------------------------------------------------"
         #print "Time: "+str(event[0])+" event type: "+str(event[1])
         #"If" to determine if the event is the arrival of a request
         if event[1].typeRequest == ST.ARRIVAL:
             #We calculate the revenue of the request
             revenue = self.requestList[
                 event[1].idRequest].calculateRevenue()
             self.totalRevenue1 += revenue[0]
             #print "try to embedd the request with revnue"+str(revenue)
             #                bw_tmp = np.array(self.physicalNetwork.graph.es["bandwidth"])
             #                averagebw=np.average(bw_tmp)
             #                cpu_tmp=np.array(self.physicalNetwork.graph.vs["CPU"])
             #                averageCPU=np.average(cpu_tmp)
             #                if averagebw>40 and averagebw<50 and averageCPU<=64:
             #                    print str(averagebw)+"-------------- "+str(averageCPU)
             #                    self.physicalNetwork.graph.write_graphml("/Users/CAF/Documents/DoctoralInstances/medios/red"+str(c)+".graphml")
             #                if averageCPU<=65:
             #                    print "cpu"
             #                    print averageCPU
             #                if averagebw<=50:
             #                    print "bw"
             #                    print averagebw
             #We use the VNE Algorithm to find a solution.
             #self.physicalNetwork=object with the current state of physical network.
             #self.requestList[event[1].idRequest] we get the current request form the virtual networks stored in the memory
             #objFunction we pass tothe algorithm the object with the objective function
             #revenue we pass the revenue to the algorithm
             intialTime = time()
             vneSolution = vneAlgorithm.embeddVirtualNetwork(
                 self.physicalNetwork, self.requestList[event[1].idRequest],
                 objFunction, revenue)
             finalTime = time()
             #print vneSolution.vneCost
             self.executionTime = self.executionTime + (finalTime -
                                                        intialTime)
             self.solutions.append(vneSolution)
             if vneSolution.penaltyValue == 0:
                 #print vneSolution
                 self.countRequestAccepted = self.countRequestAccepted + 1
                 self.totalCost = self.totalCost + vneSolution.vneCost
                 self.totalRevenue2 = self.totalRevenue2 + revenue[0]
                 if vneSolution.vneCost == revenue[0]:
                     self.optimalSolutions = self.optimalSolutions + 1
                 self.physicalNetwork.reserveFreeResourcesPaths(
                     vneSolution.pathsList, 0, objFunction.vectorForwarding)
                 self.physicalNetwork.reserveFreeResourcesNodes(
                     self.requestList[event[1].idRequest].graph,
                     vneSolution.permutation, 0)
                 departureEvent = ST.Request(event[1].idRequest,
                                             ST.DEPARTURE, 0)
                 departureTime = event[1].lifetime + event[0]
                 self.priorityQueue.put((departureTime, departureEvent))
             else:
                 self.rejectedRequest.append(
                     self.requestList[event[1].idRequest].graph.vcount())
                 self.links.append(
                     self.requestList[event[1].idRequest].graph.ecount())
                 self.penaltyValue.append(vneSolution.constraints)
                 self.countRequestRejected = self.countRequestRejected + 1
             pyshicalRevenue = self.physicalNetwork.calculateRevenue()
             self.minPhysicalRevenue.append(float(pyshicalRevenue[0]))
             self.minCPU.append(pyshicalRevenue[1])
             self.minAverageCPU.append(pyshicalRevenue[2])
             self.minBandwith.append(pyshicalRevenue[3])
             self.minAverageBandwith.append(pyshicalRevenue[4])
         #We need to add here an elif if exist an event of elasticity.
         #If the event is a departure free the resources.
         else:
             #print "Evento Salida :" +str(evento[1])
             solution = self.solutions[event[1].idRequest]
             self.physicalNetwork.reserveFreeResourcesPaths(
                 solution.pathsList, 1, objFunction.vectorForwarding)
             self.physicalNetwork.reserveFreeResourcesNodes(
                 self.requestList[event[1].idRequest].graph,
                 solution.permutation, 1)