tweaking to add ability to use custom cost functions
Merge github.com:yangyangyyy/jsprit