Previous Article in Journal
Model to Implement Virtual Computing Labs via Cloud Computing Services

Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

# Modeling the 0-1 Knapsack Problem in Cargo Flow Adjustment

by
Boliang Lin
1,*,
Siqi Liu
1,
Ruixi Lin
2,
Jianping Wu
1,
Jiaxi Wang
1 and
Chang Liu
1
1
School of Traffic and Transportation, Beijing Jiaotong University, Beijing 100044, China
2
Department of Electrical Engineering, Stanford University, Stanford, CA 94305, USA
*
Author to whom correspondence should be addressed.
Symmetry 2017, 9(7), 118; https://doi.org/10.3390/sym9070118
Submission received: 18 May 2017 / Revised: 7 July 2017 / Accepted: 7 July 2017 / Published: 14 July 2017

## Abstract

:
China’s railway network is one of the largest railway networks in the world. By the end of 2016, the total length of railway in operation reached 124,000 km and the annual freight volume exceeded 3.3 billion tons. However, the structure of network does not completely match transportation demand, i.e., there still exist a few bottlenecks in the network, which forces some freight flows to travel along non-shortest paths. At present, due to the expansion of the high-speed railway network, more passengers will travel by electric multiple unit (EMU) trains running on the high-speed railway. Therefore, fewer passenger trains will move along the regular medium-speed lines, resulting in more spare capacity for freight trains. In this context, some shipments flowing on non-shortest paths can shift to shorter paths. And consequently, a combinatorial optimization problem concerning which origin-destination (O-D) pairs should be adjusted to their shortest paths will arise. To solve it, mathematical models are developed to adjust freight flows between their shortest paths and non-shortest paths based on the 0-1 knapsack problem. We also carry out computational experiments using the commercial software Gurobi and a greedy algorithm (GA), respectively. The results indicate that the proposed models are feasible and effective.

## 1. Introduction

China’s railway network is one of the largest railway networks in the world. By the end of 2016, the total length of railway in operation reached 124,000 km and the annual freight volume exceeded 3.3 billion tons. Typically, all the shipments travel along their pre-specified paths. However, these paths do not remain unchanged. In fact, they need to be adjusted in the following situations:
(1)
When new high-speed railways are built and a number of passenger flows are diverted to them. Hence, the regular medium-speed lines will have more spare capacity for freight trains.
(2)
When some existing lines are rebuilt for capacity expansion so that more shipments can flow on them.
(3)
When a new line shortening the distance between two nodes on the opposite sides of a circle is built.
(4)
When natural disasters happen or track maintenance is carried out, reducing the capacity of railway lines. For example, annual spring maintenance lasting for around 25 days is conducted on the Datong–Qinhuangdao railway, which is known as the most famous coal-transport corridor in China. During the period, the available service time of the line will decrease by 4 h each day, which translates into a decline of coal transportation of about 200,000 tons per day. In other words, there will be a decrease of 5 million tons in total for the whole maintenance period.
For the first three situations, namely, (1), (2) and (3), shipments flowing on the non-shortest paths should be diverted to their shortest paths; while in situation (4), a part of shipments should shift to longer paths. The freight flow adjustment problem arising in these cases can be formulated as a typical combinatorial optimization problem.
As for the cargo flow adjustment problem, most previous studies have been devoted to flow assignment models. Lin et al. [1] studied the problem of finding the feasible path set for each O-D pair in a railway network. Du and Ji [2] analyzed the marginal cost and benefit of diverting car flows from one railway to its parallel line by taking the Beijing–Guangzhou railway and Beijing–Kowloon railway as an example. Ye et al. [3] calculated the shortest path of a car flow and discussed the impact of the Xinyi–Changxing railway on flow adjustment. Su and Chen [4] presented a multi-objective 0-1 programming model and converted it into a single objective formulation. He successfully achieved the adjustment of freight flow between the Baoji–Zhongwei railway and the Baoji–Lanzhou railway. Tian et al. [5] studied the car flow distribution problem and adopted artificial arcs to deal with infeasible flows. Zhao et al. [6] investigated the freight empty car allocation problem with dynamic demands, and formulated a stage-based optimization model. To address the real-time traffic management problem and car scheduling problem, Corman et al. [7] developed a new tabu search scheme and designed a computational experiment based on practical size instances from a dispatching area of the Dutch railway network. Sadykov et al. [8] considered a variant of the freight railcar flow problem. They formulated the problem as a multi-commodity flow problem in a large space-time graph and proposed three approaches for the linear programming relaxation of the formulation. Borndörfer et al. [9] investigated the freight train routing problem from a strategic perspective, calculating the routes in a macroscopic transportation network of Deutsche Bahn AG. The above literature mainly focuses on freight flow path optimization from the perspective of the whole railway network. In fact, changes of structure or capacity often occur in partial network, so fine-tuning is valuable for rail operators. However, there is little work devoted to this issue. Many researchers have studied in-depth the problem of passenger flow assignment problem. Zhou et al. [10] analyzed the distribution characteristics of the components of travel time, and proposed an estimation method of the path-selecting proportion. Han et al. [11] established a stochastic user equilibrium model for solving the passenger flow assignment problem in a schedule-based rail transit network. Fu et al. [12] proposed a train stop scheduling approach combining a passenger flow assignment procedure. Nguyen et al. [13] presented a new graph theoretic framework for the passenger assignment problem that encompassed simultaneously the departure time and the route choice. Cominetti and Correa [14] analyzed a Wardrop equilibrium model for passenger assignment in general transit networks, including the effects of congestion over the passengers’ choices.
As this paper proposes an applicable method to adjust freight flows between parallel railways based on the 0-1 knapsack problem, some related studies should be noted for this problem. Pisinger [15] defined the classical knapsack problem and gave an overview of exact solution approaches. He also pointed out that the previous benchmark tests were limited to a few highly constructed instances, which did not show the full characteristics of the knapsack problem. Poirriez et al. [16] presented a new approach for solving the unbounded knapsack problem and proposed an efficient and robust hybrid algorithm. Frenkel et al. [17] studied the effect of free and direct products on the time complexity of knapsack-type problems in groups, which were the natural generalizations of the classic knapsack and related problems to arbitrary (non-commutative) groups. He showed that free products in certain sense preserve the time complexity of knapsack-type problems, while direct products may amplify it. Rooderkerk and Heerde [18] developed a robust approach to optimize retail assortments and proposed a novel, efficient and real-time heuristic for addressing this 0-1 knapsack problem. In the following sections, the knapsack problem and flow adjustment problem (FAP) are described in detail.

## 2. Knapsack Problem

#### 2.1. The Unbounded Knapsack Problem

As a typical non-deterministic polynomial-time hard (NP-hard) problem, the unbounded knapsack problem (UKP) is defined as follows: We are given a set of $n$ types $O = { o 1 , o 2 , ... , o n }$ of items without quantity restriction. Items of the same type share a common weight $w i$ and a common value $φ i$. The problem is to choose a subset of these items aiming to maximize their overall value, while their overall weight does not exceed a given capacity $c$. Without loss of generality, it should be assumed that all values and weights are positive, all weights are smaller than the capacity $c$, and the overall weight of all items exceeds $c$. The model of UKP problem can be formulated as follows:
$Maximize ∑ i = 1 n φ i x i ,$
$Subject to ∑ i = 1 n w i x i ≤ c ,$
$∀ x i ∈ Z + , 1 ≤ i ≤ n ,$
where $x i$ represents the number of items of type $o i$ included in the knapsack.

#### 2.2. The 0-1 Knapsack Problem

The 0-1 knapsack problem is one of the most extensively studied combinatorial optimization problems. The objective of this problem is to maximize the total value of items in the knapsack, and the constraint is to ensure the sum of the weights is less than or equal to the knapsack capacity. There is only one item of each type and only two options for each item, i.e., included in the knapsack or not. Each item cannot be put into the knapsack more than once or be partially included in the knapsack. Similar problems have arisen in other fields, e.g., information encryption, decision-making in engineering projects and cargo loading. The 0-1 knapsack problem can be formulated as follows:
$Maximize ∑ i = 1 n φ i y i ,$
$Subject to ∑ i = 1 n w i y i ≤ c ,$
$y i ∈ { 0 , 1 } , 1 ≤ i ≤ n ,$
where $y i$ denotes whether the item of type $o i$ is included in the knapsack.

## 3. Flow Adjustment Models Based on the 0-1 Knapsack Problem

To describe in detail the method of adjusting freight flows between parallel railways, we construct a simplified regional railway network consisting of 6 stations and 6 links, as shown in Figure 1. There are two paths from station 1 to station 6, i.e., path A: 1→2→5→6 and path B: 1→2→3→4→5→6; path A is the shorter one.
Let $F A$ be the set of all shipments traveling along path A, and $F B$ contains all shipments flowing on path B. We assume that $F A$ consists of shipments while $F B$ comprises $n$ shipments, so the two sets can be expressed by:
$F A = { f A 1 , f A 2 , ... , f A i , ... , f A m } ,$
$F B = { f B 1 , f B 2 , ... , f B j , ... , f B n } ,$
where $f A i$ is the numerical value of shipment $i$ traveling along path A, and $f B j$ denotes the numerical value of shipment $j$ flowing on path B.
Notations used in our models are described as Table 1.

#### 3.1. Models for Flow Adjustment from Non-Shortest Path to the Shortest Path

Let us assume that a high-speed railway was built along path A recently. In this context, some passenger flows will be gradually diverted from the regular medium-speed line to this new high-speed railway. Therefore, fewer passenger trains will travel along path A, resulting in more spare capacity for freight trains. Consequently, some shipments can be adjusted from path B to path A. If we regard the spare capacity of path A as a knapsack and the shipments on path B as different types of items, the flow adjustment problem is equivalent to a 0-1 knapsack problem. When we simply take the unit transportation cost of each freight flow into consideration, the FAP can be formulated as follows:
(FAP-1)
$Maximize ∑ k = 1 n λ f B k ( l B − l A ) x B → A k ,$
$Subject to ∑ k = 1 n f B k x B → A k ≤ Δ c ,$
$x B → A k ∈ { 0 , 1 } , 1 ≤ k ≤ n ,$
The objective function (9) seeks to maximize the overall cost savings. The constraint (10) ensures that the total volume of adjusted shipments is smaller than the spare capacity $Δ c$.
In model FAP-1, transportation time cost is not considered. In fact, the time sensitivities of different commodities are quite different, for example, bulk commodities (e.g., coal, ore and oil) are not sensitive to transportation time, whereas high-value commodities (e.g., industrial equipments and fresh foods) are very sensitive. Therefore, it is necessary for us to take into account the time cost of different shipments. In other words, parameters representing time cost should be introduced. The objective function can be re-formulated by:
$z = ∑ k = 1 n λ f B k ( l B − l A ) x B → A k + ∑ k = 1 n f B k θ B k ( l B − l A ) v x B → A k = ∑ k = 1 n f B k ( l B − l A ) ( λ + θ B k v ) x B → A k ,$
The second term in formula (12) denotes the overall time cost savings. For simplicity, the generalized unit transportation cost $μ B k$ is defined as follows:
$μ B k = λ + θ B k v ,$
In this manner, the modified flow adjustment model considering transportation time cost can be expressed below:
(FAP-2)
$Maximize ∑ k = 1 n μ B k f B k ( l B − l A ) x B → A k ,$
$Subject to ∑ k = 1 n f B k x B → A k ≤ Δ c ,$
$x B → A k ∈ { 0 , 1 } , 1 ≤ k ≤ n ,$
It should be noted that, although model FAP-1 is similar to model FAP-2, and function (9) can be converted to function (14) by simply replacing $λ$ with $μ B k$, there is an essential difference between these two models.

#### 3.2. Models for Flow Adjustment from the Shortest Path to Non-Shortest Path

In this section, we assume that the annual track maintenance is going to be conducted on path A. During this period, there will be a substantial reduction of freight capacity $Δ c ′$ of path A. As a result, some shipments should shift to the non-shortest path B. Without loss of generality, let us assume that the spare capacity of path B is larger than $Δ c ′$. Apparently, the essence of this problem is to divert a number of flows from path A to path B with the objective of minimizing the operation cost. Similarly, this kind of problem can be regarded as a variant of the 0-1 knapsack problem.
(FAP-3)
$Minimize ∑ k = 1 m λ f A k ( l B − l A ) x A → B k ,$
$Subject to ∑ k = 1 m f A k x A → B k ≥ Δ c ′ ,$
$x A → B k ∈ { 0 , 1 } , 1 ≤ k ≤ m ,$
Note that, constraint (10) is different from constraint (18) which ensures that the overall volume of adjusted flows is no smaller than the capacity reduction $Δ c ′$.
If we consider both time costs and transportation costs of different commodities, another modified flow adjustment model (FAP-4) can be expressed by:
(FAP-4)
$Minimize ∑ k = 1 m f A k ( l B − l A ) μ A k x A → B k ,$
$Subject to ∑ k = 1 m f A k x A → B k ≥ Δ c ′ ,$
$x A → B k ∈ { 0 , 1 } , 1 ≤ k ≤ m ,$
$μ A k = λ + θ A k v ,$
In model FAP-1 and FAP-3, we only consider the transportation cost, while in model FAP-2 and FAP-4, time cost is taken into account so as to produce a more practical flow adjustment plan.

## 4. Computational Experiments

In this section, numerical experiments are conducted to test the feasibility of models using the optimization software Gurobi. For comparison, a greedy algorithm, which is widely used in rail transportation practice, is implemented.

#### 4.1. Computational Experiments Based on Flow Adjustment Models

To test the feasibility and efficiency of our models, several computational experiments are designed.

#### 4.1.1. Computational Experiments for Model FAP-1 and FAP-2

We make the following assumptions: the spare freight capacity of path A is $Δ c = 20$ million tons per year; the length of path A is $l A = 726$ km and that of path B is $l B = 837$ km; the unit transportation cost is $λ = 0.1$ ¥/ton-km. There are 30 shipments (the volume is virtual) moving on path B, whose volume and generalized transportation cost $μ B k$ are shown in Table 2.
It should be noted that the largest flow volume is 2.8 million tons per year ($f B 11$), while the smallest is 110,000 tons per year ($f B 28$). And the average volume of these 30 shipments is approximately 1,198,000 tons per year. Similarly, the largest $μ B k$ is $μ B 19$ (0.15 ¥/ton-km), the smallest $μ B k$ is $μ B 17$ (0.107 ¥/ton-km). The average value of all $μ B k$ is about 0.129 ¥/ton-km.
Firstly, the model FAP-1 is tested on Gurobi 6 with the branch and bound algorithm. The optimal solution is as follows:
$x B → A 1 = x B → A 2 = x B → A 3 = x B → A 4 = x B → A 7 = x B → A 8 = x B → A 10 = x B → A 11 = x B → A 15 = x B → A 18 = x B → A 19 = x B → A 20 = x B → A 24 = x B → A 26 = x B → A 27 = 1 ,$
$x B → A 5 = x B → A 6 = x B → A 9 = x B → A 12 = x B → A 13 = x B → A 14 = x B → A 16 = x B → A 17 = x B → A 21 = x B → A 22 = x B → A 23 = x B → A 25 = x B → A 28 = x B → A 29 = x B → A 30 = 0 ,$
The result shows that 15 shipments should be adjusted from path B to path A, including:
${ f B 1 , f B 2 , f B 3 , f B 4 , f B 7 , f B 8 , f B 10 , f B 11 , f B 15 , f B 18 , f B 19 , f B 20 , f B 24 , f B 26 , f B 27 } ,$
For this case, the total volume of adjusted shipments is exactly equal to the spare capacity of path A and the annual transportation cost saving is million Chinese yuan (CNY).
Secondly, we test model FAP-2 and the result shows that 16 shipments should be adjusted from path B to path A, namely:
${ f B 1 , f B 3 , f B 4 , f B 9 , f B 10 , f B 11 , f B 12 , f B 15 , f B 16 , f B 18 , f B 19 , f B 22 , f B 23 , f B 24 , f B 27 , f B 30 } ,$
The total volume of these shipments is up to 19,990,000 tons and the cost savings reach 305,930,400 CNY.
Compared to the solution of model FAP-1, the adjusted flow volume of FAP-2 decreases by 10,000 tons. The major differences of these two solutions lie in that:
(1)
There are five shipments, e.g., ${ f B 2 , f B 7 , f B 8 , f B 20 , f B 26 }$, that should shift from path B to path A according to FAP-1, with an average volume of 1,038,000 tons per year. However, these flows are not adjusted based on FAP-2. Further analysis demonstrates that the average $μ B k$ of these five shipments is merely 0.116 ¥/ton-km (far lower than the overall average $μ B k$, 0.129 ¥/ton-km), which makes little contribution to cost savings.
(2)
On the contrary, there are six shipments, namely, ${ f B 9 , f B 12 , f B 16 , f B 22 , f B 23 , f B 30 }$, that are not included in the solution of FAP-1, partly due to their relatively low average volume (about 863,000 tons per year). However, these shipments should be adjusted according to FAP-2. The main reason is that the average $μ B k$ of these shipments is 0.136 ¥/ton-km (in excess of overall average $μ B k$), which generates significant influence on cost savings.
Note that FAP-1 and FAP-2 share 10 common shipments that should be adjusted, ${ f B 1 , f B 3 , f B 4 , f B 10 , f B 11 , f B 15 , f B 18 , f B 19 , f B 24 , f B 27 }$. The average volume of them is 1,481,000 tons per year, and the average $μ B k$ is about 0.140 ¥/ton-km.

#### 4.1.2. Computational Experiments for model FAP-3 and FAP-4

Likewise, we assume that the freight capacity reduction of path A during the maintenance period is $Δ c ′ = 200 , 000$ tons per day, while the spare capacity of path B is approximately 300,000 tons per day; parameters such as $l A$, $l B$ and $λ$ remain the same. There are 50 shipments on path A, whose volume and generalized transportation cost $μ B k$ are shown in Table 3.
In Table 3, the largest-volume shipment is $f A 18$ (7970 tons per day), while the smallest is $f A 26$ (3592 tons per day). The average volume of these 50 shipments is approximately 5796 tons per day. Similarly, the largest $μ A k$ is $μ A 47$ (0.159 ¥/ton-km), and the smallest $μ B k$ are $μ A 7$ and $μ A 40$ (0.100 ¥/ton-km). The average value of all $μ A k$ is about 0.128 ¥/ton-km.
Firstly, model FAP-3 is tested on Gurobi 6 using the branch and bound algorithm. The optimal solution is described as follows:
$x A → B 1 = x A → B 2 = x A → B 3 = x A → B 4 = x A → B 5 = x A → B 7 = x A → B 8 = x A → B 10 = x A → B 11 = x A → B 13 = x A → B 16 = x A → B 18 = x A → B 20 = x A → B 21 = x A → B 22 = x A → B 24 = x A → B 25 = x A → B 26 = x A → B 28 = x A → B 29 = x A → B 32 = x A → B 33 = x A → B 34 = x A → B 36 = x A → B 38 = x A → B 40 = x A → B 41 = x A → B 42 = x A → B 44 = x A → B 46 = x A → B 47 = x A → B 48 = x A → B 49 = x A → B 50 = 1 ,$
$x A → B 6 = x A → B 9 = x A → B 12 = x A → B 14 = x A → B 15 = x A → B 17 = x A → B 19 = x A → B 23 = x A → B 27 = x A → B 30 = x A → B 31 = x A → B 35 = x A → B 37 = x A → B 39 = x A → B 43 = x A → B 45 = 0 ,$
Clearly, there are 33 shipments that should be adjusted from path A to path B, including:
${ f B 1 , f B 2 , f B 4 , f B 5 , f B 6 , f B 8 , f B 10 , f B 12 , f B 13 , f B 14 , f B 16 , f B 18 , f B 19 , f B 21 , f B 24 , f B 26 , f B 27 , f B 28 , f B 29 , f B 30 , f B 31 , f B 33 , f B 35 , f B 36 , f B 38 , f B 39 , f B 40 , f B 41 ， f B 42 , f B 45 , f B 47 , f B 48 ， f B 50 } ,$
For this case, the total volume of adjusted shipments is exactly equal to the capacity reduction of path A and the operation cost increase is CNY.
Secondly, we test model FAP-4 whose result shows that 35 shipments should be adjusted from path A to path B, namely:
${ f A 1 , f A 3 , f A 4 , f A 6 , f A 7 , f A 8 , f A 9 , f A 10 , f A 12 , f A 14 , f A 15 , f A 17 , f A 19 , f A 20 , f A 21 , f A 23 , f A 25 , f A 26 , f A 28 , f A 30 , f A 31 , f A 32 , f A 33 , f A 35 , f A 36 , f A 37 , f A 38 , f A 39 , f A 40 , f A 42 , f A 43 , f A 44 , f A 45 , f A 48 , f A 50 } ,$
The total volume of these shipments is up to 200,095 tons, slightly exceeding the threshold value of 200,000 tons, and the operation cost increase reaches 2,564,796 CNY.
Compared to the solution of model FAP-3, the adjusted flow volume of FAP-4 rises by 95 tons. The major differences of these two solutions lie in that:
(1)
There are 10 shipments, e.g., ${ f A 2 , f A 5 , f A 13 , f A 16 , f A 18 , f A 24 , f A 27 , f A 29 , f A 41 , f A 47 }$, that should shift from path A to path B according to FAP-3, with an average volume of 6313.9 tons per day. However, these flows are not required to shift based on FAP-4. Further analysis indicates that the average $μ A k$ of these 10 shipments is 0.149 ¥/ton-km, which will significantly increase the operation cost if adjusted.
(2)
Twelve shipments are not included in the solution of FAP-3, but covered by that of FAP-4, namely, ${ f A 3 , f A 7 , f A 9 , f A 15 , f A 17 , f A 20 , f A 23 , f A 25 , f A 32 , f A 37 , f A 43 , f A 44 }$. The main reason is that the average $μ A k$ of these shipments is merely 0.122 ¥/ton-km, which has little impact on cost growth.
It should not be ignored that the solutions of FAP-3 and FAP-4 share 23 common shipments which are described in detail below:
${ f A 1 , f A 4 , f A 6 , f A 8 , f A 10 , f A 12 , f A 14 , f A 19 , f A 21 , f A 26 , f A 28 , f A 30 , f A 31 , f A 33 , f A 35 , f A 36 , f A 38 , f A 39 , f A 40 , f A 42 , f A 45 , f A 48 , f A 50 } ,$
The average volume of them is 5950.5 tons per day, and the average $μ A k$ is about 0.118 ¥/ton-km.

#### 4.2. Computational Experiments Based on the Greedy Algorithm

The greedy algorithm is a heuristic algorithm which makes the locally optimal choice at each stage aiming at finding a global optimum. In many problems, a greedy strategy does not in general produce an optimal solution, but may yield locally optimal solutions approximating a global optimal solution in a reasonable time. Greedy algorithms can produce optimal solutions on some mathematical problems which have following properties:
(1)
The greedy choice property.
We can make whatever choice seems best at the moment and then solve the sub-problems that arise later. The choice made by a greedy algorithm may depend on the choice made so far, but not on future choices or all the solutions to the sub-problem.
(2)
An optimal substructure.
A problem exhibits an optimal substructure if an optimal solution to the problem contains optimal solutions to the sub-problem.
Some literature which is closely related to greedy algorithms should be noted. Rao et al. [19] proposed an optimization algorithm, combining a greedy selection scheme, to produce solutions with succinct atomic representations for signal reconstruction problems. Davis and Impagliazzo [20] defined an abstract model that captured the intrinsic power and limitations of greedy algorithms for various graph optimization problems. Cerrone et al. [21] applied carousel greedy, an enhanced greedy algorithm which sought to overcome the traditional weaknesses of greedy approaches, to a variety of well-known problems in combinatorial optimization.

#### 4.2.1. Applying the Greedy Algorithm to Model FAP-1 and FAP-2

In rail transportation, the greedy algorithm is widely used and its flowchart is shown in Figure 2.
According to the flowchart previously mentioned, we adopt the greedy algorithm to adjust shipments from path B to path A. Based on the data in Table 2, the computational result (denoted as Solution GA-1) is expressed by:
${ f B 11 , f B 27 , f B 25 , f B 24 , f B 6 , f B 21 , f B 23 , f B 4 , f B 29 } ,$
We find that the total volume of these shipments is 19,930 thousand tons, decreasing by 70,000 tons compared with the optimal solution of FAP-1. Furthermore, there is a decline in cost savings of 777,000 CNY, 0.35% lower than the optimal solution.
The greedy strategy corresponding to FAP-2 is adjusting freight flows in the order of generalized transportation cost, i.e., from the highest cost to the lowest cost.
In this case, we apply greedy algorithm to the case with the data in Table 2 and the result (Solution GA-2) is described as follows:
${ f B 19 , f B 3 , f B 28 , f B 15 , f B 24 , f B 10 , f B 30 , f B 16 , f B 9 , f B 1 , f B 11 , f B 4 , f B 27 , f B 12 , f B 18 , f B 23 , f B 13 , f B 26 } ,$
The total volume of these shipments reaches 19,950,000 tons, achieving cost savings of 305,317,700 CNY. Compared with the optimal solution of model FAP-2, the total volume declines by 40,000 tons, and the cost savings decrease by 612,700 CNY, i.e., 0.2% lower than the optimal solution. Obviously, the solution of model FAP-2 is superior to Solution GA-2.

#### 4.2.2. Applying the Greedy Algorithm to Model FAP-3 and FAP-4

To obtain a heuristic solution of model FAP-3 the greedy algorithm is implemented to the data in Table 3, following the procedures which are slightly different from what described in Figure 2. The major difference in procedures lies in that once the overall volume of solution exceeds the threshold value (200,000 tons per day), the algorithm will terminate. In this manner, the result (denoted as Solution GA-3) is efficiently obtained and can be described by:
${ f A 18 , f A 44 , f A 46 , f A 29 , f A 4 , f A 39 , f A 28 , f A 5 , f A 33 , f A 8 , f A 45 , f A 12 , f A 23 , f A 2 , f A 13 , f A 27 , f A 36 , f A 10 , f A 11 , f A 35 , f A 40 , f A 1 , f A 24 , f A 48 , f A 19 , f A 43 , f A 9 , f A 6 , f A 16 , f A 17 } ,$
The total volume of these 30 shipments is up to 200,664 tons, rising by 664 tons compared with the optimal solution of FAP-3. Moreover, the operation cost growth after adjustment is 2,227,370.4 CNY, 0.332% larger than the optimal solution of FAP-3.
The greedy strategy corresponding to FAP-4 is adjusting freight flows in the reverse order of generalized transportation cost, i.e., from the lowest to the highest.
The result (Solution GA-4) is described as follows:
${ f A 40 , f A 7 , f A 1 , f A 19 , f A 33 , f A 50 , f A 3 , f A 15 , f A 8 , f A 4 , f A 9 , f A 12 , f A 14 , f A 35 , f A 36 , f A 43 , f A 42 , f A 17 , f A 31 , f A 30 , f A 32 , f A 10 , f A 48 , f A 23 , f A 45 , f A 38 , f A 6 , f A 26 , f A 13 , f A 21 , f A 39 , f A 20 , f A 44 , f A 28 , f A 25 } ,$
The total volume of these 35 shipments is up to 201,867 tons, rising by 1772 tons compared with the optimal solution of FAP-4. The operation cost growth of Solution GA-4 is 2,662,503.942 CNY, approximately 3.81% larger than that of the optimal solution of FAP-4.
To summarize, the proposed methods outperform the greedy algorithm in terms of the solution quality.

## 5. Conclusions

In this paper, we study in depth the railway cargo flow adjustment problem. This problem is involved with shipments adjustment between parallel paths when their freight capacity is changed. Inspired by the 0-1 knapsack problem, we develop mathematical models to address the problem. There are two situations that should be taken into account, i.e., adjusting flows from non-shortest path to the shortest path and the other way around. We respectively propose two models (a basic model and a modified model) for each situation. The objective functions of two basic models (FAP-1 and FAP-3) are to maximize cost savings and to minimize operation cost growth, respectively. With consideration of transportation time cost, basic models are then modified to be more reasonable and practical. To test the feasibility and effectiveness of FAP models, computational experiments are conducted by using Gurobi. The results show that these models can efficiently address the flow adjustment problem and produce satisfactory solutions. For comparison, the greedy algorithm widely used in rail transportation is also applied to the instances. Computational results illustrate that FAP models outperform the greedy algorithm in solution quality. For future research work, researchers can focus on efficient solution approaches for the flow adjustment problem when the freight capacities of several paths change simultaneously.

## Acknowledgments

This work was supported by the National Natural Science Foundation of China (Grant No. 51378056).

## Author Contributions

The authors contributed equally to this work.

## Conflicts of Interest

The authors declare no conflict of interest.

## References

1. Lin, B.L.; Zhu, S.N.; Chen, Z.S.; Peng, H. The 0-1 integer programming model for optimal car routing problem and algorithm for the available set in rail network. J. Chin. Railw. Soc. 1997, 19, 7–12. [Google Scholar] [CrossRef]
2. Du, H.Z.; Ji, L. Study of transportation structure adjustment between lines Jing-Jiu and Jing-Guang. J. Shanghai Jiaotong Univ. 2002, 36, 592–596. [Google Scholar]
3. Ye, Y.L.; He, J.; Li, L. Wagon flow organization optimization after building of Xin-Chang railway. J. Tongji Univ. 2003, 31, 1198–1200. [Google Scholar]
4. Su, S.H.; Chen, Z.Y. Studies on models and algorithms of optimizing train flow paths in railway network. J. Chin. Railw. Soc. 2008, 30, 29–34. [Google Scholar]
5. Tian, Y.M.; Lin, B.L.; Ji, L.J. Railway car flow distribution node-arc and arc-path models based on multi-commodity and virtual arc. J. Chin. Railw. Soc. 2011, 33, 7–12. [Google Scholar]
6. Zhao, C.; Yang, L.X.; Li, S.K. Allocating freight empty cars in railway networks with dynamic demands. Discret. Dyn. Nat. Soc. 2014, 2014, 1–12. [Google Scholar] [CrossRef]
7. Corman, F.; D’Ariano, A.; Pacciarelli, D.; Pranzo, M. A tabu search algorithm for rerouting trains during rail operations. Transp. Res. B-Meth. 2010, 44, 175–192. [Google Scholar] [CrossRef]
8. Sadykov, R.; Lazarev, A.A.; Shiryaev, V.; Stratonnikov, A. Solving a freight railcar flow problem arising in Russia. In Proceedings of the 13th Workshop on Algorithmic Approaches for Transportation Modelling, Optimization, and Systems, Sophia Antipolis, France, 5 September 2013; pp. 55–67. [Google Scholar]
9. Borndörfer, R.; Fügenschuh, A.; Klug, T.; Schang, T.; Schlechte, T.; Schülldorf, H. The Freight Train Routing Problem; Angewandte Mathematik und Optimierung Schriftenreihe: Berlin-Dahlem, Germany, 2014. [Google Scholar]
10. Zhou, F.; Shi, J.G.; Xu, R.H. Estimation method of path-selecting proportion for urban rail transit based on AFC data. Math. Prob. Eng. 2015, 2015, 1–9. [Google Scholar] [CrossRef]
11. Han, B.; Zhou, W.T.; Li, D.W.; Yin, H.D. Dynamic schedule-based assignment model for urban rail transit network with capacity constraints. Sci. World J. 2015, 2015, 1–12. [Google Scholar] [CrossRef] [PubMed]
12. Fu, H.L.; Sperry, B.R.; Nie, L. Operational impacts of using restricted passenger flow assignment in high-speed train stop scheduling problem. Math. Prob. Eng. 2013, 2013, 1–8. [Google Scholar] [CrossRef]
13. Nguyen, S.; Pallottino, S.; Malucelli, F. A modeling framework for passenger assignment on a transport network with timetables. Transp. Sci. 2001, 35, 238–249. [Google Scholar] [CrossRef]
14. Cominetti, R.; Correa, J. Common-lines and passenger assignment in congested transit networks. Transp. Sci. 2001, 35, 250–267. [Google Scholar] [CrossRef]
15. Pisinger, D. Where are the hard knapsack problems? Comput. Oper. Res. 2005, 32, 2271–2284. [Google Scholar] [CrossRef]
16. Poirriez, V.; Yanev, N.; Andonov, R. A hybrid algorithm for the unbounded knapsack problem. Discret. Optim. 2009, 6, 110–124. [Google Scholar] [CrossRef]
17. Frenkel, E.; Nikolaev, A.; Ushakov, A. Knapsack problems in products of groups. J. Symb. Comput. 2016, 74, 96–108. [Google Scholar] [CrossRef]
18. Rooderkerk, R.P.; Heerde, H.J. Robust optimization of the 0-1 knapsack problem: Balancing risk and return in assortment optimization. Eur. J. Oper. Res. 2016, 250, 842–854. [Google Scholar] [CrossRef]
19. Rao, N.; Shah, P.; Wright, S. Forward-backward greedy algorithms for atomic norm regularization. IEEE Trans. Signal Process. 2015, 63, 5798–5811. [Google Scholar] [CrossRef]
20. Davis, S.; Impagliazzo, R. Models of greedy algorithms for graph problems. Algorithmica 2009, 54, 269–317. [Google Scholar] [CrossRef]
21. Cerrone, C.; Cerulli, R.; Golden, B. Carousel greedy: A generalized greedy algorithm with applications in optimization. Comput. Oper. Res. 2017, 85, 97–112. [Google Scholar] [CrossRef]
Figure 1. A simplified railway network.
Figure 1. A simplified railway network.
Figure 2. Flowchart of the greedy algorithm.
Figure 2. Flowchart of the greedy algorithm.
Table 1. Notations and their representations.
Table 1. Notations and their representations.
ParametersRepresentation
$λ$Unit transportation cost.
$l A$Length of path A.
$l B$Length of path B.
$Δ c$Spare capacity of path A.
$Δ c ′$Capacity reduction of path A.
$μ A k$Generalized transportation cost.
$θ A k$Unit time cost of shipment $f A k$.
$θ B k$Unit time cost of shipment $f B k$.
$v$Average speed of freight trains.
Decision VariablesRepresentation
$x B → A k$decision variable. $x B → A k$ equals 1 if shipment $f B k$ is adjusted to path A; and 0 otherwise.
$x A → B k$ decision variable. $x A → B k$ equals 1 if shipment $f A k$ is adjusted to path B; and 0 otherwise.
Table 2. Shipments on path B.
Table 2. Shipments on path B.
No.NameVolume (103 Tons/Year)$μ B k$ (¥/Ton-km)
1$f B 1$12000.137
2$f B 2$12100.110
3$f B 3$4600.146
4$f B 4$17900.135
5$f B 5$6500.108
6$f B 6$23100.115
7$f B 7$15400.126
8$f B 8$17600.112
9$f B 9$2300.140
10$f B 10$12600.143
11$f B 11$28000.137
12$f B 12$1900.132
13$f B 13$2000.125
14$f B 14$6100.129
15$f B 15$9600.144
16$f B 16$15600.141
17$f B 17$7200.107
18$f B 18$6900.132
19$f B 19$7500.150
20$f B 20$3700.114
21$f B 21$22500.129
22$f B 22$6600.126
23$f B 23$19600.131
24$f B 24$23200.144
25$f B 25$25600.111
26$f B 26$3100.118
27$f B 27$25800.133
28$f B 28$1100.146
29$f B 29$13600.118
30$f B 30$5800.143
Table 3. Shipments on path A.
Table 3. Shipments on path A.
No.NameVolume (Tons/Day)$μ B k$ (¥/Ton-km)
1$f A 1$61130.103
2$f A 2$66770.158
3$f A 3$38120.107
4$f A 4$76970.110
5$f A 5$75720.153
6$f A 6$56070.126
7$f A 7$52790.100
8$f A 8$73410.109
9$f A 9$57490.111
10$f A 10$62560.123
11$f A 11$62450.145
12$f A 12$68740.114
13$f A 13$64940.130
14$f A 14$40280.115
15$f A 15$37820.109
16$f A 16$55190.148
17$f A 17$54910.120
18$f A 18$79700.152
19$f A 19$58740.104
20$f A 20$44370.132
21$f A 21$54820.130
22$f A 22$42920.146
23$f A 23$67710.125
24$f A 24$60280.154
25$f A 25$48700.138
26$f A 26$35920.128
27$f A 27$64710.143
28$f A 28$76170.135
29$f A 29$78680.150
30$f A 30$51350.122
31$f A 31$50470.121
32$f A 32$46110.123
33$f A 33$75620.104
34$f A 34$45670.152
35$f A 35$62230.116
36$f A 36$62870.118
37$f A 37$47220.145
38$f A 38$42530.126
39$f A 39$76880.130
40$f A 40$61530.100
41$f A 41$47230.146
42$f A 42$40470.119
43$f A 43$58010.119
44$f A 44$79090.134
45$f A 45$69310.125
46$f A 46$78980.146
47$f A 47$38170.159
48$f A 48$59580.124
49$f A 49$35930.148
50$f A 50$50960.106

## Share and Cite

MDPI and ACS Style

Lin, B.; Liu, S.; Lin, R.; Wu, J.; Wang, J.; Liu, C. Modeling the 0-1 Knapsack Problem in Cargo Flow Adjustment. Symmetry 2017, 9, 118. https://doi.org/10.3390/sym9070118

AMA Style

Lin B, Liu S, Lin R, Wu J, Wang J, Liu C. Modeling the 0-1 Knapsack Problem in Cargo Flow Adjustment. Symmetry. 2017; 9(7):118. https://doi.org/10.3390/sym9070118

Chicago/Turabian Style

Lin, Boliang, Siqi Liu, Ruixi Lin, Jianping Wu, Jiaxi Wang, and Chang Liu. 2017. "Modeling the 0-1 Knapsack Problem in Cargo Flow Adjustment" Symmetry 9, no. 7: 118. https://doi.org/10.3390/sym9070118

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.