Sensor Networks Assignment 1 Hints - Ece
Personal tools

Sensor Networks Assignment 1 Hints

From Ece

Jump to: navigation, search

Contents

Hints for Assignment 1

  • CSV reading/writing is built into python versions 2.3+ for the m$ excel users out there. Google™ "python csv module" to find out more how to use it. (wh69)

SimPy and Discrete-Event Simulation A

  • For the fixed time, you should create a constant and add it to the yield time.
  • For running through permutations of AVGITEMS and AISLES, you want to run each case for RUNS times, so you just need a few extra for loops around the run case. To keep the number of runs down, you might want to step through AVGITEMS in steps of 5, using range(5, 51, 5), where the first two variables are the range of the variables, and the third is the size of the step.
  • Writing to a file might be useful, although you can also just copy it from a terminal window.

SimPy and Discrete-Event Simulation B

  • When creating express aisles, you are going to create a SimPy Resource based on an EXPRESS variable, and the number of checkout aisles will be AISLES-EXPRESS.
  • The dir function in Python can be useful for discovering the attributes of an object. This should particularly be useful for determining which line to get into when checking out.
  • The aisle you choose is solely up to you, but will likely be based on the above. So you should have two different yield hold type statements depending on which aisle you choose.
  • In addition to the loops above, the number of express aisles will also change, and the item limit will as well. There's going to be a LOT of data, so try to make sure everything is clearly labeled and organized, and since it will likely take a while, make sure your data is being written correctly, then fire it up and go to lunch.  :)

Sensor Network Simulation 0

  • Note that in some of the included programs in programs.py, neighbors are checked via self.host.neighbors. The self is the program itself, host is a variable that points to the node the program is running on, and neighbors is this list of all that node's neighboring nodes.
  • This program will run on all nodes once, so set numRuns = 1, and use the '+' operator before your program name in the command line (this specifies to run on all nodes).
  • When writing to a file, you should probably use append mode when opening the file. This is done via f = open('./out.txt', 'a'), where the first parameter is the filename, and the second is the mode. Another mode is 'w', or write mode, and this will clear the file and start from scratch each time you open a file in this mode.
  • Make sure to close the file when finished, since due to buffering all the data may not be written until the file is explicitly closed.
  • Achieving an average of 5-8 neighbors can be done either by adjusting the simulation's area, or by changing the radius of communication for each node.
  • If you're using linux to generate graphs with Graphviz, use neato, as opposed to dot. dot is generally meant for directed graphs, and neato for undirected.