Balancing a Knapsack
Total Page:16
File Type:pdf, Size:1020Kb
Making Change and Finding Repfigits: Balancing a Knapsack Daniel Lichtblau 100 Trade Center Dr Champaign IL 61820 USA [email protected] Abstract. We will discuss knapsack problems that arise in certain computational number theory settings. A common theme is that the search space for the standard real relaxation is large; in a sense this translates to a poor choice of variables. Lattice reduction methods have been developed in the past few years to improve handling of such problems. We show explicitly how they may be applied to computation of Frobenius instances, Keith numbers (also called "repfigits"), and as a first step in computation of Frobenius numbers. Key words. Frobenius instance solving, lattice reduction, integer linear programming, change− making problem, Frobenius numbers, Keith numbers, repfigits. A shorter, differently formatted version of this article appeared in Proceedings of the Second International Congress on Mathematical Software (ICMS 2006), A. Iglesias and N. Takayama, eds. Lecture Notes in Com− puter Science 4151:182−193. Springer−Verlag.2006. 1. Introduction Various problems in the realm of computational number theory have as key steps the solving of a linear equa− tion or system over the integers, subject to some linear inequality constraints. The Frobenius instance problem (also known as the change−making problem) is a well−known example. The problem of finding what are called repfigits, to be described below, is another. These may be regarded as a class of knapsack problems wherein one is allowed to take only certain integer multiples of various items in forming a "valid" combination. As such these fall into the category of integer linear programming (ILP). Classical methods for solving such problems include branch−and−bound and cutting plane methods [8] [16]. These approaches alone are often inadequate for certain classes of problems due to a phenomenon roughly described as "unbalanced bases". A method for dealing with this deficiency was developed in [1] [2]. In essence it involves working with a basis that is reduced (in the sense of [11]) and ordered by size, in conjunction with standard branch−and−bound. We will describe and illustrate this for the types of problem mentioned above . We remark that the handling of Frobenius instances is by no means new, having been discussed in the aforemen− tioned references. We also show how the method is applied in a new algorithm for finding Frobenius numbers, a task that is substantially harder than solving Frobenius instances. The algorithms described in this paper have been implemented in Mathematica [18]. Selected code is provided in the appendix. 2. Frobenius Instances Suppose we have a set of positive integers A = Ha1, ..., anL and a target M, a positive integer. We seek nonnega− tive integer multipliers X = Hx1, ..., xnL such that X × A = M. This is a standard problem in integer linear program− ming. A classical method [16] for solving this would be to solve the relaxed problem wherein we enforce all inequality constraints but all variables to be real rather than integer valued. If in the solution we encounter a variable a with value s that is not an integer then we spawn two subproblems where we enforce respectively that a £ dst and a ³ `sp. We continue this process of solving relaxed subproblems, splitting when a variable has a noninteger value. It can be shown that eventually either we exhaust all possibilities or we obtain an integer valued solution [16]; in either case clearly the algorithm terminates. A drawback to this approach is that the search space for the relaxed subproblems might appear to be "large", in the sense of having many points with not all coordinates integer valued. In particular it may be the case that a standard LP solver will find real valued solutions to the restricted subproblems without making rapid progress to an (entirely) integer valued solution, because it might be possible to subdivide the (real valued) solution 1 standard LP solver will find real valued solutions to the restricted subproblems without making rapid progress to an (entirely) integer valued solution, because it might be possible to subdivide the (real valued) solution polytope in such a way that integer points do not readily appear at corners. The method of [1], [2] was developed as a way to improve on this situation. Roughly it proceeds as follows. First we find a description of a solution set to our equations that is a priori integer valued but possibly does not satisfy the required inequalities. We arrange that this solution set has "good" basis vectors, such that when we solve relaxed problems with these we more rapidly walk through our (real valued) solution polytope. More correctly, the polytope is likely to intersect fewer hyperplanes orthogonal to larger direction vectors and spaced by integral multiples of those vectors. With respect to the Frobenius instance problem it goes as follows. First we find a solution vector X over Zn and n a basis V for the integer null space (that is, n - 1 independent vectors Vj Î Z with Vj × A = 0); for this we use a method based on the Hermite normal form [5]. We use multiples of the basis vectors to find a "small" solution which we still call X. The tactic utilized to do this is sometimes called the embedding method. It apparently has been independently discovered several times; variants appear in [1], [12], [13], and [14], with short code provided in the appendix of this paper. In starting with a solution over Zn rather than the nonnegatives Nn we are working with what is called an integer relaxation of the nonnegativity constraint. We will later enforce nonnegativity via the more common LP relaxations wherein integrality is not enforced. We define variables t = Ht1, ¼, tn-1L so that solution vectors are given by X + t V. For purposes of finding a valid solution to the problem at hand we need to impose two requirements. The first is that all components are nonnegative and the second is that all are integers. The first can be met by standard linear programming. For the second, as in the classical approach, we will use branching on subproblems. Specifically we find solutions to relaxed LP problems wherein we now work over nonnegative reals. We then branch on noninteger values in those solutions. For example, if a solution has, say, tj = 54, we create two subproblems identical to the one we just solved, but with the new constraints tj £ d54t = 1 and tj ³ `54p = 2, respectively (though note that if other variables also had noninteger solutions then we need not have chosen this particular one). As observed above, this branching process will terminate eventually, with either a valid solution or the information that no such solution exists. We explain again, in slightly different terms, why it is important to work with a small integer solution to the integer relaxation (that is, allowing negative values) and a lattice reduced basis for the null vectors. As our methodology is to take combinations of these null vectors, effectively they define directions in a solution polytope for the transformed problem. By working with a reduced basis we in effect change our coordinate system to one where the various search directions are roughly orthogonal. This helps us to avoid the possibility of taking many steps in similar directions in searching the polytope of nonnegative solutions for one that is integer valued. Thus we explore it far more efficiently. Moreover, in starting with a small solution we begin closer to the nonnegative orthant. Heuristically this seems to make the sought−for multipliers of the null vectors relatively small, and this is good for computational speed. This is discussed in section 2 of [1], with further explanation and illustrations found in [3]. A further efficiency, from [2], is to choose carefully the variable on which to branch. We order by increasing size the reduced lattice of null vectors. Branching will be done on the noninteger multiplier variable correspond− ing to the largest of these basis vectors. This has the effect of exploring the solution polytope in directions in which it is relatively thin, thus more quickly finding integer lattice points therein or exhausting the space. This refinement is important for handling pathological examples of the sort presented in [1] and [2]. As we have a constraint satisfaction problem we are also free to impose any linear integer objective function of our choosing. Thus an optimization is to obtain extremal values for linear forms with integer coefficients and use these results as simple cutting planes [16]. For example we can minimize or maximize the various coordi− nate values tj, selecting one either in some specific order or at random for each subproblem. This process amounts to finding the width of the polytope along the directions of our lattice basis vectors, and enforcing integrality of the optimized variable helps to further restrict the search space. 2 As reported in [2] this method is very effective in solving Frobenius instances. We illustrate with an example from [17]. A = H10 000 000 000, 10 451 674 296, 18 543 816 066, 27 129 592 681, 27 275 963 647, 29 754 323 979, 31 437 595 145, 34 219 677 075, 36 727 009 883, 43 226 644 830, 47 122 613 303, 57 481 379 652, 73 514 433 751, 74 355 454 078, 78 522 678 316, 86 905 143 028, 89 114 826 334, 91 314 621 669, 92 498 011 383, 93 095 723 941L We let the target be 862 323 776. In several seconds the instance solver returns the empty set. This has implica− tions for bounding the Frobenius number of A; we will discuss that in a later section.