Scippy

GCG

Branch-and-Price & Column Generation for Everyone

struct_gcgpqueue.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program */
4 /* GCG --- Generic Column Generation */
5 /* a Dantzig-Wolfe decomposition based extension */
6 /* of the branch-cut-and-price framework */
7 /* SCIP --- Solving Constraint Integer Programs */
8 /* */
9 /* Copyright (C) 2010-2021 Operations Research, RWTH Aachen University */
10 /* Zuse Institute Berlin (ZIB) */
11 /* */
12 /* This program is free software; you can redistribute it and/or */
13 /* modify it under the terms of the GNU Lesser General Public License */
14 /* as published by the Free Software Foundation; either version 3 */
15 /* of the License, or (at your option) any later version. */
16 /* */
17 /* This program is distributed in the hope that it will be useful, */
18 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
19 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
20 /* GNU Lesser General Public License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with this program; if not, write to the Free Software */
24 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/
25 /* */
26 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 
28 /**@file struct_gcgpqueue.h
29  * @ingroup DATASTRUCTURES
30  * @brief data structure for priority queue
31  * @author Jonas Witt
32  */
33 
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35 
36 #ifndef GCG_STRUCT_GCGPQUEUE_H_
37 #define GCG_STRUCT_GCGPQUEUE_H_
38 
39 #include "scip/def.h"
40 #include "scip/type_misc.h"
41 #include "scip/scip.h"
42 
43 #include "type_gcgpqueue.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /** @brief priority queue data structure
50  *
51  * Elements are stored in an array, which grows dynamically in size as new elements are added to the queue.
52  * The ordering is done through a pointer comparison function.
53  * The array is organized as follows. The root element (that is the "best" element $r$ with $r <= x$ for all $x$)
54  * is stored in position 0. The children of an element at position $p$ are stored at positions $q_1 = 2*p+1$ and
55  * $q_2 = 2*p+2$. That means, the parent of the element at position $q$ is at position $p = (q-1)/2$.
56  * At any time, the condition holds that $p <= q$ for each parent $p$ and its children $q$.
57  * Insertion and removal of single elements needs time $O(log n)$.
58  */
59 struct GCG_PQueue
60 {
61  SCIP* scip; /**< SCIP data structure */
62  SCIP_DECL_SORTPTRCOMP((*ptrcomp)); /**< compares two data elements */
63  void** slots; /**< array of element slots */
64  int len; /**< number of used element slots */
65  int size; /**< total number of available element slots */
66 };
67 
68 #ifdef __cplusplus
69 }
70 #endif
71 
72 #endif /* STRUCT_GCGPQUEUE_H_ */
type definitions for priority queue
priority queue data structure
SCIP_DECL_SORTPTRCOMP((*ptrcomp))