Knapsack problems with position-dependent item weights or profits

We consider three new knapsack problems with variable weights or profits of items, where the weight or profit of an item depends on the position of the item in the sequence of items packed in the knapsack. We show how to solve the problems exactly using dynamic programming algorithms with pseudo-polynomial running times and propose fully polynomial-time approximation schemes for their approximate solution.


Introduction
One of the best known problems in mathematical programming is the 0-1 Knapsack Problem (K P) which is defined as follows. We are given an item set N , consisting of n items labeled 1, 2, . . . , n, and a knapsack with a capacity C. Each item j ∈ N has a profit p j and a weight w j . The objective is to select a subset N ⊆ N such that the total profit of the selected items is maximized and their total weight does not exceed the capacity C. In the paper, we call this problem the Standard Knapsack (SK ) problem.
The SK problem can be formulated by the following integer linear program: w j x j ≤ C, x j ∈ {0, 1}, j = 1, . . . , n, with p j , w j and C being non-negative integers. The SK problem is the simplest non-trivial integer programming model with binary variables, only one single constraint and only positive coefficients. Nevertheless, adding the integrality condition (3) to the linear program (1) and (2) already puts it into the class of weakly N P-hard problems (see, e.g., Garey & Johnson, 1979). Despite the fact that in the SK problem the profits and weights of items are fixed, the problem plays an important role in applications and often appears in formulations of many combinatorial optimization problems. This problem is weakly N P-hard and can be solved exactly in pseudo-polynomial time or by constant factor approximation algorithms and approximation schemes. For an overview of all aspects of the SK problem, its relatives and applications we refer the reader to the monograph by Kellerer et al. (2004). Another interesting reference on the subject is the monograph by Martello and Toth (1990). A brief summary of recent research on the SK problem the reader may find in reviews by Cacchiani et al. (2022a, b).
Though the SK problem is considered mainly in optimization theory, it may also be studied in the context of scheduling theory. For example, let us consider a production unit, where a worker operates a machine that is only available during a certain period of time. The worker has to execute on the machine a set of jobs composed of assembly, maintenance, testing or other production operations. Due to multiple repetition of these operations, the skills of this worker are improving what results in the reduction of time required to complete each job. Therefore, one can assume that the processing time of any job executed by the worker changes over time and is proportional to the value of a function of the job position in the sequence of jobs completed so far. In order to motivate the worker to increase the productivity, the employer pays this worker for each completed job a payment proportional to the processing time of the job. Under the assumptions, the aim of the worker is to find such a job sequence which maximizes the total payment for the jobs executed in the machine availability period. So defined problem is equivalent to a variant of a knapsack problem, where the job processing times and the payments are variable position-dependent item sizes and profits, respectively. The above example may be modified in many ways, since depending on the form of the functions which define the job processing times and the payments we obtain various variable job processing times. We refer the reader to the review by Gawiejnowicz (2020a) for an introductory presentation of the variability of job processing times. A detailed discussion of various classes of scheduling problems with variable job processing times and their applications the reader may find in the monograph by Gawiejnowicz (2020b). Now, we formulate the three position-dependent knapsack problems we consider, introduce terminology and notation we use, summarize our contribution and describe the paper organization.

The formulation of position-dependent knapsack problems
In this paper, we consider three Position-Dependent Knapsack (P DK ) problems with position-dependent weights or profits of items. In the first problem, denoted by P1, the weight of item j, 1 ≤ j ≤ n, is position-dependent and described by the function w j (r ) = w j f w (r ), where r ∈ {1, 2, . . . , n} denotes the number of the position of an item in the sequence of items packed in the knapsack so far, and f w (r ) is a function of r which can be computed in a constant time for any r = 1, 2, . . . , n. The profit of item j is fixed (i.e., position-independent) and equals p j (r ) = p j . We assume that the functions f w (r ) are either monotonically non-decreasing or non-increasing.
In the second problem, denoted by P2, the weight of item j is fixed (i.e., positionindependent), w j (r ) = w j for 1 ≤ j ≤ n, while its profit is position-dependent and described by the function p j (r ) = p j f p (r ), where j, r and f p (r ) are defined similarly as above. Analogously to problem P1, we assume that the functions f p (r ) are either monotonically non-decreasing or monotonically non-increasing.
Finally, in the third problem, denoted by P3, both the weights of items and their profits are position-dependent and described by functions w j (r ) and p j (r ) as above, where 1 ≤ j ≤ n. We assume that either the functions f w (r ) or f p (r ) are monotonically non-increasing and consider two subproblems of P3, denoted by P3a and P3b, respectively. In problem P3a, the functions f w (r ) are monotonically non-increasing and the number of different profit values p j is a constant. In problem P3b, the functions f p (r ) are monotonically non-increasing and the number of different weight values w j is a constant. As for the SK problem, the aim is to find an ordered subset N ⊆ N such that the total weight of items from the subset does not exceed C, while the total profit is maximized. As generalizations of the SK problem, problems P1, P2 and P3 are weakly N P-hard, and we will prove that even problems P3a and P3b are weakly N P-hard.

Terminology and notation
Throughout the paper we apply the following terminology and notation. The values w j (r ) = w j f w (r ) and p j (r ) = p j f p (r ) are called position-dependent weights and positiondependent profits, respectively. A solution of any of the problems P1, P2, P3 can be considered as sequence σ = (i 1 , i 2 , . . . , i ν ), ν ≤ n, of a subset of the items in N . The weight of σ is given as The sequence σ is feasible if W (σ ) ≤ C. The profit of σ is then given as An item j ∈ N dominates an item i ∈ N if p j ≥ p i and w j ≤ w i , and at least one of the two inequalities is strict. If in an instance only a constant number k of different profit values p 1 , p 2 , . . . , p k are given, then items with profit p j are said to be of profit type j, j = 1, . . . , k. Weight types j are defined analogously. The number of items of weight or profit type j is denoted by k j , k j=1 k j = n. The optimal solution value of a problem instance I and the solution value computed by an approximation algorithm A are denoted as z (I ) and z A (I ), respectively. (If there is no ambiguity, the reference to the instance I is omitted and we write briefly z and z A , respectively.) A lower (an upper) bound on the total profit of an optimal solution of an instance of any of the problems is denoted by L B (U B). The total sum of all profit values and the largest profit are denoted by P = j p j and p max , respectively. An algorithm A is called an ε-approximation scheme if for every input ε ∈ ]0, 1[ the inequality holds for all problem instances I . An ε-approximation scheme A is a polynomial time approximation scheme (PTAS) if its running time is polynomial in n. An ε-approximation scheme A is a fully polynomial time approximation scheme (FPTAS) if its running time is polynomial both in n and in 1 ε .

Our contribution and the organization of the paper
The contribution of the paper is three-fold. First, we prove properties of three new knapsack problems with position-dependent item weights or profits defined in Sect. 1.1. Second, we propose dynamic programming algorithms for exact solving of the problems. Finally, we construct FPTASes for approximate solving of the problems. A brief summary of our results is given in Table 1, where symbols f p (r ) and f p (r ) denote that function f p (r ) is monotonically non-increasing and non-decreasing, respectively, while symbol k( j) denotes the maximum index of an item as it will be defined in Eq. (8), and U z = n max j=1,...,n p j f p (1) . The remaining sections of the paper are organized as follows. Sections 2 and 3 contain dynamic programming algorithms with pseudo-polynomial running time and FPTASes for problems P1 and P2, respectively. In Sect. 4, we show that problems P3a and P3b are weakly N P-hard. Moreover, dynamic programming algorithms for problems P3a and P3b are given and FPTASes for both problems are presented. Finally, in Sect. 5, we conclude and give remarks on possible topics for future research on position-dependent knapsack problems.

Exact algorithm and approximation scheme for problem P1
Recall that in problem P1 we have p j (r ) = p j and w j (r ) = w j f w (r ) for 1 ≤ j ≤ n, where f w (r ) are either monotonically non-decreasing or non-increasing functions.
First, we show that for P1 the following auxiliary result holds.
Lemma 1 If function f w (r ) is monotonically non-decreasing (non-increasing), then there exists an optimal solution of problem P1 in which items are given in non-increasing (nondecreasing) order of weights w j .
Proof We proceed using a standard exchange argument. We assume that function f w (r ) is monotonically non-decreasing, the proof for monotonically non-increasing function f w (r ) is analogous.
Consider an optimal solution to problem P1 which consists of a sequence σ = (   Since sequence σ differs from σ only by positions of items i 1 and i 2 , we get By successively exchanging all other pairs of items which weights are not non-decreasingly ordered, we obtain a sequence as required.
Lemma 1 shows that in an optimal solution for problem P1 a certain order on the items is required. After realizing this, it is easy to solve problem P1 in pseudopolynomial time by applying a dynamic programming algorithm. The algorithm runs analogously to the dynamic programming algorithm for the SK problem with an additional dimension for the number of items in the knapsack.
If f w (r ) is monotonically non-decreasing, we assume that the items are sorted in nonincreasing order of weights, i.e. w 1 ≥ w 2 ≥ . . . ≥ w n . In the case when f w (r ) is monotonically non-increasing, we assume that items are sorted in non-decreasing order of weights, i.e. w 1 ≤ w 2 ≤ . . . ≤ w n . By Lemma 1, it is optimal to assign the items to the knapsack in the order 1, 2, . . . , n.
Let y j (g, r ) denote the minimal weight of a subset of the set {1, . . . , j}, with cardinality r and total profit equal to g.
Problem P1 can by solved by the following dynamic programming algorithm which we will call Algorithm D P1.
First, Algorithm DP1 initializes functions y 0 (0, 0) and y j (g, 0) as follows: where U B is an upper bound value defined below. Assume that y j (g, r ) is computed for j = 1, . . . , k − 1, g = 0, . . . , U B, r = 0, . . . , j, for some 1 ≤ k ≤ n. Algorithm DP1 computes for g = 0, . . . , U B, r = 1, . . . , j the values of functions y j (g, r ) as follows: Finally, it computes the value of an optimal solution as follows: The running time of Algorithm DP1 is O(n 2 U B). As an upper bound value we can choose U B = np max or U B = P = j p j . Hence, taking the latter bound, we obtain the following result.

Theorem 1 Algorithm D P1 solves problem P1 in O(n 2 P) time.
Algorithm DP1 can be easily transformed into an FPTAS by a standard scaling of the profit values p j which is outlined in Kellerer et al. (2004, Section 2.6). For the sake of completeness, we will describe this procedure. First, we run DP1 for the instance with scaled profit valuesp j such thatp j := p j K for a given constant K . This yields a solution setX for the scaled items which will usually be different from the original optimal solution set X . Evaluating the original profits of item setX yields the approximate solution value z A . The difference between z A and the optimal solution value can be bounded as follows: Let L B denote a lower bound on the optimal solution value z . To get the desired performance guarantee of 1 − ε, we have to choose K such that Let U B1 denote an upper bound for the optimal profit value of the scaled instance. Then, we get a running time for the FPTAS which is in Simple lower and upper bounds for z are L B = p max and U B = np max , respectively. Since U B L B = n, it yields an overall running time of O( n 4 ε ). Hence, we have proven the following result.
Theorem 2 There exists an FPTAS for problem P1 running in O n 4 ε time.

Exact algorithm and approximation scheme for problem P2
In problem P2, we have p j (r ) = p j f p (r ) and w j (r ) = w j for 1 ≤ j ≤ n. Below, we present a dynamic programming algorithm and an FPTAS for problem P2, applying the approach similar to that in Sect. 2. Since we assume that function f p (r ) is monotonic, the following result can be proven analogously to Lemma 1.

Lemma 2 If function f p (r ) is monotonically non-decreasing (non-increasing), then there exists an optimal solution of problem P2 in which items are given in non-decreasing (nonincreasing) order of profits p j .
Hence, we may assume that if f p (r ) is monotonically non-increasing, items are sorted in non-increasing order of profits, i.e. p 1 ≥ p 2 ≥ . . . ≥ p n . Similarly, if f p (r ) is monotonically non-decreasing, we may assume that items are sorted in non-decreasing order of profits, i.e. p 1 ≤ p 2 ≤ . . . ≤ p n . The corresponding dynamic program DP2 is equivalent to the dynamic program DP1 and the dynamic programming recursion is similar to Eq. (5): The running time of DP2 is again in O(n 2 U B). Lower bounds L B and upper bounds U B for the optimal solution value z can be computed as follows. If f p (r ) is a non-increasing function, then we may choose L B = p max f p (1) and U B = np max f p (1). If f p (r ) is a nondecreasing function, find for each item j the maximum position k( j) such that it can be put into the knapsack together with the other k( j) − 1 items of smallest weight. Let W −1 ( j) denote the set of the − 1 smallest weights in the set {w 1 , . . . , w n } \ {w j }. Then, we have Consequently, and U B = n L B serve as lower and upper bounds for z , respectively. Hence, there holds the following result.
Proceeding in a similar manner as for problem P1 and setting K = εL B n as in Eq. (6), we get an FPTAS for problem P2. Since in both cases U B L B = n, Eq. (7) implies that the running time of the FPTAS is O( n 4 ε ). Hence, we have proven the following result.
Theorem 4 There exists an FPTAS for problem P2 running in O( n 4 ε ) time.

Exact algorithms and approximation schemes for problems P3a and P3b
In problem P3, we have p j (r ) = p j f p (r ) and w j (r ) = w j f w (r ) for 1 ≤ j ≤ n. Moreover, we assume that there are only a constant number k of different profit values denoted as p 1 , p 2 , . . . , p k in problem P3a and k different weight values denoted as w 1 , w 2 , . . . , w k in problem P3b. In the following, we assume that both f p (r ) and f w (r ) are non-increasing. Obviously, problem P3 is weakly N P-hard. At the first glance, it may seem that the assumption that there are only a constant number of different profit values or weight values simplifies problems P3a and P3b, respectively. Note that the SK problem with a constant number of different profit values can be solved in polynomial time, since we may guess for each profit type j the number of items in the knapsack, named as j . For each j , j = 1, . . . , k, put the j items of smallest weight into the knapsack. This approach gives us a running time of O(n k ) for the problem. However, for problems P3a and P3b the situation is different. In fact, we will show that both of these problems are weakly N P-hard by a reduction from the famous Partition problem.
Partition: Given t integers e j such that t j=1 e j = 2E, does there exist a partition of the index set T = {1, 2, . . . , t} into two subsets T 1 and T 2 such that j∈T 1 e j = j∈T 2 e j = E?
We assume, without any loss of generality, that elements e j , j = 1, . . . , t, of an instance of the Partition problem are ordered non-increasingly. (Otherwise, we can order them accordingly in O(t log t) time.) It is well known that Partition is weakly N P-complete (see, e.g., Garey and Johnson (1979)).

Theorem 5 Problems P3a and P3b are weakly N P-hard even if f p (r ) = f w (r ) for all positions r , if profits are equal to weights, and if there are only two different profit and weight values.
Proof Given an arbitrary instance of Partition, define the following instance I of problem P3a (or P3b) with n = 2t items. Items 1, . . . , t have profit 1 and weight 1, and items t + 1, . . . , 2t are dummy with profit 0 and weight 0. The capacity of the knapsack is C = E. The functions f p (r ) and f w (r ) are defined as To prove Theorem 5, we show that for the constructed instance I , there is a sequence of items σ with W (σ ) ≤ E and P(σ ) ≥ E if and only if Partition has a solution.
Let Partition have a solution, and let T 1 and T 2 be the corresponding index sets. We put items with weight 1 on the positions r ∈ {1, . . . , t} if e r = f p (r ) ∈ T 1 . The rest of the first t positions is filled with dummy items. The remaining items are not included in the knapsack. Then, we get for the obtained sequence σ that Suppose now that there is a sequence σ of at most 2t items with W (σ ) ≤ E and P(σ ) ≥ E. Only items with weight and profit 1 contribute to the total weight or total profit, respectively. Let the subset of the first t positions on which items of weight 1 are put, be denoted by S 1 . We get The values of f p (r ) which correspond to the positions r ∈ S 1 establish a solution of Partition.
In Sect. 1.2, the notion of item dominance was introduced. For the position-dependent knapsack problem, the dominance of two items means that a dominated item is only packed into the knapsack if its dominating items are packed as well. This holds also for problem P3, as it is stated in the following lemma.

Lemma 3 Let in an instance of problem P3 an item i ∈ N be dominated by an item j ∈ N .
Then there is an optimal solution with minimum weight with the following property: if item i is packed into the knapsack, then also item j is packed into the knapsack.
Proof We proceed applying a simple exchange argument. Assume that an item i ∈ N is packed into the knapsack, but not item j ∈ N . Then, remove item i from the knapsack and put item j at its position. Since the positions of the other items will not be changed, we get a solution with smaller or same total weight and at least the same profit. Because at least one of the inequalities is strict, this shows the assertion.
Under certain conditions the aforementioned domination notion applies not only to items but also to their sequence: dominating items are packed earlier than the corresponding dominated items. This double dominance is formulated in the following auxiliary result.

Lemma 4 Let N ⊆ N be a subset of items of an instance of problem P3. Assume that the following two conditions hold:
(i) f w is monotonically non-increasing or all weights in N are equal.
(ii) f p is monotonically non-increasing or all pr o f its in N are equal.
Let an item i ∈ N be dominated by an item j ∈ N . Then there is an optimal solution to the instance such that if both items are packed into the knapsack, then item j is packed earlier than item i.
Proof If item i is processed before j in an optimal sequence σ , i.e. i is processed on position i 1 and item j is processed on position i 2 with i 1 < i 2 , then exchange the positions of i and j to get a sequence σ . Since, the other items do not change their positions, we get as in Eq. (4) that By the dominance of items i and j and condition (i), both factors on the right side are nonnegative and we get that W (σ ) − W (σ ) ≥ 0. This means that σ gives a feasible sequence. The profit difference of the two sequences is equal to By the dominance of items i and j and condition (ii), we get that P(σ ) − P(σ ) ≤ 0. This means that the total profit of σ is not smaller than the total profit of σ . Hence, the lemma holds.
Corollary 1 Let be given an instance of P3 such that both f p and f w are monotonically nonincreasing. If profits and weights of the items are oppositely ordered such that p 1 ≥ p 2 ≥ . . . ≥ p n and w 1 ≤ w 2 ≤ . . . ≤ w n , then problem P3 is solved optimally by assigning the items to the knapsack in increasing order of indices.

Problem P3a
We have now the capability to present a dynamic programming algorithm for problem P3a. Using Lemmas 3 and 4, we have for items with the same profit a strict dominance relation by sorting the items in non-decreasing weight order. Hence, if the optimal solution contains j items of profit type j, we choose the j items with smallest weight of this profit type and they are assigned in non-decreasing order of weights.
Recall that the number of items of weight or profit type j is denoted by k j . Let Let y(g; 1 , . . . , k ) denote the minimal weight of a set of j items of profit type j, 1 ≤ j ≤ k, with cardinality j ≤ k j , which has the total profit equal to g. Then, problem P3a can by solved by the following dynamic programming algorithm which we will call Algorithm D P3a.
First, Algorithm DP3a initializes functions y(g; 0, . . . , 0) as follows: Assume that y(g ; 1 , . . . , k ) is computed for g = 0, . . . , U B and 1 ≤ 1 , . . . , k ≤ k with k j=1 j ≤ − 1. Moreover, let the weights of the k j items of profit type j be denoted as Note that if f p (r ) is a non-increasing function, we may choose L B = p max f p (1) and U B = np max f p (1). Summarizing, we have the following result. Note that a correctness proof of Theorem 6 could be done by standard induction arguments. Since it is straightforward, we skip it. Transformation of algorithm DP3a into an FPTAS can be done like in Sect. 3, with the difference that in the expression evaluating the running time of the scheme U B is replaced by n k+1 ε U B L B . Thus, the overall running time of the FPTAS is in O( n k+2 ε ). This implies the following result.

Theorem 7 There exists an FPTAS for problem P3a running in O( n k+2
ε ) time.

Problem P3b
A dynamic program for problem P3b can be found in a similar way, provided that we have only a constant number of weight values. If the optimal solution contains j items of weight type j, we choose the j items with largest profit of this weight type and they are assigned in non-increasing order of profits. Let y(g; 1 , . . . , k ) denote the maximum profit of a set of j items of weight type j, 1 ≤ j ≤ k, with cardinality j ≤ k j , which has the total weight equal to g. Then, problem P3b can by solved optimally by the dynamic programming algorithm Algorithm D P3b.
Let , and − j be as defined in Eq. (9), and let the profits of the k j items of weight type j be denoted as p j 1 , . . . , p j k j with p j 1 ≥ p j 2 ≥ . . . ≥ p j k j . Algorithm DP3b computes for g = 0, . . . , C, j = 1, . . . , k the values of functions y(g; ) as follows: for all g = 0, . . . , C (we adopt the convention that maximum on an empty set equals −∞). Finally, it computes the value of an optimal solution as follows: max g=0,...,C; : j ≤k j , j=1,...,k y(g; ) .
The running time of Algorithm DP3 is in O(n k C).

Theorem 8 Algorithm D P3b solves problem P3b in O(n k C) time.
Note that Algorithm DP3b cannot be transformed into an FPTAS in a similar way as we did with Algorithm DP3a in Sect. 4.1, since rounding of weight values in DP3b could create infeasible solutions.
We now turn to an alternative DP formulation, one which we will use in order to get an FPTAS via a different technique, called K -approximation sets and functions.
Let z , 1 ,..., k (g) be the maximum profit of a set of (exactly) items, of which j items are of weight type j, j = 1, . . . , k, which has the total weight of at most g units (recall that = k j=1 j ). The boundary condition is z 0, 0 (g) = 0, g = 0, . . . , C. (10) The DP recurrence is in the form of (as previously, we adopt the convention that maximum on an empty set equals −∞): for all g = 0, . . . , C. The value of an optimal solution is computed as follows: Note that the alternative DP recursion (10)-(11) is identical to the preceding one, with the small difference that exactly g weight units are replaced by at most g weight units, which changes the boundary conditions. This is done for getting that the functions z , (·) are monotone non-decreasing, since the more space there is in the knapsack, the more profit we can yield from it. The DP formulation (10)-(11) is therefore a monotone DP. Monotone DPs are known to admit FPTASes, whenever they satisfy some additional technical conditions (see, e.g., Halman et al. (2014), Alon and Halman (2021;2022)). The reason for which we switch from the y(g; ) notation of Algorithm DP3b to the one of z , (g) of DP recurrence (10)-(11) is that we want to have a clear correspondence to the notation used in Halman et al. (2014); Halman (2021, 2022).
In the remaining of this section, we will apply the framework of (Alon & Halman, 2021) to derive an FPTAS for the monotone DP (10)-(11). For the completeness of presentation, we summarize this framework in Appendix A.
In order to show that DP formulation (10)-(11) fits into the framework, first we shall show that DP formulation (10)-(11) can be seen as a special case of DP formulation (12) in the following sense. (i) We set the level index t to be the index j and therefore the number of different levels is T = n, i.e., the number of items to potentially place in the knapsack, (ii) we set the other index i to be multi-dimensional and equal to the vector , therefore, the value of m, i.e., the total number of indices i is the number of combinations j ≤ k j , j = 1, . . . , k for which k j=1 j = , (iii) we set the state variable I t,i to be g, i.e., the remaining available space in the knapsack, (iv) for every level t = and i = we set the additional information to be A , (g) = { j = 1, . . . , k : j ≥ 1, g ≥ w j f w ( )}, which is the set of indices of items that can potentially be placed in the knapsack, (v) when considering level t in (12), instead of using all previously-calculated {z r , j } r <t , we use only z t−1, j , and (vi) we set the boundary functions to be f 0, 0 ≡ 0. Thus, by (i)-(vi), we conclude that DP formulation (10)-(11) is indeed a special case of DP formulation (12).
Next, we shall set the ratio U z of the lower and upper bounds on the values of function z , (g) and the bound U S on the cardinality of the state space. This can be done by assuming, respectively, Finally, we shall show that DP formulation (10)-(11) satisfies Conditions A.1-A.4 as stated in Appendix A. Condition A.1 is satisfied, since by its construction z , (·) is a monotone non-decreasing function. Condition A.2 is satisfied due to the values of U z and U S . As for Condition A.3, it is satisfied via a direct consequence of the calculus of K -approximation functions, and specifically, the linearity, composition, and maximization of approximation rules (see Proposition A.1(2,4,5) in Appendix A). Condition A.4(i) holds, since Eq. (11) consists of maximization over at most k arguments. Therefore, τf t,i = kτz r, j . Hence, applying Theorem A.1 (see Appendix A) with parameter value set to τ f = O(n k ), we get the following result.

Theorem 9 There exists an FPTAS for problem P3b that runs in O n k+1
ε log n log U z ε log U z log C time, where U z = n max j=1,...,n p j f p (1) .
Note that unlike the other FPTASes designed in this paper, whose running times depend only on n and 1 ε , and that are therefore strongly polynomial in the instance size (SFPTASes), the running time of the FPTAS in Theorem 9 depends polynomially on the binary encoding of the numbers in the problem instance and is thus non-strongly polynomial. It is, however, possible to give an SFPTAS using the very recent framework of (Alon & Halman, 2022) for the design of SFPTASes for monotone DPs, and using the same DP recurrence (10)-(11). This SFPTAS framework requires that a monotone DP can be cast as (12) and satisfies Conditions B.1-B.6 stated in Appendix B.
Recall from the discussion above that DP formulation (10)-(11) is a special case of DP formulation (12). Before showing how DP formulation (10)-(11) satisfies Conditions B.1-B.6, we note that Condition B.2 is not satisfied: an upper bound on the value that z , can achieve is U B = n max j=1,...,n p j f p (1) , and a lower bound on every non-zero feasible solution is min j=1,...,n p j f p (1) . However, the ratio n max j=1,...,n p j min j=1,...,n p j is not guaranteed to be strongly-polynomially bounded. Therefore, we apply the SFPTAS framework on a relaxed problem. In the relaxed problem, we drop every item i with p i ≤ ε 2n max j=1,...,n p j . Since is a lower bound on the optimal solution, and we give up on a total profit of no more than ε 2 L B (as there are n items and f p (·) is monotonically non-increasing), the optimal solution of the relaxed problem serves as a ε 2 -approximation of the original one. Therefore, an SFPTAS that ε 3 -approximates the relaxed problem will serve as an SFPTAS for the original problem. We next shall show that DP (10)-(11) for the relaxed problem satisfies the aforementioned six conditions. As discussed above, the functions z , (·) are non-decreasing over {0, . . . , C}, so Condition B.1 holds. As for Condition B.2, we set z min = ε 2n L B as explained above to be a lower bound on every non-zero value of z , (·) and z max = U B to be an upper bound on z , (·), and so U z = z max z min = O n 2 ε . Condition B.3 holds by the linearity, composition, and maximization of approximation rules (Proposition A.1(2,4,5)). Condition B.4 holds, since z , can be calculated in τ f , = O(1) time for every 1 ≤ ≤ n and , as a maximization of up to k former z functions. Therefore, all z , (·) functions can be evaluated (for a single value) in . Therefore, applying Theorem B.1, we obtain the following result closing the paper.
Theorem 10 There exists an FPTAS for problem P3b that runs in O n k+1 ε log 2 n log( n ε ) ε log n ε time.

Conclusions
In this paper, we considered three Position-Dependent Knapsack (PDK) problems which are new knapsack problems with variable position-dependent profits or weights of items. We proposed pseudo-polynomial exact algorithms and fully polynomial-time approximation schemes for these problems. Unlike the SK problem, which is relatively comprehensively researched, there are many unanswered questions related to the PDK problems. It is interesting to understand the impact of monotonicity on our problems. For example, in Sect. 4 we assumed that functions f w and f p are non-increasing for problem P3a and P3b, respectively. Can other assumptions on monotonicity of the functions be solved analogously?
Another group of questions is related to problem P3. For example, it is unknown whether problem P3 is strongly N P-hard or even APX -hard. Does there exist an algorithm with constant worst-case bound, a PTAS or even an FPTAS for problem P3?
Finally, the last group of topics for future research on the PDK problems concerns generalizations of our results to other functions than p j (r ) = p j f p (r ) and w j (r ) = w j f w (r ). (2021) is based on an abstract stochastic DP formulation of the following form. Let 0 ≤ t ≤ T , 1 ≤ i ≤ m, be a pair of integers, where T represents, e.g., the length of a discrete time period, and m represents, e.g., the number of functions to be calculated in parallel in the same time period. For every 0 ≤ t ≤ T , 1 ≤ i ≤ m, let z t,i : S t,i → R + be a non-negative real-valued function, where S t,i is the finite one-dimensional state space of z t,i . One requires that the kth largest element in S t,i can be identified in constant time for every 1 ≤ k ≤ |S t,i |, e.g., S t,i is a contiguous interval of the form {A, . . . , B}, 0 ≤ t ≤ T , 1 ≤ i ≤ m. For any I t,i ∈ S t,i , let A t,i (I t,i ) be additional information which is available in the beginning of time period t and is relevant to function z t,i (·) when being in state I t,i . Typical information in A t,i (I t,i ) includes the description of the action space. The DP formulation reads as follows:

The DP model introduced in Alon and Halman
In other words, in order to calculate the value of z t,i on the state I t,i one needs to know also the additional information A t,i (I t,i ), the functions calculated in previous periods {z r , j } 0≤r <t,1≤ j≤m , as well as to be able to query (calculate) the value of function f t,i on Note that the two indices, t and i, have different roles: for any fixed 0 ≤ t ≤ T , one can calculate in parallel all the functions z t,i for 1 ≤ i ≤ m, as their calculations are based on functions from previous periods only. Therefore, the index t is called a level index, to stress that in any level one can use functions from previous levels only. The other index, i, is used in cases where there are a few functions in the same level (i.e., that have the same value of t) that can be calculated independently from each other, assuming that functions from previous levels are on hand. Note also that both indices of the function f t,i are one-dimensional. However, both can be lifted to be multi-dimensional ones (see, e.g., Alon and Halman (2021, App. A.6)). Let z min and z max denote a lower bound on every non-zero value of z t,i (·) and an upper bound on z t,i (·), respectively. Let U z = z max z min and let U S denote an upper bound on the cardinality of S t,i . The model introduced in Alon and Halman (2021) applies to DPs that satisfy the four conditions given below. The first two conditions relate to the structure of the functions: Condition A.1 requires monotonicity, while Condition A.2 requires that their domain and range are not 'too big'. The objective of Condition A.3 is to make sure that things are not 'ruined', when we use approximate (as opposed to exact) functions in the DP recursion. The last condition comes to verify that the computation time of each of the functions is not 'too big'.

Condition A.2 (bounded size of elements)
The values log U z and log U S are polynomially bounded in the (binary) input size.  ( I t,i , A t,i (I t,i  , is polynomially bounded in the (binary) input size, 1 ε , and in τz r, j . Before stating the main theorem regarding the FPTAS framework, the introduction of a new notation regarding upper bounds on computation times of various functions is needed. Let τ f t,i denote an upper bound on the time needed to evaluate f t,i (I t,i ) on a single point I t,i ∈ S t,i , with the assumption that calls to the previous {z r , j } 0≤r <t,1≤ j≤m are done in constant time,

Appendix B
In this appendix, based upon (Alon & Halman, 2022), a summary of an SFPTAS framework for monotone DPs is given.
Let the dimension of the input be defined as the number of objects in the input, i.e., as if each object would take only constant size. For example, the KP problem instance: 'n items, item i has profit p i and weight w i , i = 1, . . . , n and knapsack has capacity C' has dimension O(n), while its (binary) input size is O log C + n i=1 (log p i + log w i ) . An FPTAS is called strongly polynomial (SFPTAS), if the number of arithmetic operations it performs is polynomially bounded in the dimension of the input and in 1 ε . For example, the number of arithmetic operations that an FPTAS for the KP problem performs may depend on the binary size of the knapsack volume, but that of an SFPTAS for this problem must depend only on the number of items and 1 ε . The definition below defines the set of change points of a function. Definition B.1 (Sets of change points, Alon and Halman (2022, Def. 3.1)) Let ϕ : {A, . . . , B} → R + be a monotone function. Let C ϕ be the ordered set that is resulted from the union of the set of endpoints {A, B} and the ordered set of points, where ϕ strictly changes, i.e., The proposition below gives some general computation rules to manipulate the sets of change points. Proofs of the rules follow directly from Definition B.1.
is an upper bound on the calculation time of ψ −1 1 on any single value of its domain.
The DP model introduced in Alon and Halman (2022) is based on the abstract DP formulation (12). Let z min and z max denote a lower bound on the non-zero values of z t,i (·) and an upper bound on z t,i (·), respectively. Let U z = z max z min . The model applies to DPs that satisfy the six conditions below. The first two conditions relate to the structure of the functions: Condition B.1 requires monotonicity, while Condition B.2 requires that their range is not 'too big'. The objective of Condition B.3 is to make sure that things are not 'ruined', when we use approximate (as opposed to exact) functions in the DP recursion. Condition B.4 comes to verify that the computation time of each of the functions is not 'too big'. The last two conditions come to verify that we have the ability to calculate the sets of change points, and that the cardinality of these sets is not 'too big'.

Condition B.1 (monotonicity) The function z t,i
Condition B.2 (bounded size of range) The value log U z is polynomially bounded in the dimension of the input.

Condition B.3 (approximation invariance under approximate input)
For any real number L ≥ 1 and any I t,i , A t,i (I t,i ), if {z r , j } 0≤r <t,1≤ j≤m are monotone L-approximation functions of {z r , j } 0≤r <t,1≤ j≤m , then f t,i I t,i , A t,i (I t,i ), {z r , j } 0≤r <t,1≤ j≤m is a monotone L-approximation function of f t,i I t,i , A t,i (I t,i ), {z r , j } 0≤r <t,1≤ j≤m .

Condition B.4 (computation time)
For all t = 0, . . . , T and i = 1, . . . , m, there exists an upper bound τ f t,i on the calculation time of z t,i (I t,i ) for any single value I t,i in its domain S t,i , that is polynomially bounded in the dimension of the input, assuming that calls to {z r , j } 0≤r <t,1≤ j≤m are done in constant time.

Condition B.5 (identifiability of change points)
For any real number L ≥ 1 and any I t,i , A t,i (I t,i ), let {z r , j } 0≤r <t,1≤ j≤m be L-approximation functions of {z r , j } 0≤r <t,1≤ j≤m , and Cz r, j be given ordered sets of change points ofz r , j for 0 ≤ r < t, 1 ≤ j ≤ m. Let C max = max t≤T ,i≤m |Cz t,i | . Then there exists an oracle O C t,i = g t,i {Cz r, j } 0≤r <t,1≤ j≤m that returns the ordered set Cz t,i of change points of z t,i (·) = f t,i ( ·, A t,i (·), {z r , j } 0≤r <t,1≤ j≤m ) in time τ C t,i . The value τ C t,i is polynomially bounded in the dimension of the input and in C max . Condition B.6 (bounded sets of change points) One of the following holds: (i) The range of z t,i is Z + for 0 ≤ t ≤ T , 1 ≤ i ≤ m. In addition, the value of log z max is polynomially bounded in the dimension of the input.
(ii) Let Cz r, j , Cz t,i be as denoted in Condition B.5. Then, for every 0 ≤ t ≤ T , 1 ≤ i ≤ m, |Cz t,i | = O a · max 0≤r <t,1≤ j≤m |Cz r, j | , where the term a is polynomially bounded in the dimension of the input.
Remark B.1 Condition B.6(ii) implies, in particular, that |Cz 0,i | is polynomially bounded in the dimension of the input for any i = 1, . . . , m. Applying Condition B.5 with L = 1, we get that also |C z 0,i | is polynomially bounded in the dimension of the input for any i = 1, . . . , m.
Before the main theorem regarding the SFPTAS framework will be stated, the introduction of an additional notation is needed. For any ε > 0, let ConditionB.6(i) holds, min U S , max max 1≤i≤m |C z 0,i | , a T log U z ε , Condition B.6(ii)holds, where a is the term from Condition B.6(ii). Note that due to Condition B.2 coupled with Remark B.1, in both cases U C is strongly polynomial in the input size. As is shown in Alon and Halman (2022, Sect. 3.3.2), U C is an upper bound on the cardinality of the sets of change points generated along the execution of the algorithm. Recall that τ f t,i is an upper bound on the evaluation time of f t,i ( I t,i , A t,i (I t,i ), {z r , j } 0≤r <t,1≤ j≤m ) for any single value I t,i ∈ S t,i , assuming the calls to the various z r , j are done in constant time. Furthermore, recall that τ C t,i is an upper bound on the computation time of Publisher's Note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.