This document explains how that solution was developed and how it can be explored.
- The default max cargos for truck is 1
make dev
- We can try a max cargo option for truck = 2
make dev/maxcargo
- The default distance calculation use the Harvesine formula
make dev
- More accurate, you can use the Google Routes remote provider (you must provide GOOGLE_API_KEY env var):
make run/remote
Five different algorithms were developed, with 2 remaining:
- Iteration with sorted dictionary The classic cargos x trucks iteration (sorted dictionary)
make run
- Iteration only for cargos + O log(n) kd-tree (optimized when the trucks are loaded): While the trucks are loaded, for each truck appended, we use a kd-tree to manage the locations.
make run/kdtree
- Watch for modifications, run lint and tests
make dev/watch
- Run dev mode (with performance check)
make dev
- Apply lint corrections (90% effective), based on PEP 8
make lint/fix
I'm not Python senior, but I really appreciate Python's language.
- I followed The Zen of Python
- Read Luciano Ramalho's "Fluent Python"
- Beyond the pythonic way, or in case of doubts, my guide is the Uncle Bob's "Clean Code"
- Add a hash function for the locations: to improve even more the checking for the closest trucks
- Add parallelization processing
- Add algorithm to decide which cargo is best in case of an already designated truck
- Add Docker: there's some code, but it's not totally functional
- Plot maps for the inputs and the final solution
- For more options check the Makefile