Skip to main content

vrpbap

PyPI - Version PyPI - Python Version


Table of Contents

Installation

  1. Install hatch.
  2. Build a wheel.
hatch build
  1. Install the wheel in your environment.
pip install dist/vrpbap-0.0.1-py3-none-any.whl

License

vrpbap is distributed under the terms of the MIT license.

Example

Implement a class inheriting vrpbap.RoutePricer. Two methods are required:

  • pricerredcost_column for reduced cost pricing.
  • pricerfarkas_column for Farkas pricing.

Each method has 4 arguments:

  • edges: a set of pairs of nodes (integers), representing directed edges.
  • node_costs: a dictionary mapping a node to its negative dual value.
  • constant_cost: the negative dual value of the number of vehicle constraint (0 if no constraint).
  • time_limit: the time limit in seconds (optional).

Each method is a generator of a column, which yields a 5-tuple (route, coeffs, cost, redcost, stopped) where

  • route: tuple of nodes (integers) representing a route, including the starting and ending depots.
  • coeffs: a dictionary mapping a node to the number of times it is visited in the route, excluding the depots.
  • cost: the cost of the route in the original graph.
  • redcost: the reduced cost of the route.
  • stopped: binary flag, True if pricing is early stopped (stopped without proving the optimality).

When route is None, then the algorithm assumes that no column is found. If stopped is False in addition, it means that the subproblem is infeasible. If stopped is True, it means that pricing is stopped without finding a column.

To solve a problem, instantiate the implemented pricer and pass it to vrpbap.VRPBap. It takes the following arguments:

  • nodes: a list of nodes that must be visited, excluding depots.
  • edges: a list of edges (pairs of nodes).
  • start_depots: a list of start depots.
  • end_depots: a list of end depots.
  • pricer: the pricer.
  • routes: initial routes, represented by a list of tuples of integers (optional).
  • route_coeffs: coefficients for the initial routes, represented by a list of dictionaries (optional).
  • route_costs: the costs of the initial routes, represented by a list of integers or floats (optional).
  • max_routes: the maximum number of routes, no constraint if None (default).
  • verbosity: an integer from 0 to 3 (0 by default).
  • time_limit: the time limit in seconds (integer).
  • objective_integral: whether the objective value is integral.
from vrpbap import RoutePricer, VRPBaP


class MyPricer(RoutePricer):
    def __init__(self):
        pass

    def pricerredcost_column(self, edges, node_costs, constant_cost, time_limit=None):
        pass

    def pricerfarkas_column(self, edges, node_costs, constant_cost, time_limit=None):
        pass


pricer = MyPricer()


model = VRPBaP(
    nodes=[1, 2],
    edges=[(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)],
    start_depots=[0],
    end_depots=[0],
    pricer=pricer,
    routes=routes,
    route_coeffs=route_coeffs,
    route_costs=route_costs,
    max_routes=m,
    verbosity=args.verbosity,
    time_limit=args.timeout,
    objective_integral=True,
)
solution = model.optimize()
print(solution)

Metadata

Release files for vrpbap 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vrpbap 0.0.1
File Size Uploaded
vrpbap-0.0.1.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vrpbap 0.0.1
File Interpreter ABI Platform
vrpbap-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.1 kB

Release files / vrpbap-0.0.1.tar.gz

Download URL vrpbap-0.0.1.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
68c36c9a9c3803d9fb00e67d4f13771bb06164b01ec94e1962d25881c9ddfefd
BLAKE2b-256 checksum
How to use checksums
0becf39f65aa0c74d49a63d1522083c02a0b03bc0606bfc33ccb9b13ca839f2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / vrpbap-0.0.1-py3-none-any.whl

Download URL vrpbap-0.0.1-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d0ae8b25179588900187a3fdfb015f455077e5ed949371f96938a47ea0b1d28e
BLAKE2b-256 checksum
How to use checksums
e94a1590e95d506324fb2e22d77d0bd723fd782e5677dcfe884d4faad3cbb6df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page