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