Scippy

SCIP

Solving Constraint Integer Programs

extreduce_util.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2022 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file extreduce_util.c
17  * @brief utility methods for Steiner tree extended reductions
18  * @author Daniel Rehfeldt
19  *
20  * This file implements utility methods for Steiner tree problem extended reduction techniques.
21  *
22  * A list of all interface methods can be found in extreduce.h.
23  *
24  */
25 
26 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
27 
28 // #define SCIP_DEBUG
29 #include "extreduce.h"
30 #include "misc_stp.h"
31 #include "portab.h"
32 
33 
34 /**@name Local methods
35  *
36  * @{
37  */
38 
39 
40 
41 
42 /**@} */
43 
44 /**@name Interface methods
45  *
46  * @{
47  */
48 
49 
50 
51 /** reverts extension component (makes root the only extension leaf) */
53  const GRAPH* graph, /**< graph data structure */
54  const EXTPERMA* extperma, /**< extension data */
55  EXTCOMP* extcomp /**< component to be cleaned for */
56 )
57 {
58  int* const extleaves = extcomp->extleaves;
59  int* const compedges = extcomp->compedges;
60  const int comproot_org = extcomp->comproot;
61  const SCIP_Bool compIsSingleEdge = (extcomp->ncompedges == 1);
62 
63  assert(extcomp->ncompedges >= 1);
64  assert(extcomp->comproot == graph->tail[extcomp->compedges[0]]);
65 
66  if( compIsSingleEdge )
67  {
68  assert(extcomp->nextleaves == 1);
69  }
70  else
71  {
72  const int firstedge = compedges[0];
73 
74  assert(extcomp->ncompedges >= 3);
75  assert(extcomp->nextleaves >= 2);
76  assert(graph->head[compedges[1]] == extleaves[0]);
77 
78  compedges[0] = compedges[1];
79  compedges[1] = flipedge(firstedge);
80  }
81 
82  compedges[0] = flipedge(compedges[0]);
83 
84  assert(extleaves[0] != extcomp->comproot);
85 
86  extcomp->comproot = extleaves[0];
87  extleaves[0] = comproot_org;
88  extcomp->nextleaves = 1;
89 }
90 
91 
92 /** is extension component promising candidate for extension? */
94  const GRAPH* graph, /**< graph data structure */
95  const EXTPERMA* extperma, /**< extension data */
96  const EXTCOMP* extcomp /**< component to be cleaned for */)
97 {
98  const int* const extleaves = extcomp->extleaves;
99  const SCIP_Bool* const isterm = extperma->isterm;
100  const int nextleaves = extcomp->nextleaves;
101 
102  assert(extcomp->ncompedges == 1 || extcomp->ncompedges >= 3);
103 
104  /* we want to at least check each star! */
105  if( extcomp->ncompedges >= 3 )
106  {
107  return TRUE;
108  }
109 
110  /* go over all possible extensions and see whether any of them are promising */
111  for( int i = 0; i < nextleaves; ++i )
112  {
113  const int leaf = extleaves[i];
114 
115  if( extLeafIsExtendable(graph, isterm, leaf) )
116  return TRUE;
117  }
118 
119  return FALSE;
120 }
121 
122 
123 /** is extension component or its reversed version promising candidate for extension? */
125  const GRAPH* graph, /**< graph data structure */
126  const EXTPERMA* extperma, /**< extension data */
127  const EXTCOMP* extcomp /**< component to be cleaned for */)
128 {
129  assert(graph && extperma && extcomp);
130 
131  if( extreduce_extCompIsPromising(graph, extperma, extcomp) )
132  return TRUE;
133 
134  if( extLeafIsExtendable(graph, extperma->isterm, extcomp->comproot) )
135  return TRUE;
136 
137  return FALSE;
138 }
139 
140 /**@} */
int *RESTRICT head
Definition: graphdefs.h:224
#define FALSE
Definition: def.h:87
SCIP_Bool extreduce_extCompFullIsPromising(const GRAPH *graph, const EXTPERMA *extperma, const EXTCOMP *extcomp)
#define TRUE
Definition: def.h:86
void extreduce_extCompRevert(const GRAPH *graph, const EXTPERMA *extperma, EXTCOMP *extcomp)
This file implements extended reduction techniques for several Steiner problems.
miscellaneous methods used for solving Steiner problems
#define SCIP_Bool
Definition: def.h:84
int *RESTRICT tail
Definition: graphdefs.h:223
#define flipedge(edge)
Definition: graphdefs.h:84
SCIP_Bool extreduce_extCompIsPromising(const GRAPH *graph, const EXTPERMA *extperma, const EXTCOMP *extcomp)
Portable definitions.
static SCIP_Bool extLeafIsExtendable(const GRAPH *graph, const SCIP_Bool *isterm, int leaf)