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-2016 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file prob.c
17  * @brief Methods and datastructures for storing and manipulating the main problem
18  * @author Tobias Achterberg
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #include <assert.h>
24 #include <string.h>
25 
26 #include "scip/def.h"
27 #include "scip/set.h"
28 #include "scip/stat.h"
29 #include "scip/event.h"
30 #include "scip/lp.h"
31 #include "scip/var.h"
32 #include "scip/prob.h"
33 #include "scip/primal.h"
34 #include "scip/tree.h"
35 #include "scip/reopt.h"
36 #include "scip/branch.h"
37 #include "scip/cons.h"
38 #include "scip/pub_message.h"
39 #include "scip/pub_misc.h"
40 
41 
42 #define OBJSCALE_MAXDNOM 1000000LL /**< maximal denominator in objective integral scaling */
43 #define OBJSCALE_MAXSCALE 1000000.0 /**< maximal scalar to reach objective integrality */
44 #define OBJSCALE_MAXFINALSCALE 1000.0 /**< maximal final value to apply as scaling */
45 
46 
47 
48 /*
49  * dymanic memory arrays
50  */
51 
52 /** resizes vars array to be able to store at least num entries */
53 static
55  SCIP_PROB* prob, /**< problem data */
56  SCIP_SET* set, /**< global SCIP settings */
57  int num /**< minimal number of slots in array */
58  )
59 {
60  assert(prob != NULL);
61  assert(set != NULL);
62 
63  if( num > prob->varssize )
64  {
65  int newsize;
66 
67  newsize = SCIPsetCalcMemGrowSize(set, num);
68  SCIP_ALLOC( BMSreallocMemoryArray(&prob->vars, newsize) );
69  prob->varssize = newsize;
70  }
71  assert(num <= prob->varssize);
72 
73  return SCIP_OKAY;
74 }
75 
76 /** resizes fixedvars array to be able to store at least num entries */
77 static
79  SCIP_PROB* prob, /**< problem data */
80  SCIP_SET* set, /**< global SCIP settings */
81  int num /**< minimal number of slots in array */
82  )
83 {
84  assert(prob != NULL);
85  assert(set != NULL);
86 
87  if( num > prob->fixedvarssize )
88  {
89  int newsize;
90 
91  newsize = SCIPsetCalcMemGrowSize(set, num);
92  SCIP_ALLOC( BMSreallocMemoryArray(&prob->fixedvars, newsize) );
93  prob->fixedvarssize = newsize;
94  }
95  assert(num <= prob->fixedvarssize);
96 
97  return SCIP_OKAY;
98 }
99 
100 /** resizes deletedvars array to be able to store at least num entries */
101 static
103  SCIP_PROB* prob, /**< problem data */
104  SCIP_SET* set, /**< global SCIP settings */
105  int num /**< minimal number of slots in array */
106  )
107 {
108  assert(prob != NULL);
109  assert(set != NULL);
110 
111  if( num > prob->deletedvarssize )
112  {
113  int newsize;
114 
115  newsize = SCIPsetCalcMemGrowSize(set, num);
116  SCIP_ALLOC( BMSreallocMemoryArray(&prob->deletedvars, newsize) );
117  prob->deletedvarssize = newsize;
118  }
119  assert(num <= prob->deletedvarssize);
120 
121  return SCIP_OKAY;
122 }
123 
124 /** resizes conss array to be able to store at least num entries */
125 static
127  SCIP_PROB* prob, /**< problem data */
128  SCIP_SET* set, /**< global SCIP settings */
129  int num /**< minimal number of slots in array */
130  )
131 {
132  assert(prob != NULL);
133  assert(set != NULL);
134 
135  if( num > prob->consssize )
136  {
137  int newsize;
138 
139  newsize = SCIPsetCalcMemGrowSize(set, num);
140  SCIP_ALLOC( BMSreallocMemoryArray(&prob->conss, newsize) );
141  prob->consssize = newsize;
142  }
143  assert(num <= prob->consssize);
144 
145  return SCIP_OKAY;
146 }
147 
148 /** returns whether the constraint has a name */
149 static
151  SCIP_CONS* cons /**< constraint */
152  )
153 {
154  const char* name;
155 
156  name = SCIPconsGetName(cons);
157 
158  return (name != NULL && name[0] != '\0');
159 }
160 
161 /** returns whether the variable has a name */
162 static
164  SCIP_VAR* var /**< variable */
165  )
166 {
167  const char* name;
168 
169  name = SCIPvarGetName(var);
170 
171  return (name != NULL && name[0] != '\0');
172 }
173 
174 
175 
176 /*
177  * problem creation
178  */
179 
180 /** creates problem data structure by copying the source problem;
181  * If the problem type requires the use of variable pricers, these pricers should be activated with calls
182  * to SCIPactivatePricer(). These pricers are automatically deactivated, when the problem is freed.
183  */
185  SCIP_PROB** prob, /**< pointer to problem data structure */
186  BMS_BLKMEM* blkmem, /**< block memory */
187  SCIP_SET* set, /**< global SCIP settings */
188  const char* name, /**< problem name */
189  SCIP* sourcescip, /**< source SCIP data structure */
190  SCIP_PROB* sourceprob, /**< source problem structure */
191  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
192  * target variables */
193  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
194  * target constraints */
195  SCIP_Bool global /**< create a global or a local copy? */
196  )
197 {
198  SCIP_PROBDATA* targetdata;
199  SCIP_RESULT result;
200 
201  assert(prob != NULL);
202  assert(set != NULL);
203  assert(blkmem != NULL);
204  assert(sourcescip != NULL);
205  assert(sourceprob != NULL);
206  assert(varmap != NULL);
207  assert(consmap != NULL);
208 
209  result = SCIP_DIDNOTRUN;
210  targetdata = NULL;
211 
212  /* create problem and initialize callbacks with NULL */
213  SCIP_CALL( SCIPprobCreate(prob, blkmem, set, name, NULL, NULL, NULL, NULL, NULL, NULL, NULL, FALSE) );
214 
215  /* call user copy callback method */
216  if( sourceprob->probdata != NULL && sourceprob->probcopy != NULL )
217  {
218  SCIP_CALL( sourceprob->probcopy(set->scip, sourcescip, sourceprob->probdata, varmap, consmap, &targetdata, global, &result) );
219 
220  /* evaluate result */
221  if( result != SCIP_DIDNOTRUN && result != SCIP_SUCCESS )
222  {
223  SCIPerrorMessage("probdata copying method returned invalid result <%d>\n", result);
224  return SCIP_INVALIDRESULT;
225  }
226 
227  assert(targetdata == NULL || result == SCIP_SUCCESS);
228  }
229 
230  /* if copying was successful, add data and callbacks */
231  if( result == SCIP_SUCCESS )
232  {
233  assert( targetdata != NULL );
234  (*prob)->probdelorig = sourceprob->probdelorig;
235  (*prob)->probtrans = sourceprob->probtrans;
236  (*prob)->probdeltrans = sourceprob->probdeltrans;
237  (*prob)->probinitsol = sourceprob->probinitsol;
238  (*prob)->probexitsol = sourceprob->probexitsol;
239  (*prob)->probcopy = sourceprob->probcopy;
240  (*prob)->probdata = targetdata;
241  }
242 
243  return SCIP_OKAY;
244 }
245 
246 /** creates problem data structure
247  * If the problem type requires the use of variable pricers, these pricers should be activated with calls
248  * to SCIPactivatePricer(). These pricers are automatically deactivated, when the problem is freed.
249  */
251  SCIP_PROB** prob, /**< pointer to problem data structure */
252  BMS_BLKMEM* blkmem, /**< block memory */
253  SCIP_SET* set, /**< global SCIP settings */
254  const char* name, /**< problem name */
255  SCIP_DECL_PROBDELORIG ((*probdelorig)), /**< frees user data of original problem */
256  SCIP_DECL_PROBTRANS ((*probtrans)), /**< creates user data of transformed problem by transforming original user data */
257  SCIP_DECL_PROBDELTRANS((*probdeltrans)), /**< frees user data of transformed problem */
258  SCIP_DECL_PROBINITSOL ((*probinitsol)), /**< solving process initialization method of transformed data */
259  SCIP_DECL_PROBEXITSOL ((*probexitsol)), /**< solving process deinitialization method of transformed data */
260  SCIP_DECL_PROBCOPY ((*probcopy)), /**< copies user data if you want to copy it to a subscip, or NULL */
261  SCIP_PROBDATA* probdata, /**< user problem data set by the reader */
262  SCIP_Bool transformed /**< is this the transformed problem? */
263  )
264 {
265  assert(prob != NULL);
266 
267  SCIP_ALLOC( BMSallocMemory(prob) );
268  SCIP_ALLOC( BMSduplicateMemoryArray(&(*prob)->name, name, strlen(name)+1) );
269 
270  (*prob)->probdata = probdata;
271  (*prob)->probcopy = probcopy;
272  (*prob)->probdelorig = probdelorig;
273  (*prob)->probtrans = probtrans;
274  (*prob)->probdeltrans = probdeltrans;
275  (*prob)->probinitsol = probinitsol;
276  (*prob)->probexitsol = probexitsol;
277  if( set->misc_usevartable )
278  {
279  SCIP_CALL( SCIPhashtableCreate(&(*prob)->varnames, blkmem,
280  (set->misc_usesmalltables ? SCIP_HASHSIZE_NAMES_SMALL : SCIP_HASHSIZE_NAMES),
281  SCIPhashGetKeyVar, SCIPhashKeyEqString, SCIPhashKeyValString, NULL) );
282  }
283  else
284  (*prob)->varnames = NULL;
285  (*prob)->vars = NULL;
286  (*prob)->varssize = 0;
287  (*prob)->nvars = 0;
288  (*prob)->nbinvars = 0;
289  (*prob)->nintvars = 0;
290  (*prob)->nimplvars = 0;
291  (*prob)->ncontvars = 0;
292  (*prob)->ncolvars = 0;
293  (*prob)->fixedvars = NULL;
294  (*prob)->fixedvarssize = 0;
295  (*prob)->nfixedvars = 0;
296  (*prob)->deletedvars = NULL;
297  (*prob)->deletedvarssize = 0;
298  (*prob)->ndeletedvars = 0;
299  (*prob)->nobjvars = 0;
300  if( set->misc_useconstable )
301  {
302  SCIP_CALL( SCIPhashtableCreate(&(*prob)->consnames, blkmem,
303  (set->misc_usesmalltables ? SCIP_HASHSIZE_NAMES_SMALL : SCIP_HASHSIZE_NAMES),
304  SCIPhashGetKeyCons, SCIPhashKeyEqString, SCIPhashKeyValString, NULL) );
305  }
306  else
307  (*prob)->consnames = NULL;
308  (*prob)->conss = NULL;
309  (*prob)->consssize = 0;
310  (*prob)->nconss = 0;
311  (*prob)->maxnconss = 0;
312  (*prob)->startnvars = 0;
313  (*prob)->startnconss = 0;
314  (*prob)->objsense = SCIP_OBJSENSE_MINIMIZE;
315  (*prob)->objoffset = 0.0;
316  (*prob)->objscale = 1.0;
317  (*prob)->objlim = SCIP_INVALID;
318  (*prob)->dualbound = SCIP_INVALID;
319  (*prob)->objisintegral = FALSE;
320  (*prob)->transformed = transformed;
321  (*prob)->nlpenabled = FALSE;
322  (*prob)->permuted = FALSE;
323 
324  return SCIP_OKAY;
325 }
326 
327 /** sets callback to free user data of original problem */
329  SCIP_PROB* prob, /**< problem */
330  SCIP_DECL_PROBDELORIG ((*probdelorig)) /**< frees user data of original problem */
331  )
332 {
333  assert(prob != NULL);
334 
335  prob->probdelorig = probdelorig;
336 }
337 
338 /** sets callback to create user data of transformed problem by transforming original user data */
340  SCIP_PROB* prob, /**< problem */
341  SCIP_DECL_PROBTRANS ((*probtrans)) /**< creates user data of transformed problem by transforming original user data */
342  )
343 {
344  assert(prob != NULL);
345 
346  prob->probtrans = probtrans;
347 }
348 
349 /** sets callback to free user data of transformed problem */
351  SCIP_PROB* prob, /**< problem */
352  SCIP_DECL_PROBDELTRANS((*probdeltrans)) /**< frees user data of transformed problem */
353  )
354 {
355  assert(prob != NULL);
356 
357  prob->probdeltrans = probdeltrans;
358 }
359 
360 /** sets solving process initialization callback of transformed data */
362  SCIP_PROB* prob, /**< problem */
363  SCIP_DECL_PROBINITSOL ((*probinitsol)) /**< solving process initialization callback of transformed data */
364  )
365 {
366  assert(prob != NULL);
367 
368  prob->probinitsol= probinitsol;
369 }
370 
371 /** sets solving process deinitialization callback of transformed data */
373  SCIP_PROB* prob, /**< problem */
374  SCIP_DECL_PROBEXITSOL ((*probexitsol)) /**< solving process deinitialization callback of transformed data */
375  )
376 {
377  assert(prob != NULL);
378 
379  prob->probexitsol= probexitsol;
380 }
381 
382 /** sets callback to copy user data to copy it to a subscip, or NULL */
384  SCIP_PROB* prob, /**< problem */
385  SCIP_DECL_PROBCOPY ((*probcopy)) /**< copies user data if you want to copy it to a subscip, or NULL */
386  )
387 {
388  assert(prob != NULL);
389 
390  prob->probcopy= probcopy;
391 }
392 
393 /** frees problem data structure */
395  SCIP_PROB** prob, /**< pointer to problem data structure */
396  BMS_BLKMEM* blkmem, /**< block memory buffer */
397  SCIP_SET* set, /**< global SCIP settings */
398  SCIP_STAT* stat, /**< dynamic problem statistics */
399  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
400  SCIP_LP* lp /**< current LP data (or NULL, if it's the original problem) */
401  )
402 {
403  int v;
404 
405  assert(prob != NULL);
406  assert(*prob != NULL);
407  assert(set != NULL);
408 
409  /* remove all constraints from the problem */
410  while( (*prob)->nconss > 0 )
411  {
412  /*@todo for debug mode it even might sense, to sort them downwards after their arraypos */
413  assert((*prob)->conss != NULL);
414  SCIP_CALL( SCIPprobDelCons(*prob, blkmem, set, stat, (*prob)->conss[(*prob)->nconss - 1]) );
415  }
416 
417  if( (*prob)->transformed )
418  {
419  int h;
420 
421  /* unlock variables for all constraint handlers that don't need constraints */
422  for( h = 0; h < set->nconshdlrs; ++h )
423  {
424  if( !SCIPconshdlrNeedsCons(set->conshdlrs[h]) )
425  {
426  SCIP_CALL( SCIPconshdlrUnlockVars(set->conshdlrs[h], set) );
427  }
428  }
429  }
430 
431  /* free constraint array */
432  BMSfreeMemoryArrayNull(&(*prob)->conss);
433 
434  /* free user problem data */
435  if( (*prob)->transformed )
436  {
437  if( (*prob)->probdeltrans != NULL )
438  {
439  SCIP_CALL( (*prob)->probdeltrans(set->scip, &(*prob)->probdata) );
440  }
441  }
442  else
443  {
444  if( (*prob)->probdelorig != NULL )
445  {
446  SCIP_CALL( (*prob)->probdelorig(set->scip, &(*prob)->probdata) );
447  }
448  }
449 
450  /* release problem variables */
451  for( v = (*prob)->nvars - 1; v >= 0; --v )
452  {
453  assert(SCIPvarGetProbindex((*prob)->vars[v]) >= 0);
454  SCIP_CALL( SCIPvarRemove((*prob)->vars[v], blkmem, NULL, set, TRUE) );
455  SCIP_CALL( SCIPvarRelease(&(*prob)->vars[v], blkmem, set, eventqueue, lp) );
456  }
457  BMSfreeMemoryArrayNull(&(*prob)->vars);
458 
459  /* release fixed problem variables */
460  for( v = (*prob)->nfixedvars - 1; v >= 0; --v )
461  {
462  assert(SCIPvarGetProbindex((*prob)->fixedvars[v]) == -1);
463  SCIP_CALL( SCIPvarRelease(&(*prob)->fixedvars[v], blkmem, set, eventqueue, lp) );
464  }
465  BMSfreeMemoryArrayNull(&(*prob)->fixedvars);
466 
467  /* free deleted problem variables array */
468  BMSfreeMemoryArrayNull(&(*prob)->deletedvars);
469 
470  /* free hash tables for names */
471  if( (*prob)->varnames != NULL )
472  {
473  SCIPhashtableFree(&(*prob)->varnames);
474  }
475  if( (*prob)->consnames != NULL )
476  {
477  SCIPhashtableFree(&(*prob)->consnames);
478  }
479  BMSfreeMemoryArray(&(*prob)->name);
480  BMSfreeMemory(prob);
481 
482  return SCIP_OKAY;
483 }
484 
485 /** transform problem data into normalized form */
487  SCIP_PROB* source, /**< problem to transform */
488  BMS_BLKMEM* blkmem, /**< block memory buffer */
489  SCIP_SET* set, /**< global SCIP settings */
490  SCIP_STAT* stat, /**< problem statistics */
491  SCIP_PRIMAL* primal, /**< primal data */
492  SCIP_TREE* tree, /**< branch and bound tree */
493  SCIP_REOPT* reopt, /**< reoptimization data structure */
494  SCIP_LP* lp, /**< current LP data */
495  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
496  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
497  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
498  SCIP_PROB** target /**< pointer to target problem data structure */
499  )
500 {
501  SCIP_VAR* targetvar;
502  SCIP_CONS* targetcons;
503  char transname[SCIP_MAXSTRLEN];
504  int v;
505  int c;
506  int h;
507 
508  assert(set != NULL);
509  assert(source != NULL);
510  assert(blkmem != NULL);
511  assert(target != NULL);
512 
513  SCIPdebugMessage("transform problem: original has %d variables\n", source->nvars);
514 
515  /* create target problem data (probdelorig and probtrans are not needed, probdata is set later) */
516  (void) SCIPsnprintf(transname, SCIP_MAXSTRLEN, "t_%s", source->name);
517  SCIP_CALL( SCIPprobCreate(target, blkmem, set, transname, source->probdelorig, source->probtrans, source->probdeltrans,
518  source->probinitsol, source->probexitsol, source->probcopy, NULL, TRUE) );
519  SCIPprobSetObjsense(*target, source->objsense);
520 
521  /* transform objective limit */
522  if( source->objlim < SCIP_INVALID )
523  SCIPprobSetObjlim(*target, source->objlim);
524 
525  /* transform dual bound */
526  if( source->dualbound < SCIP_INVALID )
527  SCIPprobSetDualbound(*target, source->dualbound);
528 
529  /* transform and copy all variables to target problem */
530  SCIP_CALL( probEnsureVarsMem(*target, set, source->nvars) );
531  for( v = 0; v < source->nvars; ++v )
532  {
533  SCIP_CALL( SCIPvarTransform(source->vars[v], blkmem, set, stat, source->objsense, &targetvar) );
534  SCIP_CALL( SCIPprobAddVar(*target, blkmem, set, lp, branchcand, eventfilter, eventqueue, targetvar) );
535  SCIP_CALL( SCIPvarRelease(&targetvar, blkmem, set, eventqueue, NULL) );
536  }
537  assert((*target)->nvars == source->nvars);
538  assert((*target)->nobjvars == SCIPprobGetNObjVars(*target, set));
539 
540  /* call user data transformation */
541  if( source->probtrans != NULL )
542  {
543  SCIP_CALL( source->probtrans(set->scip, source->probdata, &(*target)->probdata) );
544  }
545  else
546  (*target)->probdata = source->probdata;
547 
548  /* transform and copy all constraints to target problem */
549  for( c = 0; c < source->nconss; ++c )
550  {
551  SCIP_CALL( SCIPconsTransform(source->conss[c], blkmem, set, &targetcons) );
552  SCIP_CALL( SCIPprobAddCons(*target, set, stat, targetcons) );
553  SCIP_CALL( SCIPconsRelease(&targetcons, blkmem, set) );
554  }
555 
556  /* lock variables for all constraint handlers that don't need constraints */
557  for( h = 0; h < set->nconshdlrs; ++h )
558  {
559  if( !SCIPconshdlrNeedsCons(set->conshdlrs[h]) )
560  {
561  SCIP_CALL( SCIPconshdlrLockVars(set->conshdlrs[h], set) );
562  }
563  }
564 
565  /* objective value is always integral, iff original objective value is always integral and shift is integral */
566  (*target)->objisintegral = source->objisintegral && SCIPsetIsIntegral(set, (*target)->objoffset);
567 
568  /* check, whether objective value is always integral by inspecting the problem, if it is the case adjust the
569  * cutoff bound if primal solution is already known
570  */
571  SCIP_CALL( SCIPprobCheckObjIntegral(*target, source, blkmem, set, stat, primal, tree, reopt, lp, eventqueue) );
572 
573  /* copy the nlpenabled flag */
574  (*target)->nlpenabled = source->nlpenabled;
575 
576  /* mark the transformed problem to be permuted iff the source problem is permuted */
577  (*target)->permuted = source->permuted;
578 
579  return SCIP_OKAY;
580 }
581 
582 /** resets the global and local bounds of original variables in original problem to their original values */
584  SCIP_PROB* prob, /**< original problem data */
585  BMS_BLKMEM* blkmem, /**< block memory */
586  SCIP_SET* set, /**< global SCIP settings */
587  SCIP_STAT* stat /**< problem statistics */
588  )
589 {
590  int v;
591 
592  assert(prob != NULL);
593  assert(!prob->transformed);
594  assert(prob->nfixedvars == 0);
595 
596  for( v = 0; v < prob->nvars; ++v )
597  {
598  SCIP_CALL( SCIPvarResetBounds(prob->vars[v], blkmem, set, stat) );
599  }
600 
601  return SCIP_OKAY;
602 }
603 
604 /** (Re)Sort the variables, which appear in the four categories (binary, integer, implicit, continuous) after presolve
605  * with respect to their original index (within their categories). Adjust the problem index afterwards which is
606  * supposed to reflect the position in the variable array. This additional (re)sorting is supposed to get more robust
607  * against the order presolving fixed variables. (We also reobtain a possible block structure induced by the user
608  * model)
609  */
611  SCIP_PROB* prob /**< problem data */
612  )
613 {
614  SCIP_VAR** vars;
615  int nbinvars;
616  int nintvars;
617  int nimplvars;
618  int ncontvars;
619  int nvars;
620  int v;
621 
622  vars = prob->vars;
623  nvars = prob->nvars;
624  nbinvars = prob->nbinvars;
625  nintvars = prob->nintvars;
626  nimplvars = prob->nimplvars;
627  ncontvars = prob->ncontvars;
628 
629  if( nvars == 0 )
630  return;
631 
632  assert(vars != NULL);
633  assert(nbinvars + nintvars + nimplvars + ncontvars == nvars);
634 
635  SCIPdebugMessage("entering sorting with respect to original block structure! \n");
636 
637  /* sort binaries */
638  if( nbinvars > 0 )
639  SCIPsortPtr((void**)vars, SCIPvarComp, nbinvars);
640 
641  /* sort integers */
642  if( nintvars > 0 )
643  SCIPsortPtr((void**)&vars[nbinvars], SCIPvarComp, nintvars);
644 
645  /* sort implicit variables */
646  if( nimplvars > 0 )
647  SCIPsortPtr((void**)&vars[nbinvars + nintvars], SCIPvarComp, nimplvars);
648 
649  /* sort continuous variables*/
650  if( ncontvars > 0 )
651  SCIPsortPtr((void**)&vars[nbinvars + nintvars + nimplvars], SCIPvarComp, ncontvars);
652 
653  /* after sorting, the problem index of each variable has to be adjusted */
654  for( v = 0; v < nvars; ++v )
655  {
656  vars[v]->probindex = v;
657  SCIPdebugMessage("Variable: Problem index <%d>, original index <%d> \n", vars[v]->probindex, vars[v]->index);
658  }
659 }
660 
661 
662 
663 /*
664  * problem modification
665  */
666 
667 /** sets user problem data */
669  SCIP_PROB* prob, /**< problem */
670  SCIP_PROBDATA* probdata /**< user problem data to use */
671  )
672 {
673  assert(prob != NULL);
674 
675  prob->probdata = probdata;
676 }
677 
678 /** inserts variable at the correct position in vars array, depending on its type */
679 static
681  SCIP_PROB* prob, /**< problem data */
682  SCIP_VAR* var /**< variable to insert */
683  )
684 {
685  int insertpos;
686  int intstart;
687  int implstart;
688  int contstart;
689 
690  assert(prob != NULL);
691  assert(prob->vars != NULL);
692  assert(prob->nvars < prob->varssize);
693  assert(var != NULL);
694  assert(SCIPvarGetProbindex(var) == -1);
698  /* original variables cannot go into transformed problem and transformed variables cannot go into original problem */
699  assert((SCIPvarGetStatus(var) != SCIP_VARSTATUS_ORIGINAL) == prob->transformed);
700 
701  /* insert variable in array */
702  insertpos = prob->nvars;
703  intstart = prob->nbinvars;
704  implstart = intstart + prob->nintvars;
705  contstart = implstart + prob->nimplvars;
706 
708  prob->ncontvars++;
709  else
710  {
711  if( insertpos > contstart )
712  {
713  prob->vars[insertpos] = prob->vars[contstart];
714  SCIPvarSetProbindex(prob->vars[insertpos], insertpos);
715  insertpos = contstart;
716  }
717  assert(insertpos == contstart);
718 
720  prob->nimplvars++;
721  else
722  {
723  if( insertpos > implstart )
724  {
725  prob->vars[insertpos] = prob->vars[implstart];
726  SCIPvarSetProbindex(prob->vars[insertpos], insertpos);
727  insertpos = implstart;
728  }
729  assert(insertpos == implstart);
730 
732  prob->nintvars++;
733  else
734  {
735  assert(SCIPvarGetType(var) == SCIP_VARTYPE_BINARY);
736  if( insertpos > intstart )
737  {
738  prob->vars[insertpos] = prob->vars[intstart];
739  SCIPvarSetProbindex(prob->vars[insertpos], insertpos);
740  insertpos = intstart;
741  }
742  assert(insertpos == intstart);
743 
744  prob->nbinvars++;
745  }
746  }
747  }
748  prob->nvars++;
749 
750  assert(prob->nvars == prob->nbinvars + prob->nintvars + prob->nimplvars + prob->ncontvars);
751  assert((SCIPvarGetType(var) == SCIP_VARTYPE_BINARY && insertpos == prob->nbinvars - 1)
752  || (SCIPvarGetType(var) == SCIP_VARTYPE_INTEGER && insertpos == prob->nbinvars + prob->nintvars - 1)
753  || (SCIPvarGetType(var) == SCIP_VARTYPE_IMPLINT && insertpos == prob->nbinvars + prob->nintvars + prob->nimplvars - 1)
755  && insertpos == prob->nbinvars + prob->nintvars + prob->nimplvars + prob->ncontvars - 1));
756 
757  prob->vars[insertpos] = var;
758  SCIPvarSetProbindex(var, insertpos);
759 
760  /* update number of column variables in problem */
762  prob->ncolvars++;
763  assert(0 <= prob->ncolvars && prob->ncolvars <= prob->nvars);
764 }
765 
766 /** removes variable from vars array */
767 static
769  SCIP_PROB* prob, /**< problem data */
770  BMS_BLKMEM* blkmem, /**< block memory */
771  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
772  SCIP_SET* set, /**< global SCIP settings */
773  SCIP_VAR* var /**< variable to remove */
774  )
775 {
776  int freepos;
777  int intstart;
778  int implstart;
779  int contstart;
780 
781  assert(prob != NULL);
782  assert(var != NULL);
783  assert(SCIPvarGetProbindex(var) >= 0);
784  assert(prob->vars != NULL);
785  assert(prob->vars[SCIPvarGetProbindex(var)] == var);
786 
787  intstart = prob->nbinvars;
788  implstart = intstart + prob->nintvars;
789  contstart = implstart + prob->nimplvars;
790 
791  switch( SCIPvarGetType(var) )
792  {
793  case SCIP_VARTYPE_BINARY:
794  assert(0 <= SCIPvarGetProbindex(var) && SCIPvarGetProbindex(var) < intstart);
795  prob->nbinvars--;
796  break;
798  assert(intstart <= SCIPvarGetProbindex(var) && SCIPvarGetProbindex(var) < implstart);
799  prob->nintvars--;
800  break;
802  assert(implstart <= SCIPvarGetProbindex(var) && SCIPvarGetProbindex(var) < contstart);
803  prob->nimplvars--;
804  break;
806  assert(contstart <= SCIPvarGetProbindex(var) && SCIPvarGetProbindex(var) < prob->nvars);
807  prob->ncontvars--;
808  break;
809  default:
810  SCIPerrorMessage("unknown variable type\n");
811  SCIPABORT();
812  return SCIP_INVALIDDATA; /*lint !e527*/
813  }
814 
815  /* move last binary, last integer, last implicit, and last continuous variable forward to fill the free slot */
816  freepos = SCIPvarGetProbindex(var);
817  if( freepos < intstart-1 )
818  {
819  /* move last binary variable to free slot */
820  prob->vars[freepos] = prob->vars[intstart-1];
821  SCIPvarSetProbindex(prob->vars[freepos], freepos);
822  freepos = intstart-1;
823  }
824  if( freepos < implstart-1 )
825  {
826  /* move last integer variable to free slot */
827  prob->vars[freepos] = prob->vars[implstart-1];
828  SCIPvarSetProbindex(prob->vars[freepos], freepos);
829  freepos = implstart-1;
830  }
831  if( freepos < contstart-1 )
832  {
833  /* move last implicit integer variable to free slot */
834  prob->vars[freepos] = prob->vars[contstart-1];
835  SCIPvarSetProbindex(prob->vars[freepos], freepos);
836  freepos = contstart-1;
837  }
838  if( freepos < prob->nvars-1 )
839  {
840  /* move last implicit integer variable to free slot */
841  prob->vars[freepos] = prob->vars[prob->nvars-1];
842  SCIPvarSetProbindex(prob->vars[freepos], freepos);
843  freepos = prob->nvars-1;
844  }
845  assert(freepos == prob->nvars-1);
846 
847  prob->nvars--;
848  assert(prob->nvars == prob->nbinvars + prob->nintvars + prob->nimplvars + prob->ncontvars);
849 
850  /* update number of column variables in problem */
852  prob->ncolvars--;
853  assert(0 <= prob->ncolvars && prob->ncolvars <= prob->nvars);
854 
855  /* inform the variable that it is no longer in the problem; if necessary, delete it from the implication graph */
856  SCIP_CALL( SCIPvarRemove(var, blkmem, cliquetable, set, FALSE) );
857 
858  return SCIP_OKAY;
859 }
860 
861 /** adds variable's name to the namespace */
863  SCIP_PROB* prob, /**< problem data */
864  SCIP_VAR* var /**< variable */
865  )
866 {
867  assert(SCIPvarGetProbindex(var) != -1);
868 
869  if( varHasName(var) && prob->varnames != NULL )
870  {
871  SCIP_CALL( SCIPhashtableInsert(prob->varnames, (void*)var) );
872  }
873 
874  return SCIP_OKAY;
875 }
876 
877 /** removes variable's name from the namespace */
879  SCIP_PROB* prob, /**< problem data */
880  SCIP_VAR* var /**< variable */
881  )
882 {
883  if( varHasName(var) && prob->varnames != NULL )
884  {
885  assert(SCIPhashtableExists(prob->varnames, (void*)var));
886  SCIP_CALL( SCIPhashtableRemove(prob->varnames, (void*)var) );
887  }
888 
889  return SCIP_OKAY;
890 }
891 
892 /** adds variable to the problem and captures it */
894  SCIP_PROB* prob, /**< problem data */
895  BMS_BLKMEM* blkmem, /**< block memory buffers */
896  SCIP_SET* set, /**< global SCIP settings */
897  SCIP_LP* lp, /**< current LP data */
898  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
899  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
900  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
901  SCIP_VAR* var /**< variable to add */
902  )
903 {
904  assert(prob != NULL);
905  assert(set != NULL);
906  assert(var != NULL);
907  assert(SCIPvarGetProbindex(var) == -1);
911  /* original variables cannot go into transformed problem and transformed variables cannot go into original problem */
912  assert((SCIPvarGetStatus(var) != SCIP_VARSTATUS_ORIGINAL) == prob->transformed);
913 
914 #ifndef NDEBUG
915  /* check if we add this variables to the same scip, where we created it */
916  if( var->scip != set->scip )
917  {
918  SCIPerrorMessage("variable belongs to a different scip instance\n");
919  return SCIP_INVALIDDATA;
920  }
921 #endif
922 
923  /* capture variable */
924  SCIPvarCapture(var);
925 
926  /* allocate additional memory */
927  SCIP_CALL( probEnsureVarsMem(prob, set, prob->nvars+1) );
928 
929  /* insert variable in vars array and mark it to be in problem */
930  probInsertVar(prob, var);
931 
932  /* add variable's name to the namespace */
933  SCIP_CALL( SCIPprobAddVarName(prob, var) );
934 
935  /* update branching candidates and pseudo and loose objective value in the LP */
937  {
938  SCIP_CALL( SCIPbranchcandUpdateVar(branchcand, set, var) );
939  SCIP_CALL( SCIPlpUpdateAddVar(lp, set, var) );
940  }
941 
942  SCIPdebugMessage("added variable <%s> to problem (%d variables: %d binary, %d integer, %d implicit, %d continuous)\n",
943  SCIPvarGetName(var), prob->nvars, prob->nbinvars, prob->nintvars, prob->nimplvars, prob->ncontvars);
944 
945  if( prob->transformed )
946  {
947  SCIP_EVENT* event;
948 
949  /* issue VARADDED event */
950  SCIP_CALL( SCIPeventCreateVarAdded(&event, blkmem, var) );
951  SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, NULL, NULL, eventfilter, &event) );
952 
953  /* update the number of variables with non-zero objective coefficient */
954  SCIPprobUpdateNObjVars(prob, set, 0.0, SCIPvarGetObj(var));
955  }
956 
957  return SCIP_OKAY;
958 }
959 
960 /** marks variable to be removed from the problem; however, the variable is NOT removed from the constraints */
962  SCIP_PROB* prob, /**< problem data */
963  BMS_BLKMEM* blkmem, /**< block memory */
964  SCIP_SET* set, /**< global SCIP settings */
965  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
966  SCIP_VAR* var, /**< problem variable */
967  SCIP_Bool* deleted /**< pointer to store whether marking variable to be deleted was successful */
968  )
969 {
970  assert(prob != NULL);
971  assert(set != NULL);
972  assert(var != NULL);
973  assert(deleted != NULL);
974  assert(SCIPvarGetProbindex(var) != -1);
978 
979  *deleted = FALSE;
980 
981  /* don't remove variables that are not in the problem */
982  /**@todo what about negated variables? should the negation variable be removed instead? */
983  if( SCIPvarGetProbindex(var) == -1 )
984  return SCIP_OKAY;
985 
986  /* don't remove the direct counterpart of an original variable from the transformed problem, because otherwise
987  * operations on the original variables would be applied to a NULL pointer
988  */
989  if( SCIPvarIsTransformedOrigvar(var) )
990  return SCIP_OKAY;
991 
992  assert(SCIPvarGetNegatedVar(var) == NULL);
993 
994  SCIPdebugMessage("deleting variable <%s> from problem (%d variables: %d binary, %d integer, %d implicit, %d continuous)\n",
995  SCIPvarGetName(var), prob->nvars, prob->nbinvars, prob->nintvars, prob->nimplvars, prob->ncontvars);
996 
997  /* mark variable to be deleted from the problem */
998  SCIPvarMarkDeleted(var);
999 
1000  if( prob->transformed )
1001  {
1002  SCIP_EVENT* event;
1003 
1004  assert(eventqueue != NULL);
1005 
1006  /* issue VARDELETED event */
1007  SCIP_CALL( SCIPeventCreateVarDeleted(&event, blkmem, var) );
1008  SCIP_CALL( SCIPeventqueueAdd(eventqueue, blkmem, set, NULL, NULL, NULL, NULL, &event) );
1009  }
1010 
1011  /* remember that the variable should be deleted from the problem in SCIPprobPerformVarDeletions() */
1012  SCIP_CALL( probEnsureDeletedvarsMem(prob, set, prob->ndeletedvars+1) );
1013  prob->deletedvars[prob->ndeletedvars] = var;
1014  prob->ndeletedvars++;
1015 
1016  *deleted = TRUE;
1017 
1018  return SCIP_OKAY;
1019 }
1020 
1021 /** actually removes the deleted variables from the problem and releases them */
1023  SCIP_PROB* prob, /**< problem data */
1024  BMS_BLKMEM* blkmem, /**< block memory */
1025  SCIP_SET* set, /**< global SCIP settings */
1026  SCIP_STAT* stat, /**< dynamic problem statistics */
1027  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1028  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
1029  SCIP_LP* lp, /**< current LP data (may be NULL) */
1030  SCIP_BRANCHCAND* branchcand /**< branching candidate storage */
1031  )
1032 {
1033  int i;
1034 
1035  assert(prob != NULL);
1036  assert(set != NULL);
1037 
1038  /* delete variables from the constraints;
1039  * do this only in solving stage, in presolving, it is already handled by the constraint handlers
1040  */
1041  if( SCIPsetGetStage(set) == SCIP_STAGE_SOLVING )
1042  {
1043  for( i = 0; i < set->nconshdlrs; ++i )
1044  {
1045  SCIP_CALL( SCIPconshdlrDelVars(set->conshdlrs[i], blkmem, set, stat) );
1046  }
1047  }
1048 
1049  for( i = 0; i < prob->ndeletedvars; ++i )
1050  {
1051  SCIP_VAR* var;
1052 
1053  var = prob->deletedvars[i];
1054 
1055  /* don't delete the variable, if it was fixed or aggregated in the meantime */
1056  if( SCIPvarGetProbindex(var) >= 0 )
1057  {
1058  SCIPdebugMessage("perform deletion of <%s> [%p]\n", SCIPvarGetName(var), (void*)var);
1059 
1060  /* convert column variable back into loose variable, free LP column */
1062  {
1063  SCIP_CALL( SCIPvarLoose(var, blkmem, set, eventqueue, prob, lp) );
1064  }
1065 
1066  /* update branching candidates and pseudo and loose objective value in the LP */
1068  {
1069  SCIP_CALL( SCIPlpUpdateDelVar(lp, set, var) );
1070  SCIP_CALL( SCIPbranchcandRemoveVar(branchcand, var) );
1071  }
1072 
1073  /* remove variable's name from the namespace */
1074  SCIP_CALL( SCIPprobRemoveVarName(prob, var) );
1075 
1076  /* remove variable from vars array and mark it to be not in problem */
1077  SCIP_CALL( probRemoveVar(prob, blkmem, cliquetable, set, var) );
1078 
1079  /* update the number of variables with non-zero objective coefficient */
1080  if( prob->transformed )
1081  SCIPprobUpdateNObjVars(prob, set, SCIPvarGetObj(var), 0.0);
1082 
1083  /* release variable */
1084  SCIP_CALL( SCIPvarRelease(&prob->deletedvars[i], blkmem, set, eventqueue, lp) );
1085  }
1086  }
1087  prob->ndeletedvars = 0;
1088 
1089  return SCIP_OKAY;
1090 }
1091 
1092 /** changes the type of a variable in the problem */
1094  SCIP_PROB* prob, /**< problem data */
1095  BMS_BLKMEM* blkmem, /**< block memory */
1096  SCIP_SET* set, /**< global SCIP settings */
1097  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1098  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
1099  SCIP_VAR* var, /**< variable to add */
1100  SCIP_VARTYPE vartype /**< new type of variable */
1101  )
1102 {
1103  assert(prob != NULL);
1104  assert(var != NULL);
1105  assert(SCIPvarGetProbindex(var) >= 0);
1109  assert(branchcand != NULL || SCIPvarGetStatus(var) == SCIP_VARSTATUS_ORIGINAL);
1110 
1111  if( SCIPvarGetType(var) == vartype )
1112  return SCIP_OKAY;
1113 
1114  /* temporarily remove variable from branching candidates */
1115  if( branchcand != NULL )
1116  {
1117  SCIP_CALL( SCIPbranchcandRemoveVar(branchcand, var) );
1118  }
1119 
1120  /* temporarily remove variable from problem */
1121  SCIP_CALL( probRemoveVar(prob, blkmem, cliquetable, set, var) );
1122 
1123  /* change the type of the variable */
1124  SCIP_CALL( SCIPvarChgType(var, vartype) );
1125 
1126  /* reinsert variable into problem */
1127  probInsertVar(prob, var);
1128 
1129  /* update branching candidates */
1130  if( branchcand != NULL )
1131  {
1132  SCIP_CALL( SCIPbranchcandUpdateVar(branchcand, set, var) );
1133  }
1134 
1135  return SCIP_OKAY;
1136 }
1137 
1138 /** informs problem, that the given loose problem variable changed its status */
1140  SCIP_PROB* prob, /**< problem data */
1141  BMS_BLKMEM* blkmem, /**< block memory */
1142  SCIP_SET* set, /**< global SCIP settings */
1143  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
1144  SCIP_CLIQUETABLE* cliquetable, /**< clique table data structure */
1145  SCIP_VAR* var /**< problem variable */
1146  )
1147 {
1148  assert(prob != NULL);
1149  assert(var != NULL);
1150  assert(SCIPvarGetProbindex(var) != -1);
1151 
1152  /* get current status of variable */
1153  switch( SCIPvarGetStatus(var) )
1154  {
1156  SCIPerrorMessage("variables cannot switch to ORIGINAL status\n");
1157  return SCIP_INVALIDDATA;
1158 
1159  case SCIP_VARSTATUS_LOOSE:
1160  /* variable switched from column to loose */
1161  prob->ncolvars--;
1162  break;
1163 
1164  case SCIP_VARSTATUS_COLUMN:
1165  /* variable switched from non-column to column */
1166  prob->ncolvars++;
1167  break;
1168 
1169  case SCIP_VARSTATUS_FIXED:
1173  /* variable switched from unfixed to fixed (if it was fixed before, probindex would have been -1) */
1174 
1175  /* remove variable from problem */
1176  SCIP_CALL( probRemoveVar(prob, blkmem, cliquetable, set, var) );
1177 
1178  /* insert variable in fixedvars array */
1179  SCIP_CALL( probEnsureFixedvarsMem(prob, set, prob->nfixedvars+1) );
1180  prob->fixedvars[prob->nfixedvars] = var;
1181  prob->nfixedvars++;
1182 
1183  /* update branching candidates */
1184  SCIP_CALL( SCIPbranchcandUpdateVar(branchcand, set, var) );
1185  break;
1186 
1187  default:
1188  SCIPerrorMessage("invalid variable status <%d>\n", SCIPvarGetStatus(var));
1189  return SCIP_INVALIDDATA;
1190  }
1191  assert(0 <= prob->ncolvars && prob->ncolvars <= prob->nvars);
1192 
1193  return SCIP_OKAY;
1194 }
1195 
1196 /** adds constraint's name to the namespace */
1198  SCIP_PROB* prob, /**< problem data */
1199  SCIP_CONS* cons /**< constraint */
1200  )
1201 {
1202  /* add constraint's name to the namespace */
1203  if( consHasName(cons) && prob->consnames != NULL )
1204  {
1205  SCIP_CALL( SCIPhashtableInsert(prob->consnames, (void*)cons) );
1206  }
1207 
1208  return SCIP_OKAY;
1209 }
1210 
1211 /** remove constraint's name from the namespace */
1213  SCIP_PROB* prob, /**< problem data */
1214  SCIP_CONS* cons /**< constraint */
1215  )
1216 {
1217  /* remove constraint's name from the namespace */
1218  if( consHasName(cons) && prob->consnames != NULL )
1219  {
1220  assert(SCIPhashtableExists(prob->consnames, (void*)cons));
1221  SCIP_CALL( SCIPhashtableRemove(prob->consnames, (void*)cons) );
1222  }
1223 
1224  return SCIP_OKAY;
1225 }
1226 
1227 /** adds constraint to the problem and captures it;
1228  * a local constraint is automatically upgraded into a global constraint
1229  */
1231  SCIP_PROB* prob, /**< problem data */
1232  SCIP_SET* set, /**< global SCIP settings */
1233  SCIP_STAT* stat, /**< dynamic problem statistics */
1234  SCIP_CONS* cons /**< constraint to add */
1235  )
1236 {
1237  assert(prob != NULL);
1238  assert(cons != NULL);
1239  assert(cons->addconssetchg == NULL);
1240  assert(cons->addarraypos == -1);
1241 
1242 #ifndef NDEBUG
1243  /* check if we add this constraint to the same scip, where we create the constraint */
1244  if( cons->scip != set->scip )
1245  {
1246  SCIPerrorMessage("constraint belongs to different scip instance\n");
1247  return SCIP_INVALIDDATA;
1248  }
1249 #endif
1250  SCIPdebugMessage("adding constraint <%s> to global problem -> %d constraints\n",
1251  SCIPconsGetName(cons), prob->nconss+1);
1252 
1253  /* mark the constraint as problem constraint, and remember the constraint's position */
1254  cons->addconssetchg = NULL;
1255  cons->addarraypos = prob->nconss;
1256 
1257  /* add the constraint to the problem's constraint array */
1258  SCIP_CALL( probEnsureConssMem(prob, set, prob->nconss+1) );
1259  prob->conss[prob->nconss] = cons;
1260  prob->nconss++;
1261  prob->maxnconss = MAX(prob->maxnconss, prob->nconss);
1262 
1263  /* undelete constraint, if it was globally deleted in the past */
1264  cons->deleted = FALSE;
1265 
1266  /* mark constraint to be globally valid */
1267  SCIPconsSetLocal(cons, FALSE);
1268 
1269  /* capture constraint */
1270  SCIPconsCapture(cons);
1271 
1272  /* add constraint's name to the namespace */
1273  SCIP_CALL( SCIPprobAddConsName(prob, cons) );
1274 
1275  /* if the problem is the transformed problem, activate and lock constraint */
1276  if( prob->transformed )
1277  {
1278  /* activate constraint */
1279  if( !SCIPconsIsActive(cons) )
1280  {
1281  SCIP_CALL( SCIPconsActivate(cons, set, stat, -1, (stat->nnodes <= 1)) );
1282  }
1283 
1284  /* if constraint is a check-constraint, lock roundings of constraint's variables */
1285  if( SCIPconsIsChecked(cons) )
1286  {
1287  SCIP_CALL( SCIPconsAddLocks(cons, set, +1, 0) );
1288  }
1289  }
1290 
1291  return SCIP_OKAY;
1292 }
1293 
1294 /** releases and removes constraint from the problem; if the user has not captured the constraint for his own use, the
1295  * constraint may be invalid after the call
1296  */
1298  SCIP_PROB* prob, /**< problem data */
1299  BMS_BLKMEM* blkmem, /**< block memory */
1300  SCIP_SET* set, /**< global SCIP settings */
1301  SCIP_STAT* stat, /**< dynamic problem statistics */
1302  SCIP_CONS* cons /**< constraint to remove */
1303  )
1304 {
1305  int arraypos;
1306 
1307  assert(prob != NULL);
1308  assert(blkmem != NULL);
1309  assert(cons != NULL);
1310  assert(cons->addconssetchg == NULL);
1311  assert(0 <= cons->addarraypos && cons->addarraypos < prob->nconss);
1312  assert(prob->conss != NULL);
1313  assert(prob->conss[cons->addarraypos] == cons);
1314 
1315  /* if the problem is the transformed problem, deactivate and unlock constraint */
1316  if( prob->transformed )
1317  {
1318  /* if constraint is a check-constraint, unlock roundings of constraint's variables */
1319  if( SCIPconsIsChecked(cons) )
1320  {
1321  SCIP_CALL( SCIPconsAddLocks(cons, set, -1, 0) );
1322  }
1323 
1324  /* deactivate constraint, if it is currently active */
1325  if( cons->active && !cons->updatedeactivate )
1326  {
1327  SCIP_CALL( SCIPconsDeactivate(cons, set, stat) );
1328  }
1329  }
1330  assert(!cons->active || cons->updatedeactivate);
1331  assert(!cons->enabled || cons->updatedeactivate);
1332 
1333  /* remove constraint's name from the namespace */
1334  SCIP_CALL( SCIPprobRemoveConsName(prob, cons) );
1335 
1336  /* remove the constraint from the problem's constraint array */
1337  arraypos = cons->addarraypos;
1338  prob->conss[arraypos] = prob->conss[prob->nconss-1];
1339  assert(prob->conss[arraypos] != NULL);
1340  assert(prob->conss[arraypos]->addconssetchg == NULL);
1341  prob->conss[arraypos]->addarraypos = arraypos;
1342  prob->nconss--;
1343 
1344  /* mark the constraint to be no longer in the problem */
1345  cons->addarraypos = -1;
1346 
1347  /* release constraint */
1348  SCIP_CALL( SCIPconsRelease(&cons, blkmem, set) );
1349 
1350  return SCIP_OKAY;
1351 }
1352 
1353 /** remembers the current number of constraints in the problem's internal data structure
1354  * - resets maximum number of constraints to current number of constraints
1355  * - remembers current number of constraints as starting number of constraints
1356  */
1358  SCIP_PROB* prob /**< problem data */
1359  )
1360 {
1361  assert(prob != NULL);
1362 
1363  /* remember number of constraints for statistic */
1364  prob->maxnconss = prob->nconss;
1365  prob->startnvars = prob->nvars;
1366  prob->startnconss = prob->nconss;
1367 }
1368 
1369 /** sets objective sense: minimization or maximization */
1371  SCIP_PROB* prob, /**< problem data */
1372  SCIP_OBJSENSE objsense /**< new objective sense */
1373  )
1374 {
1375  assert(prob != NULL);
1376  assert(prob->objsense == SCIP_OBJSENSE_MAXIMIZE || prob->objsense == SCIP_OBJSENSE_MINIMIZE);
1377  assert(objsense == SCIP_OBJSENSE_MAXIMIZE || objsense == SCIP_OBJSENSE_MINIMIZE);
1378 
1379  prob->objsense = objsense;
1380 }
1381 
1382 /** adds value to objective offset */
1384  SCIP_PROB* prob, /**< problem data */
1385  SCIP_Real addval /**< value to add to objective offset */
1386  )
1387 {
1388  assert(prob != NULL);
1389  assert(prob->transformed);
1390 
1391  SCIPdebugMessage("adding %g to objective offset %g: new offset = %g\n", addval, prob->objoffset, prob->objoffset + addval);
1392  prob->objoffset += addval;
1393 }
1394 
1395 /** sets the dual bound on objective function */
1397  SCIP_PROB* prob, /**< problem data */
1398  SCIP_Real dualbound /**< external dual bound */
1399  )
1400 {
1401  assert(prob != NULL);
1402 
1403  prob->dualbound = dualbound;
1404 }
1405 
1406 /** sets limit on objective function, such that only solutions better than this limit are accepted */
1408  SCIP_PROB* prob, /**< problem data */
1409  SCIP_Real objlim /**< external objective limit */
1410  )
1411 {
1412  assert(prob != NULL);
1413 
1414  prob->objlim = objlim;
1415 }
1416 
1417 /** informs the problem, that its objective value is always integral in every feasible solution */
1419  SCIP_PROB* prob /**< problem data */
1420  )
1421 {
1422  assert(prob != NULL);
1423 
1424  prob->objisintegral = TRUE;
1425 }
1426 
1427 /** sets integral objective value flag, if all variables with non-zero objective values are integral and have
1428  * integral objective value and also updates the cutoff bound if primal solution is already known
1429  */
1431  SCIP_PROB* transprob, /**< tranformed problem data */
1432  SCIP_PROB* origprob, /**< original problem data */
1433  BMS_BLKMEM* blkmem, /**< block memory */
1434  SCIP_SET* set, /**< global SCIP settings */
1435  SCIP_STAT* stat, /**< problem statistics data */
1436  SCIP_PRIMAL* primal, /**< primal data */
1437  SCIP_TREE* tree, /**< branch and bound tree */
1438  SCIP_REOPT* reopt, /**< reoptimization data structure */
1439  SCIP_LP* lp, /**< current LP data */
1440  SCIP_EVENTQUEUE* eventqueue /**< event queue */
1441  )
1442 {
1443  SCIP_Real obj;
1444  int v;
1445 
1446  assert(transprob != NULL);
1447  assert(origprob != NULL);
1448 
1449  /* if we know already, that the objective value is integral, nothing has to be done */
1450  if( transprob->objisintegral )
1451  return SCIP_OKAY;
1452 
1453  /* if there exist unknown variables, we cannot conclude that the objective value is always integral */
1454  if( set->nactivepricers != 0 )
1455  return SCIP_OKAY;
1456 
1457  /* if the objective value offset is fractional, the value itself is possibly fractional */
1458  if( !SCIPsetIsIntegral(set, transprob->objoffset) )
1459  return SCIP_OKAY;
1460 
1461  /* scan through the variables */
1462  for( v = 0; v < transprob->nvars; ++v )
1463  {
1464  /* get objective value of variable */
1465  obj = SCIPvarGetObj(transprob->vars[v]);
1466 
1467  /* check, if objective value is non-zero */
1468  if( !SCIPsetIsZero(set, obj) )
1469  {
1470  /* if variable's objective value is fractional, the problem's objective value may also be fractional */
1471  if( !SCIPsetIsIntegral(set, obj) )
1472  break;
1473 
1474  /* if variable with non-zero objective value is continuous, the problem's objective value may be fractional */
1475  if( SCIPvarGetType(transprob->vars[v]) == SCIP_VARTYPE_CONTINUOUS )
1476  break;
1477  }
1478  }
1479 
1480  /* objective value is integral, if the variable loop scanned all variables */
1481  if( v == transprob->nvars )
1482  {
1483  transprob->objisintegral = TRUE;
1484 
1485  /* update upper bound and cutoff bound in primal data structure due to new internality information */
1486  SCIP_CALL( SCIPprimalUpdateObjoffset(primal, blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp) );
1487  }
1488 
1489  return SCIP_OKAY;
1490 }
1491 
1492 /** update the number of variables with non-zero objective coefficient */
1494  SCIP_PROB* prob, /**< problem data */
1495  SCIP_SET* set, /**< global SCIP settings */
1496  SCIP_Real oldobj, /**< old objective value for variable */
1497  SCIP_Real newobj /**< new objective value for variable */
1498  )
1499 {
1500  assert(prob->transformed);
1501 
1502  if( !SCIPsetIsZero(set, oldobj) )
1503  prob->nobjvars--;
1504 
1505  if( !SCIPsetIsZero(set, newobj) )
1506  prob->nobjvars++;
1507 }
1508 
1509 /** update the dual bound if its better as the current one */
1511  SCIP_PROB* prob, /**< problem data */
1512  SCIP_Real newbound /**< new dual bound for the node (if it's tighter than the old one) */
1513  )
1514 {
1515  if( prob->dualbound == SCIP_INVALID ) /*lint !e777*/
1516  SCIPprobSetDualbound(prob, newbound);
1517  else
1518  {
1519  switch( prob->objsense )
1520  {
1522  prob->dualbound = MAX(newbound, prob->dualbound);
1523  break;
1524 
1526  prob->dualbound = MIN(newbound, prob->dualbound);
1527  break;
1528 
1529  default:
1530  SCIPerrorMessage("invalid objective sense <%d>\n", prob->objsense);
1531  SCIPABORT();
1532  }
1533  }
1534 }
1535 
1536 /** if possible, scales objective function such that it is integral with gcd = 1 */
1538  SCIP_PROB* transprob, /**< tranformed problem data */
1539  SCIP_PROB* origprob, /**< original problem data */
1540  BMS_BLKMEM* blkmem, /**< block memory */
1541  SCIP_SET* set, /**< global SCIP settings */
1542  SCIP_STAT* stat, /**< problem statistics data */
1543  SCIP_PRIMAL* primal, /**< primal data */
1544  SCIP_TREE* tree, /**< branch and bound tree */
1545  SCIP_REOPT* reopt, /**< reoptimization data structure */
1546  SCIP_LP* lp, /**< current LP data */
1547  SCIP_EVENTQUEUE* eventqueue /**< event queue */
1548  )
1549 {
1550  int v;
1551  int nints;
1552 
1553  assert(transprob != NULL);
1554  assert(set != NULL);
1555 
1556  /* do not change objective if there are pricers involved */
1557  if( set->nactivepricers != 0 )
1558  return SCIP_OKAY;
1559 
1560  nints = transprob->nvars - transprob->ncontvars;
1561 
1562  /* scan through the continuous variables */
1563  for( v = nints; v < transprob->nvars; ++v )
1564  {
1565  SCIP_Real obj;
1566 
1567  /* get objective value of variable; it it is non-zero, no scaling can be applied */
1568  obj = SCIPvarGetObj(transprob->vars[v]);
1569  if( !SCIPsetIsZero(set, obj) )
1570  break;
1571  }
1572 
1573  /* only continue if all continuous variables have obj = 0 */
1574  if( v == transprob->nvars )
1575  {
1576  SCIP_Real* objvals;
1577  SCIP_Real intscalar;
1578  SCIP_Bool success;
1579 
1580  /* get temporary memory */
1581  SCIP_CALL( SCIPsetAllocBufferArray(set, &objvals, nints) );
1582 
1583  /* get objective values of integer variables */
1584  for( v = 0; v < nints; ++v )
1585  objvals[v] = SCIPvarGetObj(transprob->vars[v]);
1586 
1587  /* calculate integral scalar */
1589  &intscalar, &success) );
1590 
1591  SCIPdebugMessage("integral objective scalar: success=%u, intscalar=%g\n", success, intscalar);
1592 
1593  if( success )
1594  {
1595  SCIP_Longint gcd;
1596 
1597  assert(intscalar > 0.0);
1598 
1599  /* calculate gcd of resulting integral coefficients */
1600  gcd = 0;
1601  for( v = 0; v < nints && gcd != 1; ++v )
1602  {
1603  SCIP_Longint absobj;
1604 
1605  absobj = (SCIP_Longint)(REALABS(objvals[v]) * intscalar + 0.5);
1606  if( gcd == 0 )
1607  gcd = absobj;
1608  else if( absobj > 0 )
1609  gcd = SCIPcalcGreComDiv(gcd, absobj);
1610  }
1611  if( gcd != 0 )
1612  intscalar /= gcd;
1613  SCIPdebugMessage("integral objective scalar: gcd=%" SCIP_LONGINT_FORMAT ", intscalar=%g\n", gcd, intscalar);
1614 
1615  /* only apply scaling if the final scalar is small enough */
1616  if( intscalar <= OBJSCALE_MAXFINALSCALE )
1617  {
1618  /* apply scaling */
1619  if( !SCIPsetIsEQ(set, intscalar, 1.0) )
1620  {
1621  /* calculate scaled objective values */
1622  for( v = 0; v < nints; ++v )
1623  {
1624  SCIP_Real newobj;
1625 
1626  /* check if new obj is really integral */
1627  newobj = intscalar * SCIPvarGetObj(transprob->vars[v]);
1628  if( !SCIPsetIsFeasIntegral(set, newobj) )
1629  break;
1630  objvals[v] = SCIPsetFeasFloor(set, newobj);
1631  }
1632 
1633  /* change the variables' objective values and adjust objscale and objoffset */
1634  if( v == nints )
1635  {
1636  for( v = 0; v < nints; ++v )
1637  {
1638  SCIPdebugMessage(" -> var <%s>: newobj = %.6f\n", SCIPvarGetName(transprob->vars[v]), objvals[v]);
1639  SCIP_CALL( SCIPvarChgObj(transprob->vars[v], blkmem, set, transprob, primal, lp, eventqueue, objvals[v]) );
1640  }
1641  transprob->objoffset *= intscalar;
1642  transprob->objscale /= intscalar;
1643  transprob->objisintegral = TRUE;
1644  SCIPdebugMessage("integral objective scalar: objscale=%g\n", transprob->objscale);
1645 
1646  /* update upperbound and cutoffbound in primal data structure */
1647  SCIP_CALL( SCIPprimalUpdateObjoffset(primal, blkmem, set, stat, eventqueue, transprob, origprob, tree, reopt, lp) );
1648  }
1649  }
1650  }
1651  }
1652 
1653  /* free temporary memory */
1654  SCIPsetFreeBufferArray(set, &objvals);
1655  }
1656 
1657  return SCIP_OKAY;
1658 }
1659 
1660 /** remembers the current solution as root solution in the problem variables */
1662  SCIP_PROB* prob, /**< problem data */
1663  SCIP_SET* set, /**< global SCIP settings */
1664  SCIP_LP* lp, /**< current LP data */
1665  SCIP_Bool roothaslp /**< is the root solution from LP? */
1666  )
1667 {
1668  int v;
1669 
1670  assert(prob != NULL);
1671  assert(prob->transformed);
1672 
1673  if( roothaslp )
1674  {
1675  for( v = 0; v < prob->nvars; ++v )
1676  SCIPvarStoreRootSol(prob->vars[v], roothaslp);
1677 
1679  SCIPlpStoreRootObjval(lp, set, prob);
1680  }
1681 }
1682 
1683 /** remembers the best solution w.r.t. root reduced cost propagation as root solution in the problem variables */
1685  SCIP_PROB* prob, /**< problem data */
1686  SCIP_SET* set, /**< global SCIP settings */
1687  SCIP_STAT* stat, /**< problem statistics */
1688  SCIP_LP* lp /**< current LP data */
1689  )
1690 {
1691  SCIP_Real rootlpobjval;
1692  int v;
1693 
1694  assert(prob != NULL);
1695  assert(lp != NULL);
1696  assert(prob->transformed);
1697  assert(lp->lpsolstat == SCIP_LPSOLSTAT_OPTIMAL);
1698 
1699  /* in case we have a zero objective fucntion, we skip the root reduced cost update */
1700  if( SCIPprobGetNObjVars(prob, set) == 0 )
1701  return;
1702 
1703  SCIPdebugMessage("update root reduced costs\n");
1704 
1705  /* compute current root LP objective value */
1706  rootlpobjval = SCIPlpGetObjval(lp, set, prob);
1707  assert(rootlpobjval != SCIP_INVALID); /*lint !e777*/
1708 
1709  for( v = 0; v < prob->nvars; ++v )
1710  {
1711  SCIP_VAR* var;
1712  SCIP_COL* col;
1713  SCIP_Real rootsol = 0.0;
1714  SCIP_Real rootredcost = 0.0;
1715 
1716  var = prob->vars[v];
1717  assert(var != NULL);
1718 
1719  /* check if the variable is part of the LP */
1721  continue;
1722 
1723  col = SCIPvarGetCol(var);
1724  assert(col != NULL);
1725 
1727 
1728  if( !SCIPvarIsBinary(var) )
1729  {
1730  rootsol = SCIPvarGetSol(var, TRUE);
1731  rootredcost = SCIPcolGetRedcost(col, stat, lp);
1732  }
1733  else
1734  {
1735  SCIP_Real primsol;
1736  SCIP_BASESTAT basestat;
1737  SCIP_Bool lpissolbasic;
1738 
1739  basestat = SCIPcolGetBasisStatus(col);
1740  lpissolbasic = SCIPlpIsSolBasic(lp);
1741  primsol = SCIPcolGetPrimsol(col);
1742 
1743  if( (lpissolbasic && (basestat == SCIP_BASESTAT_LOWER || basestat == SCIP_BASESTAT_UPPER)) ||
1744  (!lpissolbasic && (SCIPsetIsFeasEQ(set, SCIPvarGetLbLocal(var), primsol) ||
1745  SCIPsetIsFeasEQ(set, SCIPvarGetUbLocal(var), primsol))) )
1746  {
1747  SCIP_Real lbrootredcost;
1748  SCIP_Real ubrootredcost;
1749 
1750  /* get reduced cost if the variable gets fixed to zero */
1751  lbrootredcost = SCIPvarGetImplRedcost(var, set, FALSE, stat, prob, lp);
1752  assert( !SCIPsetIsDualfeasPositive(set, lbrootredcost)
1754 
1755  /* get reduced cost if the variable gets fixed to one */
1756  ubrootredcost = SCIPvarGetImplRedcost(var, set, TRUE, stat, prob, lp);
1757  assert( !SCIPsetIsDualfeasNegative(set, ubrootredcost)
1759 
1760  if( -lbrootredcost > ubrootredcost )
1761  {
1762  rootredcost = lbrootredcost;
1763  rootsol = 1.0;
1764  }
1765  else
1766  {
1767  rootredcost = ubrootredcost;
1768  rootsol = 0.0;
1769  }
1770  }
1771  }
1772 
1773  /* update the current solution as best root solution in the problem variables if it is better */
1774  SCIPvarUpdateBestRootSol(var, set, rootsol, rootredcost, rootlpobjval);
1775  }
1776 }
1777 
1778 /** informs problem, that the presolving process was finished, and updates all internal data structures */
1780  SCIP_PROB* prob, /**< problem data */
1781  SCIP_SET* set /**< global SCIP settings */
1782  )
1783 { /*lint --e{715}*/
1784  return SCIP_OKAY;
1785 }
1786 
1787 /** initializes problem for branch and bound process and resets all constraint's ages and histories of current run */
1789  SCIP_PROB* prob, /**< problem data */
1790  SCIP_SET* set /**< global SCIP settings */
1791  )
1792 {
1793  int c;
1794  int v;
1795 
1796  assert(prob != NULL);
1797  assert(prob->transformed);
1798  assert(set != NULL);
1799 
1800  /* reset constraint's ages */
1801  for( c = 0; c < prob->nconss; ++c )
1802  {
1803  SCIP_CALL( SCIPconsResetAge(prob->conss[c], set) );
1804  }
1805 
1806  /* initialize variables for solving */
1807  for( v = 0; v < prob->nvars; ++v )
1808  SCIPvarInitSolve(prob->vars[v]);
1809 
1810  /* call user data function */
1811  if( prob->probinitsol != NULL )
1812  {
1813  SCIP_CALL( prob->probinitsol(set->scip, prob->probdata) );
1814  }
1815 
1816  /* assert that the counter for variables with nonzero objective is correct */
1817  assert(prob->nobjvars == SCIPprobGetNObjVars(prob, set));
1818 
1819  return SCIP_OKAY;
1820 }
1821 
1822 /** deinitializes problem after branch and bound process, and converts all COLUMN variables back into LOOSE variables */
1824  SCIP_PROB* prob, /**< problem data */
1825  BMS_BLKMEM* blkmem, /**< block memory */
1826  SCIP_SET* set, /**< global SCIP settings */
1827  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1828  SCIP_LP* lp, /**< current LP data */
1829  SCIP_Bool restart /**< was this exit solve call triggered by a restart? */
1830  )
1831 {
1832  SCIP_VAR* var;
1833  int v;
1834 
1835  assert(prob != NULL);
1836  assert(prob->transformed);
1837  assert(set != NULL);
1838 
1839  /* call user data function */
1840  if( prob->probexitsol != NULL )
1841  {
1842  SCIP_CALL( prob->probexitsol(set->scip, prob->probdata, restart) );
1843  }
1844 
1845  /* convert all COLUMN variables back into LOOSE variables */
1846  if( prob->ncolvars > 0 )
1847  {
1848  for( v = 0; v < prob->nvars; ++v )
1849  {
1850  var = prob->vars[v];
1852  {
1853  SCIP_CALL( SCIPvarLoose(var, blkmem, set, eventqueue, prob, lp) );
1854  }
1855 
1856  /* invalided root reduced cost, root reduced solution, and root LP objective value for each variable */
1857  SCIPvarSetBestRootSol(var, 0.0, 0.0, SCIP_INVALID);
1858  }
1859  }
1860  assert(prob->ncolvars == 0);
1861 
1862  return SCIP_OKAY;
1863 }
1864 
1865 
1866 
1867 
1868 /*
1869  * problem information
1870  */
1871 
1872 /** sets problem name */
1874  SCIP_PROB* prob, /**< problem data */
1875  const char* name /**< name to be set */
1876  )
1877 {
1878  assert(prob != NULL);
1879 
1880  BMSfreeMemoryArray(&(prob->name));
1881  SCIP_ALLOC( BMSduplicateMemoryArray(&(prob->name), name, strlen(name)+1) );
1882 
1883  return SCIP_OKAY;
1884 }
1885 
1886 /** returns the number of implicit binary variables, meaning variable of vartype != SCIP_VARTYPE_BINARY and !=
1887  * SCIP_VARTYPE_CONTINUOUS but with global bounds [0,1]
1888  *
1889  * @note this number needs to be computed, because it cannot be updated like the other counters for binary and integer
1890  * variables, each time the variable type changes(, we would need to update this counter each time a global bound
1891  * changes), even at the end of presolving this cannot be computed, because some variable can change to an
1892  * implicit binary status
1893  */
1895  SCIP_PROB* prob /**< problem data */
1896  )
1897 {
1898  int v;
1899  int nimplbinvars = 0;
1900 
1901  for( v = prob->nbinvars + prob->nintvars + prob->nimplvars - 1; v >= prob->nbinvars; --v )
1902  {
1903  if( SCIPvarIsBinary(prob->vars[v]) )
1904  ++nimplbinvars;
1905  }
1906 
1907  return nimplbinvars;
1908 }
1909 
1910 /** returns the number of variables with non-zero objective coefficient */
1912  SCIP_PROB* prob, /**< problem data */
1913  SCIP_SET* set /**< global SCIP settings */
1914  )
1915 {
1916  if( prob->transformed )
1917  {
1918  /* this is much too expensive, to check it in each debug run */
1919 #ifdef SCIP_MORE_DEBUG
1920  int nobjvars;
1921  int v;
1922 
1923  nobjvars = 0;
1924 
1925  for( v = prob->nvars - 1; v >= 0; --v )
1926  {
1927  if( !SCIPsetIsZero(set, SCIPvarGetObj(prob->vars[v])) )
1928  nobjvars++;
1929  }
1930 
1931  /* check that the internal count is correct */
1932  assert(prob->nobjvars == nobjvars);
1933 #endif
1934  return prob->nobjvars;
1935  }
1936  else
1937  {
1938  int nobjvars;
1939  int v;
1940 
1941  nobjvars = 0;
1942 
1943  for( v = prob->nvars - 1; v >= 0; --v )
1944  {
1945  if( !SCIPsetIsZero(set, SCIPvarGetObj(prob->vars[v])) )
1946  nobjvars++;
1947  }
1948  return nobjvars;
1949  }
1950 }
1951 
1952 /** returns the external value of the given internal objective value */
1954  SCIP_PROB* transprob, /**< tranformed problem data */
1955  SCIP_PROB* origprob, /**< original problem data */
1956  SCIP_SET* set, /**< global SCIP settings */
1957  SCIP_Real objval /**< internal objective value */
1958  )
1959 {
1960  assert(set != NULL);
1961  assert(origprob != NULL);
1962  assert(transprob != NULL);
1963  assert(transprob->transformed);
1964  assert(transprob->objscale > 0.0);
1965 
1966  if( SCIPsetIsInfinity(set, objval) )
1967  return (SCIP_Real)transprob->objsense * SCIPsetInfinity(set);
1968  else if( SCIPsetIsInfinity(set, -objval) )
1969  return -(SCIP_Real)transprob->objsense * SCIPsetInfinity(set);
1970  else
1971  return (SCIP_Real)transprob->objsense * transprob->objscale * (objval + transprob->objoffset) + origprob->objoffset;
1972 }
1973 
1974 /** returns the internal value of the given external objective value */
1976  SCIP_PROB* transprob, /**< tranformed problem data */
1977  SCIP_PROB* origprob, /**< original problem data */
1978  SCIP_SET* set, /**< global SCIP settings */
1979  SCIP_Real objval /**< external objective value */
1980  )
1981 {
1982  assert(set != NULL);
1983  assert(origprob != NULL);
1984  assert(transprob != NULL);
1985  assert(transprob->transformed);
1986  assert(transprob->objscale > 0.0);
1987 
1988  if( SCIPsetIsInfinity(set, objval) )
1989  return (SCIP_Real)transprob->objsense * SCIPsetInfinity(set);
1990  else if( SCIPsetIsInfinity(set, -objval) )
1991  return -(SCIP_Real)transprob->objsense * SCIPsetInfinity(set);
1992  else
1993  return (SCIP_Real)transprob->objsense * (objval - origprob->objoffset)/transprob->objscale - transprob->objoffset;
1994 }
1995 
1996 /** returns variable of the problem with given name */
1998  SCIP_PROB* prob, /**< problem data */
1999  const char* name /**< name of variable to find */
2000  )
2001 {
2002  assert(prob != NULL);
2003  assert(name != NULL);
2004 
2005  if( prob->varnames == NULL )
2006  {
2007  SCIPerrorMessage("Cannot find variable if variable-names hashtable was disabled (due to parameter <misc/usevartable>)\n");
2008  SCIPABORT();/*lint --e{527}*/ /* only in debug mode */
2009  return NULL;
2010  }
2011 
2012  return (SCIP_VAR*)(SCIPhashtableRetrieve(prob->varnames, (char*)name));
2013 }
2014 
2015 /** returns constraint of the problem with given name */
2017  SCIP_PROB* prob, /**< problem data */
2018  const char* name /**< name of variable to find */
2019  )
2020 {
2021  assert(prob != NULL);
2022  assert(name != NULL);
2023 
2024  if( prob->consnames == NULL )
2025  {
2026  SCIPerrorMessage("Cannot find constraint if constraint-names hashtable was disabled (due to parameter <misc/useconstable>)\n");
2027  SCIPABORT();/*lint --e{527}*/ /* only in debug mode */
2028  return NULL;
2029  }
2030 
2031  return (SCIP_CONS*)(SCIPhashtableRetrieve(prob->consnames, (char*)name));
2032 }
2033 
2034 /** displays current pseudo solution */
2036  SCIP_PROB* prob, /**< problem data */
2037  SCIP_SET* set, /**< global SCIP settings */
2038  SCIP_MESSAGEHDLR* messagehdlr /**< message handler */
2039  )
2040 {
2041  SCIP_VAR* var;
2042  SCIP_Real solval;
2043  int v;
2044 
2045  for( v = 0; v < prob->nvars; ++v )
2046  {
2047  var = prob->vars[v];
2048  assert(var != NULL);
2049  solval = SCIPvarGetPseudoSol(var);
2050  if( !SCIPsetIsZero(set, solval) )
2051  SCIPmessagePrintInfo(messagehdlr, " <%s>=%.15g", SCIPvarGetName(var), solval);
2052  }
2053  SCIPmessagePrintInfo(messagehdlr, "\n");
2054 }
2055 
2056 /** outputs problem statistics */
2058  SCIP_PROB* prob, /**< problem data */
2059  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
2060  FILE* file /**< output file (or NULL for standard output) */
2061  )
2062 {
2063  assert(prob != NULL);
2064 
2065  SCIPmessageFPrintInfo(messagehdlr, file, " Problem name : %s\n", prob->name);
2066  SCIPmessageFPrintInfo(messagehdlr, file, " Variables : %d (%d binary, %d integer, %d implicit integer, %d continuous)\n",
2067  prob->nvars, prob->nbinvars, prob->nintvars, prob->nimplvars, prob->ncontvars);
2068  SCIPmessageFPrintInfo(messagehdlr, file, " Constraints : %d initial, %d maximal\n", prob->startnconss, prob->maxnconss);
2069  if( ! prob->transformed )
2070  SCIPmessageFPrintInfo(messagehdlr, file, " Objective sense : %s\n", prob->objsense == SCIP_OBJSENSE_MINIMIZE ? "minimize" : "maximize");
2071 }
2072 
2073 #ifndef NDEBUG
2074 
2075 /* In debug mode, the following methods are implemented as function calls to ensure
2076  * type validity.
2077  * In optimized mode, the methods are implemented as defines to improve performance.
2078  * However, we want to have them in the library anyways, so we have to undef the defines.
2079  */
2080 
2081 #undef SCIPprobIsPermuted
2082 #undef SCIPprobMarkPermuted
2083 #undef SCIPprobIsTransformed
2084 #undef SCIPprobIsObjIntegral
2085 #undef SCIPprobAllColsInLP
2086 #undef SCIPprobGetObjlim
2087 #undef SCIPprobGetData
2088 #undef SCIPprobGetName
2089 #undef SCIPprobGetNVars
2090 #undef SCIPprobGetNBinVars
2091 #undef SCIPprobGetNIntVars
2092 #undef SCIPprobGetNImplVars
2093 #undef SCIPprobGetNContVars
2094 #undef SCIPprobGetVars
2095 #undef SCIPprobGetObjoffset
2096 
2097 /** is the problem permuted */
2099  SCIP_PROB* prob
2100  )
2101 {
2102  assert(prob != NULL);
2103 
2104  return prob->permuted;
2105 }
2106 
2107 /** mark the problem as permuted */
2109  SCIP_PROB* prob
2110  )
2111 {
2112  assert(prob != NULL);
2113 
2114  prob->permuted = TRUE;
2115 }
2116 
2117 /** is the problem data transformed */
2119  SCIP_PROB* prob /**< problem data */
2120  )
2121 {
2122  assert(prob != NULL);
2123 
2124  return prob->transformed;
2125 }
2126 
2127 /** returns whether the objective value is known to be integral in every feasible solution */
2129  SCIP_PROB* prob /**< problem data */
2130  )
2131 {
2132  assert(prob != NULL);
2133 
2134  return prob->objisintegral;
2135 }
2136 
2137 /** returns TRUE iff all columns, i.e. every variable with non-empty column w.r.t. all ever created rows, are present
2138  * in the LP, and FALSE, if there are additional already existing columns, that may be added to the LP in pricing
2139  */
2141  SCIP_PROB* prob, /**< problem data */
2142  SCIP_SET* set, /**< global SCIP settings */
2143  SCIP_LP* lp /**< current LP data */
2144  )
2145 {
2146  assert(SCIPlpGetNCols(lp) <= prob->ncolvars && prob->ncolvars <= prob->nvars);
2147 
2148  return (SCIPlpGetNCols(lp) == prob->ncolvars && set->nactivepricers == 0);
2149 }
2150 
2151 /** gets limit on objective function in external space */
2153  SCIP_PROB* prob, /**< problem data */
2154  SCIP_SET* set /**< global SCIP settings */
2155  )
2156 {
2157  assert(prob != NULL);
2158  assert(set != NULL);
2159 
2160  return prob->objlim >= SCIP_INVALID ? (SCIP_Real)(prob->objsense) * SCIPsetInfinity(set) : prob->objlim;
2161 }
2162 
2163 /** gets user problem data */
2165  SCIP_PROB* prob /**< problem */
2166  )
2167 {
2168  assert(prob != NULL);
2169 
2170  return prob->probdata;
2171 }
2172 
2173 /** gets problem name */
2174 const char* SCIPprobGetName(
2175  SCIP_PROB* prob /**< problem data */
2176  )
2177 {
2178  assert(prob != NULL);
2179  return prob->name;
2180 }
2181 
2182 /** gets number of problem variables */
2184  SCIP_PROB* prob /**< problem data */
2185  )
2186 {
2187  assert(prob != NULL);
2188  return prob->nvars;
2189 }
2190 
2191 /** gets number of binary problem variables */
2193  SCIP_PROB* prob /**< problem data */
2194  )
2195 {
2196  assert(prob != NULL);
2197  return prob->nbinvars;
2198 }
2199 
2200 /** gets number of integer problem variables */
2202  SCIP_PROB* prob /**< problem data */
2203  )
2204 {
2205  assert(prob != NULL);
2206  return prob->nintvars;
2207 }
2208 
2209 /** gets number of implicit integer problem variables */
2211  SCIP_PROB* prob /**< problem data */
2212  )
2213 {
2214  assert(prob != NULL);
2215  return prob->nimplvars;
2216 }
2217 
2218 /** gets number of continuous problem variables */
2220  SCIP_PROB* prob /**< problem data */
2221  )
2222 {
2223  assert(prob != NULL);
2224  return prob->ncontvars;
2225 }
2226 
2227 /** gets problem variables */
2229  SCIP_PROB* prob /**< problem data */
2230  )
2231 {
2232  assert(prob != NULL);
2233  return prob->vars;
2234 }
2235 
2236 /** gets the objective offset */
2238  SCIP_PROB* prob /**< problem data */
2239  )
2240 {
2241  assert(prob != NULL);
2242  return prob->objoffset;
2243 }
2244 
2245 /** gets the objective scalar */
2247  SCIP_PROB* prob /**< problem data */
2248  )
2249 {
2250  assert(prob != NULL);
2251  return prob->objscale;
2252 }
2253 
2254 #endif
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:51
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:102
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5180
internal methods for managing events
SCIP_VAR * SCIPprobFindVar(SCIP_PROB *prob, const char *name)
Definition: prob.c:1997
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16443
int SCIPprobGetNBinVars(SCIP_PROB *prob)
Definition: prob.c:2192
void SCIPvarUpdateBestRootSol(SCIP_VAR *var, SCIP_SET *set, SCIP_Real rootsol, SCIP_Real rootredcost, SCIP_Real rootlpobjval)
Definition: var.c:12537
SCIP_RETCODE SCIPlpUpdateAddVar(SCIP_LP *lp, SCIP_SET *set, SCIP_VAR *var)
Definition: lp.c:15981
static void probInsertVar(SCIP_PROB *prob, SCIP_VAR *var)
Definition: prob.c:680
SCIP_HASHTABLE * varnames
Definition: struct_prob.h:53
SCIP_RETCODE SCIPconsActivate(SCIP_CONS *cons, SCIP_SET *set, SCIP_STAT *stat, int depth, SCIP_Bool focusnode)
Definition: cons.c:6379
unsigned int active
Definition: struct_cons.h:76
internal methods for branch and bound tree
void SCIPprobSetData(SCIP_PROB *prob, SCIP_PROBDATA *probdata)
Definition: prob.c:668
SCIP_PROBDATA * SCIPprobGetData(SCIP_PROB *prob)
Definition: prob.c:2164
SCIP_RETCODE SCIPhashtableInsert(SCIP_HASHTABLE *hashtable, void *element)
Definition: misc.c:1567
void SCIPprobUpdateBestRootSol(SCIP_PROB *prob, SCIP_SET *set, SCIP_STAT *stat, SCIP_LP *lp)
Definition: prob.c:1684
SCIP_Bool SCIPsetIsFeasEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5578
SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
Definition: var.c:16623
enum SCIP_BaseStat SCIP_BASESTAT
Definition: type_lpi.h:84
#define SCIP_DECL_PROBINITSOL(x)
Definition: type_prob.h:97
SCIP_Real SCIPvarGetSol(SCIP_VAR *var, SCIP_Bool getlpval)
Definition: var.c:12514
void SCIPlpSetRootLPIsRelax(SCIP_LP *lp, SCIP_Bool isrelax)
Definition: lp.c:19295
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:2057
#define SCIP_MAXSTRLEN
Definition: def.h:201
#define SCIP_DECL_PROBDELORIG(x)
Definition: type_prob.h:55
#define SCIPsetAllocBufferArray(set, ptr, num)
Definition: set.h:1788
#define NULL
Definition: lpi_spx.cpp:130
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17113
SCIP_RETCODE SCIPprobChgVarType(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_BRANCHCAND *branchcand, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var, SCIP_VARTYPE vartype)
Definition: prob.c:1093
SCIP_Real SCIPvarGetPseudoSol(SCIP_VAR *var)
Definition: var.c:17509
SCIP_RETCODE SCIPprobVarChangedStatus(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_BRANCHCAND *branchcand, SCIP_CLIQUETABLE *cliquetable, SCIP_VAR *var)
Definition: prob.c:1139
int nintvars
Definition: struct_prob.h:62
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
Definition: cons.c:7681
void SCIPprobAddObjoffset(SCIP_PROB *prob, SCIP_Real addval)
Definition: prob.c:1383
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:5042
int SCIPprobGetNVars(SCIP_PROB *prob)
Definition: prob.c:2183
int startnconss
Definition: struct_prob.h:75
#define SCIP_DECL_PROBDELTRANS(x)
Definition: type_prob.h:86
void SCIPvarSetProbindex(SCIP_VAR *var, int probindex)
Definition: var.c:5598
void SCIPprobStoreRootSol(SCIP_PROB *prob, SCIP_SET *set, SCIP_LP *lp, SCIP_Bool roothaslp)
Definition: prob.c:1661
static SCIP_Bool consHasName(SCIP_CONS *cons)
Definition: prob.c:150
#define FALSE
Definition: def.h:56
SCIP_Bool SCIPlpIsSolBasic(SCIP_LP *lp)
Definition: lp.c:19393
SCIP_Bool SCIPsetIsFeasIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5721
SCIP_Real objoffset
Definition: struct_prob.h:40
SCIP_RETCODE SCIPvarTransform(SCIP_VAR *origvar, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_OBJSENSE objsense, SCIP_VAR **transvar)
Definition: var.c:3277
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:8174
SCIP_Bool SCIPsetIsZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5292
#define TRUE
Definition: def.h:55
void SCIPprobSetExitsol(SCIP_PROB *prob, SCIP_DECL_PROBEXITSOL((*probexitsol)))
Definition: prob.c:372
void SCIPprobMarkNConss(SCIP_PROB *prob)
Definition: prob.c:1357
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
unsigned int enabled
Definition: struct_cons.h:81
#define SCIP_CALL(x)
Definition: def.h:266
SCIP_Real SCIPprobInternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:1975
internal methods for branching rules and branching candidate storage
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:4766
void SCIPvarSetBestRootSol(SCIP_VAR *var, SCIP_Real rootsol, SCIP_Real rootredcost, SCIP_Real rootlpobjval)
Definition: var.c:13101
void SCIPvarInitSolve(SCIP_VAR *var)
Definition: var.c:2797
SCIP_RETCODE SCIPprobInitSolve(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:1788
SCIP_VAR ** fixedvars
Definition: struct_prob.h:55
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)
Definition: prob.c:1537
SCIP_RETCODE SCIPprobFree(SCIP_PROB **prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: prob.c:394
#define SCIPdebugMessage
Definition: pub_message.h:77
void SCIPprobUpdateNObjVars(SCIP_PROB *prob, SCIP_SET *set, SCIP_Real oldobj, SCIP_Real newobj)
Definition: prob.c:1493
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:16905
int nimplvars
Definition: struct_prob.h:63
#define SCIP_DECL_PROBCOPY(x)
Definition: type_prob.h:140
SCIP_Bool SCIPconshdlrNeedsCons(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4781
SCIP_LPSOLSTAT SCIPlpGetSolstat(SCIP_LP *lp)
Definition: lp.c:15060
internal methods for LP management
SCIP_RETCODE SCIPconsResetAge(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:6787
SCIP_HASHTABLE * consnames
Definition: struct_prob.h:57
internal methods for collecting primal CIP solutions and primal informations
SCIP_CONSSETCHG * addconssetchg
Definition: struct_cons.h:47
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:1480
void SCIPprobSetObjIntegral(SCIP_PROB *prob)
Definition: prob.c:1418
int SCIPlpGetNCols(SCIP_LP *lp)
Definition: lp.c:19178
int nobjvars
Definition: struct_prob.h:70
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16562
SCIP_Real dualbound
Definition: struct_prob.h:44
void SCIPprobPrintPseudoSol(SCIP_PROB *prob, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr)
Definition: prob.c:2035
SCIP_Real SCIPprobGetObjlim(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:2152
int ndeletedvars
Definition: struct_prob.h:69
unsigned int deleted
Definition: struct_cons.h:84
SCIP_RETCODE SCIPprobAddConsName(SCIP_PROB *prob, SCIP_CONS *cons)
Definition: prob.c:1197
void SCIPprobSetInitsol(SCIP_PROB *prob, SCIP_DECL_PROBINITSOL((*probinitsol)))
Definition: prob.c:361
SCIP_Real SCIPprobGetObjscale(SCIP_PROB *prob)
Definition: prob.c:2246
static SCIP_RETCODE probEnsureVarsMem(SCIP_PROB *prob, SCIP_SET *set, int num)
Definition: prob.c:54
SCIP_RETCODE SCIPvarChgType(SCIP_VAR *var, SCIP_VARTYPE vartype)
Definition: var.c:5713
void SCIPprobSetCopy(SCIP_PROB *prob, SCIP_DECL_PROBCOPY((*probcopy)))
Definition: prob.c:383
SCIP_BASESTAT SCIPcolGetBasisStatus(SCIP_COL *col)
Definition: lp.c:18674
SCIP_Real SCIPvarGetImplRedcost(SCIP_VAR *var, SCIP_SET *set, SCIP_Bool varfixing, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_LP *lp)
Definition: var.c:12723
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:1022
static SCIP_RETCODE probEnsureDeletedvarsMem(SCIP_PROB *prob, SCIP_SET *set, int num)
Definition: prob.c:102
SCIP_RETCODE SCIPprobRemoveVarName(SCIP_PROB *prob, SCIP_VAR *var)
Definition: prob.c:878
void SCIPprobSetObjsense(SCIP_PROB *prob, SCIP_OBJSENSE objsense)
Definition: prob.c:1370
int SCIPprobGetNImplVars(SCIP_PROB *prob)
Definition: prob.c:2210
#define OBJSCALE_MAXFINALSCALE
Definition: prob.c:44
SCIP_Bool permuted
Definition: struct_prob.h:80
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_RETCODE SCIPconsTransform(SCIP_CONS *origcons, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_CONS **transcons)
Definition: cons.c:6060
SCIP_RETCODE SCIPprobExitSolve(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp, SCIP_Bool restart)
Definition: prob.c:1823
#define OBJSCALE_MAXDNOM
Definition: prob.c:42
SCIP_CONS * SCIPprobFindCons(SCIP_PROB *prob, const char *name)
Definition: prob.c:2016
SCIP_Real SCIPcolGetPrimsol(SCIP_COL *col)
Definition: lp.c:18639
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:5764
int varssize
Definition: struct_prob.h:59
SCIP_RETCODE SCIPvarRelease(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: var.c:2752
SCIP_RETCODE SCIPeventCreateVarAdded(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var)
Definition: event.c:436
SCIP_RETCODE SCIPconshdlrDelVars(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:3836
SCIP_Bool objisintegral
Definition: struct_prob.h:77
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:7620
SCIP_OBJSENSE objsense
Definition: struct_prob.h:76
static SCIP_RETCODE probEnsureConssMem(SCIP_PROB *prob, SCIP_SET *set, int num)
Definition: prob.c:126
#define BMSallocMemory(ptr)
Definition: memory.h:74
int SCIPprobGetNObjVars(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:1911
char * name
Definition: struct_prob.h:45
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:16771
SCIP_RETCODE SCIPprobSetName(SCIP_PROB *prob, const char *name)
Definition: prob.c:1873
SCIP_Bool SCIPprobIsObjIntegral(SCIP_PROB *prob)
Definition: prob.c:2128
void SCIPsortPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
internal methods for global SCIP settings
SCIP * scip
Definition: struct_cons.h:39
SCIP_RETCODE SCIPprobAddVarName(SCIP_PROB *prob, SCIP_VAR *var)
Definition: prob.c:862
SCIP_RETCODE SCIPprobResetBounds(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: prob.c:583
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:82
#define BMSfreeMemory(ptr)
Definition: memory.h:100
void SCIPmessagePrintInfo(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:578
SCIP_RETCODE SCIPhashtableRemove(SCIP_HASHTABLE *hashtable, void *element)
Definition: misc.c:1719
int SCIPprobGetNContVars(SCIP_PROB *prob)
Definition: prob.c:2219
SCIP_RETCODE SCIPconsAddLocks(SCIP_CONS *cons, SCIP_SET *set, int nlockspos, int nlocksneg)
Definition: cons.c:6950
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:250
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5202
SCIP_Real SCIPlpGetObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:15076
void SCIPprobResortVars(SCIP_PROB *prob)
Definition: prob.c:610
int SCIPprobGetNIntVars(SCIP_PROB *prob)
Definition: prob.c:2201
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:98
SCIP_RETCODE SCIPconshdlrUnlockVars(SCIP_CONSHDLR *conshdlr, SCIP_SET *set)
Definition: cons.c:3882
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:103
#define SCIP_DECL_PROBTRANS(x)
Definition: type_prob.h:74
SCIP_VAR * SCIPvarGetNegatedVar(SCIP_VAR *var)
Definition: var.c:16873
data structures and methods for collecting reoptimization information
internal methods for problem variables
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17123
SCIP_Bool SCIPsetIsIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5325
public data structures and miscellaneous methods
SCIP_PROBDATA * probdata
Definition: struct_prob.h:52
#define SCIP_Bool
Definition: def.h:53
#define SCIP_DECL_PROBEXITSOL(x)
Definition: type_prob.h:110
void SCIPvarCapture(SCIP_VAR *var)
Definition: var.c:2740
SCIP_Bool SCIPprobIsPermuted(SCIP_PROB *prob)
Definition: prob.c:2098
int ncontvars
Definition: struct_prob.h:64
int nbinvars
Definition: struct_prob.h:61
SCIP_Real SCIPprobGetObjoffset(SCIP_PROB *prob)
Definition: prob.c:2237
enum SCIP_Objsense SCIP_OBJSENSE
Definition: type_prob.h:41
SCIP_RETCODE SCIPvarRemove(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_CLIQUETABLE *cliquetable, SCIP_SET *set, SCIP_Bool final)
Definition: var.c:5631
SCIP_RETCODE SCIPconsRelease(SCIP_CONS **cons, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:5857
void SCIPvarStoreRootSol(SCIP_VAR *var, SCIP_Bool roothaslp)
Definition: var.c:12526
#define MAX(x, y)
Definition: tclique_def.h:75
void SCIPprobSetTrans(SCIP_PROB *prob, SCIP_DECL_PROBTRANS((*probtrans)))
Definition: prob.c:339
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)
Definition: prob.c:1430
SCIP_RETCODE SCIPeventCreateVarDeleted(SCIP_EVENT **event, BMS_BLKMEM *blkmem, SCIP_VAR *var)
Definition: event.c:454
SCIP_Bool SCIPprobAllColsInLP(SCIP_PROB *prob, SCIP_SET *set, SCIP_LP *lp)
Definition: prob.c:2140
SCIP_RETCODE SCIPprobRemoveConsName(SCIP_PROB *prob, SCIP_CONS *cons)
Definition: prob.c:1212
SCIP_VAR ** deletedvars
Definition: struct_prob.h:56
int probindex
Definition: struct_var.h:247
SCIP_RETCODE SCIPbranchcandUpdateVar(SCIP_BRANCHCAND *branchcand, SCIP_SET *set, SCIP_VAR *var)
Definition: branch.c:1080
void * SCIPhashtableRetrieve(SCIP_HASHTABLE *hashtable, void *key)
Definition: misc.c:1627
SCIP_Bool transformed
Definition: struct_prob.h:78
void SCIPprobPrintStatistics(SCIP_PROB *prob, SCIP_MESSAGEHDLR *messagehdlr, FILE *file)
Definition: prob.c:2057
void SCIPprobSetObjlim(SCIP_PROB *prob, SCIP_Real objlim)
Definition: prob.c:1407
int maxnconss
Definition: struct_prob.h:73
SCIP_RETCODE SCIPprobDelCons(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons)
Definition: prob.c:1297
int nfixedvars
Definition: struct_prob.h:67
int ncolvars
Definition: struct_prob.h:65
SCIP * scip
Definition: struct_var.h:199
SCIP_Bool SCIPprobIsTransformed(SCIP_PROB *prob)
Definition: prob.c:2118
void SCIPhashtableFree(SCIP_HASHTABLE **hashtable)
Definition: misc.c:1510
#define SCIP_HASHSIZE_NAMES
Definition: def.h:211
SCIP_Bool SCIPsetIsDualfeasPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5912
SCIP_RETCODE SCIPvarLoose(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *prob, SCIP_LP *lp)
Definition: var.c:3423
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16608
SCIP_Real SCIPsetFeasFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5747
void SCIPlpStoreRootObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:15135
SCIP_Real objlim
Definition: struct_prob.h:43
void SCIPconsCapture(SCIP_CONS *cons)
Definition: cons.c:5845
struct SCIP_ProbData SCIP_PROBDATA
Definition: type_prob.h:44
SCIP_Bool nlpenabled
Definition: struct_prob.h:79
int fixedvarssize
Definition: struct_prob.h:66
#define REALABS(x)
Definition: def.h:151
static SCIP_RETCODE probEnsureFixedvarsMem(SCIP_PROB *prob, SCIP_SET *set, int num)
Definition: prob.c:78
SCIP_Bool SCIPvarIsTransformedOrigvar(SCIP_VAR *var)
Definition: var.c:12120
static SCIP_RETCODE probRemoveVar(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_CLIQUETABLE *cliquetable, SCIP_SET *set, SCIP_VAR *var)
Definition: prob.c:768
SCIP_RETCODE SCIPprobCopy(SCIP_PROB **prob, BMS_BLKMEM *blkmem, SCIP_SET *set, const char *name, SCIP *sourcescip, SCIP_PROB *sourceprob, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global)
Definition: prob.c:184
int nconss
Definition: struct_prob.h:72
#define SCIP_HASHSIZE_NAMES_SMALL
Definition: def.h:214
public methods for message output
void SCIPprobUpdateDualbound(SCIP_PROB *prob, SCIP_Real newbound)
Definition: prob.c:1510
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:16750
void SCIPprobSetDelorig(SCIP_PROB *prob, SCIP_DECL_PROBDELORIG((*probdelorig)))
Definition: prob.c:328
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:602
SCIP_RETCODE SCIPvarResetBounds(SCIP_VAR *var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: var.c:8714
#define SCIP_Real
Definition: def.h:127
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:7799
internal methods for problem statistics
SCIP_VAR ** vars
Definition: struct_prob.h:54
void SCIPprobSetDualbound(SCIP_PROB *prob, SCIP_Real dualbound)
Definition: prob.c:1396
#define MIN(x, y)
Definition: memory.c:67
int consssize
Definition: struct_prob.h:71
SCIP_VAR ** SCIPprobGetVars(SCIP_PROB *prob)
Definition: prob.c:2228
#define SCIPsetFreeBufferArray(set, ptr)
Definition: set.h:1795
SCIP_CONS ** conss
Definition: struct_prob.h:58
#define SCIP_INVALID
Definition: def.h:147
internal methods for constraints and constraint handlers
SCIP_Bool SCIPlpIsRelax(SCIP_LP *lp)
Definition: lp.c:19373
SCIP_RETCODE SCIPprimalUpdateObjoffset(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp)
Definition: primal.c:365
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_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB **target)
Definition: prob.c:486
#define SCIP_Longint
Definition: def.h:112
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:7375
int SCIPprobGetNImplBinVars(SCIP_PROB *prob)
Definition: prob.c:1894
SCIP_RETCODE SCIPbranchcandRemoveVar(SCIP_BRANCHCAND *branchcand, SCIP_VAR *var)
Definition: branch.c:1063
SCIP_Bool SCIPhashtableExists(SCIP_HASHTABLE *hashtable, void *element)
Definition: misc.c:1692
void SCIPprobSetDeltrans(SCIP_PROB *prob, SCIP_DECL_PROBDELTRANS((*probdeltrans)))
Definition: prob.c:350
SCIP_Real SCIPsetEpsilon(SCIP_SET *set)
Definition: set.c:5064
SCIP_STAGE SCIPsetGetStage(SCIP_SET *set)
Definition: set.c:2423
unsigned int updatedeactivate
Definition: struct_cons.h:88
enum SCIP_Vartype SCIP_VARTYPE
Definition: type_var.h:58
SCIP_Real SCIPprobExternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:1953
static SCIP_Bool varHasName(SCIP_VAR *var)
Definition: prob.c:163
SCIP_RETCODE SCIPprobAddCons(SCIP_PROB *prob, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons)
Definition: prob.c:1230
int addarraypos
Definition: struct_cons.h:49
SCIP_RETCODE SCIPconsDeactivate(SCIP_CONS *cons, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:6421
SCIP_Bool SCIPsetIsDualfeasNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5923
void SCIPconsSetLocal(SCIP_CONS *cons, SCIP_Bool local)
Definition: cons.c:6297
SCIP_RETCODE SCIPprobDelVar(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *var, SCIP_Bool *deleted)
Definition: prob.c:961
common defines and data types used in all packages of SCIP
SCIP_Longint nnodes
Definition: struct_stat.h:64
SCIP_RETCODE SCIPprobExitPresolve(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:1779
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:392
SCIP_RETCODE SCIPlpUpdateDelVar(SCIP_LP *lp, SCIP_SET *set, SCIP_VAR *var)
Definition: lp.c:16002
int startnvars
Definition: struct_prob.h:74
SCIP_Real SCIPcolGetRedcost(SCIP_COL *col, SCIP_STAT *stat, SCIP_LP *lp)
Definition: lp.c:3758
#define SCIP_ALLOC(x)
Definition: def.h:277
#define SCIPABORT()
Definition: def.h:238
SCIP_LPSOLSTAT lpsolstat
Definition: struct_lp.h:326
SCIP_RETCODE SCIPconshdlrLockVars(SCIP_CONSHDLR *conshdlr, SCIP_SET *set)
Definition: cons.c:3867
const char * SCIPprobGetName(SCIP_PROB *prob)
Definition: prob.c:2174
SCIP_Longint SCIPcalcGreComDiv(SCIP_Longint val1, SCIP_Longint val2)
Definition: misc.c:7083
void SCIPprobMarkPermuted(SCIP_PROB *prob)
Definition: prob.c:2108
void SCIPvarMarkDeleted(SCIP_VAR *var)
Definition: var.c:5667
#define OBJSCALE_MAXSCALE
Definition: prob.c:43
SCIP_RETCODE SCIPprobAddVar(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *var)
Definition: prob.c:893
SCIP_Real objscale
Definition: struct_prob.h:41
int deletedvarssize
Definition: struct_prob.h:68