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