Scippy

SCIP

Solving Constraint Integer Programs

concsolver.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 concsolver.c
17  * @brief methods for concurrent solvers
18  * @author Robert Lion Gottwald
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #include <assert.h>
24 #include <string.h>
25 
26 #include "scip/concsolver.h"
27 #include "scip/set.h"
28 #include "scip/scip.h"
29 #include "scip/concurrent.h"
30 
31 #include "scip/struct_concsolver.h"
32 #include "scip/struct_stat.h"
33 #include "scip/struct_scip.h"
34 #include "blockmemshell/memory.h"
35 #include "scip/syncstore.h"
36 #include "scip/boundstore.h"
37 #include "scip/clock.h"
38 
39 
40 /** internal method for creating a concurrent solver type */
41 static
43  SCIP_CONCSOLVERTYPE** concsolvertype, /**< pointer to concurrent solver data structure */
44  SCIP_SET* set, /**< global SCIP settings */
45  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
46  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
47  const char* name, /**< name of concurrent solver */
48  SCIP_Real prefpriodefault, /**< the default preferred priority of this concurrent solver type */
49  SCIP_DECL_CONCSOLVERCREATEINST ((*concsolvercreateinst)),/**< data copy method of concurrent solver */
50  SCIP_DECL_CONCSOLVERDESTROYINST ((*concsolverdestroyinst)),/**< data copy method of concurrent solver */
51  SCIP_DECL_CONCSOLVERINITSEEDS ((*concsolverinitseeds)),/**< initialize random seeds of concurrent solver */
52  SCIP_DECL_CONCSOLVEREXEC ((*concsolverexec)),/**< execution method of concurrent solver */
53  SCIP_DECL_CONCSOLVERCOPYSOLVINGDATA ((*concsolvercopysolvdata)),/**< method to copy solving data */
54  SCIP_DECL_CONCSOLVERSTOP ((*concsolverstop)),/**< terminate solving in concurrent solver */
55  SCIP_DECL_CONCSOLVERSYNCWRITE ((*concsolversyncwrite)),/**< synchronization method of concurrent solver */
56  SCIP_DECL_CONCSOLVERSYNCREAD ((*concsolversyncread)),/**< synchronization method of concurrent solver */
57  SCIP_DECL_CONCSOLVERTYPEFREEDATA ((*concsolvertypefreedata)),/**< method to free data of concurrent solver type */
58  SCIP_CONCSOLVERTYPEDATA* data /**< the concurent solver type's data */
59  )
60 {
61  char paramname[SCIP_MAXSTRLEN];
62  char paramdesc[SCIP_MAXSTRLEN];
63 
64  assert(concsolvertype != NULL);
65  assert(name != NULL);
66  assert(prefpriodefault >= 0.0 && prefpriodefault <= 1.0);
67 
68  assert(concsolvercreateinst != NULL);
69  assert(concsolverdestroyinst != NULL);
70  assert(concsolverexec != NULL);
71  assert(concsolvercopysolvdata != NULL);
72  assert(concsolverstop != NULL);
73  assert(concsolversyncwrite != NULL);
74  assert(concsolversyncread != NULL);
75 
76  SCIP_ALLOC( BMSallocMemory(concsolvertype) );
77  BMSclearMemory(*concsolvertype);
78 
79  SCIP_ALLOC( BMSduplicateMemoryArray(&(*concsolvertype)->name, name, strlen(name) + 1) );
80 
81  (*concsolvertype)->data = data;
82  (*concsolvertype)->ninstances = 0;
83  (*concsolvertype)->concsolvercreateinst = concsolvercreateinst;
84  (*concsolvertype)->concsolverdestroyinst = concsolverdestroyinst;
85  (*concsolvertype)->concsolverinitseeds = concsolverinitseeds;
86  (*concsolvertype)->concsolverexec = concsolverexec;
87  (*concsolvertype)->concsolvercopysolvdata = concsolvercopysolvdata;
88  (*concsolvertype)->concsolverstop = concsolverstop;
89  (*concsolvertype)->concsolversyncwrite = concsolversyncwrite;
90  (*concsolvertype)->concsolversyncread = concsolversyncread;
91  (*concsolvertype)->concsolvertypefreedata = concsolvertypefreedata;
92 
93  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "concurrent/%s/prefprio", name);
94  (void) SCIPsnprintf(paramdesc, SCIP_MAXSTRLEN, "the preferred number concurrent solvers of type <%s> with respect to the number of threads", name);
95  SCIP_CALL( SCIPsetAddRealParam(set, messagehdlr, blkmem, paramname, paramdesc,
96  &(*concsolvertype)->prefprio, FALSE, prefpriodefault, 0.0, 1.0,
97  NULL, NULL) ); /*lint !e740*/
98 
99  return SCIP_OKAY;
100 }
101 
102 /** creates a concurrent solver type */
104  SCIP_CONCSOLVERTYPE** concsolvertype, /**< pointer to concurrent solver data structure */
105  SCIP_SET* set, /**< global SCIP settings */
106  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
107  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
108  const char* name, /**< name of concurrent solver */
109  SCIP_Real prefpriodefault, /**< the default preferred priority of this concurrent solver type */
110  SCIP_DECL_CONCSOLVERCREATEINST ((*concsolvercreateinst)),/**< data copy method of concurrent solver */
111  SCIP_DECL_CONCSOLVERDESTROYINST ((*concsolverdestroyinst)),/**< data copy method of concurrent solver */
112  SCIP_DECL_CONCSOLVERINITSEEDS ((*concsolverinitseeds)),/**< initialize random seeds of concurrent solver */
113  SCIP_DECL_CONCSOLVEREXEC ((*concsolverexec)),/**< execution method of concurrent solver */
114  SCIP_DECL_CONCSOLVERCOPYSOLVINGDATA ((*concsolvercopysolvdata)),/**< method to copy solving data */
115  SCIP_DECL_CONCSOLVERSTOP ((*concsolverstop)),/**< terminate solving in concurrent solver */
116  SCIP_DECL_CONCSOLVERSYNCWRITE ((*concsolversyncwrite)),/**< synchronization method of concurrent solver */
117  SCIP_DECL_CONCSOLVERSYNCREAD ((*concsolversyncread)),/**< synchronization method of concurrent solver */
118  SCIP_DECL_CONCSOLVERTYPEFREEDATA ((*concsolvertypefreedata)),/**< method to free data of concurrent solver type */
119  SCIP_CONCSOLVERTYPEDATA* data /**< the concurent solver type's data */
120  )
121 {
122  assert(concsolvertype != NULL);
123  assert(name != NULL);
124  assert(prefpriodefault >= 0.0 && prefpriodefault <= 1.0);
125 
126  assert(concsolvercreateinst != NULL);
127  assert(concsolverdestroyinst != NULL);
128  assert(concsolverexec != NULL);
129  assert(concsolvercopysolvdata != NULL);
130  assert(concsolverstop != NULL);
131  assert(concsolversyncwrite != NULL);
132  assert(concsolversyncread != NULL);
133 
134  SCIP_CALL_FINALLY( doConcsolverTypeCreate(concsolvertype, set, messagehdlr, blkmem,
135  name, prefpriodefault, concsolvercreateinst, concsolverdestroyinst, concsolverinitseeds, concsolverexec,
136  concsolvercopysolvdata, concsolverstop, concsolversyncwrite, concsolversyncread, concsolvertypefreedata, data),
137  SCIPconcsolverTypeFree(concsolvertype) );
138 
139  return SCIP_OKAY;
140 }
141 
142 /** frees all memory of a concurrent solver type */
144  SCIP_CONCSOLVERTYPE** concsolvertype /**< pointer to concurrent solver data structure */
145  )
146 {
147  assert(concsolvertype != NULL);
148  if( *concsolvertype == NULL )
149  return;
150 
151  if( (*concsolvertype)->concsolvertypefreedata != NULL )
152  (*concsolvertype)->concsolvertypefreedata(&(*concsolvertype)->data);
153 
154  BMSfreeMemoryArrayNull(&(*concsolvertype)->name);
155  BMSfreeMemory(concsolvertype);
156 }
157 
158 /** gets the data of a concurrent solver type */
160  SCIP_CONCSOLVERTYPE* concsolvertype /**< concurrent solver type */
161  )
162 {
163  assert(concsolvertype != NULL);
164 
165  return concsolvertype->data;
166 }
167 
168 /** sets the data of a concurrent solver type */
170  SCIP_CONCSOLVERTYPE* concsolvertype, /**< concurrent solver type */
171  SCIP_CONCSOLVERTYPEDATA* data /**< the concurrent solver's data */
172  )
173 {
174  assert(concsolvertype != NULL);
175 
176  concsolvertype->data = data;
177 }
178 
179 /** gets the name of a concurrent solver type */
181  SCIP_CONCSOLVERTYPE* concsolvertype /**< concurrent solver type */
182  )
183 {
184  assert(concsolvertype != NULL);
185 
186  return concsolvertype->name;
187 }
188 
189 /** gets the preferred priority from a concurrent solver type */
191  SCIP_CONCSOLVERTYPE* concsolvertype /**< concurrent solver type */
192  )
193 {
194  assert(concsolvertype != NULL);
195 
196  return concsolvertype->prefprio;
197 }
198 
199 /** creates an instance of the given concurrent solver type */
201  SCIP_SET* set, /**< global SCIP settings */
202  SCIP_CONCSOLVERTYPE* concsolvertype, /**< concurrent solver type to create */
203  SCIP_CONCSOLVER** concsolver /**< pointer to return concurrent solver instance */
204  )
205 {
206  char instancename[SCIP_MAXSTRLEN];
207 
208  ++concsolvertype->ninstances;
209  (void) SCIPsnprintf(instancename, SCIP_MAXSTRLEN, "%s-%i", concsolvertype->name, concsolvertype->ninstances);
210 
211  SCIP_ALLOC( BMSallocMemory(concsolver) );
212  SCIP_ALLOC( BMSduplicateMemoryArray(&(*concsolver)->name, instancename, strlen(instancename) + 1) );
213 
214  (*concsolver)->type = concsolvertype;
215 
216  /* initialize counters for statistics */
217  (*concsolver)->nsolsrecvd = 0;
218  (*concsolver)->nsolsshared = 0;
219  (*concsolver)->ntighterbnds = 0;
220  (*concsolver)->ntighterintbnds = 0;
221  SCIP_CALL( SCIPcreateWallClock(set->scip, &(*concsolver)->totalsynctime) );
222 
223  /* initialize synchronization fields */
224  (*concsolver)->nsyncs = 0;
225  (*concsolver)->syncdelay = 0.0;
226 
227  /* in deterministic mode use number of nonzeros and variables to get a good initial synchronization frequency
228  * in opportunistic mode use the frequency as set by the user
229  */
230  if( set->parallel_mode == (int) SCIP_PARA_DETERMINISTIC )
231  (*concsolver)->syncfreq = 0.01 * set->scip->stat->nnz * SCIPgetNVars(set->scip) * set->concurrent_freqinit;
232  else
233  (*concsolver)->syncfreq = set->concurrent_freqinit;
234 
235  (*concsolver)->syncdata = NULL;
236 
237  SCIPdebugMessage("concsolver %s initialized sync freq to %f\n", (*concsolver)->name, (*concsolver)->syncfreq);
238  /* register concurrent solver */
239  (*concsolver)->idx = SCIPgetNConcurrentSolvers(set->scip);
240  SCIP_CALL( concsolvertype->concsolvercreateinst(set->scip, concsolvertype, *concsolver) );
241  SCIP_CALL( SCIPaddConcurrentSolver(set->scip, *concsolver) );
242 
243  return SCIP_OKAY;
244 }
245 
246 /** destroys an instance of the given concurrent solver */
248  SCIP_SET* set, /**< global SCIP settings */
249  SCIP_CONCSOLVER** concsolver /**< concurrent solver */
250  )
251 {
252  assert(concsolver != NULL);
253  assert((*concsolver)->type != NULL);
254  assert(set != NULL);
255  assert((*concsolver)->type->concsolverdestroyinst != NULL);
256 
257  SCIP_CALL( (*concsolver)->type->concsolverdestroyinst(set->scip, *concsolver) );
258  --(*concsolver)->type->ninstances;
259 
260  SCIP_CALL( SCIPfreeClock(set->scip, &(*concsolver)->totalsynctime) );
261  BMSfreeMemoryArray(&(*concsolver)->name);
262 
263  BMSfreeMemory(concsolver);
264 
265  return SCIP_OKAY;
266 }
267 
268 /** gets the data of a concurrent solver */
270  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
271  )
272 {
273  assert(concsolver != NULL);
274 
275  return concsolver->data;
276 }
277 
278 /** sets the data of a concurrent solver */
280  SCIP_CONCSOLVER* concsolver, /**< concurrent solver */
281  SCIP_CONCSOLVERDATA* data /**< the concurrent solver's data */
282  )
283 {
284  assert(concsolver != NULL);
285 
286  concsolver->data = data;
287 }
288 
289 /** gets the name of a concurrent solver */
291  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
292  )
293 {
294  assert(concsolver != NULL);
295 
296  return concsolver->name;
297 }
298 
299 /** initializes the random seeds of a concurrent solver */
301  SCIP_CONCSOLVER* concsolver, /**< concurrent solver */
302  unsigned int seed /**< seed for initializing the solver's internal random seeds */
303  )
304 {
305  assert(concsolver != NULL);
306  assert(concsolver->type != NULL);
307 
308  if( concsolver->type->concsolverinitseeds != NULL )
309  SCIP_CALL( concsolver->type->concsolverinitseeds(concsolver, seed) );
310 
311  return SCIP_OKAY;
312 }
313 
314 /** start the solving process of a concurrent solver */
316  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
317  )
318 {
319  assert(concsolver != NULL);
320  assert(concsolver->type != NULL);
321  assert(concsolver->type->concsolverexec != NULL);
322 
323  /* set the stopped flag to false */
324  concsolver->stopped = FALSE;
325 
326  /* then call the execute callback */
327  SCIP_CALL( concsolver->type->concsolverexec(concsolver, &concsolver->solvingtime, &concsolver->nlpiterations, &concsolver->nnodes) );
328 
329  return SCIP_OKAY;
330 }
331 
332 /** gets solving data of concurrent solver and stores it in the given SCIP instance */
334  SCIP_CONCSOLVER* concsolver, /**< concurrent solver */
335  SCIP* scip /**< SCIP datastructure */
336  )
337 {
338  assert(concsolver != NULL);
339  assert(concsolver->type != NULL);
340  assert(concsolver->type->concsolvercopysolvdata != NULL);
341 
342  return concsolver->type->concsolvercopysolvdata(concsolver, scip);
343 }
344 
345 /** interrupt solving in a concurrent solver */
347  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
348  )
349 {
350  assert(concsolver != NULL);
351  assert(concsolver->type != NULL);
352  assert(concsolver->type->concsolverstop != NULL);
353 
354  SCIP_CALL( concsolver->type->concsolverstop(concsolver) );
355 
356  /* set the stopped flag to true */
357  concsolver->stopped = TRUE;
358 
359  return SCIP_OKAY;
360 }
361 
362 /** let the given concurrent solver synchronize, i.e. pass its own solutions and bounds to
363  * the SPI.
364  */
366  SCIP_CONCSOLVER* concsolver, /**< concurrent solver */
367  SCIP_SET* set /**< global SCIP settings */
368  )
369 {
370  SCIP_SYNCDATA* syncdata;
371  SCIP_SYNCSTORE* syncstore;
372  int nsols;
373  int ntighterintbnds;
374  int ntighterbnds;
375  SCIP_CONCSOLVERTYPE* concsolvertype;
376 
377  assert(concsolver != NULL);
378  assert(concsolver->type != NULL);
379  assert(concsolver->type->concsolversyncwrite != NULL);
380  assert(concsolver->type->concsolversyncread != NULL);
381 
382  if( concsolver->stopped )
383  return SCIP_OKAY;
384 
385  SCIP_CALL( SCIPstartClock(set->scip, concsolver->totalsynctime) );
386 
387  concsolvertype = concsolver->type;
388 
389  syncstore = SCIPgetSyncstore(set->scip);
390  assert(syncstore != NULL);
391 
392  SCIP_CALL( SCIPsyncstoreStartSync(syncstore, concsolver->nsyncs, &syncdata) );
393 
394  if( syncdata == NULL )
395  {
396  SCIP_CALL( SCIPstopClock(set->scip, concsolver->totalsynctime) );
397  return SCIP_OKAY;
398  }
399 
400  SCIPdebugMessage("concsolver %s starts sync %lli\n", concsolver->name, concsolver->nsyncs);
401 
402  SCIP_CALL( concsolvertype->concsolversyncwrite(concsolver, syncstore, syncdata, set->concurrent_nbestsols, set->concurrent_maxnsols, &nsols) );
403  concsolver->nsolsshared += nsols;
404 
405  if( SCIPsyncdataGetStatus(syncdata) != SCIP_STATUS_UNKNOWN )
406  {
407  SCIP_CALL( SCIPconcsolverStop(concsolver) );
408  }
409  else if( SCIPsyncdataGetNSynced(syncdata) == SCIPsyncstoreGetNSolvers(syncstore) - 1 )
410  {
411  /* if this is the last concurrent solver that is synchronizing for this synchronization data
412  * it will adjust the synchronization frequency using the progress on the gap
413  */
414  SCIP_Bool lbok;
415  SCIP_Bool ubok;
416  SCIP_Real progress;
417  SCIP_Real prevub;
418  SCIP_Real prevlb;
419  SCIP_Real newub;
420  SCIP_Real newlb;
421  SCIP_Real freqfactor;
422  SCIP_Real newsyncfreq;
423  SCIP_SYNCDATA* prevsync;
424 
425  if( concsolver->nsyncs == 0 )
426  {
427  SCIPsyncdataSetSyncFreq(syncstore, syncdata, concsolver->syncfreq);
428  }
429  else
430  {
431  prevsync = SCIPsyncstoreGetSyncdata(syncstore, concsolver->nsyncs - 1);
432  assert(SCIPsyncdataGetNSynced(prevsync) == SCIPsyncstoreGetNSolvers(syncstore));
433 
434  prevub = SCIPsyncdataGetUpperbound(prevsync);
435  prevlb = SCIPsyncdataGetLowerbound(prevsync);
436  newub = SCIPsyncdataGetUpperbound(syncdata);
437  newlb = SCIPsyncdataGetLowerbound(syncdata);
438  lbok = prevlb > -SCIPsetInfinity(set);
439  ubok = prevub < SCIPsetInfinity(set);
440 
441  if( lbok && ubok )
442  progress = SCIPrelDiff(prevub - prevlb, newub - newlb);
443  else if( lbok )
444  progress = SCIPrelDiff(newlb, prevlb);
445  else if( ubok )
446  progress = SCIPrelDiff(prevub, newub);
447  else if( !SCIPsetIsInfinity(set, -newlb) || !SCIPsetIsInfinity(set, newub) ||
449  progress = set->concurrent_targetprogress;
450  else
451  progress = 0.0;
452 
453  /* should not be negative */
454  assert(SCIPsetIsGE(set, progress, 0.0));
455 
456  if( progress < 0.5 * set->concurrent_targetprogress )
457  freqfactor = set->concurrent_freqfactor;
458  else if( progress > 2 * set->concurrent_targetprogress )
459  freqfactor = 0.5 + 0.5 / set->concurrent_freqfactor;
460  else
461  freqfactor = 1.0;
462 
463  SCIPdebugMessage("syncfreq is %g and freqfactor is %f due to progress %f\n", concsolver->syncfreq, freqfactor, progress);
464  newsyncfreq = concsolver->syncfreq * freqfactor;
465  SCIPsyncdataSetSyncFreq(syncstore, syncdata, newsyncfreq);
466  SCIPdebugMessage("new syncfreq is %g\n", SCIPsyncdataGetSyncFreq(syncdata));
467  }
468  }
469 
470  SCIPdebugMessage("concsolver %s finishing sync %lli\n", concsolver->name, concsolver->nsyncs);
471 
472  SCIP_CALL( SCIPsyncstoreFinishSync(syncstore, &syncdata) );
473  ++concsolver->nsyncs;
474 
475  concsolver->syncdelay += concsolver->timesincelastsync;
476 
477  syncdata = SCIPsyncstoreGetNextSyncdata(syncstore, concsolver->syncdata, concsolver->syncfreq, concsolver->nsyncs, &concsolver->syncdelay);
478 
479  while( syncdata != NULL )
480  {
481  SCIP_CALL( SCIPsyncstoreEnsureAllSynced(syncstore, syncdata) );
482  concsolver->syncdata = syncdata;
483  SCIP_CALL( concsolvertype->concsolversyncread(concsolver, syncstore, syncdata, &nsols, &ntighterbnds, &ntighterintbnds) );
484  concsolver->ntighterbnds += ntighterbnds;
485  concsolver->ntighterintbnds += ntighterintbnds;
486  concsolver->nsolsrecvd += nsols;
487  SCIPdebugMessage("syncfreq before reading the next syncdata is %g\n", concsolver->syncfreq);
488  concsolver->syncfreq = SCIPsyncdataGetSyncFreq(concsolver->syncdata);
489  SCIPdebugMessage("syncfreq after reading the next syncdata is %g\n", concsolver->syncfreq);
490  syncdata = SCIPsyncstoreGetNextSyncdata(syncstore, concsolver->syncdata, concsolver->syncfreq, concsolver->nsyncs, &concsolver->syncdelay);
491  }
492 
493  SCIP_CALL( SCIPstopClock(set->scip, concsolver->totalsynctime) );
494 
495  return SCIP_OKAY;
496 }
497 
498 /** gets the current synchronization frequency of the concurent solver */
500  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
501  )
502 {
503  assert(concsolver != NULL);
504 
505  return concsolver->syncfreq;
506 }
507 
508 /** gets the total memory used by the concurent solver */
510  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
511  )
512 {
513  assert(concsolver != NULL);
514 
515  return concsolver->syncdata != NULL ? SCIPsyncdataGetMemTotal(concsolver->syncdata) : 0;
516 }
517 
518 /** sets the time elapsed since the last synchronization. Must be set before the synchronization is
519  * started.
520  */
522  SCIP_CONCSOLVER* concsolver, /**< concurrent solver */
523  SCIP_Real time /**< the time passed since the last synchronization */
524  )
525 {
526  assert(concsolver != NULL);
527 
528  concsolver->timesincelastsync = time;
529 }
530 
531 /** gets the solving time of the concurrent solver */
533  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
534  )
535 {
536  assert(concsolver != NULL);
537 
538  return concsolver->solvingtime;
539 }
540 
541 /** gets the time spent for synchronization for the concurrent solver */
543  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
544  )
545 {
546  assert(concsolver != NULL);
547 
548  return SCIPclockGetTime(concsolver->totalsynctime);
549 }
550 
551 /** gets the number of lp iterations the concurrent solver used */
553  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
554  )
555 {
556  assert(concsolver != NULL);
557 
558  return concsolver->nlpiterations;
559 }
560 
561 /** gets the number of branch and bound nodes the concurrent solver used */
563  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
564  )
565 {
566  assert(concsolver != NULL);
567 
568  return concsolver->nnodes;
569 }
570 
571 /** gets the number of solutions the concurrent solver received during synchronization */
573  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
574  )
575 {
576  assert(concsolver != NULL);
577 
578  return concsolver->nsolsrecvd;
579 }
580 
581 /** gets the number of solutions the concurrent solver shared during synchronization */
583  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
584  )
585 {
586  assert(concsolver != NULL);
587 
588  return concsolver->nsolsshared;
589 }
590 
591 /** gets the number of tighter global variable bounds the solver received */
593  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
594  )
595 {
596  assert(concsolver != NULL);
597 
598  return concsolver->ntighterbnds;
599 }
600 
601 /** gets the number of tighter global variable bounds of integer variables the solver received */
603  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
604  )
605 {
606  assert(concsolver != NULL);
607 
608  return concsolver->ntighterintbnds;
609 }
610 
611 /** gets index of concurrent solver */
613  SCIP_CONCSOLVER* concsolver /**< concurrent solver */
614  )
615 {
616  assert(concsolver != NULL);
617 
618  return concsolver->idx;
619 }
SCIP_Longint nsyncs
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5953
struct SCIP_ConcSolverTypeData SCIP_CONCSOLVERTYPEDATA
#define NULL
Definition: def.h:239
#define SCIP_DECL_CONCSOLVERSYNCREAD(x)
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:130
int SCIPboundstoreGetNChgs(SCIP_BOUNDSTORE *boundstore)
Definition: boundstore.c:188
int SCIPgetNConcurrentSolvers(SCIP *scip)
Definition: concurrent.c:107
SCIP_RETCODE SCIPsyncstoreEnsureAllSynced(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:395
#define SCIP_MAXSTRLEN
Definition: def.h:260
SCIP_Real SCIPconcsolverTypeGetPrefPrio(SCIP_CONCSOLVERTYPE *concsolvertype)
Definition: concsolver.c:190
SCIP_STATUS SCIPsyncdataGetStatus(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:505
internal methods for clocks and timing issues
#define SCIP_CALL_FINALLY(x, y)
Definition: def.h:393
SCIP_SYNCDATA * SCIPsyncstoreGetSyncdata(SCIP_SYNCSTORE *syncstore, SCIP_Longint syncnum)
Definition: syncstore.c:326
void SCIPconcsolverTypeFree(SCIP_CONCSOLVERTYPE **concsolvertype)
Definition: concsolver.c:143
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:5813
SCIP_RETCODE SCIPstopClock(SCIP *scip, SCIP_CLOCK *clck)
Definition: scip_timing.c:245
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
SCIP_Real SCIPrelDiff(SCIP_Real val1, SCIP_Real val2)
Definition: misc.c:10325
char * SCIPconcsolverGetName(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:290
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10017
#define TRUE
Definition: def.h:64
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_Longint SCIPconcsolverGetNSolsShared(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:582
datastructures for concurrent solvers
SCIP_RETCODE SCIPconcsolverSync(SCIP_CONCSOLVER *concsolver, SCIP_SET *set)
Definition: concsolver.c:365
SCIP_Longint ntighterbnds
datastructures for concurrent solvers
#define SCIPdebugMessage
Definition: pub_message.h:77
SCIP_RETCODE SCIPfreeClock(SCIP *scip, SCIP_CLOCK **clck)
Definition: scip_timing.c:194
#define BMSfreeMemory(ptr)
Definition: memory.h:127
SCIP_RETCODE SCIPconcsolverCreateInstance(SCIP_SET *set, SCIP_CONCSOLVERTYPE *concsolvertype, SCIP_CONCSOLVER **concsolver)
Definition: concsolver.c:200
#define SCIP_DECL_CONCSOLVERDESTROYINST(x)
void SCIPconcsolverSetData(SCIP_CONCSOLVER *concsolver, SCIP_CONCSOLVERDATA *data)
Definition: concsolver.c:279
static SCIP_RETCODE doConcsolverTypeCreate(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:42
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6047
SCIP_RETCODE SCIPcreateWallClock(SCIP *scip, SCIP_CLOCK **clck)
Definition: scip_timing.c:177
SCIP_SYNCDATA * SCIPsyncstoreGetNextSyncdata(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_Real syncfreq, SCIP_Longint writenum, SCIP_Real *delay)
Definition: syncstore.c:347
#define SCIP_DECL_CONCSOLVERSTOP(x)
SCIP_Longint SCIPconcsolverGetMemTotal(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:509
SCIP_Longint nsolsshared
SCIP_RETCODE SCIPconcsolverGetSolvingData(SCIP_CONCSOLVER *concsolver, SCIP *scip)
Definition: concsolver.c:333
SCIP_Longint SCIPconcsolverGetNSolsRecvd(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:572
SCIP_Real SCIPconcsolverGetSolvingTime(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:532
void SCIPsyncdataSetSyncFreq(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_Real syncfreq)
Definition: syncstore.c:619
void SCIPconcsolverSetTimeSinceLastSync(SCIP_CONCSOLVER *concsolver, SCIP_Real time)
Definition: concsolver.c:521
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:129
SCIP_Real SCIPconcsolverGetSyncFreq(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:499
SCIP_Longint nsolsrecvd
SCIP_CLOCK * totalsynctime
struct SCIP_SyncData SCIP_SYNCDATA
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
Definition: clock.c:428
the interface of the boundstore structure
SCIP_RETCODE SCIPconcsolverInitSeeds(SCIP_CONCSOLVER *concsolver, unsigned int seed)
Definition: concsolver.c:300
internal methods for global SCIP settings
#define SCIP_CALL(x)
Definition: def.h:351
SCIP main data structure.
#define SCIP_DECL_CONCSOLVERINITSEEDS(x)
SCIP_RETCODE SCIPconcsolverDestroyInstance(SCIP_SET *set, SCIP_CONCSOLVER **concsolver)
Definition: concsolver.c:247
SCIP_RETCODE SCIPconcsolverStop(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:346
SCIP_Longint SCIPconcsolverGetNNodes(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:562
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:125
SCIP_Longint SCIPconcsolverGetNTighterIntBnds(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:602
the function declarations for the synchronization store
SCIP_CONCSOLVERTYPE * type
#define SCIP_Bool
Definition: def.h:62
SCIP_SYNCSTORE * SCIPgetSyncstore(SCIP *scip)
SCIP_Real SCIPsyncdataGetLowerbound(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:581
SCIP_RETCODE SCIPsyncstoreStartSync(SCIP_SYNCSTORE *syncstore, SCIP_Longint syncnum, SCIP_SYNCDATA **syncdata)
Definition: syncstore.c:424
SCIP_CONCSOLVERTYPEDATA * data
SCIP_Longint SCIPsyncdataGetMemTotal(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:551
#define SCIP_DECL_CONCSOLVERCOPYSOLVINGDATA(x)
SCIP_CONCSOLVERDATA * SCIPconcsolverGetData(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:269
datastructures for problem statistics
#define SCIP_DECL_CONCSOLVERTYPEFREEDATA(x)
#define BMSclearMemory(ptr)
Definition: memory.h:111
helper functions for concurrent scip solvers
int SCIPgetNVars(SCIP *scip)
Definition: scip_prob.c:2044
int SCIPsyncdataGetNSynced(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:529
int SCIPconcsolverGetIdx(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:612
SCIP_Longint ntighterintbnds
SCIP_SYNCDATA * syncdata
SCIP_Real SCIPconcsolverGetSyncTime(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:542
SCIP_CONCSOLVERDATA * data
SCIP_RETCODE SCIPconcsolverExec(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:315
SCIP_BOUNDSTORE * SCIPsyncdataGetBoundChgs(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:609
SCIP_RETCODE SCIPaddConcurrentSolver(SCIP *scip, SCIP_CONCSOLVER *concsolver)
Definition: concurrent.c:129
SCIP_Real SCIPsyncdataGetSyncFreq(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:561
#define SCIP_Real
Definition: def.h:150
SCIP_Longint SCIPconcsolverGetNTighterBnds(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:592
void SCIPconcsolverTypeSetData(SCIP_CONCSOLVERTYPE *concsolvertype, SCIP_CONCSOLVERTYPEDATA *data)
Definition: concsolver.c:169
#define BMSallocMemory(ptr)
Definition: memory.h:101
#define SCIP_Longint
Definition: def.h:135
SCIP_Longint SCIPconcsolverGetNLPIterations(SCIP_CONCSOLVER *concsolver)
Definition: concsolver.c:552
SCIP_RETCODE SCIPsyncstoreFinishSync(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA **syncdata)
Definition: syncstore.c:467
SCIP_CONCSOLVERTYPEDATA * SCIPconcsolverTypeGetData(SCIP_CONCSOLVERTYPE *concsolvertype)
Definition: concsolver.c:159
SCIP_Longint nlpiterations
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:419
SCIP_RETCODE SCIPsetAddRealParam(SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: set.c:2927
SCIP_Real SCIPsyncdataGetUpperbound(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:571
#define SCIP_DECL_CONCSOLVERSYNCWRITE(x)
#define SCIP_ALLOC(x)
Definition: def.h:362
int SCIPsyncstoreGetNSolvers(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:539
#define SCIP_DECL_CONCSOLVERCREATEINST(x)
SCIP_RETCODE SCIPstartClock(SCIP *scip, SCIP_CLOCK *clck)
Definition: scip_timing.c:228
SCIP_Longint nnodes
SCIP callable library.
struct SCIP_ConcSolverData SCIP_CONCSOLVERDATA
SCIP_Real timesincelastsync
char * SCIPconcsolverTypeGetName(SCIP_CONCSOLVERTYPE *concsolvertype)
Definition: concsolver.c:180
memory allocation routines