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