公交调度可视化调研3 | 青训营笔记

159 阅读8分钟

公交调度可视化调研3 | 青训营笔记

这是我参与「第五届青训营 」伴学笔记创作活动的第 14 天

(仅供自己参考,技术点请看字节整理的资料和相应官方技术文档)

这是前端项目系列里的第3篇《公交调度可视化调研3》

Technician Routing and Scheduling Problem

Objective and Prerequisites

Try this modeling example to discover how mathematical optimization can help telecommunications firms automate and improve their technician assignment, scheduling, and routing decisions in order to ensure the highest levels of customer satisfaction.

This modeling example is at the intermediate level, where we assume that you know Python and are familiar with the Gurobi Python API. In addition, you have some knowledge about building mathematical optimization models. To fully understand the content of this notebook, you should be familiar with object-oriented-programming.

Download the Repository
You can download the repository containing this and other examples by clicking here.

Gurobi License
In order to run this Jupyter Notebook properly, you must have a Gurobi license. If you do not have one, you can request an evaluation license as a commercial user, or download a free license as an academic user.

Motivation

The Technician Routing and Scheduling (TRS) is a common problem faced by telecommunication firms, which must be able to provide services for a large number of customers. With its limited resources, these firms must try to deliver timely, affordable and reliable services to maximize customer satisfaction. The TRS problem involves assignment, scheduling, and routing of multi-skilled technicians to serve customers with unique priorities, service time windows, processing times, skills requirements, and geographical locations. In the current practice, these decisions are often being made by operators via heuristics, sometimes manually -and this method can not only be time-consuming, but may also deviate from optima significantly. Using mathematical optimization to solve the TRS problem will enable telecom operators and dispatchers to automate and improve their assignment, scheduling, and routing decisions, while achieving high customer satisfaction.

Problem Description

A telecom firm operates multiple service centers to serve its customers. Each service center has its technicians who are dispatched from the service center to work on their assigned jobs, and return to the center after all the jobs are completed. A technician has multiple skills and available working capacity that cannot be exceeded during the scheduling horizon. A service order/job has a known processing time, a customer-specified time window for starting the service, a deadline of completing the service, and its skill requirements. Depending on the nature of the job (routine maintenance or emergency), and relationship with the customer (existing, new), the firm assesses the importance of the job and assigns a priority score to it. A job is assigned to at most one technician who possesses the required skills, but the technician's available capacity during the scheduling horizon cannot be exceeded. To solve the TRS problem, telecommunications companies must be able to simultaneously makes three types of decisions: (i) the assignment of jobs to a technician at all the service centers; (ii) the routing of each technician, i.e. the sequence/order of customers for a technician to visit; (iii) and the scheduling of jobs, i.e. the timing for a technician to arrive at a customer location and complete the corresponding job. The firm’s goal is to minimize the total weighted lateness of all jobs, with their priority being the weights.

The following constraints must be satisfied:

  • A technician, if utilized, departs from the service center where he/she is based and returns to the same service center after his/her assigned jobs are completed.
  • A technician’s available capacity during the scheduling horizon cannot be exceeded.
  • A job, if selected, is assigned to at most one technician who possesses the required skills.
  • A technician must arrive at a customer location during an interval (time window) specified by the customer, and must complete a job before the deadline required by the customer. This an important constraint for guaranteeing customer satisfaction.

The above basic TRS is a variant of the multi-depot vehicle routing problem with time windows, known as the MDVRPTW in the literature [1].

Solution Approach

Mathematical programming is a declarative approach where the modeler formulates a mathematical optimization model that captures the key aspects of a complex decision problem. The Gurobi Optimizer solves such models using state-of-the-art mathematics and computer science.

A mathematical optimization model has five components, namely:

  • Sets and indices.
  • Parameters.
  • Decision variables.
  • Objective function(s).
  • Constraints.

To simplify the MIP formulation, we consider that for each job's skill requirements, we can determine the subset of technicians that are qualified to perform the job based on the skills that the technicians have.

We now present a MIP formulation for the basic TRS problem.

Model Formulation

Sets and Indices

j∈J={1,2,...,n}j∈J={1,2,...,n}: Index and set of jobs.

k∈Kk∈K: Index and set of technicians.

K(j)⊂KK(j)⊂K: Subset of technicians qualified to perform job j∈Jj∈J

d∈D={n+1,n+2,...,n+m}d∈D={n+1,n+2,...,n+m}: Index and set of depots (service centers), where mm is the number of depots.

l,i,j∈L=J∪D={1,2,...,n+m}l,i,j∈L=J∪D={1,2,...,n+m}: index and set of locations to visit.

Parameters

βk,d∈{0,1}βk,d∈{0,1}: This parameter is equal 1 if technician k∈Kk∈K must depart from and return to depot d∈Dd∈D; and 0 otherwise.

pj∈R+pj∈R+; Processing time (duration) of job j∈Jj∈J.

τi,j∈R+τi,j∈R+: Travel time, in minutes, from location i∈Li∈L to location j∈Lj∈L.

Wk∈NWk∈N: Workload limit of technician k∈Kk∈K during the planning horizon. That is, the number of hours, in minutes, that the technician is available for the next work day.

πj∈{1,2,3,4}πj∈{1,2,3,4}: Priority weight of job j∈Jj∈J, a larger number means higher priority.

aj∈R+aj∈R+: Earliest time to start the service at location of job j∈Jj∈J.

bj∈R+bj∈R+: Latest time to start the service at location of job j∈Jj∈J.

ddj∈R+ddj∈R+: Due date of job j∈Jj∈J, i.e. the latest time to complete the service for job j∈Jj∈J.

M∈NM∈N: This is a very large number. This number is determined as follows: the planning horizon is of 10 working hours (i.e. 600 min). We want the value of MM to be an order of magnitude larger than the planning horizon. Therefore, we set M = 6100.

Decision Variables

xj,k∈{0,1}xj,k∈{0,1}: This variable is equal 1 if job j∈Jj∈J is assigned to technician k∈Kk∈K, and 0 otherwise.

uk∈{0,1}uk∈{0,1}: This variable is equal 1 if technician k∈Kk∈K is used to perform a job, and 0 otherwise.

yi,j,k∈{0,1}yi,j,k∈{0,1}: This variable is equal 1 if technician k∈Kk∈K travels from location i∈Li∈L to location j∈Lj∈L; and 0 otherwise.

tj≥0tj≥0: This variable determines the time to arrive or start the service at location j∈Jj∈J.

zj≥0zj≥0: This variable determines the lateness of completing job j∈Jj∈J.

xaj,xbj≥0xaj,xbj≥0: Correction to earliest and latest time to start the service for job j∈Jj∈J.

gjgj: This variable is equal 1 if job j∈Jj∈J cannot be filled, and 0 otherwise.

Objective Function

  • Minimize lateness:  The Objective function is to minimize the total weighted lateness of all the jobs.

∑j∈Jπj⋅zj+∑j∈J0.01⋅πj⋅M(xaj+xbj)+∑j∈Jπj⋅M⋅gj(0)(0)∑j∈Jπj⋅zj+∑j∈J0.01⋅πj⋅M(xaj+xbj)+∑j∈Jπj⋅M⋅gj

Note: We want to treat the constraints of filling the jobs demand and the constraints about starting the jobs within a time window as soft constraints. Soft constraints can be violated, but the violation will incur in a huge penalty. To consider that each job has different priority, we use the priority penalty for the calculation of the penalty associated with a violation of soft constraints. We assume that not filling jobs demand greatly deteriorate customer satisfaction, consequently should incur the largest penalties associated with the soft constraints. Recall that the value of the paramter MM is a large number, then the penalty associated with not filling a job is determined as follows: πj⋅Mπj⋅M. The time windows constraints violation also deteriorates customer satisfaction but to a lesser degree than the penalty associated with violating the time windows constraints. The time window constraints are determined as follows: 0.01⋅πj⋅M0.01⋅πj⋅M.

Constraints

  • Assign qualified technicians:  For each job, we assign one technician who is qualified for the job, or a gap is declared.

∑k∈K(j)xj,k+gj=1∀j∈J(1)(1)∑k∈K(j)xj,k+gj=1∀j∈J

Note: The penalty of the gap variable gjgj is (0.1⋅πj⋅M0.1⋅πj⋅M) which is a large number to discourage not being able to satisfy demand.

  • Only one technician:  For each job, we only allow one technician to be assigned.

∑k∈Kxj,k≤1∀j∈J(2)(2)∑k∈Kxj,k≤1∀j∈J

  • Technician capacity:  For each technician, we ensure that the available capacity of the technician is not exceeded.

∑j∈Jpj⋅xj,k+∑i∈L∑j∈Lτi,j⋅yi,j,k≤Wk⋅uk∀k∈K(3)(3)∑j∈Jpj⋅xj,k+∑i∈L∑j∈Lτi,j⋅yi,j,k≤Wk⋅uk∀k∈K

  • Technician tour:  For each technician and job, we ensure that if the technician is assigned to the job, then the technician must travel to another location (to form a tour).

∑j∈Lyi,j,k=xi,k∀i∈J,k∈K(4)(4)∑j∈Lyi,j,k=xi,k∀i∈J,k∈K

  • For each technician and job, we ensure that if a technician is assigned to the job, then the technician must travel from another location to the location of the job (to form a tour).

∑i∈Lyi,j,k=xj,k∀j∈J,k∈K(5)(5)∑i∈Lyi,j,k=xj,k∀j∈J,k∈K

  • Same depot:  For each technician and depot, we ensure that a technician, if assigned to any job, must depart from and return to the service center (depot) where the technician is based.

∑j∈Jyd,j,k=βk,d⋅uk∀k∈K,d∈D(6)(6)∑j∈Jyd,j,k=βk,d⋅uk∀k∈K,d∈D

∑i∈Jyi,d,k=βk,d⋅uk∀k∈K,d∈D(7)(7)∑i∈Jyi,d,k=βk,d⋅uk∀k∈K,d∈D

  • Temporal relationship:  For each location and job, we ensure the temporal relationship between two consecutive jobs served by the same technician. That is, if a technician kk travels from job ii to job jj, then the start of the service time at job jj must be no less than the completion time of job ii plus the travel time from job ii to job jj.

tj≥ti+pi+τi,j−M⋅(1−∑k∈Kyi,j,k)∀i∈L,j∈J(8)(8)tj≥ti+pi+τi,j−M⋅(1−∑k∈Kyi,j,k)∀i∈L,j∈J

Note: Observe that if the technician kk travels from the location of job ii to the location of job jj, then ∑k∈Kyi,j,k=1∑k∈Kyi,j,k=1. Therefore, M⋅(1−∑k∈Kyi,j,k)=0M⋅(1−∑k∈Kyi,j,k)=0, and the constraint tj≥ti+pi+τi,jtj≥ti+pi+τi,j would be properly enforced. Now consider the case where the technician kk does not travel from the location of job ii to the location of job jj. Hence, ∑k∈Kyi,j,k=0∑k∈Kyi,j,k=0 and M⋅(1−∑k∈Kyi,j,k)=MM⋅(1−∑k∈Kyi,j,k)=M. In this case, this constraint becomes tj≥ti+pi+τi,j−Mtj≥ti+pi+τi,j−M. But MM is a very large number, then ti+pi+τi,j−M<0ti+pi+τi,j−M<0 and since tj≥0tj≥0, this constraint is redundant.

  • Time window:  For each job j∈Jj∈J ensure that the time window for the job is satisfied.

tj≥aj−xaj∀j∈J(9)(9)tj≥aj−xaj∀j∈J

tj≤bj+xbj∀j∈J(10)(10)tj≤bj+xbj∀j∈J

Note: To discourage that the time window of a job is violated, we associate the penalty of (0.01⋅πj⋅M0.01⋅πj⋅M) to the correction variables xaj,xbjxaj,xbj.

  • Lateness constraint:  For each job j∈Jj∈J calculate the lateness of the job.

zj≥tj+pj−ddj∀j∈J(11)(11)zj≥tj+pj−ddj∀j∈J

  • Note that since the lateness decision variable zjzj is non-negative, there is no benefit to complete a job before its due date; on the other hand, since the objective function minimizes the total weighted lateness, Constraint (11) should always be binding.