# An Exact Algorithm for Bilevel 0-1 Knapsack Problems

Authors: Raid Mansi; Cláudio Alves; J. M. Valério de Carvalho; Saïd Hanafi
Journal: Mathematical Problems in Engineering
 (2012)

---

## Abstract

We propose a new exact method for solving bilevel 0-1 knapsack problems. A bilevel problem models a hierarchical decision process that involves two decision makers called the leader and the follower. In these processes, the leader takes his decision by considering explicitly the reaction of the follower. From an optimization standpoint, these are problems in which a subset of the variables
must be the optimal solution of another (parametric) optimization problem. These problems have various applications in the field of transportation and revenue management, for example. Our approach relies on different components. We describe a polynomial time procedure to solve the linear relaxation of the bilevel 0-1 knapsack problem. Using the information provided by the solutions generated by this procedure, we compute a feasible solution (and hence a lower bound) for the problem. This bound is used together with an upper bound to reduce the size of the original problem. The optimal integer solution of the original problem is computed using dynamic programming. We
report on computational experiments which are compared with the results achieved with other state-of-the-art approaches. The results attest the performance of our approach.


---

## Body

## 1. Introduction

Bilevel optimization problems were introduced for the first time in [1] in connection with the well-known Stackelberg game [2]. These problems are related to the decision making process conducted by two agents, each with his own individual objective, under a given hierarchical structure. The agent that is at the top of this hierarchy is called the leader. His distinctive feature in the process is that he knows which decision is taken by the other agent (called the follower). As a consequence, he can optimize his own objective by taking into account the decision of the follower.The bilevel 0-1 knapsack problem (BKP) that is addressed in this paper is defined in this context. It is a hierarchical optimization problem in which the set of feasible solutions depends on the set of optimal solutions of a parametric 0-1 knapsack problem. The BKP can be formulated as follows:(1.1)(BKP)max⁡x,yf1(x,y)=d1x+d2ys.t.x∈{0,1}n1,y∈Argmax{f2(y′)=cy′:a1x+a2y′≤b,y′∈{0,1}n2}.
The n1 decision variables related to the leader are denoted by x. The follower has n2 decision variables which are denoted by y. The objective functions of the leader and the follower are denoted, respectively, by f1(x,y) and f2(y). The weights of the variables x and y in the objective function of the leader are denoted by d1 and d2, respectively, while the vector c represents the coefficients of the follower variables in his own objective function. The vectors a1 and a2 are the set of coefficients related to the decision variables of the leader and the follower in the knapsack constraint of the follower, respectively. The capacity of this knapsack constraint is denoted by b. All the coefficients of the problem are assumed to be positive. The standard 0-1 knapsack problem is a special case of BKP. It is obtained from (1.1) by setting n1=0 and d2=c. As a consequence, the problem BKP is NP-hard.Different methods have been proposed in the literature for bilevel programming problems with and without integer variables [3, 4]. A recent survey on the contributions for solving bilevel programming problems can be found in [5]. Many of these methods focus on problems with continuous variables.The bilevel knapsack problem was addressed by Dempe and Richter [6], Plyasunov [7], and Brotcorne et al. [8], but only for the case where there is a single (continuous) variable for the leader and different binary variables for the follower. Note that, for these cases, there may be no optimal solution for the problem [4]. The branch-and-bound algorithm proposed by Moore and Bard in [9] and the method proposed by Brotcorne et al. in [10] can be adapted to solve the BKP addressed in this paper. At the end of the paper, we will compare our approach with the results obtained by these two algorithms.Here, we consider the case where all the variables of the problem are binary variables. We propose a new exact approach for this problem based on several intermediate procedures. A lower bound for the problem is computed by applying first a polynomial time algorithm to solve the linear relaxation of BKP. The solutions generated by this algorithm are then used to compute feasible solutions to BKP and hence to obtain a valid lower bound for the problem. Using this lower bound and a given upper bound, the size of the problem is reduced by applying fixing rules. Dynamic programming rules are applied afterwards to obtain the optimal solution of BKP.Bilevel programming problems have many applications on different fields including economics, engineering, the determination of pricing policies, production planning, transportation, and ecology. In [11], Dempe identified more than 80 references in the literature describing applications of bilevel problems. Other examples, namely, on the field of engineering are described in [12]. The BKP is a discrete bilevel problem that can be applied in many situations involving the interaction between two agents whose (binary) decisions are interrelated and with each one trying to optimize his own objective. Real applications of this problem can be found in revenue management, telecommunications, capacity allocation, and transportation, for example.An application in revenue management may involve an individual searching for the best investment plan for his capital. The investor has the choice between placing his funds directly on financial applications with a guaranteed rate of return, letting an intermediary company (a broker, e.g.) decide how to invest these funds, or dividing the funds between these two possibilities. The intermediary company cannot invest more than the amount provided by the individual and it will do so in order to maximize its own profit. For this purpose, the intermediary will buy shares, bonds, or other financial assets that will provide it a revenue. Part of this revenue will be given back to the individual as a return on investment. In turn, the individual will decide on the amount to invest by itself and the amount to give to the intermediary with the objective of maximizing his own profit. In BKP, the individual will be the leader, while the intermediary will be considered as the follower. The valueb in (1.1) represents the capital of the individual. The coefficients of a1 represent the amounts that the individual can invest by itself and which will provide him a guaranteed rate of return given by the vector d1. The alternative investment plans in which the intermediary company can invest, the revenue that these plans will provide to this company, and the revenue that will be paid back to the investor are represented in (1.1) by a2, c, and d2, respectively. In BKP, the decision of the leader has a direct impact on the knapsack constraint of the follower. In fact, the decision of the individual (the leader) will set the capacity of the knapsack and determine the total amount of money that the intermediary (the follower) will be allowed to invest.An alternative application of BKP occurs in telecommunications, and in particular in the problem of allocating bandwidth to different clients. An application in this area was addressed in [13] using an approach based on a bilevel programming problem with knapsack constraints. The BKP can be used in this context to model the interaction between a service provider and its competitors. The service provider can use its installed capacity to serve directly its clients, or it can grant capacity to another company that may use this capacity to route the demand of its own clients through the network of the service provider. The latter charges the company for this service, while the company will choose or not to reroute the traffic of its clients through the network of the service provider according to the offers of other competitors and so as to maximize its own profit. In this case, the leader is the service provider and the follower is the other company. The total capacity of the service provider is the coefficient b in (1.1). The price that is charged by the service provider is represented by d2, while the amount of traffic required by the clients is given by a1 and a2.The remainder of the paper is organized as follows. In Section2, we introduce different definitions and the notation that is used in the paper, and we describe the properties of BKP. In Section 3, we describe the details of our algorithm. We present our algorithm to solve the linear relaxation of BKP, the rules used to reduce the size of the problem, and the dynamic programming procedures developed to find the optimal solution of BKP. In Section 4, we report on computational results that illustrate the efficiency of our methods compared with the only available method from the literature [14]. Some final conclusions are drawn in Section 5.


## 2. The Bilevel 0-1 Knapsack Problem

### 2.1. Definitions

We introduce first the following standard definitions related to the bilevel 0-1 knapsack problem BKP described in the previous section:(i)
the relaxed feasible set:(2.1)S={(x,y)∈{0,1}n1+n2:a1x+a2y≤b};(ii)
the set of rational reactions of the follower for a fixedx:
(2.2)P(x)=Argmax{f2(y):a2y≤b-a1x,y∈{0,1}n2};(iii)
the Inducible Region (IR), that is, the space over which the leader optimizes:(2.3)IR={(x,y)∈S:y∈P(x)}.Using this notation, we can rewrite the BKP as follows.(2.4)(BKP)max⁡x,yf1(x,y)=d1x+d2ys.t.(x,y)∈IR.When several optimal solutions exist for the follower problem, the previous model is not sufficient to define the optimal value of the problem because, for a leader decision, the follower can have several equivalent solutions. In this case, the solutions of the BKP can be defined either optimistically or pessimistically for each fixed leader variable [15]. These approaches can be described as follows.(i) Optimistic
We assume that the leader can influence the decision of the follower in his favor. In this case, the problem to solve becomes(2.5)max⁡x{max⁡y{f1(x,y):y∈P(x)}(x,y)∈S},
and its optimal solution is called a weak solution.(ii) Pessimistic
The follower takes his decision independently of the interests of the leader. In this case, the problem to solve becomes(2.6)max⁡x{min⁡y{f1(x,y):y∈P(x)}(x,y)∈S},
and its optimal solution is called a strong solution.A detailed discussion of each approach can be found in [15]. The algorithms described in this paper can find both the strong and the weak solution of the problem. However, and for the sake of clearness, we will focus our presentation on the optimistic approach.


### 2.2. An Upper Bound for BKP

The linear relaxation of BKP obtained by removing all the integrality constraints does not provide a valid upper bound for the problem. Hence, we resort to an upper bound for bilevel programming problems provided by a relaxation of (1.1) called the high-point problem [9, 16]. The high point problem is obtained by removing the objective function of the follower and the integrality constraints. It is defined formally as follows:(2.7)(HBKP)max⁡x,yf1(x,y)=d1x+d2ys.t.a1x+a2y≤b,x∈[0,1],y∈[0,1].
The optimal solution of this relaxation can be computed using a classical procedure for the knapsack problem [17].


### 2.3. Computing a Feasible Solution for BKP

A feasible solution to BKP can be computed by solving a different optimization problem related to the follower problem as shown in the following proposition.Proposition 2.1.
Letz∈{0,…,b}. An optimal solution to the following problem denoted by FBKPz is also feasible for BKP:
(2.8)(FBKPz)max⁡x,yf(x,y)=d1x+cy(2.9)s.t.a1x=z,(2.10)a2y≤b-z,x∈{0,1}n1,y∈{0,1}n2.Proof.
As long asFBKPz admits a feasible solution, its optimal solution is feasible for the follower problem of BKP since the knapsack constraint of the follower is satisfied due to (2.9) and (2.10). This optimal solution is also optimal for the follower problem because it takes into account the follower objective function on the follower variables.An optimal solution(x*,y*) for BKP can then be defined using FBKPz as follows:(2.11)(x*,y*)∈Argmax{d1xz*+d2yz*:(xz*,yz*)isanoptimalsolutionofFBKPz,forz=0,…,b}.
Clearly, finding an optimal solution for BKP by solving FBKPz for each possible value of z is computationally expensive. To obtain a good feasible solution for BKP, in our algorithm, we solve the problem FBKPz for a set of good candidate values for z, which are obtained by solving the linear relaxation of BKP with the polynomial time procedure described in Section 3.1.


## 2.1. Definitions

We introduce first the following standard definitions related to the bilevel 0-1 knapsack problem BKP described in the previous section:(i)
the relaxed feasible set:(2.1)S={(x,y)∈{0,1}n1+n2:a1x+a2y≤b};(ii)
the set of rational reactions of the follower for a fixedx:
(2.2)P(x)=Argmax{f2(y):a2y≤b-a1x,y∈{0,1}n2};(iii)
the Inducible Region (IR), that is, the space over which the leader optimizes:(2.3)IR={(x,y)∈S:y∈P(x)}.Using this notation, we can rewrite the BKP as follows.(2.4)(BKP)max⁡x,yf1(x,y)=d1x+d2ys.t.(x,y)∈IR.When several optimal solutions exist for the follower problem, the previous model is not sufficient to define the optimal value of the problem because, for a leader decision, the follower can have several equivalent solutions. In this case, the solutions of the BKP can be defined either optimistically or pessimistically for each fixed leader variable [15]. These approaches can be described as follows.(i) Optimistic
We assume that the leader can influence the decision of the follower in his favor. In this case, the problem to solve becomes(2.5)max⁡x{max⁡y{f1(x,y):y∈P(x)}(x,y)∈S},
and its optimal solution is called a weak solution.(ii) Pessimistic
The follower takes his decision independently of the interests of the leader. In this case, the problem to solve becomes(2.6)max⁡x{min⁡y{f1(x,y):y∈P(x)}(x,y)∈S},
and its optimal solution is called a strong solution.A detailed discussion of each approach can be found in [15]. The algorithms described in this paper can find both the strong and the weak solution of the problem. However, and for the sake of clearness, we will focus our presentation on the optimistic approach.


## 2.2. An Upper Bound for BKP

The linear relaxation of BKP obtained by removing all the integrality constraints does not provide a valid upper bound for the problem. Hence, we resort to an upper bound for bilevel programming problems provided by a relaxation of (1.1) called the high-point problem [9, 16]. The high point problem is obtained by removing the objective function of the follower and the integrality constraints. It is defined formally as follows:(2.7)(HBKP)max⁡x,yf1(x,y)=d1x+d2ys.t.a1x+a2y≤b,x∈[0,1],y∈[0,1].
The optimal solution of this relaxation can be computed using a classical procedure for the knapsack problem [17].


## 2.3. Computing a Feasible Solution for BKP

A feasible solution to BKP can be computed by solving a different optimization problem related to the follower problem as shown in the following proposition.Proposition 2.1.
Letz∈{0,…,b}. An optimal solution to the following problem denoted by FBKPz is also feasible for BKP:
(2.8)(FBKPz)max⁡x,yf(x,y)=d1x+cy(2.9)s.t.a1x=z,(2.10)a2y≤b-z,x∈{0,1}n1,y∈{0,1}n2.Proof.
As long asFBKPz admits a feasible solution, its optimal solution is feasible for the follower problem of BKP since the knapsack constraint of the follower is satisfied due to (2.9) and (2.10). This optimal solution is also optimal for the follower problem because it takes into account the follower objective function on the follower variables.An optimal solution(x*,y*) for BKP can then be defined using FBKPz as follows:(2.11)(x*,y*)∈Argmax{d1xz*+d2yz*:(xz*,yz*)isanoptimalsolutionofFBKPz,forz=0,…,b}.
Clearly, finding an optimal solution for BKP by solving FBKPz for each possible value of z is computationally expensive. To obtain a good feasible solution for BKP, in our algorithm, we solve the problem FBKPz for a set of good candidate values for z, which are obtained by solving the linear relaxation of BKP with the polynomial time procedure described in Section 3.1.


## 3. An Exact Algorithm for BKP

Before we describe our exact algorithm for BKP, we define and discuss first its different components. Our algorithm relies on the computation of an upper and lower bound for BKP. The upper bound is computed by solving exactly the problem HBKP defined previously. The lower bound is obtained by solving first a linear relaxation of BKP using the polynomial time procedure described in Section3.1, and then by solving the problem FBKPz for different values of the parameter z. The values of z are associated to feasible solutions of the linear relaxation of BKP which are obtained by applying the polynomial procedure mentioned previously. The upper and lower bounds are used to fix variables of BKP to their optimal values (Section 3.2) and to further enhance the definition of the original problem so as to improve its resolution in the remaining steps (Section 3.3). The optimal value for the resulting problem is computed using dynamic programming. This value is then used to generate an optimal solution for BKP. The two phases of this dynamic programming procedure are described in Section 3.4. The outline of our exact algorithm is given in Section 3.5.


### 3.1. A Polynomial Time Solution Procedure for the Linear Relaxation of BKP

In this section, we show that the linear relaxation of BKP can be solved up to optimality in polynomial time, and we describe a procedure that computes this optimal solution. First, we recall the formal definition of this linear relaxation that will be denoted by CBKP (for continuous bilevel 0-1 knapsack problem):(3.1)(CBKP)max⁡x,yf1(x,y)=d1x+d2ys.t.0≤x≤1,y∈Argmax{f2(y′)=cy′:a1x+a2y′≤b,0≤y′≤1}.Now, we show that solving CBKP is equivalent to the resolution of the linear relaxation of a standard knapsack problem.Proposition 3.1.
Assume that the follower variablesy1,y2,…,yn2 are sorted in decreasing order of the relative value between their profit and their weight in the knapsack constraint, that is, such that c1/a12≥c2/a22≥⋯≥cn2/an22. If ci/ai2=cj/aj2, the order between the corresponding variables is determined according to the objective function of the leader, that is, di2/ai2≥dj2/aj2 (in the pessimistic case, one will consider di2/ai2≤dj2/aj2). Let x* be a decision of the leader. In this case, the total resource consumed by the leader in the knapsack constraint is given by a1x*. Furthermore, let k be defined such that b-a1x*∈[∑i=1kai2s,∑i=1k+1ai2[. The reaction of the follower related to the decision x* will be as follows:
(3.2)y1=1,y2=1,…,yk=1,yk+1=(b-a1x*-∑i=1kai2)ak+12,yk+2=0,…,yn2=0.Proof.
Indeed, for a given decisionx* of the leader, the problem CBKP becomes a standard 0-1 knapsack problem:
(3.3)(CBKPx*)y∈Argmax{f2(y)=cy′:a2y′≤b-a1x*,0≤y′≤1}.In Algorithm1, we describe a polynomial time procedure that generates a weak solution for CBKP. The algorithm is based on the same idea that is used to solve the standard 0-1 knapsack problem. We start by solving the knapsack problem associated to the leader variables and objective function:(3.4)x*∈Argmax{f1(x)=d1x:a1x≤b,0≤x≤1},
with x* being the optimal solution of this problem. Then, we solve the follower knapsack problem that results from the leader decision x*:(3.5)y*∈Argmax{f2(y)=cy:a2y≤b-a1x*,0≤y≤1},
with y* being the corresponding optimal solution. The algorithm enumerates all the nondominated feasible linear programming basic solutions starting by the solution (x*,y*). At each iteration, we move from a feasible basic solution to another by transferring the resources consumed by the leader to the follower. To clarify the procedure, we illustrate its execution in Example 3.2.Algorithm 1:A polynomial time solution procedure for CBKP.
Letdopt denote the optimal value of the leader objective function;Let(xopt,yopt) be an optimal solution of CBKP;InitializationSort the variablesx and y in decreasing order of the ratio dj1/aj1 for x and cj/aj2anddj2/aj2 for y;Letx1*=1,x2*=1,…,xk*=1,xk+1*=(b-∑i=1kai1)ak+11,xk+2*=0,…,xn1*=0be the optimal solution for the following problem:x*∈Argmax{f1(x)=d1x:a1x≤b,0≤x≤1};Lety1*=1,y2*=1,…,yt*=1,yt+1*=(b-a1x*-∑i=1tai2)at+12,yt+2*=0,…,yn2*=0be the optimal solution for the following problem:y*∈Argmax{f2(y)=cy:a2y≤b-a1x*,0≤y≤1};/*The indexesk+1andt+1  are respectively the indexes of the lastleader and follower variables with a positive value accordingto the ordering */Letdopt=d1x*+d2y*;i=k+1; j=t+1;while  (i>0) and (j<n2+1) doif(ai1xi*>aj2(1-yj*))  thenxi*=xi*-aj2(1-yj*)/ai1; yj*=1; j=j+1;endelse  if(ai1xi*<aj2(1-yj*))  thenxi*=0; yj*=yj*-ai1xi*/aj2; i=i-1;endelse  if(ai1xi*=aj2(1-yj*))  thenxi*=0; yj*=1; i=i-1; j=j+1;endif(dopt<d1x*+d2y*)  thendopt=d1x*+d2y*; (xopt,yopt)=(x*,y*);endendExample 3.2.
Consider the following continuous bilevel 0-1 knapsack problem denoted by CBKP1:
(3.6)(CBKP1)max⁡x,yf1(x,y)=3x1+2x2+7x3+5y1+y2+2y3+y4s.t.0≤x≤1,max⁡yf2(y)=2y1+2y2+3y3+4y4s.t.3x1+x2+2x3+y1+2y2+y3+4y4≤40≤y≤1.
We start by sorting the variables of the leader in decreasing order of the ratio dj1/aj1, which results in the sequence x3 (with d31/a31=7/2), x2 (with d21/a21=2/1), and x1 (with d11/a11=3/3). A similar ordering is applied to the variables of the follower resulting in the sequence y3 (with c3/a32=3/1), y1 (with c1/a12=2/1), y2 (with c2/a22=2/2), and y4 (with c4/a42=4/4). Note that y2 and y4 have the same ratio cj/aj2, but y2 with d22/a22=1/2 outperforms y4 with d42/a42=1/4. In this example, we are considering the optimistic case. In the first phase of the procedure, we solve the following problem:
(3.7)max⁡xf1(x)=3x1+2x2+7x3s.t.3x1+x2+2x3≤4,0≤x≤1.
The optimal solution of this problem is x3*=1, x2*=1, and x1*=1/3. The optimal reaction of the follower for this decision of the leader is y*=(0,0,0,0) and dopt=10. The solutions generated at each iteration of the Algorithm 1 are described as follows:(1)
x3*=1, x2*=1, x1*=1/3 and y3*=0, y1*=0, y2*=0, y4*=0 with dopt=10;(2)
x3*=1, x2*=1, x1*=0 and y3*=1, y1*=0, y2*=0, y4*=0 with dopt=11;(3)
x3*=1, x2*=0, x1*=0 and y3*=1, y1*=1, y2*=0, y4*=0 with dopt=14;(4)
x3*=0, x2*=0, x1*=0 and y3*=1, y1*=1, y2*=1, y4*=0 with dopt=8.The value dopt denotes the optimal value of the leader objective function as introduced in Algorithm 1. The optimal solution of CBKP1 is obtained at the third iteration. This solution is achieved after a polynomial number of steps.In Algorithm1, all the nondominated feasible basic solutions of CBKP are visited. For each one of these solutions, we can associate a value for the parameter z in FBKPz. In Example 3.2, the value of z is equal to 4, 3, 2, and 0 at the iterations 1 to 4, respectively. These values are equal to a1x0, with x0 being the value of the leader variables of a given basic solution generated in Algorithm 1. As shown in Section 2.3, we can obtain a feasible solution for BKP by solving the problem FBKPz using these values of z.A basic solution of CBKP has at most two fractional variables (one for the leader, and another for the follower). If a basic solution of CBKP is integer for both the leader and the follower variables, then this solution is feasible forFBKPz and for BKP too. If all the variables of the leader are integer, and only one variable of the follower is fractional, then we can fix the values of the leader variables in FBKPz and solve the resulting problem which becomes a single knapsack problem. In these two cases, it is always possible to find a feasible solution for FBKPz, and hence for BKP. However, when one of the leader variables is fractional, the problem FBKPz may be infeasible. This is due to the fact that we are considering that z∈{⌊a1x0⌋,⌊a1x0⌋+1}. Since there is no guarantee that the equation a1x=z in FBKPz has a solution, the corresponding problem FBKPz may be infeasible.Solving the problemFBKPz for a single value of the parameter z can be done efficiently using branch-and-bound, for example. Clearly, solving this problem for all the values of z in {0,…,b} is much more expensive computationally. In our algorithm, our approach to generate a good feasible solution for BKP consists in inspecting a restricted set of good candidate values for z. For this purpose, we choose the values of z that are associated to the n best solutions generated by Algorithm 1. In Example 3.2, if we set n=2, then the values of z associated to the two best solutions generated by Algorithm 1 (obtained at the iterations 2 and 3) will be used as a parameter in FBKPz. The problems that will be solved in this case are FBKP2 and FBKP3.The feasible solution (and corresponding lower bound) that is generated using this approach can be used together with the upper bound provided by HBKP to reduce the size of the original problem BKP. This can be done by fixing the values of some variables to their optimal values. The strategies used to reduce the size of the original BKP are described in the next section.


### 3.2. Reducing the Size of BKP Using Fixing Rules

A strategy to improve the resolution of 0-1 mixed integer programming problems which has been used extensively in the literature consists in fixing the values of some variables to their optimal value. Many authors [18–20] reported different procedures based on this idea to reduce the size of multidimensional knapsack problems. In this section, we show that it is also possible to apply fixing rules to BKP, and we describe the procedure that we used in our algorithm.In many cases, fixing variables to their optimal value can be done via inexpensive operations. In the sequel, we show how variables can be fixed using information on the upper and lower bounds for the problem.Proposition 3.3.
Letα∈{0,1} and LB be a lower bound for BKP. One will use the notation v(·) to indicate the optimal value of a given problem. The following fixing rules apply:(i)
for anyj∈{1,…,n1}, if v(HBKP∣xj=α)<LB, then xj can be fixed to the value 1-α;(ii)
for anyj∈{1,…,n2}, if v(HBKP∣yj=α)<LB, then yj can be fixed to the value 1-α.Proof.
Letv(BKP) be the optimal value for BKP, and let q denote both the variables x and y of the leader and follower, respectively. Note that v(BKP)=max{v(BKP∣qj=α),v(BKP∣qj=1-α)}. Therefore, if v(HBKP∣qj=α)<LB, then inevitably v(BKP)=v(BKP∣qj=1-α), and the optimal value qj* can be fixed to 1-α.These fixing rules depend only on an upper and a lower bound for the problem. The stronger the upper and lower bounds are, the more effective will be the rules for fixing the variables.To introduce a new fixing rule, we rewrite the problem HBKP (used to derive an upper bound for BKP) in its standard form as follows:(3.8)max⁡{d1x+d2y:a1x+a2y+s=b,e≥x≥0,e≥y≥0,s≥0},
where s corresponds to the vector of slack variables and e is the vector with all elements equal to 1. Let N1={1,…,n1} and N2={1,…,n2} be the indices of the leader and follower variables x and y, respectively.By reference to the LP basis that produces(x¯,y¯), we define ℬ={j∈N1:xj is basic}∪{j∈N2:yj is basic} and ℬ¯={j∈N1:xj is nonbasic}∪{j∈N2:yj is non-basic}. We subdivide ℬ¯ to identify the four subsets ℬ¯x0={j∈ℬ¯:x¯j=0}, ℬ¯y0={j∈ℬ¯:y¯j=0}, ℬ¯x1={j∈ℬ¯:x¯j=1}, and ℬ¯y1={j∈ℬ¯:y¯j=1}.Assume that(x¯,y¯) is an optimal basic solution of HBKP. The problem HBKP can be written in the optimal basis related to (x¯,y¯) in the following way:(3.9)max⁡v(HBKP)+∑j∈B¯x0d̂j1xj+∑j∈B¯y0d̂j2yj-∑j∈B¯x1d̂j1(1-xj)-∑j∈B¯y1d̂j2(1-yj)+l̂ss.t.â1x+â2y+t̂s=b̂,x∈[0,1]n1,y∈[0,1]n2,s≥0,
with v(HBKP) being the optimal value of HBKP, and (d̂1,d̂2,l̂) the vector of reduced costs corresponding to the variables (x,y,s) of the optimal basis. For a given lower bound LB for BKP, we have(3.10)v(HBKP)+∑j∈B¯x0d̂j1xj+∑j∈B¯y0d̂j2yj-∑j∈B¯x1d̂j1(1-xj)-∑j∈B¯y1d̂j2(1-yj)+l̂s≥LB.
The quantity l̂s is negative because of the negative reduced cost vector l̂ associated to the optimal basic solution, and the positive slack variables s. Moreover, since d̂j1≤0 for j∈ℬ¯x0 (resp., d̂j2≤0 for j∈ℬ¯y0), and d̂j1≥0 for j∈ℬ¯x1 (resp., d̂j2≥0 for j∈ℬ¯y1), we can consider the following cut based on the reduced costs:(3.11)∑j∈B¯x0d̂j1xj+∑j∈B¯y0d̂j2yj-∑j∈B¯x1d̂j1(1-xj)-∑j∈B¯y1d̂j2(1-yj)≤v(HBKP)-LB.
This inequality can be used to derive the fixing rule introduced in the next proposition.Proposition 3.4.
Ifx¯j (resp., y¯j) is a nonbasic variable, and |d̂j1|>v(HBKP)-LB (resp., |d̂j2|>v(HBKP)-LB), then at optimality one has xj*=x¯j (resp., yj*=y¯j).Proof.
The proof comes directly from the previous inequality (3.11).Applying these fixing rules is useful for reducing the size of the original problem BKP, and hence to improve its resolution. However, because they do not take into account the objective function of the follower, these rules may result in problems whose solutions are infeasible for the original BKP. The problem occurs when the leader has solutions with the same value than the optimal solution, but which are infeasible for the original BKP because they are not optimal for the follower. To clarify this issue, we apply these rules on the case described in Example3.2. The results are given in the following example.Example 3.5.
Consider the instance of BKP whose linear relaxation is given by CBKP1 in Example 3.2. We will denote this instance of BKP by BKP1. In Table 1, we describe an optimal solution (x¯,y¯) for the corresponding problem HBKP, and we report on the values of the associated vectors of reduced costs (d̂1,d̂2). Furthermore, we specify whether a given variable is a basic variable or not by reference to the solution (x¯,y¯), and we identify the variables that can be fixed according to the fixing rules described previously.
Let UB and LB denote, respectively, the value of an upper and lower bound for this instance of BKP. The value of the solution given in Table1 is 14, and hence we have UB = 14. By applying Algorithm 1, we obtain a lower bound of value LB = 14, as shown in Example 3.2. According to Proposition 3.4, since UB − LB = 0, all the nonbasic variables with an absolute reduced cost greater than 0 can be fixed, and hence we have x1*=0, x3*=1, y1*=1, y2*=0, and y4*=0. The variable x2 cannot be fixed because the absolute value of its reduced cost is not greater than UB − LB. Similarly, the variable y3 cannot be fixed because it is a basic variable. Applying the fixing rules leads to the following problem:(3.12)(BKP1)max⁡x,yf1(x,y)=2x2+2y3+12s.t.x2∈{0,1},max⁡yf2(y)=3y3s.t.x2+y3≤1,y3∈{0,1}.
The resulting problem has two equivalent solutions. The first one consists in the leader action x2=1 and the follower reaction y3=0. In this case, the complete solution (denoted by sol1) for the original problem is x1=0, and x2=1, x3=1 and y1=1, y2=0, y3=0, and y4=0. The second solution consists in the leader action x2=0 and the follower reaction y3=1. The complete solution for the original problem in this case (denoted by sol2) is x1=0, x2=0, and x3=1 and y1=1, y2=0, y3=1, and y4=0. The value of both sol1 and sol2 is equal to 14. However, the optimal solution of original problem BKP1 is given by sol2, since for the leader action x1=0, x2=0, and x3=1 the reaction of the follower y1=1, y2=0, y3=1, and y4=0 is optimal for the follower problem. On the contrary, sol1 is not feasible for the problem because for the leader action x1=0, x2=1, and x3=1, the follower reaction should not be y1=1, y2=0, y3=0, and y4=0 with the value 2 for the follower objective function. In this case, the follower reaction should be y1=0, y2=0, y3=1, and y4=0 with a corresponding value for the follower objective function that is equal to 3.Table 1
An optimal solution for HBKP (Example3.5).
x1x2x3y1y2y3y4(x¯,y¯)0011010(d̂1,d̂2)−3033−30−7Basic variablenononononoyesnoVariable can be fixedyesnoyesyesyesnoyesAs shown in Example3.5, the optimal solution of the problem can be found even when the fixing rules described in this section are applied. However, an additional treatment on the optimal solutions of the resulting problem is necessary to identify the solutions that are optimal for the follower problem (and hence feasible for the original problem BKP). To overcome this issue, in our algorithm, we fixed only the leader variables that are not directly influenced by the objective function of the follower.


### 3.3. Reducing the Interval of Values for the ParameterZ in FBKPZ

In this section, we show how to decrease the knapsack capacityb of the follower problem, and hence the size of the interval of possible values for z in FBKPz. Let lbz and ubz be the values of a lower and upper bound for z in the problem FBKPz. Initially, we have lbz=0 and ubz=b, and hence z∈[0,b]. The smaller the size of the interval [lbz,ubz] is, the easier the problem BKP will be to solve.To improve the values oflbz and ubz, we solve the following two linear programming problems (denoted by LBz and UBz) which relies on a lower bound LB for BKP. The optimal value of LBz leads to a feasible value for lbz, while UBz leads to a feasible value for ubz:(3.13)(LBz)min⁡zs.t.a1x=z,a2y≤b-z,d1x+d2y≥LB,x∈[0,1]n1,y∈[0,1]n2,z∈[0,b],(UBz)max⁡zs.t.a1x=z,a2y≤b-z,d1x+d2y≥LB,x∈[0,1]n1,y∈[0,1]n2,z∈[0,b].
Optimizing over the variable z with the additional constraint d1x+d2y≥LB in these two linear programs ensures that the resulting lower and upper bound for z will not cut the optimal solution of the original BKP. In the next section, we show how this new interval helps in improving the performance of the dynamic programming component of our algorithm for BKP.


### 3.4. Computing an Optimal Solution of BKP Using Dynamic Programming

In this section, we describe an approach based on dynamic programming to compute the optimal solution of BKP. The approach is divided into two phases. The first phase is a forward procedure whose objective is to find the value of an optimal solution for BKP. This forward phase divides in turn into two steps which are applied, respectively, to the leader variables and to the follower variables. The dynamic programming rules used for the follower variables are an extension of those used in [8]. In the second phase, a backtracking procedure is applied to generate a solution for the BKP with the value found in the forward phase. This dynamic programming algorithm has a pseudo-polynomial complexity, and it is able to solve both the optimistic and pessimistic cases mentioned previously. For the sake of brevity, we will focus our presentation on the optimistic case.


#### 3.4.1. Computing the Optimal Value of BKP: The Forward Phase

As alluded previously, the objective of the forward phase is to find the optimal value of BKP. This phase consists in two steps. The first step applies to the variables of the leader in BKP, and it considers only the objective function of the leader. The definition of this step relies on the interaction between the leader and the follower. For a given decisionx of the leader, the follower has to maximize his total profit cy using the corresponding residual capacity b-a1x. For each value of ϑ∈[0,b], the best action for the leader has to be determined: xϑ∈[0,b]∈Argmax{d1x:a1x=ϑ,x∈{0,1}n1}. Hence, the dynamic programming subproblem for the leader states as follows:(3.14)fk1(ϑ)=max⁡{∑j=1kdj1xj:∑j=1kaj1xj=ϑ,x∈{0,1}k},
with k∈N1.The dynamic programming procedure for the leader in this first step of the forward phase is described in Algorithm2. To illustrate the execution of this algorithm, we show in the following example how it applies to the instance of the BKP described in Example 3.2.Algorithm 2:Forward procedure for the leader.
f11(ϑ)=0 if ϑ=0, d11 if ϑ=a11, -∞ otherwise;for  k=2 to n1  dofor  ϑ=0 to b  doifϑ<ak1  thenfk1(ϑ)=fk-11(ϑ);endelsefk1(ϑ)=max(fk-11(ϑ),fk-11(ϑ-ak1)+dk1);endendendExample 3.6.
Let us recall first the definition of the instance BKP1:
(3.15)(BKP1)max⁡x,yf1(x,y)=3x1+2x2+7x3+5y1+y2+2y3+y4s.t.x∈{0,1}3,max⁡yf2(y)=2y1+2y2+3y3+4y4s.t.3x1+x2+2x3+y1+2y2+y3+4y4≤4,y∈{0,1}4.
The results of the first step of the forward phase applied to the leader variables of BKP1 are given in Table 2. In this table, we report on the optimal values of the associated subproblems at this step.
Note that the value off31(4) is smaller than f31(3) because there is no solution x with a better value which consumes exactly 4 units of capacity.Table 2
First step of the forward phase for the leader of BKP1.
k123ϑf11(ϑ)f21(ϑ)f31(ϑ)00001-∞222-∞-∞733394-∞55In the second step of the forward phase, we focus on the variables of the follower. The problem that is solved at this stage is the following:(3.16)max⁡yd2ys.t.y∈Argmax{f2(y′)=cy′:a2y′≤b,y′∈{0,1}n2}.
Let β=b-ϑ∈[0,b] denote the residual capacity associated with the leader action xϑ. In this second step, we consider both the leader and the follower objective functions, and we apply the forward procedure based on dynamic programming described in [8]. The objective is to determine all the reactions of the follower for a given action of the leader.Two tables are generated in the second step of the forward phase: one that stores the optimal values of the follower (fk2(β)), and a second one that stores the optimal values of the leader values (f̂k1(β)) with(3.17)fk2(β)=max⁡{∑j=1kcjyj:∑j=1kaj2yj≤β,y∈{0,1}k},f̂k1(β)=max⁡{∑j=1kdj2yj:y∈Argmax{fk2(β)}},
and k∈N2. To illustrate the execution of the forward procedure for the follower, we applied it to the instance BKP1 used in the previous examples. The results are reported in Example 3.7.Example 3.7.
The results after the second step of the forward phase are reported in Table3. This example shows that the values of the leader subproblems do not increase always because of the choice of the follower. For y3 (k=3) and β=1, the value for the leader decreases from 5 (for y2 and β=1) to 2. This new value is associated with d32=2 in order to satisfy the objective of the follower. Note that we applied the dynamic recurrence rules on the leader objective function for y2 (k=2) and β=2. The two values of the follower are equivalent: fy12(2)=fy12(0)+c2=2. In this case, the value for the leader is 5 because (f̂y11(2)=5)>(f̂y11(0)+d22=1).Table 3
Second step of the forward phase for the follower of BKP1.
k1234βf12(β)f̂11(β)f22(β)f̂21(β)f32(β)f̂31(β)f42(β)f̂41(β)00000000012525̲̲32̲̲322252̲5̲5757325465757425467878This dynamic programming approach can be improved by fixing some variables of the problem BKP to their optimal value, and by reducing the size of the interval[lbz,ubz] as discussed in the previous sections. Once this new interval has been computed, the first step of the forward phase can be applied with ϑ∈[0,ubz] instead of ϑ∈[0,b]. Since b≥ubz, this may reduce the number of steps of Algorithm 2. We do not apply this dynamic programming procedure up to the value of b, because there is no solution with a value better than LB for ϑ>ubz. Similarly, in the second step of the forward phase, we use the following interval for β: β∈[0,b-lbz].


#### 3.4.2. Generating an Optimal Solution for BKP: The Backtracking Phase

Let(x*,y*) be an optimal solution for BKP. The objective of the backtracking phase is to generate a solution (x*,y*) with a value that is equal to the value computed in the forward phase. Before we introduce the backtracking procedure, we define first the optimal value that is determined in the forward phase. The optimal solution can be defined using the following rule:(3.18)d1x*+d2y*=fn11(ϑ*)+f̂n21(b-ϑ*)=max⁡0≤ϑ≤b{fn11(ϑ)+f̂n21(b-ϑ)}.
The main idea is based on the fact that for each leader decision with ϑ resources consumed, the follower reaction has to be optimum for the remaining b-ϑ resources.From the valueϑ*, we apply the backtracking procedure on the leader variables described in Algorithm 3. For the follower variables, we apply the backtracking procedure described in [8] by taking into account both the leader and the follower objective functions, and starting with the value b-ϑ*.Algorithm 3:Backtracking procedure for the leader.
ϑ←ϑ*;for  k=n1 to 2 doiffk1(ϑ)=fk-11(ϑ-ak1)+dk1  thenxk*=1;ϑ←ϑ-ak1;endelsexk*=0;endendif  f11(ϑ)=0  then  x1*=0; else  x1*=1; endFor a givenk, if the follower has different equivalent choices, the value of yk* is determined according to the profit of the leader. Note that the variable yk* can take the value 0 or 1, if the two choices are equivalent for the leader and the follower. In Example 3.8, we illustrate the execution of the backtracking procedure on the instance BKP1 used in the previous examples.Example 3.8.
The optimal value for the problem BKP1 described in Example 3.2 is determined from Tables 2 and 3 as follows:
(3.19)max⁡0≤ϑ≤4{fn11(0)+f̂n21(4),fn11(1)+f̂n21(3),fn11(2)+f̂n21(2),fn11(3)+f̂n21(1),fn11(4)+f̂n21(0)}=14,
with ϑ*=2.
The results of the backtracking procedure for the follower and leader of BKP1 are given in Table 4. To determine the optimal action of the leader, we apply Algorithm 3 starting with ϑ*=2. The optimal action for the leader is x1*=0, x2*=0, and x3*=1. For the follower, we apply the backtracking procedure described in [8], starting from 4-ϑ*=2. The optimal reaction of the follower is y1*=1, y2*=0, y3*=1, and y4*=0.Table 4
Backtracking procedure for the follower and leader of BKP1.
k1234123ϑ/βf12(β)f̂11(β)f22(β)f̂21(β)f32(β)f̂31(β)f42(β)f̂41(β)f11(ϑ)f21(ϑ)f31(ϑ)000000000(0)(0)012(5)2(5)3232-∞22225255(7)5(7)-∞-∞(7)325465757339425467878-∞55


### 3.5. Outline of the Algorithm

The outline of our exact algorithm for BKP is given in Figure1. Each box in this figure corresponds to a step of our algorithm. The numbers identify the sequence by which the operations are performed.Figure 1
Outline of the algorithm.The algorithm starts by computing an upper bound for BKP through the exact resolution of HBKP. The next step consists in finding a good lower bound for BKP by computing a feasible solution for the problem. For this purpose, we solve first the problem CBKP using Algorithm1. As referred to in Section 3.1, each solution generated by Algorithm 1 can be associated to a value of the parameter z in FBKPz. From the set of solutions found by Algorithm 1, we select the n best solutions, and we solve the n problems FBKPz for the corresponding values of the parameter z.The upper and lower bounds (denoted, resp., by UB and LB in Figure1) obtained in the previous steps are used to fix the variables of the leader to their optimal values. This is done by applying the fixing rules discussed in Section 3.2. The resulting problem is called the reduced problem in Figure 1. The lower bound LB is then used to reduce the size of the interval of possible values for z. The new computed interval may help in reducing the number of steps of the dynamic programming procedures that are applied next. Similarly, the size of the reduced problem (i.e., solved with dynamic programming in the next step of the algorithm) is smaller than the original BKP, and hence, it is easier to solve using dynamic programming.The next step of our algorithm consists in applying the forward phase of the dynamic programming procedure to the reduced problem in order to compute the value of an optimal solution for BKP. Finally, from this optimal value, an optimal solution for BKP is generated using the backtracking procedure described in Section3.4.2.


## 3.1. A Polynomial Time Solution Procedure for the Linear Relaxation of BKP

In this section, we show that the linear relaxation of BKP can be solved up to optimality in polynomial time, and we describe a procedure that computes this optimal solution. First, we recall the formal definition of this linear relaxation that will be denoted by CBKP (for continuous bilevel 0-1 knapsack problem):(3.1)(CBKP)max⁡x,yf1(x,y)=d1x+d2ys.t.0≤x≤1,y∈Argmax{f2(y′)=cy′:a1x+a2y′≤b,0≤y′≤1}.Now, we show that solving CBKP is equivalent to the resolution of the linear relaxation of a standard knapsack problem.Proposition 3.1.
Assume that the follower variablesy1,y2,…,yn2 are sorted in decreasing order of the relative value between their profit and their weight in the knapsack constraint, that is, such that c1/a12≥c2/a22≥⋯≥cn2/an22. If ci/ai2=cj/aj2, the order between the corresponding variables is determined according to the objective function of the leader, that is, di2/ai2≥dj2/aj2 (in the pessimistic case, one will consider di2/ai2≤dj2/aj2). Let x* be a decision of the leader. In this case, the total resource consumed by the leader in the knapsack constraint is given by a1x*. Furthermore, let k be defined such that b-a1x*∈[∑i=1kai2s,∑i=1k+1ai2[. The reaction of the follower related to the decision x* will be as follows:
(3.2)y1=1,y2=1,…,yk=1,yk+1=(b-a1x*-∑i=1kai2)ak+12,yk+2=0,…,yn2=0.Proof.
Indeed, for a given decisionx* of the leader, the problem CBKP becomes a standard 0-1 knapsack problem:
(3.3)(CBKPx*)y∈Argmax{f2(y)=cy′:a2y′≤b-a1x*,0≤y′≤1}.In Algorithm1, we describe a polynomial time procedure that generates a weak solution for CBKP. The algorithm is based on the same idea that is used to solve the standard 0-1 knapsack problem. We start by solving the knapsack problem associated to the leader variables and objective function:(3.4)x*∈Argmax{f1(x)=d1x:a1x≤b,0≤x≤1},
with x* being the optimal solution of this problem. Then, we solve the follower knapsack problem that results from the leader decision x*:(3.5)y*∈Argmax{f2(y)=cy:a2y≤b-a1x*,0≤y≤1},
with y* being the corresponding optimal solution. The algorithm enumerates all the nondominated feasible linear programming basic solutions starting by the solution (x*,y*). At each iteration, we move from a feasible basic solution to another by transferring the resources consumed by the leader to the follower. To clarify the procedure, we illustrate its execution in Example 3.2.Algorithm 1:A polynomial time solution procedure for CBKP.
Letdopt denote the optimal value of the leader objective function;Let(xopt,yopt) be an optimal solution of CBKP;InitializationSort the variablesx and y in decreasing order of the ratio dj1/aj1 for x and cj/aj2anddj2/aj2 for y;Letx1*=1,x2*=1,…,xk*=1,xk+1*=(b-∑i=1kai1)ak+11,xk+2*=0,…,xn1*=0be the optimal solution for the following problem:x*∈Argmax{f1(x)=d1x:a1x≤b,0≤x≤1};Lety1*=1,y2*=1,…,yt*=1,yt+1*=(b-a1x*-∑i=1tai2)at+12,yt+2*=0,…,yn2*=0be the optimal solution for the following problem:y*∈Argmax{f2(y)=cy:a2y≤b-a1x*,0≤y≤1};/*The indexesk+1andt+1  are respectively the indexes of the lastleader and follower variables with a positive value accordingto the ordering */Letdopt=d1x*+d2y*;i=k+1; j=t+1;while  (i>0) and (j<n2+1) doif(ai1xi*>aj2(1-yj*))  thenxi*=xi*-aj2(1-yj*)/ai1; yj*=1; j=j+1;endelse  if(ai1xi*<aj2(1-yj*))  thenxi*=0; yj*=yj*-ai1xi*/aj2; i=i-1;endelse  if(ai1xi*=aj2(1-yj*))  thenxi*=0; yj*=1; i=i-1; j=j+1;endif(dopt<d1x*+d2y*)  thendopt=d1x*+d2y*; (xopt,yopt)=(x*,y*);endendExample 3.2.
Consider the following continuous bilevel 0-1 knapsack problem denoted by CBKP1:
(3.6)(CBKP1)max⁡x,yf1(x,y)=3x1+2x2+7x3+5y1+y2+2y3+y4s.t.0≤x≤1,max⁡yf2(y)=2y1+2y2+3y3+4y4s.t.3x1+x2+2x3+y1+2y2+y3+4y4≤40≤y≤1.
We start by sorting the variables of the leader in decreasing order of the ratio dj1/aj1, which results in the sequence x3 (with d31/a31=7/2), x2 (with d21/a21=2/1), and x1 (with d11/a11=3/3). A similar ordering is applied to the variables of the follower resulting in the sequence y3 (with c3/a32=3/1), y1 (with c1/a12=2/1), y2 (with c2/a22=2/2), and y4 (with c4/a42=4/4). Note that y2 and y4 have the same ratio cj/aj2, but y2 with d22/a22=1/2 outperforms y4 with d42/a42=1/4. In this example, we are considering the optimistic case. In the first phase of the procedure, we solve the following problem:
(3.7)max⁡xf1(x)=3x1+2x2+7x3s.t.3x1+x2+2x3≤4,0≤x≤1.
The optimal solution of this problem is x3*=1, x2*=1, and x1*=1/3. The optimal reaction of the follower for this decision of the leader is y*=(0,0,0,0) and dopt=10. The solutions generated at each iteration of the Algorithm 1 are described as follows:(1)
x3*=1, x2*=1, x1*=1/3 and y3*=0, y1*=0, y2*=0, y4*=0 with dopt=10;(2)
x3*=1, x2*=1, x1*=0 and y3*=1, y1*=0, y2*=0, y4*=0 with dopt=11;(3)
x3*=1, x2*=0, x1*=0 and y3*=1, y1*=1, y2*=0, y4*=0 with dopt=14;(4)
x3*=0, x2*=0, x1*=0 and y3*=1, y1*=1, y2*=1, y4*=0 with dopt=8.The value dopt denotes the optimal value of the leader objective function as introduced in Algorithm 1. The optimal solution of CBKP1 is obtained at the third iteration. This solution is achieved after a polynomial number of steps.In Algorithm1, all the nondominated feasible basic solutions of CBKP are visited. For each one of these solutions, we can associate a value for the parameter z in FBKPz. In Example 3.2, the value of z is equal to 4, 3, 2, and 0 at the iterations 1 to 4, respectively. These values are equal to a1x0, with x0 being the value of the leader variables of a given basic solution generated in Algorithm 1. As shown in Section 2.3, we can obtain a feasible solution for BKP by solving the problem FBKPz using these values of z.A basic solution of CBKP has at most two fractional variables (one for the leader, and another for the follower). If a basic solution of CBKP is integer for both the leader and the follower variables, then this solution is feasible forFBKPz and for BKP too. If all the variables of the leader are integer, and only one variable of the follower is fractional, then we can fix the values of the leader variables in FBKPz and solve the resulting problem which becomes a single knapsack problem. In these two cases, it is always possible to find a feasible solution for FBKPz, and hence for BKP. However, when one of the leader variables is fractional, the problem FBKPz may be infeasible. This is due to the fact that we are considering that z∈{⌊a1x0⌋,⌊a1x0⌋+1}. Since there is no guarantee that the equation a1x=z in FBKPz has a solution, the corresponding problem FBKPz may be infeasible.Solving the problemFBKPz for a single value of the parameter z can be done efficiently using branch-and-bound, for example. Clearly, solving this problem for all the values of z in {0,…,b} is much more expensive computationally. In our algorithm, our approach to generate a good feasible solution for BKP consists in inspecting a restricted set of good candidate values for z. For this purpose, we choose the values of z that are associated to the n best solutions generated by Algorithm 1. In Example 3.2, if we set n=2, then the values of z associated to the two best solutions generated by Algorithm 1 (obtained at the iterations 2 and 3) will be used as a parameter in FBKPz. The problems that will be solved in this case are FBKP2 and FBKP3.The feasible solution (and corresponding lower bound) that is generated using this approach can be used together with the upper bound provided by HBKP to reduce the size of the original problem BKP. This can be done by fixing the values of some variables to their optimal values. The strategies used to reduce the size of the original BKP are described in the next section.


## 3.2. Reducing the Size of BKP Using Fixing Rules

A strategy to improve the resolution of 0-1 mixed integer programming problems which has been used extensively in the literature consists in fixing the values of some variables to their optimal value. Many authors [18–20] reported different procedures based on this idea to reduce the size of multidimensional knapsack problems. In this section, we show that it is also possible to apply fixing rules to BKP, and we describe the procedure that we used in our algorithm.In many cases, fixing variables to their optimal value can be done via inexpensive operations. In the sequel, we show how variables can be fixed using information on the upper and lower bounds for the problem.Proposition 3.3.
Letα∈{0,1} and LB be a lower bound for BKP. One will use the notation v(·) to indicate the optimal value of a given problem. The following fixing rules apply:(i)
for anyj∈{1,…,n1}, if v(HBKP∣xj=α)<LB, then xj can be fixed to the value 1-α;(ii)
for anyj∈{1,…,n2}, if v(HBKP∣yj=α)<LB, then yj can be fixed to the value 1-α.Proof.
Letv(BKP) be the optimal value for BKP, and let q denote both the variables x and y of the leader and follower, respectively. Note that v(BKP)=max{v(BKP∣qj=α),v(BKP∣qj=1-α)}. Therefore, if v(HBKP∣qj=α)<LB, then inevitably v(BKP)=v(BKP∣qj=1-α), and the optimal value qj* can be fixed to 1-α.These fixing rules depend only on an upper and a lower bound for the problem. The stronger the upper and lower bounds are, the more effective will be the rules for fixing the variables.To introduce a new fixing rule, we rewrite the problem HBKP (used to derive an upper bound for BKP) in its standard form as follows:(3.8)max⁡{d1x+d2y:a1x+a2y+s=b,e≥x≥0,e≥y≥0,s≥0},
where s corresponds to the vector of slack variables and e is the vector with all elements equal to 1. Let N1={1,…,n1} and N2={1,…,n2} be the indices of the leader and follower variables x and y, respectively.By reference to the LP basis that produces(x¯,y¯), we define ℬ={j∈N1:xj is basic}∪{j∈N2:yj is basic} and ℬ¯={j∈N1:xj is nonbasic}∪{j∈N2:yj is non-basic}. We subdivide ℬ¯ to identify the four subsets ℬ¯x0={j∈ℬ¯:x¯j=0}, ℬ¯y0={j∈ℬ¯:y¯j=0}, ℬ¯x1={j∈ℬ¯:x¯j=1}, and ℬ¯y1={j∈ℬ¯:y¯j=1}.Assume that(x¯,y¯) is an optimal basic solution of HBKP. The problem HBKP can be written in the optimal basis related to (x¯,y¯) in the following way:(3.9)max⁡v(HBKP)+∑j∈B¯x0d̂j1xj+∑j∈B¯y0d̂j2yj-∑j∈B¯x1d̂j1(1-xj)-∑j∈B¯y1d̂j2(1-yj)+l̂ss.t.â1x+â2y+t̂s=b̂,x∈[0,1]n1,y∈[0,1]n2,s≥0,
with v(HBKP) being the optimal value of HBKP, and (d̂1,d̂2,l̂) the vector of reduced costs corresponding to the variables (x,y,s) of the optimal basis. For a given lower bound LB for BKP, we have(3.10)v(HBKP)+∑j∈B¯x0d̂j1xj+∑j∈B¯y0d̂j2yj-∑j∈B¯x1d̂j1(1-xj)-∑j∈B¯y1d̂j2(1-yj)+l̂s≥LB.
The quantity l̂s is negative because of the negative reduced cost vector l̂ associated to the optimal basic solution, and the positive slack variables s. Moreover, since d̂j1≤0 for j∈ℬ¯x0 (resp., d̂j2≤0 for j∈ℬ¯y0), and d̂j1≥0 for j∈ℬ¯x1 (resp., d̂j2≥0 for j∈ℬ¯y1), we can consider the following cut based on the reduced costs:(3.11)∑j∈B¯x0d̂j1xj+∑j∈B¯y0d̂j2yj-∑j∈B¯x1d̂j1(1-xj)-∑j∈B¯y1d̂j2(1-yj)≤v(HBKP)-LB.
This inequality can be used to derive the fixing rule introduced in the next proposition.Proposition 3.4.
Ifx¯j (resp., y¯j) is a nonbasic variable, and |d̂j1|>v(HBKP)-LB (resp., |d̂j2|>v(HBKP)-LB), then at optimality one has xj*=x¯j (resp., yj*=y¯j).Proof.
The proof comes directly from the previous inequality (3.11).Applying these fixing rules is useful for reducing the size of the original problem BKP, and hence to improve its resolution. However, because they do not take into account the objective function of the follower, these rules may result in problems whose solutions are infeasible for the original BKP. The problem occurs when the leader has solutions with the same value than the optimal solution, but which are infeasible for the original BKP because they are not optimal for the follower. To clarify this issue, we apply these rules on the case described in Example3.2. The results are given in the following example.Example 3.5.
Consider the instance of BKP whose linear relaxation is given by CBKP1 in Example 3.2. We will denote this instance of BKP by BKP1. In Table 1, we describe an optimal solution (x¯,y¯) for the corresponding problem HBKP, and we report on the values of the associated vectors of reduced costs (d̂1,d̂2). Furthermore, we specify whether a given variable is a basic variable or not by reference to the solution (x¯,y¯), and we identify the variables that can be fixed according to the fixing rules described previously.
Let UB and LB denote, respectively, the value of an upper and lower bound for this instance of BKP. The value of the solution given in Table1 is 14, and hence we have UB = 14. By applying Algorithm 1, we obtain a lower bound of value LB = 14, as shown in Example 3.2. According to Proposition 3.4, since UB − LB = 0, all the nonbasic variables with an absolute reduced cost greater than 0 can be fixed, and hence we have x1*=0, x3*=1, y1*=1, y2*=0, and y4*=0. The variable x2 cannot be fixed because the absolute value of its reduced cost is not greater than UB − LB. Similarly, the variable y3 cannot be fixed because it is a basic variable. Applying the fixing rules leads to the following problem:(3.12)(BKP1)max⁡x,yf1(x,y)=2x2+2y3+12s.t.x2∈{0,1},max⁡yf2(y)=3y3s.t.x2+y3≤1,y3∈{0,1}.
The resulting problem has two equivalent solutions. The first one consists in the leader action x2=1 and the follower reaction y3=0. In this case, the complete solution (denoted by sol1) for the original problem is x1=0, and x2=1, x3=1 and y1=1, y2=0, y3=0, and y4=0. The second solution consists in the leader action x2=0 and the follower reaction y3=1. The complete solution for the original problem in this case (denoted by sol2) is x1=0, x2=0, and x3=1 and y1=1, y2=0, y3=1, and y4=0. The value of both sol1 and sol2 is equal to 14. However, the optimal solution of original problem BKP1 is given by sol2, since for the leader action x1=0, x2=0, and x3=1 the reaction of the follower y1=1, y2=0, y3=1, and y4=0 is optimal for the follower problem. On the contrary, sol1 is not feasible for the problem because for the leader action x1=0, x2=1, and x3=1, the follower reaction should not be y1=1, y2=0, y3=0, and y4=0 with the value 2 for the follower objective function. In this case, the follower reaction should be y1=0, y2=0, y3=1, and y4=0 with a corresponding value for the follower objective function that is equal to 3.Table 1
An optimal solution for HBKP (Example3.5).
x1x2x3y1y2y3y4(x¯,y¯)0011010(d̂1,d̂2)−3033−30−7Basic variablenononononoyesnoVariable can be fixedyesnoyesyesyesnoyesAs shown in Example3.5, the optimal solution of the problem can be found even when the fixing rules described in this section are applied. However, an additional treatment on the optimal solutions of the resulting problem is necessary to identify the solutions that are optimal for the follower problem (and hence feasible for the original problem BKP). To overcome this issue, in our algorithm, we fixed only the leader variables that are not directly influenced by the objective function of the follower.


## 3.3. Reducing the Interval of Values for the ParameterZ in FBKPZ

In this section, we show how to decrease the knapsack capacityb of the follower problem, and hence the size of the interval of possible values for z in FBKPz. Let lbz and ubz be the values of a lower and upper bound for z in the problem FBKPz. Initially, we have lbz=0 and ubz=b, and hence z∈[0,b]. The smaller the size of the interval [lbz,ubz] is, the easier the problem BKP will be to solve.To improve the values oflbz and ubz, we solve the following two linear programming problems (denoted by LBz and UBz) which relies on a lower bound LB for BKP. The optimal value of LBz leads to a feasible value for lbz, while UBz leads to a feasible value for ubz:(3.13)(LBz)min⁡zs.t.a1x=z,a2y≤b-z,d1x+d2y≥LB,x∈[0,1]n1,y∈[0,1]n2,z∈[0,b],(UBz)max⁡zs.t.a1x=z,a2y≤b-z,d1x+d2y≥LB,x∈[0,1]n1,y∈[0,1]n2,z∈[0,b].
Optimizing over the variable z with the additional constraint d1x+d2y≥LB in these two linear programs ensures that the resulting lower and upper bound for z will not cut the optimal solution of the original BKP. In the next section, we show how this new interval helps in improving the performance of the dynamic programming component of our algorithm for BKP.


## 3.4. Computing an Optimal Solution of BKP Using Dynamic Programming

In this section, we describe an approach based on dynamic programming to compute the optimal solution of BKP. The approach is divided into two phases. The first phase is a forward procedure whose objective is to find the value of an optimal solution for BKP. This forward phase divides in turn into two steps which are applied, respectively, to the leader variables and to the follower variables. The dynamic programming rules used for the follower variables are an extension of those used in [8]. In the second phase, a backtracking procedure is applied to generate a solution for the BKP with the value found in the forward phase. This dynamic programming algorithm has a pseudo-polynomial complexity, and it is able to solve both the optimistic and pessimistic cases mentioned previously. For the sake of brevity, we will focus our presentation on the optimistic case.


### 3.4.1. Computing the Optimal Value of BKP: The Forward Phase

As alluded previously, the objective of the forward phase is to find the optimal value of BKP. This phase consists in two steps. The first step applies to the variables of the leader in BKP, and it considers only the objective function of the leader. The definition of this step relies on the interaction between the leader and the follower. For a given decisionx of the leader, the follower has to maximize his total profit cy using the corresponding residual capacity b-a1x. For each value of ϑ∈[0,b], the best action for the leader has to be determined: xϑ∈[0,b]∈Argmax{d1x:a1x=ϑ,x∈{0,1}n1}. Hence, the dynamic programming subproblem for the leader states as follows:(3.14)fk1(ϑ)=max⁡{∑j=1kdj1xj:∑j=1kaj1xj=ϑ,x∈{0,1}k},
with k∈N1.The dynamic programming procedure for the leader in this first step of the forward phase is described in Algorithm2. To illustrate the execution of this algorithm, we show in the following example how it applies to the instance of the BKP described in Example 3.2.Algorithm 2:Forward procedure for the leader.
f11(ϑ)=0 if ϑ=0, d11 if ϑ=a11, -∞ otherwise;for  k=2 to n1  dofor  ϑ=0 to b  doifϑ<ak1  thenfk1(ϑ)=fk-11(ϑ);endelsefk1(ϑ)=max(fk-11(ϑ),fk-11(ϑ-ak1)+dk1);endendendExample 3.6.
Let us recall first the definition of the instance BKP1:
(3.15)(BKP1)max⁡x,yf1(x,y)=3x1+2x2+7x3+5y1+y2+2y3+y4s.t.x∈{0,1}3,max⁡yf2(y)=2y1+2y2+3y3+4y4s.t.3x1+x2+2x3+y1+2y2+y3+4y4≤4,y∈{0,1}4.
The results of the first step of the forward phase applied to the leader variables of BKP1 are given in Table 2. In this table, we report on the optimal values of the associated subproblems at this step.
Note that the value off31(4) is smaller than f31(3) because there is no solution x with a better value which consumes exactly 4 units of capacity.Table 2
First step of the forward phase for the leader of BKP1.
k123ϑf11(ϑ)f21(ϑ)f31(ϑ)00001-∞222-∞-∞733394-∞55In the second step of the forward phase, we focus on the variables of the follower. The problem that is solved at this stage is the following:(3.16)max⁡yd2ys.t.y∈Argmax{f2(y′)=cy′:a2y′≤b,y′∈{0,1}n2}.
Let β=b-ϑ∈[0,b] denote the residual capacity associated with the leader action xϑ. In this second step, we consider both the leader and the follower objective functions, and we apply the forward procedure based on dynamic programming described in [8]. The objective is to determine all the reactions of the follower for a given action of the leader.Two tables are generated in the second step of the forward phase: one that stores the optimal values of the follower (fk2(β)), and a second one that stores the optimal values of the leader values (f̂k1(β)) with(3.17)fk2(β)=max⁡{∑j=1kcjyj:∑j=1kaj2yj≤β,y∈{0,1}k},f̂k1(β)=max⁡{∑j=1kdj2yj:y∈Argmax{fk2(β)}},
and k∈N2. To illustrate the execution of the forward procedure for the follower, we applied it to the instance BKP1 used in the previous examples. The results are reported in Example 3.7.Example 3.7.
The results after the second step of the forward phase are reported in Table3. This example shows that the values of the leader subproblems do not increase always because of the choice of the follower. For y3 (k=3) and β=1, the value for the leader decreases from 5 (for y2 and β=1) to 2. This new value is associated with d32=2 in order to satisfy the objective of the follower. Note that we applied the dynamic recurrence rules on the leader objective function for y2 (k=2) and β=2. The two values of the follower are equivalent: fy12(2)=fy12(0)+c2=2. In this case, the value for the leader is 5 because (f̂y11(2)=5)>(f̂y11(0)+d22=1).Table 3
Second step of the forward phase for the follower of BKP1.
k1234βf12(β)f̂11(β)f22(β)f̂21(β)f32(β)f̂31(β)f42(β)f̂41(β)00000000012525̲̲32̲̲322252̲5̲5757325465757425467878This dynamic programming approach can be improved by fixing some variables of the problem BKP to their optimal value, and by reducing the size of the interval[lbz,ubz] as discussed in the previous sections. Once this new interval has been computed, the first step of the forward phase can be applied with ϑ∈[0,ubz] instead of ϑ∈[0,b]. Since b≥ubz, this may reduce the number of steps of Algorithm 2. We do not apply this dynamic programming procedure up to the value of b, because there is no solution with a value better than LB for ϑ>ubz. Similarly, in the second step of the forward phase, we use the following interval for β: β∈[0,b-lbz].


### 3.4.2. Generating an Optimal Solution for BKP: The Backtracking Phase

Let(x*,y*) be an optimal solution for BKP. The objective of the backtracking phase is to generate a solution (x*,y*) with a value that is equal to the value computed in the forward phase. Before we introduce the backtracking procedure, we define first the optimal value that is determined in the forward phase. The optimal solution can be defined using the following rule:(3.18)d1x*+d2y*=fn11(ϑ*)+f̂n21(b-ϑ*)=max⁡0≤ϑ≤b{fn11(ϑ)+f̂n21(b-ϑ)}.
The main idea is based on the fact that for each leader decision with ϑ resources consumed, the follower reaction has to be optimum for the remaining b-ϑ resources.From the valueϑ*, we apply the backtracking procedure on the leader variables described in Algorithm 3. For the follower variables, we apply the backtracking procedure described in [8] by taking into account both the leader and the follower objective functions, and starting with the value b-ϑ*.Algorithm 3:Backtracking procedure for the leader.
ϑ←ϑ*;for  k=n1 to 2 doiffk1(ϑ)=fk-11(ϑ-ak1)+dk1  thenxk*=1;ϑ←ϑ-ak1;endelsexk*=0;endendif  f11(ϑ)=0  then  x1*=0; else  x1*=1; endFor a givenk, if the follower has different equivalent choices, the value of yk* is determined according to the profit of the leader. Note that the variable yk* can take the value 0 or 1, if the two choices are equivalent for the leader and the follower. In Example 3.8, we illustrate the execution of the backtracking procedure on the instance BKP1 used in the previous examples.Example 3.8.
The optimal value for the problem BKP1 described in Example 3.2 is determined from Tables 2 and 3 as follows:
(3.19)max⁡0≤ϑ≤4{fn11(0)+f̂n21(4),fn11(1)+f̂n21(3),fn11(2)+f̂n21(2),fn11(3)+f̂n21(1),fn11(4)+f̂n21(0)}=14,
with ϑ*=2.
The results of the backtracking procedure for the follower and leader of BKP1 are given in Table 4. To determine the optimal action of the leader, we apply Algorithm 3 starting with ϑ*=2. The optimal action for the leader is x1*=0, x2*=0, and x3*=1. For the follower, we apply the backtracking procedure described in [8], starting from 4-ϑ*=2. The optimal reaction of the follower is y1*=1, y2*=0, y3*=1, and y4*=0.Table 4
Backtracking procedure for the follower and leader of BKP1.
k1234123ϑ/βf12(β)f̂11(β)f22(β)f̂21(β)f32(β)f̂31(β)f42(β)f̂41(β)f11(ϑ)f21(ϑ)f31(ϑ)000000000(0)(0)012(5)2(5)3232-∞22225255(7)5(7)-∞-∞(7)325465757339425467878-∞55


## 3.4.1. Computing the Optimal Value of BKP: The Forward Phase

As alluded previously, the objective of the forward phase is to find the optimal value of BKP. This phase consists in two steps. The first step applies to the variables of the leader in BKP, and it considers only the objective function of the leader. The definition of this step relies on the interaction between the leader and the follower. For a given decisionx of the leader, the follower has to maximize his total profit cy using the corresponding residual capacity b-a1x. For each value of ϑ∈[0,b], the best action for the leader has to be determined: xϑ∈[0,b]∈Argmax{d1x:a1x=ϑ,x∈{0,1}n1}. Hence, the dynamic programming subproblem for the leader states as follows:(3.14)fk1(ϑ)=max⁡{∑j=1kdj1xj:∑j=1kaj1xj=ϑ,x∈{0,1}k},
with k∈N1.The dynamic programming procedure for the leader in this first step of the forward phase is described in Algorithm2. To illustrate the execution of this algorithm, we show in the following example how it applies to the instance of the BKP described in Example 3.2.Algorithm 2:Forward procedure for the leader.
f11(ϑ)=0 if ϑ=0, d11 if ϑ=a11, -∞ otherwise;for  k=2 to n1  dofor  ϑ=0 to b  doifϑ<ak1  thenfk1(ϑ)=fk-11(ϑ);endelsefk1(ϑ)=max(fk-11(ϑ),fk-11(ϑ-ak1)+dk1);endendendExample 3.6.
Let us recall first the definition of the instance BKP1:
(3.15)(BKP1)max⁡x,yf1(x,y)=3x1+2x2+7x3+5y1+y2+2y3+y4s.t.x∈{0,1}3,max⁡yf2(y)=2y1+2y2+3y3+4y4s.t.3x1+x2+2x3+y1+2y2+y3+4y4≤4,y∈{0,1}4.
The results of the first step of the forward phase applied to the leader variables of BKP1 are given in Table 2. In this table, we report on the optimal values of the associated subproblems at this step.
Note that the value off31(4) is smaller than f31(3) because there is no solution x with a better value which consumes exactly 4 units of capacity.Table 2
First step of the forward phase for the leader of BKP1.
k123ϑf11(ϑ)f21(ϑ)f31(ϑ)00001-∞222-∞-∞733394-∞55In the second step of the forward phase, we focus on the variables of the follower. The problem that is solved at this stage is the following:(3.16)max⁡yd2ys.t.y∈Argmax{f2(y′)=cy′:a2y′≤b,y′∈{0,1}n2}.
Let β=b-ϑ∈[0,b] denote the residual capacity associated with the leader action xϑ. In this second step, we consider both the leader and the follower objective functions, and we apply the forward procedure based on dynamic programming described in [8]. The objective is to determine all the reactions of the follower for a given action of the leader.Two tables are generated in the second step of the forward phase: one that stores the optimal values of the follower (fk2(β)), and a second one that stores the optimal values of the leader values (f̂k1(β)) with(3.17)fk2(β)=max⁡{∑j=1kcjyj:∑j=1kaj2yj≤β,y∈{0,1}k},f̂k1(β)=max⁡{∑j=1kdj2yj:y∈Argmax{fk2(β)}},
and k∈N2. To illustrate the execution of the forward procedure for the follower, we applied it to the instance BKP1 used in the previous examples. The results are reported in Example 3.7.Example 3.7.
The results after the second step of the forward phase are reported in Table3. This example shows that the values of the leader subproblems do not increase always because of the choice of the follower. For y3 (k=3) and β=1, the value for the leader decreases from 5 (for y2 and β=1) to 2. This new value is associated with d32=2 in order to satisfy the objective of the follower. Note that we applied the dynamic recurrence rules on the leader objective function for y2 (k=2) and β=2. The two values of the follower are equivalent: fy12(2)=fy12(0)+c2=2. In this case, the value for the leader is 5 because (f̂y11(2)=5)>(f̂y11(0)+d22=1).Table 3
Second step of the forward phase for the follower of BKP1.
k1234βf12(β)f̂11(β)f22(β)f̂21(β)f32(β)f̂31(β)f42(β)f̂41(β)00000000012525̲̲32̲̲322252̲5̲5757325465757425467878This dynamic programming approach can be improved by fixing some variables of the problem BKP to their optimal value, and by reducing the size of the interval[lbz,ubz] as discussed in the previous sections. Once this new interval has been computed, the first step of the forward phase can be applied with ϑ∈[0,ubz] instead of ϑ∈[0,b]. Since b≥ubz, this may reduce the number of steps of Algorithm 2. We do not apply this dynamic programming procedure up to the value of b, because there is no solution with a value better than LB for ϑ>ubz. Similarly, in the second step of the forward phase, we use the following interval for β: β∈[0,b-lbz].


## 3.4.2. Generating an Optimal Solution for BKP: The Backtracking Phase

Let(x*,y*) be an optimal solution for BKP. The objective of the backtracking phase is to generate a solution (x*,y*) with a value that is equal to the value computed in the forward phase. Before we introduce the backtracking procedure, we define first the optimal value that is determined in the forward phase. The optimal solution can be defined using the following rule:(3.18)d1x*+d2y*=fn11(ϑ*)+f̂n21(b-ϑ*)=max⁡0≤ϑ≤b{fn11(ϑ)+f̂n21(b-ϑ)}.
The main idea is based on the fact that for each leader decision with ϑ resources consumed, the follower reaction has to be optimum for the remaining b-ϑ resources.From the valueϑ*, we apply the backtracking procedure on the leader variables described in Algorithm 3. For the follower variables, we apply the backtracking procedure described in [8] by taking into account both the leader and the follower objective functions, and starting with the value b-ϑ*.Algorithm 3:Backtracking procedure for the leader.
ϑ←ϑ*;for  k=n1 to 2 doiffk1(ϑ)=fk-11(ϑ-ak1)+dk1  thenxk*=1;ϑ←ϑ-ak1;endelsexk*=0;endendif  f11(ϑ)=0  then  x1*=0; else  x1*=1; endFor a givenk, if the follower has different equivalent choices, the value of yk* is determined according to the profit of the leader. Note that the variable yk* can take the value 0 or 1, if the two choices are equivalent for the leader and the follower. In Example 3.8, we illustrate the execution of the backtracking procedure on the instance BKP1 used in the previous examples.Example 3.8.
The optimal value for the problem BKP1 described in Example 3.2 is determined from Tables 2 and 3 as follows:
(3.19)max⁡0≤ϑ≤4{fn11(0)+f̂n21(4),fn11(1)+f̂n21(3),fn11(2)+f̂n21(2),fn11(3)+f̂n21(1),fn11(4)+f̂n21(0)}=14,
with ϑ*=2.
The results of the backtracking procedure for the follower and leader of BKP1 are given in Table 4. To determine the optimal action of the leader, we apply Algorithm 3 starting with ϑ*=2. The optimal action for the leader is x1*=0, x2*=0, and x3*=1. For the follower, we apply the backtracking procedure described in [8], starting from 4-ϑ*=2. The optimal reaction of the follower is y1*=1, y2*=0, y3*=1, and y4*=0.Table 4
Backtracking procedure for the follower and leader of BKP1.
k1234123ϑ/βf12(β)f̂11(β)f22(β)f̂21(β)f32(β)f̂31(β)f42(β)f̂41(β)f11(ϑ)f21(ϑ)f31(ϑ)000000000(0)(0)012(5)2(5)3232-∞22225255(7)5(7)-∞-∞(7)325465757339425467878-∞55


## 3.5. Outline of the Algorithm

The outline of our exact algorithm for BKP is given in Figure1. Each box in this figure corresponds to a step of our algorithm. The numbers identify the sequence by which the operations are performed.Figure 1
Outline of the algorithm.The algorithm starts by computing an upper bound for BKP through the exact resolution of HBKP. The next step consists in finding a good lower bound for BKP by computing a feasible solution for the problem. For this purpose, we solve first the problem CBKP using Algorithm1. As referred to in Section 3.1, each solution generated by Algorithm 1 can be associated to a value of the parameter z in FBKPz. From the set of solutions found by Algorithm 1, we select the n best solutions, and we solve the n problems FBKPz for the corresponding values of the parameter z.The upper and lower bounds (denoted, resp., by UB and LB in Figure1) obtained in the previous steps are used to fix the variables of the leader to their optimal values. This is done by applying the fixing rules discussed in Section 3.2. The resulting problem is called the reduced problem in Figure 1. The lower bound LB is then used to reduce the size of the interval of possible values for z. The new computed interval may help in reducing the number of steps of the dynamic programming procedures that are applied next. Similarly, the size of the reduced problem (i.e., solved with dynamic programming in the next step of the algorithm) is smaller than the original BKP, and hence, it is easier to solve using dynamic programming.The next step of our algorithm consists in applying the forward phase of the dynamic programming procedure to the reduced problem in order to compute the value of an optimal solution for BKP. Finally, from this optimal value, an optimal solution for BKP is generated using the backtracking procedure described in Section3.4.2.


## 4. Computational Results

In this section, we report on the results of the computational study that was performed to evaluate the performance of our algorithm. Our approach is compared with other methods proposed in the literature. The limits of our algorithm are discussed, and a strategy to overcome these limits is presented and tested. All the algorithms analyzed in this section were coded in C++. We used the version 12.0 of the commercial optimization solver CPLEX. The experiments were conducted on a PC with 2.4 GHz with 4 GB of RAM.Three sets of computational experiments were performed. In the first one, we compare our algorithm with the branch-and-bound algorithm proposed by Moore and Bard in [9]. In the second one, we perform a comparative study between our algorithm and the method of Brotcorne et al. described in [10]. The third set of experiments was conducted to analyze the impact of each component of our algorithm in the performance of our global approach. The limits of our algorithm are illustrated from a computational standpoint, and a variant that handles these issues is described and tested.We used the generator proposed by Martello et al. [21] to generate instances of the knapsack problem. This generator gives us the data for the coefficients a1, a2, d1, and c of BKP. The value of b is computed as follows: b=α(∑i=1n1ai1+∑j=1n2aj2), with α∈{0.50,0.75}. The input data for the leader (d2) is generated randomly, such that all the coefficients are in the interval [1,L], with L∈{100,1000}. We generated instances with uncorrelated coefficients (UC), and with correlated coefficients (C) [17].In Table5, we compare the performance of our algorithm (denoted by MACH1) with the branch-and-bound algorithm proposed in [9] (denoted by BM). For these experiments, we used a set of small instances with uncorrelated coefficients with α=0.25 and L=100. We generated 5 instances for each set of instances characterized by the parameters n1 and n2. In Table 5, we report on the average computing time (in seconds) required by BM and MACH1 to find an optimal solution for these instances. The computing times for BM and MACH1 are given, respectively, in the columns tBM and tMACH1.Table 5
Computing time for BM and MACH1 for uncorrelated instances withL=100 and α=0.25.
n1n2tBBtMACH11010001050001010001501020505040501002211001060100502801001001301Table5 shows the difficulty of the branch-and-bound algorithm of Moore and Bard in solving these instances, while our approach remains very fast. Note that the branch-and-bound algorithm is not able to find the optimal solution of medium instances with α=0.5, n1=200, and n2=200 and correlated coefficients in less than one hour. As we will see in the next experiments, our approach can solve these (and larger) instances very efficiently.The results of our second set of experiments are reported in Table6. We compare the performance of our algorithm with the method described in [10]. In the sequel, the latter will be denoted by BHM. The algorithm BHM is composed by two phases: the first phase is a dynamic programming procedure applied to the follower problem to determine all the possible reactions of the follower; in the second phase, a reformulated integer problem is solved by making the link between the actions of the leader and the reactions of the follower.Table 6
Comparison between BHM and MACH1.
n1n2αUCCoptBHMtBHMtMACH1optBHMtBHMtMACH150500.550.40.62485.81.2501000.5550.40>6001.0100500.553.80.60>6001.21001000.54421.61.40>6002.050500.7550.40.44177.80.8501000.7552.80.80>6001.2100500.7550.80.80>6001.21001000.75512.00.80>6001.4For these experiments, we used harder instances. The sets of instances are characterized by the parametersn1, n2, and α. Again, we generated randomly 5 instances for each set. The parameters were chosen as follows: n1∈{50,100}, n2∈{50,100}, and α∈{0.50,0.75}. The coefficients were generated in the interval [1,1000], and we considered both uncorrelated and correlated instances. For these experiments, we used a maximum time limit of 600 seconds.In columnoptBHM, we give the number of times the algorithm BHM finds a proven optimal solution within the maximum time limit. Note that our algorithm always finds an optimal solution within this time limit. The average computing time required by BHM and MACH1 to find a proven optimal solution is given in the columns tBHM and tMACH1, respectively. For BHM, the average time reported in Table 6 corresponds only to the cases where this algorithm finds a proven optimal solution within the time limit of 600 seconds.From the results of Table6, it is clear that our algorithm outperforms the approach of Brotcorne et al. [10]. Our approach remains very fast both for the uncorrelated and the correlated instances, while BHM is not able to find the optimum solution for most of the correlated instances. The performance of our algorithm is due in a large part to the strategies used for fixing the value of some variables, to our procedures for computing lower and upper bounds, and in particular to the strategy for reducing the interval of values for the parameter z in FBKPz. Note that our algorithm does not have any difficulty in proving the optimality of the solution found in the backtracking phase, since the optimal value is known at the end of the forward phase. The algorithm BHM spends more time precisely in its second phase when it solves the reformulated problem. At this stage, this algorithm has no information for the value of the optimal solution. Its computing time increases quickly with the correlation of the instances because in this case the size of the reformulated integer problem becomes larger.In our final set of experiments, we focus on our algorithm. Despite its efficiency compared with other approaches, our algorithm may experience some difficulties with memory space for larger instances. These difficulties are illustrated in Table7. The instances used in this case were generated as in the previous experiments, and with the parameters n1, n2, and α given in Table 7. For each case, we generated 5 instances. Since these difficulties are due to the dynamic programming part of our algorithm, we used in these experiments a version of MACH1 in which the procedures described in Sections 3.1, 3.2, and 3.3 are disabled. We will denote this version by MACH1′. Table 7 reports the average computing time for the MACH1′ and for a variant that will be described hereinafter. The entry mem in Table 7 means that MACH1’ did not complete because of the memory space required for its execution. This problem arises for the largest instances with n1=500, n2=500, and α=0.75. Recall that, for the coefficient b, we have b=α(∑i=1n1ai1+∑j=1n2aj2). In this case, the value of b can be very large, and that is the main cause for this memory problem.Table 7
Comparison between MACH1′ and MACH2′.
n1n2αUCCtMACH1′tMACH2′tMACH1′tMACH2′2502500.55.05.05.15.42505000.513.814.014.014.65002500.511.61211.812.85005000.522.423.222.423.22502500.758.28.48.48.42505000.7520.220.421.021.45002500.7517.017.017.617.65005000.75mem33.8mem35.6To overcome this issue, we propose a variant of the algorithm MACH1 (denoted by MACH2) that consists in replacing the backtracking phase based on dynamic programming in MACH1 by the exact resolution of the problemFBKPz right after the forward phase. The forward phase gives us the optimal value for BKP. This optimal value is used for solving FBKPz. Since we know this optimal value in advance, the resolution of FBKPz becomes easier. In MACH2, we keep only two columns for dynamic programming at each iteration of the forward phase, and hence, the memory space that is necessary decreases.In Table7, we report on the average computing time required by a version of this variant without the procedures described in Sections 3.1, 3.2, and 3.3 (as in MACH1’). This version will be denoted by MACH2’. All the instances are solved up to optimality with a very small increase in the computing time compared to MACH1’. With this new variant, the problem with memory space does not occur anymore.In Table8, we compare the complete version of the algorithm MACH2 with the version MACH2′. In our implementation of MACH2, we solved the problem FBKPz with the 10 best solutions generated by Algorithm 1 to find a valid lower bound. The objective of these experiments was to evaluate the impact of the additional components of our approach, namely, the polynomial procedure for solving CBKP described in Section 3.1 (Algorithm 1) and the reduction procedures described in Sections 3.2 and 3.3. We generated randomly 5 instances for each set of instances as in the previous experiments with the parameters n1, n2, and α given in Table 8. The meaning of the entries in Table 8 is the following:(i)
qualh: quality of the solution obtained with Algorithm 1 described in Section 3.1 (value of the best solution given by Algorithm 1 divided by the value of the optimal solution of the BKP);(ii)
th: computing time (in seconds) required by Algorithm 1;(iii)
fix: percentage of variables that were fixed;(iv)
intz: measure of the reduction achieved with the procedure described in Section 3.3; the values in this column are computed as follows: (ubz-lbz)/b;(v)
tMACH2′: computing time (in seconds) required by MACH2′;(vi)
tMACH2: computing time (in seconds) required by MACH2.Table 8
Comparison between MACH2′ and MACH2.
n1n2αUCCqualhthfixintztMACH2′tMACH2qualhthfixintztMACH2′tMACH2%%%%%%5005000.599.03.09.88.5121.012.699.20.8045.521.415.850010000.599.02.60.09.9850.235.899.01.4048.951.044.810005000.599.03.88.06.8543.025.699.01.0034.4744.231.8100010000.599.02.40.09.3982.849.699.01.4044.585.265.25005000.7599.22.212.66.2230.815.899.01.0025.531.221.450010000.7599.01.60.05.7874.649.899.41.2024.375.056.610005000.7599.02.419.24.3663.026.699.01.2018.764.041.2100010000.7599.02.80.05.63122.069.899.01.0025.7124.081.4From the results of Table8, we can observe that the additional components of the algorithm have a positive impact on the performance of our global approach. The average computing times for all the sets of instances decreased with MACH2. For the set of instances with n1=1000, n2=500, and α=0.75, the reduction is greater than 50%.The lower bound given by CBKP is strong. Furthermore, it is computed very efficiently with Algorithm1. The average computing time required by this algorithm is always smaller than 4 seconds. The fixing rules presented in Section 3.2 have a limited impact on the correlated instances. This can be explained by the quality of the upper bound that was considered (given by HBKP), and by the correlation between the coefficients of the instances. These rules perform better on the uncorrelated instances. While the lower bound on the optimal value of BKP does not seem to be very useful for fixing the values of the variables, it is for reducing the interval of feasible values for z. Although the size of this interval decreases for all the instances, it is more significant for the uncorrelated instances. The reduction of the size of this interval has a strong influence on the resolution of the reduced problem with dynamic programming. Indeed, it implies reducing the capacity of the knapsack constraint at each step of the dynamic programming procedures. That explains in part the better performance of MACH2 compared with MACH2′.


## 5. Conclusions

In this paper, we described a new exact algorithm for bilevel 0-1 knapsack problems (BKPs). We developed an original method for solving the linear relaxation of BKP, and we proposed a method for computing good feasible solutions for this problem using the information provided by the solutions of this linear relaxation. We described different strategies to enhance the resolution of BKP based on a valid upper and lower bound for the problem. Finally, we presented a dynamic programming procedure to find the integer optimal solution of the problem. To evaluate the performance of our approach, we conducted a set of computational experiments. Our results were compared with other algorithms proposed in the literature. The results that we obtained show that our algorithm clearly outperforms other state-of-the-art methods presented so far.



---

*Source: 504713-2012-02-14.xml*