1    	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2    	/*                                                                           */
3    	/*                  This file is part of the program and library             */
4    	/*         SCIP --- Solving Constraint Integer Programs                      */
5    	/*                                                                           */
6    	/*  Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB)                      */
7    	/*                                                                           */
8    	/*  Licensed under the Apache License, Version 2.0 (the "License");          */
9    	/*  you may not use this file except in compliance with the License.         */
10   	/*  You may obtain a copy of the License at                                  */
11   	/*                                                                           */
12   	/*      http://www.apache.org/licenses/LICENSE-2.0                           */
13   	/*                                                                           */
14   	/*  Unless required by applicable law or agreed to in writing, software      */
15   	/*  distributed under the License is distributed on an "AS IS" BASIS,        */
16   	/*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17   	/*  See the License for the specific language governing permissions and      */
18   	/*  limitations under the License.                                           */
19   	/*                                                                           */
20   	/*  You should have received a copy of the Apache-2.0 license                */
21   	/*  along with SCIP; see the file LICENSE. If not visit scipopt.org.         */
22   	/*                                                                           */
23   	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24   	
25   	/**@file   struct_event.h
26   	 * @ingroup INTERNALAPI
27   	 * @brief  datastructures for managing events
28   	 * @author Tobias Achterberg
29   	 */
30   	
31   	/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32   	
33   	#ifndef __SCIP_STRUCT_EVENT_H__
34   	#define __SCIP_STRUCT_EVENT_H__
35   	
36   	
37   	#include "scip/def.h"
38   	#include "scip/type_clock.h"
39   	#include "scip/type_event.h"
40   	#include "scip/type_var.h"
41   	#include "scip/type_sol.h"
42   	#include "scip/type_tree.h"
43   	
44   	#ifdef __cplusplus
45   	extern "C" {
46   	#endif
47   	
48   	/** data for variable addition events */
49   	struct SCIP_EventVarAdded
50   	{
51   	   SCIP_VAR*             var;                /**< variable that was added to the problem */
52   	};
53   	
54   	/** data for variable deletion events */
55   	struct SCIP_EventVarDeleted
56   	{
57   	   SCIP_VAR*             var;                /**< variable that will be deleted from the problem */
58   	};
59   	
60   	/** data for variable fixing events */
61   	struct SCIP_EventVarFixed
62   	{
63   	   SCIP_VAR*             var;                /**< variable that was fixed */
64   	};
65   	
66   	/** data for locks change events */
67   	struct SCIP_EventVarUnlocked
68   	{
69   	   SCIP_VAR*             var;                /**< variable for which the lock numbers were changed */
70   	};
71   	
72   	/** data for objective value change events */
73   	struct SCIP_EventObjChg
74   	{
75   	   SCIP_Real             oldobj;             /**< old objective value before value changed */
76   	   SCIP_Real             newobj;             /**< new objective value after value changed */
77   	   SCIP_VAR*             var;                /**< variable whose objective value changed */
78   	};
79   	
80   	/** data for bound change events */
81   	struct SCIP_EventBdChg
82   	{
83   	   SCIP_Real             oldbound;           /**< old bound before bound changed */
84   	   SCIP_Real             newbound;           /**< new bound after bound changed */
85   	   SCIP_VAR*             var;                /**< variable whose bound changed */
86   	};
87   	
88   	/** data for domain hole events */
89   	struct SCIP_EventHole
90   	{
91   	   SCIP_Real             left;               /**< left bound of open interval in hole */
92   	   SCIP_Real             right;              /**< right bound of open interval in hole */
93   	   SCIP_VAR*             var;                /**< variable for which a hole was removed */
94   	};
95   	
96   	/** data for implication added events */
97   	struct SCIP_EventImplAdd
98   	{
99   	   SCIP_VAR*             var;                /**< variable for which an implication, variable bound, or clique was added */
100  	};
101  	
102  	/** data for variable type change events */
103  	struct SCIP_EventTypeChg
104  	{
105  	   SCIP_VARTYPE          oldtype;            /**< old variable type */
106  	   SCIP_VARTYPE          newtype;            /**< new variable type */
107  	   SCIP_VAR*             var;                /**< variable whose type changed */
108  	};
109  	
110  	/** data for row addition to separation storage events */
111  	struct SCIP_EventRowAddedSepa
112  	{
113  	   SCIP_ROW*             row;                /**< row that was added to separation storage */
114  	};
115  	
116  	/** data for row deletion from separation storage events */
117  	struct SCIP_EventRowDeletedSepa
118  	{
119  	   SCIP_ROW*             row;                /**< row that was deleted from separation storage */
120  	};
121  	
122  	/** data for row addition to LP events */
123  	struct SCIP_EventRowAddedLP
124  	{
125  	   SCIP_ROW*             row;                /**< row that was added to the LP */
126  	};
127  	
128  	/** data for row deletion from LP events */
129  	struct SCIP_EventRowDeletedLP
130  	{
131  	   SCIP_ROW*             row;                /**< row that was deleted from the LP */
132  	};
133  	
134  	/** data for row coefficient change events */
135  	struct SCIP_EventRowCoefChanged
136  	{
137  	   SCIP_ROW*             row;                /**< row which coefficient has changed */
138  	   SCIP_COL*             col;                /**< column which coefficient has changed */
139  	   SCIP_Real             oldval;             /**< old value of coefficient */
140  	   SCIP_Real             newval;             /**< new value of coefficient */
141  	};
142  	
143  	/** data for row constant change events */
144  	struct SCIP_EventRowConstChanged
145  	{
146  	   SCIP_ROW*             row;                /**< row which constant has changed */
147  	   SCIP_Real             oldval;             /**< old value of constant */
148  	   SCIP_Real             newval;             /**< new value of constant */
149  	};
150  	
151  	/** data for row side change events */
152  	struct SCIP_EventRowSideChanged
153  	{
154  	   SCIP_ROW*             row;                /**< row which side has changed */
155  	   SCIP_SIDETYPE         side;               /**< which side has changed */
156  	   SCIP_Real             oldval;             /**< old value of side */
157  	   SCIP_Real             newval;             /**< new value of side */
158  	};
159  	
160  	/** event data structure */
161  	struct SCIP_Event
162  	{
163  	   union
164  	   {
165  	      SCIP_EVENTVARADDED eventvaradded;       /**< data for variable addition events */
166  	      SCIP_EVENTVARDELETED eventvardeleted;   /**< data for variable deletion events */
167  	      SCIP_EVENTVARFIXED eventvarfixed;       /**< data for variable fixing events */
168  	      SCIP_EVENTVARUNLOCKED eventvarunlocked; /**< data for locks change events */
169  	      SCIP_EVENTOBJCHG   eventobjchg;         /**< data for objective value change events */
170  	      SCIP_EVENTBDCHG    eventbdchg;          /**< data for bound change events */
171  	      SCIP_EVENTHOLE     eventhole;           /**< data for domain hole events */
172  	      SCIP_EVENTIMPLADD  eventimpladd;        /**< data for implication added events */
173  	      SCIP_EVENTTYPECHG  eventtypechg;        /**< data for variable type change events */
174  	      SCIP_EVENTROWADDEDSEPA eventrowaddedsepa; /**< data for row addition to separation storage events */
175  	      SCIP_EVENTROWDELETEDSEPA eventrowdeletedsepa; /**< data for row deletion from separation storage events */
176  	      SCIP_EVENTROWADDEDLP eventrowaddedlp;   /**< data for row addition to LP events */
177  	      SCIP_EVENTROWDELETEDLP eventrowdeletedlp; /**< data for row deletion from LP events */
178  	      SCIP_EVENTROWCOEFCHANGED eventrowcoefchanged; /**< data for row coefficient change events */
179  	      SCIP_EVENTROWCONSTCHANGED eventrowconstchanged; /**< data for row constant change events */
180  	      SCIP_EVENTROWSIDECHANGED eventrowsidechanged; /**< data for row side change events */
181  	      SCIP_NODE*         node;                /**< data for node and LP events */
182  	      SCIP_SOL*          sol;                 /**< data for primal solution events */
183  	   } data;
184  	   SCIP_EVENTTYPE        eventtype;          /**< type of event */
185  	};
186  	
187  	/** event filter to select events to be processed by an event handler */
188  	struct SCIP_EventFilter
189  	{
190  	   SCIP_EVENTTYPE*       eventtypes;         /**< array with types of event to process; 0 marks a deleted event catch entry */
191  	   SCIP_EVENTHDLR**      eventhdlrs;         /**< array with event handlers to process the event */
192  	   SCIP_EVENTDATA**      eventdata;          /**< array with user data for the issued event */
193  	   int*                  nextpos;            /**< linked lists for free, delayed added and delayed deleted slot positions */
194  	   int                   size;               /**< size of filter arrays (available slots in arrays) */
195  	   int                   len;                /**< number entries in filter arrays (used and deleted) */
196  	   int                   firstfreepos;       /**< first deleted slot; remaining slots are in poslist */
197  	   int                   firstdeletedpos;    /**< first delayed deleted slot; remaining slots are in poslist */
198  	   SCIP_EVENTTYPE        eventmask;          /**< mask for events that are handled by any event handler in the filter */
199  	   SCIP_EVENTTYPE        delayedeventmask;   /**< mask for delayed added events */
200  	   SCIP_Bool             delayupdates;       /**< should additions and deletions to the filter be delayed? */
201  	};
202  	
203  	/** event handler */
204  	struct SCIP_Eventhdlr
205  	{
206  	   char*                 name;               /**< name of event handler */
207  	   char*                 desc;               /**< description of event handler */
208  	   SCIP_DECL_EVENTCOPY   ((*eventcopy));     /**< copy method of event handler or NULL if you don't want to copy your plugin into sub-SCIPs */
209  	   SCIP_DECL_EVENTFREE   ((*eventfree));     /**< destructor of event handler */
210  	   SCIP_DECL_EVENTINIT   ((*eventinit));     /**< initialize event handler */
211  	   SCIP_DECL_EVENTEXIT   ((*eventexit));     /**< deinitialize event handler */
212  	   SCIP_DECL_EVENTINITSOL((*eventinitsol));  /**< solving process initialization method of event handler */
213  	   SCIP_DECL_EVENTEXITSOL((*eventexitsol));  /**< solving process deinitialization method of event handler */
214  	   SCIP_DECL_EVENTDELETE ((*eventdelete));   /**< free specific event data */
215  	   SCIP_DECL_EVENTEXEC   ((*eventexec));     /**< execute event handler */
216  	   SCIP_EVENTHDLRDATA*   eventhdlrdata;      /**< event handler data */
217  	   SCIP_CLOCK*           setuptime;          /**< time spend for setting up this event handler for the next stages */
218  	   SCIP_CLOCK*           eventtime;          /**< time spend in this event handler execution method */
219  	   SCIP_Bool             initialized;        /**< is event handler initialized? */
220  	};
221  	
222  	/** event queue to cache events and process them later */
223  	struct SCIP_EventQueue
224  	{
225  	   SCIP_EVENT**          events;             /**< array with queued events */
226  	   int                   eventssize;         /**< number of available slots in events array */
227  	   int                   nevents;            /**< number of events in queue (used slots if events array) */
228  	   SCIP_Bool             delayevents;        /**< should the events be delayed and processed later? */
229  	};
230  	
231  	#ifdef __cplusplus
232  	}
233  	#endif
234  	
235  	#endif
236