Initial commit of functions from github.com/btracey/optimize

This can be done without a map with care - even with negative status values.