Mélanie Cortina
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Replaning Signature: `replanning(self, veh: Vehicle, new_activities: Optional[Set[VehicleActivity]] = None) -> Queue[VehicleActivity]` Returns a new `Queue[VehicleActivity]` with the `new_activities` in it. Optimize the order of `Queue[VehicleActivity]` following criteria such as distance. Note that: * We choose that replanning function should be able to insert several new activities, in the code, if this list contains only one element, we may use a more specific and efficient method than the generic case * In the replanning function, we take into account the two types of constraint for travelers, namely pickup_dt and max_detour_ratio. The pickup_dt constraint is integrated as a **time window for the pickup nodes** and the max_detour_ratio constraint is converted into a **temporal deadline for the dropoff** (in fact into a time window for the dropoff node with a dummy lower bound). The motivation for this conversion is to treat homogeneous constraints. It is more classical to have time windows than "distance windows". * Objective function: we would like to define several objective function available (e.g. sum of distances, sum of travel times, min of the max the service time, profit for the service, ...). But in a first implementation, we consider the total traveled distance as the objective function to minimize. * The activities already planned for vehicle are mandatory, they should appear in the new plan but not necessarily in the same order ## Problem description This corresponds to a single vehicle pickup and delivery problem. Let us note $n$ the number of new requests to add in vehicle's plan (then there are $2n$ new activities given that a request has one pickup and one dropoff activity), $m$ the number of requests currently planned in vehicle's activities for which the user has not been picked up yet, $p$ the number of requests currently planned in vehicle's activity for which the user has been picked up (only dropoff activity is to be achieved, user is a passenger of the vehicle). An activity is identified with a unique integer id. The replanning function returns an optimized plan including the following activities: * 0: vehicle's current location, it acts as the departure depot * $1, ..., n, n+1, ..., 2n$: pickups and dropoffs associated with the new requests to add in plan, where $n+i$ is the dropoff associated with pickup $i$ * $2n+1$, ..., $2n+m$, $2n+m+1$, ..., $2n+2m$: pickups and dropoffs associated with the requests currently planned in vehicle's activities for which user has not been picked up yet * $2n+2m+1$, ..., $2n+2m+p$: dropoffs associated with the passengers currently in vehicle With each activity $i$, we define: * $e_i$: earliest pickup/dropoff time * $e_0$ = current time * $e_i$ = max(request time, current time) for $1 <= i <= 2n+2m$ * $e_i$ = current time for $2n+2m+1 <= i <= 2n+2m+p$ * $l_i$: latest pickup/dropoff time * $l_0$ = current time + dt_matching * $l_i$ = request time + pickup_dt for $1 <= i <= n$ and $2n+1 <= i <= 2n+m$ * $l_i$ = ( request time + pickup_dt + shortest path travel time * max_delay_ratio) for $n+1 <= i <= 2n$ and $2n+m+1 <= i <= 2n+2m$ and $2n+2m+1 <= i <= 2n+2m+p$ where would be formally defined as max_delay_ratio = (mean speed on shortest path / mean speed on detoured path) * max_detour_ratio but should be approximated to be defined a priori * $q_i$: load, if positive it's a pickup, if negative it's a dropoff * $q_i=-q_{n+i}$ for $1 <= i <= n$ * $q_i = -q_{m+i}$ for $2n+1 <= i <= 2n+m$ * $q_i$ = -1 for $2n+m+1 <= i <= 2n+2m+p$ We note $D_{ij}$ and $T_{ij}$ the distance and travel time between activities $i$ and $j$. Vehicle has a capacity $Q$. The best plan for mobility service corresponds to the plan that respects all constraints and minimizes the total distance traveled. We define variables $x_{ij}$ (1 if vehicle travels from $i$ to $j$, 0 otherwise), $t_i$ (arrival time at $i$) and $y_i$ (number of passengers in vehicle just after activity $i$). The problem can be formulated as follows: ![](https://i.imgur.com/RibL0Ut.png) Constraints that should be ensured: * Vehicle leaves the "depot" (current location) * All nodes should be visited once * **time windows**: arrival time at $i$ is within the time window * **precedence**: a pickup is served before the corresponding dropoff * If vehicle arrives before earliest pickup time at node, it should wait * **capacity**: number of passengers remains lower or equal to vehicle's capacity ## Resolution approaches Here is a coding environment to test your own approaches: https://github.com/kit4a/ridesharing_tools.git ### Exhaustive Exhaustive resolution is possible in a reasonable execution time for $2*n+m < 10$. ### Hill climbing This approach does not necessarily produce valid solutions. It is interesting for large instances only (more than 30 activities). ### A Mixed Integer Linear Programming (MILP) formulation: In the following, we state a MILP formulation for the ride sharing problem where both the assignments of the requests over the vehicles as well as the routing for each vehicle is determined. Let $\mathcal{R}$ be a set of requests to be assigned. For each $r \in \mathcal{R}$ a pick-up and dropoff activities are associated to it. Let $\mathcal{P} = \{1,2,...,|\mathcal{R}|\}$ be the set of pick-ups and $\mathcal{D} = \{ |\mathcal{R}|+1, |\mathcal{R}|+2, ..., 2\times |\mathcal{R}|\}$ the set of dropoffs. Let $\mathcal{K}$ be a set of vehicles. Each vehicle $k \in \mathcal{K}$ has a capacity $Q_{k}$, an initial load $q_{0}^{k}$ and $\mathcal{P}^{k}$ and $\mathcal{D}^{k}$ which respectively represent the set of already planned pick-ups and dropoffs for vehicle $k$. For each pick-off activity $i \in \{\mathcal{P} \cup \mathcal{P}_{k \in \mathcal{K}}^{k} \}$ a time-window $[e_{i}, l_{i}]$ and a number of passengers to to be loaded in the vehicle $q_{i}$ are associated. For each dropoff activity $i \in \{\mathcal{D} \cup \mathcal{D}_{k \in \mathcal{K}}^{k} \}$ a deadline $\tilde{d}_{i}$ and a negative number of passengers to be loaded off $q_{i}$ are associated. * ps: Should we add a service time to account for the time where the vehicle parks to pick-up or drop-off a person? This way it is instantaneous. Let $\mathcal{G}^{k}=\{\mathcal{V}^{k}, \mathcal{A}^{k}\}$ be the graph that represents the network for each vehicle $k \in \mathcal{K}$ where $\mathcal{V}^{k}=\{ \{o^{k}\} \cup \mathcal{P} \cup \mathcal{D} \cup \mathcal{P}_{k \in \mathcal{K}}^{k} \cup \mathcal{D}_{k \in \mathcal{K}}^{k}\}$ where the node $o^{k}$ represents the departure location of vehicle $k$. $D_{ij}^{k}$ represents the distance of travelling the arc $(ij) \in \mathcal{A}^{k}$ with vehicle $k \in \mathcal{K}$ and $\tau_{ij}^{k}$ the travelling time. The variables of the model are as follows: * $x_{ij}^{k} = 1$ if the arc $(ij) \in \mathcal{A}^{k}$ is taken with vehicle $k \in \mathcal{K}$, 0 otherwise. * $y_{i}^{k} =1$ if request $i \in \mathcal{R}$ is serverd by vehicle $k \in \mathcal{K}$, 0 otherwise. * $t_{i}^{k} \in \mathbb{R}$ represents the time of arrival of vehicle $k \in \mathcal{K}$ at location $i \in \mathcal{V}^{k}$. * $q_{i}^{k} \in \mathbb{R}$ represents the load of vehicle $k \in \mathcal{K}$ at location $i \in \mathcal{V}^{k}$. ![](https://i.imgur.com/Bp2T2ke.png) The objective function maximises the number of requests as a priority and minimises the distance travelled as a secondary objective. Constraints (1) state that if a request $i \in \mathcal{R}$ is performed, both the pick-up and dropoff activities are performed. Constraints (2) state that the activities already planned for a vehicle $k \in \mathcal{K}$ need to be performed. Constraints (3-4) ensure the flow of time and quantity at each node. Constraints (5-6) ensure that the time-windows for a pick-up activity are enforced. Constraints (7) ensure that if a request is performed, the dropoff activity is conducted after the pickup activity. Constraints (8) ensure that the deadline for a dropoff activity is enforced. Constraints (9-10) enforce the bounds of the load variable. Finally, constraints (11-12) ensure the integrality and positivity of the variables. Constraints (3-4) being non-linear, they can be linearised as follows: $t_{i}^{k} \geq t_{j}^{k} + \tau_{ji}^{k} - T_{ji}^{k} (1 - x_{ji}^{k})$ $\quad \forall k \in \mathcal{K}$ , $i, j \in \mathcal{V}^{k}$ $\quad (3^{\prime})$ $q_{i}^{k} \geq q_{j}^{k} + q_{i} - Q_{ji}^{k} (1 - x_{ji}^{k})$ $\quad \forall k \in \mathcal{K}$ , $i, j \in \mathcal{V}^{k}$ $\quad (4^{\prime})$ $T_{ji}^{k}$, $Q_{ji}^{k}$ and $M_{\text{obj}}$ are upperbounds that can be defined as follows: $T_{ji}^{k}= \begin{cases} \max\{0, l_{j}+\tau_{ji}^{k}-e_{i}\} \quad \forall i \in \mathcal{P} \cup \mathcal{P}^{k}_{k \in \mathcal{k}}\\ \max\{0, \tilde{d}_{j}+\tau_{ji}^{k}-(e_{i-n}+\tau_{i-ni}^{k})\} \quad \forall i \in \mathcal{D} \cup \mathcal{D}^{k}_{k \in \mathcal{k}} \end{cases}$ $Q_{ji}^{k}=\min\{Q_{k}, Q_{k}+q_{j}\}$ $M_{\text{obj}}=4\max\limits_{k \in \mathcal{K}, (ij) \in \mathcal{A}^{k}}\{D_{ij}^{k}\}$ ``` ## Time windows definition Time windows should be defined to minimize the discomfort of passengers that are already in the vehicle ($2n < i < 2n+m+1$). * A possible approach is to define sharp time windows for passengers already in vehicle (e.g. dropoff time estimated with vehicle's current plan + alpha) and large (unrestrictive) time windows for new requests. * Another approach is to define distance windows instead of time windows. New variables $d_i$ could be defined as the distance traveled by vehicle at arrival at $i$. If vehicle travels between $i$ and $j$, $d_j = d_i + D_{ij}$. Precedence constrain becomes: $d_i < d_{n+i}$. For passengers already in vehicle, the lower bound of distance window is 0, and upper bound is max detour + sp distance - already traveled distance. For new activities, lower bound is 0 and upper bound is an arbitrary large number. With this strategy, feasibility of new plan is verified. * Or we do not try to build a feasible new plan and we use unrestrictive time windows. ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully