Scippy

SCIP

Solving Constraint Integer Programs

primal.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-2017 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file primal.c
17  * @brief methods for collecting primal CIP solutions and primal informations
18  * @author Tobias Achterberg
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #include <assert.h>
24 
25 #include "scip/def.h"
26 #include "scip/set.h"
27 #include "scip/stat.h"
28 #include "scip/visual.h"
29 #include "scip/event.h"
30 #include "scip/lp.h"
31 #include "scip/var.h"
32 #include "scip/prob.h"
33 #include "scip/sol.h"
34 #include "scip/primal.h"
35 #include "scip/tree.h"
36 #include "scip/reopt.h"
37 #include "scip/disp.h"
38 #include "scip/pub_message.h"
39 
40 
41 /*
42  * memory growing methods for dynamically allocated arrays
43  */
44 
45 /** ensures, that sols array can store at least num entries */
46 static
48  SCIP_PRIMAL* primal, /**< primal data */
49  SCIP_SET* set, /**< global SCIP settings */
50  int num /**< minimum number of entries to store */
51  )
52 {
53  assert(primal->nsols <= primal->solssize);
54 
55  if( num > primal->solssize )
56  {
57  int newsize;
58 
59  newsize = SCIPsetCalcMemGrowSize(set, num);
60  SCIP_ALLOC( BMSreallocMemoryArray(&primal->sols, newsize) );
61  primal->solssize = newsize;
62  }
63  assert(num <= primal->solssize);
64 
65  return SCIP_OKAY;
66 }
67 
68 /** ensures, that partialsols array can store at least num entries */
69 static
71  SCIP_PRIMAL* primal, /**< primal data */
72  SCIP_SET* set, /**< global SCIP settings */
73  int num /**< minimum number of entries to store */
74  )
75 {
76  assert(primal->npartialsols <= primal->partialsolssize);
77 
78  if( num > primal->partialsolssize )
79  {
80  int newsize;
81 
82  newsize = SCIPsetCalcMemGrowSize(set, num);
83  newsize = MIN(newsize, set->limit_maxorigsol);
84 
85  SCIP_ALLOC( BMSreallocMemoryArray(&primal->partialsols, newsize) );
86  primal->partialsolssize = newsize;
87  }
88  assert(num <= primal->partialsolssize);
89 
90  return SCIP_OKAY;
91 }
92 
93 /** ensures, that existingsols array can store at least num entries */
94 static
96  SCIP_PRIMAL* primal, /**< primal data */
97  SCIP_SET* set, /**< global SCIP settings */
98  int num /**< minimum number of entries to store */
99  )
100 {
101  assert(primal->nexistingsols <= primal->existingsolssize);
102 
103  if( num > primal->existingsolssize )
104  {
105  int newsize;
106 
107  newsize = SCIPsetCalcMemGrowSize(set, num);
108  SCIP_ALLOC( BMSreallocMemoryArray(&primal->existingsols, newsize) );
109  primal->existingsolssize = newsize;
110  }
111  assert(num <= primal->existingsolssize);
112 
113  return SCIP_OKAY;
114 }
115 
116 /** creates primal data */
118  SCIP_PRIMAL** primal /**< pointer to primal data */
119  )
120 {
121  assert(primal != NULL);
122 
123  SCIP_ALLOC( BMSallocMemory(primal) );
124  (*primal)->sols = NULL;
125  (*primal)->partialsols = NULL;
126  (*primal)->existingsols = NULL;
127  (*primal)->currentsol = NULL;
128  (*primal)->primalray = NULL;
129  (*primal)->solssize = 0;
130  (*primal)->partialsolssize = 0;
131  (*primal)->nsols = 0;
132  (*primal)->npartialsols = 0;
133  (*primal)->existingsolssize = 0;
134  (*primal)->nexistingsols = 0;
135  (*primal)->nsolsfound = 0;
136  (*primal)->nlimsolsfound = 0;
137  (*primal)->nbestsolsfound = 0;
138  (*primal)->nlimbestsolsfound = 0;
139  (*primal)->upperbound = SCIP_INVALID;
140  (*primal)->cutoffbound = SCIP_INVALID;
141  (*primal)->updateviolations = TRUE;
142 
143  return SCIP_OKAY;
144 }
145 
146 /** frees primal data */
148  SCIP_PRIMAL** primal, /**< pointer to primal data */
149  BMS_BLKMEM* blkmem /**< block memory */
150  )
151 {
152  int s;
153 
154  assert(primal != NULL);
155  assert(*primal != NULL);
156 
157  /* free temporary solution for storing current solution */
158  if( (*primal)->currentsol != NULL )
159  {
160  SCIP_CALL( SCIPsolFree(&(*primal)->currentsol, blkmem, *primal) );
161  }
162 
163  /* free solution for storing primal ray */
164  if( (*primal)->primalray != NULL )
165  {
166  SCIP_CALL( SCIPsolFree(&(*primal)->primalray, blkmem, *primal) );
167  }
168 
169  /* free feasible primal CIP solutions */
170  for( s = 0; s < (*primal)->nsols; ++s )
171  {
172  SCIP_CALL( SCIPsolFree(&(*primal)->sols[s], blkmem, *primal) );
173  }
174  /* free partial CIP solutions */
175  for( s = 0; s < (*primal)->npartialsols; ++s )
176  {
177  SCIP_CALL( SCIPsolFree(&(*primal)->partialsols[s], blkmem, *primal) );
178  }
179  assert((*primal)->nexistingsols == 0);
180 
181  BMSfreeMemoryArrayNull(&(*primal)->sols);
182  BMSfreeMemoryArrayNull(&(*primal)->partialsols);
183  BMSfreeMemoryArrayNull(&(*primal)->existingsols);
184  BMSfreeMemory(primal);
185 
186  return SCIP_OKAY;
187 }
188 
189 /** clears primal data */
191  SCIP_PRIMAL** primal, /**< pointer to primal data */
192  BMS_BLKMEM* blkmem /**< block memory */
193  )
194 {
195  int s;
196 
197  assert(primal != NULL);
198  assert(*primal != NULL);
199 
200  /* free temporary solution for storing current solution */
201  if( (*primal)->currentsol != NULL )
202  {
203  SCIP_CALL( SCIPsolFree(&(*primal)->currentsol, blkmem, *primal) );
204  }
205 
206  /* free solution for storing primal ray */
207  if( (*primal)->primalray != NULL )
208  {
209  SCIP_CALL( SCIPsolFree(&(*primal)->primalray, blkmem, *primal) );
210  }
211 
212  /* free feasible primal CIP solutions */
213  for( s = 0; s < (*primal)->nsols; ++s )
214  {
215  SCIP_CALL( SCIPsolFree(&(*primal)->sols[s], blkmem, *primal) );
216  }
217 
218  (*primal)->currentsol = NULL;
219  (*primal)->primalray = NULL;
220  (*primal)->nsols = 0;
221  (*primal)->nsolsfound = 0;
222  (*primal)->nlimsolsfound = 0;
223  (*primal)->nbestsolsfound = 0;
224  (*primal)->nlimbestsolsfound = 0;
225  (*primal)->upperbound = SCIP_INVALID;
226  (*primal)->cutoffbound = SCIP_INVALID;
227  (*primal)->updateviolations = TRUE;
228 
229  return SCIP_OKAY;
230 }
231 
232 /** sets the cutoff bound in primal data and in LP solver */
233 static
235  SCIP_PRIMAL* primal, /**< primal data */
236  BMS_BLKMEM* blkmem, /**< block memory */
237  SCIP_SET* set, /**< global SCIP settings */
238  SCIP_STAT* stat, /**< problem statistics data */
239  SCIP_PROB* prob, /**< problem data */
240  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
241  SCIP_TREE* tree, /**< branch and bound tree */
242  SCIP_REOPT* reopt, /**< reoptimization data structure */
243  SCIP_LP* lp, /**< current LP data */
244  SCIP_Real cutoffbound /**< new cutoff bound */
245  )
246 {
247  assert(primal != NULL);
248  assert(cutoffbound <= SCIPsetInfinity(set));
249  assert(primal->upperbound == SCIP_INVALID || SCIPsetIsLE(set, cutoffbound, primal->upperbound)); /*lint !e777*/
250  assert(!SCIPtreeInRepropagation(tree));
251 
252  SCIPsetDebugMsg(set, "changing cutoff bound from %g to %g\n", primal->cutoffbound, cutoffbound);
253 
254  primal->cutoffbound = MIN(cutoffbound, primal->upperbound); /* get rid of numerical issues */
255 
256  /* set cut off value in LP solver */
257  SCIP_CALL( SCIPlpSetCutoffbound(lp, set, prob, primal->cutoffbound) );
258 
259  /* cut off leaves of the tree */
260  SCIP_CALL( SCIPtreeCutoff(tree, reopt, blkmem, set, stat, eventqueue, lp, primal->cutoffbound) );
261 
262  return SCIP_OKAY;
263 }
264 
265 /** sets the cutoff bound in primal data and in LP solver */
267  SCIP_PRIMAL* primal, /**< primal data */
268  BMS_BLKMEM* blkmem, /**< block memory */
269  SCIP_SET* set, /**< global SCIP settings */
270  SCIP_STAT* stat, /**< problem statistics data */
271  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
272  SCIP_PROB* transprob, /**< transformed problem data */
273  SCIP_PROB* origprob, /**< original problem data */
274  SCIP_TREE* tree, /**< branch and bound tree */
275  SCIP_REOPT* reopt, /**< reoptimization data structure */
276  SCIP_LP* lp, /**< current LP data */
277  SCIP_Real cutoffbound, /**< new cutoff bound */
278  SCIP_Bool useforobjlimit /**< should the cutoff bound be used to update the objective limit, if
279  * better? */
280  )
281 {
282  assert(primal != NULL);
283  assert(cutoffbound <= SCIPsetInfinity(set));
284  assert(cutoffbound <= primal->upperbound);
285  assert(transprob != NULL);
286  assert(origprob != NULL);
287 
288  if( cutoffbound < primal->cutoffbound )
289  {
290  if( useforobjlimit )
291  {
292  SCIP_Real objval;
293 
294  objval = SCIPprobExternObjval(transprob, origprob, set, cutoffbound);
295 
296  if( objval < SCIPprobGetObjlim(origprob, set) )
297  {
298  SCIPsetDebugMsg(set, "changing cutoff bound from %g to %g changes objective limit from %g to %g\n",
299  primal->cutoffbound, cutoffbound, SCIPprobGetObjlim(origprob, set), objval);
300  SCIPprobSetObjlim(origprob, objval);
301  SCIPprobSetObjlim(transprob, objval);
302  }
303  }
304 
305  /* update cutoff bound */
306  SCIP_CALL( primalSetCutoffbound(primal, blkmem, set, stat, transprob, eventqueue, tree, reopt, lp, cutoffbound) );
307  }
308  else if( cutoffbound > primal->cutoffbound )
309  {
310  SCIPerrorMessage("invalid increase in cutoff bound\n");
311  return SCIP_INVALIDDATA;
312  }
313 
314  return SCIP_OKAY;
315 }
316 
317 /** sets upper bound in primal data and in LP solver */
318 static
320  SCIP_PRIMAL* primal, /**< primal data */
321  BMS_BLKMEM* blkmem, /**< block memory */
322  SCIP_SET* set, /**< global SCIP settings */
323  SCIP_STAT* stat, /**< problem statistics data */
324  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
325  SCIP_PROB* prob, /**< transformed problem after presolve */
326  SCIP_TREE* tree, /**< branch and bound tree */
327  SCIP_REOPT* reopt, /**< reoptimization data structure */
328  SCIP_LP* lp, /**< current LP data */
329  SCIP_Real upperbound /**< new upper bound */
330  )
331 {
332  SCIP_Real cutoffbound;
333 
334  assert(primal != NULL);
335  assert(stat != NULL);
336  assert(upperbound <= SCIPsetInfinity(set));
337  assert(upperbound <= primal->upperbound || stat->nnodes == 0);
338 
339  SCIPsetDebugMsg(set, "changing upper bound from %g to %g\n", primal->upperbound, upperbound);
340 
341  primal->upperbound = upperbound;
342 
343  /* if objective value is always integral, the cutoff bound can be reduced to nearly the previous integer number */
344  if( SCIPprobIsObjIntegral(prob) && !SCIPsetIsInfinity(set, upperbound) )
345  {
346  SCIP_Real delta;
347 
348  delta = SCIPsetCutoffbounddelta(set);
349 
350  cutoffbound = SCIPsetFeasCeil(set, upperbound) - (1.0 - delta);
351  cutoffbound = MIN(cutoffbound, upperbound); /* SCIPsetFeasCeil() can increase bound by almost 1.0 due to numerics
352  * and very large upperbound value */
353  }
354  else
355  cutoffbound = upperbound;
356 
357  /* update cutoff bound */
358  if( cutoffbound < primal->cutoffbound )
359  {
360  SCIP_CALL( primalSetCutoffbound(primal, blkmem, set, stat, prob, eventqueue, tree, reopt, lp, cutoffbound) );
361  }
362 
363  /* update upper bound in visualization output */
364  if( SCIPtreeGetCurrentDepth(tree) >= 0 )
365  {
366  SCIPvisualUpperbound(stat->visual, set, stat, primal->upperbound);
367  }
368 
369  return SCIP_OKAY;
370 }
371 
372 /** sets upper bound in primal data and in LP solver */
374  SCIP_PRIMAL* primal, /**< primal data */
375  BMS_BLKMEM* blkmem, /**< block memory */
376  SCIP_SET* set, /**< global SCIP settings */
377  SCIP_STAT* stat, /**< problem statistics data */
378  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
379  SCIP_PROB* prob, /**< transformed problem after presolve */
380  SCIP_TREE* tree, /**< branch and bound tree */
381  SCIP_REOPT* reopt, /**< reoptimization data structure */
382  SCIP_LP* lp, /**< current LP data */
383  SCIP_Real upperbound /**< new upper bound */
384  )
385 {
386  assert(primal != NULL);
387  assert(upperbound <= SCIPsetInfinity(set));
388 
389  if( upperbound < primal->upperbound )
390  {
391  /* update primal bound */
392  SCIP_CALL( primalSetUpperbound(primal, blkmem, set, stat, eventqueue, prob, tree, reopt, lp, upperbound) );
393  }
394  else if( upperbound > primal->upperbound )
395  {
396  SCIPerrorMessage("invalid increase in upper bound\n");
397  return SCIP_INVALIDDATA;
398  }
399 
400  return SCIP_OKAY;
401 }
402 
403 /** updates upper bound and cutoff bound in primal data after a tightening of the problem's objective limit */
405  SCIP_PRIMAL* primal, /**< primal data */
406  BMS_BLKMEM* blkmem, /**< block memory */
407  SCIP_SET* set, /**< global SCIP settings */
408  SCIP_STAT* stat, /**< problem statistics data */
409  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
410  SCIP_PROB* transprob, /**< transformed problem data */
411  SCIP_PROB* origprob, /**< original problem data */
412  SCIP_TREE* tree, /**< branch and bound tree */
413  SCIP_REOPT* reopt, /**< reoptimization data structure */
414  SCIP_LP* lp /**< current LP data */
415  )
416 {
417  SCIP_Real objlimit;
418  SCIP_Real inf;
419 
420  assert(primal != NULL);
421 
422  /* get internal objective limit */
423  objlimit = SCIPprobInternObjval(transprob, origprob, set, SCIPprobGetObjlim(origprob, set));
424  inf = SCIPsetInfinity(set);
425  objlimit = MIN(objlimit, inf);
426 
427  /* update the cutoff bound */
428  if( objlimit < primal->cutoffbound )
429  {
430  SCIP_CALL( primalSetCutoffbound(primal, blkmem, set, stat, transprob, eventqueue, tree, reopt, lp, objlimit) );
431  }
432 
433  /* set new upper bound (and decrease cutoff bound, if objective value is always integral) */
434  if( objlimit < primal->upperbound )
435  {
436  SCIP_CALL( primalSetUpperbound(primal, blkmem, set, stat, eventqueue, transprob, tree, reopt, lp, objlimit) );
437  }
438 
439  return SCIP_OKAY;
440 }
441 
442 /** recalculates upper bound and cutoff bound in primal data after a change of the problem's objective offset */
444  SCIP_PRIMAL* primal, /**< primal data */
445  BMS_BLKMEM* blkmem, /**< block memory */
446  SCIP_SET* set, /**< global SCIP settings */
447  SCIP_STAT* stat, /**< problem statistics data */
448  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
449  SCIP_PROB* transprob, /**< tranformed problem data */
450  SCIP_PROB* origprob, /**< original problem data */
451  SCIP_TREE* tree, /**< branch and bound tree */
452  SCIP_REOPT* reopt, /**< reoptimization data structure */
453  SCIP_LP* lp /**< current LP data */
454  )
455 {
456  SCIP_SOL* sol;
457  SCIP_Real upperbound;
458  SCIP_Real objval;
459  SCIP_Real inf;
460  int i;
461  int j;
462 
463  assert(primal != NULL);
464  assert(SCIPsetGetStage(set) <= SCIP_STAGE_PRESOLVED);
465 
466  /* recalculate internal objective limit */
467  upperbound = SCIPprobInternObjval(transprob, origprob, set, SCIPprobGetObjlim(origprob, set));
468  inf = SCIPsetInfinity(set);
469  upperbound = MIN(upperbound, inf);
470 
471  /* resort current primal solutions */
472  for( i = 1; i < primal->nsols; ++i )
473  {
474  sol = primal->sols[i];
475  objval = SCIPsolGetObj(sol, set, transprob, origprob);
476  for( j = i; j > 0 && objval < SCIPsolGetObj(primal->sols[j-1], set, transprob, origprob); --j )
477  primal->sols[j] = primal->sols[j-1];
478  primal->sols[j] = sol;
479  }
480 
481  /* compare objective limit to currently best solution */
482  if( primal->nsols > 0 )
483  {
484  SCIP_Real obj;
485 
486  assert(SCIPsolIsOriginal(primal->sols[0]));
487  obj = SCIPsolGetObj(primal->sols[0], set, transprob, origprob);
488 
489  upperbound = MIN(upperbound, obj);
490  }
491 
492  /* invalidate old upper bound */
493  SCIP_CALL( primalSetUpperbound(primal, blkmem, set, stat, eventqueue, transprob, tree, reopt, lp, SCIPsetInfinity(set)) );
494 
495  /* reset the cutoff bound
496  *
497  * @note we might need to relax the bound since in presolving the objective correction of an
498  * aggregation is still in progress
499  */
500  SCIP_CALL( primalSetCutoffbound(primal, blkmem, set, stat, transprob, eventqueue, tree, reopt, lp, upperbound) );
501 
502  /* set new upper bound (and decrease cutoff bound, if objective value is always integral) */
503  SCIP_CALL( primalSetUpperbound(primal, blkmem, set, stat, eventqueue, transprob, tree, reopt, lp, upperbound) );
504 
505  return SCIP_OKAY;
506 }
507 
508 /** adds additional objective offset in original space to all existing solution (in original space) */
510  SCIP_PRIMAL* primal, /**< primal data */
511  SCIP_SET* set, /**< global SCIP settings */
512  SCIP_Real addval /**< additional objective offset in original space */
513  )
514 {
515  int i;
516 
517  assert(primal != NULL);
518  assert(set != NULL);
519  assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM);
520 
521 #ifndef NDEBUG
522  assert(primal->nsols == 0 || SCIPsolGetOrigin(primal->sols[0]) == SCIP_SOLORIGIN_ORIGINAL);
523 
524  /* check current order of primal solutions */
525  for( i = 1; i < primal->nsols; ++i )
526  {
527  assert(SCIPsolGetOrigin(primal->sols[i]) == SCIP_SOLORIGIN_ORIGINAL);
528  assert(SCIPsetIsLE(set, SCIPsolGetOrigObj(primal->sols[i-1]), SCIPsolGetOrigObj(primal->sols[i])));
529  }
530 #endif
531 
532  /* check current order of primal solutions */
533  for( i = 0; i < primal->nexistingsols; ++i )
534  {
535  assert(primal->existingsols[i] != NULL);
536  SCIPsolOrigAddObjval(primal->existingsols[i], addval);
537  }
538 }
539 
540 /** returns whether the current primal bound is justified with a feasible primal solution; if not, the primal bound
541  * was set from the user as objective limit
542  */
544  SCIP_PRIMAL* primal, /**< primal data */
545  SCIP_SET* set, /**< global SCIP settings */
546  SCIP_PROB* transprob, /**< tranformed problem data */
547  SCIP_PROB* origprob /**< original problem data */
548  )
549 {
550  assert(primal != NULL);
551 
552  return (primal->nsols > 0 && SCIPsetIsEQ(set, primal->upperbound, SCIPsolGetObj(primal->sols[0], set, transprob, origprob)));
553 }
554 
555 /** returns the primal ray thats proves unboundedness */
557  SCIP_PRIMAL* primal /**< primal data */
558  )
559 {
560  assert(primal != NULL);
561 
562  return primal->primalray;
563 }
564 
565 /** update the primal ray thats proves unboundedness */
567  SCIP_PRIMAL* primal, /**< primal data */
568  SCIP_SET* set, /**< global SCIP settings */
569  SCIP_STAT* stat, /**< dynamic SCIP statistics */
570  SCIP_SOL* primalray, /**< the new primal ray */
571  BMS_BLKMEM* blkmem /**< block memory */
572  )
573 {
574  assert(primal != NULL);
575  assert(set != NULL);
576  assert(stat != NULL);
577  assert(primalray != NULL);
578  assert(blkmem != NULL);
579 
580  /* clear previously stored primal ray, if any */
581  if( primal->primalray != NULL )
582  {
583  SCIP_CALL( SCIPsolFree(&primal->primalray, blkmem, primal) );
584  }
585 
586  assert(primal->primalray == NULL);
587 
588  SCIP_CALL( SCIPsolCopy(&primal->primalray, blkmem, set, stat, primal, primalray) );
589 
590  return SCIP_OKAY;
591 }
592 
593 /** adds primal solution to solution storage at given position */
594 static
596  SCIP_PRIMAL* primal, /**< primal data */
597  BMS_BLKMEM* blkmem, /**< block memory */
598  SCIP_SET* set, /**< global SCIP settings */
599  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
600  SCIP_STAT* stat, /**< problem statistics data */
601  SCIP_PROB* origprob, /**< original problem */
602  SCIP_PROB* transprob, /**< transformed problem after presolve */
603  SCIP_TREE* tree, /**< branch and bound tree */
604  SCIP_REOPT* reopt, /**< reoptimization data structure */
605  SCIP_LP* lp, /**< current LP data */
606  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
607  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
608  SCIP_SOL** solptr, /**< pointer to primal CIP solution */
609  int insertpos, /**< position in solution storage to add solution to */
610  SCIP_Bool replace /**< should the solution at insertpos be replaced by the new solution? */
611  )
612 {
613  SCIP_SOL* sol;
614  /* cppcheck-suppress unassignedVariable */
615  SCIP_EVENT event;
616  SCIP_Real obj;
617  int pos;
618 
619  assert(primal != NULL);
620  assert(set != NULL);
621  assert(solptr != NULL);
622  assert(stat != NULL);
623  assert(transprob != NULL);
624  assert(origprob != NULL);
625  assert(0 <= insertpos && insertpos < set->limit_maxsol);
626  assert(tree == NULL || !SCIPtreeInRepropagation(tree));
627 
628  sol = *solptr;
629  assert(sol != NULL);
630  obj = SCIPsolGetObj(sol, set, transprob, origprob);
631 
632  SCIPsetDebugMsg(set, "insert primal solution %p with obj %g at position %d (replace=%u):\n",
633  (void*)sol, obj, insertpos, replace);
634 
635  SCIPdebug( SCIP_CALL( SCIPsolPrint(sol, set, messagehdlr, stat, transprob, NULL, NULL, FALSE, FALSE) ) );
636 
637 #if 0 /* this is not a valid debug check, but can be used to track down numerical troubles */
638 #ifndef NDEBUG
639  /* check solution again completely
640  * it fail for different reasons:
641  * - in the LP solver, the feasibility tolerance is a relative measure against the row's norm
642  * - in SCIP, the feasibility tolerance is a relative measure against the row's rhs/lhs
643  * - the rhs/lhs of a row might drastically change during presolving when variables are fixed or (multi-)aggregated
644  */
645  if( !SCIPsolIsOriginal(sol) )
646  {
647  SCIP_Bool feasible;
648 
649  SCIP_CALL( SCIPsolCheck(sol, set, messagehdlr, blkmem, stat, transprob, TRUE, TRUE, TRUE, TRUE, &feasible) );
650 
651  if( !feasible )
652  {
653  SCIPerrorMessage("infeasible solution accepted:\n");
654  SCIP_CALL( SCIPsolPrint(sol, set, messagehdlr, stat, origprob, transprob, NULL, FALSE, FALSE) );
655  }
656  assert(feasible);
657  }
658 #endif
659 #endif
660 
661  /* completely fill the solution's own value array to unlink it from the LP or pseudo solution */
662  SCIP_CALL( SCIPsolUnlink(sol, set, transprob) );
663 
664  /* allocate memory for solution storage */
665  SCIP_CALL( ensureSolsSize(primal, set, set->limit_maxsol) );
666 
667  /* if set->limit_maxsol was decreased in the meantime, free all solutions exceeding the limit */
668  for( pos = set->limit_maxsol; pos < primal->nsols; ++pos )
669  {
670  SCIP_CALL( SCIPsolFree(&primal->sols[pos], blkmem, primal) );
671  }
672  primal->nsols = MIN(primal->nsols, set->limit_maxsol);
673 
674  /* if the solution should replace an existing one, free this solution, otherwise,
675  * free the last solution if the solution storage is full;
676  */
677  if( replace )
678  {
679  SCIP_CALL( SCIPsolTransform(primal->sols[insertpos], solptr, blkmem, set, primal) );
680  sol = primal->sols[insertpos];
681  }
682  else
683  {
684  if( primal->nsols == set->limit_maxsol )
685  {
686  SCIP_CALL( SCIPsolFree(&primal->sols[set->limit_maxsol - 1], blkmem, primal) );
687  }
688  else
689  {
690  primal->nsols = primal->nsols + 1;
691  assert(primal->nsols <= set->limit_maxsol);
692  }
693 
694  /* move all solutions with worse objective value than the new solution */
695  for( pos = primal->nsols-1; pos > insertpos; --pos )
696  primal->sols[pos] = primal->sols[pos-1];
697 
698  /* insert solution at correct position */
699  assert(0 <= insertpos && insertpos < primal->nsols);
700  primal->sols[insertpos] = sol;
701  primal->nsolsfound++;
702 
703  /* check if solution is better than objective limit */
704  if( SCIPsetIsFeasLE(set, obj, SCIPprobInternObjval(transprob, origprob, set, SCIPprobGetObjlim(origprob, set))) )
705  primal->nlimsolsfound++;
706  }
707 
708  /* if its the first primal solution, store the relevant statistics */
709  if( primal->nsolsfound == 1 )
710  {
711  SCIP_Real primalsolval;
712 
714  stat->nrunsbeforefirst = SCIPsolGetRunnum(sol);
715  stat->firstprimalheur = SCIPsolGetHeur(sol);
716  stat->firstprimaltime = SCIPsolGetTime(sol);
717  stat->firstprimaldepth = SCIPsolGetDepth(sol);
718 
719  primalsolval = obj;
720  stat->firstprimalbound = SCIPprobExternObjval(transprob, origprob, set, primalsolval);
721 
722  SCIPsetDebugMsg(set, "First Solution stored in problem specific statistics.\n");
723  SCIPsetDebugMsg(set, "-> %" SCIP_LONGINT_FORMAT " nodes, %d runs, %.2g time, %d depth, %.15g objective\n", stat->nnodesbeforefirst, stat->nrunsbeforefirst,
725  }
726 
727  SCIPsetDebugMsg(set, " -> stored at position %d of %d solutions, found %" SCIP_LONGINT_FORMAT " solutions\n",
728  insertpos, primal->nsols, primal->nsolsfound);
729 
730  /* update the solution value sums in variables */
731  if( !SCIPsolIsOriginal(sol) )
732  {
733  SCIPsolUpdateVarsum(sol, set, stat, transprob,
734  (SCIP_Real)(primal->nsols - insertpos)/(SCIP_Real)(2.0*primal->nsols - 1.0));
735  }
736 
737  /* change color of node in visualization output */
738  SCIPvisualFoundSolution(stat->visual, set, stat, SCIPtreeGetCurrentNode(tree), insertpos == 0 ? TRUE : FALSE, sol);
739 
740  /* check, if the global upper bound has to be updated */
741  if( obj < primal->cutoffbound && insertpos == 0 )
742  {
743  /* update the upper bound */
744  SCIP_CALL( SCIPprimalSetUpperbound(primal, blkmem, set, stat, eventqueue, transprob, tree, reopt, lp, obj) );
745 
746  /* issue BESTSOLFOUND event */
748  primal->nbestsolsfound++;
749  stat->bestsolnode = stat->nnodes;
750  }
751  else
752  {
753  /* issue POORSOLFOUND event */
755  }
756  SCIP_CALL( SCIPeventChgSol(&event, sol) );
757  SCIP_CALL( SCIPeventProcess(&event, set, NULL, NULL, NULL, eventfilter) );
758 
759  /* display node information line */
760  if( insertpos == 0 && !replace && set->stage >= SCIP_STAGE_SOLVING )
761  {
762  SCIP_CALL( SCIPdispPrintLine(set, messagehdlr, stat, NULL, TRUE, TRUE) );
763  }
764 
765  /* if an original solution was added during solving, try to transfer it to the transformed space */
766  if( SCIPsolIsOriginal(sol) && SCIPsetGetStage(set) == SCIP_STAGE_SOLVING && set->misc_transorigsols )
767  {
768  SCIP_Bool added;
769 
770  SCIP_CALL( SCIPprimalTransformSol(primal, sol, blkmem, set, messagehdlr, stat, origprob, transprob, tree, reopt,
771  lp, eventqueue, eventfilter, NULL, NULL, 0, &added) );
772 
773  SCIPsetDebugMsg(set, "original solution %p was successfully transferred to the transformed problem space\n",
774  (void*)sol);
775 
776  }
777 
778  return SCIP_OKAY;
779 }
780 
781 /** adds primal solution to solution storage at given position */
782 static
784  SCIP_PRIMAL* primal, /**< primal data */
785  BMS_BLKMEM* blkmem, /**< block memory */
786  SCIP_SET* set, /**< global SCIP settings */
787  SCIP_PROB* prob, /**< original problem data */
788  SCIP_SOL* sol, /**< primal CIP solution */
789  int insertpos /**< position in solution storage to add solution to */
790  )
791 {
792  int pos;
793 
794  assert(primal != NULL);
795  assert(set != NULL);
796  assert(prob != NULL);
797  assert(sol != NULL);
798  assert(0 <= insertpos && insertpos < set->limit_maxorigsol);
799  assert(!set->reopt_enable);
800 
801  SCIPsetDebugMsg(set, "insert primal solution candidate %p with obj %g at position %d:\n", (void*)sol, SCIPsolGetOrigObj(sol), insertpos);
802 
803  /* allocate memory for solution storage */
804  SCIP_CALL( ensureSolsSize(primal, set, set->limit_maxorigsol) );
805 
806  /* if the solution storage is full, free the last solution(s)
807  * more than one solution may be freed, if set->limit_maxorigsol was decreased in the meantime
808  */
809  for( pos = set->limit_maxorigsol-1; pos < primal->nsols; ++pos )
810  {
811  SCIP_CALL( SCIPsolFree(&primal->sols[pos], blkmem, primal) );
812  }
813 
814  /* insert solution at correct position */
815  primal->nsols = MIN(primal->nsols+1, set->limit_maxorigsol);
816  for( pos = primal->nsols-1; pos > insertpos; --pos )
817  primal->sols[pos] = primal->sols[pos-1];
818 
819  assert(0 <= insertpos && insertpos < primal->nsols);
820  primal->sols[insertpos] = sol;
821  primal->nsolsfound++;
822 
823  /* check if solution is better than objective limit */
824  if( SCIPsetIsFeasLE(set, SCIPsolGetOrigObj(sol), SCIPprobGetObjlim(prob, set)) )
825  primal->nlimsolsfound++;
826 
827  SCIPsetDebugMsg(set, " -> stored at position %d of %d solutions, found %" SCIP_LONGINT_FORMAT " solutions\n",
828  insertpos, primal->nsols, primal->nsolsfound);
829 
830  return SCIP_OKAY;
831 }
832 
833 /** adds primal solution to solution storage */
834 static
836  SCIP_PRIMAL* primal, /**< primal data */
837  BMS_BLKMEM* blkmem, /**< block memory */
838  SCIP_SET* set, /**< global SCIP settings */
839  SCIP_PROB* prob, /**< original problem data */
840  SCIP_SOL* sol /**< primal CIP solution */
841  )
842 { /*lint --e{715}*/
843  assert(primal != NULL);
844  assert(set != NULL);
845  assert(prob != NULL);
846  assert(sol != NULL);
847 
848  if( primal->npartialsols >= set->limit_maxorigsol )
849  {
850  SCIPerrorMessage("Cannot add partial solution to storage: limit reached.\n");
851  return SCIP_INVALIDCALL;
852  }
853 
854  SCIPsetDebugMsg(set, "insert partial solution candidate %p:\n", (void*)sol);
855 
856  /* allocate memory for solution storage */
857  SCIP_CALL( ensurePartialsolsSize(primal, set, primal->npartialsols+1) );
858 
859  primal->partialsols[primal->npartialsols] = sol;
860  ++primal->npartialsols;
861 
862  return SCIP_OKAY;
863 }
864 
865 /** uses binary search to find position in solution storage */
866 static
868  SCIP_PRIMAL* primal, /**< primal data */
869  SCIP_SET* set, /**< global SCIP settings */
870  SCIP_PROB* transprob, /**< tranformed problem data */
871  SCIP_PROB* origprob, /**< original problem data */
872  SCIP_SOL* sol /**< primal solution to search position for */
873  )
874 {
875  SCIP_SOL** sols;
876  SCIP_Real obj;
877  SCIP_Real middleobj;
878  int left;
879  int right;
880  int middle;
881 
882  assert(primal != NULL);
883 
884  obj = SCIPsolGetObj(sol, set, transprob, origprob);
885  sols = primal->sols;
886 
887  left = -1;
888  right = primal->nsols;
889  while( left < right-1 )
890  {
891  middle = (left+right)/2;
892  assert(left < middle && middle < right);
893  assert(0 <= middle && middle < primal->nsols);
894 
895  middleobj = SCIPsolGetObj(sols[middle], set, transprob, origprob);
896 
897  if( obj < middleobj )
898  right = middle;
899  else
900  left = middle;
901  }
902  assert(left == right-1);
903 
904  /* prefer solutions that live in the transformed space */
905  if( !SCIPsolIsOriginal(sol) )
906  {
907  while( right > 0 && SCIPsolIsOriginal(sols[right-1])
908  && SCIPsetIsEQ(set, SCIPsolGetObj(sols[right-1], set, transprob, origprob), obj) )
909  --right;
910  }
911 
912  return right;
913 }
914 
915 /** uses binary search to find position in solution storage */
916 static
918  SCIP_PRIMAL* primal, /**< primal data */
919  SCIP_SOL* sol /**< primal solution to search position for */
920  )
921 {
922  SCIP_Real obj;
923  SCIP_Real middleobj;
924  int left;
925  int right;
926  int middle;
927 
928  assert(primal != NULL);
929 
930  obj = SCIPsolGetOrigObj(sol);
931 
932  left = -1;
933  right = primal->nsols;
934  while( left < right-1 )
935  {
936  middle = (left+right)/2;
937  assert(left < middle && middle < right);
938  assert(0 <= middle && middle < primal->nsols);
939  middleobj = SCIPsolGetOrigObj(primal->sols[middle]);
940  if( obj < middleobj )
941  right = middle;
942  else
943  left = middle;
944  }
945  assert(left == right-1);
946 
947  return right;
948 }
949 
950 /** returns whether the given primal solution is already existent in the solution storage */
951 static
953  SCIP_PRIMAL* primal, /**< primal data */
954  SCIP_SET* set, /**< global SCIP settings */
955  SCIP_STAT* stat, /**< problem statistics data */
956  SCIP_PROB* origprob, /**< original problem */
957  SCIP_PROB* transprob, /**< transformed problem after presolve */
958  SCIP_SOL* sol, /**< primal solution to search position for */
959  int* insertpos, /**< pointer to insertion position returned by primalSearchSolPos(); the
960  * position might be changed if an existing solution should be replaced */
961  SCIP_Bool* replace /**< pointer to store whether the solution at insertpos should be replaced */
962  )
963 {
964  SCIP_Real obj;
965  int i;
966 
967  assert(primal != NULL);
968  assert(insertpos != NULL);
969  assert(replace != NULL);
970  assert(0 <= (*insertpos) && (*insertpos) <= primal->nsols);
971 
972  obj = SCIPsolGetObj(sol, set, transprob, origprob);
973 
974  assert(primal->sols != NULL || primal->nsols == 0);
975  assert(primal->sols != NULL || (*insertpos) == 0);
976 
977  /* search in the better solutions */
978  for( i = (*insertpos)-1; i >= 0; --i )
979  {
980  SCIP_Real solobj;
981 
982  solobj = SCIPsolGetObj(primal->sols[i], set, transprob, origprob);
983 
984  /* due to transferring the objective value of transformed solutions to the original space, small numerical errors might occur
985  * which can lead to SCIPsetIsLE() failing in case of high absolute numbers
986  */
987  assert(SCIPsetIsLE(set, solobj, obj) || (REALABS(obj) > 1e+13 * SCIPsetEpsilon(set) && SCIPsetIsFeasLE(set, solobj, obj)));
988 
989  if( SCIPsetIsLT(set, solobj, obj) )
990  break;
991 
992  if( SCIPsolsAreEqual(sol, primal->sols[i], set, stat, origprob, transprob) )
993  {
994  if( SCIPsolIsOriginal(primal->sols[i]) && !SCIPsolIsOriginal(sol) )
995  {
996  (*insertpos) = i;
997  (*replace) = TRUE;
998  }
999  return TRUE;
1000  }
1001  }
1002 
1003  /* search in the worse solutions */
1004  for( i = (*insertpos); i < primal->nsols; ++i )
1005  {
1006  SCIP_Real solobj;
1007 
1008  solobj = SCIPsolGetObj(primal->sols[i], set, transprob, origprob);
1009 
1010  /* due to transferring the objective value of transformed solutions to the original space, small numerical errors might occur
1011  * which can lead to SCIPsetIsLE() failing in case of high absolute numbers
1012  */
1013  assert( SCIPsetIsGE(set, solobj, obj) || (REALABS(obj) > 1e+13 * SCIPsetEpsilon(set) && SCIPsetIsFeasGE(set, solobj, obj)));
1014 
1015  if( SCIPsetIsGT(set, solobj, obj) )
1016  break;
1017 
1018  if( SCIPsolsAreEqual(sol, primal->sols[i], set, stat, origprob, transprob) )
1019  {
1020  if( SCIPsolIsOriginal(primal->sols[i]) && !SCIPsolIsOriginal(sol) )
1021  {
1022  (*insertpos) = i;
1023  (*replace) = TRUE;
1024  }
1025  return TRUE;
1026  }
1027  }
1028 
1029  return FALSE;
1030 }
1031 
1032 /** returns whether the given primal solution is already existent in the original solution candidate storage */
1033 static
1035  SCIP_PRIMAL* primal, /**< primal data */
1036  SCIP_SET* set, /**< global SCIP settings */
1037  SCIP_STAT* stat, /**< problem statistics data */
1038  SCIP_PROB* prob, /**< original problem */
1039  SCIP_SOL* sol, /**< primal solution to search position for */
1040  int insertpos /**< insertion position returned by primalSearchOrigSolPos() */
1041  )
1042 {
1043  SCIP_Real obj;
1044  int i;
1045 
1046  assert(primal != NULL);
1047  assert(0 <= insertpos && insertpos <= primal->nsols);
1048 
1049  obj = SCIPsolGetOrigObj(sol);
1050 
1051  /* search in the better solutions */
1052  for( i = insertpos-1; i >= 0; --i )
1053  {
1054  SCIP_Real solobj;
1055 
1056  solobj = SCIPsolGetOrigObj(primal->sols[i]);
1057  assert( SCIPsetIsLE(set, solobj, obj) );
1058 
1059  if( SCIPsetIsLT(set, solobj, obj) )
1060  break;
1061 
1062  if( SCIPsolsAreEqual(sol, primal->sols[i], set, stat, prob, NULL) )
1063  return TRUE;
1064  }
1065 
1066  /* search in the worse solutions */
1067  for( i = insertpos; i < primal->nsols; ++i )
1068  {
1069  SCIP_Real solobj;
1070 
1071  solobj = SCIPsolGetOrigObj(primal->sols[i]);
1072  assert( SCIPsetIsGE(set, solobj, obj) );
1073 
1074  if( SCIPsetIsGT(set, solobj, obj) )
1075  break;
1076 
1077  if( SCIPsolsAreEqual(sol, primal->sols[i], set, stat, prob, NULL) )
1078  return TRUE;
1079  }
1080 
1081  return FALSE;
1082 }
1083 
1084 /** check if we are willing to check the solution for feasibility */
1085 static
1087  SCIP_PRIMAL* primal, /**< primal data */
1088  SCIP_SET* set, /**< global SCIP settings */
1089  SCIP_STAT* stat, /**< problem statistics data */
1090  SCIP_PROB* origprob, /**< original problem */
1091  SCIP_PROB* transprob, /**< transformed problem after presolve */
1092  SCIP_SOL* sol, /**< primal CIP solution */
1093  int* insertpos, /**< pointer to store the insert position of that solution */
1094  SCIP_Bool* replace /**< pointer to store whether the solution at insertpos should be replaced
1095  * (e.g., because it lives in the original space) */
1096  )
1097 {
1098  SCIP_Real obj;
1099 
1100  obj = SCIPsolGetObj(sol, set, transprob, origprob);
1101 
1102  /* check if we are willing to check worse solutions; a solution is better if the objective is smaller than the
1103  * current cutoff bound; solutions with infinite objective value are never accepted
1104  */
1105  if( (!set->misc_improvingsols || obj < primal->cutoffbound) && !SCIPsetIsInfinity(set, obj) )
1106  {
1107  /* find insert position for the solution */
1108  (*insertpos) = primalSearchSolPos(primal, set, transprob, origprob, sol);
1109  (*replace) = FALSE;
1110 
1111  /* the solution should be added, if the insertpos is smaller than the maximum number of solutions to be stored
1112  * and it does not already exist or it does exist, but the existing solution should be replaced by the new one
1113  */
1114  if( (*insertpos) < set->limit_maxsol &&
1115  (!primalExistsSol(primal, set, stat, origprob, transprob, sol, insertpos, replace) || (*replace)) )
1116  return TRUE;
1117  }
1118 
1119  return FALSE;
1120 }
1121 
1122 /** check if we are willing to store the solution candidate for later checking */
1123 static
1125  SCIP_PRIMAL* primal, /**< primal data */
1126  SCIP_SET* set, /**< global SCIP settings */
1127  SCIP_STAT* stat, /**< problem statistics data */
1128  SCIP_PROB* origprob, /**< original problem */
1129  SCIP_SOL* sol, /**< primal CIP solution */
1130  int* insertpos /**< pointer to store the insert position of that solution */
1131  )
1132 {
1133  assert(SCIPsolIsOriginal(sol));
1134 
1135  /* find insert position for the solution */
1136  (*insertpos) = primalSearchOrigSolPos(primal, sol);
1137 
1138  if( !set->reopt_enable && (*insertpos) < set->limit_maxorigsol && !primalExistsOrigSol(primal, set, stat, origprob, sol, *insertpos) )
1139  return TRUE;
1140 
1141  return FALSE;
1142 }
1143 
1144 /** adds primal solution to solution storage by copying it */
1146  SCIP_PRIMAL* primal, /**< primal data */
1147  BMS_BLKMEM* blkmem, /**< block memory */
1148  SCIP_SET* set, /**< global SCIP settings */
1149  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1150  SCIP_STAT* stat, /**< problem statistics data */
1151  SCIP_PROB* origprob, /**< original problem */
1152  SCIP_PROB* transprob, /**< transformed problem after presolve */
1153  SCIP_TREE* tree, /**< branch and bound tree */
1154  SCIP_REOPT* reopt, /**< reoptimization data structure */
1155  SCIP_LP* lp, /**< current LP data */
1156  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1157  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1158  SCIP_SOL* sol, /**< primal CIP solution */
1159  SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
1160  )
1161 {
1162  SCIP_Bool replace;
1163  int insertpos;
1164 
1165  assert(primal != NULL);
1166  assert(blkmem != NULL);
1167  assert(set != NULL);
1168  assert(messagehdlr != NULL);
1169  assert(stat != NULL);
1170  assert(origprob != NULL);
1171  assert(transprob != NULL);
1172  assert(tree != NULL);
1173  assert(lp != NULL);
1174  assert(eventqueue != NULL);
1175  assert(eventfilter != NULL);
1176  assert(sol != NULL);
1177  assert(stored != NULL);
1178 
1179  insertpos = -1;
1180 
1181  assert(!SCIPsolIsPartial(sol));
1182 
1183  if( solOfInterest(primal, set, stat, origprob, transprob, sol, &insertpos, &replace) )
1184  {
1185  SCIP_SOL* solcopy;
1186 #ifdef SCIP_MORE_DEBUG
1187  int i;
1188 #endif
1189 
1190  assert(insertpos >= 0 && insertpos < set->limit_maxsol);
1191 
1192  /* create a copy of the solution */
1193  SCIP_CALL( SCIPsolCopy(&solcopy, blkmem, set, stat, primal, sol) );
1194 
1195  /* insert copied solution into solution storage */
1196  SCIP_CALL( primalAddSol(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1197  tree, reopt, lp, eventqueue, eventfilter, &solcopy, insertpos, replace) );
1198 #ifdef SCIP_MORE_DEBUG
1199  for( i = 0; i < primal->nsols - 1; ++i )
1200  {
1201  assert(SCIPsetIsLE(set, SCIPsolGetObj(primal->sols[i], set, transprob, origprob), SCIPsolGetObj(primal->sols[i+1], set, transprob, origprob)));
1202  }
1203 #endif
1204  *stored = TRUE;
1205  }
1206  else
1207  *stored = FALSE;
1208 
1209  return SCIP_OKAY;
1210 }
1211 
1212 /** adds primal solution to solution storage, frees the solution afterwards */
1214  SCIP_PRIMAL* primal, /**< primal data */
1215  BMS_BLKMEM* blkmem, /**< block memory */
1216  SCIP_SET* set, /**< global SCIP settings */
1217  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1218  SCIP_STAT* stat, /**< problem statistics data */
1219  SCIP_PROB* origprob, /**< original problem */
1220  SCIP_PROB* transprob, /**< transformed problem after presolve */
1221  SCIP_TREE* tree, /**< branch and bound tree */
1222  SCIP_REOPT* reopt, /**< reoptimization data structure */
1223  SCIP_LP* lp, /**< current LP data */
1224  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1225  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1226  SCIP_SOL** sol, /**< pointer to primal CIP solution; is cleared in function call */
1227  SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
1228  )
1229 {
1230  SCIP_Bool replace;
1231  int insertpos;
1232 
1233  assert(primal != NULL);
1234  assert(transprob != NULL);
1235  assert(origprob != NULL);
1236  assert(sol != NULL);
1237  assert(*sol != NULL);
1238  assert(stored != NULL);
1239 
1240  insertpos = -1;
1241 
1242  if( solOfInterest(primal, set, stat, origprob, transprob, *sol, &insertpos, &replace) )
1243  {
1244  assert(insertpos >= 0 && insertpos < set->limit_maxsol);
1245 
1246  /* insert solution into solution storage */
1247  SCIP_CALL( primalAddSol(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1248  tree, reopt, lp, eventqueue, eventfilter, sol, insertpos, replace) );
1249 
1250  /* clear the pointer, such that the user cannot access the solution anymore */
1251  *sol = NULL;
1252 
1253  *stored = TRUE;
1254  }
1255  else
1256  {
1257  /* the solution is too bad -> free it immediately */
1258  SCIP_CALL( SCIPsolFree(sol, blkmem, primal) );
1259 
1260  *stored = FALSE;
1261  }
1262  assert(*sol == NULL);
1263 
1264  return SCIP_OKAY;
1265 }
1266 
1267 /** adds primal solution to solution candidate storage of original problem space */
1269  SCIP_PRIMAL* primal, /**< primal data */
1270  BMS_BLKMEM* blkmem, /**< block memory */
1271  SCIP_SET* set, /**< global SCIP settings */
1272  SCIP_STAT* stat, /**< problem statistics data */
1273  SCIP_PROB* prob, /**< original problem data */
1274  SCIP_SOL* sol, /**< primal CIP solution; is cleared in function call */
1275  SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
1276  )
1277 {
1278  int insertpos;
1279 
1280  assert(primal != NULL);
1281  assert(blkmem != NULL);
1282  assert(set != NULL);
1283  assert(stat != NULL);
1284  assert(sol != NULL);
1285  assert(SCIPsolIsOriginal(sol));
1286  assert(stored != NULL);
1287 
1288  insertpos = -1;
1289 
1290  if( SCIPsolIsPartial(sol) )
1291  {
1292  SCIP_SOL* solcopy;
1293 
1294  /* create a copy of the solution */
1295  SCIP_CALL( SCIPsolCopy(&solcopy, blkmem, set, stat, primal, sol) );
1296 
1297  SCIP_CALL( primalAddOrigPartialSol(primal, blkmem, set, prob, solcopy) );
1298 
1299  *stored = TRUE;
1300  }
1301  else if( origsolOfInterest(primal, set, stat, prob, sol, &insertpos) )
1302  {
1303  SCIP_SOL* solcopy;
1304 
1305  assert(insertpos >= 0 && insertpos < set->limit_maxorigsol);
1306  assert(!set->reopt_enable);
1307 
1308  /* create a copy of the solution */
1309  SCIP_CALL( SCIPsolCopy(&solcopy, blkmem, set, stat, primal, sol) );
1310 
1311  /* insert solution into solution storage */
1312  SCIP_CALL( primalAddOrigSol(primal, blkmem, set, prob, solcopy, insertpos) );
1313 
1314  *stored = TRUE;
1315  }
1316  else
1317  *stored = FALSE;
1318 
1319  return SCIP_OKAY;
1320 }
1321 
1322 /** adds primal solution to solution candidate storage of original problem space, frees the solution afterwards */
1324  SCIP_PRIMAL* primal, /**< primal data */
1325  BMS_BLKMEM* blkmem, /**< block memory */
1326  SCIP_SET* set, /**< global SCIP settings */
1327  SCIP_STAT* stat, /**< problem statistics data */
1328  SCIP_PROB* prob, /**< original problem data */
1329  SCIP_SOL** sol, /**< pointer to primal CIP solution; is cleared in function call */
1330  SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
1331  )
1332 {
1333  int insertpos;
1334 
1335  assert(primal != NULL);
1336  assert(sol != NULL);
1337  assert(*sol != NULL);
1338  assert(SCIPsolIsOriginal(*sol));
1339  assert(stored != NULL);
1340 
1341  insertpos = -1;
1342 
1343  if( SCIPsolIsPartial(*sol) )
1344  {
1345  /* insert solution into solution storage */
1346  SCIP_CALL( primalAddOrigPartialSol(primal, blkmem, set, prob, *sol) );
1347 
1348  /* clear the pointer, such that the user cannot access the solution anymore */
1349  *sol = NULL;
1350 
1351  *stored = TRUE;
1352  }
1353  else if( origsolOfInterest(primal, set, stat, prob, *sol, &insertpos) )
1354  {
1355  assert(insertpos >= 0 && insertpos < set->limit_maxorigsol);
1356  assert(!set->reopt_enable);
1357 
1358  /* insert solution into solution storage */
1359  SCIP_CALL( primalAddOrigSol(primal, blkmem, set, prob, *sol, insertpos) );
1360 
1361  /* clear the pointer, such that the user cannot access the solution anymore */
1362  *sol = NULL;
1363 
1364  *stored = TRUE;
1365  }
1366  else
1367  {
1368  /* the solution is too bad -> free it immediately */
1369  SCIP_CALL( SCIPsolFree(sol, blkmem, primal) );
1370 
1371  *stored = FALSE;
1372  }
1373  assert(*sol == NULL);
1374 
1375  return SCIP_OKAY;
1376 }
1377 
1378 /** links temporary solution of primal data to current solution */
1379 static
1381  SCIP_PRIMAL* primal, /**< primal data */
1382  BMS_BLKMEM* blkmem, /**< block memory */
1383  SCIP_SET* set, /**< global SCIP settings */
1384  SCIP_STAT* stat, /**< problem statistics data */
1385  SCIP_PROB* prob, /**< transformed problem data */
1386  SCIP_TREE* tree, /**< branch and bound tree */
1387  SCIP_LP* lp, /**< current LP data */
1388  SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
1389  )
1390 {
1391  assert(primal != NULL);
1392 
1393  if( primal->currentsol == NULL )
1394  {
1395  SCIP_CALL( SCIPsolCreateCurrentSol(&primal->currentsol, blkmem, set, stat, prob, primal, tree, lp, heur) );
1396  }
1397  else
1398  {
1399  SCIP_CALL( SCIPsolLinkCurrentSol(primal->currentsol, set, stat, prob, tree, lp) );
1400  SCIPsolSetHeur(primal->currentsol, heur);
1401  }
1402 
1403  return SCIP_OKAY;
1404 }
1405 
1406 /** adds current LP/pseudo solution to solution storage */
1408  SCIP_PRIMAL* primal, /**< primal data */
1409  BMS_BLKMEM* blkmem, /**< block memory */
1410  SCIP_SET* set, /**< global SCIP settings */
1411  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1412  SCIP_STAT* stat, /**< problem statistics data */
1413  SCIP_PROB* origprob, /**< original problem */
1414  SCIP_PROB* transprob, /**< transformed problem after presolve */
1415  SCIP_TREE* tree, /**< branch and bound tree */
1416  SCIP_REOPT* reopt, /**< reoptimization data structure */
1417  SCIP_LP* lp, /**< current LP data */
1418  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1419  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1420  SCIP_HEUR* heur, /**< heuristic that found the solution (or NULL if it's from the tree) */
1421  SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
1422  )
1423 {
1424  assert(primal != NULL);
1425 
1426  /* link temporary solution to current solution */
1427  SCIP_CALL( primalLinkCurrentSol(primal, blkmem, set, stat, transprob, tree, lp, heur) );
1428 
1429  /* add solution to solution storage */
1430  SCIP_CALL( SCIPprimalAddSol(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1431  tree, reopt, lp, eventqueue, eventfilter, primal->currentsol, stored) );
1432 
1433  return SCIP_OKAY;
1434 }
1435 
1436 /** checks primal solution; if feasible, adds it to storage by copying it */
1438  SCIP_PRIMAL* primal, /**< primal data */
1439  BMS_BLKMEM* blkmem, /**< block memory */
1440  SCIP_SET* set, /**< global SCIP settings */
1441  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1442  SCIP_STAT* stat, /**< problem statistics data */
1443  SCIP_PROB* origprob, /**< original problem */
1444  SCIP_PROB* transprob, /**< transformed problem after presolve */
1445  SCIP_TREE* tree, /**< branch and bound tree */
1446  SCIP_REOPT* reopt, /**< reoptimization data structure */
1447  SCIP_LP* lp, /**< current LP data */
1448  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1449  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1450  SCIP_SOL* sol, /**< primal CIP solution */
1451  SCIP_Bool printreason, /**< Should all reasons of violations be printed? */
1452  SCIP_Bool completely, /**< Should all violations be checked? */
1453  SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
1454  SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
1455  SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
1456  SCIP_Bool* stored /**< stores whether given solution was feasible and good enough to keep */
1457  )
1458 {
1459  SCIP_Bool feasible;
1460  SCIP_Bool replace;
1461  int insertpos;
1462 
1463  assert(primal != NULL);
1464  assert(set != NULL);
1465  assert(transprob != NULL);
1466  assert(origprob != NULL);
1467  assert(tree != NULL);
1468  assert(sol != NULL);
1469  assert(stored != NULL);
1470 
1471  /* if we want to solve exactly, the constraint handlers cannot rely on the LP's feasibility */
1472  checklprows = checklprows || set->misc_exactsolve;
1473 
1474  insertpos = -1;
1475 
1476  if( solOfInterest(primal, set, stat, origprob, transprob, sol, &insertpos, &replace) )
1477  {
1478  /* check solution for feasibility */
1479  SCIP_CALL( SCIPsolCheck(sol, set, messagehdlr, blkmem, stat, transprob, printreason, completely, checkbounds,
1480  checkintegrality, checklprows, &feasible) );
1481  }
1482  else
1483  feasible = FALSE;
1484 
1485  if( feasible )
1486  {
1487  SCIP_SOL* solcopy;
1488 
1489  assert(insertpos >= 0 && insertpos < set->limit_maxsol);
1490 
1491  /* create a copy of the solution */
1492  SCIP_CALL( SCIPsolCopy(&solcopy, blkmem, set, stat, primal, sol) );
1493 
1494  /* insert copied solution into solution storage */
1495  SCIP_CALL( primalAddSol(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1496  tree, reopt, lp, eventqueue, eventfilter, &solcopy, insertpos, replace) );
1497 
1498  *stored = TRUE;
1499  }
1500  else
1501  *stored = FALSE;
1502 
1503  return SCIP_OKAY;
1504 }
1505 
1506 /** checks primal solution; if feasible, adds it to storage; solution is freed afterwards */
1508  SCIP_PRIMAL* primal, /**< primal data */
1509  BMS_BLKMEM* blkmem, /**< block memory */
1510  SCIP_SET* set, /**< global SCIP settings */
1511  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1512  SCIP_STAT* stat, /**< problem statistics data */
1513  SCIP_PROB* origprob, /**< original problem */
1514  SCIP_PROB* transprob, /**< transformed problem after presolve */
1515  SCIP_TREE* tree, /**< branch and bound tree */
1516  SCIP_REOPT* reopt, /**< reoptimization data structure */
1517  SCIP_LP* lp, /**< current LP data */
1518  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1519  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1520  SCIP_SOL** sol, /**< pointer to primal CIP solution; is cleared in function call */
1521  SCIP_Bool printreason, /**< Should all the reasons of violations be printed? */
1522  SCIP_Bool completely, /**< Should all violations be checked? */
1523  SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
1524  SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
1525  SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
1526  SCIP_Bool* stored /**< stores whether solution was feasible and good enough to keep */
1527  )
1528 {
1529  SCIP_Bool feasible;
1530  SCIP_Bool replace;
1531  int insertpos;
1532 
1533  assert(primal != NULL);
1534  assert(transprob != NULL);
1535  assert(origprob != NULL);
1536  assert(tree != NULL);
1537  assert(sol != NULL);
1538  assert(*sol != NULL);
1539  assert(stored != NULL);
1540 
1541  *stored = FALSE;
1542 
1543  /* if we want to solve exactly, the constraint handlers cannot rely on the LP's feasibility */
1544  checklprows = checklprows || set->misc_exactsolve;
1545 
1546  insertpos = -1;
1547 
1548  if( solOfInterest(primal, set, stat, origprob, transprob, *sol, &insertpos, &replace) )
1549  {
1550  /* check solution for feasibility */
1551  SCIP_CALL( SCIPsolCheck(*sol, set, messagehdlr, blkmem, stat, transprob, printreason, completely, checkbounds,
1552  checkintegrality, checklprows, &feasible) );
1553  }
1554  else
1555  feasible = FALSE;
1556 
1557  if( feasible )
1558  {
1559  assert(insertpos >= 0 && insertpos < set->limit_maxsol);
1560 
1561  /* insert solution into solution storage */
1562  SCIP_CALL( primalAddSol(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1563  tree, reopt, lp, eventqueue, eventfilter, sol, insertpos, replace) );
1564 
1565  /* clear the pointer, such that the user cannot access the solution anymore */
1566  *sol = NULL;
1567  *stored = TRUE;
1568  }
1569  else
1570  {
1571  /* the solution is too bad or infeasible -> free it immediately */
1572  SCIP_CALL( SCIPsolFree(sol, blkmem, primal) );
1573  *stored = FALSE;
1574  }
1575  assert(*sol == NULL);
1576 
1577  return SCIP_OKAY;
1578 }
1579 
1580 /** checks current LP/pseudo solution; if feasible, adds it to storage */
1582  SCIP_PRIMAL* primal, /**< primal data */
1583  BMS_BLKMEM* blkmem, /**< block memory */
1584  SCIP_SET* set, /**< global SCIP settings */
1585  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1586  SCIP_STAT* stat, /**< problem statistics data */
1587  SCIP_PROB* origprob, /**< original problem */
1588  SCIP_PROB* transprob, /**< transformed problem after presolve */
1589  SCIP_TREE* tree, /**< branch and bound tree */
1590  SCIP_REOPT* reopt, /**< reoptimization data structure */
1591  SCIP_LP* lp, /**< current LP data */
1592  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1593  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1594  SCIP_HEUR* heur, /**< heuristic that found the solution (or NULL if it's from the tree) */
1595  SCIP_Bool printreason, /**< Should all reasons of violations be printed? */
1596  SCIP_Bool completely, /**< Should all violations be checked? */
1597  SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
1598  SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
1599  SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
1600  )
1601 {
1602  assert(primal != NULL);
1603 
1604  /* link temporary solution to current solution */
1605  SCIP_CALL( primalLinkCurrentSol(primal, blkmem, set, stat, transprob, tree, lp, heur) );
1606 
1607  /* add solution to solution storage */
1608  SCIP_CALL( SCIPprimalTrySol(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1609  tree, reopt, lp, eventqueue, eventfilter, primal->currentsol,
1610  printreason, completely, FALSE, checkintegrality, checklprows, stored) );
1611 
1612  return SCIP_OKAY;
1613 }
1614 
1615 /** inserts solution into the global array of all existing primal solutions */
1617  SCIP_PRIMAL* primal, /**< primal data */
1618  SCIP_SET* set, /**< global SCIP settings */
1619  SCIP_SOL* sol /**< primal CIP solution */
1620  )
1621 {
1622  assert(primal != NULL);
1623  assert(sol != NULL);
1624  assert(SCIPsolGetPrimalIndex(sol) == -1);
1625 
1626  /* allocate memory for solution storage */
1627  SCIP_CALL( ensureExistingsolsSize(primal, set, primal->nexistingsols+1) );
1628 
1629  /* append solution */
1630  SCIPsolSetPrimalIndex(sol, primal->nexistingsols);
1631  primal->existingsols[primal->nexistingsols] = sol;
1632  primal->nexistingsols++;
1633 
1634  return SCIP_OKAY;
1635 }
1636 
1637 /** removes solution from the global array of all existing primal solutions */
1639  SCIP_PRIMAL* primal, /**< primal data */
1640  SCIP_SOL* sol /**< primal CIP solution */
1641  )
1642 {
1643  int idx;
1644 
1645  assert(primal != NULL);
1646  assert(sol != NULL);
1647 
1648 #ifndef NDEBUG
1649  for( idx = 0; idx < primal->nexistingsols; ++idx )
1650  {
1651  assert(idx == SCIPsolGetPrimalIndex(primal->existingsols[idx]));
1652  }
1653 #endif
1654 
1655  /* remove solution */
1656  idx = SCIPsolGetPrimalIndex(sol);
1657  assert(0 <= idx && idx < primal->nexistingsols);
1658  assert(sol == primal->existingsols[idx]);
1659  if( idx < primal->nexistingsols-1 )
1660  {
1661  primal->existingsols[idx] = primal->existingsols[primal->nexistingsols-1];
1662  SCIPsolSetPrimalIndex(primal->existingsols[idx], idx);
1663  }
1664  primal->nexistingsols--;
1665 }
1666 
1667 /** updates all existing primal solutions after a change in a variable's objective value */
1669  SCIP_PRIMAL* primal, /**< primal data */
1670  SCIP_VAR* var, /**< problem variable */
1671  SCIP_Real oldobj, /**< old objective value */
1672  SCIP_Real newobj /**< new objective value */
1673  )
1674 {
1675  int i;
1676 
1677  assert(primal != NULL);
1678 
1679  for( i = 0; i < primal->nexistingsols; ++i )
1680  {
1681  if( !SCIPsolIsOriginal(primal->existingsols[i]) )
1682  SCIPsolUpdateVarObj(primal->existingsols[i], var, oldobj, newobj);
1683  }
1684 }
1685 
1686 /** retransforms all existing solutions to original problem space
1687  *
1688  * @note as a side effect, the objective value of the solutions can change (numerical errors)
1689  * so we update the objective cutoff value and upper bound accordingly
1690  */
1692  SCIP_PRIMAL* primal, /**< primal data */
1693  BMS_BLKMEM* blkmem, /**< block memory */
1694  SCIP_SET* set, /**< global SCIP settings */
1695  SCIP_STAT* stat, /**< problem statistics data */
1696  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1697  SCIP_PROB* origprob, /**< original problem */
1698  SCIP_PROB* transprob, /**< transformed problem */
1699  SCIP_TREE* tree, /**< branch and bound tree */
1700  SCIP_REOPT* reopt, /**< reoptimization data structure */
1701  SCIP_LP* lp /**< current LP data */
1702  )
1703 {
1704  SCIP_Bool hasinfval;
1705  int i;
1706 
1707  assert(primal != NULL);
1708 
1709  for( i = 0; i < primal->nsols; ++i )
1710  {
1711  if( SCIPsolGetOrigin(primal->sols[i]) == SCIP_SOLORIGIN_ZERO )
1712  {
1713  SCIP_CALL( SCIPsolRetransform(primal->sols[i], set, stat, origprob, transprob, &hasinfval) );
1714  }
1715  }
1716 
1717  /* check if the global upper bound has to be updated
1718  * @todo we do not inform anybody about this change; if this leads to some
1719  * problem, a possible solution is to issue a BESTSOLFOUND event
1720  */
1721  if( primal->nsols > 0 )
1722  {
1723  SCIP_Real obj;
1724 
1725  obj = SCIPsolGetObj(primal->sols[0], set, transprob, origprob);
1726  if( obj < primal->cutoffbound )
1727  {
1728  /* update the upper bound */
1729  SCIP_CALL( SCIPprimalSetUpperbound(primal, blkmem, set, stat, eventqueue, transprob, tree, reopt, lp, obj) );
1730  }
1731  }
1732 
1733  return SCIP_OKAY;
1734 }
1735 
1736 /** tries to transform original solution to the transformed problem space */
1738  SCIP_PRIMAL* primal, /**< primal data */
1739  SCIP_SOL* sol, /**< primal solution */
1740  BMS_BLKMEM* blkmem, /**< block memory */
1741  SCIP_SET* set, /**< global SCIP settings */
1742  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1743  SCIP_STAT* stat, /**< problem statistics data */
1744  SCIP_PROB* origprob, /**< original problem */
1745  SCIP_PROB* transprob, /**< transformed problem after presolve */
1746  SCIP_TREE* tree, /**< branch and bound tree */
1747  SCIP_REOPT* reopt, /**< reoptimization data structure */
1748  SCIP_LP* lp, /**< current LP data */
1749  SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1750  SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1751  SCIP_Real* solvals, /**< array for internal use to store solution values, or NULL;
1752  * if the method is called multiple times in a row, an array with size >=
1753  * number of active variables should be given for performance reasons */
1754  SCIP_Bool* solvalset, /**< array for internal use to store which solution values were set, or NULL;
1755  * if the method is called multiple times in a row, an array with size >=
1756  * number of active variables should be given for performance reasons */
1757  int solvalssize, /**< size of solvals and solvalset arrays, should be >= number of active
1758  * variables */
1759  SCIP_Bool* added /**< pointer to store whether the solution was added */
1760  )
1761 {
1762  SCIP_VAR** origvars;
1763  SCIP_VAR** transvars;
1764  SCIP_VAR* var;
1765  SCIP_Real* localsolvals;
1766  SCIP_Bool* localsolvalset;
1767  SCIP_Real solval;
1768  SCIP_Real scalar;
1769  SCIP_Real constant;
1770  SCIP_Bool localarrays;
1771  SCIP_Bool feasible;
1772  int norigvars;
1773  int ntransvars;
1774  int nvarsset;
1775  int v;
1776 
1777  assert(origprob != NULL);
1778  assert(transprob != NULL);
1779  assert(SCIPsolIsOriginal(sol));
1780  assert(solvalssize == 0 || solvals != NULL);
1781  assert(solvalssize == 0 || solvalset != NULL);
1782 
1783  origvars = origprob->vars;
1784  norigvars = origprob->nvars;
1785  transvars = transprob->vars;
1786  ntransvars = transprob->nvars;
1787  assert(solvalssize == 0 || solvalssize >= ntransvars);
1788 
1789  SCIPsetDebugMsg(set, "try to transfer original solution %p with objective %g into the transformed problem space\n",
1790  (void*)sol, SCIPsolGetOrigObj(sol));
1791 
1792  /* if no solvals and solvalset arrays are given, allocate local ones, otherwise use the given ones */
1793  localarrays = (solvalssize == 0);
1794  if( localarrays )
1795  {
1796  SCIP_CALL( SCIPsetAllocBufferArray(set, &localsolvals, ntransvars) );
1797  SCIP_CALL( SCIPsetAllocBufferArray(set, &localsolvalset, ntransvars) );
1798  }
1799  else
1800  {
1801  localsolvals = solvals;
1802  localsolvalset = solvalset;
1803  }
1804 
1805  BMSclearMemoryArray(localsolvalset, ntransvars);
1806  feasible = TRUE;
1807  (*added) = FALSE;
1808  nvarsset = 0;
1809 
1810  /* for each original variable, get the corresponding active, fixed or multi-aggregated variable;
1811  * if it resolves to an active variable, we set its solution value or check whether an already stored solution value
1812  * is consistent; if it resolves to a fixed variable, we check that the fixing matches the original solution value;
1813  * multi-aggregated variables are skipped, because their value is defined by setting solution values for the active
1814  * variables, anyway
1815  */
1816  for( v = 0; v < norigvars && feasible; ++v )
1817  {
1818  var = origvars[v];
1819 
1820  solval = SCIPsolGetVal(sol, set, stat, var);
1821 
1822  /* get corresponding active, fixed, or multi-aggregated variable */
1823  scalar = 1.0;
1824  constant = 0.0;
1825  SCIP_CALL( SCIPvarGetProbvarSum(&var, set, &scalar, &constant) );
1828 
1829  /* check whether the fixing corresponds to the solution value of the original variable */
1830  if( scalar == 0.0 )
1831  {
1832  assert(SCIPvarGetStatus(var) == SCIP_VARSTATUS_FIXED ||
1833  (SCIPsetIsInfinity(set, constant) || SCIPsetIsInfinity(set, -constant)));
1834 
1835  if( !SCIPsetIsEQ(set, solval, constant) )
1836  {
1837  SCIPsetDebugMsg(set, "original variable <%s> (solval=%g) resolves to fixed variable <%s> (original solval=%g)\n",
1838  SCIPvarGetName(origvars[v]), solval, SCIPvarGetName(var), constant);
1839  feasible = FALSE;
1840  }
1841  }
1842  else if( SCIPvarIsActive(var) )
1843  {
1844  /* if we already assigned a solution value to the transformed variable, check that it corresponds to the
1845  * value obtained from the currently regarded original variable
1846  */
1847  if( localsolvalset[SCIPvarGetProbindex(var)] )
1848  {
1849  if( !SCIPsetIsEQ(set, solval, scalar * localsolvals[SCIPvarGetProbindex(var)] + constant) )
1850  {
1851  SCIPsetDebugMsg(set, "original variable <%s> (solval=%g) resolves to active variable <%s> with assigned solval %g (original solval=%g)\n",
1852  SCIPvarGetName(origvars[v]), solval, SCIPvarGetName(var), localsolvals[SCIPvarGetProbindex(var)],
1853  scalar * localsolvals[SCIPvarGetProbindex(var)] + constant);
1854  feasible = FALSE;
1855  }
1856  }
1857  /* assign solution value to the transformed variable */
1858  else
1859  {
1860  assert(scalar != 0.0);
1861 
1862  localsolvals[SCIPvarGetProbindex(var)] = (solval - constant) / scalar;
1863  localsolvalset[SCIPvarGetProbindex(var)] = TRUE;
1864  ++nvarsset;
1865  }
1866  }
1867 #ifndef NDEBUG
1868  /* we do not have to handle multi-aggregated variables here, since by assigning values to all active variabes,
1869  * we implicitly assign values to the multi-aggregated variables, too
1870  */
1871  else
1872  assert(SCIPvarGetStatus(var) == SCIP_VARSTATUS_MULTAGGR);
1873 #endif
1874  }
1875 
1876  /* if the solution values of fixed and active variables lead to no contradiction, construct solution and try it */
1877  if( feasible )
1878  {
1879  SCIP_SOL* transsol;
1880 
1881  SCIP_CALL( SCIPsolCreate(&transsol, blkmem, set, stat, primal, tree, SCIPsolGetHeur(sol)) );
1882 
1883  /* set solution values for variables to which we assigned a value */
1884  for( v = 0; v < ntransvars; ++v )
1885  {
1886  if( localsolvalset[v] )
1887  {
1888  SCIP_CALL( SCIPsolSetVal(transsol, set, stat, tree, transvars[v], localsolvals[v]) );
1889  }
1890  }
1891 
1892  SCIP_CALL( SCIPprimalTrySolFree(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1893  tree, reopt, lp, eventqueue, eventfilter, &transsol, FALSE, FALSE, TRUE, TRUE, TRUE, added) );
1894 
1895  SCIPsetDebugMsg(set, "solution transferred, %d/%d active variables set (stored=%u)\n", nvarsset, ntransvars, *added);
1896  }
1897  else
1898  (*added) = FALSE;
1899 
1900  /* free local arrays, if needed */
1901  if( localarrays )
1902  {
1903  SCIPsetFreeBufferArray(set, &localsolvalset);
1904  SCIPsetFreeBufferArray(set, &localsolvals);
1905  }
1906 
1907  return SCIP_OKAY;
1908 }
1909 
1910 
1911 /** is the updating of violations enabled for this problem? */
1913  SCIP_PRIMAL* primal /**< problem data */
1914  )
1915 {
1916  assert(primal != NULL);
1917 
1918  return primal->updateviolations;
1919 }
1920 
1921 /** set whether the updating of violations is turned on */
1923  SCIP_PRIMAL* primal, /**< problem data */
1924  SCIP_Bool updateviolations /**< marks whether the updating of violations is turned on */
1925  )
1926 {
1927  assert(primal != NULL);
1928 
1929  primal->updateviolations = updateviolations;
1930 }
SCIP_Real cutoffbound
Definition: struct_primal.h:46
static SCIP_RETCODE primalLinkCurrentSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp, SCIP_HEUR *heur)
Definition: primal.c:1380
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:2465
SCIP_SOL * primalray
Definition: struct_primal.h:52
SCIP_RETCODE SCIPsolUnlink(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *prob)
Definition: sol.c:998
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5776
SCIP_RETCODE SCIPprimalClear(SCIP_PRIMAL **primal, BMS_BLKMEM *blkmem)
Definition: primal.c:190
internal methods for managing events
SCIP_Bool SCIPsetIsLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5834
internal methods for storing primal CIP solutions
void SCIPprimalSolFreed(SCIP_PRIMAL *primal, SCIP_SOL *sol)
Definition: primal.c:1638
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:130
internal methods for branch and bound tree
static SCIP_RETCODE primalAddOrigSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PROB *prob, SCIP_SOL *sol, int insertpos)
Definition: primal.c:783
static SCIP_RETCODE primalSetUpperbound(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_Real upperbound)
Definition: primal.c:319
SCIP_RETCODE SCIPdispPrintLine(SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, FILE *file, SCIP_Bool forcedisplay, SCIP_Bool endline)
Definition: disp.c:363
int nrunsbeforefirst
Definition: struct_stat.h:252
int partialsolssize
Definition: struct_primal.h:55
SCIP_RETCODE SCIPeventChgType(SCIP_EVENT *event, SCIP_EVENTTYPE eventtype)
Definition: event.c:969
SCIP_RETCODE SCIPprimalTrySol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: primal.c:1437
SCIP_RETCODE SCIPprimalRetransformSolutions(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp)
Definition: primal.c:1691
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:5636
SCIP_RETCODE SCIPprimalAddOrigSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_SOL *sol, SCIP_Bool *stored)
Definition: primal.c:1268
SCIP_RETCODE SCIPsolLinkCurrentSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:938
SCIP_SOL ** sols
Definition: struct_primal.h:48
SCIP_SOL * currentsol
Definition: struct_primal.h:51
#define FALSE
Definition: def.h:64
SCIP_RETCODE SCIPeventProcess(SCIP_EVENT *event, SCIP_SET *set, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter)
Definition: event.c:1460
SCIP_RETCODE SCIPsolCopy(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_SOL *sourcesol)
Definition: sol.c:344
#define TRUE
Definition: def.h:63
#define SCIPdebug(x)
Definition: pub_message.h:74
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
static SCIP_RETCODE ensureSolsSize(SCIP_PRIMAL *primal, SCIP_SET *set, int num)
Definition: primal.c:47
void SCIPsolSetPrimalIndex(SCIP_SOL *sol, int primalindex)
Definition: sol.c:2568
SCIP_Real SCIPprobInternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2091
#define SCIPsetAllocBufferArray(set, ptr, num)
Definition: set.h:1877
int SCIPtreeGetCurrentDepth(SCIP_TREE *tree)
Definition: tree.c:8300
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:16969
SCIP_Bool SCIPsolsAreEqual(SCIP_SOL *sol1, SCIP_SOL *sol2, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob)
Definition: sol.c:1977
SCIP_Real SCIPsetCutoffbounddelta(SCIP_SET *set)
Definition: set.c:5741
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:5326
SCIP_Real SCIPsolGetTime(SCIP_SOL *sol)
Definition: sol.c:2508
SCIP_Longint nsolsfound
Definition: struct_primal.h:39
methods for creating output for visualization tools (VBC, BAK)
#define SCIPsetFreeBufferArray(set, ptr)
Definition: set.h:1884
#define BMSfreeMemory(ptr)
Definition: memory.h:127
SCIP_VISUAL * visual
Definition: struct_stat.h:165
internal methods for LP management
SCIP_SOL * SCIPprimalGetRay(SCIP_PRIMAL *primal)
Definition: primal.c:556
SCIP_Real SCIPsolGetOrigObj(SCIP_SOL *sol)
Definition: sol.c:2485
internal methods for collecting primal CIP solutions and primal informations
SCIP_Real SCIPsolGetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition: sol.c:1298
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5870
SCIP_RETCODE SCIPprimalAddCurrentSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_HEUR *heur, SCIP_Bool *stored)
Definition: primal.c:1407
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:404
SCIP_Real SCIPprobGetObjlim(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:2274
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5816
SCIP_RETCODE SCIPeventChgSol(SCIP_EVENT *event, SCIP_SOL *sol)
Definition: event.c:1240
SCIP_Bool updateviolations
Definition: struct_primal.h:61
SCIP_Real SCIPsolGetObj(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition: sol.c:1492
void SCIPsolUpdateVarsum(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_Real weight)
Definition: sol.c:1787
SCIP_RETCODE SCIPprimalTrySolFree(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: primal.c:1507
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_Longint nbestsolsfound
Definition: struct_primal.h:42
static int primalSearchOrigSolPos(SCIP_PRIMAL *primal, SCIP_SOL *sol)
Definition: primal.c:917
SCIP_Longint bestsolnode
Definition: struct_stat.h:102
SCIP_Bool SCIPtreeInRepropagation(SCIP_TREE *tree)
Definition: tree.c:8273
SCIP_RETCODE SCIPsolCreateCurrentSol(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_LP *lp, SCIP_HEUR *heur)
Definition: sol.c:657
SCIP_HEUR * firstprimalheur
Definition: struct_stat.h:166
SCIP_RETCODE SCIPsolSetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real val)
Definition: sol.c:1027
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16662
SCIP_Real SCIPsetFeasCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6352
static SCIP_Bool primalExistsSol(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_SOL *sol, int *insertpos, SCIP_Bool *replace)
Definition: primal.c:952
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
Definition: sol.c:2548
#define REALABS(x)
Definition: def.h:173
static SCIP_RETCODE primalAddSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL **solptr, int insertpos, SCIP_Bool replace)
Definition: primal.c:595
SCIP_Bool SCIPprimalUpdateViolations(SCIP_PRIMAL *primal)
Definition: primal.c:1912
SCIP_Bool SCIPprobIsObjIntegral(SCIP_PROB *prob)
Definition: prob.c:2250
internal methods for global SCIP settings
#define SCIP_CALL(x)
Definition: def.h:350
SCIP_Bool SCIPsetIsFeasGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6262
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5798
SCIP_Bool SCIPsetIsFeasLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6218
SCIP_RETCODE SCIPsolTransform(SCIP_SOL *sol, SCIP_SOL **transsol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PRIMAL *primal)
Definition: sol.c:389
SCIP_RETCODE SCIPprimalSetCutoffbound(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, SCIP_Real cutoffbound, SCIP_Bool useforobjlimit)
Definition: primal.c:266
data structures and methods for collecting reoptimization information
internal methods for problem variables
SCIP_RETCODE SCIPprimalSolCreated(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_SOL *sol)
Definition: primal.c:1616
#define SCIP_Bool
Definition: def.h:61
static SCIP_Bool origsolOfInterest(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_SOL *sol, int *insertpos)
Definition: primal.c:1124
void SCIPprimalUpdateVarObj(SCIP_PRIMAL *primal, SCIP_VAR *var, SCIP_Real oldobj, SCIP_Real newobj)
Definition: primal.c:1668
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:2528
SCIP_RETCODE SCIPsolCreate(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_HEUR *heur)
Definition: sol.c:276
void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
Definition: sol.c:2589
SCIP_RETCODE SCIPsolRetransform(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_Bool *hasinfval)
Definition: sol.c:1815
SCIP_RETCODE SCIPsolPrint(SCIP_SOL *sol, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PROB *transprob, FILE *file, SCIP_Bool mipstart, SCIP_Bool printzeros)
Definition: sol.c:2037
SCIP_SOL ** partialsols
Definition: struct_primal.h:49
#define SCIPsetDebugMsg
Definition: set.h:1913
void SCIPsolOrigAddObjval(SCIP_SOL *sol, SCIP_Real addval)
Definition: sol.c:2496
static SCIP_RETCODE primalAddOrigPartialSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PROB *prob, SCIP_SOL *sol)
Definition: primal.c:835
static SCIP_RETCODE primalSetCutoffbound(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_Real cutoffbound)
Definition: primal.c:234
void SCIPprobSetObjlim(SCIP_PROB *prob, SCIP_Real objlim)
Definition: prob.c:1444
SCIP_Longint nnodesbeforefirst
Definition: struct_stat.h:111
void SCIPprimalSetUpdateViolations(SCIP_PRIMAL *primal, SCIP_Bool updateviolations)
Definition: primal.c:1922
static SCIP_Bool solOfInterest(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_SOL *sol, int *insertpos, SCIP_Bool *replace)
Definition: primal.c:1086
SCIP_RETCODE SCIPprimalAddOrigSolFree(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_SOL **sol, SCIP_Bool *stored)
Definition: primal.c:1323
SCIP_RETCODE SCIPprimalSetUpperbound(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_Real upperbound)
Definition: primal.c:373
#define SCIP_EVENTTYPE_BESTSOLFOUND
Definition: type_event.h:88
SCIP_RETCODE SCIPprimalAddSolFree(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL **sol, SCIP_Bool *stored)
Definition: primal.c:1213
#define SCIP_EVENTTYPE_POORSOLFOUND
Definition: type_event.h:87
SCIP_RETCODE SCIPlpSetCutoffbound(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob, SCIP_Real cutoffbound)
Definition: lp.c:9965
SCIP_Bool SCIPprimalUpperboundIsSol(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition: primal.c:543
SCIP_NODE * SCIPtreeGetCurrentNode(SCIP_TREE *tree)
Definition: tree.c:8283
public methods for message output
SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
Definition: sol.c:2455
SCIP_Real upperbound
Definition: struct_primal.h:45
SCIP_Bool SCIPsetIsGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5852
SCIP_RETCODE SCIPprimalAddSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL *sol, SCIP_Bool *stored)
Definition: primal.c:1145
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16781
int SCIPsolGetPrimalIndex(SCIP_SOL *sol)
Definition: sol.c:2558
void SCIPsolUpdateVarObj(SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real oldobj, SCIP_Real newobj)
Definition: sol.c:1509
#define SCIP_Real
Definition: def.h:149
internal methods for problem statistics
SCIP_VAR ** vars
Definition: struct_prob.h:55
SCIP_Real firstprimaltime
Definition: struct_stat.h:120
SCIP_Real firstprimalbound
Definition: struct_stat.h:119
#define BMSallocMemory(ptr)
Definition: memory.h:101
#define SCIP_INVALID
Definition: def.h:169
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:109
static SCIP_RETCODE ensurePartialsolsSize(SCIP_PRIMAL *primal, SCIP_SET *set, int num)
Definition: primal.c:70
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:443
int SCIPsolGetDepth(SCIP_SOL *sol)
Definition: sol.c:2538
SCIP_RETCODE SCIPprimalTransformSol(SCIP_PRIMAL *primal, SCIP_SOL *sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_Real *solvals, SCIP_Bool *solvalset, int solvalssize, SCIP_Bool *added)
Definition: primal.c:1737
SCIP_Real SCIPsetEpsilon(SCIP_SET *set)
Definition: set.c:5658
SCIP_STAGE SCIPsetGetStage(SCIP_SET *set)
Definition: set.c:2781
SCIP_Real SCIPprobExternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2069
static int primalSearchSolPos(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SOL *sol)
Definition: primal.c:867
void SCIPprimalAddOrigObjoffset(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_Real addval)
Definition: primal.c:509
SCIP_RETCODE SCIPprimalCreate(SCIP_PRIMAL **primal)
Definition: primal.c:117
SCIP_RETCODE SCIPtreeCutoff(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp, SCIP_Real cutoffbound)
Definition: tree.c:5047
#define BMSclearMemoryArray(ptr, num)
Definition: memory.h:112
SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
Definition: sol.c:2475
common defines and data types used in all packages of SCIP
SCIP_Longint nnodes
Definition: struct_stat.h:71
static SCIP_RETCODE ensureExistingsolsSize(SCIP_PRIMAL *primal, SCIP_SET *set, int num)
Definition: primal.c:95
static SCIP_Bool primalExistsOrigSol(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_SOL *sol, int insertpos)
Definition: primal.c:1034
int SCIPsolGetRunnum(SCIP_SOL *sol)
Definition: sol.c:2518
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:419
SCIP_RETCODE SCIPvarGetProbvarSum(SCIP_VAR **var, SCIP_SET *set, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12057
SCIP_RETCODE SCIPprimalFree(SCIP_PRIMAL **primal, BMS_BLKMEM *blkmem)
Definition: primal.c:147
SCIP_RETCODE SCIPprimalUpdateRay(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_STAT *stat, SCIP_SOL *primalray, BMS_BLKMEM *blkmem)
Definition: primal.c:566
int firstprimaldepth
Definition: struct_stat.h:253
#define SCIP_ALLOC(x)
Definition: def.h:361
int existingsolssize
Definition: struct_primal.h:58
void SCIPvisualUpperbound(SCIP_VISUAL *visual, SCIP_SET *set, SCIP_STAT *stat, SCIP_Real upperbound)
Definition: visual.c:778
SCIP_Longint nlimsolsfound
Definition: struct_primal.h:40
SCIP_RETCODE SCIPsolCheck(SCIP_SOL *sol, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *feasible)
Definition: sol.c:1593
SCIP_SOL ** existingsols
Definition: struct_primal.h:50
void SCIPvisualFoundSolution(SCIP_VISUAL *visual, SCIP_SET *set, SCIP_STAT *stat, SCIP_NODE *node, SCIP_Bool bettersol, SCIP_SOL *sol)
Definition: visual.c:656
SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)
Definition: var.c:16949
SCIP_RETCODE SCIPprimalTryCurrentSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_HEUR *heur, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: primal.c:1581
SCIP_RETCODE SCIPsolFree(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_PRIMAL *primal)
Definition: sol.c:751
internal methods for displaying runtime statistics