Scippy

SCIP

Solving Constraint Integer Programs

prob.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 prob.c
26 * @ingroup OTHER_CFILES
27 * @brief Methods and datastructures for storing and manipulating the main problem
28 * @author Tobias Achterberg
29 */
30
31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32
33#include "scip/branch.h"
34#include "scip/conflictstore.h"
35#include "scip/cons.h"
36#include "scip/datatree.h"
37#include "scip/event.h"
38#include "scip/lp.h"
39#include "scip/lpexact.h"
40#include "scip/primal.h"
41#include "scip/prob.h"
42#include "scip/pub_cons.h"
43#include "scip/pub_lp.h"
44#include "scip/pub_message.h"
45#include "scip/pub_misc.h"
46#include "scip/pub_misc_sort.h"
47#include "scip/pub_var.h"
48#include "scip/rational.h"
49#include "scip/set.h"
50#include "scip/stat.h"
51#include "scip/struct_cons.h"
52#include "scip/struct_lp.h"
53#include "scip/struct_prob.h"
54#include "scip/struct_set.h"
55#include "scip/struct_stat.h"
56#include "scip/struct_var.h"
57#include "scip/var.h"
58#include <string.h>
59
60#define OBJSCALE_MAXDNOM 1000000LL /**< maximal denominator in objective integral scaling */
61#define OBJSCALE_MAXSCALE 1000000.0 /**< maximal scalar to reach objective integrality */
62#define OBJSCALE_MAXFINALSCALE 1000.0 /**< maximal final value to apply as scaling */
63
64
65
66/*
67 * dymanic memory arrays
68 */
69
70/** resizes vars array to be able to store at least num entries */
71static
73 SCIP_PROB* prob, /**< problem data */
74 SCIP_SET* set, /**< global SCIP settings */
75 int num /**< minimal number of slots in array */
76 )
77{
78 assert(prob != NULL);
79 assert(set != NULL);
80
81 if( num > prob->varssize )
82 {
83 int newsize;
84
85 newsize = SCIPsetCalcMemGrowSize(set, num);
86 SCIP_ALLOC( BMSreallocMemoryArray(&prob->vars, newsize) );
87 prob->varssize = newsize;
88 }
89 assert(num <= prob->varssize);
90
91 return SCIP_OKAY;
92}
93
94/** resizes fixedvars array to be able to store at least num entries */
95static
97 SCIP_PROB* prob, /**< problem data */
98 SCIP_SET* set, /**< global SCIP settings */
99 int num /**< minimal number of slots in array */
100 )
101{
102 assert(prob != NULL);
103 assert(set != NULL);
104
105 if( num > prob->fixedvarssize )
106 {
107 int newsize;
108
109 newsize = SCIPsetCalcMemGrowSize(set, num);
110 SCIP_ALLOC( BMSreallocMemoryArray(&prob->fixedvars, newsize) );
111 prob->fixedvarssize = newsize;
112 }
113 assert(num <= prob->fixedvarssize);
114
115 return SCIP_OKAY;
116}
117
118/** resizes deletedvars array to be able to store at least num entries */
119static
121 SCIP_PROB* prob, /**< problem data */
122 SCIP_SET* set, /**< global SCIP settings */
123 int num /**< minimal number of slots in array */
124 )
125{
126 assert(prob != NULL);
127 assert(set != NULL);
128
129 if( num > prob->deletedvarssize )
130 {
131 int newsize;
132
133 newsize = SCIPsetCalcMemGrowSize(set, num);
134 SCIP_ALLOC( BMSreallocMemoryArray(&prob->deletedvars, newsize) );
135 prob->deletedvarssize = newsize;
136 }
137 assert(num <= prob->deletedvarssize);
138
139 return SCIP_OKAY;
140}
141
142/** resizes conss array to be able to store at least num entries */
143static
145 SCIP_PROB* prob, /**< problem data */
146 SCIP_SET* set, /**< global SCIP settings */
147 int num /**< minimal number of slots in array */
148 )
149{
150 assert(prob != NULL);
151 assert(set != NULL);
152
153 if( num > prob->consssize )
154 {
155 int newsize;
156
157 newsize = SCIPsetCalcMemGrowSize(set, num);
158 SCIP_ALLOC( BMSreallocMemoryArray(&prob->conss, newsize) );
159 /* resize sorted original constraints if they exist */
160 if( prob->origcheckconss != NULL )
161 {
163 }
164 prob->consssize = newsize;
165 }
166 assert(num <= prob->consssize);
167
168 return SCIP_OKAY;
169}
170
171/** returns whether the constraint has a name */
172static
174 SCIP_CONS* cons /**< constraint */
175 )
176{
177 const char* name;
178
179 name = SCIPconsGetName(cons);
180
181 return (name != NULL && name[0] != '\0');
182}
183
184/** returns whether the variable has a name */
185static
187 SCIP_VAR* var /**< variable */
188 )
189{
190 const char* name;
191
192 name = SCIPvarGetName(var);
193
194 return (name != NULL && name[0] != '\0');
195}
196
197
198
199/*
200 * problem creation
201 */
202
203/** creates problem data structure by copying the source problem
204 *
205 * If the problem type requires the use of variable pricers, these pricers should be activated with calls
206 * to SCIPactivatePricer(). These pricers are automatically deactivated, when the problem is freed.
207 */
209 SCIP_PROB** prob, /**< pointer to problem data structure */
210 BMS_BLKMEM* blkmem, /**< block memory */
211 SCIP_SET* set, /**< global SCIP settings */
212 const char* name, /**< problem name */
213 SCIP* sourcescip, /**< source SCIP data structure */
214 SCIP_PROB* sourceprob, /**< source problem structure */
215 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
216 * target variables */
217 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
218 * target constraints */
219 SCIP_Bool original, /**< copy original or transformed problem? */
220 SCIP_Bool global /**< create a global or a local copy? */
221 )
222{
223 SCIP_PROBDATA* targetdata = NULL;
225
226 assert(prob != NULL);
227 assert(set != NULL);
228 assert(blkmem != NULL);
229 assert(sourcescip != NULL);
230 assert(sourceprob != NULL);
231 assert(varmap != NULL);
232 assert(consmap != NULL);
233
234 /* create problem and initialize callbacks with NULL */
235 SCIP_CALL( SCIPprobCreate(prob, blkmem, set, name, NULL, NULL, NULL, NULL, NULL, NULL, NULL, FALSE) );
236
237 /* call user copy callback method */
238 if( sourceprob->probdata != NULL && sourceprob->probcopy != NULL )
239 {
240 SCIP_CALL( sourceprob->probcopy(set->scip, sourcescip, sourceprob->probdata, varmap, consmap, &targetdata, original, global, &result) );
241
242 /* evaluate result */
243 if( result != SCIP_DIDNOTRUN && result != SCIP_SUCCESS )
244 {
245 SCIPerrorMessage("probdata copying method returned invalid result <%d>\n", result);
246 return SCIP_INVALIDRESULT;
247 }
248
249 assert(targetdata == NULL || result == SCIP_SUCCESS);
250
251 /* if copying was successful, add data and callbacks */
252 if( result == SCIP_SUCCESS )
253 {
254 assert( targetdata != NULL );
255 (*prob)->probdelorig = sourceprob->probdelorig;
256 (*prob)->probtrans = sourceprob->probtrans;
257 (*prob)->probdeltrans = sourceprob->probdeltrans;
258 (*prob)->probinitsol = sourceprob->probinitsol;
259 (*prob)->probexitsol = sourceprob->probexitsol;
260 (*prob)->probcopy = sourceprob->probcopy;
261 (*prob)->probdata = targetdata;
262 }
263 }
264
265 return SCIP_OKAY;
266}
267
268/** creates problem data structure
269 * If the problem type requires the use of variable pricers, these pricers should be activated with calls
270 * to SCIPactivatePricer(). These pricers are automatically deactivated, when the problem is freed.
271 */
273 SCIP_PROB** prob, /**< pointer to problem data structure */
274 BMS_BLKMEM* blkmem, /**< block memory */
275 SCIP_SET* set, /**< global SCIP settings */
276 const char* name, /**< problem name */
277 SCIP_DECL_PROBDELORIG ((*probdelorig)), /**< frees user data of original problem */
278 SCIP_DECL_PROBTRANS ((*probtrans)), /**< creates user data of transformed problem by transforming original user data */
279 SCIP_DECL_PROBDELTRANS((*probdeltrans)), /**< frees user data of transformed problem */
280 SCIP_DECL_PROBINITSOL ((*probinitsol)), /**< solving process initialization method of transformed data */
281 SCIP_DECL_PROBEXITSOL ((*probexitsol)), /**< solving process deinitialization method of transformed data */
282 SCIP_DECL_PROBCOPY ((*probcopy)), /**< copies user data if you want to copy it to a subscip, or NULL */
283 SCIP_PROBDATA* probdata, /**< user problem data set by the reader */
284 SCIP_Bool transformed /**< is this the transformed problem? */
285 )
286{
287 assert(prob != NULL);
288
289 SCIP_ALLOC( BMSallocMemory(prob) );
290 SCIP_ALLOC( BMSduplicateMemoryArray(&(*prob)->name, name, strlen(name)+1) );
291
292 (*prob)->probdata = probdata;
293 (*prob)->probcopy = probcopy;
294 (*prob)->probdelorig = probdelorig;
295 (*prob)->probtrans = probtrans;
296 (*prob)->probdeltrans = probdeltrans;
297 (*prob)->probinitsol = probinitsol;
298 (*prob)->probexitsol = probexitsol;
299 if( set->misc_usevartable )
300 {
301 SCIP_CALL( SCIPhashtableCreate(&(*prob)->varnames, blkmem,
302 (set->misc_usesmalltables ? SCIP_HASHSIZE_NAMES_SMALL : SCIP_HASHSIZE_NAMES),
303 SCIPhashGetKeyVar, SCIPhashKeyEqString, SCIPhashKeyValString, NULL) );
304 }
305 else
306 (*prob)->varnames = NULL;
307 (*prob)->vars = NULL;
308 (*prob)->varssize = 0;
309 (*prob)->nvars = 0;
310 (*prob)->nbinvars = 0;
311 (*prob)->nintvars = 0;
312 (*prob)->nbinimplvars = 0;
313 (*prob)->nintimplvars = 0;
314 (*prob)->ncontimplvars = 0;
315 (*prob)->ncontvars = 0;
316 (*prob)->ncolvars = 0;
317 (*prob)->fixedvars = NULL;
318 (*prob)->fixedvarssize = 0;
319 (*prob)->nfixedvars = 0;
320 (*prob)->deletedvars = NULL;
321 (*prob)->deletedvarssize = 0;
322 (*prob)->ndeletedvars = 0;
323 (*prob)->nobjvars = 0;
324 if( set->misc_useconstable )
325 {
326 SCIP_CALL( SCIPhashtableCreate(&(*prob)->consnames, blkmem,
327 (set->misc_usesmalltables ? SCIP_HASHSIZE_NAMES_SMALL : SCIP_HASHSIZE_NAMES),
328 SCIPhashGetKeyCons, SCIPhashKeyEqString, SCIPhashKeyValString, NULL) );
329 }
330 else
331 (*prob)->consnames = NULL;
332 (*prob)->conss = NULL;
333 (*prob)->origcheckconss = NULL;
334 (*prob)->consssize = 0;
335 (*prob)->nconss = 0;
336 (*prob)->maxnconss = 0;
337 (*prob)->startnvars = 0;
338 (*prob)->startnconss = 0;
339 (*prob)->objlim = SCIP_INVALID;
340 (*prob)->dualbound = SCIP_INVALID;
341 (*prob)->objisintegral = FALSE;
342 (*prob)->transformed = transformed;
343 (*prob)->nlpenabled = FALSE;
344 (*prob)->permuted = FALSE;
345 (*prob)->consschecksorted = FALSE;
346 (*prob)->conscompression = FALSE;
347 (*prob)->objsense = SCIP_OBJSENSE_MINIMIZE;
348 (*prob)->objoffset = 0.0;
349 (*prob)->objscale = 1.0;
350 if( set->exact_enable )
351 {
352 SCIP_CALL( SCIPrationalCreateBlock(blkmem, &(*prob)->objoffsetexact) );
353 SCIP_CALL( SCIPrationalCreateBlock(blkmem, &(*prob)->objscaleexact) );
354
355 SCIPrationalSetReal((*prob)->objoffsetexact, (*prob)->objoffset);
356 SCIPrationalSetReal((*prob)->objscaleexact, (*prob)->objscale);
357 }
358 else
359 {
360 (*prob)->objoffsetexact = NULL;
361 (*prob)->objscaleexact = NULL;
362 }
363
364 return SCIP_OKAY;
365}
366
367/** sets callback to free user data of original problem */
369 SCIP_PROB* prob, /**< problem */
370 SCIP_DECL_PROBDELORIG ((*probdelorig)) /**< frees user data of original problem */
371 )
372{
373 assert(prob != NULL);
374
375 prob->probdelorig = probdelorig;
376}
377
378/** sets callback to create user data of transformed problem by transforming original user data */
380 SCIP_PROB* prob, /**< problem */
381 SCIP_DECL_PROBTRANS ((*probtrans)) /**< creates user data of transformed problem by transforming original user data */
382 )
383{
384 assert(prob != NULL);
385
386 prob->probtrans = probtrans;
387}
388
389/** sets callback to free user data of transformed problem */
391 SCIP_PROB* prob, /**< problem */
392 SCIP_DECL_PROBDELTRANS((*probdeltrans)) /**< frees user data of transformed problem */
393 )
394{
395 assert(prob != NULL);
396
397 prob->probdeltrans = probdeltrans;
398}
399
400/** sets solving process initialization callback of transformed data */
402 SCIP_PROB* prob, /**< problem */
403 SCIP_DECL_PROBINITSOL ((*probinitsol)) /**< solving process initialization callback of transformed data */
404 )
405{
406 assert(prob != NULL);
407
408 prob->probinitsol= probinitsol;
409}
410
411/** sets solving process deinitialization callback of transformed data */
413 SCIP_PROB* prob, /**< problem */
414 SCIP_DECL_PROBEXITSOL ((*probexitsol)) /**< solving process deinitialization callback of transformed data */
415 )
416{
417 assert(prob != NULL);
418
419 prob->probexitsol= probexitsol;
420}
421
422/** sets callback to copy user data to copy it to a subscip, or NULL */
424 SCIP_PROB* prob, /**< problem */
425 SCIP_DECL_PROBCOPY ((*probcopy)) /**< copies user data if you want to copy it to a subscip, or NULL */
426 )
427{
428 assert(prob != NULL);
429
430 prob->probcopy= probcopy;
431}
432
433/** frees problem data structure */
435 SCIP_PROB** prob, /**< pointer to problem data structure */
436 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
437 BMS_BLKMEM* blkmem, /**< block memory buffer */
438 SCIP_SET* set, /**< global SCIP settings */
439 SCIP_STAT* stat, /**< dynamic problem statistics */
440 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
441 SCIP_LP* lp /**< current LP data (or NULL, if it's the original problem) */
442 )
443{
444 int v;
445#ifndef NDEBUG
446 SCIP_Bool unreleasedvar = FALSE;
447#endif
448
449 assert(prob != NULL);
450 assert(*prob != NULL);
451 assert(set != NULL);
452
453 /* remove all constraints from the problem */
454 while( (*prob)->nconss > 0 )
455 {
456 /*@todo for debug mode it even might sense, to sort them downwards after their arraypos */
457 assert((*prob)->conss != NULL);
458 SCIP_CALL( SCIPprobDelCons(*prob, blkmem, set, stat, (*prob)->conss[(*prob)->nconss - 1]) );
459 }
460
461 if( (*prob)->transformed )
462 {
463 int h;
464
465 /* unlock variables for all constraint handlers that don't need constraints */
466 for( h = 0; h < set->nconshdlrs; ++h )
467 {
468 if( !SCIPconshdlrNeedsCons(set->conshdlrs[h]) )
469 {
470 SCIP_CALL( SCIPconshdlrUnlockVars(set->conshdlrs[h], set) );
471 }
472 }
473 }
474
475 /* free constraint array */
476 BMSfreeMemoryArrayNull(&(*prob)->origcheckconss);
477 BMSfreeMemoryArrayNull(&(*prob)->conss);
478
479 /* free user problem data */
480 if( (*prob)->transformed )
481 {
482 if( (*prob)->probdeltrans != NULL )
483 {
484 SCIP_CALL( (*prob)->probdeltrans(set->scip, &(*prob)->probdata) );
485 }
486 }
487 else
488 {
489 if( (*prob)->probdelorig != NULL )
490 {
491 SCIP_CALL( (*prob)->probdelorig(set->scip, &(*prob)->probdata) );
492 }
493 }
494
495 /* release problem variables */
496 for( v = (*prob)->nvars - 1; v >= 0; --v )
497 {
498 assert(SCIPvarGetProbindex((*prob)->vars[v]) >= 0);
499
500 if( SCIPvarGetNUses((*prob)->vars[v]) > 1 )
501 {
502 SCIPmessageFPrintWarning(messagehdlr, "%s variable <%s> not released when freeing SCIP problem <%s>.\n",
503 (*prob)->transformed ? "Transformed" : "Original", SCIPvarGetName((*prob)->vars[v]), SCIPprobGetName(*prob));
504#ifndef NDEBUG
505 unreleasedvar = TRUE;
506#endif
507 }
508
509 SCIP_CALL( SCIPvarRemove((*prob)->vars[v], blkmem, NULL, set, TRUE, FALSE) );
510 SCIP_CALL( SCIPvarRelease(&(*prob)->vars[v], blkmem, set, eventqueue, lp) );
511 }
512 BMSfreeMemoryArrayNull(&(*prob)->vars);
513
514 /* release fixed problem variables */
515 for( v = (*prob)->nfixedvars - 1; v >= 0; --v )
516 {
517 assert(SCIPvarGetProbindex((*prob)->fixedvars[v]) == -1);
518
519 if( SCIPvarGetNUses((*prob)->fixedvars[v]) > 1 )
520 {
521 SCIPmessageFPrintWarning(messagehdlr, "%s variable <%s> not released when freeing SCIP problem <%s>.\n",
522 (*prob)->transformed ? "Transformed" : "Original", SCIPvarGetName((*prob)->fixedvars[v]), SCIPprobGetName(*prob));
523#ifndef NDEBUG
524 unreleasedvar = TRUE;
525#endif
526 }
527
528 SCIP_CALL( SCIPvarRelease(&(*prob)->fixedvars[v], blkmem, set, eventqueue, lp) );
529 }
530 BMSfreeMemoryArrayNull(&(*prob)->fixedvars);
531
532 assert(! unreleasedvar);
533
534 /* free deleted problem variables array */
535 BMSfreeMemoryArrayNull(&(*prob)->deletedvars);
536
537 /* free hash tables for names */
538 if( (*prob)->consnames != NULL )
539 SCIPhashtableFree(&(*prob)->consnames);
540 if( (*prob)->varnames != NULL )
541 SCIPhashtableFree(&(*prob)->varnames);
542 if( (*prob)->objscaleexact != NULL )
543 SCIPrationalFreeBlock(blkmem, &(*prob)->objscaleexact);
544 if( (*prob)->objoffsetexact != NULL )
545 SCIPrationalFreeBlock(blkmem, &(*prob)->objoffsetexact);
546 BMSfreeMemoryArray(&(*prob)->name);
547 BMSfreeMemory(prob);
548
549 return SCIP_OKAY;
550}
551
552/** transform problem data into normalized form */
554 SCIP_PROB* source, /**< problem to transform */
555 BMS_BLKMEM* blkmem, /**< block memory buffer */
556 SCIP_SET* set, /**< global SCIP settings */
557 SCIP_STAT* stat, /**< problem statistics */
558 SCIP_PRIMAL* primal, /**< primal data */
559 SCIP_TREE* tree, /**< branch and bound tree */
560 SCIP_REOPT* reopt, /**< reoptimization data structure */
561 SCIP_LP* lp, /**< current LP data */
562 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
563 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
564 SCIP_EVENTFILTER* eventfilter, /**< global event filter */
565 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
566 SCIP_PROB** target /**< pointer to target problem data structure */
567 )
568{
569 SCIP_VAR* targetvar;
570 SCIP_CONS* targetcons;
571 char transname[SCIP_MAXSTRLEN];
572 int v;
573 int c;
574 int h;
575
576 assert(set != NULL);
577 assert(source != NULL);
578 assert(blkmem != NULL);
579 assert(target != NULL);
580
581 SCIPsetDebugMsg(set, "transform problem: original has %d variables\n", source->nvars);
582
583 /* create target problem data (probdelorig and probtrans are not needed, probdata is set later) */
584 (void) SCIPsnprintf(transname, SCIP_MAXSTRLEN, "t_%s", source->name);
585 SCIP_CALL( SCIPprobCreate(target, blkmem, set, transname, source->probdelorig, source->probtrans, source->probdeltrans,
586 source->probinitsol, source->probexitsol, source->probcopy, NULL, TRUE) );
587 SCIPprobSetObjsense(*target, source->objsense);
588
589 /* transform objective limit */
590 if( source->objlim < SCIP_INVALID )
591 SCIPprobSetObjlim(*target, source->objlim);
592
593 /* transform dual bound */
594 if( source->dualbound < SCIP_INVALID )
595 SCIPprobSetDualbound(*target, source->dualbound);
596
597 /* transform and copy all variables to target problem */
598 SCIP_CALL( probEnsureVarsMem(*target, set, source->nvars) );
599 for( v = 0; v < source->nvars; ++v )
600 {
601 SCIP_CALL( SCIPvarTransform(source->vars[v], blkmem, set, stat, source->objsense, &targetvar) );
602
603 /* if in exact mode copy the exact data */
604 SCIP_CALL( SCIPvarCopyExactData(blkmem, targetvar, source->vars[v], source->objsense == SCIP_OBJSENSE_MAXIMIZE) );
605
606 SCIP_CALL( SCIPprobAddVar(*target, blkmem, set, lp, branchcand, eventqueue, eventfilter, targetvar) );
607 SCIP_CALL( SCIPvarRelease(&targetvar, blkmem, set, eventqueue, NULL) );
608 }
609 assert((*target)->nvars == source->nvars);
610 assert((*target)->nobjvars == SCIPprobGetNObjVars(*target, set));
611
612 /* call user data transformation */
613 if( source->probtrans != NULL )
614 {
615 SCIP_CALL( source->probtrans(set->scip, source->probdata, &(*target)->probdata) );
616 }
617 else
618 (*target)->probdata = source->probdata;
619
620 /* transform and copy all constraints to target problem */
621 for( c = 0; c < source->nconss; ++c )
622 {
623 SCIP_CALL( SCIPconsTransform(source->conss[c], blkmem, set, &targetcons) );
624 SCIP_CALL( SCIPprobAddCons(*target, set, stat, targetcons) );
625 SCIP_CALL( SCIPconsRelease(&targetcons, blkmem, set) );
626 }
627
628 /* lock variables for all constraint handlers that don't need constraints */
629 for( h = 0; h < set->nconshdlrs; ++h )
630 {
631 if( !SCIPconshdlrNeedsCons(set->conshdlrs[h]) )
632 {
633 SCIP_CALL( SCIPconshdlrLockVars(set->conshdlrs[h], set) );
634 }
635 }
636
637 /* objective value is always integral, iff original objective value is always integral and shift is integral */
638 (*target)->objisintegral = source->objisintegral && SCIPsetIsIntegral(set, (*target)->objoffset);
639
640 /* check, whether objective value is always integral by inspecting the problem, if it is the case adjust the
641 * cutoff bound if primal solution is already known
642 */
643 SCIP_CALL( SCIPprobCheckObjIntegral(*target, source, blkmem, set, stat, primal, tree, reopt, lp, eventqueue, eventfilter) );
644
645 /* copy the nlpenabled flag */
646 (*target)->nlpenabled = source->nlpenabled;
647
648 /* mark the transformed problem to be permuted iff the source problem is permuted */
649 (*target)->permuted = source->permuted;
650
651 /* transform the conflict pool */
652 SCIP_CALL( SCIPconflictstoreTransform(conflictstore, blkmem, set, stat, tree, *target, reopt) );
653
654 return SCIP_OKAY;
655}
656
657/** resets the global and local bounds of original variables in original problem to their original values */
659 SCIP_PROB* prob, /**< original problem data */
660 BMS_BLKMEM* blkmem, /**< block memory */
661 SCIP_SET* set, /**< global SCIP settings */
662 SCIP_STAT* stat /**< problem statistics */
663 )
664{
665 int v;
666
667 assert(prob != NULL);
668 assert(prob->nfixedvars == 0);
669
670 for( v = 0; v < prob->nvars; ++v )
671 {
672 SCIP_CALL( SCIPvarResetBounds(prob->vars[v], blkmem, set, stat) );
673 }
674
675 return SCIP_OKAY;
676}
677
678/** (Re)Sort the variables, which appear in the four categories (binary, integer, implicit, continuous) after presolve
679 * with respect to their original index (within their categories). Adjust the problem index afterwards which is
680 * supposed to reflect the position in the variable array. This additional (re)sorting is supposed to get more robust
681 * against the order presolving fixed variables. (We also reobtain a possible block structure induced by the user
682 * model)
683 */
685 SCIP_PROB* prob /**< problem data */
686 )
687{
688 SCIP_VAR** vars;
689 int nbinvars;
690 int nintvars;
691 int nbinimplvars;
692 int nintimplvars;
693 int ncontimplvars;
694 int ncontvars;
695 int nvars;
696 int v;
697
698 vars = prob->vars;
699 nvars = prob->nvars;
700 nbinvars = prob->nbinvars;
701 nintvars = prob->nintvars;
702 nbinimplvars = prob->nbinimplvars;
703 nintimplvars = prob->nintimplvars;
704 ncontimplvars = prob->ncontimplvars;
705 ncontvars = prob->ncontvars;
706
707 if( nvars == 0 )
708 return;
709
710 assert(vars != NULL);
711 assert(nbinvars + nintvars + nbinimplvars + nintimplvars + ncontimplvars + ncontvars == nvars);
712
713 SCIPdebugMessage("entering sorting with respect to original block structure! \n");
714
715 /* sort binaries */
716 if( nbinvars > 0 )
717 SCIPsortPtr((void**)vars, SCIPvarComp, nbinvars);
718
719 /* sort integers */
720 if( nintvars > 0 )
721 SCIPsortPtr((void**)&vars[nbinvars], SCIPvarComp, nintvars);
722
723 /* sort binary implicit variables */
724 if( nbinimplvars > 0 )
725 SCIPsortPtr((void**)&vars[nbinvars + nintvars], SCIPvarComp, nbinimplvars);
726
727 /* sort integer implicit variables */
728 if( nintimplvars > 0 )
729 SCIPsortPtr((void**)&vars[nbinvars + nintvars + nbinimplvars], SCIPvarComp, nintimplvars);
730
731 /* sort continuous implicit integer variables */
732 if( ncontimplvars > 0 )
733 SCIPsortPtr((void**)&vars[nbinvars + nintvars + nbinimplvars + nintimplvars], SCIPvarComp, ncontimplvars);
734
735 /* sort continuous variables */
736 if( ncontvars > 0 )
737 SCIPsortPtr((void**)&vars[nbinvars + nintvars + nbinimplvars + nintimplvars + ncontimplvars], SCIPvarComp, ncontvars);
738
739 /* after sorting, the problem index of each variable has to be adjusted */
740 for( v = 0; v < nvars; ++v )
741 {
742 vars[v]->probindex = v;
743 SCIPdebugMessage("Variable: Problem index <%d>, original index <%d> \n", vars[v]->probindex, vars[v]->index);
744 }
745}
746
747/** possibly create and sort the constraints according to check priorties */
749 SCIP_PROB* prob /**< problem data */
750 )
751{
752 if( prob->consschecksorted || prob->transformed )
753 return SCIP_OKAY;
754
755 if( prob->nconss > 0 )
756 {
757 /* possibly create and copy constraints */
758 if( prob->origcheckconss == NULL )
759 {
761 }
762 assert( prob->origcheckconss != NULL );
763
764 /* sort original constraint according to check priority */
765 SCIPsortPtr((void**)prob->origcheckconss, SCIPconsCompCheck, prob->nconss);
766 }
767 prob->consschecksorted = TRUE;
768
769 return SCIP_OKAY;
770}
771
772
773/*
774 * problem modification
775 */
776
777/** sets user problem data */
779 SCIP_PROB* prob, /**< problem */
780 SCIP_PROBDATA* probdata /**< user problem data to use */
781 )
782{
783 assert(prob != NULL);
784
785 prob->probdata = probdata;
786}
787
788/** moves the first behind the last variable for each extended variable type in reverse order until the given one and
789 * returns the cleared variable position in the given problem
790 */
791static
793 SCIP_PROB* prob, /**< problem data */
794 SCIP_VARTYPE vartype, /**< type of the variable to be inserted */
795 SCIP_IMPLINTTYPE impltype /**< implied type of the variable to be inserted */
796 )
797{
798 int insertpos = prob->nvars;
799 int intstart = prob->nbinvars;
800 int binimplstart = intstart + prob->nintvars;
801 int intimplstart = binimplstart + prob->nbinimplvars;
802 int contimplstart = intimplstart + prob->nintimplvars;
803 int contstart = contimplstart + prob->ncontimplvars;
804
805 /* non-implied continuous variable */
806 if( vartype == SCIP_VARTYPE_CONTINUOUS && impltype == SCIP_IMPLINTTYPE_NONE )
807 {
808 ++prob->ncontvars;
809 return insertpos;
810 }
811 if( insertpos > contstart )
812 {
813 prob->vars[insertpos] = prob->vars[contstart];
814 SCIPvarSetProbindex(prob->vars[insertpos], insertpos);
815 insertpos = contstart;
816 }
817 assert(insertpos == contstart);
818
819 /* implied continuous variable */
820 if( vartype == SCIP_VARTYPE_CONTINUOUS )
821 {
822 assert(impltype != SCIP_IMPLINTTYPE_NONE);
823 ++prob->ncontimplvars;
824 return insertpos;
825 }
826 if( insertpos > contimplstart )
827 {
828 prob->vars[insertpos] = prob->vars[contimplstart];
829 SCIPvarSetProbindex(prob->vars[insertpos], insertpos);
830 insertpos = contimplstart;
831 }
832 assert(insertpos == contimplstart);
833
834 /* implied integral variable */
835 if( vartype == SCIP_VARTYPE_INTEGER && impltype != SCIP_IMPLINTTYPE_NONE )
836 {
837 ++prob->nintimplvars;
838 return insertpos;
839 }
840 if( insertpos > intimplstart )
841 {
842 prob->vars[insertpos] = prob->vars[intimplstart];
843 SCIPvarSetProbindex(prob->vars[insertpos], insertpos);
844 insertpos = intimplstart;
845 }
846 assert(insertpos == intimplstart);
847
848 /* implied binary variable */
849 if( vartype == SCIP_VARTYPE_BINARY && impltype != SCIP_IMPLINTTYPE_NONE )
850 {
851 ++prob->nbinimplvars;
852 return insertpos;
853 }
854 if( insertpos > binimplstart )
855 {
856 prob->vars[insertpos] = prob->vars[binimplstart];
857 SCIPvarSetProbindex(prob->vars[insertpos], insertpos);
858 insertpos = binimplstart;
859 }
860 assert(insertpos == binimplstart);
861
862 /* non-implied integral variable */
863 if( vartype == SCIP_VARTYPE_INTEGER )
864 {
865 assert(impltype == SCIP_IMPLINTTYPE_NONE);
866 ++prob->nintvars;
867 return insertpos;
868 }
869 if( insertpos > intstart )
870 {
871 prob->vars[insertpos] = prob->vars[intstart];
872 SCIPvarSetProbindex(prob->vars[insertpos], insertpos);
873 insertpos = intstart;
874 }
875 assert(insertpos == intstart);
876
877 /* non-implied binary variable */
878 assert(vartype == SCIP_VARTYPE_BINARY);
879 assert(impltype == SCIP_IMPLINTTYPE_NONE);
880 ++prob->nbinvars;
881
882 return insertpos;
883}
884
885/** inserts variable at the correct position in vars array, depending on its extended variable type */
886static
888 SCIP_PROB* prob, /**< problem data */
889 SCIP_VAR* var /**< variable to insert */
890 )
891{
892 assert(prob != NULL);
893 assert(prob->vars != NULL);
894 assert(prob->nvars < prob->varssize);
895 assert(var != NULL);
896 assert(SCIPvarGetProbindex(var) == -1);
900 /* original variables cannot go into transformed problem and transformed variables cannot go into original problem */
901 assert((SCIPvarGetStatus(var) != SCIP_VARSTATUS_ORIGINAL) == prob->transformed);
902
903 /* get insert position */
904 SCIP_VARTYPE vartype = SCIPvarGetType(var);
905 SCIP_IMPLINTTYPE impltype = SCIPvarGetImplType(var);
906 int insertpos = probProvidePos(prob, vartype, impltype);
907 assert((vartype == SCIP_VARTYPE_BINARY && impltype == SCIP_IMPLINTTYPE_NONE && insertpos == prob->nbinvars - 1)
908 || (vartype == SCIP_VARTYPE_INTEGER && impltype == SCIP_IMPLINTTYPE_NONE && insertpos == prob->nbinvars + prob->nintvars - 1)
909 || (vartype == SCIP_VARTYPE_BINARY && impltype != SCIP_IMPLINTTYPE_NONE && insertpos == prob->nbinvars + prob->nintvars + prob->nbinimplvars - 1)
910 || (vartype == SCIP_VARTYPE_INTEGER && impltype != SCIP_IMPLINTTYPE_NONE && insertpos == prob->nbinvars + prob->nintvars + prob->nbinimplvars + prob->nintimplvars - 1)
911 || (vartype == SCIP_VARTYPE_CONTINUOUS && impltype != SCIP_IMPLINTTYPE_NONE && insertpos == prob->nbinvars + prob->nintvars + prob->nbinimplvars + prob->nintimplvars + prob->ncontimplvars - 1)
912 || (vartype == SCIP_VARTYPE_CONTINUOUS && impltype == SCIP_IMPLINTTYPE_NONE && insertpos == prob->nbinvars + prob->nintvars + prob->nbinimplvars + prob->nintimplvars + prob->ncontimplvars + prob->ncontvars - 1));
913
914 /* fill insert position */
915 prob->vars[insertpos] = var;
916 SCIPvarSetProbindex(var, insertpos);
917 ++prob->nvars;
918 assert(prob->nvars == prob->nbinvars + prob->nintvars + prob->nbinimplvars + prob->nintimplvars + prob->ncontimplvars + prob->ncontvars);
919
920 /* update number of column variables in problem */
922 ++prob->ncolvars;
923 assert(prob->ncolvars >= 0);
924 assert(prob->ncolvars <= prob->nvars);
925}
926
927/** removes variable from vars array */
928static
930 SCIP_PROB* prob, /**< problem data */
931 BMS_BLKMEM* blkmem, /**< block memory */
932 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
933 SCIP_SET* set, /**< global SCIP settings */
934 SCIP_VAR* var, /**< variable to remove */
935 SCIP_Bool isupgraded /**< is the variable removed for the purpose of upgrading its variable type? */
936 )
937{
938 int freepos;
939 int intstart;
940 int binimplstart;
941 int intimplstart;
942 int contimplstart;
943 int contstart;
944 SCIP_VARTYPE vartype;
945 SCIP_IMPLINTTYPE impltype;
946
947 assert(prob != NULL);
948 assert(var != NULL);
949 assert(SCIPvarGetProbindex(var) >= 0);
950 assert(prob->vars != NULL);
951 assert(prob->vars[SCIPvarGetProbindex(var)] == var);
952
953 intstart = prob->nbinvars;
954 binimplstart = intstart + prob->nintvars;
955 intimplstart = binimplstart + prob->nbinimplvars;
956 contimplstart = intimplstart + prob->nintimplvars;
957 contstart = contimplstart + prob->ncontimplvars;
958 vartype = SCIPvarGetType(var);
959 impltype = SCIPvarGetImplType(var);
960
961 if( impltype != SCIP_IMPLINTTYPE_NONE )
962 {
963 switch( vartype )
964 {
966 assert(binimplstart <= SCIPvarGetProbindex(var) && SCIPvarGetProbindex(var) < intimplstart);
967 --prob->nbinimplvars;
968 break;
970 assert(intimplstart <= SCIPvarGetProbindex(var) && SCIPvarGetProbindex(var) < contimplstart);
971 --prob->nintimplvars;
972 break;
974 assert(contimplstart <= SCIPvarGetProbindex(var) && SCIPvarGetProbindex(var) < contstart);
975 --prob->ncontimplvars;
976 break;
977 default:
978 SCIPerrorMessage("unknown variable type\n");
979 return SCIP_INVALIDDATA;
980 } /*lint !e788*/
981 }
982 else
983 {
984 switch( vartype )
985 {
987 assert(0 <= SCIPvarGetProbindex(var) && SCIPvarGetProbindex(var) < intstart);
988 --prob->nbinvars;
989 break;
991 assert(intstart <= SCIPvarGetProbindex(var) && SCIPvarGetProbindex(var) < binimplstart);
992 --prob->nintvars;
993 break;
995 assert(contstart <= SCIPvarGetProbindex(var) && SCIPvarGetProbindex(var) < prob->nvars);
996 --prob->ncontvars;
997 break;
998 default:
999 SCIPerrorMessage("unknown variable type\n");
1000 return SCIP_INVALIDDATA;
1001 } /*lint !e788*/
1002 }
1003
1004 /* move last binary, last integer, last implicit, and last continuous variable forward to fill the free slot */
1005 freepos = SCIPvarGetProbindex(var);
1006 if( freepos < intstart-1 )
1007 {
1008 /* move last binary variable to free slot */
1009 prob->vars[freepos] = prob->vars[intstart-1];
1010 SCIPvarSetProbindex(prob->vars[freepos], freepos);
1011 freepos = intstart-1;
1012 }
1013 if( freepos < binimplstart-1 )
1014 {
1015 /* move last integer variable to free slot */
1016 prob->vars[freepos] = prob->vars[binimplstart-1];
1017 SCIPvarSetProbindex(prob->vars[freepos], freepos);
1018 freepos = binimplstart-1;
1019 }
1020 if( freepos < intimplstart-1 )
1021 {
1022 /* move last binary implied integral variable to free slot */
1023 prob->vars[freepos] = prob->vars[intimplstart-1];
1024 SCIPvarSetProbindex(prob->vars[freepos], freepos);
1025 freepos = intimplstart-1;
1026 }
1027 if( freepos < contimplstart-1 )
1028 {
1029 /* move last integer implied integral variable to free slot */
1030 prob->vars[freepos] = prob->vars[contimplstart-1];
1031 SCIPvarSetProbindex(prob->vars[freepos], freepos);
1032 freepos = contimplstart-1;
1033 }
1034 if( freepos < contstart-1 )
1035 {
1036 /* move last continuous implicit integer variable to free slot */
1037 prob->vars[freepos] = prob->vars[contstart-1];
1038 SCIPvarSetProbindex(prob->vars[freepos], freepos);
1039 freepos = contstart-1;
1040 }
1041 if( freepos < prob->nvars-1 )
1042 {
1043 /* move last continuous variable to free slot */
1044 prob->vars[freepos] = prob->vars[prob->nvars-1];
1045 SCIPvarSetProbindex(prob->vars[freepos], freepos);
1046 freepos = prob->nvars-1;
1047 }
1048 assert(freepos == prob->nvars-1);
1049
1050 --prob->nvars;
1051 assert(prob->nvars == prob->nbinvars + prob->nintvars + prob->nbinimplvars + prob->nintimplvars + prob->ncontimplvars + prob->ncontvars);
1052
1053 /* update number of column variables in problem */
1055 prob->ncolvars--;
1056 assert(0 <= prob->ncolvars && prob->ncolvars <= prob->nvars);
1057
1058 /* inform the variable that it is no longer in the problem; if necessary, delete it from the implication graph */
1059 SCIP_CALL( SCIPvarRemove(var, blkmem, cliquetable, set, FALSE, isupgraded) );
1060
1061 return SCIP_OKAY;
1062}
1063
1064/** adds variable's name to the namespace */
1066 SCIP_PROB* prob, /**< problem data */
1067 SCIP_VAR* var /**< variable */
1068 )
1069{
1070 assert(SCIPvarGetProbindex(var) != -1);
1071
1072 if( varHasName(var) && prob->varnames != NULL )
1073 {
1074 SCIP_CALL( SCIPhashtableInsert(prob->varnames, (void*)var) );
1075 }
1076
1077 return SCIP_OKAY;
1078}
1079
1080/** removes variable's name from the namespace */
1082 SCIP_PROB* prob, /**< problem data */
1083 SCIP_VAR* var /**< variable */
1084 )
1085{
1086 if( varHasName(var) && prob->varnames != NULL )
1087 {
1088 assert(SCIPhashtableExists(prob->varnames, (void*)var));
1089 SCIP_CALL( SCIPhashtableRemove(prob->varnames, (void*)var) );
1090 }
1091
1092 return SCIP_OKAY;
1093}
1094
1095/** adds variable to the problem and captures it */
1097 SCIP_PROB* prob, /**< problem data */
1098 BMS_BLKMEM* blkmem, /**< block memory buffers */
1099 SCIP_SET* set, /**< global SCIP settings */
1100 SCIP_LP* lp, /**< current LP data */
1101 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1102 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1103 SCIP_EVENTFILTER* eventfilter, /**< global event filter */
1104 SCIP_VAR* var /**< variable to add */
1105 )
1106{
1107 assert(prob != NULL);
1108 assert(set != NULL);
1109 assert(var != NULL);
1110 assert(SCIPvarGetProbindex(var) == -1);
1114 /* original variables cannot go into transformed problem and transformed variables cannot go into original problem */
1115 assert((SCIPvarGetStatus(var) != SCIP_VARSTATUS_ORIGINAL) == prob->transformed);
1116
1117#ifndef NDEBUG
1118 /* check if we add this variables to the same scip, where we created it */
1119 if( var->scip != set->scip )
1120 {
1121 SCIPerrorMessage("variable belongs to a different scip instance\n");
1122 return SCIP_INVALIDDATA;
1123 }
1124#endif
1125
1126 /* capture variable */
1127 SCIPvarCapture(var);
1128
1129 /* allocate additional memory */
1130 SCIP_CALL( probEnsureVarsMem(prob, set, prob->nvars+1) );
1131
1132 /* insert variable in vars array and mark it to be in problem */
1133 probInsertVar(prob, var);
1134
1135 /* add variable's name to the namespace */
1136 SCIP_CALL( SCIPprobAddVarName(prob, var) );
1137
1138 /* update branching candidates and pseudo and loose objective value in the LP */
1140 {
1141 SCIP_CALL( SCIPbranchcandUpdateVar(branchcand, set, var) );
1142 SCIP_CALL( SCIPlpUpdateAddVar(lp, set, var) );
1144 }
1145
1146 SCIPsetDebugMsg(set, "added variable <%s> to problem (%d variables: %d binary, %d integer, %d continuous; %d implied)\n",
1147 SCIPvarGetName(var), prob->nvars, prob->nbinvars + prob->nbinimplvars, prob->nintvars + prob->nintimplvars,
1148 prob->ncontvars+ prob->ncontimplvars, SCIPprobGetNImplVars(prob));
1149
1150 if( prob->transformed )
1151 {
1152 SCIP_EVENT* event;
1153
1154 /* issue VARADDED event */
1155 SCIP_CALL( SCIPeventCreateVarAdded(&event, blkmem, var) );
1156 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, NULL, NULL, eventfilter, &event) );
1157
1158 /* update the number of variables with non-zero objective coefficient */
1159 SCIPprobUpdateNObjVars(prob, set, 0.0, SCIPvarGetObj(var));
1160
1161 /* SCIP assumes that the status of objisintegral does not change after transformation. Thus, the objective of all
1162 * new variables beyond that stage has to be compatible. */
1165 }
1166
1167 return SCIP_OKAY;
1168}
1169
1170/** marks variable to be removed from the problem; however, the variable is NOT removed from the constraints */
1172 SCIP_PROB* prob, /**< problem data */
1173 BMS_BLKMEM* blkmem, /**< block memory */
1174 SCIP_SET* set, /**< global SCIP settings */
1175 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1176 SCIP_VAR* var, /**< problem variable */
1177 SCIP_Bool* deleted /**< pointer to store whether marking variable to be deleted was successful */
1178 )
1179{
1180 assert(prob != NULL);
1181 assert(set != NULL);
1182 assert(var != NULL);
1183 assert(deleted != NULL);
1184 assert(SCIPvarGetProbindex(var) != -1);
1188
1189 *deleted = FALSE;
1190
1191 /* don't remove variables that are not in the problem */
1192 /**@todo what about negated variables? should the negation variable be removed instead? */
1193 if( SCIPvarGetProbindex(var) == -1 )
1194 return SCIP_OKAY;
1195
1196 /* don't remove the direct counterpart of an original variable from the transformed problem, because otherwise
1197 * operations on the original variables would be applied to a NULL pointer
1198 */
1200 return SCIP_OKAY;
1201
1202 assert(SCIPvarGetNegatedVar(var) == NULL);
1203
1204 SCIPsetDebugMsg(set, "deleting variable <%s> from problem (%d variables: %d binary, %d integer, %d continuous; %d implied)\n",
1205 SCIPvarGetName(var), prob->nvars, prob->nbinvars + prob->nbinimplvars, prob->nintvars + prob->nintimplvars,
1206 prob->ncontvars+ prob->ncontimplvars, SCIPprobGetNImplVars(prob));
1207
1208 /* mark variable to be deleted from the problem */
1209 SCIPvarMarkDeleted(var);
1210
1211 if( prob->transformed )
1212 {
1213 SCIP_EVENT* event;
1214
1215 assert(eventqueue != NULL);
1216
1217 /* issue VARDELETED event */
1218 SCIP_CALL( SCIPeventCreateVarDeleted(&event, blkmem, var) );
1219 SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, NULL, NULL, NULL, &event) );
1220 }
1221
1222 /* remember that the variable should be deleted from the problem in SCIPprobPerformVarDeletions() */
1224 prob->deletedvars[prob->ndeletedvars] = var;
1225 prob->ndeletedvars++;
1226
1227 *deleted = TRUE;
1228
1229 return SCIP_OKAY;
1230}
1231
1232/** actually removes the deleted variables from the problem and releases them */
1234 SCIP_PROB* prob, /**< problem data */
1235 BMS_BLKMEM* blkmem, /**< block memory */
1236 SCIP_SET* set, /**< global SCIP settings */
1237 SCIP_STAT* stat, /**< dynamic problem statistics */
1238 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1239 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
1240 SCIP_LP* lp, /**< current LP data (may be NULL) */
1241 SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
1242 )
1243{
1244 int i;
1245
1246 assert(prob != NULL);
1247 assert(set != NULL);
1248
1249 /* delete variables from the constraints;
1250 * do this only in solving stage, in presolving, it is already handled by the constraint handlers
1251 */
1253 {
1254 for( i = 0; i < set->nconshdlrs; ++i )
1255 {
1256 SCIP_CALL( SCIPconshdlrDelVars(set->conshdlrs[i], blkmem, set, stat) );
1257 }
1258 }
1259
1260 for( i = 0; i < prob->ndeletedvars; ++i )
1261 {
1262 SCIP_VAR* var;
1263
1264 var = prob->deletedvars[i];
1265
1266 /* don't delete the variable, if it was fixed or aggregated in the meantime */
1267 if( SCIPvarGetProbindex(var) >= 0 )
1268 {
1269 SCIPsetDebugMsg(set, "perform deletion of <%s> [%p]\n", SCIPvarGetName(var), (void*)var);
1270
1271 /* convert column variable back into loose variable, free LP column */
1273 {
1274 SCIP_CALL( SCIPvarLoose(var, blkmem, set, eventqueue, prob, lp) );
1275 }
1276
1277 /* update branching candidates and pseudo and loose objective value in the LP */
1279 {
1280 SCIP_CALL( SCIPlpUpdateDelVar(lp, set, var) );
1281 SCIP_CALL( SCIPbranchcandRemoveVar(branchcand, var) );
1282 }
1283
1284 /* remove variable's name from the namespace */
1285 SCIP_CALL( SCIPprobRemoveVarName(prob, var) );
1286
1287 /* remove variable from vars array and mark it to be not in problem */
1288 SCIP_CALL( probRemoveVar(prob, blkmem, cliquetable, set, var, FALSE) );
1289
1290 /* update the number of variables with non-zero objective coefficient */
1291 if( prob->transformed )
1292 SCIPprobUpdateNObjVars(prob, set, SCIPvarGetObj(var), 0.0);
1293
1294 /* release variable */
1295 SCIP_CALL( SCIPvarRelease(&prob->deletedvars[i], blkmem, set, eventqueue, lp) );
1296 }
1297 }
1298 prob->ndeletedvars = 0;
1299
1300 return SCIP_OKAY;
1301}
1302
1303/** changes the type of a variable in the problem */
1305 SCIP_PROB* prob, /**< problem data */
1306 BMS_BLKMEM* blkmem, /**< block memory */
1307 SCIP_SET* set, /**< global SCIP settings */
1308 SCIP_PRIMAL* primal, /**< primal data */
1309 SCIP_LP* lp, /**< current LP data */
1310 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1311 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1312 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
1313 SCIP_VAR* var, /**< variable to change type of */
1314 SCIP_VARTYPE vartype /**< new type of variable */
1315 )
1316{
1317 SCIP_Bool upgraded;
1318
1319 assert(prob != NULL);
1320 assert(var != NULL);
1321 assert(SCIPvarGetProbindex(var) >= 0);
1325 assert(branchcand != NULL || SCIPvarGetStatus(var) == SCIP_VARSTATUS_ORIGINAL);
1326
1327 if( SCIPvarGetType(var) == vartype )
1328 return SCIP_OKAY;
1329
1330 /* temporarily remove variable from branching candidates */
1331 if( branchcand != NULL )
1332 {
1333 SCIP_CALL( SCIPbranchcandRemoveVar(branchcand, var) );
1334 }
1335
1336 /* Do not remove cliques, varbounds and implications if we upgrade the type */
1337 upgraded = vartype > SCIPvarGetType(var);
1338
1339 /* temporarily remove variable from problem */
1340 SCIP_CALL( probRemoveVar(prob, blkmem, cliquetable, set, var, upgraded) );
1341
1342 /* change the type of the variable */
1343 SCIP_CALL( SCIPvarChgType(var, blkmem, set, primal, lp, eventqueue, vartype) );
1344
1345 /* reinsert variable into problem */
1346 probInsertVar(prob, var);
1347
1348 /* update branching candidates */
1349 if( branchcand != NULL )
1350 {
1351 SCIP_CALL( SCIPbranchcandUpdateVar(branchcand, set, var) );
1352 }
1353
1354 return SCIP_OKAY;
1355}
1356
1357/** changes the implied integral type of a variable in the problem */
1359 SCIP_PROB* prob, /**< problem data */
1360 BMS_BLKMEM* blkmem, /**< block memory */
1361 SCIP_SET* set, /**< global SCIP settings */
1362 SCIP_PRIMAL* primal, /**< primal data */
1363 SCIP_LP* lp, /**< current LP data */
1364 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1365 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1366 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
1367 SCIP_VAR* var, /**< variable to change implied integral type of */
1368 SCIP_IMPLINTTYPE impltype /**< new implied integral type of variable */
1369 )
1370{
1371 SCIP_Bool upgraded;
1372
1373 assert(prob != NULL);
1374 assert(var != NULL);
1375 assert(SCIPvarGetProbindex(var) >= 0);
1379 assert(branchcand != NULL || SCIPvarGetStatus(var) == SCIP_VARSTATUS_ORIGINAL);
1380
1381 if( SCIPvarGetImplType(var) == impltype )
1382 return SCIP_OKAY;
1383
1384 /* temporarily remove variable from branching candidates */
1385 if( branchcand != NULL )
1386 {
1387 SCIP_CALL( SCIPbranchcandRemoveVar(branchcand, var) );
1388 }
1389
1390 /* Do not remove cliques, varbounds and implications unless type becomes non-implied */
1391 upgraded = impltype != SCIP_IMPLINTTYPE_NONE;
1392
1393 /* temporarily remove variable from problem */
1394 SCIP_CALL( probRemoveVar(prob, blkmem, cliquetable, set, var, upgraded) );
1395
1396 /* change the type of the variable */
1397 SCIP_CALL( SCIPvarChgImplType(var, blkmem, set, primal, lp, eventqueue, impltype) );
1398
1399 /* reinsert variable into problem */
1400 probInsertVar(prob, var);
1401
1402 /* update branching candidates */
1403 if( branchcand != NULL )
1404 {
1405 SCIP_CALL( SCIPbranchcandUpdateVar(branchcand, set, var) );
1406 }
1407
1408 return SCIP_OKAY;
1409}
1410
1411/** informs problem, that the given loose problem variable changed its status */
1413 SCIP_PROB* prob, /**< problem data */
1414 BMS_BLKMEM* blkmem, /**< block memory */
1415 SCIP_SET* set, /**< global SCIP settings */
1416 SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1417 SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
1418 SCIP_VAR* var /**< problem variable */
1419 )
1420{
1421 assert(prob != NULL);
1422 assert(var != NULL);
1423 assert(SCIPvarGetProbindex(var) != -1);
1424
1425 /* get current status of variable */
1426 switch( SCIPvarGetStatus(var) )
1427 {
1429 SCIPerrorMessage("variables cannot switch to ORIGINAL status\n");
1430 return SCIP_INVALIDDATA;
1431
1433 /* variable switched from column to loose */
1434 prob->ncolvars--;
1435 break;
1436
1438 /* variable switched from non-column to column */
1439 prob->ncolvars++;
1440 break;
1441
1446 /* variable switched from unfixed to fixed (if it was fixed before, probindex would have been -1) */
1447
1448 /* remove variable from problem */
1449 SCIP_CALL( probRemoveVar(prob, blkmem, cliquetable, set, var, FALSE) );
1450
1451 /* insert variable in fixedvars array */
1453 prob->fixedvars[prob->nfixedvars] = var;
1454 prob->nfixedvars++;
1455
1456 /* update branching candidates */
1457 SCIP_CALL( SCIPbranchcandUpdateVar(branchcand, set, var) );
1458 break;
1459
1460 default:
1461 SCIPerrorMessage("invalid variable status <%d>\n", SCIPvarGetStatus(var));
1462 return SCIP_INVALIDDATA;
1463 }
1464 assert(0 <= prob->ncolvars && prob->ncolvars <= prob->nvars);
1465
1466 return SCIP_OKAY;
1467}
1468
1469/** adds constraint's name to the namespace */
1471 SCIP_PROB* prob, /**< problem data */
1472 SCIP_CONS* cons /**< constraint */
1473 )
1474{
1475 /* add constraint's name to the namespace */
1476 if( consHasName(cons) && prob->consnames != NULL )
1477 {
1478 SCIP_CALL( SCIPhashtableInsert(prob->consnames, (void*)cons) );
1479 }
1480
1481 return SCIP_OKAY;
1482}
1483
1484/** remove constraint's name from the namespace */
1486 SCIP_PROB* prob, /**< problem data */
1487 SCIP_CONS* cons /**< constraint */
1488 )
1489{
1490 /* remove constraint's name from the namespace */
1491 if( consHasName(cons) && prob->consnames != NULL )
1492 {
1493 SCIP_CONS* currentcons;
1494 currentcons = (SCIP_CONS*)SCIPhashtableRetrieve(prob->consnames, (void*)(cons->name));
1495 if( currentcons == cons )
1496 {
1497 SCIP_CALL( SCIPhashtableRemove(prob->consnames, (void*)cons) );
1498 }
1499 }
1500
1501 return SCIP_OKAY;
1502}
1503
1504/** adds constraint to the problem and captures it;
1505 * a local constraint is automatically upgraded into a global constraint
1506 */
1508 SCIP_PROB* prob, /**< problem data */
1509 SCIP_SET* set, /**< global SCIP settings */
1510 SCIP_STAT* stat, /**< dynamic problem statistics */
1511 SCIP_CONS* cons /**< constraint to add */
1512 )
1513{
1514 assert(prob != NULL);
1515 assert(cons != NULL);
1516 assert(cons->addconssetchg == NULL);
1517 assert(cons->addarraypos == -1);
1518
1519#ifndef NDEBUG
1520 /* check if we add this constraint to the same scip, where we create the constraint */
1521 if( cons->scip != set->scip )
1522 {
1523 SCIPerrorMessage("constraint belongs to different scip instance\n");
1524 return SCIP_INVALIDDATA;
1525 }
1526#endif
1527 SCIPsetDebugMsg(set, "adding constraint <%s> to global problem -> %d constraints\n",
1528 SCIPconsGetName(cons), prob->nconss+1);
1529
1530 /* mark the constraint as problem constraint, and remember the constraint's position */
1531 cons->addconssetchg = NULL;
1532 cons->addarraypos = prob->nconss;
1533
1534 /* add the constraint to the problem's constraint array */
1535 SCIP_CALL( probEnsureConssMem(prob, set, prob->nconss+1) );
1536 prob->conss[prob->nconss] = cons;
1537 if( prob->origcheckconss != NULL )
1538 prob->origcheckconss[prob->nconss] = cons;
1539 prob->nconss++;
1540 prob->maxnconss = MAX(prob->maxnconss, prob->nconss);
1541 prob->consschecksorted = FALSE;
1542 stat->nactiveconssadded++;
1543
1544 /* undelete constraint, if it was globally deleted in the past */
1545 cons->deleted = FALSE;
1546
1547 /* mark constraint to be globally valid */
1548 SCIPconsSetLocal(cons, FALSE);
1549
1550 /* capture constraint */
1551 SCIPconsCapture(cons);
1552
1553 /* add constraint's name to the namespace */
1554 SCIP_CALL( SCIPprobAddConsName(prob, cons) );
1555
1556 /* if the problem is the transformed problem, activate and lock constraint */
1557 if( prob->transformed )
1558 {
1559 /* activate constraint */
1560 if( !SCIPconsIsActive(cons) )
1561 {
1562 SCIP_CALL( SCIPconsActivate(cons, set, stat, -1, (stat->nnodes <= 1)) );
1563 }
1564
1565 /* if constraint is a check-constraint, lock roundings of constraint's variables */
1566 if( SCIPconsIsChecked(cons) )
1567 {
1569 }
1570 }
1571
1572 return SCIP_OKAY;
1573}
1574
1575/** releases and removes constraint from the problem; if the user has not captured the constraint for his own use, the
1576 * constraint may be invalid after the call
1577 */
1579 SCIP_PROB* prob, /**< problem data */
1580 BMS_BLKMEM* blkmem, /**< block memory */
1581 SCIP_SET* set, /**< global SCIP settings */
1582 SCIP_STAT* stat, /**< dynamic problem statistics */
1583 SCIP_CONS* cons /**< constraint to remove */
1584 )
1585{
1586 int arraypos;
1587
1588 assert(prob != NULL);
1589 assert(blkmem != NULL);
1590 assert(cons != NULL);
1591 assert(cons->addconssetchg == NULL);
1592 assert(0 <= cons->addarraypos && cons->addarraypos < prob->nconss);
1593 assert(prob->conss != NULL);
1594 assert(prob->conss[cons->addarraypos] == cons);
1595
1596 /* if the problem is the transformed problem, deactivate and unlock constraint */
1597 if( prob->transformed )
1598 {
1599 /* if constraint is a check-constraint, unlock roundings of constraint's variables */
1600 if( SCIPconsIsChecked(cons) )
1601 {
1603 }
1604
1605 /* deactivate constraint, if it is currently active */
1606 if( cons->active && !cons->updatedeactivate )
1607 {
1608 SCIP_CALL( SCIPconsDeactivate(cons, set, stat) );
1609 }
1610 }
1611 assert(!cons->active || cons->updatedeactivate);
1612 assert(!cons->enabled || cons->updatedeactivate);
1613
1614 /* remove constraint's name from the namespace */
1615 SCIP_CALL( SCIPprobRemoveConsName(prob, cons) );
1616
1617 /* remove the constraint from the problem's constraint array */
1618 arraypos = cons->addarraypos;
1619 prob->conss[arraypos] = prob->conss[prob->nconss-1];
1620 assert(prob->conss[arraypos] != NULL);
1621 assert(prob->conss[arraypos]->addconssetchg == NULL);
1622 prob->conss[arraypos]->addarraypos = arraypos;
1623 prob->nconss--;
1624 prob->consschecksorted = FALSE;
1625
1626 /* if we delete constraints then delete array origcheckconss to be sure */
1627 if( prob->origcheckconss != NULL )
1629
1630 /* mark the constraint to be no longer in the problem */
1631 cons->addarraypos = -1;
1632
1633 /* release constraint */
1634 SCIP_CALL( SCIPconsRelease(&cons, blkmem, set) );
1635
1636 return SCIP_OKAY;
1637}
1638
1639/** remembers the current number of constraints in the problem's internal data structure
1640 * - resets maximum number of constraints to current number of constraints
1641 * - remembers current number of constraints as starting number of constraints
1642 */
1644 SCIP_PROB* prob /**< problem data */
1645 )
1646{
1647 assert(prob != NULL);
1648
1649 /* remember number of constraints for statistic */
1650 prob->maxnconss = prob->nconss;
1651 prob->startnvars = prob->nvars;
1652 prob->startnconss = prob->nconss;
1653}
1654
1655/** sets objective sense: minimization or maximization */
1657 SCIP_PROB* prob, /**< problem data */
1658 SCIP_OBJSENSE objsense /**< new objective sense */
1659 )
1660{
1661 assert(prob != NULL);
1663 assert(objsense == SCIP_OBJSENSE_MAXIMIZE || objsense == SCIP_OBJSENSE_MINIMIZE);
1664
1665 prob->objsense = objsense;
1666}
1667
1668/** adds value to objective offset */
1670 SCIP_PROB* prob, /**< problem data */
1671 SCIP_Real addval /**< value to add to objective offset */
1672 )
1673{
1674 assert(prob != NULL);
1675 assert(prob->objoffsetexact == NULL);
1676
1677 SCIPdebugMessage("adding %g to real objective offset %g\n", addval, prob->objoffset);
1678
1679 prob->objoffset += addval;
1680
1681 SCIPdebugMessage("new objective offset %g\n", prob->objoffset);
1682}
1683
1684/** adds value to objective offset */
1686 SCIP_PROB* prob, /**< problem data */
1687 SCIP_RATIONAL* addval /**< value to add to objective offset */
1688 )
1689{
1690 assert(prob != NULL);
1691 assert(prob->objoffsetexact != NULL);
1692
1693 SCIPrationalDebugMessage("adding %q to exact objective offset %q\n", addval, prob->objoffsetexact);
1694
1695 SCIPrationalAdd(prob->objoffsetexact, prob->objoffsetexact, addval);
1697
1698 SCIPrationalDebugMessage("new objective offset %q\n", prob->objoffsetexact);
1699}
1700
1701/** sets the dual bound on objective function */
1703 SCIP_PROB* prob, /**< problem data */
1704 SCIP_Real dualbound /**< external dual bound */
1705 )
1706{
1707 assert(prob != NULL);
1708
1709 prob->dualbound = dualbound;
1710}
1711
1712/** sets limit on objective function, such that only solutions better than this limit are accepted */
1714 SCIP_PROB* prob, /**< problem data */
1715 SCIP_Real objlim /**< external objective limit */
1716 )
1717{
1718 assert(prob != NULL);
1719
1720 prob->objlim = objlim;
1721}
1722
1723/** informs the problem, that its objective value is always integral in every feasible solution */
1725 SCIP_PROB* prob /**< problem data */
1726 )
1727{
1728 assert(prob != NULL);
1729
1730 prob->objisintegral = TRUE;
1731}
1732
1733/** sets integral objective value flag, if all variables with non-zero objective values are integral and have
1734 * integral objective value and also updates the cutoff bound if primal solution is already known
1735 */
1736static
1738 SCIP_PROB* transprob, /**< tranformed problem data */
1739 SCIP_PROB* origprob, /**< original problem data */
1740 BMS_BLKMEM* blkmem, /**< block memory */
1741 SCIP_SET* set, /**< global SCIP settings */
1742 SCIP_STAT* stat, /**< problem statistics data */
1743 SCIP_PRIMAL* primal, /**< primal data */
1744 SCIP_TREE* tree, /**< branch and bound tree */
1745 SCIP_REOPT* reopt, /**< reoptimization data structure */
1746 SCIP_LP* lp, /**< current LP data */
1747 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1748 SCIP_EVENTFILTER* eventfilter /**< global event filter */
1749 )
1750{
1751 SCIP_RATIONAL* obj;
1752 int v;
1753
1754 assert(transprob != NULL);
1755 assert(origprob != NULL);
1756 assert(set->exact_enable);
1757
1758 /* if we know already, that the objective value is integral, nothing has to be done */
1759 if( transprob->objisintegral )
1760 return SCIP_OKAY;
1761
1762 /* if there exist unknown variables, we cannot conclude that the objective value is always integral */
1763 if( set->nactivepricers != 0 || set->nactivebenders != 0 )
1764 return SCIP_OKAY;
1765
1766 /* if the objective value offset is fractional, the value itself is possibly fractional */
1767 if( !EPSISINT(transprob->objoffset, 0.0) ) /*lint !e835*/
1768 return SCIP_OKAY;
1769
1770 /* scan through the variables */
1771 for( v = 0; v < transprob->nvars; ++v )
1772 {
1773 /* get objective value of variable */
1774 obj = SCIPvarGetObjExact(transprob->vars[v]);
1775
1776 /* check, if objective value is non-zero */
1777 if( !SCIPrationalIsZero(obj) )
1778 {
1779 /* if variable's objective value is fractional, the problem's objective value may also be fractional */
1780 if( !SCIPrationalIsIntegral(obj) )
1781 break;
1782
1783 /* if variable with non-zero objective value is continuous, the problem's objective value may be fractional */
1784 if( !SCIPvarIsIntegral(transprob->vars[v]) )
1785 break;
1786 }
1787 }
1788
1789 /* objective value is integral, if the variable loop scanned all variables */
1790 if( v == transprob->nvars )
1791 {
1792 transprob->objisintegral = TRUE;
1793
1794 /* update upper bound and cutoff bound in primal data structure due to new internality information */
1795 SCIP_CALL( SCIPprimalUpdateObjoffset(primal, blkmem, set, stat, eventqueue, eventfilter, transprob, origprob, tree, reopt, lp) );
1796 }
1797
1798 return SCIP_OKAY;
1799}
1800
1801/** sets integral objective value flag, if all variables with non-zero objective values are integral and have
1802 * integral objective value and also updates the cutoff bound if primal solution is already known
1803 */
1805 SCIP_PROB* transprob, /**< tranformed problem data */
1806 SCIP_PROB* origprob, /**< original problem data */
1807 BMS_BLKMEM* blkmem, /**< block memory */
1808 SCIP_SET* set, /**< global SCIP settings */
1809 SCIP_STAT* stat, /**< problem statistics data */
1810 SCIP_PRIMAL* primal, /**< primal data */
1811 SCIP_TREE* tree, /**< branch and bound tree */
1812 SCIP_REOPT* reopt, /**< reoptimization data structure */
1813 SCIP_LP* lp, /**< current LP data */
1814 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1815 SCIP_EVENTFILTER* eventfilter /**< global event filter */
1816 )
1817{
1818 SCIP_Real obj;
1819 int v;
1820
1821 assert(transprob != NULL);
1822 assert(origprob != NULL);
1823
1824 if( set->exact_enable )
1825 return probCheckObjIntegralExact(transprob, origprob, blkmem, set, stat, primal, tree, reopt, lp, eventqueue,
1826 eventfilter);
1827
1828 /* if we know already, that the objective value is integral, nothing has to be done */
1829 if( transprob->objisintegral )
1830 return SCIP_OKAY;
1831
1832 /* if there exist unknown variables, we cannot conclude that the objective value is always integral */
1833 if( set->nactivepricers != 0 || set->nactivebenders != 0 )
1834 return SCIP_OKAY;
1835
1836 /* if the objective value offset is fractional, the value itself is possibly fractional */
1837 if( !SCIPsetIsIntegral(set, transprob->objoffset) )
1838 return SCIP_OKAY;
1839
1840 /* scan through the variables */
1841 for( v = 0; v < transprob->nvars; ++v )
1842 {
1843 /* get objective value of variable */
1844 obj = SCIPvarGetObj(transprob->vars[v]);
1845
1846 /* check, if objective value is non-zero */
1847 if( !SCIPsetIsZero(set, obj) )
1848 {
1849 /* if variable's objective value is fractional, the problem's objective value may also be fractional */
1850 if( !SCIPsetIsIntegral(set, obj) )
1851 break;
1852
1853 /* if variable with non-zero objective value is continuous, the problem's objective value may be fractional */
1854 if( !SCIPvarIsIntegral(transprob->vars[v]) )
1855 break;
1856 }
1857 }
1858
1859 /* objective value is integral, if the variable loop scanned all variables */
1860 if( v == transprob->nvars )
1861 {
1862 transprob->objisintegral = TRUE;
1863
1864 /* update upper bound and cutoff bound in primal data structure due to new internality information */
1865 SCIP_CALL( SCIPprimalUpdateObjoffset(primal, blkmem, set, stat, eventqueue, eventfilter, transprob, origprob, tree, reopt, lp) );
1866 }
1867
1868 return SCIP_OKAY;
1869}
1870
1871
1872
1873/** update the number of variables with non-zero objective coefficient */
1875 SCIP_PROB* prob, /**< problem data */
1876 SCIP_SET* set, /**< global SCIP settings */
1877 SCIP_Real oldobj, /**< old objective value for variable */
1878 SCIP_Real newobj /**< new objective value for variable */
1879 )
1880{
1881 assert(prob->transformed);
1882
1883 if( !SCIPsetIsZero(set, oldobj) )
1884 prob->nobjvars--;
1885
1886 if( !SCIPsetIsZero(set, newobj) )
1887 prob->nobjvars++;
1888}
1889
1890/** update the dual bound if its better as the current one */
1892 SCIP_PROB* prob, /**< problem data */
1893 SCIP_Real newbound /**< new dual bound for the node (if it's tighter than the old one) */
1894 )
1895{
1896 if( prob->dualbound == SCIP_INVALID ) /*lint !e777*/
1897 SCIPprobSetDualbound(prob, newbound);
1898 else
1899 {
1900 switch( prob->objsense )
1901 {
1903 prob->dualbound = MAX(newbound, prob->dualbound);
1904 break;
1905
1907 prob->dualbound = MIN(newbound, prob->dualbound);
1908 break;
1909
1910 default:
1911 SCIPerrorMessage("invalid objective sense <%d>\n", prob->objsense);
1912 SCIPABORT();
1913 }
1914 }
1915}
1916
1917/** invalidates the dual bound */
1919 SCIP_PROB* prob /**< problem data */
1920 )
1921{
1922 assert(prob != NULL);
1923
1924 prob->dualbound = SCIP_INVALID;
1925}
1926
1927/** if possible, scales objective function such that it is integral with gcd = 1 */
1928static
1930 SCIP_PROB* transprob, /**< tranformed problem data */
1931 SCIP_PROB* origprob, /**< original problem data */
1932 BMS_BLKMEM* blkmem, /**< block memory */
1933 SCIP_SET* set, /**< global SCIP settings */
1934 SCIP_STAT* stat, /**< problem statistics data */
1935 SCIP_PRIMAL* primal, /**< primal data */
1936 SCIP_TREE* tree, /**< branch and bound tree */
1937 SCIP_REOPT* reopt, /**< reoptimization data structure */
1938 SCIP_LP* lp, /**< current LP data */
1939 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1940 SCIP_EVENTFILTER* eventfilter /**< global event filter */
1941 )
1942{
1943 int v;
1944 int nints;
1945
1946 assert(transprob != NULL);
1947 assert(set != NULL);
1948
1949 /* do not change objective if there are pricers involved */
1950 if( set->nactivepricers != 0 || set->nactivebenders != 0 || !set->misc_scaleobj )
1951 return SCIP_OKAY;
1952
1953 nints = transprob->nvars - transprob->ncontvars;
1954
1955 /* scan through the continuous variables */
1956 for( v = nints; v < transprob->nvars; ++v )
1957 {
1958 SCIP_RATIONAL* obj;
1959
1960 /* get objective value of variable; it it is non-zero, no scaling can be applied */
1961 obj = SCIPvarGetObjExact(transprob->vars[v]);
1962 if( !SCIPrationalIsZero(obj) )
1963 break;
1964 }
1965
1966 /* only continue if all continuous variables have obj = 0 */
1967 if( v == transprob->nvars )
1968 {
1969 SCIP_RATIONAL** objvals;
1970 SCIP_RATIONAL* intscalar;
1971 SCIP_Bool success;
1972
1973 /* get temporary memory */
1974 SCIP_CALL( SCIPrationalCreateBuffer(set->buffer, &intscalar) );
1975 SCIP_CALL( SCIPrationalCreateBufferArray(set->buffer, &objvals, nints) );
1976
1977 /* get objective values of integer variables */
1978 for( v = 0; v < nints; ++v )
1979 SCIPrationalSetRational(objvals[v], SCIPvarGetObjExact(transprob->vars[v]));
1980
1981 /* calculate integral scalar */
1983 intscalar, &success) );
1984
1985 SCIPrationalDebugMessage("integral objective scalar: success=%u, intscalar=%q\n", success, intscalar);
1986
1987 /* apply scaling */
1988 if( success && !SCIPrationalIsEQReal(intscalar, 1.0) )
1989 {
1990 /* calculate scaled objective values */
1991 for( v = 0; v < nints; ++v )
1992 {
1993 SCIPrationalMult(objvals[v], objvals[v], intscalar);
1994 assert(SCIPrationalIsIntegral(objvals[v]));
1995 }
1996
1997 /* change the variables' objective values and adjust objscale and objoffset */
1998 if( v == nints )
1999 {
2000 for( v = 0; v < nints; ++v )
2001 {
2002 SCIPrationalDebugMessage(" -> var <%s>: newobj = %q\n", SCIPvarGetName(transprob->vars[v]), objvals[v]);
2003 SCIP_CALL( SCIPvarChgObjExact(transprob->vars[v], blkmem, set, transprob, primal, lp->lpexact, eventqueue, objvals[v]) );
2004 }
2005 SCIPrationalMult(transprob->objoffsetexact, transprob->objoffsetexact, intscalar);
2006 SCIPrationalDiv(transprob->objscaleexact, transprob->objscaleexact, intscalar);
2007 transprob->objoffset = SCIPrationalGetReal(transprob->objoffsetexact);
2008 transprob->objscale = SCIPrationalGetReal(transprob->objscaleexact);
2009 transprob->objisintegral = TRUE;
2010 SCIPrationalDebugMessage("integral objective scalar: objscale=%q\n", transprob->objscaleexact);
2011
2012 /* update upperbound and cutoffbound in primal data structure */
2013 SCIP_CALL( SCIPprimalUpdateObjoffsetExact(primal, blkmem, set, stat, eventqueue, eventfilter, transprob, origprob, tree, reopt, lp) );
2014 }
2015 }
2016
2017 /* free temporary memory */
2018 SCIPrationalFreeBuffer(set->buffer, &intscalar);
2019 SCIPrationalFreeBufferArray(set->buffer, &objvals, nints);
2020 }
2021
2022 return SCIP_OKAY;
2023}
2024
2025/** if possible, scales objective function such that it is integral with gcd = 1 */
2027 SCIP_PROB* transprob, /**< tranformed problem data */
2028 SCIP_PROB* origprob, /**< original problem data */
2029 BMS_BLKMEM* blkmem, /**< block memory */
2030 SCIP_SET* set, /**< global SCIP settings */
2031 SCIP_STAT* stat, /**< problem statistics data */
2032 SCIP_PRIMAL* primal, /**< primal data */
2033 SCIP_TREE* tree, /**< branch and bound tree */
2034 SCIP_REOPT* reopt, /**< reoptimization data structure */
2035 SCIP_LP* lp, /**< current LP data */
2036 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2037 SCIP_EVENTFILTER* eventfilter /**< global event filter */
2038 )
2039{
2040 int v;
2041 int nints;
2042
2043 assert(transprob != NULL);
2044 assert(set != NULL);
2045
2046 /* do not change objective if there are pricers involved */
2047 if( set->nactivepricers != 0 || set->nactivebenders != 0 || !set->misc_scaleobj )
2048 return SCIP_OKAY;
2049
2050 if( set->exact_enable )
2051 {
2052 SCIP_CALL( probScaleObjExact(transprob, origprob, blkmem, set, stat, primal, tree, reopt, lp, eventqueue,
2053 eventfilter) );
2054 return SCIP_OKAY;
2055 }
2056
2057 nints = transprob->nvars - transprob->ncontvars;
2058
2059 /* scan through the continuous variables */
2060 for( v = nints; v < transprob->nvars; ++v )
2061 {
2062 SCIP_Real obj;
2063
2064 /* get objective value of variable; it it is non-zero, no scaling can be applied */
2065 obj = SCIPvarGetObj(transprob->vars[v]);
2066 if( !SCIPsetIsZero(set, obj) )
2067 break;
2068 }
2069
2070 /* only continue if all continuous variables have obj = 0 */
2071 if( v == transprob->nvars )
2072 {
2073 SCIP_Real* objvals;
2074 SCIP_Real intscalar;
2075 SCIP_Bool success;
2076
2077 /* get temporary memory */
2078 SCIP_CALL( SCIPsetAllocBufferArray(set, &objvals, nints) );
2079
2080 /* get objective values of integer variables */
2081 for( v = 0; v < nints; ++v )
2082 objvals[v] = SCIPvarGetObj(transprob->vars[v]);
2083
2084 /* calculate integral scalar */
2086 &intscalar, &success) );
2087
2088 SCIPsetDebugMsg(set, "integral objective scalar: success=%u, intscalar=%g\n", success, intscalar);
2089
2090 if( success )
2091 {
2092 SCIP_Longint gcd;
2093
2094 assert(intscalar > 0.0);
2095
2096 /* calculate gcd of resulting integral coefficients */
2097 gcd = 0;
2098 for( v = 0; v < nints && gcd != 1; ++v )
2099 {
2100 SCIP_Longint absobj;
2101
2102 /* if absobj exceeds maximum SCIP_Longint value, return */
2103 if( REALABS(objvals[v]) * intscalar + 0.5 > (SCIP_Real)SCIP_LONGINT_MAX )
2104 {
2105 SCIPsetFreeBufferArray(set, &objvals);
2106 return SCIP_OKAY;
2107 }
2108
2109 absobj = (SCIP_Longint)(REALABS(objvals[v]) * intscalar + 0.5);
2110 if( gcd == 0 )
2111 gcd = absobj;
2112 else if( absobj > 0 )
2113 gcd = SCIPcalcGreComDiv(gcd, absobj);
2114 }
2115 if( gcd != 0 )
2116 intscalar /= gcd;
2117 SCIPsetDebugMsg(set, "integral objective scalar: gcd=%" SCIP_LONGINT_FORMAT ", intscalar=%g\n", gcd, intscalar);
2118
2119 /* only apply scaling if the final scalar is small enough */
2120 if( intscalar <= OBJSCALE_MAXFINALSCALE )
2121 {
2122 /* apply scaling */
2123 if( !SCIPsetIsEQ(set, intscalar, 1.0) )
2124 {
2125 /* calculate scaled objective values */
2126 for( v = 0; v < nints; ++v )
2127 {
2128 SCIP_Real newobj;
2129
2130 /* check if new obj is really integral */
2131 newobj = intscalar * SCIPvarGetObj(transprob->vars[v]);
2132 if( !SCIPsetIsFeasIntegral(set, newobj) )
2133 break;
2134 objvals[v] = SCIPsetFeasFloor(set, newobj);
2135 }
2136
2137 /* change the variables' objective values and adjust objscale and objoffset */
2138 if( v == nints )
2139 {
2140 for( v = 0; v < nints; ++v )
2141 {
2142 SCIPsetDebugMsg(set, " -> var <%s>: newobj = %.6f\n", SCIPvarGetName(transprob->vars[v]), objvals[v]);
2143 SCIP_CALL( SCIPvarChgObj(transprob->vars[v], blkmem, set, transprob, primal, lp, eventqueue, objvals[v]) );
2144 }
2145 transprob->objoffset *= intscalar;
2146 transprob->objscale /= intscalar;
2147 transprob->objisintegral = TRUE;
2148 SCIPsetDebugMsg(set, "integral objective scalar: objscale=%g\n", transprob->objscale);
2149
2150 /* update upperbound and cutoffbound in primal data structure */
2151 SCIP_CALL( SCIPprimalUpdateObjoffset(primal, blkmem, set, stat, eventqueue, eventfilter, transprob, origprob, tree, reopt, lp) );
2152 }
2153 }
2154 }
2155 }
2156
2157 /* free temporary memory */
2158 SCIPsetFreeBufferArray(set, &objvals);
2159 }
2160
2161 return SCIP_OKAY;
2162}
2163
2164/** remembers the current solution as root solution in the problem variables */
2166 SCIP_PROB* prob, /**< problem data */
2167 SCIP_SET* set, /**< global SCIP settings */
2168 SCIP_STAT* stat, /**< SCIP statistics */
2169 SCIP_LP* lp, /**< current LP data */
2170 SCIP_Bool roothaslp /**< is the root solution from LP? */
2171 )
2172{
2173 int v;
2174
2175 assert(prob != NULL);
2176 assert(prob->transformed);
2177
2178 if( roothaslp )
2179 {
2180 for( v = 0; v < prob->nvars; ++v )
2181 SCIPvarStoreRootSol(prob->vars[v], roothaslp);
2182
2184 SCIPlpStoreRootObjval(lp, set, prob);
2185
2186 /* compute root LP best-estimate */
2188 }
2189}
2190
2191/** remembers the best solution w.r.t. root reduced cost propagation as root solution in the problem variables */
2193 SCIP_PROB* prob, /**< problem data */
2194 SCIP_SET* set, /**< global SCIP settings */
2195 SCIP_STAT* stat, /**< problem statistics */
2196 SCIP_LP* lp /**< current LP data */
2197 )
2198{
2199 SCIP_Real rootlpobjval;
2200 int v;
2201
2202 assert(prob != NULL);
2203 assert(lp != NULL);
2204 assert(prob->transformed);
2205 assert(lp->lpsolstat == SCIP_LPSOLSTAT_OPTIMAL);
2206
2207 /* in case we have a zero objective fucntion, we skip the root reduced cost update */
2208 if( SCIPprobGetNObjVars(prob, set) == 0 )
2209 return;
2210
2211 if( !SCIPlpIsDualReliable(lp) )
2212 return;
2213
2214 SCIPsetDebugMsg(set, "update root reduced costs\n");
2215
2216 /* compute current root LP objective value */
2217 rootlpobjval = SCIPlpGetObjval(lp, set, prob);
2218 assert(rootlpobjval != SCIP_INVALID); /*lint !e777*/
2219
2220 for( v = 0; v < prob->nvars; ++v )
2221 {
2222 SCIP_VAR* var;
2223 SCIP_COL* col;
2224 SCIP_Real rootsol = 0.0;
2225 SCIP_Real rootredcost = 0.0;
2226
2227 var = prob->vars[v];
2228 assert(var != NULL);
2229
2230 /* check if the variable is part of the LP */
2232 continue;
2233
2234 col = SCIPvarGetCol(var);
2235 assert(col != NULL);
2236
2238
2239 if( !SCIPvarIsBinary(var) )
2240 {
2241 rootsol = SCIPvarGetSol(var, TRUE);
2242 rootredcost = SCIPcolGetRedcost(col, stat, lp);
2243 }
2244 else
2245 {
2246 SCIP_Real primsol;
2247 SCIP_BASESTAT basestat;
2248 SCIP_Bool lpissolbasic;
2249
2250 basestat = SCIPcolGetBasisStatus(col);
2251 lpissolbasic = SCIPlpIsSolBasic(lp);
2252 primsol = SCIPcolGetPrimsol(col);
2253
2254 if( (lpissolbasic && (basestat == SCIP_BASESTAT_LOWER || basestat == SCIP_BASESTAT_UPPER)) ||
2255 (!lpissolbasic && (SCIPsetIsFeasEQ(set, SCIPvarGetLbLocal(var), primsol) ||
2256 SCIPsetIsFeasEQ(set, SCIPvarGetUbLocal(var), primsol))) )
2257 {
2258 SCIP_Real lbrootredcost;
2259 SCIP_Real ubrootredcost;
2260
2261 /* get reduced cost if the variable gets fixed to zero */
2262 lbrootredcost = SCIPvarGetImplRedcost(var, set, FALSE, stat, prob, lp);
2263 assert( !SCIPsetIsDualfeasPositive(set, lbrootredcost)
2265
2266 /* get reduced cost if the variable gets fixed to one */
2267 ubrootredcost = SCIPvarGetImplRedcost(var, set, TRUE, stat, prob, lp);
2268 assert( set->exact_enable || !SCIPsetIsDualfeasNegative(set, ubrootredcost)
2270
2271 if( -lbrootredcost > ubrootredcost )
2272 {
2273 rootredcost = lbrootredcost;
2274 rootsol = 1.0;
2275 }
2276 else
2277 {
2278 rootredcost = ubrootredcost;
2279 rootsol = 0.0;
2280 }
2281 }
2282 }
2283
2284 /* update the current solution as best root solution in the problem variables if it is better */
2285 SCIPvarUpdateBestRootSol(var, set, rootsol, rootredcost, rootlpobjval);
2286 }
2287}
2288
2289/** informs problem, that the presolving process was finished, and updates all internal data structures */ /*lint -e715*/
2291 SCIP_PROB* prob, /**< problem data */
2292 SCIP_SET* set /**< global SCIP settings */
2293 )
2294{ /*lint --e{715}*/
2295 return SCIP_OKAY;
2296}
2297
2298/** initializes problem for branch and bound process and resets all constraint's ages and histories of current run */
2300 SCIP_PROB* prob, /**< problem data */
2301 SCIP_SET* set /**< global SCIP settings */
2302 )
2303{
2304 int c;
2305 int v;
2306
2307 assert(prob != NULL);
2308 assert(prob->transformed);
2309 assert(set != NULL);
2310
2311 /* reset constraint's ages */
2312 for( c = 0; c < prob->nconss; ++c )
2313 {
2314 SCIP_CALL( SCIPconsResetAge(prob->conss[c], set) );
2315 }
2316
2317 /* initialize variables for solving */
2318 for( v = 0; v < prob->nvars; ++v )
2319 SCIPvarInitSolve(prob->vars[v]);
2320
2321 /* call user data function */
2322 if( prob->probinitsol != NULL )
2323 {
2324 SCIP_CALL( prob->probinitsol(set->scip, prob->probdata) );
2325 }
2326
2327 /* assert that the counter for variables with nonzero objective is correct */
2328 assert(prob->nobjvars == SCIPprobGetNObjVars(prob, set));
2329
2330 return SCIP_OKAY;
2331}
2332
2333/** deinitializes problem after branch and bound process, and converts all COLUMN variables back into LOOSE variables */
2335 SCIP_PROB* prob, /**< problem data */
2336 BMS_BLKMEM* blkmem, /**< block memory */
2337 SCIP_SET* set, /**< global SCIP settings */
2338 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
2339 SCIP_LP* lp, /**< current LP data */
2340 SCIP_Bool restart /**< was this exit solve call triggered by a restart? */
2341 )
2342{
2343 SCIP_VAR* var;
2344 int v;
2345
2346 assert(prob != NULL);
2347 assert(prob->transformed);
2348 assert(set != NULL);
2349
2350 /* call user data function */
2351 if( prob->probexitsol != NULL )
2352 {
2353 SCIP_CALL( prob->probexitsol(set->scip, prob->probdata, restart) );
2354 }
2355
2356 /* - convert all COLUMN variables back into LOOSE variables
2357 * - mark relaxation-only variables for deletion, if possible and restarting
2358 * - initPresolve will then call SCIPprobPerformVarDeletions
2359 * - if no restart, then the whole transformed problem will be deleted anyway
2360 */
2361 if( prob->ncolvars > 0 || restart )
2362 {
2363 for( v = 0; v < prob->nvars; ++v )
2364 {
2365 var = prob->vars[v];
2367 {
2368 SCIP_CALL( SCIPvarLoose(var, blkmem, set, eventqueue, prob, lp) );
2369 }
2370
2371 /* invalidate root reduced cost, root reduced solution, and root LP objective value for each variable */
2372 SCIPvarSetBestRootSol(var, 0.0, 0.0, SCIP_INVALID);
2373
2374 if( SCIPvarIsRelaxationOnly(var) && restart )
2375 {
2376 /* relaxation variables should be unlocked and only captured by prob at this moment */
2377 assert(SCIPvarGetNLocksDown(var) == 0);
2378 assert(SCIPvarGetNLocksUp(var) == 0);
2379 assert(SCIPvarGetNUses(var) == 1);
2380
2381 if( SCIPvarIsDeletable(var) )
2382 {
2383 SCIP_Bool deleted;
2384
2385 SCIPsetDebugMsg(set, "queue relaxation-only variable <%s> for deletion\n", SCIPvarGetName(var));
2386 SCIP_CALL( SCIPprobDelVar(prob, blkmem, set, eventqueue, var, &deleted) );
2387 assert(deleted);
2388 }
2389 else
2390 {
2391 SCIPsetDebugMsg(set, "cannot queue relaxation-only variable <%s> for deletion because it is marked non-deletable\n", SCIPvarGetName(var));
2392 }
2393 }
2394 }
2395 }
2396 assert(prob->ncolvars == 0);
2397
2398 return SCIP_OKAY;
2399}
2400
2401
2402
2403
2404/*
2405 * problem information
2406 */
2407
2408/** sets problem name */
2410 SCIP_PROB* prob, /**< problem data */
2411 const char* name /**< name to be set */
2412 )
2413{
2414 assert(prob != NULL);
2415
2416 BMSfreeMemoryArray(&(prob->name));
2417 SCIP_ALLOC( BMSduplicateMemoryArray(&(prob->name), name, strlen(name)+1) );
2418
2419 return SCIP_OKAY;
2420}
2421
2422/** returns the number of variables with non-zero objective coefficient */
2424 SCIP_PROB* prob, /**< problem data */
2425 SCIP_SET* set /**< global SCIP settings */
2426 )
2427{
2428 if( prob->transformed )
2429 {
2430 /* this is much too expensive, to check it in each debug run */
2431#ifdef SCIP_MORE_DEBUG
2432 int nobjvars;
2433 int v;
2434
2435 nobjvars = 0;
2436
2437 for( v = prob->nvars - 1; v >= 0; --v )
2438 {
2439 if( !SCIPsetIsZero(set, SCIPvarGetObj(prob->vars[v])) )
2440 nobjvars++;
2441 }
2442
2443 /* check that the internal count is correct */
2444 assert(prob->nobjvars == nobjvars);
2445#endif
2446 return prob->nobjvars;
2447 }
2448 else
2449 {
2450 int nobjvars;
2451 int v;
2452
2453 nobjvars = 0;
2454
2455 for( v = prob->nvars - 1; v >= 0; --v )
2456 {
2457 if( !SCIPsetIsZero(set, SCIPvarGetObj(prob->vars[v])) )
2458 nobjvars++;
2459 }
2460 return nobjvars;
2461 }
2462}
2463
2464/** returns the minimal absolute non-zero objective coefficient
2465 *
2466 * @note currently, this is only used for statistics and printed after the solving process. if this information is
2467 * needed during the (pre)solving process this should be implemented more efficiently, e.g., updating the minimal
2468 * absolute non-zero coefficient every time an objective coefficient has changed.
2469 */
2471 SCIP_PROB* prob, /**< problem data */
2472 SCIP_SET* set /**< global SCIP settings */
2473 )
2474{
2475 SCIP_Real absmin;
2476 int v;
2477
2478 absmin = SCIPsetInfinity(set);
2479
2480 for( v = 0; v < prob->nvars; v++ )
2481 {
2482 SCIP_Real objcoef = SCIPvarGetObj(prob->vars[v]);
2483
2484 if( !SCIPsetIsZero(set, objcoef) && SCIPsetIsLT(set, REALABS(objcoef), absmin) )
2485 absmin = REALABS(objcoef);
2486 }
2487
2488 return absmin;
2489}
2490
2491/** returns the maximal absolute non-zero objective coefficient
2492 *
2493 * @note currently, this is only used for statistics and printed after the solving process. if this information is
2494 * needed during the (pre)solving process this should be implemented more efficiently, e.g., updating the maximal
2495 * absolute non-zero coefficient every time an objective coefficient has changed.
2496 */
2498 SCIP_PROB* prob, /**< problem data */
2499 SCIP_SET* set /**< global SCIP settings */
2500 )
2501{
2502 SCIP_Real absmax;
2503 int v;
2504
2505 absmax = -SCIPsetInfinity(set);
2506
2507 for( v = 0; v < prob->nvars; v++ )
2508 {
2509 SCIP_Real objcoef = SCIPvarGetObj(prob->vars[v]);
2510
2511 if( !SCIPsetIsZero(set, objcoef) && SCIPsetIsGT(set, REALABS(objcoef), absmax) )
2512 absmax = REALABS(objcoef);
2513 }
2514
2515 return absmax;
2516}
2517
2518
2519/** returns the external value of the given internal objective value */
2521 SCIP_PROB* transprob, /**< tranformed problem data */
2522 SCIP_PROB* origprob, /**< original problem data */
2523 SCIP_SET* set, /**< global SCIP settings */
2524 SCIP_Real objval /**< internal objective value */
2525 )
2526{
2527 assert(set != NULL);
2528 assert(origprob != NULL);
2529 assert(transprob != NULL);
2530 assert(transprob->transformed);
2531 assert(transprob->objscale > 0.0);
2532 assert(origprob->objoffsetexact == NULL || origprob->objoffset == SCIPrationalGetReal(origprob->objoffsetexact)); /*lint !e777*/
2533 assert(origprob->objscaleexact == NULL || origprob->objscale == SCIPrationalGetReal(origprob->objscaleexact)); /*lint !e777*/
2534 assert(transprob->objoffsetexact == NULL || transprob->objoffset == SCIPrationalGetReal(transprob->objoffsetexact)); /*lint !e777*/
2535 assert(transprob->objscaleexact == NULL || transprob->objscale == SCIPrationalGetReal(transprob->objscaleexact)); /*lint !e777*/
2536
2537 if( SCIPsetIsInfinity(set, objval) )
2538 return (SCIP_Real)transprob->objsense * SCIPsetInfinity(set);
2539 else if( SCIPsetIsInfinity(set, -objval) )
2540 return -(SCIP_Real)transprob->objsense * SCIPsetInfinity(set);
2541 else
2542 return (SCIP_Real)transprob->objsense * transprob->objscale * (objval + transprob->objoffset) + origprob->objoffset;
2543}
2544
2545/** returns the external value of the given internal objective value */
2547 SCIP_PROB* transprob, /**< tranformed problem data */
2548 SCIP_PROB* origprob, /**< original problem data */
2549 SCIP_SET* set, /**< global SCIP settings */
2550 SCIP_RATIONAL* objval, /**< internal objective value */
2551 SCIP_RATIONAL* objvalext /**< store external objective value */
2552 )
2553{
2554 assert(set != NULL);
2555 assert(origprob != NULL);
2556 assert(transprob != NULL);
2557 assert(transprob->transformed);
2558 assert(SCIPrationalIsPositive(transprob->objscaleexact));
2559 assert(set->exact_enable);
2560
2561 if( SCIPrationalIsAbsInfinity(objval) )
2562 SCIPrationalMultReal(objvalext, objval, (SCIP_Real)transprob->objsense);
2563 else
2564 {
2565 SCIPrationalAdd(objvalext, objval, transprob->objoffsetexact);
2566 SCIPrationalMult(objvalext, objvalext, transprob->objscaleexact);
2567 SCIPrationalMultReal(objvalext, objvalext, (SCIP_Real)transprob->objsense);
2568 SCIPrationalAdd(objvalext, objvalext, origprob->objoffsetexact);
2569 }
2570}
2571
2572/** returns the internal value of the given external objective value */
2574 SCIP_PROB* transprob, /**< tranformed problem data */
2575 SCIP_PROB* origprob, /**< original problem data */
2576 SCIP_SET* set, /**< global SCIP settings */
2577 SCIP_Real objval /**< external objective value */
2578 )
2579{
2580 assert(set != NULL);
2581 assert(origprob != NULL);
2582 assert(transprob != NULL);
2583 assert(transprob->transformed);
2584 assert(transprob->objscale > 0.0);
2585 assert(origprob->objoffsetexact == NULL || origprob->objoffset == SCIPrationalGetReal(origprob->objoffsetexact)); /*lint !e777*/
2586 assert(origprob->objscaleexact == NULL || origprob->objscale == SCIPrationalGetReal(origprob->objscaleexact)); /*lint !e777*/
2587 assert(transprob->objoffsetexact == NULL || transprob->objoffset == SCIPrationalGetReal(transprob->objoffsetexact)); /*lint !e777*/
2588 assert(transprob->objscaleexact == NULL || transprob->objscale == SCIPrationalGetReal(transprob->objscaleexact)); /*lint !e777*/
2589
2590 if( SCIPsetIsInfinity(set, objval) )
2591 return (SCIP_Real)transprob->objsense * SCIPsetInfinity(set);
2592 else if( SCIPsetIsInfinity(set, -objval) )
2593 return -(SCIP_Real)transprob->objsense * SCIPsetInfinity(set);
2594 else
2595 return (SCIP_Real)transprob->objsense * (objval - origprob->objoffset) / transprob->objscale - transprob->objoffset;
2596}
2597
2598/** returns the internal value of the given external objective value */
2600 SCIP_PROB* transprob, /**< tranformed problem data */
2601 SCIP_PROB* origprob, /**< original problem data */
2602 SCIP_SET* set, /**< global SCIP settings */
2603 SCIP_RATIONAL* objval, /**< internal objective value */
2604 SCIP_RATIONAL* objvalint /**< store internal objective value */
2605 )
2606{
2607 assert(set != NULL);
2608 assert(origprob != NULL);
2609 assert(transprob != NULL);
2610 assert(transprob->transformed);
2611 assert(SCIPrationalIsPositive(transprob->objscaleexact));
2612 assert(set->exact_enable);
2613
2614 if( SCIPrationalIsAbsInfinity(objval) )
2615 SCIPrationalMultReal(objvalint, objval, (SCIP_Real)transprob->objsense);
2616 else
2617 {
2618 SCIPrationalDiff(objvalint, objval, origprob->objoffsetexact);
2619 SCIPrationalDiv(objvalint, objvalint, transprob->objscaleexact);
2620 SCIPrationalMultReal(objvalint, objvalint, (SCIP_Real)transprob->objsense);
2621 SCIPrationalDiff(objvalint, objvalint, transprob->objoffsetexact);
2622 }
2623}
2624
2625/** returns variable of the problem with given name */
2627 SCIP_PROB* prob, /**< problem data */
2628 const char* name /**< name of variable to find */
2629 )
2630{
2631 assert(prob != NULL);
2632 assert(name != NULL);
2633
2634 if( prob->varnames == NULL )
2635 {
2636 SCIPerrorMessage("Cannot find variable if variable-names hashtable was disabled (due to parameter <misc/usevartable>)\n");
2637 SCIPABORT();/*lint --e{527}*/ /* only in debug mode */
2638 return NULL;
2639 }
2640
2641 return (SCIP_VAR*)(SCIPhashtableRetrieve(prob->varnames, (char*)name));
2642}
2643
2644/** returns constraint of the problem with given name */
2646 SCIP_PROB* prob, /**< problem data */
2647 const char* name /**< name of variable to find */
2648 )
2649{
2650 assert(prob != NULL);
2651 assert(name != NULL);
2652
2653 if( prob->consnames == NULL )
2654 {
2655 SCIPerrorMessage("Cannot find constraint if constraint-names hashtable was disabled (due to parameter <misc/useconstable>)\n");
2656 SCIPABORT();/*lint --e{527}*/ /* only in debug mode */
2657 return NULL;
2658 }
2659
2660 return (SCIP_CONS*)(SCIPhashtableRetrieve(prob->consnames, (char*)name));
2661}
2662
2663/** displays current pseudo solution */
2665 SCIP_PROB* prob, /**< problem data */
2666 SCIP_SET* set, /**< global SCIP settings */
2667 SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
2668 )
2669{
2670 SCIP_VAR* var;
2671 SCIP_Real solval;
2672 int v;
2673
2674 for( v = 0; v < prob->nvars; ++v )
2675 {
2676 var = prob->vars[v];
2677 assert(var != NULL);
2678 solval = SCIPvarGetPseudoSol(var);
2679 if( !SCIPsetIsZero(set, solval) )
2680 SCIPmessagePrintInfo(messagehdlr, " <%s>=%.15g", SCIPvarGetName(var), solval);
2681 }
2682 SCIPmessagePrintInfo(messagehdlr, "\n");
2683}
2684
2685/** outputs problem statistics */
2687 SCIP_PROB* prob, /**< problem data */
2688 SCIP_SET* set, /**< global SCIP settings */
2689 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
2690 FILE* file /**< output file (or NULL for standard output) */
2691 )
2692{
2693 assert(prob != NULL);
2694
2695 SCIPmessageFPrintInfo(messagehdlr, file, " Problem name : %s\n", prob->name);
2696 SCIPmessageFPrintInfo(messagehdlr, file, " Variables : %d (%d binary, %d integer, %d continuous)\n",
2697 prob->nvars, prob->nbinvars + prob->nbinimplvars, prob->nintvars + prob->nintimplvars, prob->ncontvars + prob->ncontimplvars);
2698 SCIPmessageFPrintInfo(messagehdlr, file, " Implied int vars : %d (%d binary, %d integer, %d continuous)\n",
2699 SCIPprobGetNImplVars(prob), prob->nbinimplvars, prob->nintimplvars, prob->ncontimplvars);
2700 SCIPmessageFPrintInfo(messagehdlr, file, " Constraints : %d initial, %d maximal\n", prob->startnconss, prob->maxnconss);
2701 SCIPmessageFPrintInfo(messagehdlr, file, " Objective : %s, %d non-zeros (abs.min = %g, abs.max = %g)\n",
2702 !prob->transformed ? (prob->objsense == SCIP_OBJSENSE_MINIMIZE ? "minimize" : "maximize") : "minimize",
2704}
2705
2706
2707/** collects problem statistics in a SCIP_DATATREE object */
2709 SCIP_PROB* prob, /**< problem data */
2710 BMS_BLKMEM* blkmem, /**< block memory */
2711 SCIP_SET* set, /**< global SCIP settings */
2712 SCIP_DATATREE* datatree /**< data tree */
2713 )
2714{
2715 assert(prob != NULL);
2716 assert(datatree != NULL);
2717
2718 /* collect problem name */
2719 SCIP_CALL( SCIPdatatreeInsertString(datatree, set, blkmem, "problem_name", prob->name) );
2720
2721 /* collect variables information */
2722 SCIP_CALL( SCIPdatatreeInsertLong(datatree, set, blkmem, "num_variables", (SCIP_Longint)prob->nvars) );
2723 SCIP_CALL( SCIPdatatreeInsertLong(datatree, set, blkmem, "num_binary_variables", (SCIP_Longint)prob->nbinvars) );
2724 SCIP_CALL( SCIPdatatreeInsertLong(datatree, set, blkmem, "num_integer_variables", (SCIP_Longint)prob->nintvars) );
2725 SCIP_CALL( SCIPdatatreeInsertLong(datatree, set, blkmem, "num_implied_binary_variables", (SCIP_Longint)prob->nbinimplvars) );
2726 SCIP_CALL( SCIPdatatreeInsertLong(datatree, set, blkmem, "num_implied_integer_variables", (SCIP_Longint)prob->nintimplvars) );
2727 SCIP_CALL( SCIPdatatreeInsertLong(datatree, set, blkmem, "num_implied_continuous_variables", (SCIP_Longint)prob->ncontimplvars) );
2728 SCIP_CALL( SCIPdatatreeInsertLong(datatree, set, blkmem, "num_continuous_variables", (SCIP_Longint)prob->ncontvars) );
2729
2730 /* collect constraints information */
2731 SCIP_CALL( SCIPdatatreeInsertLong(datatree, set, blkmem, "num_initial_constraints", (SCIP_Longint)prob->startnconss) );
2732 SCIP_CALL( SCIPdatatreeInsertLong(datatree, set, blkmem, "num_maximal_constraints", (SCIP_Longint)prob->maxnconss) );
2733
2734 /* collect objective information */
2735 SCIP_CALL( SCIPdatatreeInsertString(datatree, set, blkmem, "objective_sense",
2736 !prob->transformed ? (prob->objsense == SCIP_OBJSENSE_MINIMIZE ? "minimize" : "maximize") : "minimize") );
2737 SCIP_CALL( SCIPdatatreeInsertLong(datatree, set, blkmem, "objective_non_zeros", (SCIP_Longint)SCIPprobGetNObjVars(prob, set)) );
2738 SCIP_CALL( SCIPdatatreeInsertReal(datatree, set, blkmem, "objective_abs_min", SCIPprobGetAbsMinObjCoef(prob, set)) );
2739 SCIP_CALL( SCIPdatatreeInsertReal(datatree, set, blkmem, "objective_abs_max", SCIPprobGetAbsMaxObjCoef(prob, set)) );
2740
2741 return SCIP_OKAY;
2742}
2743
2744
2745#ifndef NDEBUG
2746
2747/* In debug mode, the following methods are implemented as function calls to ensure
2748 * type validity.
2749 * In optimized mode, the methods are implemented as defines to improve performance.
2750 * However, we want to have them in the library anyways, so we have to undef the defines.
2751 */
2752
2753#undef SCIPprobIsPermuted
2754#undef SCIPprobMarkPermuted
2755#undef SCIPprobIsTransformed
2756#undef SCIPprobIsObjIntegral
2757#undef SCIPprobAllColsInLP
2758#undef SCIPprobGetObjlim
2759#undef SCIPprobGetData
2760#undef SCIPprobGetName
2761#undef SCIPprobGetNVars
2762#undef SCIPprobGetNBinVars
2763#undef SCIPprobGetNIntVars
2764#undef SCIPprobGetNImplVars
2765#undef SCIPprobGetNContVars
2766#undef SCIPprobGetVars
2767#undef SCIPprobGetNFixedVars
2768#undef SCIPprobGetFixedVars
2769#undef SCIPprobGetStartNVars
2770#undef SCIPprobGetNConss
2771#undef SCIPprobGetConss
2772#undef SCIPprobGetMaxNConss
2773#undef SCIPprobGetStartNConss
2774#undef SCIPprobGetObjsense
2775#undef SCIPprobGetObjoffset
2776#undef SCIPprobGetObjscale
2777#undef SCIPprobGetObjoffsetExact
2778#undef SCIPprobGetObjscaleExact
2779#undef SCIPisConsCompressedEnabled
2780#undef SCIPprobEnableConsCompression
2781
2782/** is the problem permuted */
2784 SCIP_PROB* prob
2785 )
2786{
2787 assert(prob != NULL);
2788
2789 return prob->permuted;
2790}
2791
2792/** mark the problem as permuted */
2794 SCIP_PROB* prob
2795 )
2796{
2797 assert(prob != NULL);
2798
2799 prob->permuted = TRUE;
2800}
2801
2802/** is the problem data transformed */
2804 SCIP_PROB* prob /**< problem data */
2805 )
2806{
2807 assert(prob != NULL);
2808
2809 return prob->transformed;
2810}
2811
2812/** returns whether the objective value is known to be integral in every feasible solution */
2814 SCIP_PROB* prob /**< problem data */
2815 )
2816{
2817 assert(prob != NULL);
2818
2819 return prob->objisintegral;
2820}
2821
2822/** returns TRUE iff all columns, i.e. every variable with non-empty column w.r.t. all ever created rows, are present
2823 * in the LP, and FALSE, if there are additional already existing columns, that may be added to the LP in pricing
2824 */
2826 SCIP_PROB* prob, /**< problem data */
2827 SCIP_SET* set, /**< global SCIP settings */
2828 SCIP_LP* lp /**< current LP data */
2829 )
2830{
2831 assert(SCIPlpGetNCols(lp) <= prob->ncolvars && prob->ncolvars <= prob->nvars);
2832
2833 return (SCIPlpGetNCols(lp) == prob->ncolvars && set->nactivepricers == 0);
2834}
2835
2836/** gets limit on objective function in external space */
2838 SCIP_PROB* prob, /**< problem data */
2839 SCIP_SET* set /**< global SCIP settings */
2840 )
2841{
2842 assert(prob != NULL);
2843 assert(set != NULL);
2844
2845 return prob->objlim >= SCIP_INVALID ? (SCIP_Real)(prob->objsense) * SCIPsetInfinity(set) : prob->objlim;
2846}
2847
2848/** gets user problem data */
2850 SCIP_PROB* prob /**< problem */
2851 )
2852{
2853 assert(prob != NULL);
2854
2855 return prob->probdata;
2856}
2857
2858/** gets problem name */
2860 SCIP_PROB* prob /**< problem data */
2861 )
2862{
2863 assert(prob != NULL);
2864 return prob->name;
2865}
2866
2867/** gets number of problem variables */
2869 SCIP_PROB* prob /**< problem data */
2870 )
2871{
2872 assert(prob != NULL);
2873 return prob->nvars;
2874}
2875
2876/** gets number of binary problem variables */
2878 SCIP_PROB* prob /**< problem data */
2879 )
2880{
2881 assert(prob != NULL);
2882 return prob->nbinvars;
2883}
2884
2885/** gets number of integer problem variables */
2887 SCIP_PROB* prob /**< problem data */
2888 )
2889{
2890 assert(prob != NULL);
2891 return prob->nintvars;
2892}
2893
2894/** gets number of implied integral problem variables of any type */
2896 SCIP_PROB* prob /**< problem data */
2897 )
2898{
2899 assert(prob != NULL);
2900 return prob->nbinimplvars + prob->nintimplvars + prob->ncontimplvars;
2901}
2902
2903/** gets number of continuous problem variables */
2905 SCIP_PROB* prob /**< problem data */
2906 )
2907{
2908 assert(prob != NULL);
2909 return prob->ncontvars;
2910}
2911
2912/** gets problem variables */
2914 SCIP_PROB* prob /**< problem data */
2915 )
2916{
2917 assert(prob != NULL);
2918 return prob->vars;
2919}
2920
2921/** gets number of fixed variables */
2923 SCIP_PROB* prob /**< problem data */
2924 )
2925{
2926 assert(prob != NULL);
2927 return prob->nfixedvars;
2928}
2929
2930/** gets fixed variables */
2932 SCIP_PROB* prob /**< problem data */
2933 )
2934{
2935 assert(prob != NULL);
2936 return prob->fixedvars;
2937}
2938
2939/** gets number of variables existing when problem solving started */
2941 SCIP_PROB* prob /**< problem data */
2942 )
2943{
2944 assert(prob != NULL);
2945 return prob->startnvars;
2946}
2947
2948/** gets number of problem constraints */
2950 SCIP_PROB* prob /**< problem data */
2951 )
2952{
2953 assert(prob != NULL);
2954 return prob->nconss;
2955}
2956
2957/** gets problem constraints */
2959 SCIP_PROB* prob /**< problem data */
2960 )
2961{
2962 assert(prob != NULL);
2963 return prob->conss;
2964}
2965
2966/** gets maximum number of constraints existing at the same time */
2968 SCIP_PROB* prob /**< problem data */
2969 )
2970{
2971 assert(prob != NULL);
2972 return prob->maxnconss;
2973}
2974
2975/** gets number of constraints existing when problem solving started */
2977 SCIP_PROB* prob /**< problem data */
2978 )
2979{
2980 assert(prob != NULL);
2981 return prob->startnconss;
2982}
2983
2984/** gets the objective sense*/
2986 SCIP_PROB* prob /**< problem data */
2987 )
2988{
2989 assert(prob != NULL);
2990 return prob->objsense;
2991}
2992
2993/** gets the objective offset */
2995 SCIP_PROB* prob /**< problem data */
2996 )
2997{
2998 assert(prob != NULL);
2999
3000 return prob->objoffset;
3001}
3002
3003/** gets the objective scalar */
3005 SCIP_PROB* prob /**< problem data */
3006 )
3007{
3008 assert(prob != NULL);
3009
3010 return prob->objscale;
3011}
3012
3013/** gets the exact objective offset */
3015 SCIP_PROB* prob /**< problem data */
3016 )
3017{
3018 assert(prob != NULL);
3019 assert(prob->objoffsetexact != NULL);
3020
3021 return prob->objoffsetexact;
3022}
3023
3024/** gets the exact objective scalar */
3026 SCIP_PROB* prob /**< problem data */
3027 )
3028{
3029 assert(prob != NULL);
3030 assert(prob->objscaleexact != NULL);
3031
3032 return prob->objscaleexact;
3033}
3034
3035/** is constraint compression enabled for this problem? */
3037 SCIP_PROB* prob /**< problem data */
3038 )
3039{
3040 assert(prob != NULL);
3041
3042 return prob->conscompression;
3043}
3044
3045/** enable problem compression, i.e., constraints can reduce memory size by removing fixed variables during creation */
3047 SCIP_PROB* prob /**< problem data */
3048 )
3049{
3050 assert(prob != NULL);
3051
3052 prob->conscompression = TRUE;
3053}
3054
3055#endif
SCIP_RETCODE SCIPbranchcandRemoveVar(SCIP_BRANCHCAND *branchcand, SCIP_VAR *var)
Definition: branch.c:1152
SCIP_RETCODE SCIPbranchcandUpdateVar(SCIP_BRANCHCAND *branchcand, SCIP_SET *set, SCIP_VAR *var)
Definition: branch.c:1169
internal methods for branching rules and branching candidate storage
SCIP_VAR * h
Definition: circlepacking.c:68
SCIP_RETCODE SCIPconflictstoreTransform(SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_PROB *transprob, SCIP_REOPT *reopt)
internal methods for storing conflicts
SCIP_RETCODE SCIPconsAddLocks(SCIP_CONS *cons, SCIP_SET *set, SCIP_LOCKTYPE locktype, int nlockspos, int nlocksneg)
Definition: cons.c:7553
void SCIPconsCapture(SCIP_CONS *cons)
Definition: cons.c:6427
void SCIPconsSetLocal(SCIP_CONS *cons, SCIP_Bool local)
Definition: cons.c:6949
SCIP_RETCODE SCIPconsDeactivate(SCIP_CONS *cons, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:7073
SCIP_RETCODE SCIPconshdlrLockVars(SCIP_CONSHDLR *conshdlr, SCIP_SET *set)
Definition: cons.c:4276
SCIP_RETCODE SCIPconsResetAge(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:7452
SCIP_RETCODE SCIPconsTransform(SCIP_CONS *origcons, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_CONS **transcons)
Definition: cons.c:6712
SCIP_RETCODE SCIPconsRelease(SCIP_CONS **cons, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:6439
SCIP_RETCODE SCIPconshdlrUnlockVars(SCIP_CONSHDLR *conshdlr, SCIP_SET *set)
Definition: cons.c:4296
SCIP_RETCODE SCIPconsActivate(SCIP_CONS *cons, SCIP_SET *set, SCIP_STAT *stat, int depth, SCIP_Bool focusnode)
Definition: cons.c:7031
SCIP_RETCODE SCIPconshdlrDelVars(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:4240
internal methods for constraints and constraint handlers
SCIP_RETCODE SCIPdatatreeInsertLong(SCIP_DATATREE *datatree, SCIP_SET *set, BMS_BLKMEM *blkmem, const char *name, SCIP_Longint value)
Definition: datatree.c:223
SCIP_RETCODE SCIPdatatreeInsertString(SCIP_DATATREE *datatree, SCIP_SET *set, BMS_BLKMEM *blkmem, const char *name, const char *value)
Definition: datatree.c:285
SCIP_RETCODE SCIPdatatreeInsertReal(SCIP_DATATREE *datatree, SCIP_SET *set, BMS_BLKMEM *blkmem, const char *name, SCIP_Real value)
Definition: datatree.c:254
internal methods for handling data trees
#define NULL
Definition: def.h:248
#define SCIP_MAXSTRLEN
Definition: def.h:269
#define SCIP_Longint
Definition: def.h:141
#define EPSISINT(x, eps)
Definition: def.h:195
#define SCIP_INVALID
Definition: def.h:178
#define SCIP_Bool
Definition: def.h:91
#define SCIP_HASHSIZE_NAMES_SMALL
Definition: def.h:283
#define MIN(x, y)
Definition: def.h:224
#define SCIP_ALLOC(x)
Definition: def.h:366
#define SCIP_Real
Definition: def.h:156
#define SCIP_HASHSIZE_NAMES
Definition: def.h:280
#define TRUE
Definition: def.h:93
#define FALSE
Definition: def.h:94
#define MAX(x, y)
Definition: def.h:220
#define SCIP_LONGINT_FORMAT
Definition: def.h:148
#define SCIPABORT()
Definition: def.h:327
#define REALABS(x)
Definition: def.h:182
#define SCIP_LONGINT_MAX
Definition: def.h:142
#define SCIP_CALL(x)
Definition: def.h:355
SCIP_RETCODE SCIPeventCreateVarAdded(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var)
Definition: event.c:598
SCIP_RETCODE SCIPeventqueueAdd(SCIP_EVENTQUEUE *eventqueue, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter, SCIP_EVENT **event)
Definition: event.c:2561
SCIP_RETCODE SCIPeventCreateVarDeleted(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var)
Definition: event.c:616
internal methods for managing events
void SCIPhashtableFree(SCIP_HASHTABLE **hashtable)
Definition: misc.c:2348
SCIP_Bool SCIPhashtableExists(SCIP_HASHTABLE *hashtable, void *element)
Definition: misc.c:2647
SCIP_RETCODE SCIPhashtableCreate(SCIP_HASHTABLE **hashtable, BMS_BLKMEM *blkmem, int tablesize, SCIP_DECL_HASHGETKEY((*hashgetkey)), SCIP_DECL_HASHKEYEQ((*hashkeyeq)), SCIP_DECL_HASHKEYVAL((*hashkeyval)), void *userptr)
Definition: misc.c:2298
void * SCIPhashtableRetrieve(SCIP_HASHTABLE *hashtable, void *key)
Definition: misc.c:2596
SCIP_RETCODE SCIPhashtableRemove(SCIP_HASHTABLE *hashtable, void *element)
Definition: misc.c:2665
SCIP_RETCODE SCIPhashtableInsert(SCIP_HASHTABLE *hashtable, void *element)
Definition: misc.c:2535
SCIP_Longint SCIPcalcGreComDiv(SCIP_Longint val1, SCIP_Longint val2)
Definition: misc.c:9197
SCIP_RETCODE SCIPcalcIntegralScalarExact(BMS_BUFMEM *buffer, SCIP_RATIONAL **vals, int nvals, SCIP_Real maxscale, SCIP_RATIONAL *intscalar, SCIP_Bool *success)
Definition: misc.c:9842
SCIP_RETCODE SCIPcalcIntegralScalar(SCIP_Real *vals, int nvals, SCIP_Real mindelta, SCIP_Real maxdelta, SCIP_Longint maxdnom, SCIP_Real maxscale, SCIP_Real *intscalar, SCIP_Bool *success)
Definition: misc.c:9641
SCIP_Real SCIPcolGetPrimsol(SCIP_COL *col)
Definition: lp.c:17379
SCIP_BASESTAT SCIPcolGetBasisStatus(SCIP_COL *col)
Definition: lp.c:17414
SCIP_Bool SCIPconshdlrNeedsCons(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:5302
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:8588
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
Definition: cons.c:8450
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8389
SCIP_RETCODE SCIPrationalCreateBlock(BMS_BLKMEM *blkmem, SCIP_RATIONAL **rational)
Definition: rational.cpp:108
void SCIPrationalMult(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:1066
void SCIPrationalAdd(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:935
SCIP_Real SCIPrationalGetReal(SCIP_RATIONAL *rational)
Definition: rational.cpp:2085
void SCIPrationalFreeBlock(BMS_BLKMEM *mem, SCIP_RATIONAL **rational)
Definition: rational.cpp:461
#define SCIPrationalDebugMessage
Definition: rational.h:641
void SCIPrationalDiv(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:1132
SCIP_Bool SCIPrationalIsAbsInfinity(SCIP_RATIONAL *rational)
Definition: rational.cpp:1680
void SCIPrationalSetReal(SCIP_RATIONAL *res, SCIP_Real real)
Definition: rational.cpp:603
void SCIPrationalFreeBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
Definition: rational.cpp:473
void SCIPrationalDiff(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:983
SCIP_Bool SCIPrationalIsPositive(SCIP_RATIONAL *rational)
Definition: rational.cpp:1640
SCIP_RETCODE SCIPrationalCreateBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
Definition: rational.cpp:123
SCIP_Bool SCIPrationalIsZero(SCIP_RATIONAL *rational)
Definition: rational.cpp:1624
void SCIPrationalSetRational(SCIP_RATIONAL *res, SCIP_RATIONAL *src)
Definition: rational.cpp:569
SCIP_Bool SCIPrationalIsIntegral(SCIP_RATIONAL *rational)
Definition: rational.cpp:1691
SCIP_Bool SCIPrationalIsEQReal(SCIP_RATIONAL *rat, SCIP_Real real)
Definition: rational.cpp:1437
SCIP_RETCODE SCIPrationalCreateBufferArray(BMS_BUFMEM *mem, SCIP_RATIONAL ***rational, int size)
Definition: rational.cpp:214
void SCIPrationalMultReal(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_Real op2)
Definition: rational.cpp:1097
void SCIPrationalFreeBufferArray(BMS_BUFMEM *mem, SCIP_RATIONAL ***ratbufarray, int size)
Definition: rational.cpp:518
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:23683
SCIP_Real SCIPvarGetSol(SCIP_VAR *var, SCIP_Bool getlpval)
Definition: var.c:19007
SCIP_VAR * SCIPvarGetNegatedVar(SCIP_VAR *var)
Definition: var.c:23868
SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
Definition: var.c:23478
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:23386
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:24268
int SCIPvarGetNLocksDown(SCIP_VAR *var)
Definition: var.c:4449
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:23900
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:23453
void SCIPvarSetBestRootSol(SCIP_VAR *var, SCIP_Real rootsol, SCIP_Real rootredcost, SCIP_Real rootlpobjval)
Definition: var.c:19612
int SCIPvarGetNUses(SCIP_VAR *var)
Definition: var.c:23277
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:23662
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:23267
SCIP_Bool SCIPvarIsDeletable(SCIP_VAR *var)
Definition: var.c:23632
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:23490
SCIP_Bool SCIPvarIsTransformedOrigvar(SCIP_VAR *var)
Definition: var.c:18497
SCIP_Real SCIPvarGetPseudoSol(SCIP_VAR *var)
Definition: var.c:24756
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:24234
SCIP_Bool SCIPvarIsRelaxationOnly(SCIP_VAR *var)
Definition: var.c:23600
SCIP_IMPLINTTYPE SCIPvarGetImplType(SCIP_VAR *var)
Definition: var.c:23463
int SCIPvarGetNLocksUp(SCIP_VAR *var)
Definition: var.c:4462
SCIP_RATIONAL * SCIPvarGetObjExact(SCIP_VAR *var)
Definition: var.c:23910
void SCIPsortPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10827
SCIP_Bool SCIPlpIsSolBasic(SCIP_LP *lp)
Definition: lp.c:18241
SCIP_LPSOLSTAT SCIPlpGetSolstat(SCIP_LP *lp)
Definition: lp.c:13420
void SCIPlpStoreRootObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:13495
SCIP_Real SCIPlpGetColumnObjval(SCIP_LP *lp)
Definition: lp.c:13464
SCIP_RETCODE SCIPlpUpdateAddVar(SCIP_LP *lp, SCIP_SET *set, SCIP_VAR *var)
Definition: lp.c:14384
SCIP_Bool SCIPlpIsRelax(SCIP_LP *lp)
Definition: lp.c:18201
SCIP_Real SCIPlpGetObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:13436
SCIP_RETCODE SCIPlpUpdateDelVar(SCIP_LP *lp, SCIP_SET *set, SCIP_VAR *var)
Definition: lp.c:14405
SCIP_Real SCIPcolGetRedcost(SCIP_COL *col, SCIP_STAT *stat, SCIP_LP *lp)
Definition: lp.c:4147
SCIP_Bool SCIPlpIsDualReliable(SCIP_LP *lp)
Definition: lp.c:18231
int SCIPlpGetNCols(SCIP_LP *lp)
Definition: lp.c:17979
void SCIPlpSetRootLPIsRelax(SCIP_LP *lp, SCIP_Bool isrelax)
Definition: lp.c:18123
internal methods for LP management
SCIP_RETCODE SCIPlpExactUpdateAddVar(SCIP_LPEXACT *lpexact, SCIP_SET *set, SCIP_VAR *var)
Definition: lpexact.c:6603
internal methods for exact LP management
#define BMSfreeMemory(ptr)
Definition: memory.h:145
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:127
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:143
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:147
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:437
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:148
#define BMSallocMemory(ptr)
Definition: memory.h:118
void SCIPmessageFPrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:451
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:618
void SCIPmessagePrintInfo(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:594
SCIP_RETCODE SCIPprimalUpdateObjoffsetExact(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp)
Definition: primal.c:646
SCIP_RETCODE SCIPprimalUpdateObjoffset(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp)
Definition: primal.c:590
internal methods for collecting primal CIP solutions and primal informations
static SCIP_RETCODE probScaleObjExact(SCIP_PROB *transprob, SCIP_PROB *origprob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter)
Definition: prob.c:1929
void SCIPprobPrintStatistics(SCIP_PROB *prob, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, FILE *file)
Definition: prob.c:2686
SCIP_RETCODE SCIPprobCollectStatistics(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_DATATREE *datatree)
Definition: prob.c:2708
static SCIP_RETCODE probRemoveVar(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_CLIQUETABLE *cliquetable, SCIP_SET *set, SCIP_VAR *var, SCIP_Bool isupgraded)
Definition: prob.c:929
static SCIP_RETCODE probEnsureVarsMem(SCIP_PROB *prob, SCIP_SET *set, int num)
Definition: prob.c:72
SCIP_Bool SCIPprobIsPermuted(SCIP_PROB *prob)
Definition: prob.c:2783
SCIP_RETCODE SCIPprobExitPresolve(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:2290
void SCIPprobSetTrans(SCIP_PROB *prob, SCIP_DECL_PROBTRANS((*probtrans)))
Definition: prob.c:379
void SCIPprobUpdateNObjVars(SCIP_PROB *prob, SCIP_SET *set, SCIP_Real oldobj, SCIP_Real newobj)
Definition: prob.c:1874
int SCIPprobGetNContVars(SCIP_PROB *prob)
Definition: prob.c:2904
SCIP_RETCODE SCIPprobAddConsName(SCIP_PROB *prob, SCIP_CONS *cons)
Definition: prob.c:1470
SCIP_RETCODE SCIPprobTransform(SCIP_PROB *source, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_CONFLICTSTORE *conflictstore, SCIP_PROB **target)
Definition: prob.c:553
void SCIPprobSetInitsol(SCIP_PROB *prob, SCIP_DECL_PROBINITSOL((*probinitsol)))
Definition: prob.c:401
SCIP_CONS ** SCIPprobGetConss(SCIP_PROB *prob)
Definition: prob.c:2958
int SCIPprobGetNFixedVars(SCIP_PROB *prob)
Definition: prob.c:2922
static SCIP_RETCODE probCheckObjIntegralExact(SCIP_PROB *transprob, SCIP_PROB *origprob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter)
Definition: prob.c:1737
void SCIPprobInvalidateDualbound(SCIP_PROB *prob)
Definition: prob.c:1918
SCIP_RETCODE SCIPprobAddVarName(SCIP_PROB *prob, SCIP_VAR *var)
Definition: prob.c:1065
void SCIPprobInternObjvalExact(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_RATIONAL *objval, SCIP_RATIONAL *objvalint)
Definition: prob.c:2599
void SCIPprobSetObjIntegral(SCIP_PROB *prob)
Definition: prob.c:1724
SCIP_RETCODE SCIPprobVarChangedStatus(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_BRANCHCAND *branchcand, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var)
Definition: prob.c:1412
const char * SCIPprobGetName(SCIP_PROB *prob)
Definition: prob.c:2859
static int probProvidePos(SCIP_PROB *prob, SCIP_VARTYPE vartype, SCIP_IMPLINTTYPE impltype)
Definition: prob.c:792
SCIP_Real SCIPprobGetObjoffset(SCIP_PROB *prob)
Definition: prob.c:2994
int SCIPprobGetNConss(SCIP_PROB *prob)
Definition: prob.c:2949
int SCIPprobGetNObjVars(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:2423
SCIP_Real SCIPprobGetAbsMinObjCoef(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:2470
static SCIP_RETCODE probEnsureConssMem(SCIP_PROB *prob, SCIP_SET *set, int num)
Definition: prob.c:144
static void probInsertVar(SCIP_PROB *prob, SCIP_VAR *var)
Definition: prob.c:887
SCIP_RETCODE SCIPprobPerformVarDeletions(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand)
Definition: prob.c:1233
void SCIPprobSetExitsol(SCIP_PROB *prob, SCIP_DECL_PROBEXITSOL((*probexitsol)))
Definition: prob.c:412
SCIP_Real SCIPprobGetAbsMaxObjCoef(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:2497
SCIP_RETCODE SCIPprobRemoveVarName(SCIP_PROB *prob, SCIP_VAR *var)
Definition: prob.c:1081
static SCIP_RETCODE probEnsureFixedvarsMem(SCIP_PROB *prob, SCIP_SET *set, int num)
Definition: prob.c:96
int SCIPprobGetStartNConss(SCIP_PROB *prob)
Definition: prob.c:2976
SCIP_Real SCIPprobGetObjlim(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:2837
void SCIPprobUpdateDualbound(SCIP_PROB *prob, SCIP_Real newbound)
Definition: prob.c:1891
SCIP_RETCODE SCIPprobInitSolve(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:2299
void SCIPprobMarkNConss(SCIP_PROB *prob)
Definition: prob.c:1643
SCIP_RATIONAL * SCIPprobGetObjoffsetExact(SCIP_PROB *prob)
Definition: prob.c:3014
SCIP_OBJSENSE SCIPprobGetObjsense(SCIP_PROB *prob)
Definition: prob.c:2985
void SCIPprobPrintPseudoSol(SCIP_PROB *prob, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr)
Definition: prob.c:2664
int SCIPprobGetStartNVars(SCIP_PROB *prob)
Definition: prob.c:2940
#define OBJSCALE_MAXSCALE
Definition: prob.c:61
SCIP_RETCODE SCIPprobSetName(SCIP_PROB *prob, const char *name)
Definition: prob.c:2409
void SCIPprobSetDeltrans(SCIP_PROB *prob, SCIP_DECL_PROBDELTRANS((*probdeltrans)))
Definition: prob.c:390
void SCIPprobSetData(SCIP_PROB *prob, SCIP_PROBDATA *probdata)
Definition: prob.c:778
#define OBJSCALE_MAXFINALSCALE
Definition: prob.c:62
SCIP_Real SCIPprobGetObjscale(SCIP_PROB *prob)
Definition: prob.c:3004
void SCIPprobAddObjoffset(SCIP_PROB *prob, SCIP_Real addval)
Definition: prob.c:1669
SCIP_RETCODE SCIPprobChgVarImplType(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var, SCIP_IMPLINTTYPE impltype)
Definition: prob.c:1358
void SCIPprobSetCopy(SCIP_PROB *prob, SCIP_DECL_PROBCOPY((*probcopy)))
Definition: prob.c:423
SCIP_VAR * SCIPprobFindVar(SCIP_PROB *prob, const char *name)
Definition: prob.c:2626
int SCIPprobGetNImplVars(SCIP_PROB *prob)
Definition: prob.c:2895
static SCIP_Bool varHasName(SCIP_VAR *var)
Definition: prob.c:186
SCIP_RETCODE SCIPprobExitSolve(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp, SCIP_Bool restart)
Definition: prob.c:2334
SCIP_RETCODE SCIPprobCreate(SCIP_PROB **prob, BMS_BLKMEM *blkmem, SCIP_SET *set, const char *name, SCIP_DECL_PROBDELORIG((*probdelorig)), SCIP_DECL_PROBTRANS((*probtrans)), SCIP_DECL_PROBDELTRANS((*probdeltrans)), SCIP_DECL_PROBINITSOL((*probinitsol)), SCIP_DECL_PROBEXITSOL((*probexitsol)), SCIP_DECL_PROBCOPY((*probcopy)), SCIP_PROBDATA *probdata, SCIP_Bool transformed)
Definition: prob.c:272
void SCIPprobSetObjlim(SCIP_PROB *prob, SCIP_Real objlim)
Definition: prob.c:1713
SCIP_VAR ** SCIPprobGetFixedVars(SCIP_PROB *prob)
Definition: prob.c:2931
SCIP_RETCODE SCIPprobDelVar(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *var, SCIP_Bool *deleted)
Definition: prob.c:1171
SCIP_Bool SCIPprobIsObjIntegral(SCIP_PROB *prob)
Definition: prob.c:2813
SCIP_RETCODE SCIPprobAddVar(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_VAR *var)
Definition: prob.c:1096
void SCIPprobEnableConsCompression(SCIP_PROB *prob)
Definition: prob.c:3046
SCIP_CONS * SCIPprobFindCons(SCIP_PROB *prob, const char *name)
Definition: prob.c:2645
#define OBJSCALE_MAXDNOM
Definition: prob.c:60
void SCIPprobMarkPermuted(SCIP_PROB *prob)
Definition: prob.c:2793
SCIP_RETCODE SCIPprobRemoveConsName(SCIP_PROB *prob, SCIP_CONS *cons)
Definition: prob.c:1485
int SCIPprobGetNIntVars(SCIP_PROB *prob)
Definition: prob.c:2886
SCIP_RETCODE SCIPprobDelCons(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons)
Definition: prob.c:1578
int SCIPprobGetNVars(SCIP_PROB *prob)
Definition: prob.c:2868
SCIP_PROBDATA * SCIPprobGetData(SCIP_PROB *prob)
Definition: prob.c:2849
SCIP_RETCODE SCIPprobChgVarType(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTQUEUE *eventqueue, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var, SCIP_VARTYPE vartype)
Definition: prob.c:1304
static SCIP_RETCODE probEnsureDeletedvarsMem(SCIP_PROB *prob, SCIP_SET *set, int num)
Definition: prob.c:120
SCIP_Real SCIPprobExternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2520
void SCIPprobResortVars(SCIP_PROB *prob)
Definition: prob.c:684
SCIP_RETCODE SCIPprobFree(SCIP_PROB **prob, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: prob.c:434
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:208
SCIP_RETCODE SCIPprobScaleObj(SCIP_PROB *transprob, SCIP_PROB *origprob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter)
Definition: prob.c:2026
SCIP_RETCODE SCIPprobAddCons(SCIP_PROB *prob, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons)
Definition: prob.c:1507
SCIP_RETCODE SCIPprobCheckObjIntegral(SCIP_PROB *transprob, SCIP_PROB *origprob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter)
Definition: prob.c:1804
int SCIPprobGetMaxNConss(SCIP_PROB *prob)
Definition: prob.c:2967
SCIP_RETCODE SCIPprobResetBounds(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: prob.c:658
void SCIPprobSetDualbound(SCIP_PROB *prob, SCIP_Real dualbound)
Definition: prob.c:1702
void SCIPprobStoreRootSol(SCIP_PROB *prob, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp, SCIP_Bool roothaslp)
Definition: prob.c:2165
int SCIPprobGetNBinVars(SCIP_PROB *prob)
Definition: prob.c:2877
SCIP_RATIONAL * SCIPprobGetObjscaleExact(SCIP_PROB *prob)
Definition: prob.c:3025
SCIP_VAR ** SCIPprobGetVars(SCIP_PROB *prob)
Definition: prob.c:2913
void SCIPprobSetDelorig(SCIP_PROB *prob, SCIP_DECL_PROBDELORIG((*probdelorig)))
Definition: prob.c:368
SCIP_Bool SCIPprobAllColsInLP(SCIP_PROB *prob, SCIP_SET *set, SCIP_LP *lp)
Definition: prob.c:2825
void SCIPprobUpdateBestRootSol(SCIP_PROB *prob, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp)
Definition: prob.c:2192
static SCIP_Bool consHasName(SCIP_CONS *cons)
Definition: prob.c:173
SCIP_Bool SCIPprobIsTransformed(SCIP_PROB *prob)
Definition: prob.c:2803
void SCIPprobExternObjvalExact(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_RATIONAL *objval, SCIP_RATIONAL *objvalext)
Definition: prob.c:2546
SCIP_Bool SCIPprobIsConsCompressionEnabled(SCIP_PROB *prob)
Definition: prob.c:3036
void SCIPprobAddObjoffsetExact(SCIP_PROB *prob, SCIP_RATIONAL *addval)
Definition: prob.c:1685
void SCIPprobSetObjsense(SCIP_PROB *prob, SCIP_OBJSENSE objsense)
Definition: prob.c:1656
SCIP_Real SCIPprobInternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2573
SCIP_RETCODE SCIPprobSortConssCheck(SCIP_PROB *prob)
Definition: prob.c:748
internal methods for storing and manipulating the main problem
public methods for managing constraints
public methods for LP management
public methods for message output
#define SCIPerrorMessage
Definition: pub_message.h:64
#define SCIPdebugMessage
Definition: pub_message.h:96
public data structures and miscellaneous methods
methods for sorting joint arrays of various types
public methods for problem variables
wrapper for rational number arithmetic
SCIP_Bool SCIPsetIsFeasEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6945
SCIP_Real SCIPsetFeasFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:7124
SCIP_Bool SCIPsetIsDualfeasNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:7314
SCIP_Real SCIPsetEpsilon(SCIP_SET *set)
Definition: set.c:6402
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6537
SCIP_STAGE SCIPsetGetStage(SCIP_SET *set)
Definition: set.c:3197
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:6380
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6557
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6515
SCIP_Bool SCIPsetIsDualfeasPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:7303
SCIP_Bool SCIPsetIsGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6597
SCIP_Bool SCIPsetIsIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6670
SCIP_Bool SCIPsetIsZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6637
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:6080
SCIP_Bool SCIPsetIsFeasIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:7098
internal methods for global SCIP settings
#define SCIPsetFreeBufferArray(set, ptr)
Definition: set.h:1782
#define SCIPsetAllocBufferArray(set, ptr, num)
Definition: set.h:1775
#define SCIPsetDebugMsg
Definition: set.h:1811
void SCIPstatComputeRootLPBestEstimate(SCIP_STAT *stat, SCIP_SET *set, SCIP_Real rootlpobjval, SCIP_VAR **vars, int nvars)
Definition: stat.c:839
internal methods for problem statistics
unsigned int enabled
Definition: struct_cons.h:91
int addarraypos
Definition: struct_cons.h:56
SCIP_CONSSETCHG * addconssetchg
Definition: struct_cons.h:54
char * name
Definition: struct_cons.h:49
unsigned int deleted
Definition: struct_cons.h:94
SCIP * scip
Definition: struct_cons.h:111
unsigned int updatedeactivate
Definition: struct_cons.h:98
unsigned int active
Definition: struct_cons.h:85
SCIP_LPEXACT * lpexact
Definition: struct_lp.h:309
SCIP_LPSOLSTAT lpsolstat
Definition: struct_lp.h:359
int ncontimplvars
Definition: struct_prob.h:79
int deletedvarssize
Definition: struct_prob.h:84
SCIP_VAR ** fixedvars
Definition: struct_prob.h:68
int consssize
Definition: struct_prob.h:87
int ncolvars
Definition: struct_prob.h:81
SCIP_Real objoffset
Definition: struct_prob.h:50
SCIP_Bool consschecksorted
Definition: struct_prob.h:97
SCIP_Bool permuted
Definition: struct_prob.h:96
SCIP_Bool nlpenabled
Definition: struct_prob.h:95
int startnconss
Definition: struct_prob.h:91
SCIP_RATIONAL * objoffsetexact
Definition: struct_prob.h:53
SCIP_Bool transformed
Definition: struct_prob.h:94
int fixedvarssize
Definition: struct_prob.h:82
int ncontvars
Definition: struct_prob.h:80
int ndeletedvars
Definition: struct_prob.h:85
SCIP_CONS ** origcheckconss
Definition: struct_prob.h:72
SCIP_RATIONAL * objscaleexact
Definition: struct_prob.h:54
SCIP_Real dualbound
Definition: struct_prob.h:57
SCIP_PROBDATA * probdata
Definition: struct_prob.h:65
int nfixedvars
Definition: struct_prob.h:83
int startnvars
Definition: struct_prob.h:90
SCIP_OBJSENSE objsense
Definition: struct_prob.h:92
SCIP_CONS ** conss
Definition: struct_prob.h:71
int nbinimplvars
Definition: struct_prob.h:77
int nobjvars
Definition: struct_prob.h:86
SCIP_Bool objisintegral
Definition: struct_prob.h:93
SCIP_Real objscale
Definition: struct_prob.h:51
SCIP_HASHTABLE * consnames
Definition: struct_prob.h:70
int nintimplvars
Definition: struct_prob.h:78
SCIP_Bool conscompression
Definition: struct_prob.h:98
SCIP_VAR ** vars
Definition: struct_prob.h:67
int varssize
Definition: struct_prob.h:73
SCIP_Real objlim
Definition: struct_prob.h:56
char * name
Definition: struct_prob.h:58
int nintvars
Definition: struct_prob.h:76
int nconss
Definition: struct_prob.h:88
SCIP_HASHTABLE * varnames
Definition: struct_prob.h:66
int maxnconss
Definition: struct_prob.h:89
SCIP_VAR ** deletedvars
Definition: struct_prob.h:69
int nbinvars
Definition: struct_prob.h:75
SCIP_Longint nactiveconssadded
Definition: struct_stat.h:126
SCIP_Longint nnodes
Definition: struct_stat.h:84
SCIP * scip
Definition: struct_var.h:345
int probindex
Definition: struct_var.h:311
datastructures for constraints and constraint handlers
data structures for LP management
datastructures for storing and manipulating the main problem
datastructures for global SCIP settings
datastructures for problem statistics
datastructures for problem variables
Definition: heur_padm.c:135
@ SCIP_LPSOLSTAT_OPTIMAL
Definition: type_lp.h:44
@ SCIP_BASESTAT_UPPER
Definition: type_lpi.h:93
@ SCIP_BASESTAT_LOWER
Definition: type_lpi.h:91
enum SCIP_BaseStat SCIP_BASESTAT
Definition: type_lpi.h:96
#define SCIP_DECL_PROBCOPY(x)
Definition: type_prob.h:150
#define SCIP_DECL_PROBDELTRANS(x)
Definition: type_prob.h:95
#define SCIP_DECL_PROBEXITSOL(x)
Definition: type_prob.h:119
struct SCIP_ProbData SCIP_PROBDATA
Definition: type_prob.h:53
@ SCIP_OBJSENSE_MAXIMIZE
Definition: type_prob.h:47
@ SCIP_OBJSENSE_MINIMIZE
Definition: type_prob.h:48
#define SCIP_DECL_PROBDELORIG(x)
Definition: type_prob.h:64
#define SCIP_DECL_PROBTRANS(x)
Definition: type_prob.h:83
#define SCIP_DECL_PROBINITSOL(x)
Definition: type_prob.h:106
enum SCIP_Objsense SCIP_OBJSENSE
Definition: type_prob.h:50
@ SCIP_DIDNOTRUN
Definition: type_result.h:42
@ SCIP_SUCCESS
Definition: type_result.h:58
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:61
@ SCIP_INVALIDRESULT
Definition: type_retcode.h:53
@ SCIP_INVALIDDATA
Definition: type_retcode.h:52
@ SCIP_OKAY
Definition: type_retcode.h:42
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
@ SCIP_STAGE_SOLVING
Definition: type_set.h:53
@ SCIP_STAGE_TRANSFORMING
Definition: type_set.h:46
enum SCIP_ImplintType SCIP_IMPLINTTYPE
Definition: type_var.h:117
@ SCIP_IMPLINTTYPE_NONE
Definition: type_var.h:90
@ SCIP_VARTYPE_INTEGER
Definition: type_var.h:65
@ SCIP_VARTYPE_CONTINUOUS
Definition: type_var.h:71
@ SCIP_VARTYPE_BINARY
Definition: type_var.h:64
@ SCIP_VARSTATUS_ORIGINAL
Definition: type_var.h:51
@ SCIP_VARSTATUS_FIXED
Definition: type_var.h:54
@ SCIP_VARSTATUS_COLUMN
Definition: type_var.h:53
@ SCIP_VARSTATUS_MULTAGGR
Definition: type_var.h:56
@ SCIP_VARSTATUS_NEGATED
Definition: type_var.h:57
@ SCIP_VARSTATUS_AGGREGATED
Definition: type_var.h:55
@ SCIP_VARSTATUS_LOOSE
Definition: type_var.h:52
@ SCIP_LOCKTYPE_MODEL
Definition: type_var.h:141
enum SCIP_Vartype SCIP_VARTYPE
Definition: type_var.h:73
SCIP_RETCODE SCIPvarResetBounds(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: var.c:14534
SCIP_RETCODE SCIPvarChgObj(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PROB *prob, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_Real newobj)
Definition: var.c:9419
SCIP_Real SCIPvarGetImplRedcost(SCIP_VAR *var, SCIP_SET *set, SCIP_Bool varfixing, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_LP *lp)
Definition: var.c:19233
void SCIPvarInitSolve(SCIP_VAR *var)
Definition: var.c:3846
SCIP_RETCODE SCIPvarTransform(SCIP_VAR *origvar, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_OBJSENSE objsense, SCIP_VAR **transvar)
Definition: var.c:4494
SCIP_RETCODE SCIPvarRelease(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: var.c:3787
SCIP_RETCODE SCIPvarRemove(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_CLIQUETABLE *cliquetable, SCIP_SET *set, SCIP_Bool final, SCIP_Bool keepimplics)
Definition: var.c:9122
void SCIPvarCapture(SCIP_VAR *var)
Definition: var.c:3762
void SCIPvarStoreRootSol(SCIP_VAR *var, SCIP_Bool roothaslp)
Definition: var.c:19034
SCIP_RETCODE SCIPvarChgType(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_VARTYPE vartype)
Definition: var.c:9242
void SCIPvarUpdateBestRootSol(SCIP_VAR *var, SCIP_SET *set, SCIP_Real rootsol, SCIP_Real rootredcost, SCIP_Real rootlpobjval)
Definition: var.c:19045
SCIP_RETCODE SCIPvarChgImplType(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_IMPLINTTYPE impltype)
Definition: var.c:9301
void SCIPvarMarkDeleted(SCIP_VAR *var)
Definition: var.c:9159
SCIP_RETCODE SCIPvarLoose(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *prob, SCIP_LP *lp)
Definition: var.c:4680
SCIP_RETCODE SCIPvarCopyExactData(BMS_BLKMEM *blkmem, SCIP_VAR *targetvar, SCIP_VAR *sourcevar, SCIP_Bool negateobj)
Definition: var.c:2686
void SCIPvarSetProbindex(SCIP_VAR *var, int probindex)
Definition: var.c:9087
SCIP_RETCODE SCIPvarChgObjExact(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PROB *prob, SCIP_PRIMAL *primal, SCIP_LPEXACT *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_RATIONAL *newobj)
Definition: var.c:9494
internal methods for problem variables