A python package for operations research and data science problems.
Project description
(In Development)
pyords
A library for operations research and data science.
implementation types
- graph theory
- genetic algorithm
- simulation
- machine learning
motivation behind the project
Self-learning:
- Open-source software development
- Data Science
- Operations Research
- Financial Engineering
- Visualizations in Python or JavaScript
- Big splash! NumPy, Pandas, D3.js, Plotly, Matplotlib, IPython and jupyter, scikit-learn and SciPy, git, Google OR Tools (ortools), Pyomo, Supply Chain Guru, Keras, Hadoop, AWS, GCP, Vagrant
Development & Documentation
pyords Bundle
s
Bundle
s are self-contained problem definitions implemented as modular instances. That's wanna-be fancy for packaged units of code that are very plug-in and play. Contributing to Bundle
development:
-
Design the problem as a
Case
where theCase
can be tested against variousBundle
s that solve the problem defined in theCase
. For the purposes of thisREADME
we'll useVrpVehicleCase
.Case
s must help define what is required of a feature implementation (or the improvement of one). For ourVrpVehicleCase
we'll assume a set of data and configurations for basic vrp model requirements and a desired output of optimized vehicles to append to our data. -
Build a
Bundle
. The bundle should be specific to theCase
(s) it solves. Maybe you see where I'm going with this. There are two core components of this library:Bundle
sCase
s
-
Test the
Case
against itsBundle
. -
Submit implementation with documentation supporting the reason for its development.
VrpVehicleCase
- defines allowable data for one or many vehicles outputs via vrp optimization
- defines input expectations & tests
- defines
Case
expectations & tests - defines output expectations & tests
- related:
- GeoBundle
- OrBundle
GeoBundle
- processed zipcode outputs, lat and lon outputs, haversine distance outputs, and lat and lon cluster outputs
- integrations:
- related:
- ZipcodeCleanCase
- LatLonCase
- LatLonDistanceCase
- LatLonClusterCase
OrBundle
- operations research optimizations: vrp, network optimization, scheduling.
- opportunity analysis, health checks.
- implementations:
- Vrp optimization via Google OrTools
- Schedule optimization via Genetic Algorithm
- integrations:
- vrp: google ortools
using pyords Bundle
s for vehicle optimization
import pyords as pyr
df = pd.read_csv('my_shipment_data.csv')
geobndl = pyr.GeoBundle(zipcodes=df.zipcodes)
lats, lons = geo_bndl.pgeo('US')
matrix = geobndl.haversine_all_from(origin=origin, 'mi')
clusters = geobndl.cluster(by='geocodes')
orbndl = pyr.OrBundle(matrix=matrix, demand=df.pallets)
vehicles = orbndl.ortools.vrp(
depot_index=0, # required
max_vehicle_capacity=26, # default: 26
max_search_seconds=30, # default 30
partitions=clusters, # optional TODO: allow for distributed
return_solution=True # optional
)
live_vehicles_returned = [v for v in vehicles if len(v['stops'][1:-1]) > 0]
assert orbndl.vehicles.pull('n.utilized') == len(live_vehicles_returned)
df['vehicles'] = orbndl.pull('vehicle_id')
Testing pyords Bundle
s :white_check_mark:
import pyords as pyr
class VrpVehicleCase:
inputs = {
'matrix': [[0, 1, 2], [1, 0, 2], [2, 2, 0]],
'demand': [0, 3, 4],
'max_vehicle_capacity': 5,
'partitions': [1, 1, 1]
}
outputs = {
'vehicle_id': [1, 2]
}
implementation = pyr.OrBundle.ortools.vrp
def run():
bndl = pyr.OrBundle(case=VrpVehicleCase)
assert bndl.test()
if __name__ == '__main__':
VrpVehicleCase.run()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.