Scippy

SCIP

Solving Constraint Integer Programs

scip_copy.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_copy.c
17  * @brief public methods for problem copies
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_cons.h"
111 #include "scip/scip_copy.h"
112 #include "scip/scip_cut.h"
113 #include "scip/scip_general.h"
114 #include "scip/scip_mem.h"
115 #include "scip/scip_message.h"
116 #include "scip/scip_numerics.h"
117 #include "scip/scip_param.h"
118 #include "scip/scip_pricer.h"
119 #include "scip/scip_prob.h"
120 #include "scip/scip_solve.h"
121 #include "scip/scip_solvingstats.h"
122 #include "scip/scip_timing.h"
123 #include "scip/scip_var.h"
124 
125 #include "scip/pub_cons.h"
126 #include "scip/pub_cutpool.h"
127 #include "scip/pub_implics.h"
128 #include "scip/pub_lp.h"
129 #include "scip/pub_message.h"
130 #include "scip/pub_misc.h"
131 #include "scip/pub_var.h"
132 
133 
134 /* In debug mode, we include the SCIP's structure in scip.c, such that no one can access
135  * this structure except the interface methods in scip.c.
136  * In optimized mode, the structure is included in scip.h, because some of the methods
137  * are implemented as defines for performance reasons (e.g. the numerical comparisons)
138  */
139 #ifndef NDEBUG
140 #include "scip/struct_scip.h"
141 #endif
142 
143 /** returns true if the @p cut matches the selection criterium for copying */
144 static
146  SCIP* scip, /**< SCIP data structure */
147  SCIP_CUT* cut, /**< a cut */
148  char cutsel /**< cut selection for sub SCIPs ('a'ge, activity 'q'uotient) */
149  )
150 {
151  SCIP_Bool takecut;
152 
153  assert(cut != NULL);
154 
155  if( !SCIProwIsInLP(SCIPcutGetRow(cut)) )
156  return FALSE;
157 
158  switch( cutsel )
159  {
160  case 'a':
161  takecut = (SCIPcutGetAge(cut) == 0);
162  break;
163  case 'q':
164  takecut = (SCIPcutGetLPActivityQuot(cut) >= scip->set->sepa_minactivityquot);
165  break;
166  default:
167  SCIPerrorMessage("unknown cut selection strategy %c, must be either 'a' or 'q'\n");
168  SCIPABORT();
169  takecut = FALSE; /*lint !e527*/
170  break;
171  }
172 
173  return takecut;
174 }
175 
176 /** copy active and tight cuts from one SCIP instance to linear constraints of another SCIP instance */
177 static
179  SCIP* sourcescip, /**< source SCIP data structure */
180  SCIP* targetscip, /**< target SCIP data structure */
181  SCIP_CUT** cuts, /**< cuts to copy */
182  int ncuts, /**< number of cuts to copy */
183  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
184  * target variables, or NULL */
185  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
186  * target constraints, or NULL */
187  SCIP_Bool global, /**< create a global or a local copy? */
188  int* ncutsadded /**< pointer to store number of copied cuts */
189  )
190 {
191  int c;
192 
193  assert(sourcescip != NULL);
194  assert(targetscip != NULL);
195  assert(cuts != NULL || ncuts == 0);
196  assert(ncutsadded != NULL);
197 
198  for( c = 0; c < ncuts; ++c )
199  {
200  SCIP_ROW* row;
201  SCIP_Bool takecut;
202 
203  assert( cuts[c] != NULL ); /*lint !e613*/
204  row = SCIPcutGetRow(cuts[c]); /*lint !e613*/
205  assert(!SCIProwIsLocal(row));
206  assert(!SCIProwIsModifiable(row));
207 
208  /* in case of a restart, convert the cuts with a good LP activity quotient; in other cases, e.g., when heuristics
209  * copy cuts into subscips, take only currently active ones
210  */
211  if( sourcescip == targetscip )
212  {
213  assert( SCIPisInRestart(sourcescip) );
214  takecut = takeCut(sourcescip, cuts[c], sourcescip->set->sepa_cutselrestart); /*lint !e613*/
215  }
216  else
217  takecut = takeCut(sourcescip, cuts[c], sourcescip->set->sepa_cutselsubscip); /*lint !e613*/
218 
219  /* create a linear constraint out of the cut */
220  if( takecut )
221  {
222  char name[SCIP_MAXSTRLEN];
223  SCIP_CONS* cons;
224  SCIP_COL** cols;
225  SCIP_VAR** vars;
226  int ncols;
227  int i;
228 
229  cols = SCIProwGetCols(row);
230  ncols = SCIProwGetNNonz(row);
231 
232  /* get all variables of the row */
233  SCIP_CALL( SCIPallocBufferArray(targetscip, &vars, ncols) );
234  for( i = 0; i < ncols; ++i )
235  vars[i] = SCIPcolGetVar(cols[i]);
236 
237  /* get corresponding variables in targetscip if necessary */
238  if( sourcescip != targetscip )
239  {
240  SCIP_Bool success;
241 
242  for( i = 0; i < ncols; ++i )
243  {
244  SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, vars[i], &vars[i], varmap, consmap, global, &success) );
245 
246  if( !success )
247  {
248  SCIPdebugMsg(sourcescip, "Converting cuts to constraints failed.\n");
249 
250  /* free temporary memory */
251  SCIPfreeBufferArray(targetscip, &vars);
252  return SCIP_OKAY;
253  }
254  }
255  }
256 
257  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_%d", SCIProwGetName(row), SCIPgetNRuns(sourcescip));
258  SCIP_CALL( SCIPcreateConsLinear(targetscip, &cons, name, ncols, vars, SCIProwGetVals(row),
261  SCIP_CALL( SCIPaddCons(targetscip, cons) );
262 
263  SCIPdebugMsg(sourcescip, "Converted cut <%s> to constraint <%s>.\n", SCIProwGetName(row), SCIPconsGetName(cons));
264  SCIPdebugPrintCons(targetscip, cons, NULL);
265  SCIP_CALL( SCIPreleaseCons(targetscip, &cons) );
266 
267  /* free temporary memory */
268  SCIPfreeBufferArray(targetscip, &vars);
269 
270  ++(*ncutsadded);
271  }
272  }
273 
274  return SCIP_OKAY;
275 }
276 
277 /** copies plugins from sourcescip to targetscip; in case that a constraint handler which does not need constraints
278  * cannot be copied, valid will return FALSE. All plugins can declare that, if their copy process failed, the
279  * copied SCIP instance might not represent the same problem semantics as the original.
280  * Note that in this case dual reductions might be invalid.
281  *
282  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
283  * Also, 'passmessagehdlr' should be set to FALSE.
284  *
285  * @note Do not change the source SCIP environment during the copying process
286  *
287  * @note This method does not copy Benders' plugins. To this end, the method SCIPcopyBenders() must be called
288  * separately.
289  *
290  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
291  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
292  *
293  * @pre This method can be called if sourcescip is in one of the following stages:
294  * - \ref SCIP_STAGE_PROBLEM
295  * - \ref SCIP_STAGE_TRANSFORMED
296  * - \ref SCIP_STAGE_INITPRESOLVE
297  * - \ref SCIP_STAGE_PRESOLVING
298  * - \ref SCIP_STAGE_EXITPRESOLVE
299  * - \ref SCIP_STAGE_PRESOLVED
300  * - \ref SCIP_STAGE_INITSOLVE
301  * - \ref SCIP_STAGE_SOLVING
302  * - \ref SCIP_STAGE_SOLVED
303  *
304  * @pre This method can be called if targetscip is in one of the following stages:
305  * - \ref SCIP_STAGE_INIT
306  * - \ref SCIP_STAGE_FREE
307  *
308  * @post After calling this method targetscip reaches one of the following stages depending on if and when the solution
309  * process was interrupted:
310  * - \ref SCIP_STAGE_PROBLEM
311  *
312  * @note sourcescip stage does not get changed
313  *
314  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
315  */
317  SCIP* sourcescip, /**< source SCIP data structure */
318  SCIP* targetscip, /**< target SCIP data structure */
319  SCIP_Bool copyreaders, /**< should the file readers be copied */
320  SCIP_Bool copypricers, /**< should the variable pricers be copied */
321  SCIP_Bool copyconshdlrs, /**< should the constraint handlers be copied */
322  SCIP_Bool copyconflicthdlrs, /**< should the conflict handlers be copied */
323  SCIP_Bool copypresolvers, /**< should the presolvers be copied */
324  SCIP_Bool copyrelaxators, /**< should the relaxation handlers be copied */
325  SCIP_Bool copyseparators, /**< should the separators be copied */
326  SCIP_Bool copypropagators, /**< should the propagators be copied */
327  SCIP_Bool copyheuristics, /**< should the heuristics be copied */
328  SCIP_Bool copyeventhdlrs, /**< should the event handlers be copied */
329  SCIP_Bool copynodeselectors, /**< should the node selectors be copied */
330  SCIP_Bool copybranchrules, /**< should the branchrules be copied */
331  SCIP_Bool copydisplays, /**< should the display columns be copied */
332  SCIP_Bool copydialogs, /**< should the dialogs be copied */
333  SCIP_Bool copytables, /**< should the statistics tables be copied */
334  SCIP_Bool copynlpis, /**< should the NLPIs be copied */
335  SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
336  SCIP_Bool* valid /**< pointer to store whether plugins, in particular all constraint
337  * handlers which do not need constraints were validly copied */
338  )
339 {
340  assert(sourcescip != NULL);
341  assert(targetscip != NULL);
342  assert(sourcescip->set != NULL);
343  assert(targetscip->set != NULL);
344 
345  /* check stages for both, the source and the target SCIP data structure */
346  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyPlugins", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
347  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyPlugins", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
348 
349  /* passes the message handler of the source SCIP to the target SCIP, also if NULL */
350  if( passmessagehdlr )
351  {
352  SCIP_CALL( SCIPsetMessagehdlr(targetscip, SCIPgetMessagehdlr(sourcescip)) );
353  }
354 
355  SCIP_CALL( SCIPsetCopyPlugins(sourcescip->set, targetscip->set,
356  copyreaders, copypricers, copyconshdlrs, copyconflicthdlrs, copypresolvers, copyrelaxators, copyseparators, copypropagators,
357  copyheuristics, copyeventhdlrs, copynodeselectors, copybranchrules, copydisplays, copydialogs, copytables, copynlpis, valid) );
358 
359  return SCIP_OKAY;
360 }
361 
362 /** copies all Benders' decomposition plugins
363  *
364  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
365  *
366  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
367  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
368  *
369  * @pre This method can be called if sourcescip is in one of the following stages:
370  * - \ref SCIP_STAGE_PROBLEM
371  * - \ref SCIP_STAGE_TRANSFORMED
372  * - \ref SCIP_STAGE_INITPRESOLVE
373  * - \ref SCIP_STAGE_PRESOLVING
374  * - \ref SCIP_STAGE_EXITPRESOLVE
375  * - \ref SCIP_STAGE_PRESOLVED
376  * - \ref SCIP_STAGE_INITSOLVE
377  * - \ref SCIP_STAGE_SOLVING
378  * - \ref SCIP_STAGE_SOLVED
379  *
380  * @pre This method can be called if targetscip is in one of the following stages:
381  * - \ref SCIP_STAGE_INIT
382  * - \ref SCIP_STAGE_FREE
383  * - \ref SCIP_STAGE_PROBLEM
384  *
385  * @post After calling this method targetscip reaches one of the following stages depending on if and when the solution
386  * process was interrupted:
387  * - \ref SCIP_STAGE_PROBLEM
388  *
389  * @note sourcescip stage does not get changed
390  *
391  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
392  */
394  SCIP* sourcescip, /**< source SCIP data structure */
395  SCIP* targetscip, /**< target SCIP data structure */
396  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
397  * target variables; must not be NULL */
398  SCIP_Bool* valid /**< pointer to store whether all plugins were validly copied */
399  )
400 {
401  /* TODO: If the Benders' decomposition is not copied, then cons_benders needs to be deactivated. */
402  SCIP_Bool copybendersvalid;
403  int p;
404 
405  assert(sourcescip != NULL);
406  assert(targetscip != NULL);
407  assert(sourcescip != targetscip);
408  assert(sourcescip->set != NULL);
409  assert(targetscip->set != NULL);
410  assert(varmap != NULL);
411  assert(valid != NULL);
412 
413  /* check stages for both, the source and the target SCIP data structure */
414  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyBenders", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
415  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyBenders", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
416 
417  *valid = TRUE;
418 
419  if( sourcescip->set->benders != NULL )
420  {
421  for( p = sourcescip->set->nbenders - 1; p >= 0; --p )
422  {
423  copybendersvalid = FALSE;
424  SCIP_CALL( SCIPbendersCopyInclude(sourcescip->set->benders[p], sourcescip->set, targetscip->set, varmap, &copybendersvalid) );
425  *valid = *valid && copybendersvalid;
426  }
427  }
428 
429  return SCIP_OKAY;
430 }
431 
432 /** create a problem by copying the problem data of the source SCIP */
433 static
435  SCIP* sourcescip, /**< source SCIP data structure */
436  SCIP* targetscip, /**< target SCIP data structure */
437  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
438  * target variables, or NULL */
439  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
440  * target constraints, or NULL */
441  SCIP_Bool original, /**< should the original problem be copied? */
442  SCIP_Bool global, /**< create a global or a local copy? (set to TRUE for original copy) */
443  const char* name /**< problem name of target */
444  )
445 {
446  SCIP_PROB* sourceprob;
447  SCIP_HASHMAP* localvarmap;
448  SCIP_HASHMAP* localconsmap;
449  SCIP_Bool uselocalvarmap;
450  SCIP_Bool uselocalconsmap;
451 
452  assert(sourcescip != NULL);
453  assert(targetscip != NULL);
454  assert(!original || global);
455  assert(original || SCIPisTransformed(sourcescip));
456 
457  /* free old problem */
458  SCIP_CALL( SCIPfreeProb(targetscip) );
459  assert(targetscip->set->stage == SCIP_STAGE_INIT);
460 
461  uselocalvarmap = (varmap == NULL);
462  uselocalconsmap = (consmap == NULL);
463 
464  if( uselocalvarmap )
465  {
466  /* create the variable mapping hash map */
467  SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
468  }
469  else
470  localvarmap = varmap;
471 
472  if( uselocalconsmap )
473  {
474  /* create the constraint mapping hash map */
475  SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
476  }
477  else
478  localconsmap = consmap;
479 
480  /* switch stage to PROBLEM */
481  targetscip->set->stage = SCIP_STAGE_PROBLEM;
482 
483  if( original )
484  sourceprob = sourcescip->origprob;
485  else
486  sourceprob = sourcescip->transprob;
487 
488  /* create the statistics data structure */
489  SCIP_CALL( SCIPstatCreate(&targetscip->stat, targetscip->mem->probmem, targetscip->set, targetscip->transprob, targetscip->origprob, targetscip->messagehdlr) );
490  targetscip->stat->subscipdepth = sourcescip->stat->subscipdepth + 1;
491 
492  /* create the problem by copying the source problem */
493  SCIP_CALL( SCIPprobCopy(&targetscip->origprob, targetscip->mem->probmem, targetscip->set, name, sourcescip, sourceprob, localvarmap, localconsmap, global) );
494 
495  /* creating the solution candidates storage */
496  /**@todo copy solution of source SCIP as candidates for the target SCIP */
497  SCIP_CALL( SCIPprimalCreate(&targetscip->origprimal) );
498 
499  /* create conflict store to store conflict constraints */
500  SCIP_CALL( SCIPconflictstoreCreate(&targetscip->conflictstore, targetscip->set) );
501 
502  if( uselocalvarmap )
503  {
504  /* free hash map */
505  SCIPhashmapFree(&localvarmap);
506  }
507 
508  if( uselocalconsmap )
509  {
510  /* free hash map */
511  SCIPhashmapFree(&localconsmap);
512  }
513 
514  return SCIP_OKAY;
515 }
516 
517 
518 /** create a problem by copying the problem data of the source SCIP
519  *
520  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
521  * @note Do not change the source SCIP environment during the copying process
522  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
523  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
524  *
525  * @pre This method can be called if sourcescip is in one of the following stages:
526  * - \ref SCIP_STAGE_PROBLEM
527  * - \ref SCIP_STAGE_TRANSFORMED
528  * - \ref SCIP_STAGE_INITPRESOLVE
529  * - \ref SCIP_STAGE_PRESOLVING
530  * - \ref SCIP_STAGE_EXITPRESOLVE
531  * - \ref SCIP_STAGE_PRESOLVED
532  * - \ref SCIP_STAGE_INITSOLVE
533  * - \ref SCIP_STAGE_SOLVING
534  * - \ref SCIP_STAGE_SOLVED
535  *
536  * @pre This method can be called if targetscip is in one of the following stages:
537  * - \ref SCIP_STAGE_INIT
538  * - \ref SCIP_STAGE_PROBLEM
539  * - \ref SCIP_STAGE_TRANSFORMED
540  * - \ref SCIP_STAGE_INITPRESOLVE
541  * - \ref SCIP_STAGE_PRESOLVING
542  * - \ref SCIP_STAGE_EXITPRESOLVE
543  * - \ref SCIP_STAGE_PRESOLVED
544  * - \ref SCIP_STAGE_INITSOLVE
545  * - \ref SCIP_STAGE_SOLVING
546  * - \ref SCIP_STAGE_SOLVED
547  * - \ref SCIP_STAGE_FREE
548  *
549  * @post After calling this method targetscip reaches one of the following stages depending on if and when the solution
550  * process was interrupted:
551  * - \ref SCIP_STAGE_PROBLEM
552  *
553  * @note sourcescip stage does not get changed
554  *
555  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
556  */
558  SCIP* sourcescip, /**< source SCIP data structure */
559  SCIP* targetscip, /**< target SCIP data structure */
560  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
561  * target variables, or NULL */
562  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
563  * target constraints, or NULL */
564  SCIP_Bool global, /**< create a global or a local copy? */
565  const char* name /**< problem name of target */
566  )
567 {
568  assert(sourcescip != NULL);
569  assert(targetscip != NULL);
570 
571  /* check stages for both, the source and the target SCIP data structure */
572  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyProb", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
573  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyProb", TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE) );
574 
575  SCIP_CALL( copyProb(sourcescip, targetscip, varmap, consmap, FALSE, global, name) );
576 
577  return SCIP_OKAY;
578 }
579 
580 /** create a problem by copying the original problem data of the source SCIP
581  *
582  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
583  * @note Do not change the source SCIP environment during the copying process
584  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
585  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
586  *
587  * @pre This method can be called if sourcescip is in one of the following stages:
588  * - \ref SCIP_STAGE_PROBLEM
589  * - \ref SCIP_STAGE_TRANSFORMED
590  * - \ref SCIP_STAGE_INITPRESOLVE
591  * - \ref SCIP_STAGE_PRESOLVING
592  * - \ref SCIP_STAGE_EXITPRESOLVE
593  * - \ref SCIP_STAGE_PRESOLVED
594  * - \ref SCIP_STAGE_INITSOLVE
595  * - \ref SCIP_STAGE_SOLVING
596  * - \ref SCIP_STAGE_SOLVED
597  *
598  * @pre This method can be called if targetscip is in one of the following stages:
599  * - \ref SCIP_STAGE_INIT
600  * - \ref SCIP_STAGE_FREE
601  *
602  * @post After calling this method targetscip reaches one of the following stages depending on if and when the solution
603  * process was interrupted:
604  * - \ref SCIP_STAGE_PROBLEM
605  *
606  * @note sourcescip stage does not get changed
607  *
608  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
609  */
611  SCIP* sourcescip, /**< source SCIP data structure */
612  SCIP* targetscip, /**< target SCIP data structure */
613  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
614  * target variables, or NULL */
615  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
616  * target constraints, or NULL */
617  const char* name /**< problem name of target */
618  )
619 {
620  assert(sourcescip != NULL);
621  assert(targetscip != NULL);
622 
623  /* check stages for both, the source and the target SCIP data structure */
624  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrigProb", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
625  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrigProb", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
626 
627  SCIP_CALL( copyProb(sourcescip, targetscip, varmap, consmap, TRUE, TRUE, name) );
628 
629  /* set the correct objective sense; necessary if we maximize in the original problem */
630  SCIP_CALL( SCIPsetObjsense(targetscip, SCIPgetObjsense(sourcescip)) );
631 
632  return SCIP_OKAY;
633 }
634 
635 /** enables constraint compression.
636  *
637  * If constraint compression is enabled, fixed variables will be treated as constants
638  * by all constraints that are copied after calling this method.
639  *
640  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
641  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
642  *
643  * @pre This method can be called if scip is in one of the following stages:
644  * - \ref SCIP_STAGE_PROBLEM
645  *
646  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
647  */
649  SCIP* scip /**< source SCIP data structure */
650  )
651 {
652  assert(scip != NULL);
653  assert(scip->origprob != NULL);
654 
655  /* check stage */
656  SCIP_CALL( SCIPcheckStage(scip, "SCIPenableConsCompression", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
657 
658  /* enable problem compression */
660 
661  return SCIP_OKAY;
662 }
663 
664 /** is constraint compression enabled?
665  *
666  * If constraint compression is enabled, fixed variables can be treated as constants
667  * by all constraints that are copied after calling this method.
668  *
669  * @return TRUE if problem constraint compression is enabled, otherwise FALSE
670  *
671  * @pre This method can be called if scip is in one of the following stages:
672  * - \ref SCIP_STAGE_PROBLEM
673  * - \ref SCIP_STAGE_TRANSFORMING
674  * - \ref SCIP_STAGE_TRANSFORMED
675  * - \ref SCIP_STAGE_INITPRESOLVE
676  * - \ref SCIP_STAGE_PRESOLVING
677  * - \ref SCIP_STAGE_EXITPRESOLVE
678  * - \ref SCIP_STAGE_PRESOLVED
679  * - \ref SCIP_STAGE_INITSOLVE
680  * - \ref SCIP_STAGE_SOLVING
681  * - \ref SCIP_STAGE_SOLVED
682  * - \ref SCIP_STAGE_EXITSOLVE
683  * - \ref SCIP_STAGE_FREETRANS
684  *
685  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
686  */
688  SCIP* scip /**< source SCIP data structure */
689  )
690 {
691  assert(scip != NULL);
692  assert(scip->origprob != NULL);
693 
694  /* check stage */
695  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisConsCompressionEnabled", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
696 
697  /* is problem compression enabled */
699 }
700 
701 /** returns copy of the source variable; if there already is a copy of the source variable in the variable hash map,
702  * it is just returned as target variable; otherwise a new variable will be created and added to the target SCIP; this
703  * created variable is added to the variable hash map and returned as target variable
704  *
705  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
706  * @note Do not change the source SCIP environment during the copying process
707  * @note if a new variable was created, this variable will be added to the target-SCIP, but it is not captured
708  *
709  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
710  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
711  *
712  * @pre This method can be called if sourcescip is in one of the following stages:
713  * - \ref SCIP_STAGE_PROBLEM
714  * - \ref SCIP_STAGE_TRANSFORMED
715  * - \ref SCIP_STAGE_INITPRESOLVE
716  * - \ref SCIP_STAGE_PRESOLVING
717  * - \ref SCIP_STAGE_EXITPRESOLVE
718  * - \ref SCIP_STAGE_PRESOLVED
719  * - \ref SCIP_STAGE_INITSOLVE
720  * - \ref SCIP_STAGE_SOLVING
721  * - \ref SCIP_STAGE_SOLVED
722  *
723  * @pre This method can be called if targetscip is in one of the following stages:
724  * - \ref SCIP_STAGE_PROBLEM
725  * - \ref SCIP_STAGE_TRANSFORMED
726  * - \ref SCIP_STAGE_INITPRESOLVE
727  * - \ref SCIP_STAGE_PRESOLVING
728  * - \ref SCIP_STAGE_EXITPRESOLVE
729  * - \ref SCIP_STAGE_SOLVING
730  *
731  * @note targetscip stage does not get changed
732  *
733  * @note sourcescip stage does not get changed
734  *
735  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
736  */
738  SCIP* sourcescip, /**< source SCIP data structure */
739  SCIP* targetscip, /**< target SCIP data structure */
740  SCIP_VAR* sourcevar, /**< source variable */
741  SCIP_VAR** targetvar, /**< pointer to store the target variable */
742  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables to the corresponding
743  * target variables, or NULL */
744  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
745  * target constraints, or NULL */
746  SCIP_Bool global, /**< should global or local bounds be used? */
747  SCIP_Bool* success /**< pointer to store whether the copying was successful or not */
748  )
749 {
750  SCIP_HASHMAP* localvarmap;
751  SCIP_HASHMAP* localconsmap;
752  SCIP_VAR* var;
753  SCIP_Bool uselocalvarmap;
754  SCIP_Bool uselocalconsmap;
755 
756  assert(sourcescip != NULL);
757  assert(targetscip != NULL);
758  assert(sourcevar != NULL);
759  assert(targetvar != NULL);
760  assert(sourcevar->scip == sourcescip);
761 
762  /* check stages for both, the source and the target SCIP data structure */
763  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPgetVarCopy", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
764  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPgetVarCopy", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
765 
766  uselocalvarmap = (varmap == NULL);
767  uselocalconsmap = (consmap == NULL);
768  *success = TRUE;
769 
770  /* try to retrieve copied variable from hashmap */
771  if( !uselocalvarmap )
772  {
773  *targetvar = (SCIP_VAR*) SCIPhashmapGetImage(varmap, sourcevar);
774  if( *targetvar != NULL )
775  return SCIP_OKAY;
776  }
777 
778  /* if the target SCIP is already in solving stage we currently are not copying the variable!
779  * this has to be done because we cannot simply add variables to SCIP during solving and thereby enlarge the search
780  * space.
781  * unlike column generation we cannot assume here that the variable could be implicitly set to zero in all prior
782  * computations
783  */
784  if( SCIPgetStage(targetscip) > SCIP_STAGE_PROBLEM )
785  {
786  *success = FALSE;
787  *targetvar = NULL;
788 
789  return SCIP_OKAY;
790  }
791 
792  /* create the variable mapping hash map */
793  if( uselocalvarmap )
794  {
795  SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
796  }
797  else
798  localvarmap = varmap;
799 
800  if( uselocalconsmap )
801  {
802  /* create the constraint mapping hash map */
803  SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
804  }
805  else
806  localconsmap = consmap;
807 
808  /* if variable does not exist yet in target SCIP, create it */
809  switch( SCIPvarGetStatus(sourcevar) )
810  {
815  SCIP_CALL( SCIPvarCopy(&var, targetscip->mem->probmem, targetscip->set, targetscip->stat,
816  sourcescip, sourcevar, localvarmap, localconsmap, global) );
817  break;
818 
820  {
821  SCIP_CONS* cons;
822  char name[SCIP_MAXSTRLEN];
823 
824  SCIP_VAR* sourceaggrvar;
825  SCIP_VAR* targetaggrvar;
826  SCIP_Real aggrcoef;
827  SCIP_Real constant;
828 
829  /* get aggregation data */
830  sourceaggrvar = SCIPvarGetAggrVar(sourcevar);
831  aggrcoef = SCIPvarGetAggrScalar(sourcevar);
832  constant = SCIPvarGetAggrConstant(sourcevar);
833 
834  /* get copy of the aggregation variable */
835  SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourceaggrvar, &targetaggrvar, localvarmap, localconsmap, global, success) );
836  assert(*success);
837 
838  /* create copy of the aggregated variable */
839  SCIP_CALL( SCIPvarCopy(&var, targetscip->mem->probmem, targetscip->set, targetscip->stat,
840  sourcescip, sourcevar, localvarmap, localconsmap, global) );
841 
842  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_aggr", SCIPvarGetName(sourcevar));
843 
844  /* add aggregation x = a*y + c as linear constraint x - a*y = c */
845  SCIP_CALL( SCIPcreateConsLinear(targetscip, &cons, name, 0, NULL, NULL, constant,
846  constant, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
847  SCIP_CALL( SCIPaddCoefLinear(targetscip, cons, var, 1.0) );
848  SCIP_CALL( SCIPaddCoefLinear(targetscip, cons, targetaggrvar, -aggrcoef) );
849 
850  SCIP_CALL( SCIPaddCons(targetscip, cons) );
851  SCIP_CALL( SCIPreleaseCons(targetscip, &cons) );
852 
853  break;
854  }
856  {
857  SCIP_CONS* cons;
858  char name[SCIP_MAXSTRLEN];
859 
860  SCIP_VAR** sourceaggrvars;
861  SCIP_VAR** targetaggrvars;
862  SCIP_Real* aggrcoefs;
863  SCIP_Real constant;
864 
865  int naggrvars;
866  int i;
867 
868  /* get the active representation */
869  SCIP_CALL( SCIPflattenVarAggregationGraph(sourcescip, sourcevar) );
870 
871  /* get multi-aggregation data */
872  naggrvars = SCIPvarGetMultaggrNVars(sourcevar);
873  sourceaggrvars = SCIPvarGetMultaggrVars(sourcevar);
874  aggrcoefs = SCIPvarGetMultaggrScalars(sourcevar);
875  constant = SCIPvarGetMultaggrConstant(sourcevar);
876 
877  SCIP_CALL( SCIPallocBufferArray(targetscip, &targetaggrvars, naggrvars) );
878 
879  /* get copies of the active variables of the multi-aggregation */
880  for( i = 0; i < naggrvars; ++i )
881  {
882  SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourceaggrvars[i], &targetaggrvars[i], localvarmap, localconsmap, global, success) );
883  assert(*success);
884  }
885 
886  /* create copy of the multi-aggregated variable */
887  SCIP_CALL( SCIPvarCopy(&var, targetscip->mem->probmem, targetscip->set, targetscip->stat,
888  sourcescip, sourcevar, localvarmap, localconsmap, global) );
889 
890  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_multaggr", SCIPvarGetName(sourcevar));
891 
892  /* add multi-aggregation x = a^T y + c as linear constraint a^T y - x = -c */
893  SCIP_CALL( SCIPcreateConsLinear(targetscip, &cons, name, naggrvars, targetaggrvars, aggrcoefs, -constant,
894  -constant, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
895  SCIP_CALL( SCIPaddCoefLinear(targetscip, cons, var, -1.0) );
896  SCIP_CALL( SCIPaddCons(targetscip, cons) );
897  SCIP_CALL( SCIPreleaseCons(targetscip, &cons) );
898 
899  SCIPfreeBufferArray(targetscip, &targetaggrvars);
900 
901  break;
902  }
904  {
905  SCIP_VAR* sourcenegatedvar;
906  SCIP_VAR* targetnegatedvar;
907 
908  /* get negated source variable */
909  sourcenegatedvar = SCIPvarGetNegationVar(sourcevar);
910  assert(sourcenegatedvar != NULL);
911  assert(SCIPvarGetStatus(sourcenegatedvar) != SCIP_VARSTATUS_NEGATED);
912 
913  /* get copy of negated source variable */
914  SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourcenegatedvar, &targetnegatedvar, localvarmap, localconsmap, global, success) );
915  assert(*success);
916  assert(SCIPvarGetStatus(targetnegatedvar) != SCIP_VARSTATUS_NEGATED);
917 
918  /* get negation of copied negated source variable, this is the target variable */
919  SCIP_CALL( SCIPgetNegatedVar(targetscip, targetnegatedvar, targetvar) );
920  assert(SCIPvarGetStatus(*targetvar) == SCIP_VARSTATUS_NEGATED);
921 
922  /* free local hash maps if necessary */
923  if( uselocalvarmap )
924  SCIPhashmapFree(&localvarmap);
925 
926  if( uselocalconsmap )
927  SCIPhashmapFree(&localconsmap);
928 
929  /* we have to return right away, to avoid adding the negated variable to the problem since the "not negated"
930  * variable was already added */
931  return SCIP_OKAY;
932  }
933  default:
934  /* note that this is in an internal SCIP error since the variable status is only handled by the core */
935  SCIPerrorMessage("unknown variable status\n");
936  SCIPABORT();
937  return SCIP_ERROR; /*lint !e527*/
938  }
939 
940  /* add the (new) target variable to the target problem */
941  SCIP_CALL( SCIPaddVar(targetscip, var) );
942 
943  *targetvar = var;
944 
945  /* remove the variable capture which was done due to the creation of the variable */
946  SCIP_CALL( SCIPreleaseVar(targetscip, &var) );
947 
948  /* free local hash maps if necessary */
949  if( uselocalvarmap )
950  SCIPhashmapFree(&localvarmap);
951 
952  if( uselocalconsmap )
953  SCIPhashmapFree(&localconsmap);
954 
955  return SCIP_OKAY;
956 }
957 
958 /** copies all original or active variables from source-SCIP and adds these variable to the target-SCIP; the mapping
959  * between these variables are stored in the variable hashmap, target-SCIP has to be in problem creation stage, fixed
960  * and aggregated variables do not get copied
961  */
962 static
964  SCIP* sourcescip, /**< source SCIP data structure */
965  SCIP* targetscip, /**< target SCIP data structure */
966  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables to the corresponding
967  * target variables, or NULL */
968  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
969  * target constraints, or NULL */
970  SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
971  SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
972  int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
973  SCIP_Bool original, /**< should original variables be copied? */
974  SCIP_Bool global /**< should global or local bounds be used? (for original=FALSE) */
975  )
976 {
977  SCIP_VAR** sourcevars;
978  SCIP_HASHMAP* localvarmap;
979  SCIP_HASHMAP* localconsmap;
980  SCIP_Bool uselocalvarmap;
981  SCIP_Bool uselocalconsmap;
982  int nsourcevars;
983  int i;
984 
985  assert(sourcescip != NULL);
986  assert(targetscip != NULL);
987  assert(nfixedvars == 0 || fixedvars != NULL);
988  assert(nfixedvars == 0 || fixedvals != NULL);
989 
990  if( original )
991  {
992  /* get original variables of the source SCIP */
993  SCIP_CALL( SCIPgetOrigVarsData(sourcescip, &sourcevars, &nsourcevars, NULL, NULL, NULL, NULL) );
994  }
995  else
996  {
997  /* get active variables of the source SCIP */
998  SCIP_CALL( SCIPgetVarsData(sourcescip, &sourcevars, &nsourcevars, NULL, NULL, NULL, NULL) );
999  }
1000 
1001  uselocalvarmap = (varmap == NULL);
1002  uselocalconsmap = (consmap == NULL);
1003 
1004  if( uselocalvarmap )
1005  {
1006  /* create the variable mapping hash map */
1007  SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
1008  }
1009  else
1010  localvarmap = varmap;
1011 
1012  if( uselocalconsmap )
1013  {
1014  /* create the constraint mapping hash map */
1015  SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
1016  }
1017  else
1018  localconsmap = consmap;
1019 
1020  /* create the variables of the target SCIP */
1021  for( i = 0; i < nsourcevars; ++i )
1022  {
1023  SCIP_Bool success;
1024  SCIP_VAR* targetvar;
1025 
1026  /* copy variable and add this copy to the target SCIP if the copying was valid */
1027  SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourcevars[i], &targetvar, localvarmap, localconsmap, global, &success) );
1028  assert(success);
1029  assert(targetvar != NULL);
1030  }
1031 
1032  /* fix the variables that should be fixed right away */
1033  for( i = 0; i < nfixedvars; ++i )
1034  {
1035  SCIP_VAR* targetvar;
1036  SCIP_Bool infeasible;
1037  SCIP_Bool fixed;
1038 
1039  /* retrieve target variable as image of the source variable */
1040  targetvar = (SCIP_VAR*) SCIPhashmapGetImage(localvarmap, (void *)fixedvars[i]);
1041  assert(targetvar != NULL);
1042 
1043  /* fix the variable to the specified value */
1044  infeasible = fixed = FALSE;
1045  SCIP_CALL( SCIPfixVar(targetscip, targetvar, fixedvals[i], &infeasible, &fixed) );
1046 
1047  assert(!infeasible);
1048  assert(fixed);
1049  }
1050 
1051  /* integer variables that are fixed to zero or one or have bounds [0,1] will be converted to binaries */
1052 #ifndef NDEBUG
1053  if( original )
1054  {
1055  /* TODO : account for integers converted to binaries
1056  assert(SCIPgetNOrigBinVars(sourcescip) == SCIPgetNOrigBinVars(targetscip));
1057  assert(SCIPgetNOrigIntVars(sourcescip) == SCIPgetNOrigIntVars(targetscip));
1058  assert(SCIPgetNOrigImplVars(sourcescip) == SCIPgetNOrigImplVars(targetscip));
1059  assert(SCIPgetNOrigContVars(sourcescip) == SCIPgetNOrigContVars(targetscip));
1060  */
1061  }
1062  else
1063  {
1064  SCIP_VAR** sourcefixedvars;
1065  int nsourcefixedvars;
1066  int nfixedbinvars;
1067  int nfixedintvars;
1068  int nfixedimplvars;
1069  int nfixedcontvars;
1070 
1071  sourcefixedvars = SCIPgetFixedVars(sourcescip);
1072  nsourcefixedvars = SCIPgetNFixedVars(sourcescip);
1073  nfixedbinvars = 0;
1074  nfixedintvars = 0;
1075  nfixedimplvars = 0;
1076  nfixedcontvars = 0;
1077 
1078  /* count number of fixed variables for all variable types */
1079  for( i = 0; i < nsourcefixedvars; ++i )
1080  {
1081  switch( SCIPvarGetType(sourcefixedvars[i]) )
1082  {
1083  case SCIP_VARTYPE_BINARY:
1084  nfixedbinvars++;
1085  break;
1086  case SCIP_VARTYPE_INTEGER:
1087  nfixedintvars++;
1088  break;
1089  case SCIP_VARTYPE_IMPLINT:
1090  nfixedimplvars++;
1091  break;
1093  nfixedcontvars++;
1094  break;
1095  default:
1096  SCIPerrorMessage("unknown variable type\n");
1097  return SCIP_INVALIDDATA;
1098  }
1099  }
1100  assert(nsourcefixedvars == nfixedbinvars + nfixedintvars + nfixedimplvars + nfixedcontvars);
1101  assert(SCIPgetNBinVars(sourcescip) <= SCIPgetNBinVars(targetscip));
1102  assert(SCIPgetNIntVars(sourcescip) + SCIPgetNBinVars(sourcescip) <= SCIPgetNIntVars(targetscip) + SCIPgetNBinVars(targetscip)
1103  && SCIPgetNIntVars(targetscip) + SCIPgetNBinVars(targetscip) <= SCIPgetNIntVars(sourcescip) + SCIPgetNBinVars(sourcescip) + nfixedbinvars + nfixedintvars );
1104  assert(SCIPgetNImplVars(sourcescip) <= SCIPgetNImplVars(targetscip)
1105  && SCIPgetNImplVars(targetscip) <= SCIPgetNImplVars(sourcescip) + nfixedimplvars);
1106  assert(SCIPgetNContVars(sourcescip) <= SCIPgetNContVars(targetscip)
1107  && SCIPgetNContVars(targetscip) <= SCIPgetNContVars(targetscip) + nfixedcontvars);
1108  }
1109 #endif
1110 
1111  if( uselocalvarmap )
1112  {
1113  /* free hash map */
1114  SCIPhashmapFree(&localvarmap);
1115  }
1116 
1117  if( uselocalconsmap )
1118  {
1119  /* free hash map */
1120  SCIPhashmapFree(&localconsmap);
1121  }
1122 
1123  return SCIP_OKAY;
1124 }
1125 
1126 /** copies all active variables from source-SCIP and adds these variable to the target-SCIP; the mapping between these
1127  * variables are stored in the variable hashmap, target-SCIP has to be in problem creation stage, fixed and aggregated
1128  * variables are not copied
1129  *
1130  * @note the variables are added to the target-SCIP but not captured
1131  *
1132  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
1133  * @note Do not change the source SCIP environment during the copying process
1134  *
1135  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1136  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1137  *
1138  * @pre This method can be called if sourcescip is in one of the following stages:
1139  * - \ref SCIP_STAGE_PROBLEM
1140  * - \ref SCIP_STAGE_TRANSFORMED
1141  * - \ref SCIP_STAGE_INITPRESOLVE
1142  * - \ref SCIP_STAGE_PRESOLVING
1143  * - \ref SCIP_STAGE_EXITPRESOLVE
1144  * - \ref SCIP_STAGE_PRESOLVED
1145  * - \ref SCIP_STAGE_INITSOLVE
1146  * - \ref SCIP_STAGE_SOLVING
1147  * - \ref SCIP_STAGE_SOLVED
1148  *
1149  * @pre This method can be called if targetscip is in one of the following stages:
1150  * - \ref SCIP_STAGE_PROBLEM
1151  *
1152  * @note sourcescip stage does not get changed
1153  *
1154  * @note targetscip stage does not get changed
1155  *
1156  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1157  */
1159  SCIP* sourcescip, /**< source SCIP data structure */
1160  SCIP* targetscip, /**< target SCIP data structure */
1161  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables to the corresponding
1162  * target variables, or NULL */
1163  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
1164  * target constraints, or NULL */
1165  SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
1166  SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
1167  int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
1168  SCIP_Bool global /**< should global or local bounds be used? */
1169  )
1170 {
1171  assert(sourcescip != NULL);
1172  assert(targetscip != NULL);
1173 
1174  /* check stages for both, the source and the target SCIP data structure */
1175  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1176  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyVars", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
1177 
1178  SCIP_CALL( copyVars(sourcescip, targetscip, varmap, consmap, fixedvars, fixedvals, nfixedvars, FALSE, global) );
1179 
1180  return SCIP_OKAY;
1181 }
1182 
1183 /** copies all original variables from source-SCIP and adds these variable to the target-SCIP; the mapping between these
1184  * variables are stored in the variable hashmap, target-SCIP has to be in problem creation stage, fixed and aggregated
1185  * variables do not get copied
1186  *
1187  * @note the variables are added to the target-SCIP but not captured
1188  *
1189  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
1190  * @note Do not change the source SCIP environment during the copying process
1191  *
1192  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1193  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1194  *
1195  * @pre This method can be called if sourcescip is in one of the following stages:
1196  * - \ref SCIP_STAGE_PROBLEM
1197  * - \ref SCIP_STAGE_TRANSFORMED
1198  * - \ref SCIP_STAGE_INITPRESOLVE
1199  * - \ref SCIP_STAGE_PRESOLVING
1200  * - \ref SCIP_STAGE_EXITPRESOLVE
1201  * - \ref SCIP_STAGE_PRESOLVED
1202  * - \ref SCIP_STAGE_INITSOLVE
1203  * - \ref SCIP_STAGE_SOLVING
1204  * - \ref SCIP_STAGE_SOLVED
1205  *
1206  * @pre This method can be called if targetscip is in one of the following stages:
1207  * - \ref SCIP_STAGE_PROBLEM
1208  *
1209  * @note sourcescip stage does not get changed
1210  *
1211  * @note targetscip stage does not get changed
1212  *
1213  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1214  */
1216  SCIP* sourcescip, /**< source SCIP data structure */
1217  SCIP* targetscip, /**< target SCIP data structure */
1218  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables to the corresponding
1219  * target variables, or NULL */
1220  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
1221  * target constraints, or NULL */
1222  SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
1223  SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
1224  int nfixedvars /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
1225  )
1226 {
1227  assert(sourcescip != NULL);
1228  assert(targetscip != NULL);
1229 
1230  /* check stages for both, the source and the target SCIP data structure */
1231  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrigVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1232  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrigVars", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
1233 
1234  SCIP_CALL( copyVars(sourcescip, targetscip, varmap, consmap, fixedvars, fixedvals, nfixedvars, TRUE, TRUE) );
1235 
1236  return SCIP_OKAY;
1237 }
1238 
1239 /** merges the histories of variables from a source SCIP into a target SCIP. The two data structures should point to
1240  * different SCIP instances.
1241  *
1242  * @note the notion of source and target is inverted here; \p sourcescip usually denotes a copied SCIP instance, whereas
1243  * \p targetscip denotes the original instance
1244  */
1246  SCIP* sourcescip, /**< source SCIP data structure */
1247  SCIP* targetscip, /**< target SCIP data structure */
1248  SCIP_VAR** sourcevars, /**< source variables for history merge */
1249  SCIP_VAR** targetvars, /**< target variables for history merge */
1250  int nvars /**< number of variables in both variable arrays */
1251  )
1252 {
1253  int i;
1254 
1255  /* check if target scip has been set to allow merging variable statistics */
1256  if( !targetscip->set->history_allowmerge )
1257  return SCIP_OKAY;
1258 
1259  assert(nvars == 0 || (sourcevars != NULL && targetvars != NULL));
1260  assert(sourcescip != targetscip);
1261 
1262  /* we do not want to copy statistics from a scip that has not really started solving */
1263  if( SCIPgetStage(sourcescip) < SCIP_STAGE_SOLVING )
1264  return SCIP_OKAY;
1265 
1266  /* if the transformation of the source was subject to scaling, the history information cannot be just copied */
1267  if( !SCIPsetIsEQ(targetscip->set, 1.0, SCIPgetOrigObjscale(sourcescip))
1268  || !SCIPsetIsEQ(targetscip->set, 0.0, SCIPgetOrigObjoffset(sourcescip)) )
1269  return SCIP_OKAY;
1270 
1271  /* merge histories of the targetSCIP-variables to the SCIP variables. */
1272  for( i = 0; i < nvars; ++i )
1273  {
1274  SCIP_VARSTATUS sourcevarstatus;
1275 
1276  assert(sourcevars[i]->scip == sourcescip);
1277  assert(targetvars[i]->scip == targetscip);
1278 
1279  sourcevarstatus = SCIPvarGetStatus(sourcevars[i]);
1280 
1281  /* depending on the variable status, we use either the transformed variable history or the history of the col itself */
1282  switch( sourcevarstatus )
1283  {
1285  assert(NULL != SCIPvarGetTransVar(sourcevars[i]));
1286  SCIPvarMergeHistories(targetvars[i], SCIPvarGetTransVar(sourcevars[i]), targetscip->stat);
1287  break;
1288  case SCIP_VARSTATUS_COLUMN:
1289  SCIPvarMergeHistories(targetvars[i], sourcevars[i], targetscip->stat);
1290  break;
1291  default:
1292  /* other variable status are currently not supported for the merging */
1293  break;
1294  } /*lint !e788*/
1295  }
1296 
1297  return SCIP_OKAY;
1298 }
1299 
1300 /** returns copy of the source constraint; if there already is a copy of the source constraint in the constraint hash
1301  * map, it is just returned as target constraint; elsewise a new constraint will be created; this created constraint is
1302  * added to the constraint hash map and returned as target constraint; the variable map is used to map the variables of
1303  * the source SCIP to the variables of the target SCIP
1304  *
1305  * @warning If a constraint is marked to be checked for feasibility but not to be enforced, a LP or pseudo solution may
1306  * be declared feasible even if it violates this particular constraint. This constellation should only be
1307  * used, if no LP or pseudo solution can violate the constraint -- e.g. if a local constraint is redundant due
1308  * to the variable's local bounds.
1309  *
1310  * @note The constraint is not added to the target SCIP. You can check whether a constraint is added by calling
1311  * SCIPconsIsAdded(). (If you mix SCIPgetConsCopy() with SCIPcopyConss() you should pay attention to what you add
1312  * explicitly and what is already added.)
1313  *
1314  * @note The constraint is always captured, either during the creation of the copy or after finding the copy of the
1315  * constraint in the constraint hash map
1316  *
1317  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
1318  * @note Do not change the source SCIP environment during the copying process
1319  *
1320  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1321  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1322  *
1323  * @pre This method can be called if sourcescip is in one of the following stages:
1324  * - \ref SCIP_STAGE_PROBLEM
1325  * - \ref SCIP_STAGE_TRANSFORMED
1326  * - \ref SCIP_STAGE_INITPRESOLVE
1327  * - \ref SCIP_STAGE_PRESOLVING
1328  * - \ref SCIP_STAGE_EXITPRESOLVE
1329  * - \ref SCIP_STAGE_PRESOLVED
1330  * - \ref SCIP_STAGE_INITSOLVE
1331  * - \ref SCIP_STAGE_SOLVING
1332  * - \ref SCIP_STAGE_SOLVED
1333  *
1334  * @pre This method can be called if targetscip is in one of the following stages:
1335  * - \ref SCIP_STAGE_PROBLEM
1336  * - \ref SCIP_STAGE_TRANSFORMING
1337  * - \ref SCIP_STAGE_INITPRESOLVE
1338  * - \ref SCIP_STAGE_PRESOLVING
1339  * - \ref SCIP_STAGE_EXITPRESOLVE
1340  * - \ref SCIP_STAGE_PRESOLVED
1341  * - \ref SCIP_STAGE_SOLVING
1342  * - \ref SCIP_STAGE_EXITSOLVE
1343  *
1344  * @note sourcescip stage does not get changed
1345  *
1346  * @note targetscip stage does not get changed
1347  *
1348  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1349  */
1351  SCIP* sourcescip, /**< source SCIP data structure */
1352  SCIP* targetscip, /**< target SCIP data structure */
1353  SCIP_CONS* sourcecons, /**< source constraint of the source SCIP */
1354  SCIP_CONS** targetcons, /**< pointer to store the created target constraint */
1355  SCIP_CONSHDLR* sourceconshdlr, /**< source constraint handler for this constraint */
1356  SCIP_HASHMAP* varmap, /**< a SCIP_HASHMAP mapping variables of the source SCIP to the corresponding
1357  * variables of the target SCIP, or NULL */
1358  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
1359  * target constraints, or NULL */
1360  const char* name, /**< name of constraint, or NULL if the name of the source constraint should be used */
1361  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP? */
1362  SCIP_Bool separate, /**< should the constraint be separated during LP processing? */
1363  SCIP_Bool enforce, /**< should the constraint be enforced during node processing? */
1364  SCIP_Bool check, /**< should the constraint be checked for feasibility? */
1365  SCIP_Bool propagate, /**< should the constraint be propagated during node processing? */
1366  SCIP_Bool local, /**< is constraint only valid locally? */
1367  SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)? */
1368  SCIP_Bool dynamic, /**< is constraint subject to aging? */
1369  SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup? */
1370  SCIP_Bool stickingatnode, /**< should the constraint always be kept at the node where it was added, even
1371  * if it may be moved to a more global node? */
1372  SCIP_Bool global, /**< create a global or a local copy? */
1373  SCIP_Bool* valid /**< pointer to store whether the copying was valid or not */
1374  )
1375 {
1376  SCIP_HASHMAP* localvarmap;
1377  SCIP_HASHMAP* localconsmap;
1378  SCIP_Bool uselocalvarmap;
1379  SCIP_Bool uselocalconsmap;
1380 
1381  assert(targetcons != NULL);
1382  assert(sourceconshdlr != NULL);
1383 
1384  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPgetConsCopy", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1385  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPgetConsCopy", FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE) );
1386 
1387  uselocalvarmap = (varmap == NULL);
1388  uselocalconsmap = (consmap == NULL);
1389 
1390  /* a variables map and a constraint map is needed to avoid infinite recursion */
1391  if( uselocalvarmap )
1392  {
1393  /* create the variable mapping hash map */
1394  SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
1395  }
1396  else
1397  localvarmap = varmap;
1398 
1399  *targetcons = NULL;
1400  if( uselocalconsmap )
1401  {
1402  /* create local constraint mapping hash map */
1403  SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
1404  }
1405  else
1406  {
1407  /* use global map and try to retrieve copied constraint */
1408  localconsmap = consmap;
1409  *targetcons = (SCIP_CONS*) SCIPhashmapGetImage(localconsmap, sourcecons);
1410  }
1411 
1412  if( *targetcons != NULL )
1413  {
1414  /* if found capture existing copy of the constraint */
1415  SCIP_CALL( SCIPcaptureCons(targetscip, *targetcons) );
1416  *valid = TRUE;
1417  }
1418  else
1419  {
1420  /* otherwise create a copy of the constraint */
1421  SCIP_CALL( SCIPconsCopy(targetcons, targetscip->set, name, sourcescip, sourceconshdlr, sourcecons, localvarmap, localconsmap,
1422  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, global, valid) );
1423 
1424  /* it is possible for the constraint handler to declare the copy valid although no target constraint was created */
1425  assert(*targetcons == NULL || *valid);
1426 
1427  /* if a target constraint was created */
1428  if( *targetcons != NULL && !uselocalconsmap )
1429  {
1430  /* insert constraint into mapping between source SCIP and the target SCIP */
1431  SCIP_CALL( SCIPhashmapInsert(consmap, sourcecons, *targetcons) );
1432  }
1433  }
1434 
1435  /* free locally allocated hash maps */
1436  if( uselocalvarmap )
1437  {
1438  SCIPhashmapFree(&localvarmap);
1439  }
1440 
1441  if( uselocalconsmap )
1442  {
1443  SCIPhashmapFree(&localconsmap);
1444  }
1445 
1446  return SCIP_OKAY;
1447 }
1448 
1449 /** copies constraints from the source-SCIP and adds these to the target-SCIP; for mapping the
1450  * variables between the source and the target SCIP a hash map can be given; if the variable hash
1451  * map is NULL or necessary variable mapping is missing, the required variables are created in the
1452  * target-SCIP and added to the hash map, if not NULL; all variables which are created are added to
1453  * the target-SCIP but not (user) captured; if the constraint hash map is not NULL the mapping
1454  * between the constraints of the source and target-SCIP is stored
1455  *
1456  * @note the constraints are added to the target-SCIP but are not (user) captured in the target SCIP. (If you mix
1457  * SCIPgetConsCopy() with SCIPcopyConss() you should pay attention to what you add explicitly and what is already
1458  * added.) You can check whether a constraint is added by calling SCIPconsIsAdded().
1459  *
1460  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
1461  * @note Do not change the source SCIP environment during the copying process
1462  *
1463  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1464  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1465  *
1466  * @pre This method can be called if sourcescip is in one of the following stages:
1467  * - \ref SCIP_STAGE_PROBLEM
1468  * - \ref SCIP_STAGE_TRANSFORMED
1469  * - \ref SCIP_STAGE_INITPRESOLVE
1470  * - \ref SCIP_STAGE_PRESOLVING
1471  * - \ref SCIP_STAGE_EXITPRESOLVE
1472  * - \ref SCIP_STAGE_PRESOLVED
1473  * - \ref SCIP_STAGE_INITSOLVE
1474  * - \ref SCIP_STAGE_SOLVING
1475  * - \ref SCIP_STAGE_SOLVED
1476  *
1477  * @pre This method can be called if targetscip is in one of the following stages:
1478  * - \ref SCIP_STAGE_PROBLEM
1479  *
1480  * @note sourcescip stage does not get changed
1481  *
1482  * @note targetscip stage does not get changed
1483  *
1484  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1485  */
1487  SCIP* sourcescip, /**< source SCIP data structure */
1488  SCIP* targetscip, /**< target SCIP data structure */
1489  SCIP_HASHMAP* varmap, /**< a SCIP_HASHMAP mapping variables of the source SCIP to the corresponding
1490  * variables of the target SCIP, or NULL */
1491  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
1492  * target constraints, or NULL */
1493  SCIP_Bool global, /**< create a global or a local copy? */
1494  SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance?
1495  * If TRUE, the modifiable flag of constraints will be copied. */
1496  SCIP_Bool* valid /**< pointer to store whether all constraints were validly copied */
1497  )
1498 {
1499  SCIP_CONSHDLR** sourceconshdlrs;
1500  SCIP_HASHMAP* localvarmap;
1501  SCIP_HASHMAP* localconsmap;
1502  SCIP_Bool uselocalvarmap;
1503  SCIP_Bool uselocalconsmap;
1504  int nsourceconshdlrs;
1505  int i;
1506 
1507  assert(sourcescip != NULL);
1508  assert(targetscip != NULL);
1509  assert(valid != NULL);
1510 
1511  /* check stages for both, the source and the target SCIP data structure */
1512  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyConss", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1513  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyConss", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
1514 
1515  /* check if we locally need to create a variable or constraint hash map */
1516  uselocalvarmap = (varmap == NULL);
1517  uselocalconsmap = (consmap == NULL);
1518 
1519  if( uselocalvarmap )
1520  {
1521  /* create the variable mapping hash map */
1522  SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
1523  }
1524  else
1525  localvarmap = varmap;
1526 
1527  if( uselocalconsmap )
1528  {
1529  /* create the constraint mapping hash map */
1530  SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
1531  }
1532  else
1533  localconsmap = consmap;
1534 
1535  nsourceconshdlrs = SCIPgetNConshdlrs(sourcescip);
1536  sourceconshdlrs = SCIPgetConshdlrs(sourcescip);
1537  assert(nsourceconshdlrs == 0 || sourceconshdlrs != NULL);
1538 
1539  *valid = TRUE;
1540 
1541  /* copy constraints: loop through all (source) constraint handlers */
1542  for( i = 0; i < nsourceconshdlrs; ++i )
1543  {
1544  SCIP_CONS** sourceconss;
1545  SCIP_CONS* targetcons;
1546  int nsourceconss;
1547  int c;
1548 
1549  assert(sourceconshdlrs[i] != NULL);
1550 
1551  /* constraint handlers have to explicitly set the valid pointer to TRUE for every single constraint */
1552 
1553  /* Get all active constraints for copying; this array contains all active constraints;
1554  * constraints are active if they are globally valid and not deleted after presolving OR they
1555  * were locally added during the search and we are currently in a node which belongs to the
1556  * corresponding subtree.
1557  */
1558  nsourceconss = SCIPconshdlrGetNActiveConss(sourceconshdlrs[i]);
1559  sourceconss = SCIPconshdlrGetConss(sourceconshdlrs[i]);
1560 
1561 #ifdef SCIP_DISABLED_CODE
1562  /* @todo using the following might reduce the number of copied constraints - check whether this is better */
1563  /* Get all checked constraints for copying; this included local constraints */
1564  if( !global )
1565  {
1566  nsourceconss = SCIPconshdlrGetNCheckConss(sourceconshdlrs[i]);
1567  sourceconss = SCIPconshdlrGetCheckConss(sourceconshdlrs[i]);
1568  }
1569 #endif
1570 
1571  assert(nsourceconss == 0 || sourceconss != NULL);
1572 
1573  if( nsourceconss > 0 )
1574  {
1575  SCIPdebugMsg(sourcescip, "Attempting to copy %d %s constraints\n", nsourceconss, SCIPconshdlrGetName(sourceconshdlrs[i]));
1576  }
1577 
1578  /* copy all constraints of one constraint handler */
1579  for( c = 0; c < nsourceconss; ++c )
1580  {
1581  SCIP_Bool singlevalid = FALSE;
1582  /* all constraints have to be active */
1583  assert(sourceconss[c] != NULL);
1584  assert(SCIPconsIsActive(sourceconss[c]));
1585  assert(!SCIPconsIsDeleted(sourceconss[c]));
1586 
1587  /* in case of copying the global problem we have to ignore the local constraints which are active */
1588  if( global && SCIPconsIsLocal(sourceconss[c]) )
1589  {
1590  SCIPdebugMsg(sourcescip, "did not copy local constraint <%s> when creating global copy\n", SCIPconsGetName(sourceconss[c]));
1591  continue;
1592  }
1593 
1594  /* use the copy constructor of the constraint handler and creates and captures the constraint if possible */
1595  targetcons = NULL;
1596  SCIP_CALL( SCIPgetConsCopy(sourcescip, targetscip, sourceconss[c], &targetcons, sourceconshdlrs[i], localvarmap, localconsmap, NULL,
1597  SCIPconsIsInitial(sourceconss[c]), SCIPconsIsSeparated(sourceconss[c]),
1598  SCIPconsIsEnforced(sourceconss[c]), SCIPconsIsChecked(sourceconss[c]),
1599  SCIPconsIsPropagated(sourceconss[c]), FALSE, SCIPconsIsModifiable(sourceconss[c]),
1600  SCIPconsIsDynamic(sourceconss[c]), SCIPconsIsRemovable(sourceconss[c]), FALSE, global, &singlevalid) );
1601 
1602  /* it is possible for a constraint handler to declare the copy valid, although no target constraint was created */
1603  assert(targetcons == NULL || singlevalid);
1604 
1605  /* add the copied constraint to target SCIP if the copying process created a constraint */
1606  if( targetcons != NULL )
1607  {
1608  if( !enablepricing )
1609  SCIPconsSetModifiable(targetcons, FALSE);
1610 
1611  /* add constraint to target SCIP */
1612  SCIP_CALL( SCIPaddCons(targetscip, targetcons) );
1613 
1614  /* add the conflict constraint to the store of targetscip */
1615  if( SCIPconsIsConflict(sourceconss[c]) )
1616  {
1617  /* add the constraint as a conflict to the conflict pool of targetscip */
1618  SCIP_CALL( SCIPconflictstoreAddConflict(targetscip->conflictstore, targetscip->mem->probmem, targetscip->set,
1619  targetscip->stat, NULL, NULL, targetscip->reopt, targetcons, SCIP_CONFTYPE_UNKNOWN, FALSE, -SCIPinfinity(targetscip)) );
1620  }
1621 
1622  /* release constraint once for the creation capture */
1623  SCIP_CALL( SCIPreleaseCons(targetscip, &targetcons) );
1624  }
1625  else
1626  {
1627  *valid = (*valid && singlevalid);
1628  SCIPdebugMsg(sourcescip, "Constraint %s not copied, copy is %svalid\n",
1629  SCIPconsGetName(sourceconss[c]), *valid ? "" : "not ");
1630  }
1631  }
1632  }
1633 
1634  if( uselocalvarmap )
1635  {
1636  /* free hash map */
1637  SCIPhashmapFree(&localvarmap);
1638  }
1639 
1640  if( uselocalconsmap )
1641  {
1642  /* free hash map */
1643  SCIPhashmapFree(&localconsmap);
1644  }
1645 
1646  return SCIP_OKAY;
1647 }
1648 
1649 /** copies all original constraints from the source-SCIP and adds these to the target-SCIP; for mapping the
1650  * variables between the source and the target SCIP a hash map can be given; if the variable hash
1651  * map is NULL or necessary variable mapping is missing, the required variables are created in the
1652  * target-SCIP and added to the hash map, if not NULL; all variables which are created are added to
1653  * the target-SCIP but not (user) captured; if the constraint hash map is not NULL the mapping
1654  * between the constraints of the source and target-SCIP is stored
1655  *
1656  * @note the constraints are added to the target-SCIP but are not (user) captured in the target SCIP. (If you mix
1657  * SCIPgetConsCopy() with SCIPcopyConss() you should pay attention to what you add explicitly and what is already
1658  * added.) You can check whether a constraint is added by calling SCIPconsIsAdded().
1659  *
1660  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
1661  * @note Do not change the source SCIP environment during the copying process
1662  *
1663  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1664  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1665  *
1666  * @pre This method can be called if sourcescip is in one of the following stages:
1667  * - \ref SCIP_STAGE_PROBLEM
1668  * - \ref SCIP_STAGE_TRANSFORMED
1669  * - \ref SCIP_STAGE_INITPRESOLVE
1670  * - \ref SCIP_STAGE_PRESOLVING
1671  * - \ref SCIP_STAGE_EXITPRESOLVE
1672  * - \ref SCIP_STAGE_PRESOLVED
1673  * - \ref SCIP_STAGE_INITSOLVE
1674  * - \ref SCIP_STAGE_SOLVING
1675  * - \ref SCIP_STAGE_SOLVED
1676  *
1677  * @pre This method can be called if targetscip is in one of the following stages:
1678  * - \ref SCIP_STAGE_PROBLEM
1679  *
1680  * @note sourcescip stage does not get changed
1681  *
1682  * @note targetscip stage does not get changed
1683  *
1684  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1685  */
1687  SCIP* sourcescip, /**< source SCIP data structure */
1688  SCIP* targetscip, /**< target SCIP data structure */
1689  SCIP_HASHMAP* varmap, /**< a SCIP_HASHMAP mapping variables of the source SCIP to the corresponding
1690  * variables of the target SCIP, or NULL */
1691  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
1692  * target constraints, or NULL */
1693  SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance?
1694  * If TRUE, the modifiable flag of constraints will be copied. */
1695  SCIP_Bool* valid /**< pointer to store whether all constraints were validly copied */
1696  )
1697 {
1698  SCIP_CONS** sourceconss;
1699  SCIP_HASHMAP* localvarmap;
1700  SCIP_HASHMAP* localconsmap;
1701  SCIP_Bool uselocalvarmap;
1702  SCIP_Bool uselocalconsmap;
1703  int nsourceconss;
1704  int c;
1705 
1706  assert(sourcescip != NULL);
1707  assert(targetscip != NULL);
1708  assert(valid != NULL);
1709 
1710  /* check stages for both, the source and the target SCIP data structure */
1711  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrigConss", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1712  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrigConss", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
1713 
1714  /* check if we locally need to create a variable or constraint hash map */
1715  uselocalvarmap = (varmap == NULL);
1716  uselocalconsmap = (consmap == NULL);
1717 
1718  if( uselocalvarmap )
1719  {
1720  /* create the variable mapping hash map */
1721  SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
1722  }
1723  else
1724  localvarmap = varmap;
1725 
1726  if( uselocalconsmap )
1727  {
1728  /* create the constraint mapping hash map */
1729  SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
1730  }
1731  else
1732  localconsmap = consmap;
1733 
1734  sourceconss = SCIPgetOrigConss(sourcescip);
1735  nsourceconss = SCIPgetNOrigConss(sourcescip);
1736 
1737  *valid = TRUE;
1738 
1739  SCIPdebugMsg(sourcescip, "Attempting to copy %d original constraints\n", nsourceconss);
1740 
1741  /* copy constraints: loop through all (source) constraint handlers */
1742  for( c = 0; c < nsourceconss; ++c )
1743  {
1744  SCIP_CONS* targetcons;
1745  SCIP_Bool success;
1746 
1747  /* constraint handlers have to explicitly set the success pointer to TRUE */
1748  success = FALSE;
1749 
1750  /* all constraints have to be active */
1751  assert(sourceconss[c] != NULL);
1752  assert(SCIPconsIsOriginal(sourceconss[c]));
1753 
1754  /* use the copy constructor of the constraint handler and creates and captures the constraint if possible */
1755  targetcons = NULL;
1756  SCIP_CALL( SCIPgetConsCopy(sourcescip, targetscip, sourceconss[c], &targetcons, SCIPconsGetHdlr(sourceconss[c]), localvarmap, localconsmap, NULL,
1757  SCIPconsIsInitial(sourceconss[c]), SCIPconsIsSeparated(sourceconss[c]),
1758  SCIPconsIsEnforced(sourceconss[c]), SCIPconsIsChecked(sourceconss[c]),
1759  SCIPconsIsPropagated(sourceconss[c]), FALSE, SCIPconsIsModifiable(sourceconss[c]),
1760  SCIPconsIsDynamic(sourceconss[c]), SCIPconsIsRemovable(sourceconss[c]), FALSE, TRUE, &success) );
1761 
1762  /* add the copied constraint to target SCIP if the copying process was valid */
1763  if( success )
1764  {
1765  assert(targetcons != NULL);
1766 
1767  if( !enablepricing )
1768  SCIPconsSetModifiable(targetcons, FALSE);
1769 
1770  /* add constraint to target SCIP */
1771  SCIP_CALL( SCIPaddCons(targetscip, targetcons) );
1772 
1773  /* release constraint once for the creation capture */
1774  SCIP_CALL( SCIPreleaseCons(targetscip, &targetcons) );
1775  }
1776  else
1777  {
1778  *valid = FALSE;
1779  SCIPdebugMsg(sourcescip, "failed to copy constraint %s\n", SCIPconsGetName(sourceconss[c]));
1780  }
1781  }
1782 
1783  if( uselocalvarmap )
1784  {
1785  /* free hash map */
1786  SCIPhashmapFree(&localvarmap);
1787  }
1788 
1789  if( uselocalconsmap )
1790  {
1791  /* free hash map */
1792  SCIPhashmapFree(&localconsmap);
1793  }
1794 
1795  return SCIP_OKAY;
1796 }
1797 
1798 
1799 /** convert all active cuts from cutpool to linear constraints
1800  *
1801  * @note Do not change the source SCIP environment during the copying process
1802  *
1803  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1804  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1805  *
1806  * @pre This method can be called if SCIP is in one of the following stages:
1807  * - \ref SCIP_STAGE_PROBLEM
1808  * - \ref SCIP_STAGE_INITPRESOLVE
1809  * - \ref SCIP_STAGE_PRESOLVING
1810  * - \ref SCIP_STAGE_EXITPRESOLVE
1811  * - \ref SCIP_STAGE_PRESOLVED
1812  * - \ref SCIP_STAGE_SOLVING
1813  * - \ref SCIP_STAGE_EXITSOLVE
1814  *
1815  * @note SCIP stage does not get changed
1816  *
1817  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1818  */
1820  SCIP* scip, /**< SCIP data structure */
1821  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
1822  * target variables, or NULL */
1823  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
1824  * target constraints, or NULL */
1825  SCIP_Bool global, /**< create a global or a local copy? */
1826  int* ncutsadded /**< pointer to store number of added cuts, or NULL */
1827  )
1828 {
1829  assert(scip != NULL);
1830  assert(scip->set != NULL);
1831 
1832  /* check stages for the SCIP data structure */
1833  SCIP_CALL( SCIPcheckStage(scip, "SCIPconvertCutsToConss", FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE) );
1834 
1835  /* if we do not have any cuts, nothing can be converted */
1836  if( scip->set->stage < SCIP_STAGE_SOLVING )
1837  return SCIP_OKAY;
1838 
1839  /* create out of all active cuts in cutpool linear constraints in targetscip */
1840  SCIP_CALL( SCIPcopyCuts(scip, scip, varmap, consmap, global, ncutsadded) );
1841 
1842  return SCIP_OKAY;
1843 }
1844 
1845 /** copies all active cuts from cutpool of sourcescip to linear constraints in targetscip
1846  *
1847  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
1848  * @note Do not change the source SCIP environment during the copying process
1849  *
1850  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1851  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1852  *
1853  * @pre This method can be called if sourcescip is in one of the following stages:
1854  * - \ref SCIP_STAGE_PROBLEM
1855  * - \ref SCIP_STAGE_TRANSFORMED
1856  * - \ref SCIP_STAGE_INITPRESOLVE
1857  * - \ref SCIP_STAGE_PRESOLVING
1858  * - \ref SCIP_STAGE_EXITPRESOLVE
1859  * - \ref SCIP_STAGE_PRESOLVED
1860  * - \ref SCIP_STAGE_SOLVING
1861  * - \ref SCIP_STAGE_SOLVED
1862  * - \ref SCIP_STAGE_EXITSOLVE
1863  *
1864  * @pre This method can be called if targetscip is in one of the following stages:
1865  * - \ref SCIP_STAGE_PROBLEM
1866  * - \ref SCIP_STAGE_INITPRESOLVE
1867  * - \ref SCIP_STAGE_PRESOLVING
1868  * - \ref SCIP_STAGE_EXITPRESOLVE
1869  * - \ref SCIP_STAGE_PRESOLVED
1870  * - \ref SCIP_STAGE_SOLVING
1871  * - \ref SCIP_STAGE_EXITSOLVE
1872  *
1873  * @note sourcescip stage does not get changed
1874  *
1875  * @note targetscip stage does not get changed
1876  *
1877  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1878  */
1880  SCIP* sourcescip, /**< source SCIP data structure */
1881  SCIP* targetscip, /**< target SCIP data structure */
1882  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
1883  * target variables, or NULL */
1884  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
1885  * target constraints, or NULL */
1886  SCIP_Bool global, /**< create a global or a local copy? */
1887  int* ncutsadded /**< pointer to store number of copied cuts, or NULL */
1888  )
1889 {
1890  SCIP_CUT** cuts;
1891  int ncuts;
1892  int nlocalcutsadded;
1893 
1894  assert(sourcescip != NULL);
1895  assert(targetscip != NULL);
1896 
1897  /* check stages for both, the source and the target SCIP data structure */
1898  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyCuts", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE) );
1899  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyCuts", FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE) );
1900 
1901  if ( ncutsadded != NULL )
1902  *ncutsadded = 0;
1903  nlocalcutsadded = 0;
1904 
1905  /* if we do not have any cuts, nothing can be converted */
1906  if( sourcescip->set->stage < SCIP_STAGE_SOLVING )
1907  return SCIP_OKAY;
1908 
1909  if( SCIPfindConshdlr(targetscip, "linear") == NULL )
1910  {
1911  SCIPdebugMsg(sourcescip, "No linear constraint handler available. Cannot convert cuts.\n");
1912  return SCIP_OKAY;
1913  }
1914 
1915  /* convert cut from global cut pool */
1916  cuts = SCIPgetPoolCuts(sourcescip);
1917  ncuts = SCIPgetNPoolCuts(sourcescip);
1918 
1919  SCIP_CALL( copyCuts(sourcescip, targetscip, cuts, ncuts, varmap, consmap, global, &nlocalcutsadded) );
1920 
1921  SCIPdebugMsg(sourcescip, "Converted %d active cuts to constraints.\n", nlocalcutsadded);
1922 
1923  /* convert delayed cuts from global delayed cut pool */
1924  cuts = SCIPgetDelayedPoolCuts(sourcescip);
1925  ncuts = SCIPgetNDelayedPoolCuts(sourcescip);
1926 
1927  SCIP_CALL( copyCuts(sourcescip, targetscip, cuts, ncuts, varmap, consmap, global, &nlocalcutsadded) );
1928 
1929  if( ncutsadded != NULL )
1930  *ncutsadded = nlocalcutsadded;
1931 
1932  SCIPdebugMsg(sourcescip, "Converted %d active cuts to constraints.\n", nlocalcutsadded);
1933 
1934  return SCIP_OKAY;
1935 }
1936 
1937 /** copies all active conflicts from the conflict pool of sourcescip and adds them as linear constraints to targetscip
1938  *
1939  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
1940  * @note Do not change the source SCIP environment during the copying process
1941  *
1942  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1943  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1944  *
1945  * @pre This method can be called if sourcescip is in one of the following stages:
1946  * - \ref SCIP_STAGE_PROBLEM
1947  * - \ref SCIP_STAGE_TRANSFORMED
1948  * - \ref SCIP_STAGE_INITPRESOLVE
1949  * - \ref SCIP_STAGE_PRESOLVING
1950  * - \ref SCIP_STAGE_EXITPRESOLVE
1951  * - \ref SCIP_STAGE_PRESOLVED
1952  * - \ref SCIP_STAGE_SOLVING
1953  * - \ref SCIP_STAGE_SOLVED
1954  * - \ref SCIP_STAGE_EXITSOLVE
1955  *
1956  * @pre This method can be called if targetscip is in one of the following stages:
1957  * - \ref SCIP_STAGE_PROBLEM
1958  * - \ref SCIP_STAGE_INITPRESOLVE
1959  * - \ref SCIP_STAGE_PRESOLVING
1960  * - \ref SCIP_STAGE_EXITPRESOLVE
1961  * - \ref SCIP_STAGE_PRESOLVED
1962  * - \ref SCIP_STAGE_SOLVING
1963  * - \ref SCIP_STAGE_EXITSOLVE
1964  *
1965  * @note sourcescip stage does not change
1966  *
1967  * @note targetscip stage does not change
1968  *
1969  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1970  */
1972  SCIP* sourcescip, /**< source SCIP data structure */
1973  SCIP* targetscip, /**< target SCIP data structure */
1974  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
1975  * target variables, or NULL */
1976  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
1977  * target constraints, or NULL */
1978  SCIP_Bool global, /**< create a global or a local copy? */
1979  SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance?
1980  * If TRUE, the modifiable flag of constraints will be copied. */
1981  SCIP_Bool* valid /**< pointer to store whether all constraints were validly copied */
1982  )
1983 {
1984  SCIP_CONS** sourceconfs;
1985  SCIP_HASHMAP* localvarmap;
1986  SCIP_HASHMAP* localconsmap;
1987  SCIP_Bool uselocalvarmap;
1988  SCIP_Bool uselocalconsmap;
1989  SCIP_Bool success;
1990  int sourceconfssize;
1991  int nsourceconfs;
1992  int c;
1993 
1994  assert(sourcescip != NULL);
1995  assert(targetscip != NULL);
1996 
1997  /* check stages for both, the source and the target SCIP data structure */
1998  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyConss", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1999  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyConss", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
2000 
2001  /* check if we locally need to create a variable or constraint hash map */
2002  uselocalvarmap = (varmap == NULL);
2003  uselocalconsmap = (consmap == NULL);
2004 
2005  if( uselocalvarmap )
2006  {
2007  /* create the variable mapping hash map */
2008  SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
2009  }
2010  else
2011  localvarmap = varmap;
2012 
2013  if( uselocalconsmap )
2014  {
2015  /* create the constraint mapping hash map */
2016  SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
2017  }
2018  else
2019  localconsmap = consmap;
2020 
2021  /* get number of conflicts stored in the conflict pool */
2022  sourceconfssize = SCIPconflictstoreGetNConflictsInStore(sourcescip->conflictstore);
2023 
2024  /* allocate buffer */
2025  SCIP_CALL( SCIPallocBufferArray(sourcescip, &sourceconfs, sourceconfssize) );
2026 
2027  /* get all conflicts stored in the conflict pool */
2028  SCIP_CALL( SCIPconflictstoreGetConflicts(sourcescip->conflictstore, sourceconfs, sourceconfssize, &nsourceconfs) );
2029  assert(nsourceconfs <= sourceconfssize);
2030 
2031  /* copy conflicts */
2032  for( c = 0; c < nsourceconfs; ++c )
2033  {
2034  SCIP_CONS* targetcons;
2035 
2036  /* all constraints have to be active */
2037  assert(sourceconfs[c] != NULL);
2038  assert(SCIPconsIsActive(sourceconfs[c]));
2039  assert(!SCIPconsIsDeleted(sourceconfs[c]));
2040  assert(SCIPconsIsConflict(sourceconfs[c]));
2041 
2042  /* in case of copying the global problem we have to ignore the local constraints which are active */
2043  if( global && SCIPconsIsLocal(sourceconfs[c]) )
2044  {
2045  SCIPdebugMsg(sourcescip, "did not copy local constraint <%s> when creating global copy\n", SCIPconsGetName(sourceconfs[c]));
2046  continue;
2047  }
2048 
2049  /* use the copy constructor of the constraint handler and creates and captures the constraint if possible */
2050  targetcons = NULL;
2051  SCIP_CALL( SCIPgetConsCopy(sourcescip, targetscip, sourceconfs[c], &targetcons, SCIPconsGetHdlr(sourceconfs[c]),
2052  localvarmap, localconsmap, NULL, SCIPconsIsInitial(sourceconfs[c]), SCIPconsIsSeparated(sourceconfs[c]),
2053  SCIPconsIsEnforced(sourceconfs[c]), SCIPconsIsChecked(sourceconfs[c]),
2054  SCIPconsIsPropagated(sourceconfs[c]), FALSE, SCIPconsIsModifiable(sourceconfs[c]),
2055  SCIPconsIsDynamic(sourceconfs[c]), SCIPconsIsRemovable(sourceconfs[c]), FALSE, global, &success) );
2056 
2057  /* add the copied constraint to target SCIP if the copying process was valid */
2058  if( success )
2059  {
2060  assert(targetcons != NULL);
2061 
2062  if( !enablepricing )
2063  SCIPconsSetModifiable(targetcons, FALSE);
2064 
2065  /* add constraint to target SCIP */
2066  SCIP_CALL( SCIPaddCons(targetscip, targetcons) );
2067 
2068  /* release constraint once for the creation capture */
2069  SCIP_CALL( SCIPreleaseCons(targetscip, &targetcons) );
2070  }
2071  else
2072  {
2073  *valid = FALSE;
2074  SCIPdebugMsg(sourcescip, "failed to copy constraint %s\n", SCIPconsGetName(sourceconfs[c]));
2075  }
2076  }
2077 
2078  if( uselocalvarmap )
2079  {
2080  /* free hash map */
2081  SCIPhashmapFree(&localvarmap);
2082  }
2083 
2084  if( uselocalconsmap )
2085  {
2086  /* free hash map */
2087  SCIPhashmapFree(&localconsmap);
2088  }
2089 
2090  return SCIP_OKAY;
2091 }
2092 
2093 /** copies implications and cliques of sourcescip to targetscip
2094  *
2095  * This function should be called for a targetscip in transformed stage. It can save time in presolving of the
2096  * targetscip, since implications and cliques are copied.
2097  *
2098  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
2099  * @note Do not change the source SCIP environment during the copying process
2100  *
2101  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2102  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2103  *
2104  * @pre This method can be called if sourcescip is in one of the following stages:
2105  * - \ref SCIP_STAGE_TRANSFORMED
2106  * - \ref SCIP_STAGE_INITPRESOLVE
2107  * - \ref SCIP_STAGE_PRESOLVING
2108  * - \ref SCIP_STAGE_EXITPRESOLVE
2109  * - \ref SCIP_STAGE_PRESOLVED
2110  * - \ref SCIP_STAGE_SOLVING
2111  * - \ref SCIP_STAGE_SOLVED
2112  * - \ref SCIP_STAGE_EXITSOLVE
2113  *
2114  * @pre This method can be called if targetscip is in one of the following stages:
2115  * - \ref SCIP_STAGE_TRANSFORMED
2116  * - \ref SCIP_STAGE_INITPRESOLVE
2117  * - \ref SCIP_STAGE_PRESOLVING
2118  * - \ref SCIP_STAGE_EXITPRESOLVE
2119  * - \ref SCIP_STAGE_PRESOLVED
2120  * - \ref SCIP_STAGE_INITSOLVE
2121  * - \ref SCIP_STAGE_SOLVING
2122  *
2123  * @note sourcescip stage does not get changed
2124  *
2125  * @note targetscip stage does not get changed
2126  *
2127  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2128  */
2130  SCIP* sourcescip, /**< source SCIP data structure */
2131  SCIP* targetscip, /**< target SCIP data structure */
2132  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
2133  * target variables, or NULL */
2134  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
2135  * target constraints, or NULL */
2136  SCIP_Bool global, /**< create a global or a local copy? */
2137  SCIP_Bool* infeasible, /**< pointer to store whether an infeasibility was detected */
2138  int* nbdchgs, /**< pointer to store the number of performed bound changes, or NULL */
2139  int* ncopied /**< pointer to store number of copied implications and cliques, or NULL */
2140  )
2141 {
2142  SCIP_CLIQUE** cliques;
2143  SCIP_VAR** sourcevars;
2144  SCIP_Bool success;
2145  int nvars;
2146  int nbinvars;
2147  int ncliques;
2148  int j;
2149  int c;
2150 
2151  assert( sourcescip != NULL );
2152  assert( targetscip != NULL );
2153  assert( sourcescip != targetscip );
2154  assert( infeasible != NULL );
2155 
2156  /* check stages for both, the source and the target SCIP data structure */
2157  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyImplicationsCliques", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE) );
2158  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyImplicationsCliques", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2159 
2160  if ( ncopied != NULL )
2161  *ncopied = 0;
2162  if ( nbdchgs != NULL )
2163  *nbdchgs = 0;
2164 
2165  /* get all active variables */
2166  SCIP_CALL( SCIPgetVarsData(sourcescip, &sourcevars, &nvars, &nbinvars, NULL, NULL, NULL) );
2167 
2168  /* stop if no possible variables for cliques exist */
2169  if ( nbinvars == 0 )
2170  return SCIP_OKAY;
2171 
2172  /* get cliques */
2173  ncliques = SCIPgetNCliques(sourcescip);
2174  if ( ncliques > 0 )
2175  {
2176  SCIP_VAR** targetclique;
2177 
2178  /* get space for target cliques */
2179  SCIP_CALL( SCIPallocBufferArray(targetscip, &targetclique, nvars) );
2180  cliques = SCIPgetCliques(sourcescip);
2181 
2182  /* loop through all cliques */
2183  for (c = 0; c < ncliques; ++c)
2184  {
2185  SCIP_VAR** cliquevars;
2186  SCIP_Bool* cliquevals;
2187  int cliquesize;
2188  int nboundchg = 0;
2189 
2190  assert( cliques[c] != NULL );
2191  cliquevals = SCIPcliqueGetValues(cliques[c]);
2192  cliquevars = SCIPcliqueGetVars(cliques[c]);
2193  cliquesize = SCIPcliqueGetNVars(cliques[c]);
2194 
2195  /* get target variables of clique */
2196  for (j = 0; j < cliquesize; ++j)
2197  {
2198  SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, cliquevars[j], &targetclique[j], varmap, consmap, global, &success) );
2199  if ( ! success )
2200  {
2201  SCIPdebugMsg(sourcescip, "Getting copy for variable <%s> failed.\n", SCIPvarGetName(cliquevars[j]));
2202  SCIPfreeBufferArray(targetscip, &targetclique);
2203  return SCIP_OKAY;
2204  }
2205  }
2206 
2207  /* create clique */
2208  SCIP_CALL( SCIPaddClique(targetscip, targetclique, cliquevals, cliquesize, SCIPcliqueIsEquation(cliques[c]),
2209  infeasible, &nboundchg) );
2210 
2211  if ( *infeasible )
2212  {
2213  SCIPfreeBufferArray(targetscip, &targetclique);
2214  return SCIP_OKAY;
2215  }
2216  if ( ncopied != NULL )
2217  ++(*ncopied);
2218  if ( nbdchgs != NULL )
2219  *nbdchgs += nboundchg;
2220  }
2221  SCIPfreeBufferArray(targetscip, &targetclique);
2222  }
2223 
2224  /* create binary implications */
2225  for (j = 0; j < nbinvars; ++j)
2226  {
2227  SCIP_VAR* sourcevar;
2228  SCIP_VAR* targetvar;
2229  SCIP_Bool d;
2230 
2231  sourcevar = sourcevars[j];
2232  SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourcevar, &targetvar, varmap, consmap, global, &success) );
2233  if ( ! success )
2234  {
2235  SCIPdebugMsg(sourcescip, "Getting copy for variable <%s> failed.\n", SCIPvarGetName(sourcevar));
2236  return SCIP_OKAY;
2237  }
2238 
2239  /* consider both possible implications */
2240  for (d = 0; d <= 1; ++d)
2241  {
2242  SCIP_BOUNDTYPE* impltypes;
2243  SCIP_VAR** implvars;
2244  SCIP_Real* implbounds;
2245  int nimpls;
2246  int l;
2247 
2248  nimpls = SCIPvarGetNImpls(sourcevar, d);
2249  if ( nimpls == 0 )
2250  continue;
2251 
2252  impltypes = SCIPvarGetImplTypes(sourcevar, d);
2253  implvars = SCIPvarGetImplVars(sourcevar, d);
2254  implbounds = SCIPvarGetImplBounds(sourcevar, d);
2255 
2256  /* create implications */
2257  for (l = 0; l < nimpls; ++l)
2258  {
2259  SCIP_VAR* implvar;
2260  int nboundchg = 0;
2261 
2262  SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, implvars[l], &implvar, varmap, consmap, global, &success) );
2263  if ( ! success )
2264  {
2265  SCIPdebugMsg(sourcescip, "Getting copy for variable <%s> failed.\n", SCIPvarGetName(implvars[l]));
2266  return SCIP_OKAY;
2267  }
2268 
2269  SCIP_CALL( SCIPaddVarImplication(targetscip, targetvar, d, implvar, impltypes[l], implbounds[l], infeasible, &nboundchg) );
2270  if ( *infeasible )
2271  return SCIP_OKAY;
2272  if ( ncopied != NULL )
2273  ++(*ncopied);
2274  if ( nbdchgs != NULL )
2275  *nbdchgs += nboundchg;
2276  }
2277  }
2278  }
2279 
2280  return SCIP_OKAY;
2281 }
2282 
2283 /** copies parameter settings from sourcescip to targetscip
2284  *
2285  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
2286  * @note Do not change the source SCIP environment during the copying process
2287  *
2288  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2289  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2290  *
2291  * @pre This method can be called if sourcescip is in one of the following stages:
2292  * - \ref SCIP_STAGE_PROBLEM
2293  * - \ref SCIP_STAGE_TRANSFORMED
2294  * - \ref SCIP_STAGE_INITPRESOLVE
2295  * - \ref SCIP_STAGE_PRESOLVING
2296  * - \ref SCIP_STAGE_EXITPRESOLVE
2297  * - \ref SCIP_STAGE_PRESOLVED
2298  * - \ref SCIP_STAGE_INITSOLVE
2299  * - \ref SCIP_STAGE_SOLVING
2300  * - \ref SCIP_STAGE_SOLVED
2301  *
2302  * @pre This method can be called if targetscip is in one of the following stages:
2303  * - \ref SCIP_STAGE_INIT
2304  * - \ref SCIP_STAGE_PROBLEM
2305  * - \ref SCIP_STAGE_FREE
2306  *
2307  * @note sourcescip stage does not get changed
2308  *
2309  * @note targetscip stage does not get changed
2310  *
2311  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2312  */
2314  SCIP* sourcescip, /**< source SCIP data structure */
2315  SCIP* targetscip /**< target SCIP data structure */
2316  )
2317 {
2318  assert(sourcescip != NULL);
2319  assert(targetscip != NULL);
2320  assert(sourcescip->set != NULL);
2321  assert(targetscip->set != NULL);
2322 
2323  /* check stages for both, the source and the target SCIP data structure */
2324  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyParamSettings", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
2325  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyParamSettings", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
2326 
2327  SCIP_CALL( SCIPsetCopyParams(sourcescip->set, targetscip->set, targetscip->messagehdlr) );
2328 
2329  return SCIP_OKAY;
2330 }
2331 
2332 /** gets depth of current scip instance (increased by each copy call)
2333  *
2334  * @return Depth of subscip of SCIP is returned.
2335  *
2336  * @pre This method can be called if SCIP is in one of the following stages:
2337  * - \ref SCIP_STAGE_PROBLEM
2338  * - \ref SCIP_STAGE_TRANSFORMING
2339  * - \ref SCIP_STAGE_TRANSFORMED
2340  * - \ref SCIP_STAGE_INITPRESOLVE
2341  * - \ref SCIP_STAGE_PRESOLVING
2342  * - \ref SCIP_STAGE_EXITPRESOLVE
2343  * - \ref SCIP_STAGE_PRESOLVED
2344  * - \ref SCIP_STAGE_INITSOLVE
2345  * - \ref SCIP_STAGE_SOLVING
2346  * - \ref SCIP_STAGE_SOLVED
2347  * - \ref SCIP_STAGE_EXITSOLVE
2348  * - \ref SCIP_STAGE_FREETRANS
2349  *
2350  * @note SCIP stage does not get changed
2351  *
2352  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2353  */
2355  SCIP* scip /**< SCIP data structure */
2356  )
2357 {
2358  assert( scip != NULL );
2359  assert( scip->stat != NULL );
2360 
2361  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSubscipDepth", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2362 
2363  return scip->stat->subscipdepth;
2364 }
2365 
2366 /** sets depth of scip instance
2367  *
2368  * @pre This method can be called if SCIP is in one of the following stages:
2369  * - \ref SCIP_STAGE_PROBLEM
2370  *
2371  * @note SCIP stage does not get changed
2372  *
2373  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2374  */
2376  SCIP* scip, /**< SCIP data structure */
2377  int newdepth /**< new subscip depth */
2378  )
2379 {
2380  assert( scip != NULL );
2381  assert( scip->stat != NULL );
2382  assert( newdepth > 0 );
2383 
2384  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPsetSubscipDepth", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
2385 
2386  scip->stat->subscipdepth = newdepth;
2387 }
2388 
2389 /** copies source SCIP data into target SCIP data structure
2390  *
2391  * distinguishes between
2392  * - local and global copies
2393  * - copies of the original or transformed problem
2394  *
2395  * Allows for constraint compression by specifying a number of source variables
2396  * and values that should be fixed in the copy.
2397  */
2398 static
2400  SCIP* sourcescip, /**< source SCIP data structure */
2401  SCIP* targetscip, /**< target SCIP data structure */
2402  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
2403  * target variables, or NULL */
2404  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
2405  * target constraints, or NULL */
2406  const char* suffix, /**< optional suffix for problem name inside the target SCIP */
2407  SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
2408  SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
2409  int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
2410  SCIP_Bool useconscompression, /**< should constraint compression be used when constraints are created? */
2411  SCIP_Bool global, /**< create a global or a local copy? */
2412  SCIP_Bool original, /**< copy original or transformed problem? if TRUE, a copy using local bounds is not possible */
2413  SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
2414  * plugins will be copied and activated, and the modifiable flag of
2415  * constraints will be respected. If FALSE, valid will be set to FALSE, when
2416  * there are pricers present */
2417  SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
2418  SCIP_Bool* valid /**< pointer to store whether the copying was valid or not, or NULL */
2419  )
2420 {
2421  SCIP_HASHMAP* localvarmap;
2422  SCIP_HASHMAP* localconsmap;
2423  SCIP_Real startcopytime;
2424  SCIP_Real copytime;
2425  SCIP_Bool uselocalvarmap;
2426  SCIP_Bool uselocalconsmap;
2427  SCIP_Bool consscopyvalid;
2428  SCIP_Bool benderscopyvalid;
2429  SCIP_Bool localvalid;
2430  SCIP_Bool msghdlrquiet;
2431  char name[SCIP_MAXSTRLEN];
2432 
2433  assert(sourcescip != NULL);
2434  assert(targetscip != NULL);
2435  assert(suffix != NULL);
2436 
2437  /* copy the original problem if we are in SCIP_STAGE_PROBLEM stage */
2438  if( SCIPgetStage(sourcescip) == SCIP_STAGE_PROBLEM )
2439  original = TRUE;
2440 
2441  /* global must be TRUE for the original problem */
2442  assert(global || !original);
2443 
2444  /* get time before start of copy procedure */
2445  startcopytime = SCIPclockGetTime(sourcescip->stat->copyclock);
2446 
2447  /* start time measuring */
2448  SCIPclockStart(sourcescip->stat->copyclock, sourcescip->set);
2449 
2450  /* copy all plugins */
2451  SCIP_CALL( SCIPcopyPlugins(sourcescip, targetscip, TRUE, enablepricing, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
2452  TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, passmessagehdlr, &localvalid) );
2453 
2454  /* in case there are active pricers and pricing is disabled, targetscip will not be a valid copy of sourcescip */
2455  if( ! enablepricing && SCIPgetNActivePricers(sourcescip) > 0 )
2456  localvalid = FALSE;
2457 
2458  SCIPdebugMsg(sourcescip, "Copying plugins was%s valid.\n", localvalid ? "" : " not");
2459 
2460  uselocalvarmap = (varmap == NULL);
2461  uselocalconsmap = (consmap == NULL);
2462 
2463  if( uselocalvarmap )
2464  {
2465  /* create the variable mapping hash map */
2466  SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
2467  }
2468  else
2469  localvarmap = varmap;
2470 
2471  if( uselocalconsmap )
2472  {
2473  /* create the constraint mapping hash map */
2474  SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
2475  }
2476  else
2477  localconsmap = consmap;
2478 
2479  /* construct name for the target SCIP using the source problem name and the given suffix string */
2480  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_%s", SCIPgetProbName(sourcescip), suffix);
2481 
2482  /* store the quiet state of the message handler, if existent */
2483  msghdlrquiet = SCIPmessagehdlrIsQuiet(targetscip->messagehdlr);
2484 
2485  /* explicitly suppress output when copying parameters */
2486  SCIPsetMessagehdlrQuiet(targetscip, TRUE);
2487 
2488  /* copy all settings */
2489  SCIP_CALL( SCIPcopyParamSettings(sourcescip, targetscip) );
2490 
2491  /* restore original quiet state */
2492  SCIPsetMessagehdlrQuiet(targetscip, msghdlrquiet);
2493 
2494  /* create problem in the target SCIP copying the source original or transformed problem data */
2495  if( original )
2496  {
2497  SCIP_CALL( SCIPcopyOrigProb(sourcescip, targetscip, localvarmap, localconsmap, name) );
2498  }
2499  else
2500  {
2501  SCIP_CALL( SCIPcopyProb(sourcescip, targetscip, localvarmap, localconsmap, global, name) );
2502  }
2503 
2504  /* copy original or transformed variables and perform fixings if needed */
2505  SCIP_CALL( copyVars(sourcescip, targetscip, localvarmap, localconsmap, fixedvars, fixedvals, nfixedvars, original, global) );
2506 
2507  /* if fixed variables are directly specified or inferred from local bounds, enable constraint compression */
2508  if( useconscompression && (nfixedvars > 0 || !global) )
2509  {
2510  SCIP_CALL( SCIPenableConsCompression(targetscip) );
2511 
2512  /* domain reductions yield a copy that is no longer guaranteed to be valid */
2513  localvalid = FALSE;
2514  }
2515 
2516  /* copy all (original) constraints */
2517  if( original )
2518  {
2519  SCIP_CALL( SCIPcopyOrigConss(sourcescip, targetscip, localvarmap, localconsmap, enablepricing, &consscopyvalid) );
2520  }
2521  else
2522  {
2523  SCIP_CALL( SCIPcopyConss(sourcescip, targetscip, localvarmap, localconsmap, global, enablepricing, &consscopyvalid) );
2524  }
2525 
2526  SCIPdebugMsg(sourcescip, "Copying constraints was%s valid.\n", consscopyvalid ? "" : " not");
2527 
2528  localvalid = localvalid && consscopyvalid;
2529 
2530  /* copy the Benders' decomposition plugins explicitly, because it requires the variable mapping hash map */
2531  SCIP_CALL( SCIPcopyBenders(sourcescip, targetscip, localvarmap, &benderscopyvalid) );
2532 
2533  SCIPdebugMsg(sourcescip, "Copying Benders' decomposition plugins was%s valid.\n", benderscopyvalid ? "" : " not");
2534 
2535  localvalid = localvalid && benderscopyvalid;
2536 
2537  if( uselocalvarmap )
2538  {
2539  /* free hash map */
2540  SCIPhashmapFree(&localvarmap);
2541  }
2542 
2543  if( uselocalconsmap )
2544  {
2545  /* free hash map */
2546  SCIPhashmapFree(&localconsmap);
2547  }
2548 
2549  /* stop time measuring */
2550  SCIPclockStop(sourcescip->stat->copyclock, sourcescip->set);
2551 
2552  /* get time after copying procedure */
2553  copytime = SCIPclockGetTime(sourcescip->stat->copyclock) - startcopytime;
2554 
2555  if( copytime > sourcescip->stat->maxcopytime )
2556  sourcescip->stat->maxcopytime = copytime;
2557  if( copytime < sourcescip->stat->mincopytime )
2558  sourcescip->stat->mincopytime = copytime;
2559 
2560  /* increase copy counter */
2561  ++(sourcescip->stat->ncopies);
2562 
2563  targetscip->concurrent = sourcescip->concurrent;
2564  SCIP_CALL( SCIPsyncstoreRelease(&targetscip->syncstore) );
2565  targetscip->syncstore = sourcescip->syncstore;
2566  SCIP_CALL( SCIPsyncstoreCapture(targetscip->syncstore) );
2567 
2568  /* return the information about a valid copy to the user */
2569  if( valid != NULL )
2570  *valid = localvalid;
2571 
2572  return SCIP_OKAY;
2573 }
2574 
2575 /** copies source SCIP to target SCIP; the copying process is done in the following order:
2576  * 1) copy the plugins
2577  * 2) copy the settings
2578  * 3) create problem data in target-SCIP and copy the problem data of the source-SCIP
2579  * 4) copy all active variables
2580  * 5) copy all constraints
2581  *
2582  * The source problem depends on the stage of the \p sourcescip - In SCIP_STAGE_PROBLEM, the original problem is copied,
2583  * otherwise, the transformed problem is copied. For an explicit copy of the original problem, use SCIPcopyOrig().
2584  *
2585  * @note all variables and constraints which are created in the target-SCIP are not (user) captured
2586  *
2587  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
2588  * Also, 'passmessagehdlr' should be set to FALSE.
2589  * @note Do not change the source SCIP environment during the copying process
2590  *
2591  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2592  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2593  *
2594  * @pre This method can be called if sourcescip is in one of the following stages:
2595  * - \ref SCIP_STAGE_PROBLEM
2596  * - \ref SCIP_STAGE_TRANSFORMED
2597  * - \ref SCIP_STAGE_INITPRESOLVE
2598  * - \ref SCIP_STAGE_PRESOLVING
2599  * - \ref SCIP_STAGE_EXITPRESOLVE
2600  * - \ref SCIP_STAGE_PRESOLVED
2601  * - \ref SCIP_STAGE_INITSOLVE
2602  * - \ref SCIP_STAGE_SOLVING
2603  * - \ref SCIP_STAGE_SOLVED
2604  *
2605  * @pre This method can be called if targetscip is in one of the following stages:
2606  * - \ref SCIP_STAGE_INIT
2607  * - \ref SCIP_STAGE_FREE
2608  *
2609  * @note sourcescip stage does not get changed
2610  *
2611  * @note targetscip stage does not get changed
2612  *
2613  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2614  */
2616  SCIP* sourcescip, /**< source SCIP data structure */
2617  SCIP* targetscip, /**< target SCIP data structure */
2618  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
2619  * target variables, or NULL */
2620  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
2621  * target constraints, or NULL */
2622  const char* suffix, /**< optional suffix for problem name inside the target SCIP */
2623  SCIP_Bool global, /**< create a global or a local copy? */
2624  SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
2625  * plugins will be copied and activated, and the modifiable flag of
2626  * constraints will be respected. If FALSE, valid will be set to FALSE, when
2627  * there are pricers present */
2628  SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
2629  SCIP_Bool* valid /**< pointer to store whether the copying was valid, or NULL */
2630  )
2631 {
2632  SCIP_VAR** fixedvars = NULL;
2633  SCIP_Real* fixedvals = NULL;
2634  int nfixedvars = 0;
2635  SCIP_Bool original = FALSE;
2636  SCIP_Bool useconscompression = FALSE;
2637 
2638  assert(sourcescip != NULL);
2639  assert(targetscip != NULL);
2640  assert(suffix != NULL);
2641 
2642  /* check stages for both, the source and the target SCIP data structure */
2643  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopy", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
2644  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopy", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
2645 
2646  /* copy source SCIP data into target SCIP data structure */
2647  SCIP_CALL( doCopy(sourcescip, targetscip, varmap, consmap, suffix, fixedvars, fixedvals, nfixedvars,
2648  useconscompression, global, original, enablepricing, passmessagehdlr, valid) );
2649 
2650  return SCIP_OKAY;
2651 }
2652 
2653 /** copies source SCIP to target SCIP but compresses constraints
2654  *
2655  * constraint compression is performed by removing fixed variables immediately
2656  * during constraint creation if the involved constraint handlers support
2657  * compression
2658  *
2659  * the copying process is done in the following order:
2660  * 1) copy the plugins
2661  * 2) copy the settings
2662  * 3) create problem data in target-SCIP and copy the problem data of the source-SCIP
2663  * 4) copy all active variables
2664  * a) fix all variable copies specified by \p fixedvars, \p fixedvals, and \p nfixedvars
2665  * b) enable constraint compression
2666  * 5) copy all constraints
2667  *
2668  * The source problem depends on the stage of the \p sourcescip - In SCIP_STAGE_PROBLEM, the original problem is copied,
2669  * otherwise, the transformed problem is copied. For an explicit copy of the original problem, use SCIPcopyOrigConsCompression().
2670  *
2671  * @note: in case that a combination of local bounds and explicit fixing values should be used,
2672  * the fixing value of a variable is preferred if local bounds and fixing value disagree.
2673  *
2674  * @note all variables and constraints which are created in the target-SCIP are not (user) captured
2675  *
2676  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
2677  * Also, 'passmessagehdlr' should be set to FALSE.
2678  * @note Do not change the source SCIP environment during the copying process
2679  *
2680  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2681  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2682  *
2683  * @pre This method can be called if sourcescip is in one of the following stages:
2684  * - \ref SCIP_STAGE_PROBLEM
2685  * - \ref SCIP_STAGE_TRANSFORMED
2686  * - \ref SCIP_STAGE_INITPRESOLVE
2687  * - \ref SCIP_STAGE_PRESOLVING
2688  * - \ref SCIP_STAGE_EXITPRESOLVE
2689  * - \ref SCIP_STAGE_PRESOLVED
2690  * - \ref SCIP_STAGE_INITSOLVE
2691  * - \ref SCIP_STAGE_SOLVING
2692  * - \ref SCIP_STAGE_SOLVED
2693  *
2694  * @pre This method can be called if targetscip is in one of the following stages:
2695  * - \ref SCIP_STAGE_INIT
2696  * - \ref SCIP_STAGE_FREE
2697  *
2698  * @note sourcescip stage does not get changed
2699  *
2700  * @note targetscip stage does not get changed
2701  *
2702  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2703  */
2705  SCIP* sourcescip, /**< source SCIP data structure */
2706  SCIP* targetscip, /**< target SCIP data structure */
2707  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
2708  * target variables, or NULL */
2709  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
2710  * target constraints, or NULL */
2711  const char* suffix, /**< optional suffix for problem name inside the target SCIP */
2712  SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
2713  SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
2714  int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
2715  SCIP_Bool global, /**< create a global or a local copy? */
2716  SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
2717  * plugins will be copied and activated, and the modifiable flag of
2718  * constraints will be respected. If FALSE, valid will be set to FALSE, when
2719  * there are pricers present */
2720  SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
2721  SCIP_Bool* valid /**< pointer to store whether the copying was valid, or NULL */
2722  )
2723 {
2724  SCIP_Bool original = FALSE;
2725  SCIP_Bool useconscompression = TRUE;
2726 
2727  assert(sourcescip != NULL);
2728  assert(targetscip != NULL);
2729  assert(suffix != NULL);
2730 
2731  /* check stages for both, the source and the target SCIP data structure */
2732  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyConsCompression", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
2733  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyConsCompression", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
2734 
2735  /* copy the source problem data */
2736  SCIP_CALL( doCopy(sourcescip, targetscip, varmap, consmap, suffix, fixedvars, fixedvals, nfixedvars,
2737  useconscompression, global, original, enablepricing, passmessagehdlr, valid) );
2738 
2739  return SCIP_OKAY;
2740 }
2741 
2742 
2743 /** copies source SCIP original problem to target SCIP; the copying process is done in the following order:
2744  * 1) copy the plugins
2745  * 2) copy the settings
2746  * 3) create problem data in target-SCIP and copy the original problem data of the source-SCIP
2747  * 4) copy all original variables
2748  * 5) copy all original constraints
2749  *
2750  * @note all variables and constraints which are created in the target-SCIP are not (user) captured
2751  *
2752  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
2753  * Also, 'passmessagehdlr' should be set to FALSE.
2754  * @note Do not change the source SCIP environment during the copying process
2755  *
2756  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2757  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2758  *
2759  * @pre This method can be called if sourcescip is in one of the following stages:
2760  * - \ref SCIP_STAGE_PROBLEM
2761  * - \ref SCIP_STAGE_TRANSFORMED
2762  * - \ref SCIP_STAGE_INITPRESOLVE
2763  * - \ref SCIP_STAGE_PRESOLVING
2764  * - \ref SCIP_STAGE_EXITPRESOLVE
2765  * - \ref SCIP_STAGE_PRESOLVED
2766  * - \ref SCIP_STAGE_INITSOLVE
2767  * - \ref SCIP_STAGE_SOLVING
2768  * - \ref SCIP_STAGE_SOLVED
2769  *
2770  * @pre This method can be called if targetscip is in one of the following stages:
2771  * - \ref SCIP_STAGE_INIT
2772  * - \ref SCIP_STAGE_FREE
2773  *
2774  * @note sourcescip stage does not get changed
2775  *
2776  * @note targetscip stage does not get changed
2777  *
2778  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2779  */
2781  SCIP* sourcescip, /**< source SCIP data structure */
2782  SCIP* targetscip, /**< target SCIP data structure */
2783  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
2784  * target variables, or NULL */
2785  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
2786  * target constraints, or NULL */
2787  const char* suffix, /**< suffix which will be added to the names of the target SCIP, might be empty */
2788  SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
2789  * plugins will be copied and activated, and the modifiable flag of
2790  * constraints will be respected. If FALSE, valid will be set to FALSE, when
2791  * there are pricers present */
2792  SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
2793  SCIP_Bool* valid /**< pointer to store whether the copying was valid, or NULL */
2794  )
2795 {
2796  SCIP_VAR** fixedvars = NULL;
2797  SCIP_Real* fixedvals = NULL;
2798  int nfixedvars = 0;
2799  SCIP_Bool global = TRUE;
2800  SCIP_Bool original = TRUE;
2801  SCIP_Bool useconscompression = FALSE;
2802 
2803  assert(sourcescip != NULL);
2804  assert(targetscip != NULL);
2805  assert(suffix != NULL);
2806 
2807  /* check stages for both, the source and the target SCIP data structure */
2808  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrig", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
2809  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrig", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
2810 
2811  SCIP_CALL( doCopy(sourcescip, targetscip, varmap, consmap, suffix, fixedvars, fixedvals, nfixedvars,
2812  useconscompression, global, original, enablepricing, passmessagehdlr, valid) );
2813 
2814  return SCIP_OKAY;
2815 }
2816 
2817 /** copies source SCIP original problem to target SCIP but compresses constraints
2818  *
2819  * constraint compression is performed by removing fixed variables immediately
2820  * during constraint creation if the involved constraint handlers support
2821  * compression
2822  *
2823  * the copying process is done in the following order:
2824  * 1) copy the plugins
2825  * 2) copy the settings
2826  * 3) create problem data in target-SCIP and copy the problem data of the source-SCIP
2827  * 4) copy all original variables
2828  * a) fix all variable copies specified by \p fixedvars, \p fixedvals, and \p nfixedvars
2829  * b) enable constraint compression
2830  * 5) copy all constraints
2831  *
2832  * @note all variables and constraints which are created in the target-SCIP are not (user) captured
2833  *
2834  * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
2835  * Also, 'passmessagehdlr' should be set to FALSE.
2836  * @note Do not change the source SCIP environment during the copying process
2837  *
2838  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2839  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2840  *
2841  * @pre This method can be called if sourcescip is in one of the following stages:
2842  * - \ref SCIP_STAGE_PROBLEM
2843  * - \ref SCIP_STAGE_TRANSFORMED
2844  * - \ref SCIP_STAGE_INITPRESOLVE
2845  * - \ref SCIP_STAGE_PRESOLVING
2846  * - \ref SCIP_STAGE_EXITPRESOLVE
2847  * - \ref SCIP_STAGE_PRESOLVED
2848  * - \ref SCIP_STAGE_INITSOLVE
2849  * - \ref SCIP_STAGE_SOLVING
2850  * - \ref SCIP_STAGE_SOLVED
2851  *
2852  * @pre This method can be called if targetscip is in one of the following stages:
2853  * - \ref SCIP_STAGE_INIT
2854  * - \ref SCIP_STAGE_FREE
2855  *
2856  * @note sourcescip stage does not get changed
2857  *
2858  * @note targetscip stage does not get changed
2859  *
2860  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2861  */
2863  SCIP* sourcescip, /**< source SCIP data structure */
2864  SCIP* targetscip, /**< target SCIP data structure */
2865  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
2866  * target variables, or NULL */
2867  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
2868  * target constraints, or NULL */
2869  const char* suffix, /**< optional suffix for problem name inside the target SCIP */
2870  SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
2871  SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
2872  int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
2873  SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
2874  * plugins will be copied and activated, and the modifiable flag of
2875  * constraints will be respected. If FALSE, valid will be set to FALSE, when
2876  * there are pricers present */
2877  SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
2878  SCIP_Bool* valid /**< pointer to store whether the copying was valid, or NULL */
2879  )
2880 {
2881  SCIP_Bool original = TRUE;
2882  SCIP_Bool global = TRUE;
2883  SCIP_Bool useconscompression = TRUE;
2884 
2885  assert(sourcescip != NULL);
2886  assert(targetscip != NULL);
2887  assert(suffix != NULL);
2888 
2889  /* check stages for both, the source and the target SCIP data structure */
2890  SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrigConsCompression", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
2891  SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrigConsCompression", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
2892 
2893  /* copy the source problem data */
2894  SCIP_CALL( doCopy(sourcescip, targetscip, varmap, consmap, suffix, fixedvars, fixedvals, nfixedvars,
2895  useconscompression, global, original, enablepricing, passmessagehdlr, valid) );
2896 
2897  SCIP_CALL( SCIPsyncstoreRelease(&targetscip->syncstore) );
2898  targetscip->syncstore = sourcescip->syncstore;
2899  SCIP_CALL( SCIPsyncstoreCapture(targetscip->syncstore) );
2900 
2901  return SCIP_OKAY;
2902 }
2903 
2904 /** return updated time limit for a sub-SCIP */
2905 static
2907  SCIP* sourcescip, /**< source SCIP data structure */
2908  SCIP_Real* timelimit /**< pointer to store sub-SCIP time limit */
2909  )
2910 {
2911  SCIP_CALL( SCIPgetRealParam(sourcescip, "limits/time", timelimit) );
2912  if( !SCIPisInfinity(sourcescip, *timelimit) )
2913  (*timelimit) -= SCIPgetSolvingTime(sourcescip);
2914 
2915  return SCIP_OKAY;
2916 }
2917 
2918 /** set updated time limit for a sub-SCIP */
2919 static
2921  SCIP* sourcescip, /**< source SCIP data structure */
2922  SCIP* targetscip /**< target SCIP data structure */
2923  )
2924 {
2925  if( SCIPgetParam(targetscip, "limits/softtime") == NULL )
2926  return SCIP_OKAY;
2927  else
2928  {
2929  SCIP_Real timelimit = -1.0;
2930 
2931  SCIP_CALL( SCIPgetRealParam(sourcescip, "limits/softtime", &timelimit) );
2932  if( !SCIPisNegative(sourcescip, timelimit) )
2933  {
2934  timelimit -= SCIPgetSolvingTime(sourcescip);
2935  timelimit = MAX(0.0, timelimit);
2936  }
2937 
2938  SCIP_CALL( SCIPsetRealParam(targetscip, "limits/softtime", timelimit) );
2939  }
2940  return SCIP_OKAY;
2941 }
2942 
2943 /** return updated memory limit for a sub-SCIP */
2944 static
2946  SCIP* sourcescip, /**< source SCIP data structure */
2947  SCIP_Real* memorylimit /**< pointer to store sub-SCIP memory limit */
2948  )
2949 {
2950  SCIP_CALL( SCIPgetRealParam(sourcescip, "limits/memory", memorylimit) );
2951 
2952  /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
2953  if( !SCIPisInfinity(sourcescip, *memorylimit) )
2954  (*memorylimit) -= (SCIPgetMemUsed(sourcescip) + SCIPgetMemExternEstim(sourcescip))/1048576.0;
2955 
2956  return SCIP_OKAY;
2957 }
2958 
2959 /** checks if there is enough time and memory left for copying the sourcescip into a sub-SCIP and solve the sub-SCIP
2960  *
2961  * This is the case if the time and memory limit that would be passed to the sub-SCIP are larger than 0.0
2962  *
2963  * @pre This method can be called if sourcescip is in one of the following stages:
2964  * - \ref SCIP_STAGE_PROBLEM
2965  * - \ref SCIP_STAGE_TRANSFORMED
2966  * - \ref SCIP_STAGE_INITPRESOLVE
2967  * - \ref SCIP_STAGE_PRESOLVING
2968  * - \ref SCIP_STAGE_EXITPRESOLVE
2969  * - \ref SCIP_STAGE_PRESOLVED
2970  * - \ref SCIP_STAGE_INITSOLVE
2971  * - \ref SCIP_STAGE_SOLVING
2972  * - \ref SCIP_STAGE_SOLVED
2973  *
2974  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2975  */
2977  SCIP* sourcescip, /**< source SCIP data structure */
2978  SCIP_Bool* success /**< pointer to store whether there is time and memory left to copy the
2979  * problem and run the sub-SCIP */
2980  )
2981 {
2982  SCIP_Real timelimit;
2983  SCIP_Real memorylimit;
2984 
2985  SCIP_CALL( getCopyTimelimit(sourcescip, &timelimit) );
2986  SCIP_CALL( getCopyMemlimit(sourcescip, &memorylimit) );
2987 
2988  *success = timelimit > 0.0 && memorylimit > 2.0 * SCIPgetMemExternEstim(sourcescip) / 1048576.0;
2989 
2990  return SCIP_OKAY;
2991 }
2992 
2993 /** copies limits from source SCIP to target SCIP
2994  *
2995  * @note time and memory limit are reduced by the amount already spent in the source SCIP before installing the limit
2996  * in the target SCIP
2997  * @note all other limits are disabled and need to be enabled afterwards, if needed
2998  *
2999  * @pre This method can be called if sourcescip is in one of the following stages:
3000  * - \ref SCIP_STAGE_PROBLEM
3001  * - \ref SCIP_STAGE_TRANSFORMED
3002  * - \ref SCIP_STAGE_INITPRESOLVE
3003  * - \ref SCIP_STAGE_PRESOLVING
3004  * - \ref SCIP_STAGE_EXITPRESOLVE
3005  * - \ref SCIP_STAGE_PRESOLVED
3006  * - \ref SCIP_STAGE_INITSOLVE
3007  * - \ref SCIP_STAGE_SOLVING
3008  * - \ref SCIP_STAGE_SOLVED
3009  *
3010  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
3011  */
3013  SCIP* sourcescip, /**< source SCIP data structure */
3014  SCIP* targetscip /**< target SCIP data structure */
3015  )
3016 {
3017  SCIP_Real timelimit;
3018  SCIP_Real memorylimit;
3019 
3020  SCIP_CALL( getCopyTimelimit(sourcescip, &timelimit) );
3021  SCIP_CALL( getCopyMemlimit(sourcescip, &memorylimit) );
3022 
3023  /* avoid negative limits */
3024  if( timelimit < 0.0 )
3025  timelimit = 0.0;
3026  if( memorylimit < 0.0 )
3027  memorylimit = 0.0;
3028 
3029  /* set time and memory limit to the adjusted values */
3030  SCIP_CALL( SCIPsetRealParam(targetscip, "limits/time", timelimit) );
3031  SCIP_CALL( SCIPsetRealParam(targetscip, "limits/memory", memorylimit) );
3032 
3033  /* copy and adjust soft time limit (or disable it) */
3034  SCIP_CALL( copySofttimelimit(sourcescip, targetscip) );
3035 
3036  /* disable all other limits */
3037  SCIP_CALL( SCIPsetRealParam(targetscip, "limits/absgap", 0.0) );
3038  SCIP_CALL( SCIPsetIntParam(targetscip, "limits/bestsol", -1) );
3039  SCIP_CALL( SCIPsetRealParam(targetscip, "limits/gap", 0.0) );
3040  SCIP_CALL( SCIPsetLongintParam(targetscip, "limits/nodes", -1LL) );
3041  SCIP_CALL( SCIPsetIntParam(targetscip, "limits/restarts", -1) );
3042  SCIP_CALL( SCIPsetIntParam(targetscip, "limits/solutions", -1) );
3043  SCIP_CALL( SCIPsetLongintParam(targetscip, "limits/stallnodes", -1LL) );
3044  SCIP_CALL( SCIPsetLongintParam(targetscip, "limits/totalnodes", -1LL) );
3045 
3046  return SCIP_OKAY;
3047 }
internal methods for separators
SCIP_STAT * stat
Definition: struct_scip.h:69
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:50
int SCIPgetNIntVars(SCIP *scip)
Definition: scip_prob.c:2134
SCIP_RETCODE SCIPflattenVarAggregationGraph(SCIP *scip, SCIP_VAR *var)
Definition: scip_var.c:1696
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
Definition: scip_timing.c:436
SCIP_Bool SCIPmessagehdlrIsQuiet(SCIP_MESSAGEHDLR *messagehdlr)
Definition: message.c:900
#define NULL
Definition: def.h:239
internal methods for managing events
default message handler
SCIP_VAR ** SCIPcliqueGetVars(SCIP_CLIQUE *clique)
Definition: implics.c:3343
trivialnegation primal heuristic
int SCIPgetNDelayedPoolCuts(SCIP *scip)
Definition: scip_cut.c:738
internal methods for storing primal CIP solutions
SCIP_RETCODE SCIPsyncstoreRelease(SCIP_SYNCSTORE **syncstore)
Definition: syncstore.c:77
SCIP_RETCODE SCIPcopyOrig(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip_copy.c:2780
public methods for SCIP parameter handling
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:412
methods to interpret (evaluate) an expression tree "fast"
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
Definition: cons.c:8335
SCIP_Real * SCIPvarGetMultaggrScalars(SCIP_VAR *var)
Definition: var.c:17135
internal methods for branch and bound tree
SCIP_RETCODE SCIPcopyOrigProb(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *name)
Definition: scip_copy.c:610
SCIP_Bool SCIPprobIsConsCompressionEnabled(SCIP_PROB *prob)
Definition: prob.c:2391
public methods for memory management
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip_cons.c:954
public methods for implications, variable bounds, and cliques
methods for implications, variable bounds, and cliques
SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
Definition: scip_param.c:379
int SCIPconflictstoreGetNConflictsInStore(SCIP_CONFLICTSTORE *conflictstore)
#define SCIP_MAXSTRLEN
Definition: def.h:260
SCIP_RETCODE SCIPsetMessagehdlr(SCIP *scip, SCIP_MESSAGEHDLR *messagehdlr)
Definition: scip_message.c:136
SCIP_PRIMAL * origprimal
Definition: struct_scip.h:71
internal methods for clocks and timing issues
SCIP_VAR ** SCIPvarGetMultaggrVars(SCIP_VAR *var)
Definition: var.c:17123
int SCIProwGetNNonz(SCIP_ROW *row)
Definition: lp.c:16790
SCIP_CUT ** SCIPgetDelayedPoolCuts(SCIP *scip)
Definition: scip_cut.c:722
internal methods for NLPI solver interfaces
public solving methods
public methods for timing
const char * SCIProwGetName(SCIP_ROW *row)
Definition: lp.c:16928
SCIP_RETCODE SCIPcopyPlugins(SCIP *sourcescip, SCIP *targetscip, SCIP_Bool copyreaders, SCIP_Bool copypricers, SCIP_Bool copyconshdlrs, SCIP_Bool copyconflicthdlrs, SCIP_Bool copypresolvers, SCIP_Bool copyrelaxators, SCIP_Bool copyseparators, SCIP_Bool copypropagators, SCIP_Bool copyheuristics, SCIP_Bool copyeventhdlrs, SCIP_Bool copynodeselectors, SCIP_Bool copybranchrules, SCIP_Bool copydisplays, SCIP_Bool copydialogs, SCIP_Bool copytables, SCIP_Bool copynlpis, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip_copy.c:316
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip_var.c:1251
interface methods for specific LP solvers
internal methods for displaying statistics tables
SCIP_CONCURRENT * concurrent
Definition: struct_scip.h:99
SCIP_Bool history_allowmerge
Definition: struct_set.h:271
SCIP_RETCODE SCIPconvertCutsToConss(SCIP *scip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
Definition: scip_copy.c:1819
static SCIP_RETCODE copyVars(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool original, SCIP_Bool global)
Definition: scip_copy.c:963
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:1918
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:350
SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4563
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:16869
#define FALSE
Definition: def.h:65
SCIP_RETCODE SCIPbendersCopyInclude(SCIP_BENDERS *benders, SCIP_SET *sourceset, SCIP_SET *targetset, SCIP_HASHMAP *varmap, SCIP_Bool *valid)
Definition: benders.c:777
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:2793
void SCIPsetSubscipDepth(SCIP *scip, int newdepth)
Definition: scip_copy.c:2375
methods for the aggregation rows
char sepa_cutselrestart
Definition: struct_set.h:509
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
Definition: scip_copy.c:3012
int SCIPgetSubscipDepth(SCIP *scip)
Definition: scip_copy.c:2354
internal methods for Benders&#39; decomposition
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:280
int SCIPgetNActivePricers(SCIP *scip)
Definition: scip_pricer.c:418
SCIP_RETCODE SCIPcopyConsCompression(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip_copy.c:2704
SCIP_Real SCIPinfinity(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10017
SCIP_STAGE stage
Definition: struct_set.h:63
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
#define TRUE
Definition: def.h:64
SCIP_Real SCIPcutGetLPActivityQuot(SCIP_CUT *cut)
Definition: cutpool.c:396
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_Bool SCIPcliqueIsEquation(SCIP_CLIQUE *clique)
Definition: implics.c:3399
methods commonly used by primal heuristics
enum SCIP_Varstatus SCIP_VARSTATUS
Definition: type_var.h:48
internal methods for branching rules and branching candidate storage
datastructures for concurrent solvers
SCIP_Real SCIPvarGetAggrScalar(SCIP_VAR *var)
Definition: var.c:17089
public methods for problem variables
static SCIP_RETCODE getCopyTimelimit(SCIP *sourcescip, SCIP_Real *timelimit)
Definition: scip_copy.c:2906
SCIP_RETCODE SCIPgetOrigVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:2409
SCIP_MESSAGEHDLR * SCIPgetMessagehdlr(SCIP *scip)
Definition: scip_message.c:171
internal methods for handling parameter settings
SCIP_PROB * transprob
Definition: struct_scip.h:87
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:2931
methods for creating output for visualization tools (VBC, BAK)
SCIP_CLOCK * copyclock
Definition: struct_stat.h:162
nodereopt branching rule
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:142
SCIP_RETCODE SCIPcopyBenders(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_Bool *valid)
Definition: scip_copy.c:393
#define SCIPdebugPrintCons(x, y, z)
Definition: pub_message.h:83
SCIP_Bool SCIPisTransformed(SCIP *scip)
Definition: scip_general.c:611
public methods for SCIP variables
SCIP_VAR * SCIPvarGetNegationVar(SCIP_VAR *var)
Definition: var.c:17169
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
Definition: scip_param.c:694
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
Definition: cons.c:8345
#define SCIPdebugMsg
Definition: scip_message.h:88
SCIP_RETCODE SCIPcopyParamSettings(SCIP *sourcescip, SCIP *targetscip)
Definition: scip_copy.c:2313
SCIP_CUT ** SCIPgetPoolCuts(SCIP *scip)
Definition: scip_cut.c:446
internal methods for LP management
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
Definition: cons.c:8137
SCIP_PROB * origprob
Definition: struct_scip.h:70
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
int SCIPgetNContVars(SCIP *scip)
Definition: scip_prob.c:2224
internal methods for branching and inference history
public methods for numerical tolerances
internal methods for collecting primal CIP solutions and primal informations
SCIP_RETCODE SCIPconflictstoreCreate(SCIP_CONFLICTSTORE **conflictstore, SCIP_SET *set)
SCIP_Bool SCIPconsIsOriginal(SCIP_CONS *cons)
Definition: cons.c:8375
int SCIPgetNConshdlrs(SCIP *scip)
Definition: scip_cons.c:978
public methods for querying solving statistics
internal methods for propagators
const char * SCIPgetProbName(SCIP *scip)
Definition: scip_prob.c:1123
SCIP_Bool SCIProwIsInLP(SCIP_ROW *row)
Definition: lp.c:17080
SCIP_RETCODE SCIPcopyOrigConss(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool enablepricing, SCIP_Bool *valid)
Definition: scip_copy.c:1686
int SCIPgetNFixedVars(SCIP *scip)
Definition: scip_prob.c:2361
SCIP_VAR ** SCIPgetFixedVars(SCIP *scip)
Definition: scip_prob.c:2318
SCIP_RETCODE SCIPaddClique(SCIP *scip, SCIP_VAR **vars, SCIP_Bool *values, int nvars, SCIP_Bool isequation, SCIP_Bool *infeasible, int *nbdchgs)
Definition: scip_var.c:6819
SCIP_RETCODE SCIPenableConsCompression(SCIP *scip)
Definition: scip_copy.c:648
static SCIP_RETCODE getCopyMemlimit(SCIP *sourcescip, SCIP_Real *memorylimit)
Definition: scip_copy.c:2945
SCIP_MEM * mem
Definition: struct_scip.h:61
SCIP_RETCODE SCIPsetCopyPlugins(SCIP_SET *sourceset, SCIP_SET *targetset, SCIP_Bool copyreaders, SCIP_Bool copypricers, SCIP_Bool copyconshdlrs, SCIP_Bool copyconflicthdlrs, SCIP_Bool copypresolvers, SCIP_Bool copyrelaxators, SCIP_Bool copyseparators, SCIP_Bool copypropagators, SCIP_Bool copyheuristics, SCIP_Bool copyeventhdlrs, SCIP_Bool copynodeselectors, SCIP_Bool copybranchrules, SCIP_Bool copydisplays, SCIP_Bool copydialogs, SCIP_Bool copytables, SCIP_Bool copynlpis, SCIP_Bool *allvalid)
Definition: set.c:890
public methods for managing constraints
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
Definition: scip_prob.c:1298
SCIP_RETCODE SCIPcopyOrigConsCompression(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip_copy.c:2862
git hash methods
SCIP_Real mincopytime
Definition: struct_stat.h:129
void SCIPvarMergeHistories(SCIP_VAR *targetvar, SCIP_VAR *othervar, SCIP_STAT *stat)
Definition: var.c:4349
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:45
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4191
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2822
SCIP_CONSHDLR ** SCIPgetConshdlrs(SCIP *scip)
Definition: scip_cons.c:967
methods for block memory pools and memory buffers
SCIP_SYNCSTORE * syncstore
Definition: struct_scip.h:98
SCIP_RETCODE SCIPfreeProb(SCIP *scip)
Definition: scip_prob.c:745
void SCIPprobEnableConsCompression(SCIP_PROB *prob)
Definition: prob.c:2401
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
Definition: lp.c:16978
SCIP_RETCODE SCIPcopyVars(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool global)
Definition: scip_copy.c:1158
SCIP_RETCODE SCIPaddVarImplication(SCIP *scip, SCIP_VAR *var, SCIP_Bool varfixing, SCIP_VAR *implvar, SCIP_BOUNDTYPE impltype, SCIP_Real implbound, SCIP_Bool *infeasible, int *nbdchgs)
Definition: scip_var.c:6691
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
char sepa_cutselsubscip
Definition: struct_set.h:510
SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
Definition: scip_copy.c:1879
int nbenders
Definition: struct_set.h:136
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip_mem.c:128
internal methods for presolvers
SCIP_CONFLICTSTORE * conflictstore
Definition: struct_scip.h:93
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8076
SCIP_Real SCIPvarGetAggrConstant(SCIP_VAR *var)
Definition: var.c:17100
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
Definition: cons.c:8295
SCIP_CONS ** SCIPgetOrigConss(SCIP *scip)
Definition: scip_prob.c:3213
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16729
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
Definition: clock.c:428
SCIP_REOPT * reopt
Definition: struct_scip.h:74
internal methods for NLP management
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:2826
SCIP_RETCODE SCIPmergeVariableStatistics(SCIP *sourcescip, SCIP *targetscip, SCIP_VAR **sourcevars, SCIP_VAR **targetvars, int nvars)
Definition: scip_copy.c:1245
internal miscellaneous methods
static SCIP_RETCODE copyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_CUT **cuts, int ncuts, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
Definition: scip_copy.c:178
SCIP_PARAM * SCIPgetParam(SCIP *scip, const char *name)
Definition: scip_param.c:306
internal methods for node selectors and node priority queues
internal methods for variable pricers
public methods for problem copies
SCIP_ROW * SCIPcutGetRow(SCIP_CUT *cut)
Definition: cutpool.c:372
SCIP_RETCODE SCIPcopyOrigVars(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars)
Definition: scip_copy.c:1215
internal methods for global SCIP settings
internal methods for storing conflicts
#define SCIP_CALL(x)
Definition: def.h:351
SCIP main data structure.
int SCIPgetNOrigConss(SCIP *scip)
Definition: scip_prob.c:3186
SCIP_Real SCIPvarGetMultaggrConstant(SCIP_VAR *var)
Definition: var.c:17147
static SCIP_RETCODE copyProb(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool original, SCIP_Bool global, const char *name)
Definition: scip_copy.c:434
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:16879
internal methods for storing priced variables
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
Definition: cons.c:8315
internal methods for relaxators
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5975
SCIP_RETCODE SCIPcaptureCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_cons.c:1152
SCIP_RETCODE SCIPcopyImplicationsCliques(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool *infeasible, int *nbdchgs, int *ncopied)
Definition: scip_copy.c:2129
internal methods for storing separated cuts
SCIP_Bool SCIProwIsModifiable(SCIP_ROW *row)
Definition: lp.c:16988
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
Definition: lp.c:16815
public methods for constraint handler plugins and constraints
SCIP_RETCODE SCIPcopyConflicts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool *valid)
Definition: scip_copy.c:1971
methods commonly used for presolving
SCIP_RETCODE SCIPgetConsCopy(SCIP *sourcescip, SCIP *targetscip, SCIP_CONS *sourcecons, SCIP_CONS **targetcons, SCIP_CONSHDLR *sourceconshdlr, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *name, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode, SCIP_Bool global, SCIP_Bool *valid)
Definition: scip_copy.c:1350
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
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:130
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
Definition: lp.c:16825
public data structures and miscellaneous methods
SCIP_BOUNDTYPE * SCIPvarGetImplTypes(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17653
internal methods for user interface dialog
#define SCIP_Bool
Definition: def.h:62
int SCIPgetNImplVars(SCIP *scip)
Definition: scip_prob.c:2179
SCIP_Real SCIPgetOrigObjscale(SCIP *scip)
Definition: scip_prob.c:1400
public methods for storing cuts in a cut pool
static SCIP_RETCODE copySofttimelimit(SCIP *sourcescip, SCIP *targetscip)
Definition: scip_copy.c:2920
void SCIPconsSetModifiable(SCIP_CONS *cons, SCIP_Bool modifiable)
Definition: cons.c:6653
SCIP_RETCODE SCIPstatCreate(SCIP_STAT **stat, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_MESSAGEHDLR *messagehdlr)
Definition: stat.c:45
internal methods for input file readers
int SCIPvarGetNImpls(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17621
SCIP_RETCODE SCIPcopyConss(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool *valid)
Definition: scip_copy.c:1486
SCIP_RETCODE SCIPsetCopyParams(SCIP_SET *sourceset, SCIP_SET *targetset, SCIP_MESSAGEHDLR *messagehdlr)
Definition: set.c:1099
void SCIPsetMessagehdlrQuiet(SCIP *scip, SCIP_Bool quiet)
Definition: scip_message.c:191
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:8096
methods for debugging
SCIP_Bool * SCIPcliqueGetValues(SCIP_CLIQUE *clique)
Definition: implics.c:3355
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip_param.c:578
public methods for LP management
SCIP_Bool SCIPconsIsDeleted(SCIP_CONS *cons)
Definition: cons.c:8205
SCIP_BENDERS ** benders
Definition: struct_set.h:92
public methods for cuts and aggregation rows
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:8275
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
Definition: cons.c:8245
SCIP_VAR * SCIPvarGetAggrVar(SCIP_VAR *var)
Definition: var.c:17078
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
Definition: scip_var.c:8168
int SCIPgetNRuns(SCIP *scip)
SCIP_Real maxcopytime
Definition: struct_stat.h:128
reoptsols primal heuristic
internal methods for storing cuts in a cut pool
Constraint handler for linear constraints in their most general form, .
SCIP_RETCODE SCIPvarCopy(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP *sourcescip, SCIP_VAR *sourcevar, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global)
Definition: var.c:2086
int SCIPvarGetMultaggrNVars(SCIP_VAR *var)
Definition: var.c:17111
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Real * SCIPvarGetImplBounds(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17667
SCIP * scip
Definition: struct_var.h:201
int SCIPgetNBinVars(SCIP *scip)
Definition: scip_prob.c:2089
int SCIPconshdlrGetNActiveConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4627
helper functions for concurrent scip solvers
public methods for variable pricer plugins
int SCIPgetNVars(SCIP *scip)
Definition: scip_prob.c:2044
internal methods for return codes for SCIP methods
SCIP_VAR ** SCIPvarGetImplVars(SCIP_VAR *var, SCIP_Bool varfixing)
Definition: var.c:17638
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_CLIQUE ** SCIPgetCliques(SCIP *scip)
Definition: scip_var.c:7527
SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
Definition: lp.c:16835
SCIP_RETCODE SCIPcopyProb(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, const char *name)
Definition: scip_copy.c:557
general public methods
#define MAX(x, y)
Definition: def.h:208
BMS_BLKMEM * probmem
Definition: struct_mem.h:40
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
Definition: lp.c:16639
internal methods for conflict analysis
SCIP_Longint SCIPgetMemUsed(SCIP *scip)
Definition: scip_mem.c:171
SCIP_RETCODE SCIPgetVarCopy(SCIP *sourcescip, SCIP *targetscip, SCIP_VAR *sourcevar, SCIP_VAR **targetvar, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool *success)
Definition: scip_copy.c:737
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition: scip_prob.c:1724
internal methods for tree compressions
internal methods for main solving loop and node processing
SCIP_CONS ** SCIPconshdlrGetCheckConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4583
int SCIPgetNConss(SCIP *scip)
Definition: scip_prob.c:3094
SCIP_Bool SCIPisConsCompressionEnabled(SCIP *scip)
Definition: scip_copy.c:687
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1187
SCIP_RETCODE SCIPprobCopy(SCIP_PROB **prob, BMS_BLKMEM *blkmem, SCIP_SET *set, const char *name, SCIP *sourcescip, SCIP_PROB *sourceprob, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global)
Definition: prob.c:191
SCIP_SET * set
Definition: struct_scip.h:62
SCIP_RETCODE SCIPcopy(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip_copy.c:2615
public methods for message output
int SCIPgetNCliques(SCIP *scip)
Definition: scip_var.c:7473
SCIP_Longint SCIPgetMemExternEstim(SCIP *scip)
Definition: scip_mem.c:197
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16848
SCIP_Real sepa_minactivityquot
Definition: struct_set.h:504
SCIP_MESSAGEHDLR * messagehdlr
Definition: struct_scip.h:65
default user interface dialog
#define SCIP_Real
Definition: def.h:150
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
Definition: cons.c:8325
internal methods for problem statistics
SCIP_RETCODE SCIPconflictstoreAddConflict(SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_PROB *transprob, SCIP_REOPT *reopt, SCIP_CONS *cons, SCIP_CONFTYPE conftype, SCIP_Bool cutoffinvolved, SCIP_Real primalbound)
int SCIPconshdlrGetNCheckConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4613
public methods for message handling
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
Definition: cons.c:8265
int SCIPgetNPoolCuts(SCIP *scip)
Definition: scip_cut.c:464
internal methods for constraints and constraint handlers
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
Definition: cons.c:8255
SCIP_RETCODE SCIPconsCopy(SCIP_CONS **cons, SCIP_SET *set, const char *name, SCIP *sourcescip, SCIP_CONSHDLR *sourceconshdlr, SCIP_CONS *sourcecons, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode, SCIP_Bool global, SCIP_Bool *valid)
Definition: cons.c:5946
SCIP_Real SCIPgetOrigObjoffset(SCIP *scip)
Definition: scip_prob.c:1375
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
Definition: scip_copy.c:2976
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16894
declarations for XML parsing
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
Definition: scip_prob.c:1281
build flags methods
static SCIP_Bool takeCut(SCIP *scip, SCIP_CUT *cut, char cutsel)
Definition: scip_copy.c:145
SCIP_RETCODE SCIPsyncstoreCapture(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:112
SCIP_Bool SCIPconsIsConflict(SCIP_CONS *cons)
Definition: cons.c:8225
int SCIPcliqueGetNVars(SCIP_CLIQUE *clique)
Definition: implics.c:3333
SCIP_RETCODE SCIPprimalCreate(SCIP_PRIMAL **primal)
Definition: primal.c:118
int SCIPcutGetAge(SCIP_CUT *cut)
Definition: cutpool.c:382
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
Definition: misc.c:2874
static SCIP_RETCODE doCopy(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool useconscompression, SCIP_Bool global, SCIP_Bool original, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip_copy.c:2399
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
SCIP_VAR * SCIPvarGetTransVar(SCIP_VAR *var)
Definition: var.c:17046
#define SCIPABORT()
Definition: def.h:323
public methods for global and local (sub)problems
SCIP_Bool SCIPisInRestart(SCIP *scip)
Definition: scip_solve.c:3571
internal methods for Benders&#39; decomposition cuts
int subscipdepth
Definition: struct_stat.h:200
SCIP_RETCODE SCIPconflictstoreGetConflicts(SCIP_CONFLICTSTORE *conflictstore, SCIP_CONS **conflicts, int conflictsize, int *nconflicts)
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip_param.c:636
SCIP_RETCODE SCIPgetNegatedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **negvar)
Definition: scip_var.c:1530
internal methods for displaying runtime statistics
OFINS - Objective Function Induced Neighborhood Search - a primal heuristic for reoptimization.