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