Modeling Elevator Usage Pt. I

I was reading a book on modeling and the first problem in the first chapter asked the reader to model the use of an elevator during the morning rush at an office. There was the implicit assumption that employees would only be going up, and that there wouldn’t be any intra-level travel. I though this problem was interesting, so I thought I’d start to model this with Python. (I turned out that it was a rabbit hole.) I think that this is interesting for two reasons, you can model the wait-time for a very common situation, this can be abstracted to a more general constrained resource problem. This is my first whack:

Continue reading

Making and Changing into a Directory

This function, added to your shell profile, will allow you to create directories and cd into them in one fell swoop, without you having to type mkdir, and then cd ALL DAY. After looking around online, I like the name mkcd for this utility, because md makes me think of markdown.

For some reason, I couldn’t get this to work as a one-liner in my .zshrc file, but the listing below worked fine.

function mkcd () {
  mkdir -p $1
  cd $1

Note that the -p flag allows you to create a directory several directories deep at one go, without having to descend into them one at a time.

Visualizing Networks with Graphviz

In this post I’ll look at building graphs in Python using the graphviz module. This assumes that you’ve installed graphviz itself, which is easy enough on a Mac using homebrew. (Simply run: brew install graphviz.) I had two requirements for my graphs: I needed them to be directed, and I wanted to use the edge thickness to illustrate the strength of a connection. The first part was dead simple, but the second part required a little hunting.

Continue reading