Scippy

SCIP

Solving Constraint Integer Programs

scip_concurrent.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-2018 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 scip_concurrent.c
17  * @brief public methods for concurrent solving mode
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  * @author Gerald Gamrath
21  * @author Robert Lion Gottwald
22  * @author Stefan Heinz
23  * @author Gregor Hendel
24  * @author Thorsten Koch
25  * @author Alexander Martin
26  * @author Marc Pfetsch
27  * @author Michael Winkler
28  * @author Kati Wolter
29  *
30  * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #include <ctype.h>
36 #include <stdarg.h>
37 #include <assert.h>
38 #include <string.h>
39 #if defined(_WIN32) || defined(_WIN64)
40 #else
41 #include <strings.h> /*lint --e{766}*/
42 #endif
43 
44 
45 #include "lpi/lpi.h"
46 #include "nlpi/exprinterpret.h"
47 #include "nlpi/nlpi.h"
48 #include "scip/benders.h"
49 #include "scip/benderscut.h"
50 #include "scip/branch.h"
51 #include "scip/branch_nodereopt.h"
52 #include "scip/clock.h"
53 #include "scip/compr.h"
54 #include "scip/concsolver.h"
55 #include "scip/concurrent.h"
56 #include "scip/conflict.h"
57 #include "scip/conflictstore.h"
58 #include "scip/cons.h"
59 #include "scip/cons_linear.h"
60 #include "scip/cutpool.h"
61 #include "scip/cuts.h"
62 #include "scip/debug.h"
63 #include "scip/def.h"
64 #include "scip/dialog.h"
65 #include "scip/dialog_default.h"
66 #include "scip/disp.h"
67 #include "scip/event.h"
68 #include "scip/heur.h"
69 #include "scip/heur_ofins.h"
70 #include "scip/heur_reoptsols.h"
72 #include "scip/heuristics.h"
73 #include "scip/history.h"
74 #include "scip/implics.h"
75 #include "scip/interrupt.h"
76 #include "scip/lp.h"
77 #include "scip/mem.h"
78 #include "scip/message_default.h"
79 #include "scip/misc.h"
80 #include "scip/nlp.h"
81 #include "scip/nodesel.h"
82 #include "scip/paramset.h"
83 #include "scip/presol.h"
84 #include "scip/presolve.h"
85 #include "scip/pricer.h"
86 #include "scip/pricestore.h"
87 #include "scip/primal.h"
88 #include "scip/prob.h"
89 #include "scip/prop.h"
90 #include "scip/reader.h"
91 #include "scip/relax.h"
92 #include "scip/reopt.h"
93 #include "scip/retcode.h"
94 #include "scip/scipbuildflags.h"
95 #include "scip/scipcoreplugins.h"
96 #include "scip/scipgithash.h"
97 #include "scip/sepa.h"
98 #include "scip/sepastore.h"
99 #include "scip/set.h"
100 #include "scip/sol.h"
101 #include "scip/solve.h"
102 #include "scip/stat.h"
103 #include "scip/syncstore.h"
104 #include "scip/table.h"
105 #include "scip/tree.h"
106 #include "scip/var.h"
107 #include "scip/visual.h"
108 #include "xml/xml.h"
109 
110 #include "scip/scip_concurrent.h"
111 
112 #include "scip/pub_message.h"
113 
114 
115 /* In debug mode, we include the SCIP's structure in scip.c, such that no one can access
116  * this structure except the interface methods in scip.c.
117  * In optimized mode, the structure is included in scip.h, because some of the methods
118  * are implemented as defines for performance reasons (e.g. the numerical comparisons)
119  */
120 #ifndef NDEBUG
121 #include "scip/struct_scip.h"
122 #endif
123 
124 /** creates a concurrent solver type and includes it in SCIP.
125  *
126  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
127  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
128  *
129  * @pre This method can be called if @p scip is in one of the following stages:
130  * - \ref SCIP_STAGE_INIT
131  * - \ref SCIP_STAGE_PROBLEM
132  */
134  SCIP* scip, /**< SCIP data structure */
135  const char* name, /**< name of concurrent_solver */
136  SCIP_Real prefpriodefault, /**< the default preferred priority of this concurrent solver type */
137  SCIP_DECL_CONCSOLVERCREATEINST ((*concsolvercreateinst)), /**< data copy method of concurrent solver */
138  SCIP_DECL_CONCSOLVERDESTROYINST ((*concsolverdestroyinst)), /**< data copy method of concurrent solver */
139  SCIP_DECL_CONCSOLVERINITSEEDS ((*concsolverinitseeds)), /**< initialize random seeds of concurrent solver */
140  SCIP_DECL_CONCSOLVEREXEC ((*concsolverexec)), /**< execution method of concurrent solver */
141  SCIP_DECL_CONCSOLVERCOPYSOLVINGDATA ((*concsolvercopysolvdata)),/**< method to copy solving data */
142  SCIP_DECL_CONCSOLVERSTOP ((*concsolverstop)), /**< terminate solving in concurrent solver */
143  SCIP_DECL_CONCSOLVERSYNCWRITE ((*concsolversyncwrite)), /**< synchronization method of concurrent solver */
144  SCIP_DECL_CONCSOLVERSYNCREAD ((*concsolversyncread)), /**< synchronization method of concurrent solver */
145  SCIP_DECL_CONCSOLVERTYPEFREEDATA ((*concsolvertypefreedata)),/**< method to free data of concurrent solver type */
146  SCIP_CONCSOLVERTYPEDATA* data /**< the concurent solver type's data */
147  )
148 {
149  SCIP_CONCSOLVERTYPE* concsolvertype;
150 
151  SCIP_CALL( SCIPcheckStage(scip, "SCIPincludeConcsolverType", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
152 
153  /* check whether concurrent solver type is already present */
154  if( SCIPfindConcsolverType(scip, name) != NULL )
155  {
156  SCIPerrorMessage("concurrent solver type <%s> already included.\n", name);
157  return SCIP_INVALIDDATA;
158  }
159 
160  SCIP_CALL( SCIPconcsolverTypeCreate(&concsolvertype, scip->set, scip->messagehdlr, scip->mem->setmem,
161  name, prefpriodefault, concsolvercreateinst, concsolverdestroyinst,
162  concsolverinitseeds, concsolverexec, concsolvercopysolvdata,
163  concsolverstop, concsolversyncwrite, concsolversyncread,
164  concsolvertypefreedata, data) );
165 
166  SCIP_CALL( SCIPsetIncludeConcsolverType(scip->set, concsolvertype) );
167 
168  return SCIP_OKAY;
169 }
170 
171 /** returns the concurrent solver type with the given name, or NULL if not existing */
173  SCIP* scip, /**< SCIP data structure */
174  const char* name /**< name of concurrent_solver */
175  )
176 {
177  assert(scip != NULL);
178  assert(scip->set != NULL);
179  assert(name != NULL);
180 
181  return SCIPsetFindConcsolverType(scip->set, name);
182 }
183 
184 /** returns the array of included concurrent solver types */
186  SCIP* scip /**< SCIP data structure */
187  )
188 {
189  assert(scip != NULL);
190  assert(scip->set != NULL);
191 
192  return scip->set->concsolvertypes;
193 }
194 
195 /** returns the number of included concurrent solver types */
197  SCIP* scip /**< SCIP data structure */
198  )
199 {
200  assert(scip != NULL);
201  assert(scip->set != NULL);
202 
203  return scip->set->nconcsolvertypes;
204 }
205 
206 /** Constructs the parallel interface to execute processes concurrently.
207  *
208  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
209  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
210  *
211  * @pre This method can be called if @p scip is in one of the following stages:
212  * - \ref SCIP_STAGE_PROBLEM
213  * - \ref SCIP_STAGE_TRANSFORMING
214  * - \ref SCIP_STAGE_TRANSFORMED
215  * - \ref SCIP_STAGE_INITPRESOLVE
216  * - \ref SCIP_STAGE_PRESOLVING
217  * - \ref SCIP_STAGE_EXITPRESOLVE
218  * - \ref SCIP_STAGE_PRESOLVED
219  * - \ref SCIP_STAGE_INITSOLVE
220  * - \ref SCIP_STAGE_SOLVING
221  * - \ref SCIP_STAGE_SOLVED
222  * - \ref SCIP_STAGE_EXITSOLVE
223  * - \ref SCIP_STAGE_FREETRANS
224  *
225  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
226  */
228  SCIP* scip /**< SCIP data structure */
229  )
230 {
231  SCIP_CALL( SCIPcheckStage(scip, "SCIPconstructSyncstore", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
232 
234 
235  return SCIP_OKAY;
236 }
237 
238 /** releases the current parallel interface
239  *
240  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
241  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
242  *
243  * @pre This method can be called if @p scip is in one of the following stages:
244  * - \ref SCIP_STAGE_PROBLEM
245  * - \ref SCIP_STAGE_TRANSFORMING
246  * - \ref SCIP_STAGE_TRANSFORMED
247  * - \ref SCIP_STAGE_INITPRESOLVE
248  * - \ref SCIP_STAGE_PRESOLVING
249  * - \ref SCIP_STAGE_EXITPRESOLVE
250  * - \ref SCIP_STAGE_PRESOLVED
251  * - \ref SCIP_STAGE_INITSOLVE
252  * - \ref SCIP_STAGE_SOLVING
253  * - \ref SCIP_STAGE_SOLVED
254  * - \ref SCIP_STAGE_EXITSOLVE
255  * - \ref SCIP_STAGE_FREETRANS
256  * - \ref SCIP_STAGE_FREE
257  *
258  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
259  */
261  SCIP* scip /**< SCIP data structure */
262  )
263 {
264  SCIP_CALL( SCIPcheckStage(scip, "SCIPfreeSyncstore", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE) );
265 
267 
268  return SCIP_OKAY;
269 }
270 
271 /** Gets the parallel interface to execute processes concurrently.
272  *
273  * @return the \ref SCIP_SYNCSTORE parallel interface pointer to submit jobs for concurrent processing.
274  *
275  * @pre This method can be called if @p scip is in one of the following stages:
276  * - \ref SCIP_STAGE_INIT
277  * - \ref SCIP_STAGE_PROBLEM
278  * - \ref SCIP_STAGE_TRANSFORMING
279  * - \ref SCIP_STAGE_TRANSFORMED
280  * - \ref SCIP_STAGE_INITPRESOLVE
281  * - \ref SCIP_STAGE_PRESOLVING
282  * - \ref SCIP_STAGE_EXITPRESOLVE
283  * - \ref SCIP_STAGE_PRESOLVED
284  * - \ref SCIP_STAGE_INITSOLVE
285  * - \ref SCIP_STAGE_SOLVING
286  * - \ref SCIP_STAGE_SOLVED
287  * - \ref SCIP_STAGE_EXITSOLVE
288  * - \ref SCIP_STAGE_FREETRANS
289  *
290  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
291  */
293  SCIP* scip /**< SCIP data structure */
294  )
295 {
296  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSyncstore", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
297 
298  return scip->syncstore;
299 }
int nconcsolvertypes
Definition: struct_set.h:132
internal methods for separators
struct SCIP_ConcSolverTypeData SCIP_CONCSOLVERTYPEDATA
#define NULL
Definition: def.h:239
internal methods for managing events
default message handler
trivialnegation primal heuristic
internal methods for storing primal CIP solutions
SCIP_RETCODE SCIPsyncstoreRelease(SCIP_SYNCSTORE **syncstore)
Definition: syncstore.c:77
#define SCIP_DECL_CONCSOLVERSYNCREAD(x)
methods to interpret (evaluate) an expression tree "fast"
internal methods for branch and bound tree
methods for implications, variable bounds, and cliques
internal methods for clocks and timing issues
internal methods for NLPI solver interfaces
interface methods for specific LP solvers
internal methods for displaying statistics tables
SCIP_RETCODE SCIPconcsolverTypeCreate(SCIP_CONCSOLVERTYPE **concsolvertype, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, SCIP_Real prefpriodefault, SCIP_DECL_CONCSOLVERCREATEINST((*concsolvercreateinst)), SCIP_DECL_CONCSOLVERDESTROYINST((*concsolverdestroyinst)), SCIP_DECL_CONCSOLVERINITSEEDS((*concsolverinitseeds)), SCIP_DECL_CONCSOLVEREXEC((*concsolverexec)), SCIP_DECL_CONCSOLVERCOPYSOLVINGDATA((*concsolvercopysolvdata)), SCIP_DECL_CONCSOLVERSTOP((*concsolverstop)), SCIP_DECL_CONCSOLVERSYNCWRITE((*concsolversyncwrite)), SCIP_DECL_CONCSOLVERSYNCREAD((*concsolversyncread)), SCIP_DECL_CONCSOLVERTYPEFREEDATA((*concsolvertypefreedata)), SCIP_CONCSOLVERTYPEDATA *data)
Definition: concsolver.c:103
#define SCIP_DECL_CONCSOLVEREXEC(x)
#define FALSE
Definition: def.h:65
methods for the aggregation rows
internal methods for Benders&#39; decomposition
#define TRUE
Definition: def.h:64
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
methods commonly used by primal heuristics
internal methods for branching rules and branching candidate storage
datastructures for concurrent solvers
internal methods for handling parameter settings
SCIP_RETCODE SCIPsetIncludeConcsolverType(SCIP_SET *set, SCIP_CONCSOLVERTYPE *concsolvertype)
Definition: set.c:4330
methods for creating output for visualization tools (VBC, BAK)
nodereopt branching rule
internal methods for LP management
#define SCIP_DECL_CONCSOLVERDESTROYINST(x)
internal methods for branching and inference history
internal methods for collecting primal CIP solutions and primal informations
SCIP_RETCODE SCIPconstructSyncstore(SCIP *scip)
internal methods for propagators
#define SCIP_DECL_CONCSOLVERSTOP(x)
SCIP_MEM * mem
Definition: struct_scip.h:61
SCIP_RETCODE SCIPincludeConcsolverType(SCIP *scip, const char *name, SCIP_Real prefpriodefault, SCIP_DECL_CONCSOLVERCREATEINST((*concsolvercreateinst)), SCIP_DECL_CONCSOLVERDESTROYINST((*concsolverdestroyinst)), SCIP_DECL_CONCSOLVERINITSEEDS((*concsolverinitseeds)), SCIP_DECL_CONCSOLVEREXEC((*concsolverexec)), SCIP_DECL_CONCSOLVERCOPYSOLVINGDATA((*concsolvercopysolvdata)), SCIP_DECL_CONCSOLVERSTOP((*concsolverstop)), SCIP_DECL_CONCSOLVERSYNCWRITE((*concsolversyncwrite)), SCIP_DECL_CONCSOLVERSYNCREAD((*concsolversyncread)), SCIP_DECL_CONCSOLVERTYPEFREEDATA((*concsolvertypefreedata)), SCIP_CONCSOLVERTYPEDATA *data)
git hash methods
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:45
methods for block memory pools and memory buffers
SCIP_SYNCSTORE * syncstore
Definition: struct_scip.h:98
register additional core functionality that is designed as plugins
SCIP_RETCODE SCIPcheckStage(SCIP *scip, const char *method, SCIP_Bool init, SCIP_Bool problem, SCIP_Bool transforming, SCIP_Bool transformed, SCIP_Bool initpresolve, SCIP_Bool presolving, SCIP_Bool exitpresolve, SCIP_Bool presolved, SCIP_Bool initsolve, SCIP_Bool solving, SCIP_Bool solved, SCIP_Bool exitsolve, SCIP_Bool freetrans, SCIP_Bool freescip)
Definition: debug.c:1933
internal methods for presolvers
internal methods for NLP management
internal miscellaneous methods
SCIP_CONCSOLVERTYPE ** concsolvertypes
Definition: struct_set.h:90
internal methods for node selectors and node priority queues
internal methods for variable pricers
internal methods for global SCIP settings
internal methods for storing conflicts
#define SCIP_CALL(x)
Definition: def.h:351
SCIP main data structure.
#define SCIP_DECL_CONCSOLVERINITSEEDS(x)
BMS_BLKMEM * setmem
Definition: struct_mem.h:39
internal methods for storing priced variables
internal methods for relaxators
internal methods for storing separated cuts
methods commonly used for presolving
methods for catching the user CTRL-C interrupt
internal methods for problem variables
data structures and methods for collecting reoptimization information
the function declarations for the synchronization store
internal methods for user interface dialog
SCIP_RETCODE SCIPfreeSyncstore(SCIP *scip)
SCIP_SYNCSTORE * SCIPgetSyncstore(SCIP *scip)
public methods for concurrent solving mode
internal methods for input file readers
methods for debugging
#define SCIP_DECL_CONCSOLVERCOPYSOLVINGDATA(x)
reoptsols primal heuristic
internal methods for storing cuts in a cut pool
Constraint handler for linear constraints in their most general form, .
#define SCIP_DECL_CONCSOLVERTYPEFREEDATA(x)
int SCIPgetNConcsolverTypes(SCIP *scip)
helper functions for concurrent scip solvers
SCIP_CONCSOLVERTYPE ** SCIPgetConcsolverTypes(SCIP *scip)
SCIP_RETCODE SCIPsyncstoreCreate(SCIP_SYNCSTORE **syncstore)
Definition: syncstore.c:56
internal methods for return codes for SCIP methods
internal methods for conflict analysis
internal methods for tree compressions
internal methods for main solving loop and node processing
SCIP_SET * set
Definition: struct_scip.h:62
public methods for message output
SCIP_MESSAGEHDLR * messagehdlr
Definition: struct_scip.h:65
default user interface dialog
#define SCIP_Real
Definition: def.h:150
internal methods for problem statistics
internal methods for constraints and constraint handlers
declarations for XML parsing
build flags methods
common defines and data types used in all packages of SCIP
#define SCIP_CALL_ABORT(x)
Definition: def.h:330
internal methods for primal heuristics
#define SCIP_DECL_CONCSOLVERSYNCWRITE(x)
#define SCIP_DECL_CONCSOLVERCREATEINST(x)
SCIP_CONCSOLVERTYPE * SCIPfindConcsolverType(SCIP *scip, const char *name)
SCIP_CONCSOLVERTYPE * SCIPsetFindConcsolverType(SCIP_SET *set, const char *name)
Definition: set.c:4352
internal methods for Benders&#39; decomposition cuts
internal methods for displaying runtime statistics
OFINS - Objective Function Induced Neighborhood Search - a primal heuristic for reoptimization.