import pdq #---- Define globals ------------------------------------------------- arrivRate = 0.75 service_time = 1.0 #---- Initialize ----------------------------------------------------- pdq.Init("OpenCenter") pdq.SetComment("A simple M/M/1 queue") #---- Define the workload and circuit type --------------------------- pdq.streams = pdq.CreateOpen("work", arrivRate) pdq.SetWUnit("Customers") pdq.SetTUnit("Seconds") #---- Define the queueing center ------------------------------------- pdq.nodes = pdq.CreateNode("server", pdq.CEN, pdq.FCFS) #---- Define service demand due to workload on the queueing center --- pdq.SetDemand("server", "work", service_time) #---- Solve the model ------------------------------------------------ # Must use the CANONical method for an open circuit
# Service times in seconds S = array([20, 600, 300, 60]) # Service demands in seconds D = array([v[0]*S[0], v[1]*S[1], v[2]*S[2], v[3]*S[3]]) """ Use the service demands derived from the solved traffic equations to parameterize and solve PyDQ queueing model of the passport office """ # Initialize and solve the model pdq.Init("Passport Office"); numStreams = pdq.CreateOpen("Applicant", L[0]); numNodes = pdq.CreateNode("Window0", pdq.CEN, pdq.FCFS); numNodes = pdq.CreateNode("Window1", pdq.CEN, pdq.FCFS); numNodes = pdq.CreateNode("Window2", pdq.CEN, pdq.FCFS); numNodes = pdq.CreateNode("Window3", pdq.CEN, pdq.FCFS); pdq.SetDemand("Window0", "Applicant", D[0]); pdq.SetDemand("Window1", "Applicant", D[1]); pdq.SetDemand("Window2", "Applicant", D[2]); pdq.SetDemand("Window3", "Applicant", D[3]); pdq.Solve(pdq.CANON); pdq.Report(); # Utilizations: L_0 * D_k
PDQ model using 2 MSQ nodes in tandem. """ import pdq from math import * arrivalRate = 40.0 / 60 # cust per min browseTime = 45.0 # mins buyingTime = 4.0 # mins cashiers = 3 pdq.Init("Big Book Store Model") # Create an open circuit Jackson network streams = pdq.CreateOpen("Customers", arrivalRate) pdq.SetWUnit("Cust") pdq.SetTUnit("Min") # timebase for PDQ report #*** New MSQ flag tells PDQ the following are multiserver nodes *** # M/M/inf queue defined as 100 times the number of Erlangs = lambda * S nodes = pdq.CreateNode("Browsing", int(ceil(arrivalRate * browseTime)) * 100, pdq.MSQ) # M/M/m where m is the number of cashiers nodes = pdq.CreateNode("Checkout", cashiers, pdq.MSQ) # Set service times ... pdq.SetDemand("Browsing", "Customers", browseTime)
# $Id$ # #--------------------------------------------------------------------- import pdq #--------------------------------------------------------------------- # Based on simple_series_circuit.c # # An open queueing circuit with 3 centers. arrivals_per_second = 0.10 pdq.Init("Simple Series Circuit") pdq.streams = pdq.CreateOpen("Work", arrivals_per_second) pdq.nodes = pdq.CreateNode("Center1", pdq.CEN, pdq.FCFS) pdq.nodes = pdq.CreateNode("Center2", pdq.CEN, pdq.FCFS) pdq.nodes = pdq.CreateNode("Center3", pdq.CEN, pdq.FCFS) pdq.SetDemand("Center1", "Work", 1.0) pdq.SetDemand("Center2", "Work", 2.0) pdq.SetDemand("Center3", "Work", 3.0) pdq.Solve(pdq.CANON) pdq.Report() #---------------------------------------------------------------------
# # Created by NJG on Thu, May 31, 2007 # # Blair Zajac, author of Orca states: # "If long term trends indicate increasing figures, more or faster CPUs # will eventually be necessary unless load can be displaced. For ideal # utilization of your CPU, the maximum value here should be equal to the # number of CPUs in the box." # # Zajac's comment implies any waiting line is bad. # PDQ steady-state model for HPC/batch workload with # stretch factor == 1 (no waiting line). # Very low arrival rate over 10 hour period. import pdq processors = 4 arrivalRate = 0.099 # jobs per hour (very low arrivals) crunchTime = 10.0 # hours (very long service time) pdq.Init("ORCA LA Model") s = pdq.CreateOpen("Crunch", arrivalRate) n = pdq.CreateNode("HPCnode", int(processors), pdq.MSQ) pdq.SetDemand("HPCnode", "Crunch", crunchTime) pdq.SetWUnit("Jobs") pdq.SetTUnit("Hour") pdq.Solve(pdq.CANON) pdq.Report()
no_nodes = pdq.CreateNode("TR", pdq.CEN, pdq.FCFS) # NOTE: Althought the Token Ring LAN is a passive computational device, # it is treated as a separate node so as to agree to the results # presented in the original CMG'93 paper. #----- Assign transaction names ------------------------------------------------ txCD = "CatDsply" txRQ = "RemQuote" txSU = "StatusUp" #----- Define an OPEN circuit aggregate workload ------------------------------- no_streams = pdq.CreateOpen(txCD, USERS * 4.0 / 60.0) no_streams = pdq.CreateOpen(txRQ, USERS * 8.0 / 60.0) no_streams = pdq.CreateOpen(txSU, USERS * 1.0 / 60.0) #------------------------------------------------------------------------------- # Define the service demands on each physical resource ... # CD request + reply chain from workflow diagram #------------------------------------------------------------------------------- pdq.SetDemand("PC", txCD, demand[(CD_Req, PC)] + (5 * demand[(CD_Rpy, PC)])) pdq.SetDemand("FS", txCD, demand[(Req_CD, FS)] + (5 * demand[(CD_Msg, FS)])) for i in range(FS_DISKS): pdq.SetDemand( FDarray[i].label, txCD, demand[(Req_CD, FDarray[i].id)] + (5 * demand[(CD_Msg, FDarray[i].id)]))
# copies of the Software, and permit persons to whom the Software is # # furnished to do so, under the terms of the COPYING file. # # # # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY # # KIND, either express or implied. # ############################################################################### # # Created by NJG on Wed, Apr 18, 2007 # # # $Id: orca.py,v 1.2 2009/03/26 02:55:32 pfeller Exp $ import pdq # Measured parameters servers = 4 arivrate = 0.099 # per hr servtime = 10.0 # hrs pdq.Init("ORCA Batch") nstreams = pdq.CreateOpen("Crunch", arivrate) pdq.SetWUnit("Jobs") pdq.SetTUnit("Hours") nnodes = pdq.CreateNode("HPC", int(servers), pdq.MSQ) pdq.SetDemand("HPC", "Crunch", servtime) pdq.Solve(pdq.CANON) pdq.Report()
# Based on open_feedback rx_prob = 0.30 inter_arriv_rate = 0.5 service_time = 0.75 mean_visits = 1.0 / (1.0 - rx_prob) #----- Initialize the model ------------------------------------------ pdq.Init("Open Feedback") #---- Define the queueing center ------------------------------------- pdq.nodes = pdq.CreateNode("channel", pdq.CEN, pdq.FCFS) #---- Define the workload and circuit type --------------------------- pdq.streams = pdq.CreateOpen("message", inter_arriv_rate) #---- Define service demand due to workload on the queueing center --- pdq.SetVisits("channel", "message", mean_visits, service_time) #---- Must import the CANONical method for an open circuit ----------- pdq.Solve(pdq.CANON) pdq.Report() #---------------------------------------------------------------------
# KIND, either express or implied. # ############################################################################### # # Created by NJG on Wed, Apr 18, 2007 # # Queueing model of an email-spam analyzer system comprising a # battery of SMP servers essentially running in batch mode. # Each node was a 4-way SMP server. # The performance metric of interest was the mean queue length. # # This simple M/M/4 model gave results that were in surprisingly # good agreement with monitored queue lengths. # # $Id: spamcan1.py,v 1.2 2009/03/31 00:48:34 pfeller Exp $ import pdq # Measured performance parameters cpusPerServer = 4 emailThruput = 2376 # emails per hour scannerTime = 6.0 # seconds per email pdq.Init("Spam Farm Model") # Timebase is SECONDS ... nstreams = pdq.CreateOpen("Email", float(emailThruput) / 3600) nnodes = pdq.CreateNode("spamCan", int(cpusPerServer), pdq.MSQ) pdq.SetDemand("spamCan", "Email", scannerTime) pdq.Solve(pdq.CANON) pdq.Report()
import pdq #---- Define globals ------------------------------------------------- arrival_rate = 0.9 service_time = 1.0 #---- Initialize ----------------------------------------------------- pdq.Init("OpenCenter") pdq.SetComment("A simple M/M/1 queue") #---- Define the workload and circuit type --------------------------- pdq.streams = pdq.CreateOpen("work", arrival_rate) pdq.SetWUnit("Customers") pdq.SetTUnit("Seconds") #---- Define the queueing center ------------------------------------- pdq.nodes = pdq.CreateNode("server", pdq.CEN, pdq.FCFS) #---- Define service demand due to workload on the queueing center --- pdq.SetDemand("server", "work", service_time) #---- Solve the model ------------------------------------------------ # Must use the CANONical method for an open circuit
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY # # KIND, either express or implied. # ############################################################################### # # Created by NJG on Wed, Apr 18, 2007 # # Queueing model of an email-spam analyzer system comprising a # battery of SMP servers essentially running in batch mode. # Each node was a 4-way SMP server. # The performance metric of interest was the mean queue length. # # This simple M/M/4 model gave results that were in surprisingly # good agreement with monitored queue lengths. # # $Id: spamcan.py,v 1.2 2009/03/26 02:55:32 pfeller Exp $ import pdq # Measured parameters servers = 4 arivrate = 0.66 # per min servtime = 6.0 # seconds pdq.Init("SPAM Analyzer") nstreams = pdq.CreateOpen("Email", arivrate) nnodes = pdq.CreateNode("spamCan", int(servers), pdq.MSQ) pdq.SetDemand("spamCan", "Email", servtime) pdq.Solve(pdq.CANON) pdq.Report()
def ShowState(*L): """ L is a list of strings. Displayed by sys.stderr as concatenated elements of L and then stops execution """ sys.stderr.write("*** Trace state *** \n%s\n***\n" % "".join(L)) sys.exit(1) # PDQ modeling code starts here ... jNet = JackNet("SimPy Jackson Network", 1) # create an instance pdq.Init(jNet.name) pdq.SetWUnit("Msgs") pdq.SetTUnit("Time") # Create PDQ context and workload for the network streams = pdq.CreateOpen(jNet.work, jNet.arrivRate) # Create PDQ queues for i in range(len(jNet.router)): nodes = pdq.CreateNode(jNet.router[i], pdq.CEN, pdq.FCFS) pdq.SetVisits(jNet.router[i], jNet.work, jNet.visitRatio[i], \ jNet.servTime[i]) # Solve the model and report the peformance measures pdq.Solve(pdq.CANON) pdq.Report() # generic PDQ format # Collect particular PDQ statistics print "---------- Selected PDQ Metrics for SimPy Comparison ---------" for i in range(len(jNet.router)):
#!/usr/bin/env python ############################################################################### # Copyright (C) 1994 - 2009, Performance Dynamics Company # # # # This software is licensed as described in the file COPYING, which # # you should have received as part of this distribution. The terms # # are also available at http://www.perfdynamics.com/Tools/copyright.html. # # # # You may opt to use, copy, modify, merge, publish, distribute and/or sell # # copies of the Software, and permit persons to whom the Software is # # furnished to do so, under the terms of the COPYING file. # # # # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY # # KIND, either express or implied. # ############################################################################### # # M/M/1 in PyDQ import pdq pdq.Init("Python Test Script") pdq.nodes = pdq.CreateNode("Deadhorse", pdq.CEN, pdq.FCFS) pdq.streams = pdq.CreateOpen("Floggit", 0.75) pdq.SetWUnit("Cust") pdq.SetTUnit("Min") pdq.SetDemand("Deadhorse", "Floggit", 1.0) pdq.Solve(pdq.CANON) pdq.Report()
#---- Branching probabilities and weights ---------------------------- p12 = 0.30 p13 = 0.70 p23 = 0.20 p32 = 0.10 w3 = (p13 + p23 * p12) / (1 - p23 * p32) w2 = p12 + p32 * w3 #---- Initialize and solve the model --------------------------------- pdq.Init("Passport Office") pdq.streams = pdq.CreateOpen("Applicant", 0.00427) pdq.nodes = pdq.CreateNode("Window1", pdq.CEN, pdq.FCFS) pdq.nodes = pdq.CreateNode("Window2", pdq.CEN, pdq.FCFS) pdq.nodes = pdq.CreateNode("Window3", pdq.CEN, pdq.FCFS) pdq.nodes = pdq.CreateNode("Window4", pdq.CEN, pdq.FCFS) pdq.SetDemand("Window1", "Applicant", 20.0) pdq.SetDemand("Window2", "Applicant", 600.0 * w2) pdq.SetDemand("Window3", "Applicant", 300.0 * w3) pdq.SetDemand("Window4", "Applicant", 60.0) pdq.Solve(pdq.CANON) pdq.Report()
import pdq L = 50 S = 0.01 pdq.Init("example 7") nodes = pdq.CreateNode("Kanal", pdq.CEN, pdq.FCFS) stream = pdq.CreateOpen("Poruka", L) pdq.SetVisits("Kanal", "Poruka", 1.0 / 0.7, S) # pdq.SetDemand("Kanal", "Poruka", S) pdq.Solve(pdq.CANON) pdq.Report()