Scippy

SCIP

Solving Constraint Integer Programs

struct_event.h
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-2014 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 email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file struct_event.h
17  * @brief datastructures for managing events
18  * @author Tobias Achterberg
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #ifndef __SCIP_STRUCT_EVENT_H__
24 #define __SCIP_STRUCT_EVENT_H__
25 
26 
27 #include "scip/def.h"
28 #include "scip/type_clock.h"
29 #include "scip/type_event.h"
30 #include "scip/type_var.h"
31 #include "scip/type_sol.h"
32 #include "scip/type_tree.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /** data for variable addition events */
40 {
41  SCIP_VAR* var; /**< variable that was added to the problem */
42 };
43 
44 /** data for variable deletion events */
46 {
47  SCIP_VAR* var; /**< variable that will be deleted from the problem */
48 };
49 
50 /** data for variable fixing events */
52 {
53  SCIP_VAR* var; /**< variable that was fixed */
54 };
55 
56 /** data for locks change events */
58 {
59  SCIP_VAR* var; /**< variable for which the lock numbers were changed */
60 };
61 
62 /** data for objective value change events */
64 {
65  SCIP_Real oldobj; /**< old objective value before value changed */
66  SCIP_Real newobj; /**< new objective value after value changed */
67  SCIP_VAR* var; /**< variable whose objective value changed */
68 };
69 
70 /** data for bound change events */
72 {
73  SCIP_Real oldbound; /**< old bound before bound changed */
74  SCIP_Real newbound; /**< new bound after bound changed */
75  SCIP_VAR* var; /**< variable whose bound changed */
76 };
77 
78 /** data for domain hole events */
80 {
81  SCIP_Real left; /**< left bound of open interval in hole */
82  SCIP_Real right; /**< right bound of open interval in hole */
83  SCIP_VAR* var; /**< variable for which a hole was removed */
84 };
85 
86 /** data for implication added events */
88 {
89  SCIP_VAR* var; /**< variable for which an implication, variable bound, or clique was added */
90 };
91 
92 /** data for row addition to separation storage events */
94 {
95  SCIP_ROW* row; /**< row that was added to separation storage */
96 };
97 
98 /** data for row deletion from separation storage events */
100 {
101  SCIP_ROW* row; /**< row that was deleted from separation storage */
102 };
103 
104 /** data for row addition to LP events */
106 {
107  SCIP_ROW* row; /**< row that was added to the LP */
108 };
109 
110 /** data for row deletion from LP events */
112 {
113  SCIP_ROW* row; /**< row that was deleted from the LP */
114 };
115 
116 /** data for row coefficient change events */
118 {
119  SCIP_ROW* row; /**< row which coefficient has changed */
120  SCIP_COL* col; /**< column which coefficient has changed */
121  SCIP_Real oldval; /**< old value of coefficient */
122  SCIP_Real newval; /**< new value of coefficient */
123 };
124 
125 /** data for row constant change events */
127 {
128  SCIP_ROW* row; /**< row which constant has changed */
129  SCIP_Real oldval; /**< old value of constant */
130  SCIP_Real newval; /**< new value of constant */
131 };
132 
133 /** data for row side change events */
135 {
136  SCIP_ROW* row; /**< row which side has changed */
137  SCIP_SIDETYPE side; /**< which side has changed */
138  SCIP_Real oldval; /**< old value of side */
139  SCIP_Real newval; /**< new value of side */
140 };
141 
142 /** event data structure */
144 {
145  union
146  {
147  SCIP_EVENTVARADDED eventvaradded; /**< data for variable addition events */
148  SCIP_EVENTVARDELETED eventvardeleted; /**< data for variable deletion events */
149  SCIP_EVENTVARFIXED eventvarfixed; /**< data for variable fixing events */
150  SCIP_EVENTVARUNLOCKED eventvarunlocked; /**< data for locks change events */
151  SCIP_EVENTOBJCHG eventobjchg; /**< data for objective value change events */
152  SCIP_EVENTBDCHG eventbdchg; /**< data for bound change events */
153  SCIP_EVENTHOLE eventhole; /**< data for domain hole events */
154  SCIP_EVENTIMPLADD eventimpladd; /**< data for implication added events */
155  SCIP_EVENTROWADDEDSEPA eventrowaddedsepa; /**< data for row addition to separation storage events */
156  SCIP_EVENTROWDELETEDSEPA eventrowdeletedsepa; /**< data for row deletion from separation storage events */
157  SCIP_EVENTROWADDEDLP eventrowaddedlp; /**< data for row addition to LP events */
158  SCIP_EVENTROWDELETEDLP eventrowdeletedlp; /**< data for row deletion from LP events */
159  SCIP_EVENTROWCOEFCHANGED eventrowcoefchanged; /**< data for row coefficient change events */
160  SCIP_EVENTROWCONSTCHANGED eventrowconstchanged; /**< data for row constant change events */
161  SCIP_EVENTROWSIDECHANGED eventrowsidechanged; /**< data for row side change events */
162  SCIP_NODE* node; /**< data for node and LP events */
163  SCIP_SOL* sol; /**< data for primal solution events */
164  } data;
165  SCIP_EVENTTYPE eventtype; /**< type of event */
166 };
167 
168 /** event filter to select events to be processed by an event handler */
170 {
171  SCIP_EVENTTYPE* eventtypes; /**< array with types of event to process; 0 marks a deleted event catch entry */
172  SCIP_EVENTHDLR** eventhdlrs; /**< array with event handlers to process the event */
173  SCIP_EVENTDATA** eventdatas; /**< array with user data for the issued event */
174  int* nextpos; /**< linked lists for free, delayed added and delayed deleted slot positions */
175  int size; /**< size of filter arrays (available slots in arrays) */
176  int len; /**< number entries in filter arrays (used and deleted) */
177  int firstfreepos; /**< first deleted slot; remaining slots are in poslist */
178  int firstdeletedpos; /**< first delayed deleted slot; remaining slots are in poslist */
179  unsigned int eventmask; /**< mask for events that are handled by any event handler in the filter */
180  unsigned int delayedeventmask; /**< mask for delayed added events */
181  SCIP_Bool delayupdates; /**< should additions and deletions to the filter be delayed? */
182 };
183 
184 /** event handler */
186 {
187  char* name; /**< name of event handler */
188  char* desc; /**< description of event handler */
189  SCIP_DECL_EVENTCOPY ((*eventcopy)); /**< copy method of event handler or NULL if you don't want to copy your plugin into sub-SCIPs */
190  SCIP_DECL_EVENTFREE ((*eventfree)); /**< destructor of event handler */
191  SCIP_DECL_EVENTINIT ((*eventinit)); /**< initialize event handler */
192  SCIP_DECL_EVENTEXIT ((*eventexit)); /**< deinitialize event handler */
193  SCIP_DECL_EVENTINITSOL((*eventinitsol)); /**< solving process initialization method of event handler */
194  SCIP_DECL_EVENTEXITSOL((*eventexitsol)); /**< solving process deinitialization method of event handler */
195  SCIP_DECL_EVENTDELETE ((*eventdelete)); /**< free specific event data */
196  SCIP_DECL_EVENTEXEC ((*eventexec)); /**< execute event handler */
197  SCIP_EVENTHDLRDATA* eventhdlrdata; /**< event handler data */
198  SCIP_CLOCK* setuptime; /**< time spend for setting up this event handler for the next stages */
199  SCIP_CLOCK* eventtime; /**< time spend in this event handler execution method */
200  SCIP_Bool initialized; /**< is event handler initialized? */
201 };
202 
203 /** event queue to cache events and process them later */
205 {
206  SCIP_EVENT** events; /**< array with queued events */
207  int eventssize; /**< number of available slots in events array */
208  int nevents; /**< number of events in queue (used slots if events array) */
209  SCIP_Bool delayevents; /**< should the events be delayed and processed later? */
210 };
211 
212 #ifdef __cplusplus
213 }
214 #endif
215 
216 #endif
217