Scippy

SCIP

Solving Constraint Integer Programs

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 event.h
17  * @brief internal methods 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_EVENT_H__
24 #define __SCIP_EVENT_H__
25 
26 
27 #include "scip/def.h"
28 #include "blockmemshell/memory.h"
29 #include "scip/type_retcode.h"
30 #include "scip/type_set.h"
31 #include "scip/type_event.h"
32 #include "scip/type_lp.h"
33 #include "scip/type_var.h"
34 #include "scip/type_sol.h"
35 #include "scip/type_primal.h"
36 #include "scip/type_branch.h"
37 #include "scip/pub_event.h"
38 
39 #include "scip/struct_event.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /*
46  * Event handler methods
47  */
48 
49 /** copies the given event handler to a new scip */
50 extern
52  SCIP_EVENTHDLR* eventhdlr, /**< event handler */
53  SCIP_SET* set /**< SCIP_SET of SCIP to copy to */
54  );
55 
56 /** creates an event handler */
57 extern
59  SCIP_EVENTHDLR** eventhdlr, /**< pointer to event handler data structure */
60  const char* name, /**< name of event handler */
61  const char* desc, /**< description of event handler */
62  SCIP_DECL_EVENTCOPY ((*eventcopy)), /**< copy method of event handler or NULL if you don't want to copy your plugin into sub-SCIPs */
63  SCIP_DECL_EVENTFREE ((*eventfree)), /**< destructor of event handler */
64  SCIP_DECL_EVENTINIT ((*eventinit)), /**< initialize event handler */
65  SCIP_DECL_EVENTEXIT ((*eventexit)), /**< deinitialize event handler */
66  SCIP_DECL_EVENTINITSOL((*eventinitsol)), /**< solving process initialization method of event handler */
67  SCIP_DECL_EVENTEXITSOL((*eventexitsol)), /**< solving process deinitialization method of event handler */
68  SCIP_DECL_EVENTDELETE ((*eventdelete)), /**< free specific event data */
69  SCIP_DECL_EVENTEXEC ((*eventexec)), /**< execute event handler */
70  SCIP_EVENTHDLRDATA* eventhdlrdata /**< event handler data */
71  );
72 
73 /** calls destructor and frees memory of event handler */
74 extern
76  SCIP_EVENTHDLR** eventhdlr, /**< pointer to event handler data structure */
77  SCIP_SET* set /**< global SCIP settings */
78  );
79 
80 /** initializes event handler */
81 extern
83  SCIP_EVENTHDLR* eventhdlr, /**< event handler for this event */
84  SCIP_SET* set /**< global SCIP settings */
85  );
86 
87 /** calls exit method of event handler */
88 extern
90  SCIP_EVENTHDLR* eventhdlr, /**< event handler for this event */
91  SCIP_SET* set /**< global SCIP settings */
92  );
93 
94 /** informs event handler that the branch and bound process is being started */
95 extern
97  SCIP_EVENTHDLR* eventhdlr, /**< event handler */
98  SCIP_SET* set /**< global SCIP settings */
99  );
100 
101 /** informs event handler that the branch and bound process data is being freed */
102 extern
104  SCIP_EVENTHDLR* eventhdlr, /**< event handler */
105  SCIP_SET* set /**< global SCIP settings */
106  );
107 
108 /** calls execution method of event handler */
109 extern
111  SCIP_EVENTHDLR* eventhdlr, /**< event handler */
112  SCIP_SET* set, /**< global SCIP settings */
113  SCIP_EVENT* event, /**< event to call event handler with */
114  SCIP_EVENTDATA* eventdata /**< user data for the issued event */
115  );
116 
117 /**
118  * callback setter methods of event handlers
119  */
120 /** sets copy callback for all events of this event handler */
121 extern
123  SCIP_EVENTHDLR* eventhdlr, /**< event handler */
124  SCIP_DECL_EVENTCOPY ((*eventcopy)) /**< copy callback for events */
125  );
126 
127 /** sets destructor callback of this event handler */
128 extern
130  SCIP_EVENTHDLR* eventhdlr, /**< event handler */
131  SCIP_DECL_EVENTFREE ((*eventfree)) /**< destructor callback of event handler */
132  );
133 
134 /** sets initialization callback of this event handler */
135 extern
137  SCIP_EVENTHDLR* eventhdlr, /**< event handler */
138  SCIP_DECL_EVENTINIT ((*eventinit)) /**< initialization callback of event handler */
139  );
140 
141 /** sets deinitialization callback of this event handler */
142 extern
144  SCIP_EVENTHDLR* eventhdlr, /**< event handler */
145  SCIP_DECL_EVENTEXIT ((*eventexit)) /**< deinitialization callback of event handler */
146  );
147 
148 /** sets solving process initialization callback of this event handler */
149 extern
151  SCIP_EVENTHDLR* eventhdlr, /**< event handler */
152  SCIP_DECL_EVENTINITSOL((*eventinitsol)) /**< solving process initialization callback of event handler */
153  );
154 
155 /** sets solving process deinitialization callback of this event handler */
156 extern
158  SCIP_EVENTHDLR* eventhdlr, /**< event handler */
159  SCIP_DECL_EVENTEXITSOL((*eventexitsol)) /**< solving process deinitialization callback of event handler */
160  );
161 
162 /** sets callback to free specific event data */
163 extern
165  SCIP_EVENTHDLR* eventhdlr, /**< event handler */
166  SCIP_DECL_EVENTDELETE ((*eventdelete)) /**< callback to free specific event data */
167  );
168 
169 
170 /*
171  * Event methods
172  */
173 
174 /** creates an event for an addition of a variable to the problem */
175 extern
177  SCIP_EVENT** event, /**< pointer to store the event */
178  BMS_BLKMEM* blkmem, /**< block memory */
179  SCIP_VAR* var /**< variable that was added to the problem */
180  );
181 
182 /** creates an event for a deletion of a variable from the problem */
183 extern
185  SCIP_EVENT** event, /**< pointer to store the event */
186  BMS_BLKMEM* blkmem, /**< block memory */
187  SCIP_VAR* var /**< variable that is to be deleted from the problem */
188  );
189 
190 /** creates an event for a fixing of a variable */
191 extern
193  SCIP_EVENT** event, /**< pointer to store the event */
194  BMS_BLKMEM* blkmem, /**< block memory */
195  SCIP_VAR* var /**< variable that was fixed */
196  );
197 
198 /** creates an event for a change in the number of locks of a variable down to zero or one */
199 extern
201  SCIP_EVENT** event, /**< pointer to store the event */
202  BMS_BLKMEM* blkmem, /**< block memory */
203  SCIP_VAR* var /**< variable that changed the number of locks */
204  );
205 
206 /** creates an event for a change in the objective value of a variable */
207 extern
209  SCIP_EVENT** event, /**< pointer to store the event */
210  BMS_BLKMEM* blkmem, /**< block memory */
211  SCIP_VAR* var, /**< variable whose objective value changed */
212  SCIP_Real oldobj, /**< old objective value before value changed */
213  SCIP_Real newobj /**< new objective value after value changed */
214  );
215 
216 /** creates an event for a change in the global lower bound of a variable */
217 extern
219  SCIP_EVENT** event, /**< pointer to store the event */
220  BMS_BLKMEM* blkmem, /**< block memory */
221  SCIP_VAR* var, /**< variable whose bound changed */
222  SCIP_Real oldbound, /**< old bound before bound changed */
223  SCIP_Real newbound /**< new bound after bound changed */
224  );
225 
226 /** creates an event for a change in the global upper bound of a variable */
227 extern
229  SCIP_EVENT** event, /**< pointer to store the event */
230  BMS_BLKMEM* blkmem, /**< block memory */
231  SCIP_VAR* var, /**< variable whose bound changed */
232  SCIP_Real oldbound, /**< old bound before bound changed */
233  SCIP_Real newbound /**< new bound after bound changed */
234  );
235 
236 /** creates an event for a change in the lower bound of a variable */
237 extern
239  SCIP_EVENT** event, /**< pointer to store the event */
240  BMS_BLKMEM* blkmem, /**< block memory */
241  SCIP_VAR* var, /**< variable whose bound changed */
242  SCIP_Real oldbound, /**< old bound before bound changed */
243  SCIP_Real newbound /**< new bound after bound changed */
244  );
245 
246 /** creates an event for a change in the upper bound of a variable */
247 extern
249  SCIP_EVENT** event, /**< pointer to store the event */
250  BMS_BLKMEM* blkmem, /**< block memory */
251  SCIP_VAR* var, /**< variable whose bound changed */
252  SCIP_Real oldbound, /**< old bound before bound changed */
253  SCIP_Real newbound /**< new bound after bound changed */
254  );
255 
256 /** creates an event for an addition of a global domain hole to a variable */
258  SCIP_EVENT** event, /**< pointer to store the event */
259  BMS_BLKMEM* blkmem, /**< block memory */
260  SCIP_VAR* var, /**< variable whose bound changed */
261  SCIP_Real left, /**< left bound of open interval in new hole */
262  SCIP_Real right /**< right bound of open interval in new hole */
263  );
264 
265 /** creates an event for removing a global domain hole of a variable */
267  SCIP_EVENT** event, /**< pointer to store the event */
268  BMS_BLKMEM* blkmem, /**< block memory */
269  SCIP_VAR* var, /**< variable whose bound changed */
270  SCIP_Real left, /**< left bound of open interval in hole */
271  SCIP_Real right /**< right bound of open interval in hole */
272  );
273 
274 /** creates an event for an addition of a local domain hole to a variable */
276  SCIP_EVENT** event, /**< pointer to store the event */
277  BMS_BLKMEM* blkmem, /**< block memory */
278  SCIP_VAR* var, /**< variable whose bound changed */
279  SCIP_Real left, /**< left bound of open interval in new hole */
280  SCIP_Real right /**< right bound of open interval in new hole */
281  );
282 
283 /** creates an event for removing a local domain hole of a variable */
285  SCIP_EVENT** event, /**< pointer to store the event */
286  BMS_BLKMEM* blkmem, /**< block memory */
287  SCIP_VAR* var, /**< variable whose bound changed */
288  SCIP_Real left, /**< left bound of open interval in hole */
289  SCIP_Real right /**< right bound of open interval in hole */
290  );
291 
292 /** creates an event for an addition to the variable's implications list, clique or variable bounds information */
293 extern
295  SCIP_EVENT** event, /**< pointer to store the event */
296  BMS_BLKMEM* blkmem, /**< block memory */
297  SCIP_VAR* var /**< variable that was fixed */
298  );
299 
300 /** creates an event for the addition of a linear row to the separation storage */
301 extern
303  SCIP_EVENT** event, /**< pointer to store the event */
304  BMS_BLKMEM* blkmem, /**< block memory */
305  SCIP_ROW* row /**< row that was added to the separation storage*/
306  );
307 
308 /** creates an event for the deletion of a linear row from the separation storage */
309 extern
311  SCIP_EVENT** event, /**< pointer to store the event */
312  BMS_BLKMEM* blkmem, /**< block memory */
313  SCIP_ROW* row /**< row that was deleted from the separation storage */
314  );
315 
316 /** creates an event for the addition of a linear row to the LP */
317 extern
319  SCIP_EVENT** event, /**< pointer to store the event */
320  BMS_BLKMEM* blkmem, /**< block memory */
321  SCIP_ROW* row /**< row that was added to the LP */
322  );
323 
324 /** creates an event for the deletion of a linear row from the LP */
325 extern
327  SCIP_EVENT** event, /**< pointer to store the event */
328  BMS_BLKMEM* blkmem, /**< block memory */
329  SCIP_ROW* row /**< row that was deleted from the LP */
330  );
331 
332 /** creates an event for the change of a coefficient in a linear row */
333 extern
335  SCIP_EVENT** event, /**< pointer to store the event */
336  BMS_BLKMEM* blkmem, /**< block memory */
337  SCIP_ROW* row, /**< row in which a coefficient changed */
338  SCIP_COL* col, /**< column which coefficient changed */
339  SCIP_Real oldval, /**< old value of coefficient */
340  SCIP_Real newval /**< new value of coefficient */
341  );
342 
343 /** creates an event for the change of a constant in a linear row */
344 extern
346  SCIP_EVENT** event, /**< pointer to store the event */
347  BMS_BLKMEM* blkmem, /**< block memory */
348  SCIP_ROW* row, /**< row in which the constant changed */
349  SCIP_Real oldval, /**< old value of constant */
350  SCIP_Real newval /**< new value of constant */
351  );
352 
353 /** creates an event for the change of a side of a linear row */
354 extern
356  SCIP_EVENT** event, /**< pointer to store the event */
357  BMS_BLKMEM* blkmem, /**< block memory */
358  SCIP_ROW* row, /**< row which side has changed */
359  SCIP_SIDETYPE side, /**< which side has changed */
360  SCIP_Real oldval, /**< old value of side */
361  SCIP_Real newval /**< new value of side */
362  );
363 
364 /** frees an event */
365 extern
367  SCIP_EVENT** event, /**< event to free */
368  BMS_BLKMEM* blkmem /**< block memory buffer */
369  );
370 
371 /** sets type of event */
372 extern
374  SCIP_EVENT* event, /**< event */
375  SCIP_EVENTTYPE eventtype /**< new event type */
376  );
377 
378 /** sets variable for a variable event */
379 extern
381  SCIP_EVENT* event, /**< event */
382  SCIP_VAR* var /**< new variable */
383  );
384 
385 /** sets node for a node or LP event */
386 extern
388  SCIP_EVENT* event, /**< event */
389  SCIP_NODE* node /**< new node */
390  );
391 
392 /** sets solution for a primal solution event */
393 extern
395  SCIP_EVENT* event, /**< event */
396  SCIP_SOL* sol /**< new primal solution */
397  );
398 
399 /** processes event by calling the appropriate event handlers */
400 extern
402  SCIP_EVENT* event, /**< event */
403  SCIP_SET* set, /**< global SCIP settings */
404  SCIP_PRIMAL* primal, /**< primal data; only needed for objchanged events, or NULL */
405  SCIP_LP* lp, /**< current LP data; only needed for obj/boundchanged events, or NULL */
406  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage; only needed for bound change events, or NULL */
407  SCIP_EVENTFILTER* eventfilter /**< event filter for global events; not needed for variable specific events */
408  );
409 
410 
411 
412 /*
413  * Event filter methods
414  */
415 
416 /** creates an event filter */
417 extern
419  SCIP_EVENTFILTER** eventfilter, /**< pointer to store the event filter */
420  BMS_BLKMEM* blkmem /**< block memory buffer */
421  );
422 
423 /** frees an event filter and the associated event data entries */
424 extern
426  SCIP_EVENTFILTER** eventfilter, /**< pointer to store the event filter */
427  BMS_BLKMEM* blkmem, /**< block memory buffer */
428  SCIP_SET* set /**< global SCIP settings */
429  );
430 
431 /** adds element to event filter */
432 extern
434  SCIP_EVENTFILTER* eventfilter, /**< event filter */
435  BMS_BLKMEM* blkmem, /**< block memory buffer */
436  SCIP_SET* set, /**< global SCIP settings */
437  SCIP_EVENTTYPE eventtype, /**< event type to catch */
438  SCIP_EVENTHDLR* eventhdlr, /**< event handler to call for the event processing */
439  SCIP_EVENTDATA* eventdata, /**< event data to pass to the event handler for the event processing */
440  int* filterpos /**< pointer to store position of event filter entry, or NULL */
441  );
442 
443 /** deletes element from event filter */
444 extern
446  SCIP_EVENTFILTER* eventfilter, /**< event filter */
447  BMS_BLKMEM* blkmem, /**< block memory buffer */
448  SCIP_SET* set, /**< global SCIP settings */
449  SCIP_EVENTTYPE eventtype, /**< event type */
450  SCIP_EVENTHDLR* eventhdlr, /**< event handler to call for the event processing */
451  SCIP_EVENTDATA* eventdata, /**< event data to pass to the event handler for the event processing */
452  int filterpos /**< position of event filter entry, or -1 if unknown */
453  );
454 
455 /** processes the event with all event handlers with matching filter setting */
456 extern
458  SCIP_EVENTFILTER* eventfilter, /**< event filter */
459  SCIP_SET* set, /**< global SCIP settings */
460  SCIP_EVENT* event /**< event to process */
461  );
462 
463 
464 
465 /*
466  * Event queue methods
467  */
468 
469 /** creates an event queue */
470 extern
472  SCIP_EVENTQUEUE** eventqueue /**< pointer to store the event queue */
473  );
474 
475 /** frees event queue; there must not be any unprocessed events in the queue! */
476 extern
478  SCIP_EVENTQUEUE** eventqueue /**< pointer to the event queue */
479  );
480 
481 /** processes event or adds event to the event queue */
482 extern
484  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
485  BMS_BLKMEM* blkmem, /**< block memory buffer */
486  SCIP_SET* set, /**< global SCIP settings */
487  SCIP_PRIMAL* primal, /**< primal data; only needed for objchanged events, or NULL */
488  SCIP_LP* lp, /**< current LP data; only needed for obj/boundchanged events, or NULL */
489  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage; only needed for bound change events, or NULL */
490  SCIP_EVENTFILTER* eventfilter, /**< event filter for global events; not needed for variable specific events */
491  SCIP_EVENT** event /**< pointer to event to add to the queue; will be NULL after queue addition */
492  );
493 
494 /** marks queue to delay incoming events until a call to SCIPeventqueueProcess() */
495 extern
497  SCIP_EVENTQUEUE* eventqueue /**< event queue */
498  );
499 
500 /** processes all events in the queue */
501 extern
503  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
504  BMS_BLKMEM* blkmem, /**< block memory buffer */
505  SCIP_SET* set, /**< global SCIP settings */
506  SCIP_PRIMAL* primal, /**< primal data */
507  SCIP_LP* lp, /**< current LP data */
508  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
509  SCIP_EVENTFILTER* eventfilter /**< event filter for global (not variable dependent) events */
510  );
511 
512 /** returns TRUE iff events of the queue are delayed until the next SCIPeventqueueProcess() call */
513 extern
515  SCIP_EVENTQUEUE* eventqueue /**< event queue */
516  );
517 
518 #ifdef __cplusplus
519 }
520 #endif
521 
522 #endif
523