The Grotto Network Design Course’s Example Code

This is the code used to generate the examples in the course lecture slides. Some of these examples are relatively short Python scripts, others a more involved and utilize separate functions to help formulate, solve, and process the results of the various network design problems surveyed in the course.

The code is divided up into separate directories (Python packages) for each of the main lecture areas with an additional directory for utilities that are used across multiple design problems.

Note

Many (most) of the examples uses additional Python libraries that are commonly found in many free scientific Python distributions such as Anaconda, PythonXY, and Canopy. These include numpy, scipy, matplotlib, networkx. In addition there are two additional libraries: PulP and SimPy that are needed for problem formulation and discrete event simulation (more on these in particular package documentation).

Note

The APIs of open source libraries may change over time and break this code please report any problems to gregb@grotto-networking.com. For example this code was last updated December 2014 to deal with a change in the NetworkX API for saving graphs to JSON.

How to execute examples

As this is academic example code, rather than a set of Python libraries for production use, no elaborate or automated installation procedure is needed. Just download the unzip the code from appropriate section of the https://www.grotto-networking.com website.

However, since we aren’t using an installer we need to be able to tell Python where to look for the utility modules and such. This can be done in a couple ways: (1) adjusting the python path, or (2) appending to the Python sys.path in an interactive shell. In the examples below I’ve unzipped the code archive to the directory

D:\Greg\Compute_and_Networking\DesignCourse\Code

on my Windows machine and

/home/greg/Greg_Work/Compute_and_Networking/DesignCourse/Code

on my Linux box.

Dealing with PYTHONPATH:

Windows command line:

set PYTHONPATH=D:\Greg\Compute_and_Networking\DesignCourse\Code;

Linux bash shell:

export PYTHONPATH="$PYTHONPATH$:/home/greg/Greg_Work/Compute_and_Networking/DesignCourse/Code"

Within a Python interactive shell like IPython (windows):

import sys
sys.path.append(r"D:\Greg\Compute_and_Networking\DesignCourse\Code") # Windows

Within a Python interactive shell like IPython (windows):

import sys
sys.path.append("/home/greg/Greg_Work/Compute_and_Networking/DesignCourse/Code") # Linux

Indices and tables

Table Of Contents

Next topic

RandomVariables package

This Page