Scippy

SCIP

Solving Constraint Integer Programs

scip_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-2018 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file scip_prob.c
17  * @brief public methods for global and local (sub)problems
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  * @author Gerald Gamrath
21  * @author Robert Lion Gottwald
22  * @author Stefan Heinz
23  * @author Gregor Hendel
24  * @author Thorsten Koch
25  * @author Alexander Martin
26  * @author Marc Pfetsch
27  * @author Michael Winkler
28  * @author Kati Wolter
29  *
30  * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #include <ctype.h>
36 #include <stdarg.h>
37 #include <assert.h>
38 #include <string.h>
39 #if defined(_WIN32) || defined(_WIN64)
40 #else
41 #include <strings.h> /*lint --e{766}*/
42 #endif
43 
44 
45 #include "lpi/lpi.h"
46 #include "nlpi/exprinterpret.h"
47 #include "nlpi/nlpi.h"
48 #include "scip/benders.h"
49 #include "scip/benderscut.h"
50 #include "scip/branch.h"
51 #include "scip/branch_nodereopt.h"
52 #include "scip/clock.h"
53 #include "scip/compr.h"
54 #include "scip/concsolver.h"
55 #include "scip/concurrent.h"
56 #include "scip/conflict.h"
57 #include "scip/conflictstore.h"
58 #include "scip/cons.h"
59 #include "scip/cons_linear.h"
60 #include "scip/cutpool.h"
61 #include "scip/cuts.h"
62 #include "scip/debug.h"
63 #include "scip/def.h"
64 #include "scip/dialog.h"
65 #include "scip/dialog_default.h"
66 #include "scip/disp.h"
67 #include "scip/event.h"
68 #include "scip/heur.h"
69 #include "scip/heur_ofins.h"
70 #include "scip/heur_reoptsols.h"
72 #include "scip/heuristics.h"
73 #include "scip/history.h"
74 #include "scip/implics.h"
75 #include "scip/interrupt.h"
76 #include "scip/lp.h"
77 #include "scip/mem.h"
78 #include "scip/message_default.h"
79 #include "scip/misc.h"
80 #include "scip/nlp.h"
81 #include "scip/nodesel.h"
82 #include "scip/paramset.h"
83 #include "scip/presol.h"
84 #include "scip/presolve.h"
85 #include "scip/pricer.h"
86 #include "scip/pricestore.h"
87 #include "scip/primal.h"
88 #include "scip/prob.h"
89 #include "scip/prop.h"
90 #include "scip/reader.h"
91 #include "scip/relax.h"
92 #include "scip/reopt.h"
93 #include "scip/retcode.h"
94 #include "scip/scipbuildflags.h"
95 #include "scip/scipcoreplugins.h"
96 #include "scip/scipgithash.h"
97 #include "scip/sepa.h"
98 #include "scip/sepastore.h"
99 #include "scip/set.h"
100 #include "scip/sol.h"
101 #include "scip/solve.h"
102 #include "scip/stat.h"
103 #include "scip/syncstore.h"
104 #include "scip/table.h"
105 #include "scip/tree.h"
106 #include "scip/var.h"
107 #include "scip/visual.h"
108 #include "xml/xml.h"
109 
110 #include "scip/scip_cons.h"
111 #include "scip/scip_general.h"
112 #include "scip/scip_mem.h"
113 #include "scip/scip_numerics.h"
114 #include "scip/scip_param.h"
115 #include "scip/scip_prob.h"
116 #include "scip/scip_randnumgen.h"
117 #include "scip/scip_sol.h"
118 #include "scip/scip_solve.h"
119 #include "scip/scip_solvingstats.h"
120 #include "scip/scip_timing.h"
121 #include "scip/scip_var.h"
122 
123 #include "scip/pub_cons.h"
124 #include "scip/pub_event.h"
125 #include "scip/pub_message.h"
126 #include "scip/pub_misc.h"
127 #include "scip/pub_reader.h"
128 #include "scip/pub_sol.h"
129 #include "scip/pub_tree.h"
130 #include "scip/pub_var.h"
131 
132 
133 /* In debug mode, we include the SCIP's structure in scip.c, such that no one can access
134  * this structure except the interface methods in scip.c.
135  * In optimized mode, the structure is included in scip.h, because some of the methods
136  * are implemented as defines for performance reasons (e.g. the numerical comparisons)
137  */
138 #ifndef NDEBUG
139 #include "scip/struct_scip.h"
140 #endif
141 
142 /** creates empty problem and initializes all solving data structures (the objective sense is set to MINIMIZE)
143  * If the problem type requires the use of variable pricers, these pricers should be added to the problem with calls
144  * to SCIPactivatePricer(). These pricers are automatically deactivated, when the problem is freed.
145  *
146  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
147  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
148  *
149  * @pre This method can be called if @p scip is in one of the following stages:
150  * - \ref SCIP_STAGE_INIT
151  * - \ref SCIP_STAGE_PROBLEM
152  * - \ref SCIP_STAGE_TRANSFORMED
153  * - \ref SCIP_STAGE_PRESOLVING
154  * - \ref SCIP_STAGE_PRESOLVED
155  * - \ref SCIP_STAGE_SOLVING
156  * - \ref SCIP_STAGE_SOLVED
157  * - \ref SCIP_STAGE_FREE
158  *
159  * @post After calling this method, \SCIP reaches the following stage:
160  * - \ref SCIP_STAGE_PROBLEM
161  */
163  SCIP* scip, /**< SCIP data structure */
164  const char* name, /**< problem name */
165  SCIP_DECL_PROBDELORIG ((*probdelorig)), /**< frees user data of original problem */
166  SCIP_DECL_PROBTRANS ((*probtrans)), /**< creates user data of transformed problem by transforming original user data */
167  SCIP_DECL_PROBDELTRANS((*probdeltrans)), /**< frees user data of transformed problem */
168  SCIP_DECL_PROBINITSOL ((*probinitsol)), /**< solving process initialization method of transformed data */
169  SCIP_DECL_PROBEXITSOL ((*probexitsol)), /**< solving process deinitialization method of transformed data */
170  SCIP_DECL_PROBCOPY ((*probcopy)), /**< copies user data if you want to copy it to a subscip, or NULL */
171  SCIP_PROBDATA* probdata /**< user problem data set by the reader */
172  )
173 {
174  SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateProb", TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE) );
175 
176  /* free old problem */
177  SCIP_CALL( SCIPfreeProb(scip) );
178  assert(scip->set->stage == SCIP_STAGE_INIT);
179 
180  /* switch stage to PROBLEM */
181  scip->set->stage = SCIP_STAGE_PROBLEM;
182 
183  SCIP_CALL( SCIPstatCreate(&scip->stat, scip->mem->probmem, scip->set, NULL, NULL, scip->messagehdlr) );
184 
185  SCIP_CALL( SCIPprobCreate(&scip->origprob, scip->mem->probmem, scip->set, name,
186  probdelorig, probtrans, probdeltrans, probinitsol, probexitsol, probcopy, probdata, FALSE) );
187 
188  /* create solution pool for original solution candidates */
190 
191  /* create conflict pool for storing conflict constraints */
193 
194  /* initialize reoptimization structure, if needed */
196 
197  return SCIP_OKAY;
198 }
199 
200 /** creates empty problem and initializes all solving data structures (the objective sense is set to MINIMIZE)
201  * all callback methods will be set to NULL and can be set afterwards, if needed, via SCIPsetProbDelorig(),
202  * SCIPsetProbTrans(), SCIPsetProbDeltrans(), SCIPsetProbInitsol(), SCIPsetProbExitsol(), and
203  * SCIPsetProbCopy()
204  * If the problem type requires the use of variable pricers, these pricers should be added to the problem with calls
205  * to SCIPactivatePricer(). These pricers are automatically deactivated, when the problem is freed.
206  *
207  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
208  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
209  *
210  * @pre This method can be called if @p scip is in one of the following stages:
211  * - \ref SCIP_STAGE_INIT
212  * - \ref SCIP_STAGE_PROBLEM
213  * - \ref SCIP_STAGE_TRANSFORMED
214  * - \ref SCIP_STAGE_PRESOLVING
215  * - \ref SCIP_STAGE_PRESOLVED
216  * - \ref SCIP_STAGE_SOLVING
217  * - \ref SCIP_STAGE_SOLVED
218  * - \ref SCIP_STAGE_FREE
219  *
220  * @post After calling this method, \SCIP reaches the following stage:
221  * - \ref SCIP_STAGE_PROBLEM
222  */
224  SCIP* scip, /**< SCIP data structure */
225  const char* name /**< problem name */
226  )
227 {
228  SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateProbBasic", TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE) );
229 
230  SCIP_CALL( SCIPcreateProb(scip, name, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
231 
232  return SCIP_OKAY;
233 }
234 
235 /** sets callback to free user data of original problem
236  *
237  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
238  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
239  *
240  * @pre This method can be called if @p scip is in one of the following stages:
241  * - \ref SCIP_STAGE_PROBLEM
242  */
244  SCIP* scip, /**< SCIP data structure */
245  SCIP_DECL_PROBDELORIG ((*probdelorig)) /**< frees user data of original problem */
246  )
247 {
248  assert(scip != NULL);
249  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetProbDelorig", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
250 
251  SCIPprobSetDelorig(scip->origprob, probdelorig);
252 
253  return SCIP_OKAY;
254 }
255 
256 /** sets callback to create user data of transformed problem by transforming original user data
257  *
258  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
259  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
260  *
261  * @pre This method can be called if @p scip is in one of the following stages:
262  * - \ref SCIP_STAGE_PROBLEM
263  */
265  SCIP* scip, /**< SCIP data structure */
266  SCIP_DECL_PROBTRANS ((*probtrans)) /**< creates user data of transformed problem by transforming original user data */
267  )
268 {
269  assert(scip != NULL);
270  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetProbTrans", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
271 
272  SCIPprobSetTrans(scip->origprob, probtrans);
273 
274  return SCIP_OKAY;
275 }
276 
277 /** sets callback to free user data of transformed problem
278  *
279  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
280  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
281  *
282  * @pre This method can be called if @p scip is in one of the following stages:
283  * - \ref SCIP_STAGE_PROBLEM
284  */
286  SCIP* scip, /**< SCIP data structure */
287  SCIP_DECL_PROBDELTRANS((*probdeltrans)) /**< frees user data of transformed problem */
288  )
289 {
290  assert(scip != NULL);
291  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetProbDeltrans", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
292 
293  SCIPprobSetDeltrans(scip->origprob, probdeltrans);
294 
295  return SCIP_OKAY;
296 }
297 
298 /** sets solving process initialization callback of transformed data
299  *
300  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
301  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
302  *
303  * @pre This method can be called if @p scip is in one of the following stages:
304  * - \ref SCIP_STAGE_PROBLEM
305  */
307  SCIP* scip, /**< SCIP data structure */
308  SCIP_DECL_PROBINITSOL ((*probinitsol)) /**< solving process initialization method of transformed data */
309  )
310 {
311  assert(scip != NULL);
312 
313  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetProbInitsol", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
314 
315  SCIPprobSetInitsol(scip->origprob, probinitsol);
316 
317  return SCIP_OKAY;
318 }
319 
320 /** sets solving process deinitialization callback of transformed data
321  *
322  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
323  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
324  *
325  * @pre This method can be called if @p scip is in one of the following stages:
326  * - \ref SCIP_STAGE_PROBLEM
327  */
329  SCIP* scip, /**< SCIP data structure */
330  SCIP_DECL_PROBEXITSOL ((*probexitsol)) /**< solving process deinitialization method of transformed data */
331  )
332 {
333  assert(scip != NULL);
334  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetProbExitsol", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
335 
336  SCIPprobSetExitsol(scip->origprob, probexitsol);
337 
338  return SCIP_OKAY;
339 }
340 
341 /** sets callback to copy user data to a subscip
342  *
343  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
344  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
345  *
346  * @pre This method can be called if @p scip is in one of the following stages:
347  * - \ref SCIP_STAGE_PROBLEM
348  */
350  SCIP* scip, /**< SCIP data structure */
351  SCIP_DECL_PROBCOPY ((*probcopy)) /**< copies user data if you want to copy it to a subscip, or NULL */
352  )
353 {
354  assert(scip != NULL);
355  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetProbCopy", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
356 
357  SCIPprobSetCopy(scip->origprob, probcopy);
358 
359  return SCIP_OKAY;
360 }
361 
362 /** reads problem from file and initializes all solving data structures
363  *
364  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
365  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
366  *
367  * @pre This method can be called if @p scip is in one of the following stages:
368  * - \ref SCIP_STAGE_INIT
369  * - \ref SCIP_STAGE_PROBLEM
370  * - \ref SCIP_STAGE_TRANSFORMED
371  * - \ref SCIP_STAGE_INITPRESOLVE
372  * - \ref SCIP_STAGE_PRESOLVING
373  * - \ref SCIP_STAGE_EXITPRESOLVE
374  * - \ref SCIP_STAGE_PRESOLVED
375  * - \ref SCIP_STAGE_SOLVING
376  * - \ref SCIP_STAGE_EXITSOLVE
377  *
378  * @post After the method was called, \SCIP is in one of the following stages:
379  * - \ref SCIP_STAGE_INIT if reading failed (usually, when a SCIP_READERROR occurs)
380  * - \ref SCIP_STAGE_PROBLEM if the problem file was successfully read
381  */
383  SCIP* scip, /**< SCIP data structure */
384  const char* filename, /**< problem file name */
385  const char* extension /**< extension of the desired file reader,
386  * or NULL if file extension should be used */
387  )
388 {
389  SCIP_RETCODE retcode;
390  SCIP_RESULT result;
391  SCIP_Bool usevartable;
392  SCIP_Bool useconstable;
393  int i;
394  char* tmpfilename;
395  char* fileextension;
396 
397  assert(scip != NULL);
398  assert(filename != NULL);
399 
400  SCIP_CALL( SCIPcheckStage(scip, "SCIPreadProb", TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
401 
402  SCIP_CALL( SCIPgetBoolParam(scip, "misc/usevartable", &usevartable) );
403  SCIP_CALL( SCIPgetBoolParam(scip, "misc/useconstable", &useconstable) );
404 
405  if( !usevartable || !useconstable )
406  {
407  SCIPerrorMessage("Cannot read problem if vartable or constable is disabled. Make sure parameters 'misc/usevartable' and 'misc/useconstable' are set to TRUE.\n");
408  return SCIP_READERROR;
409  }
410 
411  /* try all readers until one could read the file */
412  result = SCIP_DIDNOTRUN;
413 
414  /* copy filename */
415  SCIP_CALL( SCIPduplicateBufferArray(scip, &tmpfilename, filename, (int)strlen(filename)+1) );
416 
417  fileextension = NULL;
418  if( extension == NULL )
419  {
420  /* get extension from filename */
421  SCIPsplitFilename(tmpfilename, NULL, NULL, &fileextension, NULL);
422  }
423 
424  for( i = 0; i < scip->set->nreaders && result == SCIP_DIDNOTRUN; ++i )
425  {
426  retcode = SCIPreaderRead(scip->set->readers[i], scip->set, filename,
427  extension != NULL ? extension : fileextension, &result);
428 
429  /* check for reader errors */
430  if( retcode == SCIP_NOFILE || retcode == SCIP_READERROR )
431  goto TERMINATE;
432  SCIP_CALL( retcode );
433  }
434 
435  switch( result )
436  {
437  case SCIP_DIDNOTRUN:
438  retcode = SCIP_PLUGINNOTFOUND;
439  break;
440  case SCIP_SUCCESS:
441  if( scip->origprob != NULL )
442  {
443  SCIP_Real readingtime;
444 
446  "original problem has %d variables (%d bin, %d int, %d impl, %d cont) and %d constraints\n",
447  scip->origprob->nvars, scip->origprob->nbinvars, scip->origprob->nintvars,
448  scip->origprob->nimplvars, scip->origprob->ncontvars,
449  scip->origprob->nconss);
450 
451  /* in full verbose mode we will also print the number of constraints per constraint handler */
452  if( scip->set->disp_verblevel == SCIP_VERBLEVEL_FULL )
453  {
454  int* nconss;
455  int c;
456  int h;
457 
458  SCIP_CALL( SCIPallocClearBufferArray(scip, &nconss, scip->set->nconshdlrs) );
459 
460  /* loop over all constraints and constraint-handlers to count for each type the amount of original
461  * constraints
462  */
463  for( c = scip->origprob->nconss - 1; c >= 0; --c )
464  {
465  for( h = scip->set->nconshdlrs - 1; h >= 0; --h )
466  {
467  if( scip->origprob->conss[c]->conshdlr == scip->set->conshdlrs[h] )
468  {
469  ++(nconss[h]);
470  break;
471  }
472  }
473  /* constraint handler should be found */
474  assert(h >= 0);
475  }
476 
477  /* loop over all constraints handlers for printing the number of original constraints */
478  for( h = 0; h < scip->set->nconshdlrs; ++h )
479  {
480  if( nconss[h] > 0 )
481  {
483  "%7d constraints of type <%s>\n", nconss[h], SCIPconshdlrGetName(scip->set->conshdlrs[h]));
484  }
485  }
486 
487  SCIPfreeBufferArray(scip, &nconss);
488  }
489 
490  /* in case the permutation seed is different to 0, permute the original problem */
491  if( scip->set->random_permutationseed > 0 )
492  {
493  SCIP_Bool permuteconss;
494  SCIP_Bool permutevars;
495  int permutationseed;
496 
497  permuteconss = scip->set->random_permuteconss;
498  permutevars = scip->set->random_permutevars;
499  permutationseed = scip->set->random_permutationseed;
500 
501  SCIP_CALL( SCIPpermuteProb(scip, (unsigned int)permutationseed, permuteconss, permutevars, permutevars, permutevars, permutevars) );
502  }
503 
504  /* get reading time */
505  readingtime = SCIPgetReadingTime(scip);
506 
507  /* display timing statistics */
509  "Reading Time: %.2f\n", readingtime);
510  }
511  retcode = SCIP_OKAY;
512  break;
513  default:
514  assert(i < scip->set->nreaders);
515  SCIPerrorMessage("invalid result code <%d> from reader <%s> reading file <%s>\n",
516  result, SCIPreaderGetName(scip->set->readers[i]), filename);
517  retcode = SCIP_READERROR;
518  } /*lint !e788*/
519 
520  TERMINATE:
521  /* free buffer array */
522  SCIPfreeBufferArray(scip, &tmpfilename);
523 
524  /* check if reading time should belong to solving time */
525  if( scip->set->time_reading )
526  {
527  SCIP_Real readingtime;
528 
529  /* get reading time */
530  readingtime = SCIPgetReadingTime(scip);
531 
532  /* add reading time to solving time */
533  SCIPclockSetTime(scip->stat->solvingtime, readingtime);
534  }
535 
536  return retcode;
537 }
538 
539 /** write original or transformed problem */
540 static
542  SCIP* scip, /**< SCIP data structure */
543  const char* filename, /**< output file (or NULL for standard output) */
544  const char* extension, /**< extension of the desired file reader,
545  * or NULL if file extension should be used */
546  SCIP_Bool transformed, /**< output the transformed problem? */
547  SCIP_Bool genericnames /**< using generic variable and constraint names? */
548  )
549 {
550  SCIP_RETCODE retcode;
551  char* tmpfilename;
552  char* fileextension;
553  char* compression;
554  FILE* file;
555 
556  assert(scip != NULL );
557 
558  fileextension = NULL;
559  compression = NULL;
560  file = NULL;
561  tmpfilename = NULL;
562 
563  if( filename != NULL && filename[0] != '\0' )
564  {
565  int success;
566 
567  file = fopen(filename, "w");
568  if( file == NULL )
569  {
570  SCIPerrorMessage("cannot create file <%s> for writing\n", filename);
571  SCIPprintSysError(filename);
572  return SCIP_FILECREATEERROR;
573  }
574 
575  /* get extension from filename,
576  * if an error occurred, close the file before returning */
577  if( BMSduplicateMemoryArray(&tmpfilename, filename, strlen(filename)+1) == NULL )
578  {
579  (void) fclose(file);
580  SCIPerrorMessage("Error <%d> in function call\n", SCIP_NOMEMORY);
581  return SCIP_NOMEMORY;
582  }
583 
584  SCIPsplitFilename(tmpfilename, NULL, NULL, &fileextension, &compression);
585 
586  if( compression != NULL )
587  {
588  SCIPmessagePrintWarning(scip->messagehdlr, "currently it is not possible to write files with any compression\n");
589  BMSfreeMemoryArray(&tmpfilename);
590  (void) fclose(file);
591  return SCIP_FILECREATEERROR;
592  }
593 
594  if( extension == NULL && fileextension == NULL )
595  {
596  SCIPmessagePrintWarning(scip->messagehdlr, "filename <%s> has no file extension, select default <cip> format for writing\n", filename);
597  }
598 
599  if( transformed )
600  retcode = SCIPprintTransProblem(scip, file, extension != NULL ? extension : fileextension, genericnames);
601  else
602  retcode = SCIPprintOrigProblem(scip, file, extension != NULL ? extension : fileextension, genericnames);
603 
604  BMSfreeMemoryArray(&tmpfilename);
605 
606  success = fclose(file);
607  if( success != 0 )
608  {
609  SCIPerrorMessage("An error occurred while closing file <%s>\n", filename);
610  return SCIP_FILECREATEERROR;
611  }
612  }
613  else
614  {
615  /* print to stdout */
616  if( transformed )
617  retcode = SCIPprintTransProblem(scip, NULL, extension, genericnames);
618  else
619  retcode = SCIPprintOrigProblem(scip, NULL, extension, genericnames);
620  }
621 
622  /* check for write errors */
623  if( retcode == SCIP_WRITEERROR || retcode == SCIP_PLUGINNOTFOUND )
624  return retcode;
625  else
626  {
627  SCIP_CALL( retcode );
628  }
629 
630  return SCIP_OKAY;
631 }
632 
633 /** writes original problem to file
634  *
635  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
636  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
637  *
638  * @pre This method can be called if @p scip is in one of the following stages:
639  * - \ref SCIP_STAGE_PROBLEM
640  * - \ref SCIP_STAGE_TRANSFORMING
641  * - \ref SCIP_STAGE_TRANSFORMED
642  * - \ref SCIP_STAGE_INITPRESOLVE
643  * - \ref SCIP_STAGE_PRESOLVING
644  * - \ref SCIP_STAGE_EXITPRESOLVE
645  * - \ref SCIP_STAGE_PRESOLVED
646  * - \ref SCIP_STAGE_INITSOLVE
647  * - \ref SCIP_STAGE_SOLVING
648  * - \ref SCIP_STAGE_SOLVED
649  * - \ref SCIP_STAGE_EXITSOLVE
650  * - \ref SCIP_STAGE_FREETRANS
651  */
653  SCIP* scip, /**< SCIP data structure */
654  const char* filename, /**< output file (or NULL for standard output) */
655  const char* extension, /**< extension of the desired file reader,
656  * or NULL if file extension should be used */
657  SCIP_Bool genericnames /**< using generic variable and constraint names? */
658  )
659 {
660  SCIP_RETCODE retcode;
661 
662  SCIP_CALL( SCIPcheckStage(scip, "SCIPwriteOrigProblem", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
663 
664  assert( scip != NULL );
665  assert( scip->origprob != NULL );
666 
667  retcode = writeProblem(scip, filename, extension, FALSE, genericnames);
668 
669  /* check for write errors */
670  if( retcode == SCIP_FILECREATEERROR || retcode == SCIP_WRITEERROR || retcode == SCIP_PLUGINNOTFOUND )
671  return retcode;
672  else
673  {
674  SCIP_CALL( retcode );
675  }
676 
677  return SCIP_OKAY;
678 }
679 
680 /** writes transformed problem which are valid in the current node to file
681  *
682  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
683  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
684  *
685  * @pre This method can be called if @p scip is in one of the following stages:
686  * - \ref SCIP_STAGE_TRANSFORMED
687  * - \ref SCIP_STAGE_INITPRESOLVE
688  * - \ref SCIP_STAGE_PRESOLVING
689  * - \ref SCIP_STAGE_EXITPRESOLVE
690  * - \ref SCIP_STAGE_PRESOLVED
691  * - \ref SCIP_STAGE_INITSOLVE
692  * - \ref SCIP_STAGE_SOLVING
693  * - \ref SCIP_STAGE_SOLVED
694  * - \ref SCIP_STAGE_EXITSOLVE
695  *
696  * @note If you want the write all constraints (including the once which are redundant for example), you need to set
697  * the parameter <write/allconss> to TRUE
698  */
700  SCIP* scip, /**< SCIP data structure */
701  const char* filename, /**< output file (or NULL for standard output) */
702  const char* extension, /**< extension of the desired file reader,
703  * or NULL if file extension should be used */
704  SCIP_Bool genericnames /**< using generic variable and constraint names? */
705  )
706 {
707  SCIP_RETCODE retcode;
708 
709  SCIP_CALL( SCIPcheckStage(scip, "SCIPwriteTransProblem", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
710 
711  assert( scip != NULL );
712  assert( scip->transprob != NULL );
713 
714  retcode = writeProblem(scip, filename, extension, TRUE, genericnames);
715 
716  /* check for write errors */
717  if( retcode == SCIP_FILECREATEERROR || retcode == SCIP_WRITEERROR || retcode == SCIP_PLUGINNOTFOUND )
718  return retcode;
719  else
720  {
721  SCIP_CALL( retcode );
722  }
723 
724  return SCIP_OKAY;
725 }
726 
727 /** frees problem and solution process data
728  *
729  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
730  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
731  *
732  * @pre This method can be called if @p scip is in one of the following stages:
733  * - \ref SCIP_STAGE_INIT
734  * - \ref SCIP_STAGE_PROBLEM
735  * - \ref SCIP_STAGE_TRANSFORMED
736  * - \ref SCIP_STAGE_PRESOLVING
737  * - \ref SCIP_STAGE_PRESOLVED
738  * - \ref SCIP_STAGE_SOLVING
739  * - \ref SCIP_STAGE_SOLVED
740  * - \ref SCIP_STAGE_FREE
741  *
742  * @post After this method was called, SCIP is in the following stage:
743  * - \ref SCIP_STAGE_INIT
744  */
746  SCIP* scip /**< SCIP data structure */
747  )
748 {
749  SCIP_Bool transsolorig;
750 
751  SCIP_CALL( SCIPcheckStage(scip, "SCIPfreeProb", TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE) );
752 
753  /* if we free the problem, we do not have to transfer transformed solutions to the original space, so temporarily disable it */
754  transsolorig = scip->set->misc_transsolsorig;
755  scip->set->misc_transsolsorig = FALSE;
756 
757  /* release variables and constraints captured by reoptimization */
758  if( scip->set->reopt_enable || scip->reopt != NULL)
759  {
760  SCIP_CALL( SCIPreoptReleaseData(scip->reopt, scip->set, scip->mem->probmem) );
761  }
762 
763  SCIP_CALL( SCIPfreeTransform(scip) );
764  /* for some reason the free transform can generate events caught in the globalbnd eventhander
765  * which requires the concurrent so it must be freed afterwards this happened o instance fiber
766  */
767  SCIP_CALL( SCIPfreeConcurrent(scip) );
768 
769  assert(scip->set->stage == SCIP_STAGE_INIT || scip->set->stage == SCIP_STAGE_PROBLEM);
770  scip->set->misc_transsolsorig = transsolorig;
771 
772  if( scip->set->stage == SCIP_STAGE_PROBLEM )
773  {
774  int i;
775 
776  /* free concsolvers and deinitialize the syncstore */
777  if( scip->set->nconcsolvers > 0 )
778  {
779  assert(SCIPsyncstoreIsInitialized(scip->syncstore));
780 
783  }
784 
785  /* deactivate all pricers */
786  for( i = scip->set->nactivepricers-1; i >= 0; --i )
787  {
788  SCIP_CALL( SCIPpricerDeactivate(scip->set->pricers[i], scip->set) );
789  }
790  assert(scip->set->nactivepricers == 0);
791 
792  /* deactivate all Benders' decomposition */
793  for( i = scip->set->nactivebenders-1; i >= 0; --i )
794  {
795  SCIPbendersDeactivate(scip->set->benders[i], scip->set);
796  }
797  assert(scip->set->nactivebenders == 0);
798 
799  /* free all debug data */
801 
802  /* free original primal solution candidate pool, original problem and problem statistics data structures */
803  if( scip->set->reopt_enable || scip->reopt != NULL)
804  {
805  SCIP_CALL( SCIPreoptFree(&scip->reopt, scip->set, scip->origprimal, scip->mem->probmem) );
806  }
807  SCIP_CALL( SCIPconflictstoreFree(&scip->conflictstore, scip->mem->probmem, scip->set, scip->stat, scip->reopt) );
808  SCIP_CALL( SCIPprimalFree(&scip->origprimal, scip->mem->probmem) );
809  SCIP_CALL( SCIPprobFree(&scip->origprob, scip->messagehdlr, scip->mem->probmem, scip->set, scip->stat, scip->eventqueue, scip->lp) );
810  SCIP_CALL( SCIPstatFree(&scip->stat, scip->mem->probmem) );
811 
812  /* readers */
813  for( i = 0; i < scip->set->nreaders; ++i )
814  {
816  }
817 
818  /* switch stage to INIT */
819  scip->set->stage = SCIP_STAGE_INIT;
820  }
821  assert(scip->set->stage == SCIP_STAGE_INIT);
822 
823  return SCIP_OKAY;
824 }
825 
826 /** permutes parts of the problem data structure
827  *
828  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
829  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
830  *
831  * @pre This method can be called if @p scip is in one of the following stages:
832  * - \ref SCIP_STAGE_PROBLEM
833  * - \ref SCIP_STAGE_TRANSFORMED
834  *
835  * @todo This need to be changed to use the new random number generator implemented in random.c
836  */
838  SCIP* scip, /**< SCIP data structure */
839  unsigned int randseed, /**< seed value for random generator */
840  SCIP_Bool permuteconss, /**< should the list of constraints in each constraint handler be permuted? */
841  SCIP_Bool permutebinvars, /**< should the list of binary variables be permuted? */
842  SCIP_Bool permuteintvars, /**< should the list of integer variables be permuted? */
843  SCIP_Bool permuteimplvars, /**< should the list of implicit integer variables be permuted? */
844  SCIP_Bool permutecontvars /**< should the list of continuous integer variables be permuted? */
845  )
846 {
847  SCIP_VAR** vars;
848  SCIP_CONSHDLR** conshdlrs;
849  SCIP_RANDNUMGEN* randnumgen;
850  SCIP_Bool permuted;
851  int nconshdlrs;
852  int nbinvars;
853  int nintvars;
854  int nimplvars;
855  int nvars;
856  int j;
857 
858  assert(scip != NULL);
859  SCIP_CALL( SCIPcheckStage(scip, "SCIPpermuteProb", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
860 
861  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, &nimplvars, NULL) );
862 
863  assert(nvars == 0 || vars != NULL);
864  assert(nvars == nbinvars+nintvars+nimplvars+SCIPgetNContVars(scip));
865 
866  conshdlrs = SCIPgetConshdlrs(scip);
867  nconshdlrs = SCIPgetNConshdlrs(scip);
868  assert(nconshdlrs == 0 || conshdlrs != NULL);
869 
870  /* create a random number generator */
871  SCIP_CALL( SCIPcreateRandom(scip, &randnumgen, randseed, TRUE) );
872 
873  /* The constraint handler should not be permuted since they are called w.r.t. to certain properties; besides
874  * that the "conshdlrs" array should stay in the order as it is since this array is used to copy the plugins for
875  * sub-SCIPs and contains the dependencies between the constraint handlers; for example the linear constraint
876  * handler stays in front of all constraint handler which can upgrade a linear constraint (such as logicor,
877  * setppc, and knapsack).
878  */
879 
880  permuted = FALSE;
881 
882  /* for each constraint handler, permute its constraints */
883  if( permuteconss )
884  {
885  int i;
886 
887  /* we must only permute active constraints */
888  if( SCIPisTransformed(scip) && !SCIPprobIsPermuted(scip->transprob) )
889  {
890  /* loop over all constraint handlers */
891  for( i = 0; i < nconshdlrs; ++i )
892  {
893  SCIP_CONS** conss;
894  int nconss;
895 
896  conss = SCIPconshdlrGetConss(conshdlrs[i]);
897  nconss = SCIPconshdlrGetNActiveConss(conshdlrs[i]);
898 
899  assert(nconss == 0 || conss != NULL);
900 
901  SCIPrandomPermuteArray(randnumgen, (void**)conss, 0, nconss);
902 
903  /* readjust the mapping of constraints to array positions */
904  for( j = 0; j < nconss; ++j )
905  conss[j]->consspos = j;
906 
907  permuted = TRUE;
908  }
909  }
910  else if( !SCIPisTransformed(scip) && !SCIPprobIsPermuted(scip->origprob) )
911  {
912  SCIP_CONS** conss = scip->origprob->conss;
913  int nconss = scip->origprob->nconss;
914 
915  SCIPrandomPermuteArray(randnumgen, (void**)conss, 0, nconss);
916 
917  for( j = 0; j < nconss; ++j )
918  {
919  assert(conss[j]->consspos == -1);
920  conss[j]->addarraypos = j;
921  }
922 
923  permuted = TRUE;
924  }
925  }
926 
927  /* permute binary variables */
928  if( permutebinvars && !SCIPprobIsPermuted(scip->origprob) )
929  {
930  SCIPrandomPermuteArray(randnumgen, (void**)vars, 0, nbinvars);
931 
932  /* readjust the mapping of variables to array positions */
933  for( j = 0; j < nbinvars; ++j )
934  vars[j]->probindex = j;
935 
936  permuted = TRUE;
937  }
938 
939  /* permute general integer variables */
940  if( permuteintvars && !SCIPprobIsPermuted(scip->origprob) )
941  {
942  SCIPrandomPermuteArray(randnumgen, (void**)vars, nbinvars, nbinvars+nintvars);
943 
944  /* readjust the mapping of variables to array positions */
945  for( j = nbinvars; j < nbinvars+nintvars; ++j )
946  vars[j]->probindex = j;
947 
948  permuted = TRUE;
949  }
950 
951  /* permute general integer variables */
952  if( permuteimplvars && !SCIPprobIsPermuted(scip->origprob) )
953  {
954  SCIPrandomPermuteArray(randnumgen, (void**)vars, nbinvars+nintvars, nbinvars+nintvars+nimplvars);
955 
956  /* readjust the mapping of variables to array positions */
957  for( j = nbinvars+nintvars; j < nbinvars+nintvars+nimplvars; ++j )
958  vars[j]->probindex = j;
959 
960  permuted = TRUE;
961  }
962 
963  /* permute general integer variables */
964  if( permutecontvars && !SCIPprobIsPermuted(scip->origprob) )
965  {
966  SCIPrandomPermuteArray(randnumgen, (void**)vars, nbinvars+nintvars+nimplvars, nvars);
967 
968  /* readjust the mapping of variables to array positions */
969  for( j = nbinvars+nintvars+nimplvars; j < nvars; ++j )
970  vars[j]->probindex = j;
971 
972  permuted = TRUE;
973  }
974 
975  if( permuted && SCIPisTransformed(scip) )
976  {
977  assert(!SCIPprobIsPermuted(scip->transprob));
978 
979  /* mark tranformed problem as permuted */
981 
983  "permute transformed problem using random seed %u\n", randseed);
984  }
985  else if( permuted && !SCIPisTransformed(scip) )
986  {
987  assert(!SCIPprobIsPermuted(scip->origprob));
988 
989  /* mark original problem as permuted */
991 
993  "permute original problem using random seed %u\n", randseed);
994  }
995 
996  /* free random number generator */
997  SCIPfreeRandom(scip, &randnumgen);
998 
999  return SCIP_OKAY;
1000 }
1001 
1002 /** gets user problem data
1003  *
1004  * @return a SCIP_PROBDATA pointer, or NULL if no problem data was allocated
1005  *
1006  * @pre This method can be called if @p scip is in one of the following stages:
1007  * - \ref SCIP_STAGE_PROBLEM
1008  * - \ref SCIP_STAGE_TRANSFORMING
1009  * - \ref SCIP_STAGE_TRANSFORMED
1010  * - \ref SCIP_STAGE_INITPRESOLVE
1011  * - \ref SCIP_STAGE_PRESOLVING
1012  * - \ref SCIP_STAGE_EXITPRESOLVE
1013  * - \ref SCIP_STAGE_PRESOLVED
1014  * - \ref SCIP_STAGE_INITSOLVE
1015  * - \ref SCIP_STAGE_SOLVING
1016  * - \ref SCIP_STAGE_SOLVED
1017  * - \ref SCIP_STAGE_EXITSOLVE
1018  * - \ref SCIP_STAGE_FREETRANS
1019  */
1021  SCIP* scip /**< SCIP data structure */
1022  )
1023 {
1024  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetProbData", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1025 
1026  switch( scip->set->stage )
1027  {
1028  case SCIP_STAGE_PROBLEM:
1029  return SCIPprobGetData(scip->origprob);
1030 
1034  case SCIP_STAGE_PRESOLVING:
1036  case SCIP_STAGE_PRESOLVED:
1037  case SCIP_STAGE_INITSOLVE:
1038  case SCIP_STAGE_SOLVING:
1039  case SCIP_STAGE_SOLVED:
1040  case SCIP_STAGE_EXITSOLVE:
1041  case SCIP_STAGE_FREETRANS:
1042  return SCIPprobGetData(scip->transprob);
1043 
1044  default:
1045  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
1046  SCIPABORT();
1047  return NULL; /*lint !e527*/
1048  } /*lint !e788*/
1049 }
1050 
1051 /** sets user problem data
1052  *
1053  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
1054  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1055  *
1056  * @pre This method can be called if @p scip is in one of the following stages:
1057  * - \ref SCIP_STAGE_PROBLEM
1058  * - \ref SCIP_STAGE_TRANSFORMING
1059  * - \ref SCIP_STAGE_TRANSFORMED
1060  * - \ref SCIP_STAGE_INITPRESOLVE
1061  * - \ref SCIP_STAGE_PRESOLVING
1062  * - \ref SCIP_STAGE_EXITPRESOLVE
1063  * - \ref SCIP_STAGE_PRESOLVED
1064  * - \ref SCIP_STAGE_INITSOLVE
1065  * - \ref SCIP_STAGE_SOLVING
1066  * - \ref SCIP_STAGE_SOLVED
1067  * - \ref SCIP_STAGE_EXITSOLVE
1068  * - \ref SCIP_STAGE_FREETRANS
1069  */
1071  SCIP* scip, /**< SCIP data structure */
1072  SCIP_PROBDATA* probdata /**< user problem data to use */
1073  )
1074 {
1075  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetProbData", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1076 
1077  switch( scip->set->stage )
1078  {
1079  case SCIP_STAGE_PROBLEM:
1080  SCIPprobSetData(scip->origprob, probdata);
1081  return SCIP_OKAY;
1082 
1086  case SCIP_STAGE_PRESOLVING:
1088  case SCIP_STAGE_PRESOLVED:
1089  case SCIP_STAGE_INITSOLVE:
1090  case SCIP_STAGE_SOLVING:
1091  case SCIP_STAGE_SOLVED:
1092  case SCIP_STAGE_EXITSOLVE:
1093  case SCIP_STAGE_FREETRANS:
1094  SCIPprobSetData(scip->transprob, probdata);
1095  return SCIP_OKAY;
1096 
1097  case SCIP_STAGE_INIT:
1098  case SCIP_STAGE_FREE:
1099  default:
1100  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
1101  return SCIP_INVALIDCALL;
1102  }
1103 }
1104 
1105 /** returns name of the current problem instance
1106  *
1107  * @return name of the current problem instance
1108  *
1109  * @pre This method can be called if @p scip is in one of the following stages:
1110  * - \ref SCIP_STAGE_PROBLEM
1111  * - \ref SCIP_STAGE_TRANSFORMING
1112  * - \ref SCIP_STAGE_TRANSFORMED
1113  * - \ref SCIP_STAGE_INITPRESOLVE
1114  * - \ref SCIP_STAGE_PRESOLVING
1115  * - \ref SCIP_STAGE_EXITPRESOLVE
1116  * - \ref SCIP_STAGE_PRESOLVED
1117  * - \ref SCIP_STAGE_INITSOLVE
1118  * - \ref SCIP_STAGE_SOLVING
1119  * - \ref SCIP_STAGE_SOLVED
1120  * - \ref SCIP_STAGE_EXITSOLVE
1121  * - \ref SCIP_STAGE_FREETRANS
1122  */
1123 const char* SCIPgetProbName(
1124  SCIP* scip /**< SCIP data structure */
1125  )
1126 {
1127  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetProbName", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1128 
1129  return SCIPprobGetName(scip->origprob);
1130 }
1131 
1132 /** sets name of the current problem instance
1133  *
1134  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
1135  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1136  *
1137  * @pre This method can be called if @p scip is in one of the following stages:
1138  * - \ref SCIP_STAGE_PROBLEM
1139  * - \ref SCIP_STAGE_TRANSFORMING
1140  * - \ref SCIP_STAGE_TRANSFORMED
1141  * - \ref SCIP_STAGE_INITPRESOLVE
1142  * - \ref SCIP_STAGE_PRESOLVING
1143  * - \ref SCIP_STAGE_EXITPRESOLVE
1144  * - \ref SCIP_STAGE_PRESOLVED
1145  * - \ref SCIP_STAGE_INITSOLVE
1146  * - \ref SCIP_STAGE_SOLVING
1147  * - \ref SCIP_STAGE_SOLVED
1148  * - \ref SCIP_STAGE_EXITSOLVE
1149  * - \ref SCIP_STAGE_FREETRANS
1150  */
1152  SCIP* scip, /**< SCIP data structure */
1153  const char* name /**< name to be set */
1154  )
1155 {
1156  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetProbName", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1157 
1158  return SCIPprobSetName(scip->origprob, name);
1159 }
1160 
1161 /** changes the objective function of the original problem.
1162  *
1163  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
1164  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1165  *
1166  * @pre This method can be called if @p scip is in one of the following stages:
1167  * - \ref SCIP_STAGE_PROBLEM
1168  * - \ref SCIP_STAGE_PRESOLVED
1169  *
1170  * @note This method should be only used to change the objective function during two reoptimization runs and is only
1171  * recommended to an experienced user.
1172  *
1173  * @note All variables not given in \p vars array are assumed to have an objective coefficient of zero.
1174  */
1176  SCIP* scip, /**< SCIP data structure */
1177  SCIP_OBJSENSE objsense, /**< new objective function */
1178  SCIP_VAR** vars, /**< original problem variables */
1179  SCIP_Real* coefs, /**< objective coefficients */
1180  int nvars /**< variables in vars array */
1181  )
1182 {
1183  SCIP_VAR** origvars;
1184  int norigvars;
1185  int i;
1186 
1187  SCIP_CALL( SCIPcheckStage(scip, "SCIPchgReoptObjective", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
1188 
1189  assert(nvars == 0 || vars != NULL);
1190  assert(nvars == 0 || coefs != NULL);
1191 
1192  origvars = scip->origprob->vars;
1193  norigvars = scip->origprob->nvars;
1194 
1195 #ifdef SCIP_MORE_DEBUG
1196  SCIPdebugMsg(scip, "objective function need to be set:\n");
1197  for( i = 0; i < nvars; i++ )
1198  {
1199  if( !SCIPisZero(scip, coefs[i]) )
1200  SCIPdebugMsg(scip, "%s%g <%s> ", SCIPisPositive(scip, coefs[i]) ? "+" : "", coefs[i], SCIPvarGetName(vars[i]));
1201  }
1202  SCIPdebugMsg(scip, "\n");
1203 #endif
1204 
1205  /* Set all coefficients of original variables to 0, since we will add the new objective coefficients later. */
1206  for( i = 0; i < norigvars; i++ )
1207  {
1208  SCIP_CALL( SCIPchgVarObj(scip, origvars[i], 0.0) );
1209  }
1210 
1211  if( scip->set->stage >= SCIP_STAGE_TRANSFORMED )
1212  {
1213  /* In order to avoid numerical troubles, also explicitly set all transformed objective coefficients to 0. */
1214  for( i = 0; i < scip->transprob->nvars; i++ )
1215  {
1216  SCIP_CALL( SCIPchgVarObj(scip, scip->transprob->vars[i], 0.0) );
1217  }
1218  }
1219 
1220  /* reset objective data of original problem */
1221  scip->origprob->objscale = 1.0;
1222  scip->origprob->objsense = objsense;
1223  scip->origprob->objoffset = 0.0;
1224  scip->origprob->objisintegral = FALSE;
1225 
1226  if( scip->set->stage >= SCIP_STAGE_TRANSFORMED )
1227  {
1228  /* reset objective data of transformed problem */
1229  scip->transprob->objscale = 1.0;
1230  scip->transprob->objsense = objsense;
1231  scip->transprob->objoffset = 0.0;
1232  scip->transprob->objisintegral = FALSE;
1233  }
1234 
1235  /* set new objective values */
1236  for( i = 0; i < nvars; ++i )
1237  {
1238  if( !SCIPvarIsOriginal(vars[i]) )
1239  {
1240  SCIPerrorMessage("Cannot handle variable <%s> (status: %d) in SCIPchgReoptObjective().\n",
1241  SCIPvarGetName(vars[i]), SCIPvarGetStatus(vars[i]));
1242  return SCIP_INVALIDDATA;
1243  }
1244 
1245  /* Add coefficients because this gets transferred to the transformed problem (the coefficients were set to 0 above). */
1246  SCIP_CALL( SCIPaddVarObj(scip, vars[i], coefs[i]) );
1247  }
1248 
1249 #ifdef SCIP_MORE_DEBUG
1250  SCIPdebugMsg(scip, "new objective function:\n");
1251  for( i = 0; i < norigvars; i++ )
1252  {
1253  SCIP_Real objval = SCIPvarGetObj(origvars[i]);
1254  if( !SCIPisZero(scip, objval) )
1255  SCIPdebugMsg(scip, "%s%g <%s> ", SCIPisPositive(scip, objval) ? "+" : "", objval, SCIPvarGetName(origvars[i]));
1256  }
1257  SCIPdebugMsg(scip, "\n");
1258 #endif
1259 
1260  return SCIP_OKAY;
1261 }
1262 
1263 /** returns objective sense of original problem
1264  *
1265  * @return objective sense of original problem
1266  *
1267  * @pre This method can be called if @p scip is in one of the following stages:
1268  * - \ref SCIP_STAGE_PROBLEM
1269  * - \ref SCIP_STAGE_TRANSFORMING
1270  * - \ref SCIP_STAGE_TRANSFORMED
1271  * - \ref SCIP_STAGE_INITPRESOLVE
1272  * - \ref SCIP_STAGE_PRESOLVING
1273  * - \ref SCIP_STAGE_EXITPRESOLVE
1274  * - \ref SCIP_STAGE_PRESOLVED
1275  * - \ref SCIP_STAGE_INITSOLVE
1276  * - \ref SCIP_STAGE_SOLVING
1277  * - \ref SCIP_STAGE_SOLVED
1278  * - \ref SCIP_STAGE_EXITSOLVE
1279  * - \ref SCIP_STAGE_FREETRANS
1280  */
1282  SCIP* scip /**< SCIP data structure */
1283  )
1284 {
1285  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetObjsense", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1286 
1287  return scip->origprob->objsense;
1288 }
1289 
1290 /** sets objective sense of problem
1291  *
1292  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
1293  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1294  *
1295  * @pre This method can be called if @p scip is in one of the following stages:
1296  * - \ref SCIP_STAGE_PROBLEM
1297  */
1299  SCIP* scip, /**< SCIP data structure */
1300  SCIP_OBJSENSE objsense /**< new objective sense */
1301  )
1302 {
1303  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetObjsense", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
1304 
1305  if( objsense != SCIP_OBJSENSE_MAXIMIZE && objsense != SCIP_OBJSENSE_MINIMIZE )
1306  {
1307  SCIPerrorMessage("invalid objective sense\n");
1308  return SCIP_INVALIDDATA;
1309  }
1310 
1311  SCIPprobSetObjsense(scip->origprob, objsense);
1312 
1313  return SCIP_OKAY;
1314 }
1315 
1316 /** adds offset of objective function
1317  *
1318  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
1319  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1320  *
1321  * @pre This method can be called if @p scip is in one of the following stages:
1322  * - \ref SCIP_STAGE_PRESOLVING
1323  */
1325  SCIP* scip, /**< SCIP data structure */
1326  SCIP_Real addval /**< value to add to objective offset */
1327  )
1328 {
1329  SCIP_CALL( SCIPcheckStage(scip, "SCIPaddObjoffset", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
1330 
1331  SCIPprobAddObjoffset(scip->transprob, addval);
1332  SCIP_CALL( SCIPprimalUpdateObjoffset(scip->primal, SCIPblkmem(scip), scip->set, scip->stat,
1333  scip->eventqueue, scip->transprob, scip->origprob, scip->tree, scip->reopt, scip->lp) );
1334 
1335  return SCIP_OKAY;
1336 }
1337 
1338 /** adds offset of objective function to original problem and to all existing solution in original space
1339  *
1340  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
1341  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1342  *
1343  * @pre This method can be called if @p scip is in one of the following stages:
1344  * - \ref SCIP_STAGE_PROBLEM
1345  */
1347  SCIP* scip, /**< SCIP data structure */
1348  SCIP_Real addval /**< value to add to objective offset */
1349  )
1350 {
1351  SCIP_CALL( SCIPcheckStage(scip, "SCIPaddOrigObjoffset", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
1352 
1353  scip->origprob->objoffset += addval;
1354  SCIPprimalAddOrigObjoffset(scip->origprimal, scip->set, addval);
1355 
1356  return SCIP_OKAY;
1357 }
1358 
1359 /** returns the objective offset of the original problem
1360  *
1361  * @return the objective offset of the original problem
1362  *
1363  * @pre This method can be called if @p scip is in one of the following stages:
1364  * - \ref SCIP_STAGE_PROBLEM
1365  * - \ref SCIP_STAGE_TRANSFORMING
1366  * - \ref SCIP_STAGE_TRANSFORMED
1367  * - \ref SCIP_STAGE_INITPRESOLVE
1368  * - \ref SCIP_STAGE_PRESOLVING
1369  * - \ref SCIP_STAGE_EXITPRESOLVE
1370  * - \ref SCIP_STAGE_PRESOLVED
1371  * - \ref SCIP_STAGE_INITSOLVE
1372  * - \ref SCIP_STAGE_SOLVING
1373  * - \ref SCIP_STAGE_SOLVED
1374  */
1376  SCIP* scip /**< SCIP data structure */
1377  )
1378 {
1379  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetOrigObjoffset", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1380 
1381  return scip->origprob->objoffset;
1382 }
1383 
1384 /** returns the objective scale of the original problem
1385  *
1386  * @return the objective scale of the original problem
1387  *
1388  * @pre This method can be called if @p scip is in one of the following stages:
1389  * - \ref SCIP_STAGE_PROBLEM
1390  * - \ref SCIP_STAGE_TRANSFORMING
1391  * - \ref SCIP_STAGE_TRANSFORMED
1392  * - \ref SCIP_STAGE_INITPRESOLVE
1393  * - \ref SCIP_STAGE_PRESOLVING
1394  * - \ref SCIP_STAGE_EXITPRESOLVE
1395  * - \ref SCIP_STAGE_PRESOLVED
1396  * - \ref SCIP_STAGE_INITSOLVE
1397  * - \ref SCIP_STAGE_SOLVING
1398  * - \ref SCIP_STAGE_SOLVED
1399  */
1401  SCIP* scip /**< SCIP data structure */
1402  )
1403 {
1404  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetOrigObjscale", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1405 
1406  return scip->origprob->objscale;
1407 }
1408 
1409 /** returns the objective offset of the transformed problem
1410  *
1411  * @return the objective offset of the transformed problem
1412  *
1413  * @pre This method can be called if @p scip is in one of the following stages:
1414  * - \ref SCIP_STAGE_TRANSFORMED
1415  * - \ref SCIP_STAGE_INITPRESOLVE
1416  * - \ref SCIP_STAGE_PRESOLVING
1417  * - \ref SCIP_STAGE_EXITPRESOLVE
1418  * - \ref SCIP_STAGE_PRESOLVED
1419  * - \ref SCIP_STAGE_INITSOLVE
1420  * - \ref SCIP_STAGE_SOLVING
1421  * - \ref SCIP_STAGE_SOLVED
1422  */
1424  SCIP* scip /**< SCIP data structure */
1425  )
1426 {
1427  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetTransObjoffset", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1428 
1429  return scip->transprob->objoffset;
1430 }
1431 
1432 /** returns the objective scale of the transformed problem
1433  *
1434  * @return the objective scale of the transformed problem
1435  *
1436  * @pre This method can be called if @p scip is in one of the following stages:
1437  * - \ref SCIP_STAGE_TRANSFORMED
1438  * - \ref SCIP_STAGE_INITPRESOLVE
1439  * - \ref SCIP_STAGE_PRESOLVING
1440  * - \ref SCIP_STAGE_EXITPRESOLVE
1441  * - \ref SCIP_STAGE_PRESOLVED
1442  * - \ref SCIP_STAGE_INITSOLVE
1443  * - \ref SCIP_STAGE_SOLVING
1444  * - \ref SCIP_STAGE_SOLVED
1445  */
1447  SCIP* scip /**< SCIP data structure */
1448  )
1449 {
1450  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetTransObjscale", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1451 
1452  return scip->transprob->objscale;
1453 }
1454 
1455 /** sets limit on objective function, such that only solutions better than this limit are accepted
1456  *
1457  * @note SCIP will only look for solutions with a strictly better objective value, thus, e.g., prune
1458  * all branch-and-bound nodes with dual bound equal or worse to the objective limit.
1459  * However, SCIP will also collect solutions with objective value worse than the objective limit and
1460  * use them to run improvement heuristics on them.
1461  * @note If SCIP can prove that there exists no solution with a strictly better objective value, the solving status
1462  * will normally be infeasible (the objective limit is interpreted as part of the problem).
1463  * The only exception is that by chance, SCIP found a solution with the same objective value and thus
1464  * proved the optimality of this solution, resulting in solution status optimal.
1465  *
1466  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
1467  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1468  *
1469  * @pre This method can be called if @p scip is in one of the following stages:
1470  * - \ref SCIP_STAGE_PROBLEM
1471  * - \ref SCIP_STAGE_TRANSFORMED
1472  * - \ref SCIP_STAGE_INITPRESOLVE
1473  * - \ref SCIP_STAGE_PRESOLVING
1474  * - \ref SCIP_STAGE_EXITPRESOLVE
1475  * - \ref SCIP_STAGE_PRESOLVED
1476  * - \ref SCIP_STAGE_SOLVING
1477  */
1479  SCIP* scip, /**< SCIP data structure */
1480  SCIP_Real objlimit /**< new primal objective limit */
1481  )
1482 {
1483  SCIP_Real oldobjlimit;
1484 
1485  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetObjlimit", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1486 
1487  switch( scip->set->stage )
1488  {
1489  case SCIP_STAGE_PROBLEM:
1490  SCIPprobSetObjlim(scip->origprob, objlimit);
1491  break;
1492  case SCIP_STAGE_PRESOLVED:
1493  oldobjlimit = SCIPprobGetObjlim(scip->origprob, scip->set);
1494  assert(oldobjlimit == SCIPprobGetObjlim(scip->transprob, scip->set)); /*lint !e777*/
1495  if( SCIPtransformObj(scip, objlimit) > SCIPprobInternObjval(scip->transprob, scip->origprob, scip->set, oldobjlimit) && ! scip->set->reopt_enable)
1496  {
1497  SCIPerrorMessage("cannot relax objective limit from %.15g to %.15g in presolved stage.\n", oldobjlimit, objlimit);
1498  return SCIP_INVALIDDATA;
1499  }
1500  SCIPprobSetObjlim(scip->origprob, objlimit);
1501  SCIPprobSetObjlim(scip->transprob, objlimit);
1502  SCIP_CALL( SCIPprimalUpdateObjlimit(scip->primal, scip->mem->probmem, scip->set, scip->stat, scip->eventqueue,
1503  scip->transprob, scip->origprob, scip->tree, scip->reopt, scip->lp) );
1504  break;
1505 
1508  case SCIP_STAGE_PRESOLVING:
1510  case SCIP_STAGE_SOLVING:
1511  oldobjlimit = SCIPprobGetObjlim(scip->origprob, scip->set);
1512  assert(oldobjlimit == SCIPprobGetObjlim(scip->transprob, scip->set)); /*lint !e777*/
1513  if( SCIPtransformObj(scip, objlimit) > SCIPprobInternObjval(scip->transprob, scip->origprob, scip->set, oldobjlimit) )
1514  {
1515  SCIPerrorMessage("cannot relax objective limit from %.15g to %.15g after problem was transformed.\n", oldobjlimit, objlimit);
1516  return SCIP_INVALIDDATA;
1517  }
1518  SCIPprobSetObjlim(scip->origprob, objlimit);
1519  SCIPprobSetObjlim(scip->transprob, objlimit);
1520  SCIP_CALL( SCIPprimalUpdateObjlimit(scip->primal, scip->mem->probmem, scip->set, scip->stat, scip->eventqueue,
1521  scip->transprob, scip->origprob, scip->tree, scip->reopt, scip->lp) );
1522  break;
1523 
1524  default:
1525  SCIPerrorMessage("method is not callable in SCIP stage <%d>\n", scip->set->stage);
1526  return SCIP_INVALIDCALL;
1527  } /*lint !e788*/
1528 
1529  return SCIP_OKAY;
1530 }
1531 
1532 /** returns current limit on objective function
1533  *
1534  * @return the current objective limit of the original problem
1535  *
1536  * @pre This method can be called if @p scip is in one of the following stages:
1537  * - \ref SCIP_STAGE_PROBLEM
1538  * - \ref SCIP_STAGE_TRANSFORMING
1539  * - \ref SCIP_STAGE_TRANSFORMED
1540  * - \ref SCIP_STAGE_INITPRESOLVE
1541  * - \ref SCIP_STAGE_PRESOLVING
1542  * - \ref SCIP_STAGE_EXITPRESOLVE
1543  * - \ref SCIP_STAGE_PRESOLVED
1544  * - \ref SCIP_STAGE_INITSOLVE
1545  * - \ref SCIP_STAGE_SOLVING
1546  * - \ref SCIP_STAGE_SOLVED
1547  */
1549  SCIP* scip /**< SCIP data structure */
1550  )
1551 {
1552  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetObjlimit", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1553 
1554  return SCIPprobGetObjlim(scip->origprob, scip->set);
1555 }
1556 
1557 /** informs SCIP, that the objective value is always integral in every feasible solution
1558  *
1559  * @return \ref SCIP_OKAY is returned if everything worked. otherwise a suitable error code is passed. see \ref
1560  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1561  *
1562  * @pre This method can be called if @p scip is in one of the following stages:
1563  * - \ref SCIP_STAGE_PROBLEM
1564  * - \ref SCIP_STAGE_TRANSFORMING
1565  * - \ref SCIP_STAGE_INITPRESOLVE
1566  * - \ref SCIP_STAGE_EXITPRESOLVE
1567  * - \ref SCIP_STAGE_SOLVING
1568  *
1569  * @note This function should be used to inform SCIP that the objective function is integral, helping to improve the
1570  * performance. This is useful when using column generation. If no column generation (pricing) is used, SCIP
1571  * automatically detects whether the objective function is integral or can be scaled to be integral. However, in
1572  * any case, the user has to make sure that no variable is added during the solving process that destroys this
1573  * property.
1574  */
1576  SCIP* scip /**< SCIP data structure */
1577  )
1578 {
1579  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetObjIntegral", FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1580 
1581  switch( scip->set->stage )
1582  {
1583  case SCIP_STAGE_PROBLEM:
1585  return SCIP_OKAY;
1586 
1588  case SCIP_STAGE_PRESOLVING:
1589  case SCIP_STAGE_PRESOLVED:
1590  case SCIP_STAGE_SOLVING:
1592  return SCIP_OKAY;
1593 
1594  default:
1595  SCIPerrorMessage("method is not callable in SCIP stage <%d>\n", scip->set->stage);
1596  return SCIP_INVALIDCALL;
1597  } /*lint !e788*/
1598 }
1599 
1600 /** returns whether the objective value is known to be integral in every feasible solution
1601  *
1602  * @return TRUE, if objective value is known to be always integral, otherwise FALSE
1603  *
1604  * @pre This method can be called if @p scip is in one of the following stages:
1605  * - \ref SCIP_STAGE_PROBLEM
1606  * - \ref SCIP_STAGE_TRANSFORMING
1607  * - \ref SCIP_STAGE_INITPRESOLVE
1608  * - \ref SCIP_STAGE_PRESOLVING
1609  * - \ref SCIP_STAGE_EXITPRESOLVE
1610  * - \ref SCIP_STAGE_PRESOLVED
1611  * - \ref SCIP_STAGE_SOLVING
1612  *
1613  * @note If no pricing is performed, SCIP automatically detects whether the objective function is integral or can be
1614  * scaled to be integral, helping to improve performance. This function returns the result. Otherwise
1615  * SCIPsetObjIntegral() can be used to inform SCIP. However, in any case, the user has to make sure that no
1616  * variable is added during the solving process that destroys this property.
1617  */
1619  SCIP* scip /**< SCIP data structure */
1620  )
1621 {
1622  int v;
1623 
1624  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisObjIntegral", FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1625 
1626  switch( scip->set->stage )
1627  {
1628  case SCIP_STAGE_PROBLEM:
1629  /* if the user explicitly added the information that there is an integral objective, return TRUE */
1630  if( SCIPprobIsObjIntegral(scip->origprob) )
1631  return TRUE;
1632 
1633  /* if there exist unknown variables, we cannot conclude that the objective value is always integral */
1634  if ( scip->set->nactivepricers != 0 )
1635  return FALSE;
1636 
1637  /* if the objective value offset is fractional, the value itself is possibly fractional */
1638  if ( ! SCIPisIntegral(scip, scip->origprob->objoffset) )
1639  return FALSE;
1640 
1641  /* scan through the variables */
1642  for (v = 0; v < scip->origprob->nvars; ++v)
1643  {
1644  SCIP_Real obj;
1645 
1646  /* get objective value of variable */
1647  obj = SCIPvarGetObj(scip->origprob->vars[v]);
1648 
1649  /* check, if objective value is non-zero */
1650  if ( ! SCIPisZero(scip, obj) )
1651  {
1652  /* if variable's objective value is fractional, the problem's objective value may also be fractional */
1653  if ( ! SCIPisIntegral(scip, obj) )
1654  break;
1655 
1656  /* if variable with non-zero objective value is continuous, the problem's objective value may be fractional */
1658  break;
1659  }
1660  }
1661 
1662  /* we do not store the result, since we assume that the original problem might be changed */
1663  if ( v == scip->origprob->nvars )
1664  return TRUE;
1665  return FALSE;
1666 
1669  case SCIP_STAGE_PRESOLVING:
1671  case SCIP_STAGE_PRESOLVED:
1672  case SCIP_STAGE_SOLVING:
1673  return SCIPprobIsObjIntegral(scip->transprob);
1674 
1675  default:
1676  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
1677  SCIPABORT();
1678  return FALSE; /*lint !e527*/
1679  } /*lint !e788*/
1680 }
1681 
1682 /** returns the Euclidean norm of the objective function vector (available only for transformed problem)
1683  *
1684  * @return the Euclidean norm of the transformed objective function vector
1685  *
1686  * @pre This method can be called if @p scip is in one of the following stages:
1687  * - \ref SCIP_STAGE_TRANSFORMED
1688  * - \ref SCIP_STAGE_INITPRESOLVE
1689  * - \ref SCIP_STAGE_PRESOLVING
1690  * - \ref SCIP_STAGE_EXITPRESOLVE
1691  * - \ref SCIP_STAGE_PRESOLVED
1692  * - \ref SCIP_STAGE_INITSOLVE
1693  * - \ref SCIP_STAGE_SOLVING
1694  * - \ref SCIP_STAGE_SOLVED
1695  * - \ref SCIP_STAGE_EXITSOLVE
1696  */
1698  SCIP* scip /**< SCIP data structure */
1699  )
1700 {
1701  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetObjNorm", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
1702 
1703  if( scip->lp->objsqrnormunreliable )
1704  SCIPlpRecalculateObjSqrNorm(scip->set, scip->lp);
1705  assert(!scip->lp->objsqrnormunreliable);
1706 
1707  return SCIPlpGetObjNorm(scip->lp);
1708 }
1709 
1710 /** adds variable to the problem
1711  *
1712  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1713  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1714  *
1715  * @pre This method can be called if @p scip is in one of the following stages:
1716  * - \ref SCIP_STAGE_PROBLEM
1717  * - \ref SCIP_STAGE_TRANSFORMING
1718  * - \ref SCIP_STAGE_INITPRESOLVE
1719  * - \ref SCIP_STAGE_PRESOLVING
1720  * - \ref SCIP_STAGE_EXITPRESOLVE
1721  * - \ref SCIP_STAGE_PRESOLVED
1722  * - \ref SCIP_STAGE_SOLVING
1723  */
1725  SCIP* scip, /**< SCIP data structure */
1726  SCIP_VAR* var /**< variable to add */
1727  )
1728 {
1729  SCIP_CALL( SCIPcheckStage(scip, "SCIPaddVar", FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1730 
1731  /* avoid inserting the same variable twice */
1732  if( SCIPvarGetProbindex(var) != -1 )
1733  return SCIP_OKAY;
1734 
1735  /* insert the negation variable x instead of the negated variable x' in x' = offset - x */
1737  {
1738  assert(SCIPvarGetNegationVar(var) != NULL);
1740  return SCIP_OKAY;
1741  }
1742 
1743  switch( scip->set->stage )
1744  {
1745  case SCIP_STAGE_PROBLEM:
1747  {
1748  SCIPerrorMessage("cannot add transformed variables to original problem\n");
1749  return SCIP_INVALIDDATA;
1750  }
1751  SCIP_CALL( SCIPprobAddVar(scip->origprob, scip->mem->probmem, scip->set, scip->lp, scip->branchcand,
1752  scip->eventfilter, scip->eventqueue, var) );
1753  return SCIP_OKAY;
1754 
1757  case SCIP_STAGE_PRESOLVING:
1759  case SCIP_STAGE_PRESOLVED:
1760  case SCIP_STAGE_SOLVING:
1761  /* check variable's status */
1763  {
1764  SCIPerrorMessage("cannot add original variables to transformed problem\n");
1765  return SCIP_INVALIDDATA;
1766  }
1768  {
1769  SCIPerrorMessage("cannot add fixed or aggregated variables to transformed problem\n");
1770  return SCIP_INVALIDDATA;
1771  }
1772  SCIP_CALL( SCIPprobAddVar(scip->transprob, scip->mem->probmem, scip->set, scip->lp,
1773  scip->branchcand, scip->eventfilter, scip->eventqueue, var) );
1774  return SCIP_OKAY;
1775 
1776  default:
1777  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
1778  return SCIP_INVALIDCALL;
1779  } /*lint !e788*/
1780 }
1781 
1782 /** adds variable to the problem and uses it as pricing candidate to enter the LP
1783  *
1784  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1785  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1786  *
1787  * @pre This method can only be called if @p scip is in stage \ref SCIP_STAGE_SOLVING
1788  */
1790  SCIP* scip, /**< SCIP data structure */
1791  SCIP_VAR* var, /**< variable to add */
1792  SCIP_Real score /**< pricing score of variable (the larger, the better the variable) */
1793  )
1794 {
1795  SCIP_CALL( SCIPcheckStage(scip, "SCIPaddPricedVar", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1796 
1797  /* insert the negation variable x instead of the negated variable x' in x' = offset - x */
1799  {
1800  assert(SCIPvarGetNegationVar(var) != NULL);
1801  SCIP_CALL( SCIPaddPricedVar(scip, SCIPvarGetNegationVar(var), score) );
1802  return SCIP_OKAY;
1803  }
1804 
1805  /* add variable to problem if not yet inserted */
1806  if( SCIPvarGetProbindex(var) == -1 )
1807  {
1808  /* check variable's status */
1810  {
1811  SCIPerrorMessage("cannot add original variables to transformed problem\n");
1812  return SCIP_INVALIDDATA;
1813  }
1815  {
1816  SCIPerrorMessage("cannot add fixed or aggregated variables to transformed problem\n");
1817  return SCIP_INVALIDDATA;
1818  }
1819  SCIP_CALL( SCIPprobAddVar(scip->transprob, scip->mem->probmem, scip->set, scip->lp,
1820  scip->branchcand, scip->eventfilter, scip->eventqueue, var) );
1821  }
1822 
1823  /* add variable to pricing storage */
1824  SCIP_CALL( SCIPpricestoreAddVar(scip->pricestore, scip->mem->probmem, scip->set, scip->eventqueue, scip->lp, var, score,
1825  (SCIPtreeGetCurrentDepth(scip->tree) == 0)) );
1826 
1827  return SCIP_OKAY;
1828 }
1829 
1830 /** removes variable from the problem
1831  *
1832  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1833  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1834  *
1835  * @pre This method can be called if @p scip is in one of the following stages:
1836  * - \ref SCIP_STAGE_PROBLEM
1837  * - \ref SCIP_STAGE_TRANSFORMING
1838  * - \ref SCIP_STAGE_TRANSFORMED
1839  * - \ref SCIP_STAGE_PRESOLVING
1840  * - \ref SCIP_STAGE_FREETRANS
1841  */
1843  SCIP* scip, /**< SCIP data structure */
1844  SCIP_VAR* var, /**< variable to delete */
1845  SCIP_Bool* deleted /**< pointer to store whether marking variable to be deleted was successful */
1846  )
1847 {
1848  assert(scip != NULL);
1849  assert(var != NULL);
1850  assert(deleted != NULL);
1851 
1852  SCIP_CALL( SCIPcheckStage(scip, "SCIPdelVar", FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE) );
1853 
1854  switch( scip->set->stage )
1855  {
1856  case SCIP_STAGE_PROBLEM:
1858  {
1859  SCIPerrorMessage("cannot remove transformed variables from original problem\n");
1860  return SCIP_INVALIDDATA;
1861  }
1862  SCIP_CALL( SCIPprobDelVar(scip->origprob, scip->mem->probmem, scip->set, scip->eventqueue, var, deleted) );
1863 
1864  /* delete the variables from the problems that were marked to be deleted */
1865  SCIP_CALL( SCIPprobPerformVarDeletions(scip->origprob, scip->mem->probmem, scip->set, scip->stat, scip->eventqueue, scip->cliquetable, scip->lp, scip->branchcand) );
1866 
1867  return SCIP_OKAY;
1868 
1871  case SCIP_STAGE_PRESOLVING:
1872  /* check variable's status */
1874  {
1875  SCIPerrorMessage("cannot remove original variables from transformed problem\n");
1876  return SCIP_INVALIDDATA;
1877  }
1879  {
1880  SCIPerrorMessage("cannot remove fixed or aggregated variables from transformed problem\n");
1881  return SCIP_INVALIDDATA;
1882  }
1883 
1884  SCIP_CALL( SCIPprobDelVar(scip->transprob, scip->mem->probmem, scip->set, scip->eventqueue, var, deleted) );
1885 
1886  return SCIP_OKAY;
1887  case SCIP_STAGE_FREETRANS:
1888  /* in FREETRANS stage, we don't need to remove the variable, because the transformed problem is freed anyways */
1889  *deleted = FALSE;
1890 
1891  return SCIP_OKAY;
1892  default:
1893  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
1894  return SCIP_INVALIDCALL;
1895  } /*lint !e788*/
1896 }
1897 
1898 /** gets variables of the problem along with the numbers of different variable types; data may become invalid after
1899  * calls to SCIPchgVarType(), SCIPfixVar(), SCIPaggregateVars(), and SCIPmultiaggregateVar()
1900  *
1901  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1902  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1903  *
1904  * @pre This method can be called if @p scip is in one of the following stages:
1905  * - \ref SCIP_STAGE_PROBLEM
1906  * - \ref SCIP_STAGE_TRANSFORMED
1907  * - \ref SCIP_STAGE_INITPRESOLVE
1908  * - \ref SCIP_STAGE_PRESOLVING
1909  * - \ref SCIP_STAGE_EXITPRESOLVE
1910  * - \ref SCIP_STAGE_PRESOLVED
1911  * - \ref SCIP_STAGE_INITSOLVE
1912  * - \ref SCIP_STAGE_SOLVING
1913  * - \ref SCIP_STAGE_SOLVED
1914  * - \ref SCIP_STAGE_EXITSOLVE
1915  *
1916  * @note Variables in the vars array are ordered: binaries first, then integers, implicit integers and continuous last.
1917  */
1919  SCIP* scip, /**< SCIP data structure */
1920  SCIP_VAR*** vars, /**< pointer to store variables array or NULL if not needed */
1921  int* nvars, /**< pointer to store number of variables or NULL if not needed */
1922  int* nbinvars, /**< pointer to store number of binary variables or NULL if not needed */
1923  int* nintvars, /**< pointer to store number of integer variables or NULL if not needed */
1924  int* nimplvars, /**< pointer to store number of implicit integral vars or NULL if not needed */
1925  int* ncontvars /**< pointer to store number of continuous variables or NULL if not needed */
1926  )
1927 {
1928  SCIP_CALL( SCIPcheckStage(scip, "SCIPgetVarsData", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
1929 
1930  switch( scip->set->stage )
1931  {
1932  case SCIP_STAGE_PROBLEM:
1933  if( vars != NULL )
1934  *vars = scip->origprob->vars;
1935  if( nvars != NULL )
1936  *nvars = scip->origprob->nvars;
1937  if( nbinvars != NULL )
1938  *nbinvars = scip->origprob->nbinvars;
1939  if( nintvars != NULL )
1940  *nintvars = scip->origprob->nintvars;
1941  if( nimplvars != NULL )
1942  *nimplvars = scip->origprob->nimplvars;
1943  if( ncontvars != NULL )
1944  *ncontvars = scip->origprob->ncontvars;
1945  return SCIP_OKAY;
1946 
1949  case SCIP_STAGE_PRESOLVING:
1951  case SCIP_STAGE_PRESOLVED:
1952  case SCIP_STAGE_INITSOLVE:
1953  case SCIP_STAGE_SOLVING:
1954  case SCIP_STAGE_SOLVED:
1955  case SCIP_STAGE_EXITSOLVE:
1956  if( vars != NULL )
1957  *vars = scip->transprob->vars;
1958  if( nvars != NULL )
1959  *nvars = scip->transprob->nvars;
1960  if( nbinvars != NULL )
1961  *nbinvars = scip->transprob->nbinvars;
1962  if( nintvars != NULL )
1963  *nintvars = scip->transprob->nintvars;
1964  if( nimplvars != NULL )
1965  *nimplvars = scip->transprob->nimplvars;
1966  if( ncontvars != NULL )
1967  *ncontvars = scip->transprob->ncontvars;
1968  return SCIP_OKAY;
1969 
1970  default:
1971  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
1972  return SCIP_INVALIDCALL;
1973  } /*lint !e788*/
1974 }
1975 
1976 /** gets array with active problem variables
1977  *
1978  * @return array with active problem variables
1979  *
1980  * @pre This method can be called if @p scip is in one of the following stages:
1981  * - \ref SCIP_STAGE_PROBLEM
1982  * - \ref SCIP_STAGE_TRANSFORMED
1983  * - \ref SCIP_STAGE_INITPRESOLVE
1984  * - \ref SCIP_STAGE_PRESOLVING
1985  * - \ref SCIP_STAGE_EXITPRESOLVE
1986  * - \ref SCIP_STAGE_PRESOLVED
1987  * - \ref SCIP_STAGE_INITSOLVE
1988  * - \ref SCIP_STAGE_SOLVING
1989  * - \ref SCIP_STAGE_SOLVED
1990  * - \ref SCIP_STAGE_EXITSOLVE
1991  *
1992  * @note Variables in the array are ordered: binaries first, then integers, implicit integers and continuous last.
1993  *
1994  * @warning If your are using the methods which add or change bound of variables (e.g., SCIPchgVarType(), SCIPfixVar(),
1995  * SCIPaggregateVars(), and SCIPmultiaggregateVar()), it can happen that the internal variable array (which is
1996  * accessed via this method) gets resized and/or resorted. This can invalid the data pointer which is returned
1997  * by this method.
1998  */
2000  SCIP* scip /**< SCIP data structure */
2001  )
2002 {
2003  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
2004 
2005  switch( scip->set->stage )
2006  {
2007  case SCIP_STAGE_PROBLEM:
2008  return scip->origprob->vars;
2009 
2012  case SCIP_STAGE_PRESOLVING:
2014  case SCIP_STAGE_PRESOLVED:
2015  case SCIP_STAGE_INITSOLVE:
2016  case SCIP_STAGE_SOLVING:
2017  case SCIP_STAGE_SOLVED:
2018  case SCIP_STAGE_EXITSOLVE:
2019  return scip->transprob->vars;
2020 
2021  default:
2022  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2023  SCIPABORT();
2024  return NULL; /*lint !e527*/
2025  } /*lint !e788*/
2026 }
2027 
2028 /** gets number of active problem variables
2029  *
2030  * @return the number of active problem variables
2031  *
2032  * @pre This method can be called if @p scip is in one of the following stages:
2033  * - \ref SCIP_STAGE_PROBLEM
2034  * - \ref SCIP_STAGE_TRANSFORMED
2035  * - \ref SCIP_STAGE_INITPRESOLVE
2036  * - \ref SCIP_STAGE_PRESOLVING
2037  * - \ref SCIP_STAGE_EXITPRESOLVE
2038  * - \ref SCIP_STAGE_PRESOLVED
2039  * - \ref SCIP_STAGE_INITSOLVE
2040  * - \ref SCIP_STAGE_SOLVING
2041  * - \ref SCIP_STAGE_SOLVED
2042  * - \ref SCIP_STAGE_EXITSOLVE
2043  */
2045  SCIP* scip /**< SCIP data structure */
2046  )
2047 {
2048  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
2049 
2050  switch( scip->set->stage )
2051  {
2052  case SCIP_STAGE_PROBLEM:
2053  return scip->origprob->nvars;
2054 
2057  case SCIP_STAGE_PRESOLVING:
2059  case SCIP_STAGE_PRESOLVED:
2060  case SCIP_STAGE_INITSOLVE:
2061  case SCIP_STAGE_SOLVING:
2062  case SCIP_STAGE_SOLVED:
2063  case SCIP_STAGE_EXITSOLVE:
2064  return scip->transprob->nvars;
2065 
2066  default:
2067  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2068  SCIPABORT();
2069  return 0; /*lint !e527*/
2070  } /*lint !e788*/
2071 }
2072 
2073 /** gets number of binary active problem variables
2074  *
2075  * @return the number of binary active problem variables
2076  *
2077  * @pre This method can be called if @p scip is in one of the following stages:
2078  * - \ref SCIP_STAGE_PROBLEM
2079  * - \ref SCIP_STAGE_TRANSFORMED
2080  * - \ref SCIP_STAGE_INITPRESOLVE
2081  * - \ref SCIP_STAGE_PRESOLVING
2082  * - \ref SCIP_STAGE_EXITPRESOLVE
2083  * - \ref SCIP_STAGE_PRESOLVED
2084  * - \ref SCIP_STAGE_INITSOLVE
2085  * - \ref SCIP_STAGE_SOLVING
2086  * - \ref SCIP_STAGE_SOLVED
2087  * - \ref SCIP_STAGE_EXITSOLVE
2088  */
2090  SCIP* scip /**< SCIP data structure */
2091  )
2092 {
2093  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNBinVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
2094 
2095  switch( scip->set->stage )
2096  {
2097  case SCIP_STAGE_PROBLEM:
2098  return scip->origprob->nbinvars;
2099 
2102  case SCIP_STAGE_PRESOLVING:
2104  case SCIP_STAGE_PRESOLVED:
2105  case SCIP_STAGE_INITSOLVE:
2106  case SCIP_STAGE_SOLVING:
2107  case SCIP_STAGE_SOLVED:
2108  case SCIP_STAGE_EXITSOLVE:
2109  return scip->transprob->nbinvars;
2110 
2111  default:
2112  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2113  SCIPABORT();
2114  return 0; /*lint !e527*/
2115  } /*lint !e788*/
2116 }
2117 
2118 /** gets number of integer active problem variables
2119  *
2120  * @return the number of integer active problem variables
2121  *
2122  * @pre This method can be called if @p scip is in one of the following stages:
2123  * - \ref SCIP_STAGE_PROBLEM
2124  * - \ref SCIP_STAGE_TRANSFORMED
2125  * - \ref SCIP_STAGE_INITPRESOLVE
2126  * - \ref SCIP_STAGE_PRESOLVING
2127  * - \ref SCIP_STAGE_EXITPRESOLVE
2128  * - \ref SCIP_STAGE_PRESOLVED
2129  * - \ref SCIP_STAGE_INITSOLVE
2130  * - \ref SCIP_STAGE_SOLVING
2131  * - \ref SCIP_STAGE_SOLVED
2132  * - \ref SCIP_STAGE_EXITSOLVE
2133  */
2135  SCIP* scip /**< SCIP data structure */
2136  )
2137 {
2138  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNIntVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
2139 
2140  switch( scip->set->stage )
2141  {
2142  case SCIP_STAGE_PROBLEM:
2143  return scip->origprob->nintvars;
2144 
2147  case SCIP_STAGE_PRESOLVING:
2149  case SCIP_STAGE_PRESOLVED:
2150  case SCIP_STAGE_INITSOLVE:
2151  case SCIP_STAGE_SOLVING:
2152  case SCIP_STAGE_SOLVED:
2153  case SCIP_STAGE_EXITSOLVE:
2154  return scip->transprob->nintvars;
2155 
2156  default:
2157  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2158  SCIPABORT();
2159  return 0; /*lint !e527*/
2160  } /*lint !e788*/
2161 }
2162 
2163 /** gets number of implicit integer active problem variables
2164  *
2165  * @return the number of implicit integer active problem variables
2166  *
2167  * @pre This method can be called if @p scip is in one of the following stages:
2168  * - \ref SCIP_STAGE_PROBLEM
2169  * - \ref SCIP_STAGE_TRANSFORMED
2170  * - \ref SCIP_STAGE_INITPRESOLVE
2171  * - \ref SCIP_STAGE_PRESOLVING
2172  * - \ref SCIP_STAGE_EXITPRESOLVE
2173  * - \ref SCIP_STAGE_PRESOLVED
2174  * - \ref SCIP_STAGE_INITSOLVE
2175  * - \ref SCIP_STAGE_SOLVING
2176  * - \ref SCIP_STAGE_SOLVED
2177  * - \ref SCIP_STAGE_EXITSOLVE
2178  */
2180  SCIP* scip /**< SCIP data structure */
2181  )
2182 {
2183  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNImplVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
2184 
2185  switch( scip->set->stage )
2186  {
2187  case SCIP_STAGE_PROBLEM:
2188  return scip->origprob->nimplvars;
2189 
2192  case SCIP_STAGE_PRESOLVING:
2194  case SCIP_STAGE_PRESOLVED:
2195  case SCIP_STAGE_INITSOLVE:
2196  case SCIP_STAGE_SOLVING:
2197  case SCIP_STAGE_SOLVED:
2198  case SCIP_STAGE_EXITSOLVE:
2199  return scip->transprob->nimplvars;
2200 
2201  default:
2202  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2203  SCIPABORT();
2204  return 0; /*lint !e527*/
2205  } /*lint !e788*/
2206 }
2207 
2208 /** gets number of continuous active problem variables
2209  *
2210  * @return the number of continuous active problem variables
2211  *
2212  * @pre This method can be called if @p scip is in one of the following stages:
2213  * - \ref SCIP_STAGE_PROBLEM
2214  * - \ref SCIP_STAGE_TRANSFORMED
2215  * - \ref SCIP_STAGE_INITPRESOLVE
2216  * - \ref SCIP_STAGE_PRESOLVING
2217  * - \ref SCIP_STAGE_EXITPRESOLVE
2218  * - \ref SCIP_STAGE_PRESOLVED
2219  * - \ref SCIP_STAGE_INITSOLVE
2220  * - \ref SCIP_STAGE_SOLVING
2221  * - \ref SCIP_STAGE_SOLVED
2222  * - \ref SCIP_STAGE_EXITSOLVE
2223  */
2225  SCIP* scip /**< SCIP data structure */
2226  )
2227 {
2228  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNContVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
2229 
2230  switch( scip->set->stage )
2231  {
2232  case SCIP_STAGE_PROBLEM:
2233  return scip->origprob->ncontvars;
2234 
2237  case SCIP_STAGE_PRESOLVING:
2239  case SCIP_STAGE_PRESOLVED:
2240  case SCIP_STAGE_INITSOLVE:
2241  case SCIP_STAGE_SOLVING:
2242  case SCIP_STAGE_SOLVED:
2243  case SCIP_STAGE_EXITSOLVE:
2244  return scip->transprob->ncontvars;
2245 
2246  default:
2247  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2248  SCIPABORT();
2249  return 0; /*lint !e527*/
2250  } /*lint !e788*/
2251 }
2252 
2253 
2254 /** gets number of active problem variables with a non-zero objective coefficient
2255  *
2256  * @note In case of the original problem the number of variables is counted. In case of the transformed problem the
2257  * number of variables is just returned since it is stored internally
2258  *
2259  * @return the number of active problem variables with a non-zero objective coefficient
2260  *
2261  * @pre This method can be called if @p scip is in one of the following stages:
2262  * - \ref SCIP_STAGE_PROBLEM
2263  * - \ref SCIP_STAGE_TRANSFORMED
2264  * - \ref SCIP_STAGE_INITPRESOLVE
2265  * - \ref SCIP_STAGE_PRESOLVING
2266  * - \ref SCIP_STAGE_EXITPRESOLVE
2267  * - \ref SCIP_STAGE_PRESOLVED
2268  * - \ref SCIP_STAGE_INITSOLVE
2269  * - \ref SCIP_STAGE_SOLVING
2270  * - \ref SCIP_STAGE_SOLVED
2271  */
2273  SCIP* scip /**< SCIP data structure */
2274  )
2275 {
2276  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNObjVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
2277 
2278  switch( scip->set->stage )
2279  {
2280  case SCIP_STAGE_PROBLEM:
2281  return SCIPprobGetNObjVars(scip->origprob, scip->set);
2282 
2285  case SCIP_STAGE_PRESOLVING:
2287  case SCIP_STAGE_PRESOLVED:
2288  case SCIP_STAGE_INITSOLVE:
2289  case SCIP_STAGE_SOLVING:
2290  case SCIP_STAGE_SOLVED:
2291  return SCIPprobGetNObjVars(scip->transprob, scip->set);
2292 
2293  default:
2294  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2295  SCIPABORT();
2296  return 0; /*lint !e527*/
2297  } /*lint !e788*/
2298 }
2299 
2300 
2301 /** gets array with fixed and aggregated problem variables; data may become invalid after
2302  * calls to SCIPfixVar(), SCIPaggregateVars(), and SCIPmultiaggregateVar()
2303  *
2304  * @return an array with fixed and aggregated problem variables; data may become invalid after
2305  * calls to SCIPfixVar(), SCIPaggregateVars(), and SCIPmultiaggregateVar()
2306  *
2307  * @pre This method can be called if @p scip is in one of the following stages:
2308  * - \ref SCIP_STAGE_PROBLEM
2309  * - \ref SCIP_STAGE_TRANSFORMED
2310  * - \ref SCIP_STAGE_INITPRESOLVE
2311  * - \ref SCIP_STAGE_PRESOLVING
2312  * - \ref SCIP_STAGE_EXITPRESOLVE
2313  * - \ref SCIP_STAGE_PRESOLVED
2314  * - \ref SCIP_STAGE_INITSOLVE
2315  * - \ref SCIP_STAGE_SOLVING
2316  * - \ref SCIP_STAGE_SOLVED
2317  */
2319  SCIP* scip /**< SCIP data structure */
2320  )
2321 {
2322  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetFixedVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
2323 
2324  switch( scip->set->stage )
2325  {
2326  case SCIP_STAGE_PROBLEM:
2327  return NULL;
2328 
2331  case SCIP_STAGE_PRESOLVING:
2333  case SCIP_STAGE_PRESOLVED:
2334  case SCIP_STAGE_INITSOLVE:
2335  case SCIP_STAGE_SOLVING:
2336  case SCIP_STAGE_SOLVED:
2337  return scip->transprob->fixedvars;
2338 
2339  default:
2340  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2341  SCIPABORT();
2342  return NULL; /*lint !e527*/
2343  } /*lint !e788*/
2344 }
2345 
2346 /** gets number of fixed or aggregated problem variables
2347  *
2348  * @return the number of fixed or aggregated problem variables
2349  *
2350  * @pre This method can be called if @p scip is in one of the following stages:
2351  * - \ref SCIP_STAGE_PROBLEM
2352  * - \ref SCIP_STAGE_TRANSFORMED
2353  * - \ref SCIP_STAGE_INITPRESOLVE
2354  * - \ref SCIP_STAGE_PRESOLVING
2355  * - \ref SCIP_STAGE_EXITPRESOLVE
2356  * - \ref SCIP_STAGE_PRESOLVED
2357  * - \ref SCIP_STAGE_INITSOLVE
2358  * - \ref SCIP_STAGE_SOLVING
2359  * - \ref SCIP_STAGE_SOLVED
2360  */
2362  SCIP* scip /**< SCIP data structure */
2363  )
2364 {
2365  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNFixedVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
2366 
2367  switch( scip->set->stage )
2368  {
2369  case SCIP_STAGE_PROBLEM:
2370  return 0;
2371 
2374  case SCIP_STAGE_PRESOLVING:
2376  case SCIP_STAGE_PRESOLVED:
2377  case SCIP_STAGE_INITSOLVE:
2378  case SCIP_STAGE_SOLVING:
2379  case SCIP_STAGE_SOLVED:
2380  return scip->transprob->nfixedvars;
2381 
2382  default:
2383  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2384  SCIPABORT();
2385  return 0; /*lint !e527*/
2386  } /*lint !e788*/
2387 }
2388 
2389 /** gets variables of the original problem along with the numbers of different variable types; data may become invalid
2390  * after a call to SCIPchgVarType()
2391  *
2392  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2393  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2394  *
2395  * @pre This method can be called if @p scip is in one of the following stages:
2396  * - \ref SCIP_STAGE_PROBLEM
2397  * - \ref SCIP_STAGE_TRANSFORMING
2398  * - \ref SCIP_STAGE_TRANSFORMED
2399  * - \ref SCIP_STAGE_INITPRESOLVE
2400  * - \ref SCIP_STAGE_PRESOLVING
2401  * - \ref SCIP_STAGE_EXITPRESOLVE
2402  * - \ref SCIP_STAGE_PRESOLVED
2403  * - \ref SCIP_STAGE_INITSOLVE
2404  * - \ref SCIP_STAGE_SOLVING
2405  * - \ref SCIP_STAGE_SOLVED
2406  * - \ref SCIP_STAGE_EXITSOLVE
2407  * - \ref SCIP_STAGE_FREETRANS
2408  */
2410  SCIP* scip, /**< SCIP data structure */
2411  SCIP_VAR*** vars, /**< pointer to store variables array or NULL if not needed */
2412  int* nvars, /**< pointer to store number of variables or NULL if not needed */
2413  int* nbinvars, /**< pointer to store number of binary variables or NULL if not needed */
2414  int* nintvars, /**< pointer to store number of integer variables or NULL if not needed */
2415  int* nimplvars, /**< pointer to store number of implicit integral vars or NULL if not needed */
2416  int* ncontvars /**< pointer to store number of continuous variables or NULL if not needed */
2417  )
2418 {
2419  SCIP_CALL( SCIPcheckStage(scip, "SCIPgetOrigVarsData", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2420 
2421  if( vars != NULL )
2422  *vars = scip->origprob->vars;
2423  if( nvars != NULL )
2424  *nvars = scip->origprob->nvars;
2425  if( nbinvars != NULL )
2426  *nbinvars = scip->origprob->nbinvars;
2427  if( nintvars != NULL )
2428  *nintvars = scip->origprob->nintvars;
2429  if( nimplvars != NULL )
2430  *nimplvars = scip->origprob->nimplvars;
2431  if( ncontvars != NULL )
2432  *ncontvars = scip->origprob->ncontvars;
2433 
2434  return SCIP_OKAY;
2435 }
2436 
2437 /** gets array with original problem variables; data may become invalid after
2438  * a call to SCIPchgVarType()
2439  *
2440  * @return an array with original problem variables; data may become invalid after
2441  * a call to SCIPchgVarType()
2442  *
2443  * @pre This method can be called if @p scip is in one of the following stages:
2444  * - \ref SCIP_STAGE_PROBLEM
2445  * - \ref SCIP_STAGE_TRANSFORMING
2446  * - \ref SCIP_STAGE_TRANSFORMED
2447  * - \ref SCIP_STAGE_INITPRESOLVE
2448  * - \ref SCIP_STAGE_PRESOLVING
2449  * - \ref SCIP_STAGE_EXITPRESOLVE
2450  * - \ref SCIP_STAGE_PRESOLVED
2451  * - \ref SCIP_STAGE_INITSOLVE
2452  * - \ref SCIP_STAGE_SOLVING
2453  * - \ref SCIP_STAGE_SOLVED
2454  * - \ref SCIP_STAGE_EXITSOLVE
2455  * - \ref SCIP_STAGE_FREETRANS
2456  */
2458  SCIP* scip /**< SCIP data structure */
2459  )
2460 {
2461  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetOrigVars", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2462 
2463  return scip->origprob->vars;
2464 }
2465 
2466 /** gets number of original problem variables
2467  *
2468  * @return the number of original problem variables
2469  *
2470  * @pre This method can be called if @p scip is in one of the following stages:
2471  * - \ref SCIP_STAGE_PROBLEM
2472  * - \ref SCIP_STAGE_TRANSFORMING
2473  * - \ref SCIP_STAGE_TRANSFORMED
2474  * - \ref SCIP_STAGE_INITPRESOLVE
2475  * - \ref SCIP_STAGE_PRESOLVING
2476  * - \ref SCIP_STAGE_EXITPRESOLVE
2477  * - \ref SCIP_STAGE_PRESOLVED
2478  * - \ref SCIP_STAGE_INITSOLVE
2479  * - \ref SCIP_STAGE_SOLVING
2480  * - \ref SCIP_STAGE_SOLVED
2481  * - \ref SCIP_STAGE_EXITSOLVE
2482  * - \ref SCIP_STAGE_FREETRANS
2483  */
2485  SCIP* scip /**< SCIP data structure */
2486  )
2487 {
2488  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNOrigVars", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2489 
2490  return scip->origprob->nvars;
2491 }
2492 
2493 /** gets number of binary variables in the original problem
2494  *
2495  * @return the number of binary variables in the original problem
2496  *
2497  * @pre This method can be called if @p scip is in one of the following stages:
2498  * - \ref SCIP_STAGE_PROBLEM
2499  * - \ref SCIP_STAGE_TRANSFORMING
2500  * - \ref SCIP_STAGE_TRANSFORMED
2501  * - \ref SCIP_STAGE_INITPRESOLVE
2502  * - \ref SCIP_STAGE_PRESOLVING
2503  * - \ref SCIP_STAGE_EXITPRESOLVE
2504  * - \ref SCIP_STAGE_PRESOLVED
2505  * - \ref SCIP_STAGE_INITSOLVE
2506  * - \ref SCIP_STAGE_SOLVING
2507  * - \ref SCIP_STAGE_SOLVED
2508  * - \ref SCIP_STAGE_EXITSOLVE
2509  * - \ref SCIP_STAGE_FREETRANS
2510  */
2512  SCIP* scip /**< SCIP data structure */
2513  )
2514 {
2515  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNOrigBinVars", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2516 
2517  return scip->origprob->nbinvars;
2518 }
2519 
2520 /** gets the number of integer variables in the original problem
2521  *
2522  * @return the number of integer variables in the original problem
2523  *
2524  * @pre This method can be called if @p scip is in one of the following stages:
2525  * - \ref SCIP_STAGE_PROBLEM
2526  * - \ref SCIP_STAGE_TRANSFORMING
2527  * - \ref SCIP_STAGE_TRANSFORMED
2528  * - \ref SCIP_STAGE_INITPRESOLVE
2529  * - \ref SCIP_STAGE_PRESOLVING
2530  * - \ref SCIP_STAGE_EXITPRESOLVE
2531  * - \ref SCIP_STAGE_PRESOLVED
2532  * - \ref SCIP_STAGE_INITSOLVE
2533  * - \ref SCIP_STAGE_SOLVING
2534  * - \ref SCIP_STAGE_SOLVED
2535  * - \ref SCIP_STAGE_EXITSOLVE
2536  * - \ref SCIP_STAGE_FREETRANS
2537  */
2539  SCIP* scip /**< SCIP data structure */
2540  )
2541 {
2542  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNOrigIntVars", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2543 
2544  return scip->origprob->nintvars;
2545 }
2546 
2547 /** gets number of implicit integer variables in the original problem
2548  *
2549  * @return the number of implicit integer variables in the original problem
2550  *
2551  * @pre This method can be called if @p scip is in one of the following stages:
2552  * - \ref SCIP_STAGE_PROBLEM
2553  * - \ref SCIP_STAGE_TRANSFORMING
2554  * - \ref SCIP_STAGE_TRANSFORMED
2555  * - \ref SCIP_STAGE_INITPRESOLVE
2556  * - \ref SCIP_STAGE_PRESOLVING
2557  * - \ref SCIP_STAGE_EXITPRESOLVE
2558  * - \ref SCIP_STAGE_PRESOLVED
2559  * - \ref SCIP_STAGE_INITSOLVE
2560  * - \ref SCIP_STAGE_SOLVING
2561  * - \ref SCIP_STAGE_SOLVED
2562  * - \ref SCIP_STAGE_EXITSOLVE
2563  * - \ref SCIP_STAGE_FREETRANS
2564  */
2566  SCIP* scip /**< SCIP data structure */
2567  )
2568 {
2569  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNOrigImplVars", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2570 
2571  return scip->origprob->nimplvars;
2572 }
2573 
2574 /** gets number of continuous variables in the original problem
2575  *
2576  * @return the number of continuous variables in the original problem
2577  *
2578  * @pre This method can be called if @p scip is in one of the following stages:
2579  * - \ref SCIP_STAGE_PROBLEM
2580  * - \ref SCIP_STAGE_TRANSFORMING
2581  * - \ref SCIP_STAGE_TRANSFORMED
2582  * - \ref SCIP_STAGE_INITPRESOLVE
2583  * - \ref SCIP_STAGE_PRESOLVING
2584  * - \ref SCIP_STAGE_EXITPRESOLVE
2585  * - \ref SCIP_STAGE_PRESOLVED
2586  * - \ref SCIP_STAGE_INITSOLVE
2587  * - \ref SCIP_STAGE_SOLVING
2588  * - \ref SCIP_STAGE_SOLVED
2589  * - \ref SCIP_STAGE_EXITSOLVE
2590  * - \ref SCIP_STAGE_FREETRANS
2591  */
2593  SCIP* scip /**< SCIP data structure */
2594  )
2595 {
2596  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNOrigContVars", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2597 
2598  return scip->origprob->ncontvars;
2599 }
2600 
2601 /** gets number of all problem variables created during creation and solving of problem;
2602  * this includes also variables that were deleted in the meantime
2603  *
2604  * @return the number of all problem variables created during creation and solving of problem;
2605  * this includes also variables that were deleted in the meantime
2606  *
2607  * @pre This method can be called if @p scip is in one of the following stages:
2608  * - \ref SCIP_STAGE_PROBLEM
2609  * - \ref SCIP_STAGE_TRANSFORMING
2610  * - \ref SCIP_STAGE_TRANSFORMED
2611  * - \ref SCIP_STAGE_INITPRESOLVE
2612  * - \ref SCIP_STAGE_PRESOLVING
2613  * - \ref SCIP_STAGE_EXITPRESOLVE
2614  * - \ref SCIP_STAGE_PRESOLVED
2615  * - \ref SCIP_STAGE_INITSOLVE
2616  * - \ref SCIP_STAGE_SOLVING
2617  * - \ref SCIP_STAGE_SOLVED
2618  * - \ref SCIP_STAGE_EXITSOLVE
2619  * - \ref SCIP_STAGE_FREETRANS
2620  */
2622  SCIP* scip /**< SCIP data structure */
2623  )
2624 {
2625  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNTotalVars", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2626 
2627  assert(scip->stat != NULL);
2628 
2629  switch( scip->set->stage )
2630  {
2631  case SCIP_STAGE_PROBLEM:
2635  case SCIP_STAGE_PRESOLVING:
2637  case SCIP_STAGE_PRESOLVED:
2638  case SCIP_STAGE_INITSOLVE:
2639  case SCIP_STAGE_SOLVING:
2640  case SCIP_STAGE_SOLVED:
2641  case SCIP_STAGE_EXITSOLVE:
2642  case SCIP_STAGE_FREETRANS:
2643  return scip->stat->nvaridx;
2644 
2645  default:
2646  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2647  SCIPABORT();
2648  return 0; /*lint !e527*/
2649  } /*lint !e788*/
2650 }
2651 
2652 
2653 /** gets variables of the original or transformed problem along with the numbers of different variable types;
2654  * the returned problem space (original or transformed) corresponds to the given solution;
2655  * data may become invalid after calls to SCIPchgVarType(), SCIPfixVar(), SCIPaggregateVars(), and
2656  * SCIPmultiaggregateVar()
2657  *
2658  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2659  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2660  *
2661  * @pre This method can be called if @p scip is in one of the following stages:
2662  * - \ref SCIP_STAGE_PROBLEM
2663  * - \ref SCIP_STAGE_TRANSFORMED
2664  * - \ref SCIP_STAGE_INITPRESOLVE
2665  * - \ref SCIP_STAGE_PRESOLVING
2666  * - \ref SCIP_STAGE_EXITPRESOLVE
2667  * - \ref SCIP_STAGE_PRESOLVED
2668  * - \ref SCIP_STAGE_INITSOLVE
2669  * - \ref SCIP_STAGE_SOLVING
2670  * - \ref SCIP_STAGE_SOLVED
2671  */
2673  SCIP* scip, /**< SCIP data structure */
2674  SCIP_SOL* sol, /**< primal solution that selects the problem space, NULL for current solution */
2675  SCIP_VAR*** vars, /**< pointer to store variables array or NULL if not needed */
2676  int* nvars, /**< pointer to store number of variables or NULL if not needed */
2677  int* nbinvars, /**< pointer to store number of binary variables or NULL if not needed */
2678  int* nintvars, /**< pointer to store number of integer variables or NULL if not needed */
2679  int* nimplvars, /**< pointer to store number of implicit integral vars or NULL if not needed */
2680  int* ncontvars /**< pointer to store number of continuous variables or NULL if not needed */
2681  )
2682 {
2683  SCIP_CALL( SCIPcheckStage(scip, "SCIPgetSolVarsData", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
2684 
2685  if( scip->set->stage == SCIP_STAGE_PROBLEM || (sol != NULL && SCIPsolIsOriginal(sol)) )
2686  {
2687  if( vars != NULL )
2688  *vars = scip->origprob->vars;
2689  if( nvars != NULL )
2690  *nvars = scip->origprob->nvars;
2691  if( nbinvars != NULL )
2692  *nbinvars = scip->origprob->nbinvars;
2693  if( nintvars != NULL )
2694  *nintvars = scip->origprob->nintvars;
2695  if( nimplvars != NULL )
2696  *nimplvars = scip->origprob->nimplvars;
2697  if( ncontvars != NULL )
2698  *ncontvars = scip->origprob->ncontvars;
2699  }
2700  else
2701  {
2702  if( vars != NULL )
2703  *vars = scip->transprob->vars;
2704  if( nvars != NULL )
2705  *nvars = scip->transprob->nvars;
2706  if( nbinvars != NULL )
2707  *nbinvars = scip->transprob->nbinvars;
2708  if( nintvars != NULL )
2709  *nintvars = scip->transprob->nintvars;
2710  if( nimplvars != NULL )
2711  *nimplvars = scip->transprob->nimplvars;
2712  if( ncontvars != NULL )
2713  *ncontvars = scip->transprob->ncontvars;
2714  }
2715 
2716  return SCIP_OKAY;
2717 }
2718 
2719 /** returns variable of given name in the problem, or NULL if not existing
2720  *
2721  * @return variable of given name in the problem, or NULL if not existing
2722  *
2723  * @pre This method can be called if @p scip is in one of the following stages:
2724  * - \ref SCIP_STAGE_PROBLEM
2725  * - \ref SCIP_STAGE_TRANSFORMING
2726  * - \ref SCIP_STAGE_TRANSFORMED
2727  * - \ref SCIP_STAGE_INITPRESOLVE
2728  * - \ref SCIP_STAGE_PRESOLVING
2729  * - \ref SCIP_STAGE_EXITPRESOLVE
2730  * - \ref SCIP_STAGE_PRESOLVED
2731  * - \ref SCIP_STAGE_INITSOLVE
2732  * - \ref SCIP_STAGE_SOLVING
2733  * - \ref SCIP_STAGE_SOLVED
2734  * - \ref SCIP_STAGE_EXITSOLVE
2735  * - \ref SCIP_STAGE_FREETRANS
2736  */
2738  SCIP* scip, /**< SCIP data structure */
2739  const char* name /**< name of variable to find */
2740  )
2741 {
2742  SCIP_VAR* var;
2743 
2744  assert(name != NULL);
2745 
2746  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPfindVar", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2747 
2748  switch( scip->set->stage )
2749  {
2750  case SCIP_STAGE_PROBLEM:
2751  return SCIPprobFindVar(scip->origprob, name);
2752 
2756  case SCIP_STAGE_PRESOLVING:
2758  case SCIP_STAGE_PRESOLVED:
2759  case SCIP_STAGE_INITSOLVE:
2760  case SCIP_STAGE_SOLVING:
2761  case SCIP_STAGE_SOLVED:
2762  case SCIP_STAGE_EXITSOLVE:
2763  case SCIP_STAGE_FREETRANS:
2764  var = SCIPprobFindVar(scip->transprob, name);
2765  if( var == NULL )
2766  return SCIPprobFindVar(scip->origprob, name);
2767  else
2768  return var;
2769 
2770  default:
2771  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2772  SCIPABORT();
2773  return NULL; /*lint !e527*/
2774  } /*lint !e788*/
2775 }
2776 
2777 /** returns TRUE iff all potential variables exist in the problem, and FALSE, if there may be additional variables,
2778  * that will be added in pricing and improve the objective value
2779  *
2780  * @return TRUE, if all potential variables exist in the problem; FALSE, otherwise
2781  *
2782  * @pre This method can be called if @p scip is in one of the following stages:
2783  * - \ref SCIP_STAGE_TRANSFORMING
2784  * - \ref SCIP_STAGE_TRANSFORMED
2785  * - \ref SCIP_STAGE_INITPRESOLVE
2786  * - \ref SCIP_STAGE_PRESOLVING
2787  * - \ref SCIP_STAGE_EXITPRESOLVE
2788  * - \ref SCIP_STAGE_PRESOLVED
2789  * - \ref SCIP_STAGE_INITSOLVE
2790  * - \ref SCIP_STAGE_SOLVING
2791  * - \ref SCIP_STAGE_SOLVED
2792  * - \ref SCIP_STAGE_EXITSOLVE
2793  * - \ref SCIP_STAGE_FREETRANS
2794  */
2796  SCIP* scip /**< SCIP data structure */
2797  )
2798 {
2799  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPallVarsInProb", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2800 
2801  return (scip->set->nactivepricers == 0);
2802 }
2803 
2804 /** adds constraint to the problem; if constraint is only valid locally, it is added to the local subproblem of the
2805  * current node (and all of its subnodes); otherwise it is added to the global problem;
2806  * if a local constraint is added at the root node, it is automatically upgraded into a global constraint
2807  *
2808  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2809  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2810  *
2811  * @pre This method can be called if @p scip is in one of the following stages:
2812  * - \ref SCIP_STAGE_PROBLEM
2813  * - \ref SCIP_STAGE_TRANSFORMED
2814  * - \ref SCIP_STAGE_INITPRESOLVE
2815  * - \ref SCIP_STAGE_PRESOLVING
2816  * - \ref SCIP_STAGE_EXITPRESOLVE
2817  * - \ref SCIP_STAGE_PRESOLVED
2818  * - \ref SCIP_STAGE_INITSOLVE
2819  * - \ref SCIP_STAGE_SOLVING
2820  * - \ref SCIP_STAGE_EXITSOLVE
2821  */
2823  SCIP* scip, /**< SCIP data structure */
2824  SCIP_CONS* cons /**< constraint to add */
2825  )
2826 {
2827  assert(cons != NULL);
2828 
2829  SCIP_CALL( SCIPcheckStage(scip, "SCIPaddCons", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE) );
2830 
2831  switch( scip->set->stage )
2832  {
2833  case SCIP_STAGE_PROBLEM:
2834  {
2835  SCIP_CALL( SCIPprobAddCons(scip->origprob, scip->set, scip->stat, cons) );
2836 
2837  if( scip->set->reopt_enable )
2838  {
2839  SCIP_CALL( SCIPreoptAddCons(scip->reopt, scip->set, scip->mem->probmem, cons) );
2840  }
2841  }
2842  return SCIP_OKAY;
2843 
2845  SCIP_CALL( SCIPprobAddCons(scip->transprob, scip->set, scip->stat, cons) );
2846  return SCIP_OKAY;
2847 
2849  case SCIP_STAGE_PRESOLVING:
2851  case SCIP_STAGE_PRESOLVED:
2852  case SCIP_STAGE_INITSOLVE:
2853  case SCIP_STAGE_SOLVING:
2854  assert( SCIPtreeGetCurrentDepth(scip->tree) >= 0 || scip->set->stage == SCIP_STAGE_PRESOLVED
2855  || scip->set->stage == SCIP_STAGE_INITSOLVE );
2857  SCIPconsSetLocal(cons, FALSE);
2858  if( SCIPconsIsGlobal(cons) )
2859  {
2860  SCIP_CALL( SCIPprobAddCons(scip->transprob, scip->set, scip->stat, cons) );
2861  }
2862  else
2863  {
2865  SCIP_CALL( SCIPnodeAddCons(SCIPtreeGetCurrentNode(scip->tree), scip->mem->probmem, scip->set, scip->stat,
2866  scip->tree, cons) );
2867  }
2868  return SCIP_OKAY;
2869 
2870  case SCIP_STAGE_EXITSOLVE:
2871  SCIP_CALL( SCIPprobAddCons(scip->transprob, scip->set, scip->stat, cons) );
2872  return SCIP_OKAY;
2873 
2874  default:
2875  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2876  return SCIP_INVALIDCALL;
2877  } /*lint !e788*/
2878 }
2879 
2880 /** globally removes constraint from all subproblems; removes constraint from the constraint set change data of the
2881  * node, where it was added, or from the problem, if it was a problem constraint
2882  *
2883  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2884  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2885  *
2886  * @pre This method can be called if @p scip is in one of the following stages:
2887  * - \ref SCIP_STAGE_PROBLEM
2888  * - \ref SCIP_STAGE_INITPRESOLVE
2889  * - \ref SCIP_STAGE_PRESOLVING
2890  * - \ref SCIP_STAGE_EXITPRESOLVE
2891  * - \ref SCIP_STAGE_INITSOLVE
2892  * - \ref SCIP_STAGE_SOLVING
2893  * - \ref SCIP_STAGE_EXITSOLVE
2894  */
2896  SCIP* scip, /**< SCIP data structure */
2897  SCIP_CONS* cons /**< constraint to delete */
2898  )
2899 {
2900  assert(cons != NULL);
2901 
2902  SCIP_CALL( SCIPcheckStage(scip, "SCIPdelCons", FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE) );
2903 
2904  switch( scip->set->stage )
2905  {
2906  case SCIP_STAGE_PROBLEM:
2907  assert(cons->addconssetchg == NULL);
2908  SCIP_CALL( SCIPconsDelete(cons, scip->mem->probmem, scip->set, scip->stat, scip->origprob, scip->reopt) );
2909  return SCIP_OKAY;
2910 
2911  /* only added constraints can be removed in (de-)initialization process of presolving, otherwise the reduction
2912  * might be wrong
2913  */
2916  assert(SCIPconsIsAdded(cons));
2917  /*lint -fallthrough*/
2918 
2919  case SCIP_STAGE_PRESOLVING:
2920  case SCIP_STAGE_INITSOLVE:
2921  case SCIP_STAGE_SOLVING:
2922  case SCIP_STAGE_EXITSOLVE:
2923  SCIP_CALL( SCIPconsDelete(cons, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->reopt) );
2924  return SCIP_OKAY;
2925 
2926  default:
2927  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2928  return SCIP_INVALIDCALL;
2929  } /*lint !e788*/
2930 }
2931 
2932 /** returns original constraint of given name in the problem, or NULL if not existing
2933  *
2934  * @return original constraint of given name in the problem, or NULL if not existing
2935  *
2936  * @pre This method can be called if @p scip is in one of the following stages:
2937  * - \ref SCIP_STAGE_PROBLEM
2938  * - \ref SCIP_STAGE_TRANSFORMING
2939  * - \ref SCIP_STAGE_TRANSFORMED
2940  * - \ref SCIP_STAGE_INITPRESOLVE
2941  * - \ref SCIP_STAGE_PRESOLVING
2942  * - \ref SCIP_STAGE_EXITPRESOLVE
2943  * - \ref SCIP_STAGE_PRESOLVED
2944  * - \ref SCIP_STAGE_INITSOLVE
2945  * - \ref SCIP_STAGE_SOLVING
2946  * - \ref SCIP_STAGE_SOLVED
2947  * - \ref SCIP_STAGE_EXITSOLVE
2948  * - \ref SCIP_STAGE_FREETRANS
2949  */
2951  SCIP* scip, /**< SCIP data structure */
2952  const char* name /**< name of constraint to find */
2953  )
2954 {
2955  assert(name != NULL);
2956 
2957  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPfindOrigCons", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2958 
2959  switch( scip->set->stage )
2960  {
2961  case SCIP_STAGE_PROBLEM:
2965  case SCIP_STAGE_PRESOLVING:
2967  case SCIP_STAGE_PRESOLVED:
2968  case SCIP_STAGE_SOLVING:
2969  case SCIP_STAGE_SOLVED:
2970  case SCIP_STAGE_EXITSOLVE:
2971  case SCIP_STAGE_FREETRANS:
2972  return SCIPprobFindCons(scip->origprob, name);
2973 
2974  default:
2975  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2976  SCIPABORT();
2977  return NULL; /*lint !e527*/
2978  } /*lint !e788*/
2979 }
2980 
2981 /** returns constraint of given name in the problem, or NULL if not existing
2982  *
2983  * @return constraint of given name in the problem, or NULL if not existing
2984  *
2985  * @pre This method can be called if @p scip is in one of the following stages:
2986  * - \ref SCIP_STAGE_PROBLEM
2987  * - \ref SCIP_STAGE_TRANSFORMING
2988  * - \ref SCIP_STAGE_TRANSFORMED
2989  * - \ref SCIP_STAGE_INITPRESOLVE
2990  * - \ref SCIP_STAGE_PRESOLVING
2991  * - \ref SCIP_STAGE_EXITPRESOLVE
2992  * - \ref SCIP_STAGE_PRESOLVED
2993  * - \ref SCIP_STAGE_INITSOLVE
2994  * - \ref SCIP_STAGE_SOLVING
2995  * - \ref SCIP_STAGE_SOLVED
2996  * - \ref SCIP_STAGE_EXITSOLVE
2997  * - \ref SCIP_STAGE_FREETRANS
2998  */
3000  SCIP* scip, /**< SCIP data structure */
3001  const char* name /**< name of constraint to find */
3002  )
3003 {
3004  SCIP_CONS* cons;
3005 
3006  assert(name != NULL);
3007 
3008  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPfindCons", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
3009 
3010  switch( scip->set->stage )
3011  {
3012  case SCIP_STAGE_PROBLEM:
3013  return SCIPprobFindCons(scip->origprob, name);
3014 
3018  case SCIP_STAGE_PRESOLVING:
3020  case SCIP_STAGE_PRESOLVED:
3021  case SCIP_STAGE_SOLVING:
3022  case SCIP_STAGE_SOLVED:
3023  case SCIP_STAGE_EXITSOLVE:
3024  case SCIP_STAGE_FREETRANS:
3025  cons = SCIPprobFindCons(scip->transprob, name);
3026  if( cons == NULL )
3027  return SCIPprobFindCons(scip->origprob, name);
3028  else
3029  return cons;
3030 
3031  default:
3032  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
3033  SCIPABORT();
3034  return NULL; /*lint !e527*/
3035  } /*lint !e788*/
3036 }
3037 
3038 /** gets number of upgraded constraints
3039  *
3040  * @return number of upgraded constraints
3041  *
3042  * @pre This method can be called if @p scip is in one of the following stages:
3043  * - \ref SCIP_STAGE_PROBLEM
3044  * - \ref SCIP_STAGE_TRANSFORMED
3045  * - \ref SCIP_STAGE_INITPRESOLVE
3046  * - \ref SCIP_STAGE_PRESOLVING
3047  * - \ref SCIP_STAGE_PRESOLVED
3048  * - \ref SCIP_STAGE_EXITPRESOLVE
3049  * - \ref SCIP_STAGE_SOLVING
3050  * - \ref SCIP_STAGE_SOLVED
3051  */
3053  SCIP* scip /**< SCIP data structure */
3054  )
3055 {
3056  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNUpgrConss", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
3057 
3058  switch( scip->set->stage )
3059  {
3060  case SCIP_STAGE_PROBLEM:
3061  return 0;
3062 
3065  case SCIP_STAGE_PRESOLVING:
3067  case SCIP_STAGE_PRESOLVED:
3068  case SCIP_STAGE_SOLVING:
3069  case SCIP_STAGE_SOLVED:
3070  return scip->stat->npresolupgdconss;
3071 
3072  default:
3073  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
3074  SCIPABORT();
3075  return 0; /*lint !e527*/
3076  } /*lint !e788*/
3077 }
3078 
3079 /** gets total number of globally valid constraints currently in the problem
3080  *
3081  * @return total number of globally valid constraints currently in the problem
3082  *
3083  * @pre This method can be called if @p scip is in one of the following stages:
3084  * - \ref SCIP_STAGE_PROBLEM
3085  * - \ref SCIP_STAGE_TRANSFORMED
3086  * - \ref SCIP_STAGE_INITPRESOLVE
3087  * - \ref SCIP_STAGE_PRESOLVING
3088  * - \ref SCIP_STAGE_EXITPRESOLVE
3089  * - \ref SCIP_STAGE_PRESOLVED
3090  * - \ref SCIP_STAGE_INITSOLVE
3091  * - \ref SCIP_STAGE_SOLVING
3092  * - \ref SCIP_STAGE_SOLVED
3093  */
3095  SCIP* scip /**< SCIP data structure */
3096  )
3097 {
3098  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNConss", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
3099 
3100  switch( scip->set->stage )
3101  {
3102  case SCIP_STAGE_PROBLEM:
3103  return scip->origprob->nconss;
3104 
3107  case SCIP_STAGE_PRESOLVING:
3109  case SCIP_STAGE_PRESOLVED:
3110  case SCIP_STAGE_INITSOLVE:
3111  case SCIP_STAGE_SOLVING:
3112  case SCIP_STAGE_SOLVED:
3113  return scip->transprob->nconss;
3114 
3115  default:
3116  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
3117  SCIPABORT();
3118  return 0; /*lint !e527*/
3119  } /*lint !e788*/
3120 }
3121 
3122 /** gets array of globally valid constraints currently in the problem
3123  *
3124  * @return array of globally valid constraints currently in the problem
3125  *
3126  * @pre This method can be called if @p scip is in one of the following stages:
3127  * - \ref SCIP_STAGE_PROBLEM
3128  * - \ref SCIP_STAGE_TRANSFORMED
3129  * - \ref SCIP_STAGE_INITPRESOLVE
3130  * - \ref SCIP_STAGE_PRESOLVING
3131  * - \ref SCIP_STAGE_EXITPRESOLVE
3132  * - \ref SCIP_STAGE_PRESOLVED
3133  * - \ref SCIP_STAGE_INITSOLVE
3134  * - \ref SCIP_STAGE_SOLVING
3135  * - \ref SCIP_STAGE_SOLVED
3136  *
3137  * @warning If your are using the method SCIPaddCons(), it can happen that the internal constraint array (which is
3138  * accessed via this method) gets resized. This can invalid the pointer which is returned by this method.
3139  */
3141  SCIP* scip /**< SCIP data structure */
3142  )
3143 {
3144  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetConss", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
3145 
3146  switch( scip->set->stage )
3147  {
3148  case SCIP_STAGE_PROBLEM:
3149  return scip->origprob->conss;
3150 
3153  case SCIP_STAGE_PRESOLVING:
3155  case SCIP_STAGE_PRESOLVED:
3156  case SCIP_STAGE_INITSOLVE:
3157  case SCIP_STAGE_SOLVING:
3158  case SCIP_STAGE_SOLVED:
3159  return scip->transprob->conss;
3160 
3161  default:
3162  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
3163  SCIPABORT();
3164  return NULL; /*lint !e527*/
3165  } /*lint !e788*/
3166 }
3167 
3168 /** gets total number of constraints in the original problem
3169  *
3170  * @return total number of constraints in the original problem
3171  *
3172  * @pre This method can be called if @p scip is in one of the following stages:
3173  * - \ref SCIP_STAGE_PROBLEM
3174  * - \ref SCIP_STAGE_TRANSFORMING
3175  * - \ref SCIP_STAGE_TRANSFORMED
3176  * - \ref SCIP_STAGE_INITPRESOLVE
3177  * - \ref SCIP_STAGE_PRESOLVING
3178  * - \ref SCIP_STAGE_EXITPRESOLVE
3179  * - \ref SCIP_STAGE_PRESOLVED
3180  * - \ref SCIP_STAGE_INITSOLVE
3181  * - \ref SCIP_STAGE_SOLVING
3182  * - \ref SCIP_STAGE_SOLVED
3183  * - \ref SCIP_STAGE_EXITSOLVE
3184  * - \ref SCIP_STAGE_FREETRANS
3185  */
3187  SCIP* scip /**< SCIP data structure */
3188  )
3189 {
3190  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNOrigConss", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
3191 
3192  return scip->origprob->nconss;
3193 }
3194 
3195 /** gets array of constraints in the original problem
3196  *
3197  * @return array of constraints in the original problem
3198  *
3199  * @pre This method can be called if @p scip is in one of the following stages:
3200  * - \ref SCIP_STAGE_PROBLEM
3201  * - \ref SCIP_STAGE_TRANSFORMING
3202  * - \ref SCIP_STAGE_TRANSFORMED
3203  * - \ref SCIP_STAGE_INITPRESOLVE
3204  * - \ref SCIP_STAGE_PRESOLVING
3205  * - \ref SCIP_STAGE_EXITPRESOLVE
3206  * - \ref SCIP_STAGE_PRESOLVED
3207  * - \ref SCIP_STAGE_INITSOLVE
3208  * - \ref SCIP_STAGE_SOLVING
3209  * - \ref SCIP_STAGE_SOLVED
3210  * - \ref SCIP_STAGE_EXITSOLVE
3211  * - \ref SCIP_STAGE_FREETRANS
3212  */
3214  SCIP* scip /**< SCIP data structure */
3215  )
3216 {
3217  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetOrigConss", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
3218 
3219  return scip->origprob->conss;
3220 }
3221 
3222 /** computes the number of check constraint in the current node (loop over all constraint handler and cumulates the
3223  * number of check constraints)
3224  *
3225  * @return returns the number of check constraints
3226  *
3227  * @pre This method can be called if @p scip is in one of the following stages:
3228  * - \ref SCIP_STAGE_TRANSFORMED
3229  * - \ref SCIP_STAGE_INITPRESOLVE
3230  * - \ref SCIP_STAGE_PRESOLVING
3231  * - \ref SCIP_STAGE_EXITPRESOLVE
3232  * - \ref SCIP_STAGE_PRESOLVED
3233  * - \ref SCIP_STAGE_INITSOLVE
3234  * - \ref SCIP_STAGE_SOLVING
3235  */
3237  SCIP* scip /**< SCIP data structure */
3238  )
3239 {
3240  SCIP_CONSHDLR** conshdlrs;
3241  int nconshdlrs;
3242  int ncheckconss;
3243  int c;
3244 
3245  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNCheckConss", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3246 
3247  nconshdlrs = SCIPgetNConshdlrs(scip);
3248  conshdlrs = SCIPgetConshdlrs(scip);
3249  assert(conshdlrs != NULL);
3250 
3251  ncheckconss = 0;
3252 
3253  /* loop over all constraint handler and collect the number of constraints which need to be checked */
3254  for( c = 0; c < nconshdlrs; ++c )
3255  {
3256  assert(conshdlrs[c] != NULL);
3257  ncheckconss += SCIPconshdlrGetNCheckConss(conshdlrs[c]);
3258  }
3259 
3260  return ncheckconss;
3261 }
3262 
3263 /*
3264  * local subproblem methods
3265  */
3266 
3267 /** adds a conflict to a given node or globally to the problem if @p node == NULL.
3268  *
3269  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3270  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3271  *
3272  * @pre this method can be called in one of the following stages of the SCIP solving process:
3273  * - \ref SCIP_STAGE_INITPRESOLVE
3274  * - \ref SCIP_STAGE_PRESOLVING
3275  * - \ref SCIP_STAGE_EXITPRESOLVE
3276  * - \ref SCIP_STAGE_SOLVING
3277  *
3278  * @note this method will release the constraint
3279  */
3281  SCIP* scip, /**< SCIP data structure */
3282  SCIP_NODE* node, /**< node to add conflict (or NULL if global) */
3283  SCIP_CONS* cons, /**< constraint representing the conflict */
3284  SCIP_NODE* validnode, /**< node at whichaddConf the constraint is valid (or NULL) */
3285  SCIP_CONFTYPE conftype, /**< type of the conflict */
3286  SCIP_Bool iscutoffinvolved /**< is a cutoff bound involved in this conflict */
3287  )
3288 {
3289  SCIP_Real primalbound;
3290 
3291  assert(scip != NULL);
3292  assert(cons != NULL);
3293  assert(scip->conflictstore != NULL);
3294  assert(conftype != SCIP_CONFTYPE_UNKNOWN);
3295  assert(conftype != SCIP_CONFTYPE_BNDEXCEEDING || iscutoffinvolved);
3296 
3297  SCIP_CALL( SCIPcheckStage(scip, "SCIPaddConflict", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3298 
3299  if( iscutoffinvolved )
3300  primalbound = SCIPgetCutoffbound(scip);
3301  else
3302  primalbound = -SCIPinfinity(scip);
3303 
3304  /* add a global conflict */
3305  if( node == NULL )
3306  {
3307  SCIP_CALL( SCIPaddCons(scip, cons) );
3308  }
3309  /* add a local conflict */
3310  else
3311  {
3312  SCIP_CALL( SCIPaddConsNode(scip, node, cons, validnode) );
3313  }
3314 
3315  if( node == NULL || SCIPnodeGetType(node) != SCIP_NODETYPE_PROBINGNODE )
3316  {
3317  /* add the conflict to the conflict store */
3318  SCIP_CALL( SCIPconflictstoreAddConflict(scip->conflictstore, scip->mem->probmem, scip->set, scip->stat, scip->tree,
3319  scip->transprob, scip->reopt, cons, conftype, iscutoffinvolved, primalbound) );
3320  }
3321 
3322  /* mark constraint to be a conflict */
3323  SCIPconsMarkConflict(cons);
3324 
3325  SCIP_CALL( SCIPreleaseCons(scip, &cons) );
3326 
3327  return SCIP_OKAY;
3328 }
3329 
3330 /** tries to remove conflicts depending on an old cutoff bound if the improvement of the new incumbent is good enough
3331  *
3332  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3333  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3334  *
3335  * @pre this method can be called in one of the following stages of the SCIP solving process:
3336  * - \ref SCIP_STAGE_PRESOLVING
3337  * - \ref SCIP_STAGE_SOLVING
3338  */
3340  SCIP* scip, /**< SCIP data structure */
3341  SCIP_EVENT* event /**< event data */
3342  )
3343 {
3344  assert(scip != NULL);
3345  assert(event != NULL);
3347  assert(SCIPeventGetSol(event) != NULL);
3348 
3349  SCIP_CALL( SCIPcheckStage(scip, "SCIPclearConflictStore", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3350 
3352  scip->transprob, scip->reopt, scip->primal->cutoffbound) );
3353 
3354  return SCIP_OKAY;
3355 }
3356 
3357 /** adds constraint to the given node (and all of its subnodes), even if it is a global constraint;
3358  * It is sometimes desirable to add the constraint to a more local node (i.e., a node of larger depth) even if
3359  * the constraint is also valid higher in the tree, for example, if one wants to produce a constraint which is
3360  * only active in a small part of the tree although it is valid in a larger part.
3361  * In this case, one should pass the more global node where the constraint is valid as "validnode".
3362  * Note that the same constraint cannot be added twice to the branching tree with different "validnode" parameters.
3363  * If the constraint is valid at the same node as it is inserted (the usual case), one should pass NULL as "validnode".
3364  * If the "validnode" is the root node, it is automatically upgraded into a global constraint, but still only added to
3365  * the given node. If a local constraint is added to the root node, it is added to the global problem instead.
3366  *
3367  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3368  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3369  *
3370  * @pre this method can be called in one of the following stages of the SCIP solving process:
3371  * - \ref SCIP_STAGE_INITPRESOLVE
3372  * - \ref SCIP_STAGE_PRESOLVING
3373  * - \ref SCIP_STAGE_EXITPRESOLVE
3374  * - \ref SCIP_STAGE_SOLVING
3375  */
3377  SCIP* scip, /**< SCIP data structure */
3378  SCIP_NODE* node, /**< node to add constraint to */
3379  SCIP_CONS* cons, /**< constraint to add */
3380  SCIP_NODE* validnode /**< node at which the constraint is valid, or NULL */
3381  )
3382 {
3383  assert(cons != NULL);
3384  assert(node != NULL);
3385 
3386  SCIP_CALL( SCIPcheckStage(scip, "SCIPaddConsNode", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3387 
3388  if( validnode != NULL )
3389  {
3390  int validdepth;
3391 
3392  validdepth = SCIPnodeGetDepth(validnode);
3393  if( validdepth > SCIPnodeGetDepth(node) )
3394  {
3395  SCIPerrorMessage("cannot add constraint <%s> valid in depth %d to a node of depth %d\n",
3396  SCIPconsGetName(cons), validdepth, SCIPnodeGetDepth(node));
3397  return SCIP_INVALIDDATA;
3398  }
3399  if( cons->validdepth != -1 && cons->validdepth != validdepth )
3400  {
3401  SCIPerrorMessage("constraint <%s> is already marked to be valid in depth %d - cannot mark it to be valid in depth %d\n",
3402  SCIPconsGetName(cons), cons->validdepth, validdepth);
3403  return SCIP_INVALIDDATA;
3404  }
3405  if( validdepth <= SCIPtreeGetEffectiveRootDepth(scip->tree) )
3406  SCIPconsSetLocal(cons, FALSE);
3407  else
3408  cons->validdepth = validdepth;
3409  }
3410 
3412  {
3413  SCIPconsSetLocal(cons, FALSE);
3414  SCIP_CALL( SCIPprobAddCons(scip->transprob, scip->set, scip->stat, cons) );
3415  }
3416  else
3417  {
3418  SCIP_CALL( SCIPnodeAddCons(node, scip->mem->probmem, scip->set, scip->stat, scip->tree, cons) );
3419  }
3420 
3421  return SCIP_OKAY;
3422 }
3423 
3424 /** adds constraint locally to the current node (and all of its subnodes), even if it is a global constraint;
3425  * It is sometimes desirable to add the constraint to a more local node (i.e., a node of larger depth) even if
3426  * the constraint is also valid higher in the tree, for example, if one wants to produce a constraint which is
3427  * only active in a small part of the tree although it is valid in a larger part.
3428  *
3429  * If the constraint is valid at the same node as it is inserted (the usual case), one should pass NULL as "validnode".
3430  * If the "validnode" is the root node, it is automatically upgraded into a global constraint, but still only added to
3431  * the given node. If a local constraint is added to the root node, it is added to the global problem instead.
3432  *
3433  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3434  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3435  *
3436  * @pre this method can be called in one of the following stages of the SCIP solving process:
3437  * - \ref SCIP_STAGE_INITPRESOLVE
3438  * - \ref SCIP_STAGE_PRESOLVING
3439  * - \ref SCIP_STAGE_EXITPRESOLVE
3440  * - \ref SCIP_STAGE_SOLVING
3441  *
3442  * @note The same constraint cannot be added twice to the branching tree with different "validnode" parameters. This is
3443  * the case due to internal data structures and performance issues. In such a case you should try to realize your
3444  * issue using the method SCIPdisableCons() and SCIPenableCons() and control these via the event system of SCIP.
3445  */
3447  SCIP* scip, /**< SCIP data structure */
3448  SCIP_CONS* cons, /**< constraint to add */
3449  SCIP_NODE* validnode /**< node at which the constraint is valid, or NULL */
3450  )
3451 {
3452  assert(cons != NULL);
3453 
3454  SCIP_CALL( SCIPcheckStage(scip, "SCIPaddConsLocal", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3455 
3456  SCIP_CALL( SCIPaddConsNode(scip, SCIPtreeGetCurrentNode(scip->tree), cons, validnode) );
3457 
3458  return SCIP_OKAY;
3459 }
3460 
3461 /** disables constraint's separation, enforcing, and propagation capabilities at the given node (and all subnodes);
3462  * if the method is called at the root node, the constraint is globally deleted from the problem;
3463  * the constraint deletion is being remembered at the given node, s.t. after leaving the node's subtree, the constraint
3464  * is automatically enabled again, and after entering the node's subtree, it is automatically disabled;
3465  * this may improve performance because redundant checks on this constraint are avoided, but it consumes memory;
3466  * alternatively, use SCIPdisableCons()
3467  *
3468  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3469  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3470  *
3471  * @pre this method can be called in one of the following stages of the SCIP solving process:
3472  * - \ref SCIP_STAGE_INITPRESOLVE
3473  * - \ref SCIP_STAGE_PRESOLVING
3474  * - \ref SCIP_STAGE_EXITPRESOLVE
3475  * - \ref SCIP_STAGE_SOLVING
3476  */
3478  SCIP* scip, /**< SCIP data structure */
3479  SCIP_NODE* node, /**< node to disable constraint in */
3480  SCIP_CONS* cons /**< constraint to locally delete */
3481  )
3482 {
3483  assert(cons != NULL);
3484 
3485  SCIP_CALL( SCIPcheckStage(scip, "SCIPdelConsNode", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3486 
3487  /* only added constraints can be removed in (de-)initialization process of presolving, otherwise the reduction
3488  * might be wrong
3489  */
3490  if( scip->set->stage == SCIP_STAGE_INITPRESOLVE || scip->set->stage == SCIP_STAGE_EXITPRESOLVE )
3491  assert(SCIPconsIsAdded(cons));
3492 
3494  {
3495  SCIP_CALL( SCIPconsDelete(cons, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->reopt) );
3496  }
3497  else
3498  {
3499  SCIP_CALL( SCIPnodeDelCons(node, scip->mem->probmem, scip->set, scip->stat, scip->tree, cons) );
3500  }
3501 
3502  return SCIP_OKAY;
3503 }
3504 
3505 /** disables constraint's separation, enforcing, and propagation capabilities at the current node (and all subnodes);
3506  * if the method is called during problem modification or at the root node, the constraint is globally deleted from
3507  * the problem;
3508  * the constraint deletion is being remembered at the current node, s.t. after leaving the current subtree, the
3509  * constraint is automatically enabled again, and after reentering the current node's subtree, it is automatically
3510  * disabled again;
3511  * this may improve performance because redundant checks on this constraint are avoided, but it consumes memory;
3512  * alternatively, use SCIPdisableCons()
3513  *
3514  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3515  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3516  *
3517  * @pre this method can be called in one of the following stages of the SCIP solving process:
3518  * - \ref SCIP_STAGE_PROBLEM
3519  * - \ref SCIP_STAGE_INITPRESOLVE
3520  * - \ref SCIP_STAGE_PRESOLVING
3521  * - \ref SCIP_STAGE_EXITPRESOLVE
3522  * - \ref SCIP_STAGE_SOLVING
3523  *
3524  * @note SCIP stage does not get changed
3525  *
3526  */
3528  SCIP* scip, /**< SCIP data structure */
3529  SCIP_CONS* cons /**< constraint to locally delete */
3530  )
3531 {
3532  SCIP_NODE* node;
3533 
3534  assert(cons != NULL);
3535 
3536  SCIP_CALL( SCIPcheckStage(scip, "SCIPdelConsLocal", FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3537 
3538  switch( scip->set->stage )
3539  {
3540  case SCIP_STAGE_PROBLEM:
3541  assert(cons->addconssetchg == NULL);
3542  SCIP_CALL( SCIPconsDelete(cons, scip->mem->probmem, scip->set, scip->stat, scip->origprob, scip->reopt) );
3543  return SCIP_OKAY;
3544 
3545  /* only added constraints can be removed in (de-)initialization process of presolving, otherwise the reduction
3546  * might be wrong
3547  */
3550  assert(SCIPconsIsAdded(cons));
3551  /*lint -fallthrough*/
3552 
3553  case SCIP_STAGE_PRESOLVING:
3554  case SCIP_STAGE_SOLVING:
3555  node = SCIPtreeGetCurrentNode(scip->tree);
3556 
3558  {
3559  SCIP_CALL( SCIPconsDelete(cons, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->reopt) );
3560  }
3561  else
3562  {
3563  SCIP_CALL( SCIPnodeDelCons(node, scip->mem->probmem, scip->set, scip->stat, scip->tree, cons) );
3564  }
3565  return SCIP_OKAY;
3566 
3567  default:
3568  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
3569  return SCIP_INVALIDCALL;
3570  } /*lint !e788*/
3571 }
3572 
3573 /** gets estimate of best primal solution w.r.t. original problem contained in current subtree
3574  *
3575  * @return estimate of best primal solution w.r.t. original problem contained in current subtree
3576  *
3577  * @pre this method can be called in one of the following stages of the SCIP solving process:
3578  * - \ref SCIP_STAGE_SOLVING
3579  */
3581  SCIP* scip /**< SCIP data structure */
3582  )
3583 {
3584  SCIP_NODE* node;
3585 
3586  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLocalOrigEstimate", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3587 
3588  node = SCIPtreeGetCurrentNode(scip->tree);
3589  return node != NULL ? SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, SCIPnodeGetEstimate(node)) : SCIP_INVALID;
3590 }
3591 
3592 /** gets estimate of best primal solution w.r.t. transformed problem contained in current subtree
3593  *
3594  * @return estimate of best primal solution w.r.t. transformed problem contained in current subtree
3595  *
3596  * @pre this method can be called in one of the following stages of the SCIP solving process:
3597  * - \ref SCIP_STAGE_SOLVING
3598  */
3600  SCIP* scip /**< SCIP data structure */
3601  )
3602 {
3603  SCIP_NODE* node;
3604 
3605  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLocalTransEstimate", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3606 
3607  node = SCIPtreeGetCurrentNode(scip->tree);
3608 
3609  return node != NULL ? SCIPnodeGetEstimate(node) : SCIP_INVALID;
3610 }
3611 
3612 /** gets dual bound of current node
3613  *
3614  * @return dual bound of current node
3615  *
3616  * @pre this method can be called in one of the following stages of the SCIP solving process:
3617  * - \ref SCIP_STAGE_SOLVING
3618  */
3620  SCIP* scip /**< SCIP data structure */
3621  )
3622 {
3623  SCIP_NODE* node;
3624 
3625  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLocalDualbound", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3626 
3627  node = SCIPtreeGetCurrentNode(scip->tree);
3628  return node != NULL ? SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, SCIPnodeGetLowerbound(node)) : SCIP_INVALID;
3629 }
3630 
3631 /** gets lower bound of current node in transformed problem
3632  *
3633  * @return lower bound of current node in transformed problem
3634  *
3635  * @pre this method can be called in one of the following stages of the SCIP solving process:
3636  * - \ref SCIP_STAGE_SOLVING
3637  */
3639  SCIP* scip /**< SCIP data structure */
3640  )
3641 {
3642  SCIP_NODE* node;
3643 
3644  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLocalLowerbound", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3645 
3646  node = SCIPtreeGetCurrentNode(scip->tree);
3647 
3648  return node != NULL ? SCIPnodeGetLowerbound(node) : SCIP_INVALID;
3649 }
3650 
3651 /** gets dual bound of given node
3652  *
3653  * @return dual bound of a given node
3654  *
3655  * @pre this method can be called in one of the following stages of the SCIP solving process:
3656  * - \ref SCIP_STAGE_SOLVING
3657  */
3659  SCIP* scip, /**< SCIP data structure */
3660  SCIP_NODE* node /**< node to get dual bound for */
3661  )
3662 {
3663  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNodeDualbound", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3664 
3665  return SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, SCIPnodeGetLowerbound(node));
3666 }
3667 
3668 /** gets lower bound of given node in transformed problem
3669  *
3670  * @return lower bound of given node in transformed problem
3671  *
3672  * @pre this method can be called in one of the following stages of the SCIP solving process:
3673  * - \ref SCIP_STAGE_SOLVING
3674  */
3676  SCIP* scip, /**< SCIP data structure */
3677  SCIP_NODE* node /**< node to get dual bound for */
3678  )
3679 {
3680  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNodeLowerbound", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3681 
3682  return SCIPnodeGetLowerbound(node);
3683 }
3684 
3685 /** if given value is tighter (larger for minimization, smaller for maximization) than the current node's dual bound (in
3686  * original problem space), sets the current node's dual bound to the new value
3687  *
3688  * @note the given new bound has to be a dual bound, i.e., it has to be valid for the original problem.
3689  *
3690  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3691  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3692  *
3693  * @pre this method can be called in one of the following stages of the SCIP solving process:
3694  * - \ref SCIP_STAGE_PROBLEM
3695  * - \ref SCIP_STAGE_PRESOLVING
3696  * - \ref SCIP_STAGE_PRESOLVED
3697  * - \ref SCIP_STAGE_SOLVING
3698  */
3700  SCIP* scip, /**< SCIP data structure */
3701  SCIP_Real newbound /**< new dual bound for the node (if it's tighter than the old one) */
3702  )
3703 {
3704  SCIP_CALL( SCIPcheckStage(scip, "SCIPupdateLocalDualbound", FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3705 
3706  switch( scip->set->stage )
3707  {
3708  case SCIP_STAGE_PROBLEM:
3709  /* since no root node, for which we could update the dual bound, has been create yet, update the dual bound stored in
3710  * the problem data
3711  */
3712  SCIPprobUpdateDualbound(scip->origprob, newbound);
3713  break;
3714 
3715  case SCIP_STAGE_PRESOLVING:
3716  case SCIP_STAGE_PRESOLVED:
3717  /* since no root node, for which we could update the dual bound, has been create yet, update the dual bound stored in
3718  * the problem data
3719  */
3720  SCIPprobUpdateDualbound(scip->transprob, SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, newbound));
3721  break;
3722 
3723  case SCIP_STAGE_SOLVING:
3725  break;
3726 
3727  default:
3728  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
3729  SCIPABORT();
3730  return SCIP_INVALIDCALL; /*lint !e527*/
3731  } /*lint !e788*/
3732 
3733  return SCIP_OKAY;
3734 }
3735 
3736 /** if given value is larger than the current node's lower bound (in transformed problem), sets the current node's
3737  * lower bound to the new value
3738  *
3739  * @note the given new bound has to be a lower bound, i.e., it has to be valid for the transformed problem.
3740  *
3741  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3742  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3743  *
3744  * @pre this method can be called in one of the following stages of the SCIP solving process:
3745  * - \ref SCIP_STAGE_PRESOLVING
3746  * - \ref SCIP_STAGE_PRESOLVED
3747  * - \ref SCIP_STAGE_SOLVING
3748  */
3750  SCIP* scip, /**< SCIP data structure */
3751  SCIP_Real newbound /**< new lower bound for the node (if it's larger than the old one) */
3752  )
3753 {
3754  SCIP_CALL( SCIPcheckStage(scip, "SCIPupdateLocalLowerbound", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3755 
3756  switch( scip->set->stage )
3757  {
3758  case SCIP_STAGE_PRESOLVING:
3759  case SCIP_STAGE_PRESOLVED:
3760  /* since no root node, for which we could update the lower bound, has been created yet, update the dual bound stored
3761  * in the problem data
3762  */
3763  SCIPprobUpdateDualbound(scip->transprob, SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, newbound));
3764  break;
3765 
3766  case SCIP_STAGE_SOLVING:
3768  break;
3769 
3770  default:
3771  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
3772  SCIPABORT();
3773  return SCIP_INVALIDCALL; /*lint !e527*/
3774  } /*lint !e788*/
3775 
3776  return SCIP_OKAY;
3777 }
3778 
3779 /** if given value is tighter (larger for minimization, smaller for maximization) than the node's dual bound,
3780  * sets the node's dual bound to the new value
3781  *
3782  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3783  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3784  *
3785  * @pre this method can be called in one of the following stages of the SCIP solving process:
3786  * - \ref SCIP_STAGE_SOLVING
3787  */
3789  SCIP* scip, /**< SCIP data structure */
3790  SCIP_NODE* node, /**< node to update dual bound for */
3791  SCIP_Real newbound /**< new dual bound for the node (if it's tighter than the old one) */
3792  )
3793 {
3794  SCIP_CALL( SCIPcheckStage(scip, "SCIPupdateNodeDualbound", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3795 
3796  SCIP_CALL( SCIPupdateNodeLowerbound(scip, node, SCIPprobInternObjval(scip->transprob, scip->origprob, scip->set, newbound)) );
3797 
3798  return SCIP_OKAY;
3799 }
3800 
3801 /** if given value is larger than the node's lower bound (in transformed problem), sets the node's lower bound
3802  * to the new value
3803  *
3804  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3805  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3806  *
3807  * @pre this method can be called in one of the following stages of the SCIP solving process:
3808  * - \ref SCIP_STAGE_SOLVING
3809  */
3811  SCIP* scip, /**< SCIP data structure */
3812  SCIP_NODE* node, /**< node to update lower bound for */
3813  SCIP_Real newbound /**< new lower bound for the node (if it's larger than the old one) */
3814  )
3815 {
3816  SCIP_CALL( SCIPcheckStage(scip, "SCIPupdateNodeLowerbound", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3817 
3818  SCIPnodeUpdateLowerbound(node, scip->stat, scip->set, scip->tree, scip->transprob, scip->origprob, newbound);
3819 
3820  /* if lowerbound exceeds the cutoffbound the node will be marked to be cutoff
3821  *
3822  * If the node is an inner node (,not a child node,) we need to cutoff the node manually if we exceed the
3823  * cutoffbound. This is only relevant if a user updates the lower bound; in the main solving process of SCIP the
3824  * lowerbound is only changed before branching and the given node is always a child node. Therefore, we only check
3825  * for a cutoff here in the user function instead of in SCIPnodeUpdateLowerbound().
3826  */
3827  if( SCIPisGE(scip, newbound, scip->primal->cutoffbound) )
3828  {
3829  SCIP_CALL( SCIPnodeCutoff(node, scip->set, scip->stat, scip->tree, scip->transprob, scip->origprob, scip->reopt,
3830  scip->lp, scip->mem->probmem) );
3831  }
3832 
3833  return SCIP_OKAY;
3834 }
3835 
3836 /** change the node selection priority of the given child
3837  *
3838  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3839  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3840  *
3841  * @pre this method can be called in one of the following stages of the SCIP solving process:
3842  * - \ref SCIP_STAGE_SOLVING
3843  */
3845  SCIP* scip, /**< SCIP data structure */
3846  SCIP_NODE* child, /**< child to update the node selection priority */
3847  SCIP_Real priority /**< node selection priority value */
3848  )
3849 {
3850  SCIP_CALL( SCIPcheckStage(scip, "SCIPchgChildPrio", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3851 
3852  if( SCIPnodeGetType(child) != SCIP_NODETYPE_CHILD )
3853  return SCIP_INVALIDDATA;
3854 
3855  SCIPchildChgNodeselPrio(scip->tree, child, priority);
3856 
3857  return SCIP_OKAY;
3858 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_Real cutoffbound
Definition: struct_primal.h:46
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:2470
SCIP_RETCODE SCIPclearConflictStore(SCIP *scip, SCIP_EVENT *event)
Definition: scip_prob.c:3339
internal methods for separators
void SCIPfreeRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen)
SCIP_STAT * stat
Definition: struct_scip.h:69
SCIP_RETCODE SCIPconsDelete(SCIP_CONS *cons, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_REOPT *reopt)
Definition: cons.c:6343
int SCIPgetNIntVars(SCIP *scip)
Definition: scip_prob.c:2134
SCIP_RETCODE SCIPreoptReleaseData(SCIP_REOPT *reopt, SCIP_SET *set, BMS_BLKMEM *blkmem)
Definition: reopt.c:5113
int SCIPgetNCheckConss(SCIP *scip)
Definition: scip_prob.c:3236
SCIP_RETCODE SCIPpricerDeactivate(SCIP_PRICER *pricer, SCIP_SET *set)
Definition: pricer.c:363
#define NULL
Definition: def.h:239
internal methods for managing events
SCIP_READER ** readers
Definition: struct_set.h:68
default message handler
SCIP_VAR * SCIPprobFindVar(SCIP_PROB *prob, const char *name)
Definition: prob.c:2118
trivialnegation primal heuristic
internal methods for storing primal CIP solutions
void SCIPbendersDeactivate(SCIP_BENDERS *benders, SCIP_SET *set)
Definition: benders.c:1891
public methods for SCIP parameter handling
int random_permutationseed
Definition: struct_set.h:384
methods to interpret (evaluate) an expression tree "fast"
public methods for branch and bound tree
internal methods for branch and bound tree
SCIP_RETCODE SCIPaddVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real addobj)
Definition: scip_var.c:4499
void SCIPprobSetData(SCIP_PROB *prob, SCIP_PROBDATA *probdata)
Definition: prob.c:694
static SCIP_RETCODE writeProblem(SCIP *scip, const char *filename, const char *extension, SCIP_Bool transformed, SCIP_Bool genericnames)
Definition: scip_prob.c:541
SCIP_PROBDATA * SCIPprobGetData(SCIP_PROB *prob)
Definition: prob.c:2291
#define SCIPdebugFreeDebugData(set)
Definition: debug.h:254
SCIP_RETCODE SCIPgetSolVarsData(SCIP *scip, SCIP_SOL *sol, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:2672
public methods for memory management
SCIP_RETCODE SCIPaddOrigObjoffset(SCIP *scip, SCIP_Real addval)
Definition: scip_prob.c:1346
SCIP_Real SCIPgetReadingTime(SCIP *scip)
Definition: scip_timing.c:463
SCIP_Real SCIPgetCutoffbound(SCIP *scip)
#define SCIPallocClearBufferArray(scip, ptr, num)
Definition: scip_mem.h:132
#define SCIP_DECL_PROBINITSOL(x)
Definition: type_prob.h:97
SCIP_Real SCIPnodeGetLowerbound(SCIP_NODE *node)
Definition: tree.c:7364
methods for implications, variable bounds, and cliques
SCIP_Real SCIPgetLocalTransEstimate(SCIP *scip)
Definition: scip_prob.c:3599
#define SCIP_DECL_PROBDELORIG(x)
Definition: type_prob.h:55
SCIP_RETCODE SCIPsetProbCopy(SCIP *scip, SCIP_DECL_PROBCOPY((*probcopy)))
Definition: scip_prob.c:349
SCIP_PRIMAL * origprimal
Definition: struct_scip.h:71
int validdepth
Definition: struct_cons.h:60
SCIP_RETCODE SCIPconflictstoreCleanNewIncumbent(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_STAT *stat, BMS_BLKMEM *blkmem, SCIP_PROB *transprob, SCIP_REOPT *reopt, SCIP_Real cutoffbound)
void SCIPlpRecalculateObjSqrNorm(SCIP_SET *set, SCIP_LP *lp)
Definition: lp.c:17206
internal methods for clocks and timing issues
SCIP_RETCODE SCIPcreateProb(SCIP *scip, 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)
Definition: scip_prob.c:162
SCIP_RETCODE SCIPdelCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2895
SCIP_RETCODE SCIPnodeDelCons(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_CONS *cons)
Definition: tree.c:1608
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
int SCIPgetNOrigVars(SCIP *scip)
Definition: scip_prob.c:2484
int nconcsolvers
Definition: struct_set.h:134
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_EVENTQUEUE * eventqueue
Definition: struct_scip.h:78
internal methods for NLPI solver interfaces
public solving methods
int nintvars
Definition: struct_prob.h:63
SCIP_Bool SCIPconsIsAdded(SCIP_CONS *cons)
Definition: cons.c:8505
SCIP_RETCODE SCIPdelConsNode(SCIP *scip, SCIP_NODE *node, SCIP_CONS *cons)
Definition: scip_prob.c:3477
public methods for timing
SCIP_PRIMAL * primal
Definition: struct_scip.h:83
void SCIPprobAddObjoffset(SCIP_PROB *prob, SCIP_Real addval)
Definition: prob.c:1425
void SCIPsplitFilename(char *filename, char **path, char **name, char **extension, char **compression)
Definition: misc.c:10236
SCIP_RETCODE SCIPprintTransProblem(SCIP *scip, FILE *file, const char *extension, SCIP_Bool genericnames)
const char * SCIPreaderGetName(SCIP_READER *reader)
Definition: reader.c:547
interface methods for specific LP solvers
SCIP_Bool time_reading
Definition: struct_set.h:552
SCIP_RETCODE SCIPreoptAddCons(SCIP_REOPT *reopt, SCIP_SET *set, BMS_BLKMEM *blkmem, SCIP_CONS *cons)
Definition: reopt.c:8096
internal methods for displaying statistics tables
void SCIPconsMarkConflict(SCIP_CONS *cons)
Definition: cons.c:6984
#define SCIP_DECL_PROBDELTRANS(x)
Definition: type_prob.h:86
SCIP_BRANCHCAND * branchcand
Definition: struct_scip.h:79
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:1918
SCIP_RETCODE SCIPsetProbExitsol(SCIP *scip, SCIP_DECL_PROBEXITSOL((*probexitsol)))
Definition: scip_prob.c:328
SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4563
SCIP_RETCODE SCIPchgReoptObjective(SCIP *scip, SCIP_OBJSENSE objsense, SCIP_VAR **vars, SCIP_Real *coefs, int nvars)
Definition: scip_prob.c:1175
#define FALSE
Definition: def.h:65
methods for the aggregation rows
SCIP_Real objoffset
Definition: struct_prob.h:41
internal methods for Benders&#39; decomposition
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_STAGE stage
Definition: struct_set.h:63
void SCIPrandomPermuteArray(SCIP_RANDNUMGEN *randnumgen, void **array, int begin, int end)
Definition: misc.c:9443
#define TRUE
Definition: def.h:64
void SCIPprobSetExitsol(SCIP_PROB *prob, SCIP_DECL_PROBEXITSOL((*probexitsol)))
Definition: prob.c:377
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_Real SCIPgetLocalLowerbound(SCIP *scip)
Definition: scip_prob.c:3638
methods commonly used by primal heuristics
SCIP_RETCODE SCIPwriteOrigProblem(SCIP *scip, const char *filename, const char *extension, SCIP_Bool genericnames)
Definition: scip_prob.c:652
SCIP_Real SCIPprobInternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2096
int SCIPtreeGetCurrentDepth(SCIP_TREE *tree)
Definition: tree.c:8304
SCIP_RETCODE SCIPsetProbData(SCIP *scip, SCIP_PROBDATA *probdata)
Definition: scip_prob.c:1070
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:17036
internal methods for branching rules and branching candidate storage
SCIP_RETCODE SCIPreoptFree(SCIP_REOPT **reopt, SCIP_SET *set, SCIP_PRIMAL *origprimal, BMS_BLKMEM *blkmem)
Definition: reopt.c:5139
datastructures for concurrent solvers
SCIP_VAR ** SCIPgetOrigVars(SCIP *scip)
Definition: scip_prob.c:2457
public methods for problem variables
SCIP_VAR ** fixedvars
Definition: struct_prob.h:56
SCIP_Bool SCIPallVarsInProb(SCIP *scip)
Definition: scip_prob.c:2795
SCIP_RETCODE SCIPgetOrigVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:2409
int nimplvars
Definition: struct_prob.h:64
#define SCIPduplicateBufferArray(scip, ptr, source, num)
Definition: scip_mem.h:138
#define SCIP_DECL_PROBCOPY(x)
Definition: type_prob.h:140
SCIP_CONS ** SCIPgetConss(SCIP *scip)
Definition: scip_prob.c:3140
internal methods for handling parameter settings
SCIP_PROB * transprob
Definition: struct_scip.h:87
int SCIPnodeGetDepth(SCIP_NODE *node)
Definition: tree.c:7354
methods for creating output for visualization tools (VBC, BAK)
nodereopt branching rule
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:142
SCIP_Bool SCIPisTransformed(SCIP *scip)
Definition: scip_general.c:611
public methods for SCIP variables
int nactivebenders
Definition: struct_set.h:137
SCIP_VAR * SCIPvarGetNegationVar(SCIP_VAR *var)
Definition: var.c:17169
#define SCIPdebugMsg
Definition: scip_message.h:88
internal methods for LP management
SCIP_PROB * origprob
Definition: struct_scip.h:70
int SCIPgetNContVars(SCIP *scip)
Definition: scip_prob.c:2224
SCIP_RETCODE SCIPcreateProbBasic(SCIP *scip, const char *name)
Definition: scip_prob.c:223
SCIP_Real SCIPgetObjNorm(SCIP *scip)
Definition: scip_prob.c:1697
SCIP_Bool objsqrnormunreliable
Definition: struct_lp.h:340
internal methods for branching and inference history
public methods for numerical tolerances
internal methods for collecting primal CIP solutions and primal informations
SCIP_Bool reopt_enable
Definition: struct_set.h:468
SCIP_RETCODE SCIPconflictstoreCreate(SCIP_CONFLICTSTORE **conflictstore, SCIP_SET *set)
SCIP_RETCODE SCIPchgChildPrio(SCIP *scip, SCIP_NODE *child, SCIP_Real priority)
Definition: scip_prob.c:3844
SCIP_CONSSETCHG * addconssetchg
Definition: struct_cons.h:48
SCIP_Bool SCIPconsIsGlobal(SCIP_CONS *cons)
Definition: cons.c:8305
void SCIPprobSetObjIntegral(SCIP_PROB *prob)
Definition: prob.c:1460
int SCIPgetNConshdlrs(SCIP *scip)
Definition: scip_cons.c:978
public methods for querying solving statistics
internal methods for propagators
const char * SCIPgetProbName(SCIP *scip)
Definition: scip_prob.c:1123
void SCIPclockSetTime(SCIP_CLOCK *clck, SCIP_Real sec)
Definition: clock.c:518
SCIP_PRICESTORE * pricestore
Definition: struct_scip.h:90
SCIP_RETCODE SCIPprobFree(SCIP_PROB **prob, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp)
Definition: prob.c:399
SCIP_RETCODE SCIPprimalUpdateObjlimit(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:405
int SCIPgetNFixedVars(SCIP *scip)
Definition: scip_prob.c:2361
SCIP_VAR * SCIPfindVar(SCIP *scip, const char *name)
Definition: scip_prob.c:2737
SCIP_VAR ** SCIPgetFixedVars(SCIP *scip)
Definition: scip_prob.c:2318
SCIP_Real SCIPprobGetObjlim(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:2279
SCIP_RETCODE SCIPnodeCutoff(SCIP_NODE *node, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_REOPT *reopt, SCIP_LP *lp, BMS_BLKMEM *blkmem)
Definition: tree.c:1146
void SCIPprobSetInitsol(SCIP_PROB *prob, SCIP_DECL_PROBINITSOL((*probinitsol)))
Definition: prob.c:366
void SCIPprobSetCopy(SCIP_PROB *prob, SCIP_DECL_PROBCOPY((*probcopy)))
Definition: prob.c:388
SCIP_RETCODE SCIPdelVar(SCIP *scip, SCIP_VAR *var, SCIP_Bool *deleted)
Definition: scip_prob.c:1842
SCIP_MEM * mem
Definition: struct_scip.h:61
public methods for managing constraints
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
Definition: scip_prob.c:1298
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:1059
void SCIPnodeUpdateLowerbound(SCIP_NODE *node, SCIP_STAT *stat, SCIP_SET *set, SCIP_TREE *tree, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_Real newbound)
Definition: tree.c:2299
SCIP_RETCODE SCIPsetObjIntegral(SCIP *scip)
Definition: scip_prob.c:1575
void SCIPprobSetObjsense(SCIP_PROB *prob, SCIP_OBJSENSE objsense)
Definition: prob.c:1412
git hash methods
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:129
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:45
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4191
void SCIPmessagePrintVerbInfo(SCIP_MESSAGEHDLR *messagehdlr, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, const char *formatstr,...)
Definition: message.c:668
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2822
SCIP_CONSHDLR ** SCIPgetConshdlrs(SCIP *scip)
Definition: scip_cons.c:967
SCIP_Bool SCIPsyncstoreIsInitialized(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:775
SCIP_EVENTFILTER * eventfilter
Definition: struct_scip.h:77
SCIP_RETCODE SCIPaddConsLocal(SCIP *scip, SCIP_CONS *cons, SCIP_NODE *validnode)
Definition: scip_prob.c:3446
SCIP_CONS * SCIPprobFindCons(SCIP_PROB *prob, const char *name)
Definition: prob.c:2137
SCIP_RETCODE SCIPstatFree(SCIP_STAT **stat, BMS_BLKMEM *blkmem)
Definition: stat.c:111
methods for block memory pools and memory buffers
SCIP_SYNCSTORE * syncstore
Definition: struct_scip.h:98
SCIP_RETCODE SCIPfreeProb(SCIP *scip)
Definition: scip_prob.c:745
SCIP_RETCODE SCIPreadProb(SCIP *scip, const char *filename, const char *extension)
Definition: scip_prob.c:382
SCIP_RETCODE SCIPdelConsLocal(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:3527
SCIP_RETCODE SCIPconflictstoreFree(SCIP_CONFLICTSTORE **conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_REOPT *reopt)
SCIP_Bool random_permutevars
Definition: struct_set.h:388
register additional core functionality that is designed as plugins
SCIP_RETCODE SCIPcheckStage(SCIP *scip, const char *method, SCIP_Bool init, SCIP_Bool problem, SCIP_Bool transforming, SCIP_Bool transformed, SCIP_Bool initpresolve, SCIP_Bool presolving, SCIP_Bool exitpresolve, SCIP_Bool presolved, SCIP_Bool initsolve, SCIP_Bool solving, SCIP_Bool solved, SCIP_Bool exitsolve, SCIP_Bool freetrans, SCIP_Bool freescip)
Definition: debug.c:1933
SCIP_CONS * SCIPfindOrigCons(SCIP *scip, const char *name)
Definition: scip_prob.c:2950
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip_mem.c:128
SCIP_Bool objisintegral
Definition: struct_prob.h:78
SCIP_CONSHDLR ** conshdlrs
Definition: struct_set.h:70
internal methods for presolvers
SCIP_CONFLICTSTORE * conflictstore
Definition: struct_scip.h:93
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8076
SCIP_OBJSENSE objsense
Definition: struct_prob.h:77
SCIP_RETCODE SCIPreaderResetReadingTime(SCIP_READER *reader)
Definition: reader.c:618
SCIP_CONS ** SCIPgetOrigConss(SCIP *scip)
Definition: scip_prob.c:3213
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16729
SCIP_REOPT * reopt
Definition: struct_scip.h:74
internal methods for NLP management
void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:417
SCIP_Real SCIPgetNodeDualbound(SCIP *scip, SCIP_NODE *node)
Definition: scip_prob.c:3658
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
Definition: scip_param.c:322
SCIP_CONS * SCIPfindCons(SCIP *scip, const char *name)
Definition: scip_prob.c:2999
int SCIPprobGetNObjVars(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:1977
internal miscellaneous methods
SCIP_RETCODE SCIPprintOrigProblem(SCIP *scip, FILE *file, const char *extension, SCIP_Bool genericnames)
SCIP_Real SCIPlpGetObjNorm(SCIP_LP *lp)
Definition: lp.c:17237
SCIP_RETCODE SCIPprobSetName(SCIP_PROB *prob, const char *name)
Definition: prob.c:1939
SCIP_Real SCIPgetLocalDualbound(SCIP *scip)
Definition: scip_prob.c:3619
internal methods for node selectors and node priority queues
SCIP_Bool SCIPprobIsObjIntegral(SCIP_PROB *prob)
Definition: prob.c:2255
internal methods for variable pricers
public methods for primal CIP solutions
internal methods for global SCIP settings
internal methods for storing conflicts
#define SCIP_CALL(x)
Definition: def.h:351
SCIP main data structure.
int SCIPgetNTotalVars(SCIP *scip)
Definition: scip_prob.c:2621
int SCIPgetNOrigConss(SCIP *scip)
Definition: scip_prob.c:3186
SCIP_VAR * h
Definition: circlepacking.c:59
SCIP_RETCODE SCIPreaderRead(SCIP_READER *reader, SCIP_SET *set, const char *filename, const char *extension, SCIP_RESULT *result)
Definition: reader.c:173
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:254
internal methods for storing priced variables
internal methods for relaxators
internal methods for storing separated cuts
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:125
public methods for constraint handler plugins and constraints
methods commonly used for presolving
SCIP_RETCODE SCIPaddConsNode(SCIP *scip, SCIP_NODE *node, SCIP_CONS *cons, SCIP_NODE *validnode)
Definition: scip_prob.c:3376
#define SCIP_DECL_PROBTRANS(x)
Definition: type_prob.h:74
methods for catching the user CTRL-C interrupt
SCIP_CLIQUETABLE * cliquetable
Definition: struct_scip.h:86
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
Definition: scip_var.c:4450
SCIP_RETCODE SCIPcreateRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen, unsigned int initialseed, SCIP_Bool useglobalseed)
internal methods for problem variables
data structures and methods for collecting reoptimization information
the function declarations for the synchronization store
SCIP_Bool SCIPvarIsOriginal(SCIP_VAR *var)
Definition: var.c:16858
public data structures and miscellaneous methods
SCIP_RETCODE SCIPfreeTransform(SCIP *scip)
Definition: scip_solve.c:3367
SCIP_RETCODE SCIPpermuteProb(SCIP *scip, unsigned int randseed, SCIP_Bool permuteconss, SCIP_Bool permutebinvars, SCIP_Bool permuteintvars, SCIP_Bool permuteimplvars, SCIP_Bool permutecontvars)
Definition: scip_prob.c:837
internal methods for user interface dialog
int SCIPtreeGetEffectiveRootDepth(SCIP_TREE *tree)
Definition: tree.c:8343
#define SCIP_Bool
Definition: def.h:62
SCIP_RETCODE SCIPsetProbTrans(SCIP *scip, SCIP_DECL_PROBTRANS((*probtrans)))
Definition: scip_prob.c:264
int SCIPgetNImplVars(SCIP *scip)
Definition: scip_prob.c:2179
SCIP_Real SCIPgetObjlimit(SCIP *scip)
Definition: scip_prob.c:1548
#define SCIP_DECL_PROBEXITSOL(x)
Definition: type_prob.h:110
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
Definition: event.c:995
SCIP_Bool SCIPprobIsPermuted(SCIP_PROB *prob)
Definition: prob.c:2225
SCIP_Real SCIPgetOrigObjscale(SCIP *scip)
Definition: scip_prob.c:1400
SCIP_RETCODE SCIPwriteTransProblem(SCIP *scip, const char *filename, const char *extension, SCIP_Bool genericnames)
Definition: scip_prob.c:699
int ncontvars
Definition: struct_prob.h:65
void SCIPprintSysError(const char *message)
Definition: misc.c:9926
int nbinvars
Definition: struct_prob.h:62
enum SCIP_Objsense SCIP_OBJSENSE
Definition: type_prob.h:41
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
Definition: scip_prob.c:1478
SCIP_CONSHDLR * conshdlr
Definition: struct_cons.h:44
SCIP_RETCODE SCIPstatCreate(SCIP_STAT **stat, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_MESSAGEHDLR *messagehdlr)
Definition: stat.c:45
SCIP_RETCODE SCIPupdateNodeDualbound(SCIP *scip, SCIP_NODE *node, SCIP_Real newbound)
Definition: scip_prob.c:3788
SCIP_RETCODE SCIPupdateNodeLowerbound(SCIP *scip, SCIP_NODE *node, SCIP_Real newbound)
Definition: scip_prob.c:3810
internal methods for input file readers
void SCIPprobSetTrans(SCIP_PROB *prob, SCIP_DECL_PROBTRANS((*probtrans)))
Definition: prob.c:344
int nreaders
Definition: struct_set.h:97
SCIP_RETCODE SCIPfreeConcurrent(SCIP *scip)
Definition: concurrent.c:142
methods for debugging
SCIP_BENDERS ** benders
Definition: struct_set.h:92
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17191
static const unsigned int randseed
Definition: circle.c:46
SCIP_RETCODE SCIPpricestoreAddVar(SCIP_PRICESTORE *pricestore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp, SCIP_VAR *var, SCIP_Real score, SCIP_Bool root)
Definition: pricestore.c:171
SCIP_RETCODE SCIPupdateLocalDualbound(SCIP *scip, SCIP_Real newbound)
Definition: scip_prob.c:3699
reoptsols primal heuristic
internal methods for storing cuts in a cut pool
Constraint handler for linear constraints in their most general form, .
int SCIPgetNObjVars(SCIP *scip)
Definition: scip_prob.c:2272
void SCIPprobSetObjlim(SCIP_PROB *prob, SCIP_Real objlim)
Definition: prob.c:1449
int SCIPgetNOrigContVars(SCIP *scip)
Definition: scip_prob.c:2592
int nfixedvars
Definition: struct_prob.h:68
SCIP_Real SCIPgetTransObjscale(SCIP *scip)
Definition: scip_prob.c:1446
int SCIPgetNBinVars(SCIP *scip)
Definition: scip_prob.c:2089
int SCIPconshdlrGetNActiveConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4627
helper functions for concurrent scip solvers
int SCIPgetNVars(SCIP *scip)
Definition: scip_prob.c:2044
SCIP_RETCODE SCIPsyncstoreExit(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:190
SCIP_Real SCIPnodeGetEstimate(SCIP_NODE *node)
Definition: tree.c:7374
SCIP_RETCODE SCIPupdateLocalLowerbound(SCIP *scip, SCIP_Real newbound)
Definition: scip_prob.c:3749
internal methods for return codes for SCIP methods
SCIP_RETCODE SCIPaddPricedVar(SCIP *scip, SCIP_VAR *var, SCIP_Real score)
Definition: scip_prob.c:1789
SCIP_Real SCIPgetTransObjoffset(SCIP *scip)
Definition: scip_prob.c:1423
SCIP_RETCODE SCIPsetProbInitsol(SCIP *scip, SCIP_DECL_PROBINITSOL((*probinitsol)))
Definition: scip_prob.c:306
SCIP_Bool SCIPisObjIntegral(SCIP *scip)
Definition: scip_prob.c:1618
public methods for managing events
#define SCIP_EVENTTYPE_BESTSOLFOUND
Definition: type_event.h:88
general public methods
int SCIPgetNOrigIntVars(SCIP *scip)
Definition: scip_prob.c:2538
BMS_BLKMEM * probmem
Definition: struct_mem.h:40
struct SCIP_ProbData SCIP_PROBDATA
Definition: type_prob.h:44
SCIP_RETCODE SCIPsetProbName(SCIP *scip, const char *name)
Definition: scip_prob.c:1151
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
public methods for solutions
internal methods for conflict analysis
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition: scip_prob.c:1724
internal methods for tree compressions
public methods for random numbers
internal methods for main solving loop and node processing
SCIP_PROBDATA * SCIPgetProbData(SCIP *scip)
Definition: scip_prob.c:1020
SCIP_Real SCIPtransformObj(SCIP *scip, SCIP_Real obj)
Definition: scip_sol.c:1600
SCIP_VERBLEVEL disp_verblevel
Definition: struct_set.h:261
int nactivepricers
Definition: struct_set.h:100
int SCIPgetNConss(SCIP *scip)
Definition: scip_prob.c:3094
SCIP_NODE * SCIPtreeGetCurrentNode(SCIP_TREE *tree)
Definition: tree.c:8287
SCIP_CLOCK * solvingtime
Definition: struct_stat.h:144
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1187
int nconss
Definition: struct_prob.h:73
SCIP_SET * set
Definition: struct_scip.h:62
SCIP_Bool misc_transsolsorig
Definition: struct_set.h:370
public methods for message output
int SCIPgetNUpgrConss(SCIP *scip)
Definition: scip_prob.c:3052
void SCIPprobUpdateDualbound(SCIP_PROB *prob, SCIP_Real newbound)
Definition: prob.c:1552
void SCIPprobSetDelorig(SCIP_PROB *prob, SCIP_DECL_PROBDELORIG((*probdelorig)))
Definition: prob.c:333
SCIP_VAR ** SCIPgetVars(SCIP *scip)
Definition: scip_prob.c:1999
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16848
SCIP_MESSAGEHDLR * messagehdlr
Definition: struct_scip.h:65
SCIP_NODETYPE SCIPnodeGetType(SCIP_NODE *node)
Definition: tree.c:7334
default user interface dialog
#define SCIP_Real
Definition: def.h:150
internal methods for problem statistics
SCIP_VAR ** vars
Definition: struct_prob.h:55
SCIP_PRICER ** pricers
Definition: struct_set.h:69
enum SCIP_ConflictType SCIP_CONFTYPE
Definition: type_conflict.h:56
public methods for input file readers
SCIP_RETCODE SCIPconflictstoreAddConflict(SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_PROB *transprob, SCIP_REOPT *reopt, SCIP_CONS *cons, SCIP_CONFTYPE conftype, SCIP_Bool cutoffinvolved, SCIP_Real primalbound)
int SCIPconshdlrGetNCheckConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4613
SCIP_Bool random_permuteconss
Definition: struct_set.h:387
SCIP_RETCODE SCIPsetFreeConcsolvers(SCIP_SET *set)
Definition: set.c:4396
SCIP_CONS ** conss
Definition: struct_prob.h:59
#define SCIP_INVALID
Definition: def.h:170
SCIP_Real SCIPgetLocalOrigEstimate(SCIP *scip)
Definition: scip_prob.c:3580
internal methods for constraints and constraint handlers
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:444
SCIP_Real SCIPgetOrigObjoffset(SCIP *scip)
Definition: scip_prob.c:1375
SCIP_RETCODE SCIPnodeAddCons(SCIP_NODE *node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_CONS *cons)
Definition: tree.c:1565
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16894
SCIP_TREE * tree
Definition: struct_scip.h:84
declarations for XML parsing
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
Definition: scip_prob.c:1281
build flags methods
SCIP_Real SCIPgetNodeLowerbound(SCIP *scip, SCIP_NODE *node)
Definition: scip_prob.c:3675
void SCIPprobSetDeltrans(SCIP_PROB *prob, SCIP_DECL_PROBDELTRANS((*probdeltrans)))
Definition: prob.c:355
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
int SCIPgetNOrigImplVars(SCIP *scip)
Definition: scip_prob.c:2565
SCIP_RETCODE SCIPsetProbDeltrans(SCIP *scip, SCIP_DECL_PROBDELTRANS((*probdeltrans)))
Definition: scip_prob.c:285
SCIP_Real SCIPprobExternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2074
SCIP_RETCODE SCIPprobAddCons(SCIP_PROB *prob, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons)
Definition: prob.c:1271
void SCIPprimalAddOrigObjoffset(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_Real addval)
Definition: primal.c:510
SCIP_RETCODE SCIPprimalCreate(SCIP_PRIMAL **primal)
Definition: primal.c:118
int nconshdlrs
Definition: struct_set.h:102
void SCIPconsSetLocal(SCIP_CONS *cons, SCIP_Bool local)
Definition: cons.c:6640
SCIP_RETCODE SCIPprobDelVar(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_EVENTQUEUE *eventqueue, SCIP_VAR *var, SCIP_Bool *deleted)
Definition: prob.c:998
common defines and data types used in all packages of SCIP
int SCIPgetNOrigBinVars(SCIP *scip)
Definition: scip_prob.c:2511
SCIP_RETCODE SCIPsetProbDelorig(SCIP *scip, SCIP_DECL_PROBDELORIG((*probdelorig)))
Definition: scip_prob.c:243
SCIP_RETCODE SCIPaddConflict(SCIP *scip, SCIP_NODE *node, SCIP_CONS *cons, SCIP_NODE *validnode, SCIP_CONFTYPE conftype, SCIP_Bool iscutoffinvolved)
Definition: scip_prob.c:3280
#define SCIP_CALL_ABORT(x)
Definition: def.h:330
SCIP_RETCODE SCIPprimalFree(SCIP_PRIMAL **primal, BMS_BLKMEM *blkmem)
Definition: primal.c:148
internal methods for primal heuristics
SCIP_LP * lp
Definition: struct_scip.h:80
#define SCIPABORT()
Definition: def.h:323
public methods for global and local (sub)problems
void SCIPchildChgNodeselPrio(SCIP_TREE *tree, SCIP_NODE *child, SCIP_Real priority)
Definition: tree.c:2377
int npresolupgdconss
Definition: struct_stat.h:236
const char * SCIPprobGetName(SCIP_PROB *prob)
Definition: prob.c:2301
SCIP_RETCODE SCIPaddObjoffset(SCIP *scip, SCIP_Real addval)
Definition: scip_prob.c:1324
SCIP_SOL * SCIPeventGetSol(SCIP_EVENT *event)
Definition: event.c:1259
void SCIPprobMarkPermuted(SCIP_PROB *prob)
Definition: prob.c:2235
internal methods for Benders&#39; decomposition cuts
SCIP_RETCODE SCIPenableReoptimization(SCIP *scip, SCIP_Bool enable)
Definition: scip_solve.c:3066
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:919
SCIP_Real objscale
Definition: struct_prob.h:42
internal methods for displaying runtime statistics
OFINS - Objective Function Induced Neighborhood Search - a primal heuristic for reoptimization.