Skip to main content

No project description provided

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vrpbap-0.0.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vrpbap-0.0.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file vrpbap-0.0.1.tar.gz.

File metadata

  • Download URL: vrpbap-0.0.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for vrpbap-0.0.1.tar.gz
Algorithm Hash digest
SHA256 68c36c9a9c3803d9fb00e67d4f13771bb06164b01ec94e1962d25881c9ddfefd
MD5 9e5978f510bde27a37e0ab9157c82bfc
BLAKE2b-256 0becf39f65aa0c74d49a63d1522083c02a0b03bc0606bfc33ccb9b13ca839f2d

See more details on using hashes here.

File details

Details for the file vrpbap-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: vrpbap-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for vrpbap-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d0ae8b25179588900187a3fdfb015f455077e5ed949371f96938a47ea0b1d28e
MD5 24c40e12b31e7d3e7e5208a6bb909cb2
BLAKE2b-256 e94a1590e95d506324fb2e22d77d0bd723fd782e5677dcfe884d4faad3cbb6df

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page