Skip to main content

A solver for fixed route vehicle charging problems

Project description

frvcpy: An Open-Source Solver for the FRVCP

Inserting charging stations into electric vehicle routes

The FRVCP

The fixed route vehicle charging problem (FRVCP) is characterized by a vehicle that must visit an ordered sequence of locations (a fixed route). The vehicle is limited in its onboard energy, which gets depleted as it travels. As a result, it must restore its energy along the way. The typical objective of the FRVCP is to find the optimal "insertion" of energy restoration operations into the fixed route that minimize the route's duration. The problem was given its acronym in Montoya et al. (2017) for the case of electric vehicles (EVs), which require nontrivial amounts of time to restore the energy in their batteries and must therefore carefully consider their recharging operations.

The Solver

To solve the FRVCP, frvcpy implements the labeling algorithm from Froger et al. (2019), providing an exact solution in low runtime. The algorithm incorporates realistic problem features such as nonlinear charging functions, heterogeneous charging station technologies, and multiple CS visits between stops.

Usage

With a compatible instance file (see the schema), solve the FRVCP from a Python script:

from frvcpy.translator import translate
from frvcpy.solver import Solver

route = [0,3,2,1,0]      # route to make energy feasible
q_init = 750           # vehicle's initial energy level

# using an existing instance from file
frvcp_solver = Solver("instances/frvcpy-instance.json", route, q_init)

# run the algorithm
duration, feas_route = frvcp_solver.solve()

print(f"Duration: {duration:.4}")
# Duration: 123.4567

print(f"Energy-feasible route:\n{feas_route}")
# Energy-feasible route:
# [(0, None), (3, None), (2, None), (4, 300.0), (1, None), (0, None)]

Or from the command line:

frvcpy --instance=./instances/frvcpy-instance.json --route=0,3,2,1,0 --qinit=750
# Duration: 123.4567
# Energy-feasible route:
# [(0, None), (3, None), (2, None), (4, 300.0), (1, None), (0, None)]

Instance Translation

frvcpy includes a translator for some E-VRP instances formatted according to the VRP-REP specification. If you have such an instance file, it can be translated with the Python API via

from frvcpy.translator import translate

# Option 1) make instance object to be passed directly to the solver
frvcp_instance = translate("instances/vrprep-instance.xml")

# Option 2) write the translated instance to file
frvcp_instance = translate("instances/vrprep-instance.xml", to_file="instances/my-instance.json")

Or via the command line via

frvcpy-translate instances/vrprep-instance.xml instances/my-instance.json

Translation requirements for VRP-REP instances

The translator assumes VRP-REP instances are formatted similarly to the Montoya et al. (2017) instances:

  • CSs are identified as <node> elements having attribute type="2"
  • Charging stations nodes have a <custom> child element which contains a cs_type element
  • For each unique CS type t appearing in those cs_type elements, there exists a charging function element with attribute cs_type=t
  • These function elements are part of a charging_functions element in a vehicle_profile's custom element
  • The depot has node ID 0, the N customers have IDs {1, ..., N}, and the CSs have IDs {N+1, ..., N+C}

Here is a small example meeting these requirements:

<?xml version="1.0" encoding="UTF-8"?>
<instance>
  <network>
    <nodes>
      <node id="0" type="0">
        <cx>74.83</cx>
        <cy>51.85</cy>
      </node>
      <node id="1" type="1">
        <cx>68.77</cx>
        <cy>75.69</cy>
      </node>
      <node id="11" type="2">
        <cx>57.0</cx>
        <cy>57.04</cy>
        <custom>
          <cs_type>fast</cs_type>
        </custom>
      </node>
    </nodes>
    <euclidean/>
    <decimals>14</decimals>
  </network>
  <fleet>
    <vehicle_profile type="0">
      <departure_node>0</departure_node>
      <arrival_node>0</arrival_node>
      <speed_factor>25.0</speed_factor>
      <custom>
        <consumption_rate>0.125</consumption_rate>
        <battery_capacity>16.0</battery_capacity>
        <charging_functions>
          <function cs_type="fast">
            <breakpoint>
              <battery_level>0.0</battery_level>
              <charging_time>0.0</charging_time>
            </breakpoint>
            <breakpoint>
              <battery_level>13.6</battery_level>
              <charging_time>0.317</charging_time>
            </breakpoint>
            <breakpoint>
              <battery_level>15.2</battery_level>
              <charging_time>0.383</charging_time>
            </breakpoint>
            <breakpoint>
              <battery_level>16.0</battery_level>
              <charging_time>0.517</charging_time>
            </breakpoint>
          </function>
        </charging_functions>
      </custom>
    </vehicle_profile>
  </fleet>
  <requests>
    <request id="1" node="1">
      <service_time>0.5</service_time>
    </request>
  </requests>
</instance>

Solver Input

Use of the solver requires

  1. An instance (either a JSON file or equivalent Python dictionary) containing the information described in the schema.

    • We suggest following the convention where the first (zeroth) node is the depot, followed by customer nodes, followed by CS nodes.

    • If the depot also serves as a CS for the EV, then an additional CS node should be created for it (note: this is handled automatically if using the translator).

  2. EV's fixed route

    • Ordered list of depot/customer nodes the EV must visit
  3. EV's initial charge

    • A number in [0, max_q], as defined in the instance

Additional information

For more information about the algorithm used in the solver, see Froger et al. (2019).

For a write-up of the package: Manuscript in preparation

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

frvcpy-0.1.0rc1.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

frvcpy-0.1.0rc1-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file frvcpy-0.1.0rc1.tar.gz.

File metadata

  • Download URL: frvcpy-0.1.0rc1.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for frvcpy-0.1.0rc1.tar.gz
Algorithm Hash digest
SHA256 bdfb0be4f33214c2e5038f05312375c31da9bc49bbea42991738cdb5c8f1e24b
MD5 a305b639760298c0185c083f2011d3dd
BLAKE2b-256 6d2ae1ecf427e8f73caa797220524cccf09b567322b2ba57b0f6f82d8f900419

See more details on using hashes here.

File details

Details for the file frvcpy-0.1.0rc1-py3-none-any.whl.

File metadata

  • Download URL: frvcpy-0.1.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for frvcpy-0.1.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f7bcf7ff78fe773eac4c80dc9581a2c49040c3b99cbcf2e6174fcb7cef77e1c
MD5 6ff53075ce2654c6e842e2376b985058
BLAKE2b-256 3e2c18b456cec7fe2ed7cb4433a675c1fead51d315369f0993a4f23795cc503d

See more details on using hashes here.

Supported by

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