Index construction device, index construction method, and program
Patent Information
- Application Number
- JP2025519230
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Filing Date
- 2023-05-09
- Publication Date
- 2024-11-14
AI Technical Summary
Existing algorithms for solving k-set selection problems require more than linear time and are unable to find strict optimal solutions efficiently, with storage requirements being excessive for exact solutions, making it difficult to respond quickly to inquiries.
An index construction device and method using a zero-suppressed binary decision graph to efficiently construct an index representing the optimal solution to k-set selection problems, allowing for fast inquiries through dynamic programming and data structures like hash tables and arrays.
The solution significantly reduces calculation time for obtaining optimal values and enables efficient storage and querying of k-set selection problems, facilitating the construction of an index that can handle large-scale set families and perform inquiries like searching and enumeration.
Abstract
Description
Index building device, index building method and program
[0001] The present disclosure relates to an index building device, an index building method, and a program.
[0002] The k-set selection problem is a problem in which, when a set family and an objective function are given, k distinct sets are selected from the set family so as to maximize the objective function. A rigorous method for solving the k-set selection problem is to enumerate all k sets that can be selected, but this takes exponential time.
[0003] Therefore, as a conventional technique for efficiently solving the k-set selection problem, an algorithm for calculation using a decision diagram has been proposed (e.g., Non-Patent Documents 1 and 2). In addition, a conventional technique for efficiently finding an approximate solution to the k-set selection problem is also known (e.g., Non-Patent Document 3).
[0004] David Bergman, Andre A. Cire, Willem-Jan van Hoeve, and John Hooker. Decision Diagrams for Optimization. Artificial Intelligence: Foundations, Theory, and Algorithms. Springer, 2016.David Bergman, Andre A. Cire, Willem-Jan van Hoeve, and JN Hooker. Discrete optimization with decision diagrams. INFORMS Journal on Computing, 28(1):47-66, 2016. Julien Baste, Lars Jaffke, Tomas Masarik, Geevarghese Philip, and Gunter Rote. FPT algorithms for diverse collections of hitting sets. Algorithms, 12(12):254, 2019.
[0005] However, the algorithms proposed in Non-Patent Documents 1 and 2 require a time linear or greater than the number of sets included in a given set family, while the method described in Non-Patent Document 3 cannot find an exact optimal solution. Even if an exact optimal solution can be found in a short time, storing the set family that is the optimal solution in its original form will consume a large amount of memory space, and furthermore, it will not be possible to quickly respond to queries such as searches, counting, and enumeration.
[0006] The present disclosure has been made in consideration of the above points, and provides a technique that can construct an index that can efficiently answer queries regarding exact solutions to k-set selection problems.
[0007] An index construction device according to one aspect of the present disclosure is an index construction device that constructs an index that represents a family of sets that is an optimal solution to a k-set selection problem, and includes: an input unit that inputs a zero-suppressed binary decision diagram that represents the family of sets in the k-set selection problem, an objective function that satisfies certain constraints, and k that is 2 or greater; a calculation unit that calculates information for constructing the index using the zero-suppressed binary decision diagram, the objective function, and the k; and an index construction unit that uses the information to construct, as the index, a data structure that represents the family of all sets for which the objective function is maximized.
[0008] Techniques are provided that allow for the construction of indexes that can efficiently answer queries about exact solutions to k-set selection problems.
[0009] 1 is a diagram illustrating an example of a hardware configuration of an index building device according to the present embodiment. FIG. 2 is a diagram illustrating an example of a functional configuration of an index building device according to the present embodiment. FIG. 3 is a flowchart illustrating an example of the flow of index building processing according to the present embodiment. FIG. 4 is a diagram illustrating an example of an algorithm of a DP_MAIN function. FIG. 5 is a diagram illustrating an example of an algorithm of a DP_TRANSITION function. FIG. 6 is a diagram illustrating an example of an algorithm of a FIND_SAME_PAIRS function. FIG. 7 is a diagram illustrating an example of an algorithm of an EXTEND_FROM_SAME_PAIRS function. FIG. 8 is a diagram illustrating an example of an algorithm of an INDEX_CONSTRUCT function. FIG. 9 is a diagram illustrating an example of an algorithm of an INDEX_CONSTRUCT_RECUR function. FIG. 10 is a flowchart illustrating an example of the flow of inquiry answering processing according to the present embodiment. FIG. 11 is a diagram illustrating an example of an algorithm of a MEMBERSHIP function. FIG. 12 is a diagram illustrating an example of an algorithm of a GET_TRANSITION_SEQUENCE function. FIG. 13 is a diagram illustrating an example of an algorithm of a SEARCH function. FIG. 14 is a diagram illustrating an example of an algorithm of a COUNT function. FIG. 15 is a diagram illustrating an example of an algorithm of a COUNT_RECUR function. 10 is a diagram showing an example of an algorithm for a PARTIAL_PERM function; FIG. 11 is a diagram showing an example of an algorithm for an ENUMERATE function; FIG. 12 is a diagram showing an example of an algorithm for an ENUM_RECUR function; and FIG. 13 is a diagram showing an example of an algorithm for an ENUM_RECUR_ASSIGN function.
[0010] An embodiment of the present invention will be described below.
[0011] <Preparation> ・Family of Sets Let a set consisting of multiple items be a universal set U. In this case, a family of sets is a genus F ⊆ 2 consisting of a set of items included in the universal set U. U This is what I mean.
[0012] The k-set selection problem is a problem in which, when a set family and an objective function are given, k distinct sets are selected from the set family that maximize the objective function. Examples of the k-set selection problem include the following:
[0013] Diversity maximization: This is a problem of maximizing the sum of the Hamming distances between all pairs of sets among k selected sets.
[0014] Set Covering: The problem of choosing k sets such that all items in the universal set occur.
[0015] Antenna placement: The problem is to select k antennas so that as many buildings as possible are included, with the elements of the set being considered as buildings and the set being considered as buildings covered by the antennas.
[0016] Value maximization: This is a problem of selecting k sets so that the value of the elements contained in the selected sets is maximized, assuming that the value of each element varies depending on the number of times that element is selected.
[0017] Decision graphs are known as data structures that can compress and represent discrete structures. Decision graphs include binary decision diagrams (BDDs, Reference 1), which can represent logical functions, and zero-suppressed binary decision diagrams (ZDDs, Reference 2), which can represent sets. It is known that the efficiency of approaches to solving problems such as the k-set selection problem using decision graphs such as ZDDs depends on the size of the decision graph representing the set set (i.e., the number of nodes in the decision graph).
[0018] Definition of ZDD A ZDD is a variant of a BDD and is a data structure that can manipulate a finite set. A ZDD is a directed acyclic graph (DAG) that satisfies the following properties:
[0019] ZDD Z is a set of eight Z = (U, V, λ, δ 0 , δ 1 , r, ⊥, T). Note that while the symbols ⊥ and T are generally used to represent terminal nodes, uptack and downtack symbols, respectively, in the text of this specification they are substituted by the vertical symbol "⊥" and capital tau "T."
[0020] U = {1, ..., |U|} represents the universal set, and each element corresponds to the item we want to handle. ZDD has two types of nodes: terminal nodes and non-terminal nodes. V is the set of all non-terminal nodes, and ⊥ and T represent terminal nodes, respectively. r∈V represents the root of ZDD. All nodes in ZDD are reachable from the root r.
[0021] Each node in a ZDD has a label belonging to U∪{0}, and λ represents a label function that extracts a label from a node. That is, λ:V∪{⊥,T}→U∪{0}, and the label of a node v can be obtained by λ(v). The label of a non-terminal node is one of the items in the universal set U, and the label of a terminal node is 0.
[0022] Each non-terminal node has two children, called the 0-child and the 1-child. For a non-terminal node v∈V, δ 0 (v) is its 0-child, δ 1 (v) represents its 1-child. An edge from a non-terminal node to its 0-child is called a 0-edge, and an edge from a non-terminal node to its 1-child is called a 1-edge.
[0023] For any non-terminal node v∈V, λ(v)>λ(δ 0 (v)) and λ(v)>λ(δ 1 (v)) holds, i.e., it is guaranteed that any non-terminal node will always have a label greater than its children.
[0024] The size of ZDD Z is defined as the number of its non-terminal nodes, denoted as |Z|. Also, the set of non-terminal nodes V i Let {v|∀v∈V, λ(v)=i} be the set of nodes belonging to level i. Furthermore, |V for 1≦i≦|U| i The maximum value of | is called the width of the ZDD.
[0025] ・The set family represented by ZDD is ZDD Z = (U, V, λ, δ 0 , δ 1 , r, ⊥, T) represents the family of sets F(r) on the universal set U. However, F(r) can also be written as F(Z).
[0026] The set family F(v) represented by each node v is recursively defined by the following (1) and (2).
[0027] (1) When node v is a terminal node: if v=T, then F(v)={φ}, and if v=⊥, then F(v)=φ.
[0028] (2) If node v is a non-terminal node: F(v) = {λ(v)} × F(δ 1 (v)) ∪ F(δ 0 (v)).
[0029] From the above definition, the set s = {e 1 , ..., e d} corresponds to the following path from the root on the ZDD Z: Start the path from the root, and at a non-terminal node with label e, if e∈s, extend the path to a 1-edge, otherwise extend the path to a 0-edge. This will eventually result in a path that reaches one of the terminal nodes.
[0030] If a path reaches T, it means that s∈F(Z), and if it reaches ⊥, it means that s∈F(Z) is not true. Therefore, there are |F(Z)| paths from the root r to the terminal node T. The number of paths from node v to the terminal node T is called the cardinality of v, and is represented by |F(v)|.
[0031] <Formulation of k-sets selection problem> Based on the above preparations, the k-sets selection problem to be addressed in this embodiment is formulated.
[0032] set family F⊆2 U and k∈N + (where k ≥ 2, N + is the set of all non-zero positive integers), and the objective function g: (2 U ) k →R (where R is the set of all real numbers), the k-set selection problem is 1 , ..., s k For ∈F, g(s 1 , ..., s k ) where 1≦i<j≦|U| i ≠s j is.
[0033] That is, in this embodiment, the objective function g is a function that takes k sets as arguments and returns a real number. The objective function g also satisfies the following constraints 1 and 2.
[0034] Constraint 1: The objective function g is g(s 1 , ..., s k ) = I◇ n g n ([n∈s 1 ], ..., [n∈s k ])◇ n-1 ...◇ 1 g 1 ([1∈s 1 ], ..., [1∈s k ]), where n = |U| and ◇ i (1≦i≦n) is any left-associative operator (typical examples include addition, multiplication on positive real numbers, etc.), and I is ◇ n is the identity element of g. 1 , ..., g n is a function that takes k arguments of 0 or 1 and returns a real number. Also, in the calculation process, for any a, b, c∈R (where R is the set of all real numbers) and a≦b, a◇ i c≦b◇ i It is guaranteed that c.
[0035] Also, square brackets [.] are unary operators that return 1 if the contents of the brackets are true, and 0 if they are false.
[0036] each g i is a symmetric function. i The value of g is determined only by how many times element i appears in the k sets of arguments of g. For simplicity, we will use the following to define g when element i appears x times in the k sets. i The value of "g i (x)" That is, x = [i∈s 1 ]+・・・+[i∈s k ].
[0037] Constraint 2: The value of g can be calculated in Θ(|U|) time when the number of times each element appears in the selected k sets is known.
[0038] If the objective function satisfies the above constraints 1 and 2, it can be efficiently optimized using the algorithm described below. Hereinafter, such a function will be referred to as a "factorizable function." Generally, when calculating the value of an objective function, all of its arguments must be known. On the other hand, if the objective function is a factorizable function, the value of the objective function can be calculated partially by determining how many times a certain element appears in the input.
[0039] Below, we will explain an index construction device 10 that can represent, with a small storage area, a set family that is the optimal value (maximum objective function value) for the k-set selection problem formulated above, and that can construct an index that can quickly respond to queries such as searching, counting, enumeration, etc. We will also explain how to use this index to respond to queries such as searching, counting, enumeration, etc.
[0040] <Example of Hardware Configuration of Index Building Device 10> An example of the hardware configuration of the index building device 10 according to this embodiment is shown in Fig. 1. As shown in Fig. 1, the index building device 10 according to this embodiment has an input device 101, a display device 102, an external I / F 103, a communication I / F 104, a RAM (Random Access Memory) 105, a ROM (Read Only Memory) 106, an auxiliary storage device 107, and a processor 108. Each of these pieces of hardware is connected to each other so as to be able to communicate with each other via a bus 109.
[0041] The input device 101 is, for example, a keyboard, a mouse, a touch panel, a physical button, etc. The display device 102 is, for example, a display, a display panel, etc. Note that the index building device 10 does not necessarily have to have at least one of the input device 101 and the display device 102, for example.
[0042] The external I / F 103 is an interface with an external device such as a recording medium 103a. Examples of the recording medium 103a include a CD (Compact Disc), a DVD (Digital Versatile Disk), an SD memory card (Secure Digital memory card), and a USB (Universal Serial Bus) memory card.
[0043] The communication I / F 104 is an interface for connecting the index building device 10 to a communication network. The RAM 105 is a volatile semiconductor memory (storage device) that temporarily stores programs and data. The ROM 106 is a non-volatile semiconductor memory (storage device) that can store programs and data even when the power is turned off. The auxiliary storage device 107 is a storage device (storage device) such as an HDD (Hard Disk Drive), an SSD (Solid State Drive), or a flash memory. The processor 108 is various types of arithmetic devices such as a CPU (Central Processing Unit) or a GPU (Graphics Processing Unit).
[0044] 1 is an example, and the hardware configuration of the index building device 10 is not limited to this. For example, the index building device 10 may have multiple auxiliary storage devices 107 or multiple processors 108, may not have some of the hardware shown in the figure, or may have various types of hardware other than the hardware shown in the figure.
[0045] <Example of functional configuration of index building device 10> Fig. 2 shows an example of the functional configuration of the index building device 10 according to this embodiment. As shown in Fig. 2, the index building device 10 according to this embodiment has an input unit 201, a calculation unit 202, an index building unit 203, and a query response unit 204. Each of these units is realized, for example, by a process in which one or more programs installed in the index building device 10 are executed by the processor 108 or the like. The index building device 10 according to this embodiment also has a database 205. The database 205 is realized, for example, by the auxiliary storage device 107 or the like. However, the database 205 may also be realized, for example, by a storage device or the like connected to the index building device 10 via a communication network. Here, the index building device 10 stores a set family F ⊆ 2 U ZDD Z represents k∈N + (However, N + is the set of all natural numbers greater than or equal to 2), and the objective function g: (2 U ) k →R (where R is the set of all real numbers). On the other hand, a query related to searching, counting, or enumeration is given to the index building device 10 when answering a query. Note that ZDD Z can be constructed, for example, by the method described in Reference 3, etc. Furthermore, the index building device 10 when answering a query may be called, for example, a "query answering device."
[0046] The input unit 201 receives a given ZDD Z and k∈N + and the objective function g.
[0047] The calculation unit 202 calculates the ZDD Z and k∈N input by the input unit 201. + and the objective function g, it is possible to express the set family that is the optimal value of the k-set selection problem in a small storage area, and to construct an index that can quickly respond to queries such as search, counting, and enumeration (hash table h, which will be described later). i , array H i , sequence E i ) is calculated. Here, the calculation unit 202 includes a preprocessing unit 211 and an operation unit 212.
[0048] As a preprocessing step, the preprocessing unit 211 converts the ZDD Z to satisfy the constraints of a QDD (Quasi Decision Diagram). A QDD is a ZDD to which nodes are added so that the label difference between all parent and child nodes is 1. That is, a QDD is a ZDD to which the following constraints are added, and is a subgraph of a ZDD: for every non-terminal node v, λ(v) = λ(δ 0 (v)) + 1 and λ(v) = λ(δ 1 (v)) + 1. The method of converting a ZDD to satisfy the constraints of a QDD is an existing method, and is described in, for example, Reference 4.
[0049] In addition, the preprocessing unit 211 generates a hash table h for 0≦i≦|U| as preprocessing. i :(V i ×N + ) * →N (where N is the set of all integers greater than or equal to 0). i ×N + ) * (V i ×N + ) are repeated 0 or more times. These hash tables are used to assign unique numbers (IDs) to states called frontier states, and the IDs of frontier states at each level are assigned starting from 0 in the order they are found. Frontier states are fingerprints used to determine whether intermediate states that arise during the calculation process are equivalent, and their definition will be explained later.
[0050] Here, h is a hash table, and the following operations are defined as operations on this hash table h.
[0051] h. add(key, value): Registers the value corresponding to the key in the hash table h.
[0052] h. find(key): retrieves a value corresponding to the key from the hash table h. However, if the value corresponding to the key is not registered in the hash table h, NULL is returned.
[0053] Furthermore, the preprocessing unit 211 generates an array H i and an array O for storing the maximum value of the objective function for each frontier state. i and an array E for storing the transitions between frontier states. i Prepare the following.
[0054] The operation unit 212 performs dynamic programming (DP) on the ZDD Z that satisfies the constraints of the QDD to calculate information for constructing an index.
[0055] The index construction unit 203 creates a hash table h i and array H i and array E i and the number of types of frontier states at each level, a directed acyclic graph (DAG) is constructed as the target index. The index construction unit 203 stores the index in the database. The index is used to find the optimal solution to the k-set selection problem (i.e., g(s 1 , ..., s k ) is maximized 1 , ..., s k ∈F (where s for 1≦i<j≦|U| i ≠s j ) is a data structure that represents all of the
[0056] The inquiry response unit 204 uses an index stored in the database 205 to find an answer to the given inquiry, and sends the answer to the source of the inquiry.
[0057] The database 205 stores the index constructed by the index construction unit 203 .
[0058] <Flow of Index Building Process> The flow of index building process according to this embodiment will be described below with reference to FIG.
[0059] The input unit 201 receives a given ZDD Z and k∈N + and the objective function g are input (step S101).
[0060] Next, the calculation unit 202 calculates the ZDD Z and k∈N input in step S101.+ and the objective function g, the DP_MAIN function is executed (step S102). The DP_MAIN function is + and the objective function g are used as inputs to generate a hash table h i and a function to calculate the values to be stored in each array, and the details of the algorithm will be described later.
[0061] Next, the index construction unit 203 calculates the information calculated in step S102 (hash table h i , array H i , sequence E i , the number of types of frontier states at each level) is used to execute the INDEX_CONSTRUCT function (step S103). i and array H i and array E i and the number of types of frontier states at each level, and constructs a directed acyclic graph that will be the target index. The details of the algorithm will be described later. The INDEX_CONSTRUCT function outputs a pair (G, q) consisting of a directed acyclic graph G that represents the index and its root node q.
[0062] Then, the index creation unit 203 stores (G, q) obtained in step S103 in the database 205 (step S104).
[0063] <Algorithm of DP_MAIN function> The DP_MAIN function is ZDD Z and k∈N + and the objective function g are input, and information for constructing the index (hash table h i and the values stored in each array). Here, ZDD Z and the objective function g can be accessed from functions other than the DP_MAIN function. Also, each function including the DP_MAIN function uses a list as a data structure. 1 , ..., e d A list consisting of 1 , ..., e d) In addition, the following operations are defined as operations on the list L.
[0064] L. push(e): Adds element e to the end of list L. L. pop(): Deletes the element at the end of list L. The element at the beginning of a list is also called the first element or the first element of the list.
[0065] The algorithm of the DP_MAIN function will be explained below with reference to FIG. 4. This algorithm aims to maximize the objective function g by selecting k distinct sets from the set family represented by ZDD Z. Selecting k sets from ZDD Z is equivalent to selecting k paths from the root to T. Therefore, the goal is to select k optimal r-T paths. Note that paths are not extracted one by one and exhaustively selected, but the optimal k paths are constructed in parallel from the root upwards. The hash table h obtained by the dynamic programming executed by this DP_MAIN function is i (0≦i≦|U|), the number of types of frontier states at each level m i (0≦i≦|U|), array H i , E i (0≦i≦|U|) is output to the index building unit 203 .
[0066] The preprocessing unit 211 transforms the ZDD Z so that it satisfies the constraints of the QDD (line 1). This transformation ensures that all paths in the transformed ZDD Z pass through |U| nodes from the root r to T.
[0067] The preprocessing unit 211 generates a hash table h for each level i (0≦i≦|U|). i :(V i ×N + ) * → Prepare N (where N is the set of all integers greater than or equal to 0) (line 2).
[0068] The preprocessing unit 211 creates an array H as a reverse lookup table for obtaining the frontier state from the ID. i (0≦i≦|U|) is prepared (line 3).
[0069] The preprocessing unit 211 stores an array O for storing the maximum value of the objective function that can be realized in each frontier state. i (0≦i≦|U|) is prepared (line 4). i The mth element of O i [m] stores the maximum value of the objective function that can be realized in the frontier state that belongs to level i and has ID m.
[0070] Here, assume that there are k paths from the root of ZDD Z to a node (node) belonging to level i. Note that it is okay if there are duplicate paths. Let P be the (multiple) set consisting of these k paths, and let P' be the set obtained by removing duplicate paths from this multiset P.
[0071] Then, the frontier state S for a multiset P is defined as follows:
[0072] The frontier state S is V × N + Hereinafter, a pair included in the frontier state is called a "node weight pair."
[0073] A node weight pair (v, w) indicates that w paths from the root follow the same route to reach node v. We will therefore denote the path extension from node v by x, and call the triple (v, w, x) for the node weight pair (v, w) a "branch triple." A branch triple (v, w, x) means that x paths are extended from node v to the 1-edge side, and w-x paths are extended to the 0-edge side. We will also call the list of branch triples for all node weight pairs included in the frontier state a "level transition."
[0074] The preprocessing unit 211 stores an array E i (0≦i≦|U|) is prepared (line 5). Here, the array E i The mth element E i[m] stores a list of all transitions from level i+1 that realize the maximum value of the frontier state that belongs to level i and has ID m.
[0075] The operation unit 212 executes lines 6 to 9. First, since the only possible frontier state at the root level is one in which all the endpoints of k paths are gathered at the root, the operation unit 212 combines the frontier state ((r, k)) and I with h |U| (line 6). Thereafter, starting from the root level, k paths are simultaneously extended one level at a time, and the optimal solution up to the intermediate levels is calculated. Next, the operation unit 212 loops from the root level l = |U| to the level l = 1, which is one level above the terminal node (line 7), and executes the DP_TRANSITION function using all the frontier states found at each level and the value a for that frontier state (lines 8 and 9). Here, m l is the number of frontier states present at level l. The value a is the partial maximum value of the objective function that can be realized at that frontier state. The DP_TRANSITION function takes a frontier state and the value for that frontier state as input, finds all frontier states at the next level to which a transition can be made from that frontier state, and updates the hash table and array. Details of the algorithm of the DP_TRANSITION function will be described later.
[0076] Note that one frontier state corresponds to one unique subproblem in dynamic programming, i.e., two different sets of paths are equivalent at that level if they lead to the same frontier state.
[0077] Finally, the calculation unit 202 returns to the caller of the DP_MAIN function (line 10).
[0078] <Algorithm of DP_TRANSITION function> The DP_TRANSITION function takes a list (v 1 , w 1 ), ..., (v d , w d) and the value a for that frontier state as input. Now, if the current level is l, then v i ∈V l (1≦i≦d), and w 1 +...+w d = k. Also, V l It is assumed that there is a total order and the list is sorted in ascending order. a represents the partial maximum value of the objective function that can be realized in the current frontier state. Note that the variables l and h l-1 , H l-1 , O l-1 , E l-1 represents the same as the DP_MAIN function.
[0079] The algorithm of the DP_TRANSITION function will now be described with reference to FIG.
[0080] The operation unit 212 creates an empty list L for storing the frontier states of the next level (first line).
[0081] The operation unit 212 creates an empty list T for storing level transitions (line 2).
[0082] The operation unit 212 calls the FIND_SAME_PAIRS function to find all frontier states at the next level that are reachable from the current frontier state (line 3). The FIND_SAME_PAIRS function tries all possible paths to determine how many of the w paths should be extended to the 0-edge side and how many should be extended to the 1-edge side for each node weight pair (v, w) included in the current frontier state, and generates all frontier states at the next level determined by these paths.
[0083] <Algorithm of FIND_SAME_PAIRS function> The FIND_SAME_PAIRS function returns a list (v 1 , w 1 ), ..., (v d , w d )), a list L, m, a list T, x, and a value a for its frontier state. Now, if the current level is l, then v i ∈V l(1≦i≦d), and w 1 +...+w d = k. Also, V l is assumed to have a total order, and the list is sorted in ascending order. L is a list representing the frontier state of the next level to which the current frontier state will transition, m is the ID of the current frontier state, T is a list representing the level transition, x is the number of paths extended to the 1-edge side at the current level, and a is the partial maximum value of the objective function that can be realized at the current frontier state. x is used to calculate the objective function. Note that the variables l and h l-1 , H l-1 , O l-1 , E l-1 represents the same as the DP_MAIN function.
[0084] The algorithm of the FIND_SAME_PAIRS function will be described below with reference to FIG.
[0085] If the current frontier state is an empty list (d = 0 on line 1), the operation unit 212 executes lines 2 to 16 and returns to the caller (line 17), since this indicates that all processing of the current frontier state has been completed. That is, since elements with a weight part of 0 are redundant node-weight pairs, the operation unit 212 first deletes elements with a weight part of 0 from L and then rearranges L in ascending order to obtain L' (line 2). Next, the operation unit 212 rearranges the list T representing level transitions in ascending order to obtain T' (line 3).
[0086] Next, the operation unit 212 calculates the hash table h l-1 If it is already registered, the ID of the frontier state (that is, the ID of the current frontier state) m' is obtained (line 4).
[0087] Next, the operation unit 212 calculates the value a◇ of the objective function realized by calling the FIND_SAME_PAIRS function. l g l (x) is the maximum value O in the frontier state of ID “m′” (i.e., the current frontier state). l-1 If it exceeds [m'] (line 5), O l-1[m'] to a◇ l g l (x) (line 6). Also, since the maximum value has been updated, the operation unit 212 updates E l-1 After completely clearing [m'] (line 7), its contents are set to a list consisting only of (m, T') (line 8). This indicates that the maximum value in the frontier state of ID "m'" is realized by the level transition from the frontier state of ID "m" to T'.
[0088] On the other hand, a◇ l g l (x) is the maximum value O in the current frontier state l-1 If it matches [m'] (line 9), the operation unit 212 l-1 Add (m, T') to [m'] (line 10). This is because l-1 In addition to the transitions stored in [m'], the maximum value O l-1 This means that a new transition (m, T') that realizes [m'] has been found.
[0089] The operation unit 212 calculates the hash table h l-1 If the ID is not yet assigned (line 11), the ID is set to m l-1 and store it in the hash table h l-1 (line 12). Next, the operation unit 212 registers the reverse lookup array H l-1 [m l-1 ] is substituted with L' (line 13). Also, the operation unit 212 substitutes the current maximum value a◇ for L'. l g l (x) to O l-1 [m l-1 ] (line 14), and l-1 [m l-1 ] is a list consisting of only (m, T') (line 15). l-1 is incremented to be the next ID to be assigned (line 16).
[0090] Since the operation unit 212 has completed all processing of the current frontier state, it returns to the caller of the FIND_SAME_PAIRS function (line 17) regardless of whether an update has occurred.
[0091] On the other hand, if the current frontier state is not an empty list (i.e., if the current frontier state is still being processed), the operation unit 212 executes lines 18 to 22. If the frontier state contains multiple identical node weight pairs, simply trying all possible branches for all of those pairs would result in the same frontier state being generated repeatedly. Therefore, by extracting and arranging identical node weight pairs together, and extending more of the node weight pairs to the 0-edge side as they are further to the left, repeated extension of the same path can be avoided. In other words, by imposing a constraint that the number of extensions to the 1-edge side is monotonically non-decreasing, it is possible to avoid redundant calculation of the same transition.
[0092] The operation unit 212 selects the first element of L (v 1 , w 1 ) is prepared, and c is initialized to 1 since there is always one head element itself (line 18).
[0093] The operation unit 212 performs the operation (v) within a range that does not exceed the size of the list L (i.e., within a range of c+1≦d). 1 , w 1 ) (line 19), and increments c by 1 each time such a node weight pair is found (line 20). Note that since list L is sorted in ascending order, if identical node weight pairs exist, they are adjacent. Therefore, the method in lines 19 and 20 can find all node weight pairs that are identical to the first element.
[0094] The operation unit 212 sets j as a variable representing the minimum number of branches that can be extended to the 1-branch side. 1 and 0-child δ 0 (v 1 ) and the smaller of the two concentrations is w 1 Let the value obtained by subtracting from be j (line 21). This means that if there is no particular reason, there can be no problem with the number of paths extended to the 1-branch side being 0. 0 (v1 ) concentration is w 1 If it is smaller than 0-δ 0 (v 1 ) must be extended to the 1-edge side. In other words, among the w paths that have the same route from the root to node v, δ 1 (v) The maximum extension to the side is |δ 1 (v) | Book, δ 0 (v) The maximum extension to the side is |δ 0 (v) | paths, and the number of different paths from node v to T is at most |v|. Therefore, if the number of paths that have traveled the same route is greater than or equal to |v| and reach v, it becomes impossible to select different sets.
[0095] The operation unit 212 calls the EXTEND_FROM_SAME_PAIRS function and 1 There are c pieces in 1 We try all methods to extend the end points of the paths and count the total number of paths x that have been extended to the 1-branch side (line 22). 1 , w 1 ,c,j,((v c+1 , w c+1 ), ..., (v d , w d )), L, m, T, x, and a are given as input. In this EXTEND_FROM_SAME_PAIRS function, there are c (v 1 , w 1 ) in order, the number of branches extended to the 1-branch side is made to be monotonically non-decreasing.
[0096] <Algorithm of EXTEND_FROM_SAME_PAIRS function> The EXTEND_FROM_SAME_PAIRS function takes the node weight pair (v, w) currently being considered, its number c, the minimum number j that can be extended to the 1-edge side for this node weight pair (v, w), and a list of the remaining node weight pairs (v 1 , w 1 ), ..., (v d , w d)), a list L, m, T, x, and the value a for the current frontier state, where ((v 1 , w 1 ), ..., (v d , w d )) are sorted in ascending order, L is a list representing the frontier state of the next level to which the current frontier state will transition, m is the ID of the current frontier state, and T is a list representing the method of extending paths when transitioning from the current frontier state to the frontier state of the next level, with its elements being branch triples. x represents the number of paths extended to the 1-edge side at the current level, and a represents the partial maximum value of the objective function that can be realized in the current frontier state. The algorithm of the EXTEND_FROM_SAME_PAIRS function will now be described with reference to FIG. 7.
[0097] If c = 0 (line 1), the operation unit 212 calls the FIND_SAME_PAIRS function again (line 2), and then returns to the caller of the EXTEND_FROM_SAME_PAIRS function (line 3). This causes the process to repeat, searching for an element equal to the first node weight pair. Note that the case of c = 0 indicates that all processes related to node weight pairs equal to (v, w) have been completed.
[0098] If c≠0, (v, w) is still being processed, so the operation unit 212 executes lines 4 to 11. The minimum number of branches that can be extended to the 1-branch side is given by j, and the maximum number of branches that can be extended to the 1-branch side is w or the 1-child δ of v. 1 (v), whichever is smaller. Therefore, the operation unit 212 calculates the 1-child δ of i=j to w or v. 1 (v) and (v) are looped to find the smaller one, and all possible stretching methods are actually tried (line 4).
[0099] If the number of paths extended to the 1-edge side is i, then the w-i path will reach the 0-child of node v at the next level, and i paths will reach the 1-child of node v. Therefore, the operation unit 212 adds these to the frontier state at the next level (lines 5 and 6). The operation unit 212 also adds a branch triple (v, w, i) to T, which indicates how the paths are extended at this time (line 7). Then, to continue processing the node weight pair (v, w), the operation unit 212 calls the EXTEND_FROM_SAME_PAIRS function again (line 8). At this time, the EXTEND_FROM_SAME_PAIRS function is passed v, w, c-1, i, ((v 1 , w 1 ), ..., (v d , w d )), L, m, T, x+i, and a are given as input. That is, since one (v, w) has been processed, c is decreased by 1, and i is given as an input to the EXTEND_FROM_SAME_PAIRS function to make the number of extensions to the 1-branch side monotonically non-decreasing.
[0100] After returning from the call of the EXTEND_FROM_SAME_PAIRS function on line 8 above, the operation unit 212 deletes the element added on line 7 from T and deletes the elements added on lines 5 and 6 from L (lines 9 to 11) in order to return the frontier state of the next level to the state before extending i branches from (v, w) to the 1-branch side.
[0101] <Algorithm of INDEX_CONSTRUCT function> The INDEX_CONSTRUCT function uses a hash table h i (0≦i≦|U|) and the number of types of frontier states at each level m i (0≦i≦|U|) and array H i (0≦i≦|U|) and array E i (0≦i≦|U|) is used as input, and the output is a pair of a directed acyclic graph G representing the index and its root node q. This index is a directed acyclic graph representing all sets of size k that are optimal solutions to the k-set selection problem, and the labels of the nodes are the frontier states (V×N + ) * , the edge label is the path extension from the frontier state (V × N+ ×N + ) * Note that the actual input given to the INDEX_CONSTRUCT function is the hash table h i (0≦i≦|U|), and other inputs are stored in a memory or the like, for example.
[0102] The algorithm of the INDEX_CONSTRUCT function will be described below with reference to FIG.
[0103] First, the index construction unit 203 creates an empty graph G = (N, A) (where N is a node set and A is an edge set) (line 1). Both the node set N and the edge set A are empty sets. Each node in the directed acyclic graph G, which serves as the index, corresponds to a frontier state where an optimal solution can be reached, and the edges correspond to the transition from a frontier state to the next frontier state. The edges are assigned a label indicating the level transition when transitioning from the frontier state corresponding to the parent node to the frontier state corresponding to the child node.
[0104] Next, the index construction unit 203 creates an array D i (Line 2) This array D i The initial value of each element is NULL, and it is stored as soon as the corresponding node is created. Note that since it is not always possible to reach the optimal solution from all frontier states, there may be array elements that remain NULL even after this function has finished.
[0105] Below, the hash table h i (0≦i≦|U|) and the array E i All frontier states that can reach the optimal solution are searched for using the array E i stores information that allows a frontier state at a lower level to be traced backward to a frontier state at a higher level by executing the DP_MAIN function.
[0106] The index construction unit 203 sets a list consisting of k (T, 1) frontier states, which are the only frontier states at the level of the terminal endpoint, as the initial frontier state from which to start the search (line 3). The index construction unit 203 also stores m, which is the ID of the frontier state, in the hash table h 0 Obtained from (line 4).
[0107] Next, the index construction unit 203 calls the INDEX_CONSTRUCT_RECUR function to construct the index in order from the node that is the end of the index (line 5). Note that the INDEX_CONSTRUCT_RECUR function takes l and m as inputs, but here l=0 and m=h. 0 .find(L) is given.
[0108] Then, the index construction unit 203 |U| Let [0] be q (line 6), and output (G, q) (line 7). Here, the frontier state corresponding to the root of G is the frontier state belonging to the highest level, and there exists only a frontier state consisting of only (r, k). Also, since only this frontier state exists at the highest level, the ID of this frontier state is 0. Therefore, D |U| The node of G corresponding to the frontier state is stored in [0]. The node of G corresponding to the frontier state of level l and ID m is stored in D l It is stored in [m].
[0109] <Algorithm of INDEX_CONSTRUCT_RECUR Function> The INDEX_CONSTRUCT_RECUR function takes as input a level l and m, which is the ID of a frontier state, and creates a node in G corresponding to the frontier state with ID m at level l, and an edge leading to that node.
[0110] The algorithm of the INDEX_CONSTRUCT_RECUR function will be explained below with reference to FIG. iIn this case, it is possible to refer to the frontier state before the transition from a frontier state at a lower level to a frontier state at a higher level, so the relationship is reversed and an edge is created from the higher level to the lower level. Specifically, the calculation starts from the only frontier state belonging to level 0, and all frontier states that can reach the optimal solution are traversed by depth-first search.
[0111] If a node of G corresponding to m, which is the ID of the current frontier state, has already been created (line 1), the index constructor 203 outputs that node (line 2), because in this case it is guaranteed that the frontier states above it have also been calculated.
[0112] If a node of G corresponding to m, which is the ID of the current frontier state, has not been created (line 3), the index creation unit 203 creates a node u having the current frontier state L as a label (line 4) and adds it to the node set N (line 5). l Store in [m] (line 6).
[0113] Next, the index construction unit 203 repeatedly executes lines 8 to 10 for each of the frontier states at the next higher level that have achieved the maximum value of the current frontier state and their IDs (line 7). l From [m], information can be extracted that the ID of the frontier state is m' and that it has been reached from m' to m by a level transition T.
[0114] The index construction unit 203 recursively calls the INDEX_CONSTRUCT_RECUR function using the next higher level l+1 and the ID of the frontier state m' as input, and defines the resulting node of G as w (line 8). This obtains the node w of G corresponding to m'.
[0115] The index construction unit 203 creates an edge (w, u) from node w corresponding to a frontier state belonging to level l+1 to node u corresponding to a frontier state belonging to level l, and sets its label to T (line 9). This means that a transition from the frontier state labeled by w to the frontier state labeled by u is possible through a level transition T, and that this transition realizes the maximum value of the frontier state labeled by u.
[0116] Next, the index constructor 203 adds the edge (w, u) created on line 9 to A (line 10).
[0117] Then, the index constructor 203 returns to the caller of the INDEX_CONSTRUCT_RECUR function (line 11).
[0118] <Flow of Inquiry Response Processing> The flow of the inquiry response processing according to this embodiment will be described below with reference to FIG.
[0119] The inquiry answering unit 204 receives a given inquiry (step S101). Here, the inquiry includes, for example, the type of inquiry (search, count, enumerate). If the type of inquiry is search, a set family {s 1 , ..., s k} is also included. The query may be given by, for example, input by a user, or may be given from a terminal connected to the index building device 10 via a communication network.
[0120] Next, the inquiry response unit 204 executes the MEMBERSHIP function, the COUNT function, or the ENUMERATE function depending on the type of inquiry (step S102). If the type of inquiry is a search, the MEMBERSHIP function is executed; if the type of inquiry is counting, the COUNT function is executed; and if the type of inquiry is enumeration, the ENUMERATE function is executed to obtain an answer to the respective inquiry. Details of these functions will be described later.
[0121] Then, the inquiry reply unit 204 transmits a reply to the inquiry source (step S103).
[0122] <Search: Algorithm of MEMBERSHIP Function> The MEMBERSHIP function is a set family {s 1 , ..., s k} and {s 1 , ..., s k} is included in G, output 1; otherwise, output 0.
[0123] The algorithm of the MEMBERSHIP function will be explained below with reference to FIG. 11. The index G represents a set as a sequence of level transitions when transitioning between frontier states. The sequence of labels assigned to the edges that pass from the root of the index G to the terminal represents how the path is extended at each level. Given a set {s 1 , ..., s k} is included in index G by checking whether {s 1 , ..., s k}. At each level, we extract how the path set extends to the next level, and check whether the string is included in the index G to obtain search results.
[0124] First, the query response unit 204 compares ZDD Z and {s 1 , ..., s k} is used as input to call the GET_TRANSITION_SEQUENCE function, and the level transition obtained as a result is defined as R (first line). The GET_TRANSITION_SEQUENCE function obtains a sequence of level transitions at each level of ZDD Z.
[0125] Then, the inquiry reply unit 204 calls the SEARCH function with the index G and the level transition column R as input, and outputs the result (0 or 1) (line 2).
[0126] <Get_Transition_Sequence Function Algorithm> The get_transition_sequence function uses ZDD Z and {s 1, ..., s k} and outputs a sequence of level transitions at each level of ZDD Z. That is, the set {s 1 , ..., s k When extending k paths corresponding to} from the root of ZDD Z, it outputs a list storing how to extend the paths at each level, that is, branching triples consisting of Z's nodes, weights, and 1-number of extensions to the branch side, in order from the root level to level 0.
[0127] The algorithm of the GET_TRANSITION_SEQUENCE function will be described below with reference to FIG.
[0128] The GET_TRANSITION_SEQUENCE function uses the set family {s 1 , ..., s k} is stored as an element. Since all set paths start from the root, the query answering unit 204 defines L as (r, {s 1 , ..., s k}) (first line). The query answering unit 204 also creates an empty list for storing how the path is extended at each level (second line).
[0129] Next, the query replying unit 204 loops from the top level |U| to the level one level above the terminal node in lines 4 to 15, and calculates the extent of the path at each level (line 3).
[0130] The query answering unit 204 then 1 , ..., s k} to which node. The query answering unit 204 also creates an empty list T to store how the path extends at the current level (line 5). Note that the fact that the current list L contains a pair (v, F) of a node and a set family means that the sets contained in F are completely consistent in the range from |U| to l+1, and that descending from the root of Z to level l will reach node v.
[0131] The query answering unit 204 executes lines 7 to 14 (line 6) for all (v, F) included in L. This means that for all (v, F) included in L, it checks how the path is extended to the next level.
[0132] The query answering unit 204 defines a family of sets included in F that does not include element l as F. 0 , the family containing element l is called F 1 (Lines 7 and 8). That is, among the |F| paths that reach node v via the same route, |F 0 |The book goes to the 0-branch side, |F 1 |The book extends to the 1-branch side. Therefore, the query answering unit 204 determines if F 0 If is not an empty set (line 9), then v's 0-child and F 0 and adds the pair to L' (line 10). 1 If is not an empty set (line 11), then v's 1-child and F 1 and add a pair to L' (line 12). This is a branch triple at node v, which is |F out of |F| paths. 1 |The book has been extended to the 1-branch side, so the query response unit 204 1 |) is added to T (line 13).
[0133] When all pairs included in L of the current level have been processed, the query answering unit 204 replaces L with the L' of the next level that has just been found (line 14). The query answering unit 204 also sorts the level transitions T at level l in ascending order and adds them to list R (line 15). This records in R the column indicating what level transitions have occurred at each level. Finally, the query answering unit 204 outputs list R (line 16).
[0134] <Algorithm of SEARCH Function> The SEARCH function takes as input an index G and a list R that indicates how to extend paths at each level, and outputs 1 if the label string of the path going from the root to the terminal of G is R, and 0 if not.
[0135] The algorithm of the SEARCH function will be explained below with reference to Fig. 13. The SEARCH function checks whether it can reach the end point when moving from the root of index G along the edges of G based on the elements of R. If it can reach the end point, that is, level 0, it means that R is included in G; if not, it means that it is not included.
[0136] The query reply unit 204 sets the root of G to a variable u that represents the current node on G (first line).
[0137] Next, the query reply unit 204 executes lines 3 to 8 in order from the top level |U| to level 1, and checks whether an element of R and its corresponding edge exist (line 2).
[0138] The query answering unit 204 sets the first element of R to T (line 3). 1 , ..., s k} is a level transition at level l.
[0139] If an edge labeled T originates from u and points to a node u' in a lower level G (line 4), the query answering unit 204 moves the current node to u' by overwriting u with u' (line 5). Next, the query answering unit 204 deletes the top element of R (line 6).
[0140] On the other hand, if there is no edge with label T coming out of u (line 7), the query answering unit 204 outputs 0 and ends the process (line 8). 1 , ..., s k} is not included in G, that is, the set {s 1 , ..., s k} is not included in the optimal solution represented by index G.
[0141] If the loop has been exited without terminating midway at any level, that is, if the end of G has been reached by level transitions equal to the number of elements of R, the query answering unit 204 outputs 1 and terminates (line 9). 1 , ..., s k} is included in the optimal solution represented by index G.
[0142] <Counting: COUNT Function Algorithm> The COUNT function takes an index G and a root q of G as input, and outputs the number of types of sets of size k contained in G. Each node in G represents a set made up of elements at or below the level to which the node belongs.
[0143] The algorithm of the COUNT function will be described below with reference to FIG.
[0144] First, the inquiry reply unit 204 creates a hash table C for holding the number of types of set families represented by each node of G (first line).
[0145] Next, the query response unit 204 calls the COUNT_RECUR function with q as input (line 2). The COUNT_RECUR function is a function that returns the number of types of the set family represented by the nodes of G given as input. This number of types is stored in the hash table C.
[0146] Then, the query replying unit 204 extracts the number of kinds of the set family represented by q, which is the root of G, from the hash table C and outputs the number of kinds (line 3).
[0147] <Count_Record Function Algorithm> The COUNT_RECUR function takes a node u of G as input, stores the number of types of sets of size k included in this node u in a hash table C, and also outputs it.
[0148] The algorithm of the COUNT_RECUR function will be described below with reference to FIG.
[0149] The query response unit 204 searches the hash table C using the node u as a key, and if a non-NULL y is found (line 1), it outputs that y (line 2). This is because if the number of types of the set family represented by the node u has already been calculated, that number of types is stored in the hash table C.
[0150] On the other hand, when the query response unit 204 searches the hash table C using the node u as a key and does not find a non-NULL y (line 3), it initializes the variable y for storing the number of types of the set family represented by the node u to 0 (line 4). The value of y is determined by the number of types of the set family represented by each child of the node u and the labels attached to the edges to the children.
[0151] The query replying unit 204 repeatedly executes lines 6 and 7 for each edge (u, u') from u to u' included in edge set A of G (line 5).
[0152] The query answering unit 204 sets the label of the currently focused edge (u, u') to T (line 6). Next, the query answering unit 204 adds the product of the return value of COUNT_RECUR(u') and the return value of PARTIAL_PERM(T) to the currently known number of types of set families, y (line 7).
[0153] Here, node u' in G corresponds to its label, the frontier state, and the set represented by node u' is the optimal set that can be created by extending paths from that frontier state. It is known that a level transition T is required to transition from the frontier state of node u to the frontier state of node u', but it is sometimes difficult to uniquely determine which branch triple corresponds to which node weight pair. For example, consider a situation in which a path is extended from a frontier state containing four (v, 2)s to T, which contains (v, 2, 0), (v, 2, 1), (v, 2, 1), and (v, 2, 2). Given that node v is reached by four different paths, each of which contains two paths, the following two paths can be selected: "extend both paths toward the 0-edge," "extend one path toward the 0-edge and one toward the 1-edge," "extend one path toward the 0-edge and one toward the 1-edge," or "extend both paths toward the 1-edge." The set family obtained differs depending on which node weight pair these branch triples are assigned to. In this case, for (v, 2), the number of permutations containing the same element, such as (a, b, b, c), is obtained. Therefore, by multiplying the number of types of the set family represented by node u' by the number of ways of this assignment, the number of types of the set family when transitioning from node u to node u' via level transition T can be obtained.
[0154] The query answering unit 204 saves y obtained on line 7 in hash table C using node u as a key (line 8).The query answering unit 204 then outputs y (line 9).
[0155] <Algorithm of PARTIAL_PERM Function> The PARTIAL_PERM function takes as input a list T whose elements are branch triples, and outputs the number of different types of lists that can be created by swapping the positions of branch triples that share weights with nodes in T. In other words, the PARTIAL_PERM function is a function that finds the number of ways to assign each element of level transition T to each node-weight pair in the frontier state.
[0156] The algorithm of the PARTIAL_PERM function will be described below with reference to FIG.
[0157] The inquiry reply unit 204 creates a variable o for holding the number of allocation methods, and sets its initial value to 1 because there is at least one allocation method (first line).
[0158] The query response unit 204 executes lines 3 to 6 while T is not an empty list (line 2). Note that the elements of T are sorted in ascending lexicographical order.
[0159] The query answering unit 204 sets the leading element of T to (v, w, x) (line 3), which means that a certain node weight pair (v, w) is extended x lengths to the 1-edge side.
[0160] The query answering unit 204 extracts from T all branch triples whose first two elements are v and w, and defines T' as a list consisting of these branch triples (line 4).
[0161] The query answering unit 204 multiplies o by the number of different types of lists that can be created by rearranging the elements of list T' (line 5). This is the number of ways to assign branch triples to the same node weight pairs. Note that the number of different types of lists that can be created by rearranging the elements of list T' can be calculated using basic combinatorics.
[0162] Since the number of methods for assigning branch triples to node weight pairs (v, w) has now been completed, the query answering unit 204 deletes T' from T (line 6).
[0163] Finally, when all elements of T have been processed, the target value is stored in o, so the query answering unit 204 outputs this o (line 7).
[0164] <Enumeration: Algorithm of ENUMERATE Function> The ENUMERATE function takes ZDD Z, index G, and root q of index G as input, and outputs all sets of size k contained in G. However, since the output can be huge, it is output as soon as a corresponding set is found.
[0165] The algorithm of the ENUMERATE function will be explained below with reference to FIG. 17. The ENUMERATE function performs a depth-first search from the root, extending k paths along all possible routes to reach the end of G according to the labels assigned to the edges of G. This results in k sets being obtained when the end is reached. When traversing the edges, it is necessary to consider which branch triples are assigned to which node weight pairs, just as with counting.
[0166] The inquiry answering unit 204 creates a list F for holding the set family to be output (first line).
[0167] The inquiry reply unit 204 creates a list L consisting of only (r, k) as the initial state for extending k paths (line 2).
[0168] Then, the inquiry reply unit 204 calls the ENUM_RECUR function with l=|U|, u=q, F, and L as input (line 3).
[0169] <Algorithm of ENUM_RECUR Function> The ENUM_RECUR function takes as input the current level l, the current node u, list F, and list L. Note that F is a list of sets generated from the root level to level l, and L is a list representing the frontier state realized by list F. When Z is traced from the root according to the i-th set in F, the i-th node weight pair in L is obtained.
[0170] The algorithm of the ENUM_RECUR function will be described below with reference to FIG.
[0171] If l=0 (line 1), this means that k sets have been generated, so the query answering unit 204 outputs the set family F (line 2) and ends the process (line 3).
[0172] If l≠0, the query response unit 204 is in the middle of generating a set family, and therefore executes lines 5 to 7 for each edge (u, u') coming out from the current node u (line 4).
[0173] The inquiry answering unit 204 sets T as the label assigned to the edge (line 5). T represents the level transition from the current frontier state.
[0174] Next, the query answering unit 204 creates an empty list L′ for storing the next frontier state to which T transitions, and an empty list F′ for storing the set family F that is updated with the transition (line 6).
[0175] Next, the query answering unit 204 calls the ENUM_RECUR_ASSIGN function with l, u, u', i=1, T, F, L, F', and L' as inputs (line 7). The ENUM_RECUR_ASSIGN function tries all possible ways to assign each element of T to each element of the list L representing the frontier state before proceeding to the next level.
[0176] Then, when the repeated execution of lines 5 to 7 is completed, the inquiry response unit 204 returns to the caller of the ENUM_RECUR function (line 8).
[0177] <Algorithm of ENUM_RECUR_ASSIGN function> The ENUM_RECUR_ASSIGN function takes as input a level l, a current node u in G, a next node u' to move to, a number i indicating the element number in L of the node weight pair for which the branch triple assignment is to be determined, a list T representing the level transition corresponding to the edge label to be traversed when moving from node u to node u', a list F representing the sets generated from the root level to level l, a list L representing the frontier states brought about by F, a list F' representing the sets generated from the root level to level l-1, and a list L' representing the frontier states brought about by F'.
[0178] The algorithm of the ENUM_RECUR_ASSIGN function will be described below with reference to FIG.
[0179] If i exceeds the size of L (line 1), the query answering unit 204 has already assigned branch triples to all node weight pairs contained in L, so it calls the ENUM_RECUR function to move to the next level (line 2) and terminates when the call returns (line 3).
[0180] On the other hand, if i is within the size of L, the query answering unit 204 obtains the i-th element (v, w) of L (line 4). Thereafter, it is determined which branch triple to assign to this (v, w).
[0181] The query answering unit 204 executes lines 6 to 29 from j=1 to the number of elements in T to find branch triples to assign to (v, w) (line 5). Here, there are several if statements to reject branch triples that do not match (v, w).
[0182] First, since T is arranged in ascending lexicographical order, if the first element of the j-th branch triple of T is greater than v, or if the first element is the same but the second element is greater than w, it is determined that no branch triple such as (v, w, x) exists after the j-th branch triple of T. In such a case, the query answering unit 204 gives up on allocating a branch triple for (v, w) and exits the loop (lines 6 and 7).
[0183] Next, if the third element of the j-th branch triple of T is -1, it means that the branch triple has already been assigned to another node weight pair. In such a case, the query answering unit 204 ignores the branch triple and continues the loop to look at the next element of T (lines 8-9).
[0184] Next, if the first element of the j-th branch triple of T is not v or the second element is not 2, then the branch triple cannot be assigned to the node weight pair (v, w). In such a case, the query answering unit 204 ignores the branch triple and continues the loop to look at the next element of T (lines 10-11).
[0185] Next, if j is 1 or greater and the j-1th branch triple of T is the same as the jth branch triple, it means that the jth branch triple was previously assigned to (v, w). To avoid outputting the same set family multiple times, a constraint is introduced that if there are multiple identical branch triples, the one with the lowest number must be selected. Therefore, in such a case, the query answering unit 204 ignores the branch triple and continues the loop to look at the next element of T (lines 12-13).
[0186] Anything that does not fall into one of the above if statements is a branching triple that can be assigned to (v, w).
[0187] The query answering unit 204 extracts the third element of the branch triple as x (line 14).
[0188] If w-x is greater than 0, i.e., if there is one or more nodes to be extended to the 0-edge side (line 15), the query answering unit 204 adds the 0-child of v and w-x as a node weight pair to the frontier state L' at the next level (line 16). Then, the query answering unit 204 adds the i-th set of F, that is, the set corresponding to the currently assigned node weight pair (v, w), to F' as a set corresponding to the added node weight pair (line 17). Note that a certain set corresponds to a node weight pair (v, w) means that node v is reached when tracing the edges from the root according to that set on the ZDD.
[0189] Similarly, if x is greater than 0, i.e., if there is one or more nodes to be extended to the 1-edge side (line 18), the query answering unit 204 adds the 1-child of v and x as a node weight pair to the frontier state L' at the next level (line 19).The query answering unit 204 then adds to F' a set corresponding to the added node weight pair, the set obtained by adding element l to the i-th set of F (line 20).Element l is added because the 1-edge has been passed through.
[0190] Next, the query answering unit 204 sets the third element of the j-th branch triple of T to -1 to indicate that the branch triple has been assigned (line 21).
[0191] Next, to determine the assignment of branch triples to the next element of L, that is, the i+1th element, the query answering unit 204 recursively invokes the ENUM_RECUR_ASSIGN function (line 22). At this time, l, u, u', i+1, T, F, L, F', and L' are given to the ENUM_RECUR_ASSIGN function as inputs.
[0192] When the query answering unit 204 returns from the ENUM_RECUR_ASSIGN function called on line 22, it cancels the current assignment to (v, w) and restores it to its original state by restoring the third element of the branch triple used in the assignment to x (line 23).
[0193] Next, the query response unit 204 extracts and deletes the node weight pairs and sets added when x exceeds 0 and when w-x exceeds 0 (lines 24 to 29) in order to return L' and F', which were updated in lines 16 to 17 and lines 19 to 20, to their pre-allocation states.
[0194] Then, when the query response unit 204 finishes repeating lines 6 to 29, it has finished trying all the branch triple assignments for the i-th element of L, and so returns to the caller of the ENUM_RECUR_ASSIGN function (line 30).
[0195] <Summary> As described above, the index construction device 10 according to this embodiment can significantly reduce the calculation time required to obtain the optimal value (maximum objective function value) of a k-sets selection problem, and can also store all of the optimal solutions in a small memory area to construct an index that can efficiently handle queries such as search, counting, or enumeration. This makes it possible to construct an index that holds a k-sets selection problem for a large set family, for example, and operate it as a database.
[0196] The present invention is not limited to the above-described specifically disclosed embodiments, and various modifications, changes, and combinations with known technologies are possible without departing from the scope of the claims.
[0197] [References] Reference 1: Randal E. Bryant. Graph-based algorithms for Boolean function manipulation. IEEE Transactions on Computers, C-35(8):677-691, 1986. Reference 2: Shin-ichi Minato. Zero-Suppressed BDDs for Set Manipulation in Combinatorial Problems. In Proc. of the 30th ACM / IEEE Design Automation Conference (DAC'93), pp. 272-277, 1993. Reference 3: Japanese Patent Application Laid-Open No. 2020-201556 Reference 4: Donald E. Knuth. The Art of Computer Programming. Volume 4, fascicle 1, Bitwise Tricks & Techniques; Binary Decision Diagrams. Addison-Wesley, 2009.
[0198] 10 Index building device 101 Input device 102 Display device 103 External I / F 103a Recording medium 104 Communication I / F 105 RAM 106 ROM 107 Auxiliary storage device 108 Processor 109 Bus 201 Input unit 202 Calculation unit 203 Index building unit 204 Inquiry response unit 205 Database 211 Preprocessing unit 212 Operation unit
Claims
1. An index construction device that constructs an index that represents a family of sets that is an optimal solution to a k-set selection problem, comprising: an input unit that inputs a zero-suppressed binary decision diagram that represents the family of sets in the k-set selection problem, an objective function that satisfies certain constraints, and k that is 2 or greater; a calculation unit that calculates information for constructing the index using the zero-suppressed binary decision diagram, the objective function, and the k; and an index construction unit that uses the information to construct a data structure as the index that represents the family of sets for which the objective function is maximized.
2. The calculation unit creates a hash table h that stores frontier states representing a list of pairs of a node having a label i in the zero-suppressed binary decision diagram and the number of times the node appears in k paths, in association with IDs for the frontier states. i The partial maximum value of the objective function realized by the frontier state belonging to level i and having ID m is the array element E i Array E stored in [m] i The index construction unit calculates at least the following information: i and the sequence E i 2. The index construction device according to claim 1, wherein the index is constructed by using at least the above-mentioned method, in which, starting from the level of the root node of a directed acyclic graph, the nodes that are the partial maximum values realized in the frontier state of each level are used as nodes, and the directed acyclic graph is composed of edges represented by pairs of the nodes and other nodes that are one level above the nodes and are connected to the nodes by paths.
3. The index construction device of claim 2, wherein the nodes are labeled with a frontier state related to the nodes, and the edges are labeled with information representing a transition from the frontier state to a frontier state at the next lower level.
4. An index building apparatus according to any one of claims 1 to 3, further comprising a first query answering unit for using said index to answer whether a given family of sets is an optimal solution to said k-set selection problem.
5. An index construction device according to any one of claims 1 to 3, further comprising a second inquiry answering unit that uses said index to answer the number of types of optimal solutions to said k-set selection problem.
6. An index building apparatus according to any one of claims 1 to 3, further comprising a third query answering unit that uses said index to answer all optimal solutions to said k-set selection problem.
7. A method for constructing an index that represents a family of sets that is an optimal solution to a k-set selection problem, the method comprising: an input step of inputting a zero-suppressed binary decision diagram that represents the family of sets in the k-set selection problem, an objective function that satisfies certain constraints, and k, which is 2 or greater; a calculation step of calculating information for constructing the index using the zero-suppressed binary decision diagram, the objective function, and the k; and an index construction step of constructing, as the index, a data structure that represents the family of sets for which the objective function is maximized, using the information.
8. A program that causes a computer to execute the following steps for constructing an index that represents a family of sets that is an optimal solution to a k-set selection problem: an input procedure for inputting a zero-suppressed binary decision diagram that represents the family of sets in the k-set selection problem, an objective function that satisfies certain constraints, and k that is 2 or greater; a calculation procedure for calculating information for constructing the index using the zero-suppressed binary decision diagram, the objective function, and the k; and an index construction procedure for constructing, as the index, a data structure that represents the family of sets for which the objective function is maximized, using the information.
