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