Scippy

GCG

Branch-and-Price & Column Generation for Everyone

pub_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 pub_decomp.h
29  * @ingroup PUBLICCOREAPI
30  * @ingroup DATASTRUCTURES
31  * @brief public methods for working with priority queues
32  * @author Jonas Witt
33  */
34 
35 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36 #ifndef GCG_PUB_GCGPQUEUE_H__
37 #define GCG_PUB_GCGPQUEUE_H__
38 
39 #include "scip/type_scip.h"
40 #include "scip/type_retcode.h"
41 #include "scip/type_var.h"
42 #include "scip/type_cons.h"
43 #include "scip/type_misc.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /*
50  * Priority Queue
51  */
52 
53 /**@defgroup PriorityQueue Priority Queue
54  * @ingroup DATASTRUCTURES
55  * @{
56  */
57 
58 /** creates priority queue */
59 SCIP_EXPORT
60 SCIP_RETCODE GCGpqueueCreate(
61  SCIP* scip, /** SCIP data structure */
62  GCG_PQUEUE** pqueue, /**< pointer to a priority queue */
63  int initsize, /**< initial number of available element slots */
64  SCIP_DECL_SORTPTRCOMP((*ptrcomp)) /**< data element comparator */
65  );
66 
67 /** frees priority queue, but not the data elements themselves */
68 SCIP_EXPORT
69 void GCGpqueueFree(
70  GCG_PQUEUE** pqueue /**< pointer to a priority queue */
71  );
72 
73 /** clears the priority queue, but doesn't free the data elements themselves */
74 SCIP_EXPORT
75 void GCGpqueueClear(
76  GCG_PQUEUE* pqueue /**< priority queue */
77  );
78 
79 /** inserts element into priority queue */
80 SCIP_EXPORT
81 SCIP_RETCODE GCGpqueueInsert(
82  GCG_PQUEUE* pqueue, /**< priority queue */
83  void* elem /**< element to be inserted */
84  );
85 
86 /** removes and returns best element from the priority queue */
87 SCIP_EXPORT
88 void* GCGpqueueRemove(
89  GCG_PQUEUE* pqueue /**< priority queue */
90  );
91 
92 /** resorts priority queue after changing the key values */
93 SCIP_EXPORT
94 SCIP_RETCODE GCGpqueueResort(
95  GCG_PQUEUE* pqueue /**< priority queue */
96  );
97 
98 /** set the comperator of the priority queue */
99 SCIP_RETCODE GCGpqueueSetComperator(
100  GCG_PQUEUE* pqueue, /**< priority queue */
101  SCIP_DECL_SORTPTRCOMP((*ptrcomp)) /**< data element comparator */
102  );
103 
104 /**< delete item at position pos and insert last item at this position and resort pqueue */
105 extern
106 SCIP_RETCODE GCGpqueueDelete(
107  GCG_PQUEUE* pqueue, /**< priority queue */
108  int pos, /**< position of item that should be deleted */
109  void** elem /**< pointer to store element that was deleted from pqueue */
110 );
111 
112 /** returns the best element of the queue without removing it */
113 SCIP_EXPORT
114 void* GCGpqueueFirst(
115  GCG_PQUEUE* pqueue /**< priority queue */
116  );
117 
118 /** returns the number of elements in the queue */
119 SCIP_EXPORT
120 int GCGpqueueNElems(
121  GCG_PQUEUE* pqueue /**< priority queue */
122  );
123 
124 /** returns the elements of the queue; changing the returned array may destroy the queue's ordering! */
125 SCIP_EXPORT
126 void** GCGpqueueElems(
127  GCG_PQUEUE* pqueue /**< priority queue */
128  );
129 
130 /**@} */
131 
132 
133 #ifdef __cplusplus
134 }
135 #endif
136 #endif
SCIP_EXPORT void * GCGpqueueFirst(GCG_PQUEUE *pqueue)
Definition: gcgpqueue.c:313
priority queue data structure
SCIP_RETCODE GCGpqueueDelete(GCG_PQUEUE *pqueue, int pos, void **elem)
Definition: gcgpqueue.c:274
SCIP_EXPORT SCIP_RETCODE GCGpqueueCreate(SCIP *scip, GCG_PQUEUE **pqueue, int initsize, SCIP_DECL_SORTPTRCOMP((*ptrcomp)))
Definition: gcgpqueue.c:118
SCIP_EXPORT SCIP_RETCODE GCGpqueueResort(GCG_PQUEUE *pqueue)
Definition: gcgpqueue.c:234
SCIP_EXPORT void GCGpqueueClear(GCG_PQUEUE *pqueue)
Definition: gcgpqueue.c:153
SCIP_EXPORT void GCGpqueueFree(GCG_PQUEUE **pqueue)
Definition: gcgpqueue.c:142
SCIP_EXPORT int GCGpqueueNElems(GCG_PQUEUE *pqueue)
Definition: gcgpqueue.c:327
SCIP_EXPORT void * GCGpqueueRemove(GCG_PQUEUE *pqueue)
Definition: gcgpqueue.c:193
SCIP_EXPORT SCIP_RETCODE GCGpqueueInsert(GCG_PQUEUE *pqueue, void *elem)
Definition: gcgpqueue.c:163
SCIP_EXPORT void ** GCGpqueueElems(GCG_PQUEUE *pqueue)
Definition: gcgpqueue.c:338
static SCIP_DECL_SORTPTRCOMP(ptrilocomp)
SCIP_RETCODE GCGpqueueSetComperator(GCG_PQUEUE *pqueue, SCIP_DECL_SORTPTRCOMP((*ptrcomp)))
Definition: gcgpqueue.c:261