Flowty Network Optimization Solver
Project description
Flowty
Install with
pip install flowty
Windows
Install the 64-bit version of python.
Linux
Install Fortran to work with the BLAS and LAPACK.
On apt-get
compatible distributions do
apt-get update
apt-get install libgfortran5
Quick Start
Let's solve the vehicle routing problem with time windows.
The objective is to minimize the total cost of routing vehicles from a central depot to a set of customers. Each customer must be visited exactly once within a specified time window to deliver their required demand, each customer has a service time it takes to unload the vehicle (modeled within the out-going travel time), and each vehicle has a maximum capacity of goods to deliver. If a vehicle arrives early it is allowed to wait for the customer's time window to start.
# Vehicle Routing Problem with Time Windows
from flowty import Model, xsum
from flowty.datasets import vrp_rep
bunch = vrp_rep.fetch_vrp_rep("solomon-1987-r1", instance="R102_025")
name, n, es, c, d, Q, t, a, b, x, y = bunch["instance"]
m = Model()
# one graph, it is identical for all vehicles
g = m.addGraph(obj=c, edges=es, source=0, sink=n - 1, L=1, U=n - 2, type="B")
# adds resources variables to the graph.
# demand and capacity
m.addResourceDisposable(
graph=g, consumptionType="V", weight=d, boundsType="V", lb=0, ub=Q, name="d"
)
# travel time and customer time windows
m.addResourceDisposable(
graph=g, consumptionType="E", weight=t, boundsType="V", lb=a, ub=b, name="t"
)
# set partition constriants ensure customers are only visited once
for i in range(n)[1:-1]:
m += xsum(x * 1 for x in g.vars if i == x.source) == 1
# packing set - at most one of these variables can be set. Helps the algorithm
for i in range(n)[1:-1]:
m.addPackingSet([x for x in g.vars if i == x.source])
status = m.optimize()
print(f"ObjectiveValue {m.objectiveValue}")
# get the variable values
for var in m.vars:
if var.x > 0:
print(f"{var.name} = {var.x}")
Visit docs.flowy.ai to get to know more.
License
The community license is a license to the general community which may have limited features and additional restrictions. For an unlimited commercial, academic or trial license contact Flowty at info@flowty.ai.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file flowty-1.2.10-py3-none-any.whl
.
File metadata
- Download URL: flowty-1.2.10-py3-none-any.whl
- Upload date:
- Size: 6.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
c840665c9a9aa2f039b1cc3a467927f7fe6d4a2876279ee2aac1c62b1e947e5e
|
|
MD5 |
0bcf850744b99b7f3e803df5229d5e9e
|
|
BLAKE2b-256 |
c30baacd19437bcc77ff5613c6c37dc7c6d8f5227b65f8aced4668bd497efba4
|