Scippy

SCIP

Solving Constraint Integer Programs

sol.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 sol.c
17  * @brief methods for storing primal CIP solutions
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/clock.h"
29 #include "scip/misc.h"
30 #include "scip/lp.h"
31 #include "scip/nlp.h"
32 #include "scip/relax.h"
33 #include "scip/var.h"
34 #include "scip/prob.h"
35 #include "scip/sol.h"
36 #include "scip/primal.h"
37 #include "scip/tree.h"
38 #include "scip/cons.h"
39 #include "scip/pub_message.h"
40 
41 #ifndef NDEBUG
42 #include "scip/struct_sol.h"
43 #endif
44 
45 
46 
47 /** clears solution arrays of primal CIP solution */
48 static
50  SCIP_SOL* sol /**< primal CIP solution */
51  )
52 {
53  assert(sol != NULL);
54 
56  sol->hasinfval = FALSE;
57 
58  return SCIP_OKAY;
59 }
60 
61 /** sets value of variable in the solution's array */
62 static
64  SCIP_SOL* sol, /**< primal CIP solution */
65  SCIP_SET* set, /**< global SCIP settings */
66  SCIP_VAR* var, /**< problem variable */
67  SCIP_Real val /**< value to set variable to */
68  )
69 {
70  int idx;
71 
72  assert(sol != NULL);
73 
74  idx = SCIPvarGetIndex(var);
75 
76  /* from now on, variable must not be deleted */
78 
79  /* mark the variable valid */
80  SCIP_CALL( SCIPboolarraySetVal(sol->valid, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, TRUE) );
81 
82  /* set the value in the solution array */
83  SCIP_CALL( SCIPrealarraySetVal(sol->vals, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, val) );
84 
85  /* store whether the solution has infinite values assigned to variables */
86  if( val != SCIP_UNKNOWN ) /*lint !e777*/
87  sol->hasinfval = (sol->hasinfval || SCIPsetIsInfinity(set, val) || SCIPsetIsInfinity(set, -val));
88 
89  return SCIP_OKAY;
90 }
91 
92 /** increases value of variable in the solution's array */
93 static
95  SCIP_SOL* sol, /**< primal CIP solution */
96  SCIP_SET* set, /**< global SCIP settings */
97  SCIP_VAR* var, /**< problem variable */
98  SCIP_Real incval /**< increase of variable's solution value */
99  )
100 {
101  int idx;
102 
103  assert(sol != NULL);
104 
105  idx = SCIPvarGetIndex(var);
106 
107  /* from now on, variable must not be deleted */
109 
110  /* if the variable was not valid, mark it to be valid and set the value to the incval (it is 0.0 if not valid) */
111  if( !SCIPboolarrayGetVal(sol->valid, idx) )
112  {
113  /* mark the variable valid */
114  SCIP_CALL( SCIPboolarraySetVal(sol->valid, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, TRUE) );
115 
116  /* set the value in the solution array */
117  SCIP_CALL( SCIPrealarraySetVal(sol->vals, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, incval) );
118  }
119  else
120  {
121  /* increase the value in the solution array */
122  SCIP_CALL( SCIPrealarrayIncVal(sol->vals, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, incval) );
123  }
124 
125  /* store whether the solution has infinite values assigned to variables */
126  incval = SCIPrealarrayGetVal(sol->vals, idx);
127  if( incval != SCIP_UNKNOWN ) /*lint !e777*/
128  sol->hasinfval = (sol->hasinfval || SCIPsetIsInfinity(set, incval) || SCIPsetIsInfinity(set, -incval));
129 
130  return SCIP_OKAY;
131 }
132 
133 /** returns the value of the variable in the given solution */
134 static
136  SCIP_SOL* sol, /**< primal CIP solution */
137  SCIP_VAR* var /**< problem variable */
138  )
139 {
140  int idx;
141 
142  assert(sol != NULL);
143 
144  idx = SCIPvarGetIndex(var);
145 
146  /* check, if the variable's value is valid */
147  if( SCIPboolarrayGetVal(sol->valid, idx) )
148  {
149  return SCIPrealarrayGetVal(sol->vals, idx);
150  }
151  else
152  {
153  /* return the variable's value corresponding to the origin */
154  switch( sol->solorigin )
155  {
157  case SCIP_SOLORIGIN_ZERO:
158  return 0.0;
159 
161  return SCIPvarGetLPSol(var);
162 
164  return SCIPvarGetNLPSol(var);
165 
167  return SCIPvarGetRelaxSolTransVar(var);
168 
170  return SCIPvarGetPseudoSol(var);
171 
174  return SCIP_UNKNOWN;
175 
176  default:
177  SCIPerrorMessage("unknown solution origin <%d>\n", sol->solorigin);
178  SCIPABORT();
179  return 0.0; /*lint !e527*/
180  }
181  }
182 }
183 
184 /** stores solution value of variable in solution's own array */
185 static
187  SCIP_SOL* sol, /**< primal CIP solution */
188  SCIP_SET* set, /**< global SCIP settings */
189  SCIP_VAR* var /**< problem variable */
190  )
191 {
192  SCIP_Real solval;
193 
194  assert(sol != NULL);
195  assert(var != NULL);
196  assert(SCIPvarIsTransformed(var));
198 
199  /* if variable is already valid, nothing has to be done */
200  if( SCIPboolarrayGetVal(sol->valid, SCIPvarGetIndex(var)) )
201  return SCIP_OKAY;
202 
203  SCIPsetDebugMsg(set, "unlinking solution value of variable <%s>\n", SCIPvarGetName(var));
204 
205  /* store the correct solution value into the solution array */
206  switch( sol->solorigin )
207  {
209  SCIPerrorMessage("cannot unlink solutions of original problem space\n");
210  return SCIP_INVALIDDATA;
211 
212  case SCIP_SOLORIGIN_ZERO:
213  return SCIP_OKAY;
214 
216  solval = SCIPvarGetLPSol(var);
217  SCIP_CALL( solSetArrayVal(sol, set, var, solval) );
218  return SCIP_OKAY;
219 
221  solval = SCIPvarGetNLPSol(var);
222  SCIP_CALL( solSetArrayVal(sol, set, var, solval) );
223  return SCIP_OKAY;
224 
226  solval = SCIPvarGetRelaxSolTransVar(var);
227  SCIP_CALL( solSetArrayVal(sol, set, var, solval) );
228  return SCIP_OKAY;
229 
231  solval = SCIPvarGetPseudoSol(var);
232  SCIP_CALL( solSetArrayVal(sol, set, var, solval) );
233  return SCIP_OKAY;
234 
237  SCIP_CALL( solSetArrayVal(sol, set, var, SCIP_UNKNOWN) );
238  return SCIP_OKAY;
239 
240  default:
241  SCIPerrorMessage("unknown solution origin <%d>\n", sol->solorigin);
242  return SCIP_INVALIDDATA;
243  }
244 }
245 
246 /** sets the solution time, nodenum, runnum, and depth stamp to the current values */
247 static
248 void solStamp(
249  SCIP_SOL* sol, /**< primal CIP solution */
250  SCIP_STAT* stat, /**< problem statistics data */
251  SCIP_TREE* tree, /**< branch and bound tree, or NULL */
252  SCIP_Bool checktime /**< should the time be updated? */
253  )
254 {
255  assert(sol != NULL);
256  assert(stat != NULL);
257 
258  if( checktime )
259  {
260  sol->time = SCIPclockGetTime(stat->solvingtime);
261 #ifndef NDEBUG
262  sol->lpcount = stat->lpcount;
263 #endif
264  }
265  else
266  sol->time = SCIPclockGetLastTime(stat->solvingtime);
267  sol->nodenum = stat->nnodes;
268  sol->runnum = stat->nruns;
269  if( tree == NULL )
270  sol->depth = -1;
271  else
272  sol->depth = SCIPtreeGetCurrentDepth(tree);
273 }
274 
275 /** creates primal CIP solution, initialized to zero */
277  SCIP_SOL** sol, /**< pointer to primal CIP solution */
278  BMS_BLKMEM* blkmem, /**< block memory */
279  SCIP_SET* set, /**< global SCIP settings */
280  SCIP_STAT* stat, /**< problem statistics data */
281  SCIP_PRIMAL* primal, /**< primal data */
282  SCIP_TREE* tree, /**< branch and bound tree */
283  SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
284  )
285 {
286  assert(sol != NULL);
287  assert(blkmem != NULL);
288  assert(stat != NULL);
289 
290  SCIP_ALLOC( BMSallocBlockMemory(blkmem, sol) );
291  SCIP_CALL( SCIPrealarrayCreate(&(*sol)->vals, blkmem) );
292  SCIP_CALL( SCIPboolarrayCreate(&(*sol)->valid, blkmem) );
293  (*sol)->heur = heur;
294  (*sol)->solorigin = SCIP_SOLORIGIN_ZERO;
295  (*sol)->obj = 0.0;
296  (*sol)->primalindex = -1;
297  (*sol)->index = stat->solindex;
298  (*sol)->hasinfval = FALSE;
299  stat->solindex++;
300  solStamp(*sol, stat, tree, TRUE);
301 
302  SCIP_CALL( SCIPprimalSolCreated(primal, set, *sol) );
303 
304  return SCIP_OKAY;
305 }
306 
307 /** creates primal CIP solution in original problem space, initialized to the offset in the original problem */
309  SCIP_SOL** sol, /**< pointer to primal CIP solution */
310  BMS_BLKMEM* blkmem, /**< block memory */
311  SCIP_SET* set, /**< global SCIP settings */
312  SCIP_STAT* stat, /**< problem statistics data */
313  SCIP_PROB* origprob, /**< original problem data */
314  SCIP_PRIMAL* primal, /**< primal data */
315  SCIP_TREE* tree, /**< branch and bound tree */
316  SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
317  )
318 {
319  assert(sol != NULL);
320  assert(blkmem != NULL);
321  assert(stat != NULL);
322 
323  SCIP_ALLOC( BMSallocBlockMemory(blkmem, sol) );
324  SCIP_CALL( SCIPrealarrayCreate(&(*sol)->vals, blkmem) );
325  SCIP_CALL( SCIPboolarrayCreate(&(*sol)->valid, blkmem) );
326  (*sol)->heur = heur;
327  (*sol)->solorigin = SCIP_SOLORIGIN_ORIGINAL;
328  (*sol)->obj = origprob->objoffset;
329  (*sol)->primalindex = -1;
330  (*sol)->index = stat->solindex;
331  (*sol)->hasinfval = FALSE;
332  stat->solindex++;
333  solStamp(*sol, stat, tree, TRUE);
334 
335  SCIP_CALL( SCIPprimalSolCreated(primal, set, *sol) );
336 
337  return SCIP_OKAY;
338 }
339 
340 /** creates a copy of a primal CIP solution */
342  SCIP_SOL** sol, /**< pointer to store the copy of the primal CIP solution */
343  BMS_BLKMEM* blkmem, /**< block memory */
344  SCIP_SET* set, /**< global SCIP settings */
345  SCIP_STAT* stat, /**< problem statistics data */
346  SCIP_PRIMAL* primal, /**< primal data */
347  SCIP_SOL* sourcesol /**< primal CIP solution to copy */
348  )
349 {
350  assert(sol != NULL);
351  assert(sourcesol != NULL);
352 
353  SCIP_ALLOC( BMSallocBlockMemory(blkmem, sol) );
354  SCIP_CALL( SCIPrealarrayCopy(&(*sol)->vals, blkmem, sourcesol->vals) );
355  SCIP_CALL( SCIPboolarrayCopy(&(*sol)->valid, blkmem, sourcesol->valid) );
356  (*sol)->heur = sourcesol->heur;
357  (*sol)->obj = sourcesol->obj;
358  (*sol)->primalindex = -1;
359  (*sol)->time = sourcesol->time;
360 #ifndef NDEBUG
361  (*sol)->lpcount = sourcesol->lpcount;
362 #endif
363  (*sol)->nodenum = sourcesol->nodenum;
364  (*sol)->solorigin = sourcesol->solorigin;
365  (*sol)->runnum = sourcesol->runnum;
366  (*sol)->depth = sourcesol->depth;
367  (*sol)->index = stat->solindex;
368  (*sol)->hasinfval = sourcesol->hasinfval;
369  stat->solindex++;
370 
371  SCIP_CALL( SCIPprimalSolCreated(primal, set, *sol) );
372 
373  return SCIP_OKAY;
374 }
375 
376 /** transformes given original solution to the transformed space; a corresponding transformed solution has to be given
377  * which is copied into the existing solution and freed afterwards
378  */
380  SCIP_SOL* sol, /**< primal CIP solution to change, living in original space */
381  SCIP_SOL** transsol, /**< pointer to corresponding transformed primal CIP solution */
382  BMS_BLKMEM* blkmem, /**< block memory */
383  SCIP_SET* set, /**< global SCIP settings */
384  SCIP_PRIMAL* primal /**< primal data */
385  )
386 { /*lint --e{715}*/
387  SCIP_REALARRAY* tmpvals;
388  SCIP_BOOLARRAY* tmpvalid;
389  SCIP_SOL* tsol;
390 
391  assert(sol != NULL);
392  assert(transsol != NULL);
393  assert(SCIPsolIsOriginal(sol));
394  assert(sol->primalindex > -1);
395 
396  tsol = *transsol;
397  assert(tsol != NULL);
398  assert(!SCIPsolIsOriginal(tsol));
399 
400  /* switch vals and valid arrays; the exisiting solution gets the arrays of the transformed solution;
401  * the transformed one gets the original arrays, because they have to be freed anyway and freeing the transsol
402  * automatically frees its arrays
403  */
404  tmpvals = sol->vals;
405  tmpvalid = sol->valid;
406  sol->vals = tsol->vals;
407  sol->valid = tsol->valid;
408  tsol->vals = tmpvals;
409  tsol->valid = tmpvalid;
410 
411  /* copy solorigin and objective (should be the same, only to avoid numerical issues);
412  * we keep the other statistics of the original solution, since that was the first time that this solution as found
413  */
414  sol->solorigin = tsol->solorigin;
415  sol->obj = tsol->obj;
416 
417  SCIP_CALL( SCIPsolFree(transsol, blkmem, primal) );
418 
419  return SCIP_OKAY;
420 }
421 
422 /** adjusts solution values of implicit integer variables in handed solution. Solution objective value is not
423  * deteriorated by this method.
424  */
426  SCIP_SOL* sol, /**< primal CIP solution */
427  SCIP_SET* set, /**< global SCIP settings */
428  SCIP_STAT* stat, /**< problem statistics data */
429  SCIP_PROB* prob, /**< either original or transformed problem, depending on sol origin */
430  SCIP_TREE* tree, /**< branch and bound tree */
431  SCIP_Bool uselprows /**< should LP row information be considered for none-objective variables */
432  )
433 {
434  SCIP_VAR** vars;
435  int nimplvars;
436  int nbinvars;
437  int nintvars;
438  int v;
439 
440  assert(sol != NULL);
441  assert(prob != NULL);
442 
443  /* get variable data */
444  vars = SCIPprobGetVars(prob);
445  nbinvars = SCIPprobGetNBinVars(prob);
446  nintvars = SCIPprobGetNIntVars(prob);
447  nimplvars = SCIPprobGetNImplVars(prob);
448 
449  if( nimplvars == 0 )
450  return SCIP_OKAY;
451 
452  /* calculate the last array position of implicit integer variables */
453  nimplvars = nbinvars + nintvars + nimplvars;
454 
455  /* loop over implicit integer variables and round them up or down */
456  for( v = nbinvars + nintvars; v < nimplvars; ++v )
457  {
458  SCIP_VAR* var;
459  SCIP_Real solval;
460  SCIP_Real obj;
461  SCIP_Real newsolval;
462  SCIP_Bool roundup;
463  SCIP_Bool rounddown;
464  int nuplocks;
465  int ndownlocks;
466 
467  var = vars[v];
468 
469  assert( SCIPvarGetType(var) == SCIP_VARTYPE_IMPLINT );
470  solval = SCIPsolGetVal(sol, set, stat, var);
471 
472  /* we do not need to round integral solution values or those of variables which are not column variables */
473  if( SCIPsetIsFeasIntegral(set, solval) || SCIPvarGetStatus(var) != SCIP_VARSTATUS_COLUMN )
474  continue;
475 
476  nuplocks = SCIPvarGetNLocksUp(var);
477  ndownlocks = SCIPvarGetNLocksDown(var);
478  obj = SCIPvarGetObj(var);
479 
480  roundup = FALSE;
481  rounddown = FALSE;
482 
483  /* in case of a non-zero objective coefficient, there is only one possible rounding direction */
484  if( SCIPsetIsFeasNegative(set, obj) )
485  roundup = TRUE;
486  else if( SCIPsetIsFeasPositive(set, obj) )
487  rounddown = TRUE;
488  else if( uselprows )
489  {
490  /* determine rounding direction based on row violations */
491  SCIP_COL* col;
492  SCIP_ROW** rows;
493  SCIP_Real* vals;
494  int nrows;
495  int r;
496 
497  col = SCIPvarGetCol(var);
498  vals = SCIPcolGetVals(col);
499  rows = SCIPcolGetRows(col);
500  nrows = SCIPcolGetNNonz(col);
501 
502  /* loop over rows and search for equations whose violation can be decreased by rounding */
503  for( r = 0; r < nrows && !(roundup && rounddown); ++r )
504  {
505  SCIP_ROW* row;
506  SCIP_Real activity;
507  SCIP_Real rhs;
508  SCIP_Real lhs;
509 
510  row = rows[r];
511  assert(!SCIPsetIsFeasZero(set, vals[r]));
512 
513  if( SCIProwIsLocal(row) || !SCIProwIsInLP(row) )
514  continue;
515 
516  rhs = SCIProwGetRhs(row);
517  lhs = SCIProwGetLhs(row);
518 
519  if( SCIPsetIsInfinity(set, rhs) || SCIPsetIsInfinity(set, -lhs) )
520  continue;
521 
522  activity = SCIProwGetSolActivity(row, set, stat, sol);
523  if( SCIPsetIsFeasLE(set, activity, rhs) && SCIPsetIsFeasLE(set, lhs, activity) )
524  continue;
525 
526  if( (SCIPsetIsFeasGT(set, activity, rhs) && SCIPsetIsPositive(set, vals[r]))
527  || (SCIPsetIsFeasLT(set, activity, lhs) && SCIPsetIsNegative(set, vals[r])) )
528  rounddown = TRUE;
529  else
530  roundup = TRUE;
531  }
532  }
533 
534  /* in case of a tie, we select the rounding step based on the number of variable locks */
535  if( roundup == rounddown )
536  {
537  rounddown = ndownlocks <= nuplocks;
538  roundup = !rounddown;
539  }
540 
541  /* round the variable up or down */
542  if( roundup )
543  {
544  newsolval = SCIPsetCeil(set, solval);
545  assert(SCIPsetIsFeasLE(set, newsolval, SCIPvarGetUbGlobal(var)));
546  }
547  else
548  {
549  assert( rounddown ); /* should be true because of the code above */
550  newsolval = SCIPsetFloor(set, solval);
551  assert(SCIPsetIsFeasGE(set, newsolval, SCIPvarGetLbGlobal(var)));
552  }
553 
554  SCIP_CALL( SCIPsolSetVal(sol, set, stat, tree, var, newsolval) );
555  }
556 
557  return SCIP_OKAY;
558 }
559 /** creates primal CIP solution, initialized to the current LP solution */
561  SCIP_SOL** sol, /**< pointer to primal CIP solution */
562  BMS_BLKMEM* blkmem, /**< block memory */
563  SCIP_SET* set, /**< global SCIP settings */
564  SCIP_STAT* stat, /**< problem statistics data */
565  SCIP_PROB* prob, /**< transformed problem data */
566  SCIP_PRIMAL* primal, /**< primal data */
567  SCIP_TREE* tree, /**< branch and bound tree */
568  SCIP_LP* lp, /**< current LP data */
569  SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
570  )
571 {
572  assert(sol != NULL);
573  assert(lp != NULL);
574  assert(SCIPlpIsSolved(lp));
575 
576  SCIP_CALL( SCIPsolCreate(sol, blkmem, set, stat, primal, tree, heur) );
577  SCIP_CALL( SCIPsolLinkLPSol(*sol, set, stat, prob, tree, lp) );
578 
579  return SCIP_OKAY;
580 }
581 
582 /** creates primal CIP solution, initialized to the current NLP solution */
584  SCIP_SOL** sol, /**< pointer to primal CIP solution */
585  BMS_BLKMEM* blkmem, /**< block memory */
586  SCIP_SET* set, /**< global SCIP settings */
587  SCIP_STAT* stat, /**< problem statistics data */
588  SCIP_PRIMAL* primal, /**< primal data */
589  SCIP_TREE* tree, /**< branch and bound tree */
590  SCIP_NLP* nlp, /**< current NLP data */
591  SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
592  )
593 {
594  assert(sol != NULL);
595  assert(nlp != NULL);
596 
597  SCIP_CALL( SCIPsolCreate(sol, blkmem, set, stat, primal, tree, heur) );
598  SCIP_CALL( SCIPsolLinkNLPSol(*sol, stat, tree, nlp) );
599 
600  return SCIP_OKAY;
601 }
602 
603 /** creates primal CIP solution, initialized to the current relaxation solution */
605  SCIP_SOL** sol, /**< pointer to primal CIP solution */
606  BMS_BLKMEM* blkmem, /**< block memory */
607  SCIP_SET* set, /**< global SCIP settings */
608  SCIP_STAT* stat, /**< problem statistics data */
609  SCIP_PRIMAL* primal, /**< primal data */
610  SCIP_TREE* tree, /**< branch and bound tree */
611  SCIP_RELAXATION* relaxation, /**< global relaxation data */
612  SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
613  )
614 {
615  assert(sol != NULL);
616  assert(relaxation != NULL);
617  assert(SCIPrelaxationIsSolValid(relaxation));
618 
619  SCIP_CALL( SCIPsolCreate(sol, blkmem, set, stat, primal, tree, heur) );
620  SCIP_CALL( SCIPsolLinkRelaxSol(*sol, set, stat, tree, relaxation) );
621 
622  return SCIP_OKAY;
623 }
624 
625 /** creates primal CIP solution, initialized to the current pseudo solution */
627  SCIP_SOL** sol, /**< pointer to primal CIP solution */
628  BMS_BLKMEM* blkmem, /**< block memory */
629  SCIP_SET* set, /**< global SCIP settings */
630  SCIP_STAT* stat, /**< problem statistics data */
631  SCIP_PROB* prob, /**< transformed problem data */
632  SCIP_PRIMAL* primal, /**< primal data */
633  SCIP_TREE* tree, /**< branch and bound tree, or NULL */
634  SCIP_LP* lp, /**< current LP data */
635  SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
636  )
637 {
638  assert(sol != NULL);
639 
640  SCIP_CALL( SCIPsolCreate(sol, blkmem, set, stat, primal, tree, heur) );
641  SCIP_CALL( SCIPsolLinkPseudoSol(*sol, set, stat, prob, tree, lp) );
642 
643  return SCIP_OKAY;
644 }
645 
646 /** creates primal CIP solution, initialized to the current solution */
648  SCIP_SOL** sol, /**< pointer to primal CIP solution */
649  BMS_BLKMEM* blkmem, /**< block memory */
650  SCIP_SET* set, /**< global SCIP settings */
651  SCIP_STAT* stat, /**< problem statistics data */
652  SCIP_PROB* prob, /**< transformed problem data */
653  SCIP_PRIMAL* primal, /**< primal data */
654  SCIP_TREE* tree, /**< branch and bound tree */
655  SCIP_LP* lp, /**< current LP data */
656  SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
657  )
658 {
659  assert(tree != NULL);
660 
661  if( SCIPtreeHasCurrentNodeLP(tree) )
662  {
663  SCIP_CALL( SCIPsolCreateLPSol(sol, blkmem, set, stat, prob, primal, tree, lp, heur) );
664  }
665  else
666  {
667  SCIP_CALL( SCIPsolCreatePseudoSol(sol, blkmem, set, stat, prob, primal, tree, lp, heur) );
668  }
669 
670  return SCIP_OKAY;
671 }
672 
673 /** creates partial primal CIP solution, initialized to unknown values */
675  SCIP_SOL** sol, /**< pointer to primal CIP solution */
676  BMS_BLKMEM* blkmem, /**< block memory */
677  SCIP_SET* set, /**< global SCIP settings */
678  SCIP_STAT* stat, /**< problem statistics data */
679  SCIP_PRIMAL* primal, /**< primal data */
680  SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
681  )
682 {
683  assert(sol != NULL);
684  assert(blkmem != NULL);
685  assert(set != NULL);
686  assert(stat != NULL);
687  assert(primal != NULL);
688 
689  SCIP_ALLOC( BMSallocBlockMemory(blkmem, sol) );
690  SCIP_CALL( SCIPrealarrayCreate(&(*sol)->vals, blkmem) );
691  SCIP_CALL( SCIPboolarrayCreate(&(*sol)->valid, blkmem) );
692  (*sol)->heur = heur;
693  (*sol)->solorigin = SCIP_SOLORIGIN_PARTIAL;
694  (*sol)->obj = SCIP_UNKNOWN;
695  (*sol)->primalindex = -1;
696  (*sol)->index = stat->solindex;
697  (*sol)->hasinfval = FALSE;
698  stat->solindex++;
699  solStamp(*sol, stat, NULL, TRUE);
700 
701  SCIP_CALL( SCIPprimalSolCreated(primal, set, *sol) );
702 
703  return SCIP_OKAY;
704 }
705 
706 /** creates primal CIP solution, initialized to unknown values */
708  SCIP_SOL** sol, /**< pointer to primal CIP solution */
709  BMS_BLKMEM* blkmem, /**< block memory */
710  SCIP_SET* set, /**< global SCIP settings */
711  SCIP_STAT* stat, /**< problem statistics data */
712  SCIP_PRIMAL* primal, /**< primal data */
713  SCIP_TREE* tree, /**< branch and bound tree */
714  SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
715  )
716 {
717  assert(sol != NULL);
718  assert(blkmem != NULL);
719  assert(stat != NULL);
720 
721  SCIP_ALLOC( BMSallocBlockMemory(blkmem, sol) );
722  SCIP_CALL( SCIPrealarrayCreate(&(*sol)->vals, blkmem) );
723  SCIP_CALL( SCIPboolarrayCreate(&(*sol)->valid, blkmem) );
724  (*sol)->heur = heur;
725  (*sol)->solorigin = SCIP_SOLORIGIN_UNKNOWN;
726  (*sol)->obj = 0.0;
727  (*sol)->primalindex = -1;
728  (*sol)->index = stat->solindex;
729  (*sol)->hasinfval = FALSE;
730  stat->solindex++;
731  solStamp(*sol, stat, tree, TRUE);
732 
733  SCIP_CALL( SCIPprimalSolCreated(primal, set, *sol) );
734 
735  return SCIP_OKAY;
736 }
737 
738 /** frees primal CIP solution */
740  SCIP_SOL** sol, /**< pointer to primal CIP solution */
741  BMS_BLKMEM* blkmem, /**< block memory */
742  SCIP_PRIMAL* primal /**< primal data */
743  )
744 {
745  assert(sol != NULL);
746  assert(*sol != NULL);
747 
748  SCIPprimalSolFreed(primal, *sol);
749 
750  SCIP_CALL( SCIPrealarrayFree(&(*sol)->vals) );
751  SCIP_CALL( SCIPboolarrayFree(&(*sol)->valid) );
752  BMSfreeBlockMemory(blkmem, sol);
753 
754  return SCIP_OKAY;
755 }
756 
757 /** copies current LP solution into CIP solution by linking */
759  SCIP_SOL* sol, /**< primal CIP solution */
760  SCIP_SET* set, /**< global SCIP settings */
761  SCIP_STAT* stat, /**< problem statistics data */
762  SCIP_PROB* prob, /**< transformed problem data */
763  SCIP_TREE* tree, /**< branch and bound tree */
764  SCIP_LP* lp /**< current LP data */
765  )
766 {
767  assert(sol != NULL);
768  assert(stat != NULL);
769  assert(tree != NULL);
770  assert(lp != NULL);
771  assert(lp->solved);
772  assert(SCIPlpDiving(lp) || SCIPtreeProbing(tree) || !SCIPlpDivingObjChanged(lp));
773 
774  SCIPsetDebugMsg(set, "linking solution to LP\n");
775 
776  /* clear the old solution arrays */
777  SCIP_CALL( solClearArrays(sol) );
778 
779  /* link solution to LP solution */
780  if( SCIPlpDivingObjChanged(lp) )
781  {
782  /* the objective value has to be calculated manually, because the LP's value is invalid;
783  * use objective values of variables, because columns objective values are changed to dive values
784  */
785  sol->obj = SCIPlpGetLooseObjval(lp, set, prob);
786  if( !SCIPsetIsInfinity(set, -sol->obj) )
787  {
788  SCIP_VAR* var;
789  SCIP_COL** cols;
790  int ncols;
791  int c;
792 
793  cols = SCIPlpGetCols(lp);
794  ncols = SCIPlpGetNCols(lp);
795  for( c = 0; c < ncols; ++c )
796  {
797  var = SCIPcolGetVar(cols[c]);
798  sol->obj += SCIPvarGetUnchangedObj(var) * cols[c]->primsol;
799  }
800  }
801  }
802  else
803  {
804  /* the objective value in the columns is correct, s.t. the LP's objective value is also correct */
805  sol->obj = SCIPlpGetObjval(lp, set, prob);
806  }
808  solStamp(sol, stat, tree, TRUE);
809 
810  SCIPsetDebugMsg(set, " -> objective value: %g\n", sol->obj);
811 
812  return SCIP_OKAY;
813 }
814 
815 /** copies current NLP solution into CIP solution by linking */
817  SCIP_SOL* sol, /**< primal CIP solution */
818  SCIP_STAT* stat, /**< problem statistics data */
819  SCIP_TREE* tree, /**< branch and bound tree */
820  SCIP_NLP* nlp /**< current NLP data */
821  )
822 {
823  assert(sol != NULL);
824  assert(stat != NULL);
825  assert(tree != NULL);
826  assert(nlp != NULL);
828 
829  SCIPstatDebugMsg(stat, "linking solution to NLP\n");
830 
831  /* clear the old solution arrays */
832  SCIP_CALL( solClearArrays(sol) );
833 
834  /* get objective value of NLP solution */
835  if( SCIPnlpIsDivingObjChanged(nlp) )
836  {
837  /* the objective value has to be calculated manually, because the NLP's value is invalid */
838 
839  SCIP_VAR** vars;
840  int nvars;
841  int v;
842 
843  sol->obj = 0.0;
844 
845  vars = SCIPnlpGetVars(nlp);
846  nvars = SCIPnlpGetNVars(nlp);
847  for( v = 0; v < nvars; ++v )
848  {
849  assert(SCIPvarIsActive(vars[v]));
850  sol->obj += SCIPvarGetObj(vars[v]) * SCIPvarGetNLPSol(vars[v]);
851  }
852  }
853  else
854  {
855  sol->obj = SCIPnlpGetObjval(nlp);
856  }
857 
859  solStamp(sol, stat, tree, TRUE);
860 
861  SCIPstatDebugMsg(stat, " -> objective value: %g\n", sol->obj);
862 
863  return SCIP_OKAY;
864 }
865 
866 /** copies current relaxation solution into CIP solution by linking */
868  SCIP_SOL* sol, /**< primal CIP solution */
869  SCIP_SET* set, /**< global SCIP settings */
870  SCIP_STAT* stat, /**< problem statistics data */
871  SCIP_TREE* tree, /**< branch and bound tree */
872  SCIP_RELAXATION* relaxation /**< global relaxation data */
873  )
874 { /*lint --e{715}*/
875  assert(sol != NULL);
876  assert(stat != NULL);
877  assert(tree != NULL);
878  assert(relaxation != NULL);
879  assert(SCIPrelaxationIsSolValid(relaxation));
880 
881  SCIPsetDebugMsg(set, "linking solution to relaxation\n");
882 
883  /* clear the old solution arrays */
884  SCIP_CALL( solClearArrays(sol) );
885 
886  /* the objective value in the columns is correct, s.t. the LP's objective value is also correct */
887  sol->obj = SCIPrelaxationGetSolObj(relaxation);
889  solStamp(sol, stat, tree, TRUE);
890 
891  SCIPsetDebugMsg(set, " -> objective value: %g\n", sol->obj);
892 
893  return SCIP_OKAY;
894 }
895 
896 /** copies current pseudo solution into CIP solution by linking */
898  SCIP_SOL* sol, /**< primal CIP solution */
899  SCIP_SET* set, /**< global SCIP settings */
900  SCIP_STAT* stat, /**< problem statistics data */
901  SCIP_PROB* prob, /**< transformed problem data */
902  SCIP_TREE* tree, /**< branch and bound tree, or NULL */
903  SCIP_LP* lp /**< current LP data */
904  )
905 {
906  assert(sol != NULL);
907  assert(stat != NULL);
908  assert(tree != NULL);
909 
910  SCIPsetDebugMsg(set, "linking solution to pseudo solution\n");
911 
912  /* clear the old solution arrays */
913  SCIP_CALL( solClearArrays(sol) );
914 
915  /* link solution to pseudo solution */
916  sol->obj = SCIPlpGetPseudoObjval(lp, set, prob);
918  solStamp(sol, stat, tree, TRUE);
919 
920  SCIPsetDebugMsg(set, " -> objective value: %g\n", sol->obj);
921 
922  return SCIP_OKAY;
923 }
924 
925 /** copies current solution (LP or pseudo solution) into CIP solution by linking */
927  SCIP_SOL* sol, /**< primal CIP solution */
928  SCIP_SET* set, /**< global SCIP settings */
929  SCIP_STAT* stat, /**< problem statistics data */
930  SCIP_PROB* prob, /**< transformed problem data */
931  SCIP_TREE* tree, /**< branch and bound tree */
932  SCIP_LP* lp /**< current LP data */
933  )
934 {
935  assert(tree != NULL);
936 
937  SCIPsetDebugMsg(set, "linking solution to current solution\n");
938 
939  if( SCIPtreeHasCurrentNodeLP(tree) && SCIPlpIsSolved(lp) )
940  {
941  SCIP_CALL( SCIPsolLinkLPSol(sol, set, stat, prob, tree, lp) );
942  }
943  else
944  {
945  SCIP_CALL( SCIPsolLinkPseudoSol(sol, set, stat, prob, tree, lp) );
946  }
947 
948  return SCIP_OKAY;
949 }
950 
951 /** clears primal CIP solution */
953  SCIP_SOL* sol, /**< primal CIP solution */
954  SCIP_STAT* stat, /**< problem statistics data */
955  SCIP_TREE* tree /**< branch and bound tree */
956  )
957 {
958  assert(sol != NULL);
959 
960  SCIP_CALL( solClearArrays(sol) );
962  sol->obj = 0.0;
963  solStamp(sol, stat, tree, TRUE);
964 
965  return SCIP_OKAY;
966 }
967 
968 /** declares all entries in the primal CIP solution to be unknown */
970  SCIP_SOL* sol, /**< primal CIP solution */
971  SCIP_STAT* stat, /**< problem statistics data */
972  SCIP_TREE* tree /**< branch and bound tree */
973  )
974 {
975  assert(sol != NULL);
976 
977  SCIP_CALL( solClearArrays(sol) );
979  sol->obj = 0.0;
980  solStamp(sol, stat, tree, TRUE);
981 
982  return SCIP_OKAY;
983 }
984 
985 /** stores solution values of variables in solution's own array */
987  SCIP_SOL* sol, /**< primal CIP solution */
988  SCIP_SET* set, /**< global SCIP settings */
989  SCIP_PROB* prob /**< transformed problem data */
990  )
991 {
992  int v;
993 
994  assert(sol != NULL);
995  assert(prob != NULL);
996  assert(prob->nvars == 0 || prob->vars != NULL);
997 
998  if( !SCIPsolIsOriginal(sol) && sol->solorigin != SCIP_SOLORIGIN_ZERO
999  && sol->solorigin != SCIP_SOLORIGIN_UNKNOWN )
1000  {
1001  SCIPsetDebugMsg(set, "completing solution %p\n", (void*)sol);
1002 
1003  for( v = 0; v < prob->nvars; ++v )
1004  {
1005  SCIP_CALL( solUnlinkVar(sol, set, prob->vars[v]) );
1006  }
1007 
1008  sol->solorigin = SCIP_SOLORIGIN_ZERO;
1009  }
1010 
1011  return SCIP_OKAY;
1012 }
1013 
1014 /** sets value of variable in primal CIP solution */
1016  SCIP_SOL* sol, /**< primal CIP solution */
1017  SCIP_SET* set, /**< global SCIP settings */
1018  SCIP_STAT* stat, /**< problem statistics data */
1019  SCIP_TREE* tree, /**< branch and bound tree, or NULL */
1020  SCIP_VAR* var, /**< variable to add to solution */
1021  SCIP_Real val /**< solution value of variable */
1022  )
1023 {
1024  SCIP_Real oldval;
1025 
1026  assert(sol != NULL);
1027  assert(stat != NULL);
1028  assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL
1029  || sol->solorigin == SCIP_SOLORIGIN_ZERO
1032  || (sol->nodenum == stat->nnodes && sol->runnum == stat->nruns));
1033  assert(var != NULL);
1034  assert(SCIPisFinite(val));
1035 
1036  SCIPsetDebugMsg(set, "setting value of <%s> in solution %p to %g\n", SCIPvarGetName(var), (void*)sol, val);
1037 
1038  /* we want to store only values for non fixed variables (LOOSE or COLUMN); others have to be transformed */
1039  switch( SCIPvarGetStatus(var) )
1040  {
1042  if( SCIPsolIsOriginal(sol) )
1043  {
1044  oldval = solGetArrayVal(sol, var);
1045 
1046  if( !SCIPsetIsEQ(set, val, oldval) )
1047  {
1048  SCIP_Real obj;
1049  SCIP_Real objcont;
1050 
1051  SCIP_CALL( solSetArrayVal(sol, set, var, val) );
1052 
1053  /* update the objective value; we do not need to do this for partial solutions */
1054  if( !SCIPsolIsPartial(sol) )
1055  {
1056  /* an unknown solution value does not count towards the objective */
1057  obj = SCIPvarGetObj(var);
1058  if( oldval != SCIP_UNKNOWN ) /*lint !e777*/
1059  {
1060  objcont = obj * oldval;
1061 
1062  /* we want to use a clean infinity */
1063  if( SCIPsetIsInfinity(set, -objcont) || SCIPsetIsInfinity(set, sol->obj-objcont) )
1064  sol->obj = SCIPsetInfinity(set);
1065  else if( SCIPsetIsInfinity(set, objcont) || SCIPsetIsInfinity(set, -(sol->obj-objcont)) )
1066  sol->obj = -SCIPsetInfinity(set);
1067  else
1068  sol->obj -= objcont;
1069  }
1070  if( val != SCIP_UNKNOWN ) /*lint !e777*/
1071  {
1072  objcont = obj * val;
1073 
1074  /* we want to use a clean infinity */
1075  if( SCIPsetIsInfinity(set, objcont) || SCIPsetIsInfinity(set, sol->obj+objcont) )
1076  sol->obj = SCIPsetInfinity(set);
1077  else if( SCIPsetIsInfinity(set, objcont) || SCIPsetIsInfinity(set, -(sol->obj+objcont)) )
1078  sol->obj = -SCIPsetInfinity(set);
1079  else
1080  sol->obj += objcont;
1081  }
1082  }
1083 
1084  solStamp(sol, stat, tree, FALSE);
1085 
1086  }
1087  return SCIP_OKAY;
1088  }
1089  else
1090  return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetTransVar(var), val);
1091 
1092  case SCIP_VARSTATUS_LOOSE:
1093  case SCIP_VARSTATUS_COLUMN:
1094  assert(!SCIPsolIsOriginal(sol));
1095  assert(sol->solorigin != SCIP_SOLORIGIN_LPSOL || SCIPboolarrayGetVal(sol->valid, SCIPvarGetIndex(var))
1096  || sol->lpcount == stat->lpcount);
1097  oldval = solGetArrayVal(sol, var);
1098  if( !SCIPsetIsEQ(set, val, oldval) )
1099  {
1100  SCIP_Real obj;
1101  SCIP_Real objcont;
1102 
1103  SCIP_CALL( solSetArrayVal(sol, set, var, val) );
1104 
1105  /* update objective: an unknown solution value does not count towards the objective */
1106  obj = SCIPvarGetUnchangedObj(var);
1107 
1108  if( oldval != SCIP_UNKNOWN ) /*lint !e777*/
1109  {
1110  objcont = obj * oldval;
1111 
1112  /* we want to use a clean infinity */
1113  if( SCIPsetIsInfinity(set, -objcont) || SCIPsetIsInfinity(set, sol->obj-objcont) )
1114  sol->obj = SCIPsetInfinity(set);
1115  else if( SCIPsetIsInfinity(set, objcont) || SCIPsetIsInfinity(set, -(sol->obj-objcont)) )
1116  sol->obj = -SCIPsetInfinity(set);
1117  else
1118  sol->obj -= objcont;
1119  }
1120  if( val != SCIP_UNKNOWN ) /*lint !e777*/
1121  {
1122  objcont = obj * val;
1123 
1124  /* we want to use a clean infinity */
1125  if( SCIPsetIsInfinity(set, objcont) || SCIPsetIsInfinity(set, sol->obj+objcont) )
1126  sol->obj = SCIPsetInfinity(set);
1127  else if( SCIPsetIsInfinity(set, -objcont) || SCIPsetIsInfinity(set, -(sol->obj+objcont)) )
1128  sol->obj = -SCIPsetInfinity(set);
1129  else
1130  sol->obj += objcont;
1131  }
1132 
1133  solStamp(sol, stat, tree, FALSE);
1134  }
1135  return SCIP_OKAY;
1136 
1137  case SCIP_VARSTATUS_FIXED:
1138  assert(!SCIPsolIsOriginal(sol));
1139  oldval = SCIPvarGetLbGlobal(var);
1140  if( !SCIPsetIsEQ(set, val, oldval) )
1141  {
1142  SCIPerrorMessage("cannot set solution value for variable <%s> fixed to %.15g to different value %.15g\n",
1143  SCIPvarGetName(var), oldval, val);
1144  return SCIP_INVALIDDATA;
1145  }
1146  return SCIP_OKAY;
1147 
1148  case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
1149  assert(!SCIPsetIsZero(set, SCIPvarGetAggrScalar(var)));
1152 
1153  if( val == SCIP_UNKNOWN )/*lint !e777*/
1154  return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetAggrVar(var), val);
1155  if( SCIPsetIsInfinity(set, val) || SCIPsetIsInfinity(set, -val) )
1156  return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetAggrVar(var), SCIPvarGetAggrScalar(var) > 0 ? val : -val);
1157  else
1158  return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetAggrVar(var), (val - SCIPvarGetAggrConstant(var))/SCIPvarGetAggrScalar(var));
1159 
1161  if ( SCIPvarGetMultaggrNVars(var) == 1 )
1162  {
1163  SCIP_VAR** multaggrvars;
1164  SCIP_Real* multaggrscalars;
1165  SCIP_Real multaggrconstant;
1166 
1167  multaggrvars = SCIPvarGetMultaggrVars(var);
1168  multaggrscalars = SCIPvarGetMultaggrScalars(var);
1169  multaggrconstant = SCIPvarGetMultaggrConstant(var);
1170 
1171  if( SCIPsetIsInfinity(set, multaggrconstant) || SCIPsetIsInfinity(set, -multaggrconstant) )
1172  {
1173  if( (SCIPsetIsInfinity(set, multaggrconstant) && !SCIPsetIsInfinity(set, val))
1174  || (SCIPsetIsInfinity(set, -multaggrconstant) && !SCIPsetIsInfinity(set, -val)) )
1175  {
1176  SCIPerrorMessage("cannot set solution value for variable <%s> fixed to %.15g to different value %.15g\n",
1177  SCIPvarGetName(var), multaggrconstant, val);
1178  return SCIP_INVALIDDATA;
1179  }
1180  return SCIP_OKAY;
1181  }
1182  else
1183  {
1184  if( SCIPsetIsInfinity(set, val) || SCIPsetIsInfinity(set, -val) )
1185  return SCIPsolSetVal(sol, set, stat, tree, multaggrvars[0], multaggrscalars[0] > 0 ? val : -val);
1186  else
1187  return SCIPsolSetVal(sol, set, stat, tree, multaggrvars[0], (val - multaggrconstant)/multaggrscalars[0]);
1188  }
1189  }
1190  SCIPerrorMessage("cannot set solution value for multiple aggregated variable\n");
1191  return SCIP_INVALIDDATA;
1192 
1195 
1196  if( val == SCIP_UNKNOWN )/*lint !e777*/
1197  return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetNegationVar(var), val);
1198  else if( SCIPsetIsInfinity(set, val) || SCIPsetIsInfinity(set, -val) )
1199  return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetNegationVar(var), -val);
1200  else
1201  return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetNegationVar(var), SCIPvarGetNegationConstant(var) - val);
1202 
1203  default:
1204  SCIPerrorMessage("unknown variable status\n");
1205  return SCIP_INVALIDDATA;
1206  }
1207 }
1208 
1209 /** increases value of variable in primal CIP solution */
1211  SCIP_SOL* sol, /**< primal CIP solution */
1212  SCIP_SET* set, /**< global SCIP settings */
1213  SCIP_STAT* stat, /**< problem statistics data */
1214  SCIP_TREE* tree, /**< branch and bound tree */
1215  SCIP_VAR* var, /**< variable to increase solution value for */
1216  SCIP_Real incval /**< increment for solution value of variable */
1217  )
1218 {
1219  SCIP_Real oldval;
1220 
1221  assert(sol != NULL);
1222  assert(stat != NULL);
1223  assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL
1224  || sol->solorigin == SCIP_SOLORIGIN_ZERO
1225  || (sol->nodenum == stat->nnodes && sol->runnum == stat->nruns));
1226  assert(var != NULL);
1227  assert(!SCIPsetIsInfinity(set, incval) && !SCIPsetIsInfinity(set, -incval));
1228 
1229  SCIPsetDebugMsg(set, "increasing value of <%s> in solution %p by %g\n", SCIPvarGetName(var), (void*)sol, incval);
1230 
1231  if( SCIPsetIsZero(set, incval) )
1232  return SCIP_OKAY;
1233 
1234  assert(sol->solorigin != SCIP_SOLORIGIN_LPSOL || SCIPboolarrayGetVal(sol->valid, SCIPvarGetIndex(var))
1235  || sol->lpcount == stat->lpcount);
1236 
1237  oldval = solGetArrayVal(sol, var);
1238  if( SCIPsetIsInfinity(set, oldval) || SCIPsetIsInfinity(set, -oldval) )
1239  return SCIP_OKAY;
1240 
1241  /* we want to store only values for non fixed variables (LOOSE or COLUMN); others have to be transformed */
1242  /* @todo: handle strange cases, such as sums that yield infinite values */
1243  switch( SCIPvarGetStatus(var) )
1244  {
1246  if( SCIPsolIsOriginal(sol) )
1247  {
1248  SCIP_CALL( solIncArrayVal(sol, set, var, incval) );
1249  sol->obj += SCIPvarGetObj(var) * incval;
1250  solStamp(sol, stat, tree, FALSE);
1251  return SCIP_OKAY;
1252  }
1253  else
1254  return SCIPsolIncVal(sol, set, stat, tree, SCIPvarGetTransVar(var), incval);
1255 
1256  case SCIP_VARSTATUS_LOOSE:
1257  case SCIP_VARSTATUS_COLUMN:
1258  assert(!SCIPsolIsOriginal(sol));
1259  SCIP_CALL( solIncArrayVal(sol, set, var, incval) );
1260  sol->obj += SCIPvarGetUnchangedObj(var) * incval;
1261  solStamp(sol, stat, tree, FALSE);
1262  return SCIP_OKAY;
1263 
1264  case SCIP_VARSTATUS_FIXED:
1265  SCIPerrorMessage("cannot increase solution value for fixed variable\n");
1266  return SCIP_INVALIDDATA;
1267 
1268  case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
1269  assert(!SCIPsetIsZero(set, SCIPvarGetAggrScalar(var)));
1270  return SCIPsolIncVal(sol, set, stat, tree, SCIPvarGetAggrVar(var), incval/SCIPvarGetAggrScalar(var));
1271 
1273  SCIPerrorMessage("cannot increase solution value for multiple aggregated variable\n");
1274  return SCIP_INVALIDDATA;
1275 
1277  return SCIPsolIncVal(sol, set, stat, tree, SCIPvarGetNegationVar(var), -incval);
1278 
1279  default:
1280  SCIPerrorMessage("unknown variable status\n");
1281  return SCIP_INVALIDDATA;
1282  }
1283 }
1284 
1285 /** returns value of variable in primal CIP solution */
1287  SCIP_SOL* sol, /**< primal CIP solution */
1288  SCIP_SET* set, /**< global SCIP settings */
1289  SCIP_STAT* stat, /**< problem statistics data */
1290  SCIP_VAR* var /**< variable to get value for */
1291  )
1292 {
1293  SCIP_VAR** vars;
1294  SCIP_Real* scalars;
1295  SCIP_Real solval;
1296  SCIP_Real solvalsum;
1297  int nvars;
1298  int i;
1299 
1300  assert(sol != NULL);
1301  assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL
1302  || sol->solorigin == SCIP_SOLORIGIN_ZERO
1305  || (sol->nodenum == stat->nnodes && sol->runnum == stat->nruns));
1306  assert(var != NULL);
1307 
1308  /* if the value of a transformed variable in an original solution is requested, we need to project the variable back
1309  * to the original space, the opposite case is handled below
1310  */
1311  if( SCIPsolIsOriginal(sol) && SCIPvarIsTransformed(var) )
1312  {
1313  SCIP_RETCODE retcode;
1314  SCIP_VAR* origvar;
1315  SCIP_Real scalar;
1316  SCIP_Real constant;
1317 
1318  /* we cannot get the value of a transformed variable for a solution that lives in the original problem space
1319  * -> get the corresponding original variable first
1320  */
1321  origvar = var;
1322  scalar = 1.0;
1323  constant = 0.0;
1324  retcode = SCIPvarGetOrigvarSum(&origvar, &scalar, &constant);
1325  if ( retcode != SCIP_OKAY )
1326  return SCIP_INVALID;
1327  if( origvar == NULL )
1328  {
1329  /* the variable has no original counterpart: in the original solution, it has a value of zero */
1330  return 0.0;
1331  }
1332  assert(!SCIPvarIsTransformed(origvar));
1333  return scalar * SCIPsolGetVal(sol, set, stat, origvar) + constant;
1334  }
1335 
1336  /* only values for non fixed variables (LOOSE or COLUMN) are stored; others have to be transformed */
1337  switch( SCIPvarGetStatus(var) )
1338  {
1340  if( SCIPsolIsOriginal(sol) )
1341  return solGetArrayVal(sol, var);
1342  else
1343  return SCIPsolGetVal(sol, set, stat, SCIPvarGetTransVar(var));
1344 
1345  case SCIP_VARSTATUS_LOOSE:
1346  case SCIP_VARSTATUS_COLUMN:
1347  assert(!SCIPsolIsOriginal(sol));
1349  || sol->lpcount == stat->lpcount);
1350  return solGetArrayVal(sol, var);
1351 
1352  case SCIP_VARSTATUS_FIXED:
1353  assert(!SCIPsolIsOriginal(sol));
1354  assert(SCIPvarGetLbGlobal(var) == SCIPvarGetUbGlobal(var)); /*lint !e777*/
1355  assert(SCIPvarGetLbLocal(var) == SCIPvarGetUbLocal(var)); /*lint !e777*/
1356  assert(SCIPvarGetLbGlobal(var) == SCIPvarGetLbLocal(var)); /*lint !e777*/
1357  return SCIPvarGetLbGlobal(var);
1358 
1359  case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
1360  solval = SCIPsolGetVal(sol, set, stat, SCIPvarGetAggrVar(var));
1361  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
1362  return SCIP_UNKNOWN;
1363  if( SCIPsetIsInfinity(set, solval) || SCIPsetIsInfinity(set, -solval) )
1364  {
1365  if( SCIPvarGetAggrScalar(var) * solval > 0.0 )
1366  return SCIPsetInfinity(set);
1367  if( SCIPvarGetAggrScalar(var) * solval < 0.0 )
1368  return -SCIPsetInfinity(set);
1369  }
1370  return SCIPvarGetAggrScalar(var) * solval + SCIPvarGetAggrConstant(var);
1371 
1373  nvars = SCIPvarGetMultaggrNVars(var);
1374  vars = SCIPvarGetMultaggrVars(var);
1375  scalars = SCIPvarGetMultaggrScalars(var);
1376  solvalsum = SCIPvarGetMultaggrConstant(var);
1377  for( i = 0; i < nvars; ++i )
1378  {
1379  solval = SCIPsolGetVal(sol, set, stat, vars[i]);
1380  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
1381  return SCIP_UNKNOWN;
1382  if( SCIPsetIsInfinity(set, solval) || SCIPsetIsInfinity(set, -solval) )
1383  {
1384  if( scalars[i] * solval > 0.0 )
1385  return SCIPsetInfinity(set);
1386  if( scalars[i] * solval < 0.0 )
1387  return -SCIPsetInfinity(set);
1388  }
1389  solvalsum += scalars[i] * solval;
1390  }
1391  return solvalsum;
1392 
1394  solval = SCIPsolGetVal(sol, set, stat, SCIPvarGetNegationVar(var));
1395  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
1396  return SCIP_UNKNOWN;
1397  if( SCIPsetIsInfinity(set, solval) )
1398  return -SCIPsetInfinity(set);
1399  if( SCIPsetIsInfinity(set, -solval) )
1400  return SCIPsetInfinity(set);
1401  return SCIPvarGetNegationConstant(var) - solval;
1402 
1403  default:
1404  SCIPerrorMessage("unknown variable status\n");
1405  SCIPABORT();
1406  return 0.0; /*lint !e527*/
1407  }
1408 }
1409 
1410 /** returns value of variable in primal ray represented by primal CIP solution */
1412  SCIP_SOL* sol, /**< primal CIP solution, representing a primal ray */
1413  SCIP_SET* set, /**< global SCIP settings */
1414  SCIP_STAT* stat, /**< problem statistics data */
1415  SCIP_VAR* var /**< variable to get value for */
1416  )
1417 {
1418  SCIP_VAR** vars;
1419  SCIP_Real* scalars;
1420  SCIP_Real solval;
1421  SCIP_Real solvalsum;
1422  int nvars;
1423  int i;
1424 
1425  assert(sol != NULL);
1426  assert(sol->solorigin == SCIP_SOLORIGIN_ZERO);
1427  assert(var != NULL);
1428 
1429  /* only values for non fixed variables (LOOSE or COLUMN) are stored; others have to be transformed */
1430  switch( SCIPvarGetStatus(var) )
1431  {
1433  return SCIPsolGetRayVal(sol, set, stat, SCIPvarGetTransVar(var));
1434 
1435  case SCIP_VARSTATUS_LOOSE:
1436  case SCIP_VARSTATUS_COLUMN:
1437  return solGetArrayVal(sol, var);
1438 
1439  case SCIP_VARSTATUS_FIXED:
1440  assert(!SCIPsolIsOriginal(sol));
1441  assert(SCIPvarGetLbGlobal(var) == SCIPvarGetUbGlobal(var)); /*lint !e777*/
1442  assert(SCIPvarGetLbLocal(var) == SCIPvarGetUbLocal(var)); /*lint !e777*/
1443  assert(SCIPvarGetLbGlobal(var) == SCIPvarGetLbLocal(var)); /*lint !e777*/
1444  return 0.0; /* constants are ignored for computing the ray direction */
1445 
1446  case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
1447  solval = SCIPsolGetRayVal(sol, set, stat, SCIPvarGetAggrVar(var));
1448  assert(solval != SCIP_UNKNOWN); /*lint !e777*/
1449  assert(!SCIPsetIsInfinity(set, REALABS(solval)));
1450  return SCIPvarGetAggrScalar(var) * solval; /* constants are ignored for computing the ray direction */
1451 
1453  nvars = SCIPvarGetMultaggrNVars(var);
1454  vars = SCIPvarGetMultaggrVars(var);
1455  scalars = SCIPvarGetMultaggrScalars(var);
1456  solvalsum = 0.0; /* constants are ignored for computing the ray direction */
1457  for( i = 0; i < nvars; ++i )
1458  {
1459  solval = SCIPsolGetRayVal(sol, set, stat, vars[i]);
1460  assert(solval != SCIP_UNKNOWN ); /*lint !e777*/
1461  assert(!SCIPsetIsInfinity(set, REALABS(solval)));
1462  solvalsum += scalars[i] * solval;
1463  }
1464  return solvalsum;
1465 
1467  solval = SCIPsolGetRayVal(sol, set, stat, SCIPvarGetNegationVar(var));
1468  assert(solval != SCIP_UNKNOWN); /*lint !e777*/
1469  assert(!SCIPsetIsInfinity(set, REALABS(solval)));
1470  return -solval; /* constants are ignored for computing the ray direction */
1471 
1472  default:
1473  SCIPerrorMessage("unknown variable status\n");
1474  SCIPABORT();
1475  return 0.0; /*lint !e527*/
1476  }
1477 }
1478 
1479 /** gets objective value of primal CIP solution in transformed problem */
1481  SCIP_SOL* sol, /**< primal CIP solution */
1482  SCIP_SET* set, /**< global SCIP settings */
1483  SCIP_PROB* transprob, /**< tranformed problem data */
1484  SCIP_PROB* origprob /**< original problem data */
1485  )
1486 {
1487  assert(sol != NULL);
1488 
1489  /* for original solutions, sol->obj contains the external objective value */
1490  if( SCIPsolIsOriginal(sol) )
1491  return SCIPprobInternObjval(transprob, origprob, set, sol->obj);
1492  else
1493  return sol->obj;
1494 }
1495 
1496 /** updates primal solutions after a change in a variable's objective value */
1498  SCIP_SOL* sol, /**< primal CIP solution */
1499  SCIP_VAR* var, /**< problem variable */
1500  SCIP_Real oldobj, /**< old objective value */
1501  SCIP_Real newobj /**< new objective value */
1502  )
1503 {
1504  SCIP_Real solval;
1505 
1506  assert(sol != NULL);
1507  assert(!SCIPsolIsOriginal(sol));
1509 
1510  solval = solGetArrayVal(sol, var);
1511  if( solval != SCIP_UNKNOWN ) /*lint !e777*/
1512  sol->obj += (newobj - oldobj) * solval;
1513 }
1514 
1515 /* mark the given solution as partial solution */
1517  SCIP_SOL* sol, /**< primal CIP solution */
1518  SCIP_SET* set, /**< global SCIP settings */
1519  SCIP_STAT* stat, /**< problem statistics */
1520  SCIP_VAR** vars, /**< problem variables */
1521  int nvars /**< number of problem variables */
1522  )
1523 {
1524  SCIP_Real* vals;
1525  int v;
1526 
1527  assert(sol != NULL);
1528  assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL);
1529  assert(nvars == 0 || vars != NULL);
1530 
1531  if( nvars == 0 )
1532  return SCIP_OKAY;;
1533 
1534  SCIP_CALL( SCIPsetAllocBufferArray(set, &vals, nvars) );
1535 
1536  /* get values */
1537  for( v = 0; v < nvars; v++ )
1538  {
1539  assert(!SCIPvarIsTransformed(vars[v]));
1540  vals[v] = SCIPsolGetVal(sol, set, stat, vars[v]);
1541  }
1542 
1543  /* change origin to partial */
1545 
1546  /* set values */
1547  for( v = 0; v < nvars; v++ )
1548  {
1549  int idx = SCIPvarGetIndex(vars[v]);
1550 
1551  if( vals[v] != SCIP_UNKNOWN ) /*lint !e777*/
1552  {
1553  /* from now on, variable must not be deleted */
1554  SCIPvarMarkNotDeletable(vars[v]);
1555 
1556  /* mark the variable valid */
1557  SCIP_CALL( SCIPboolarraySetVal(sol->valid, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, TRUE) );
1558 
1559  /* set the value in the solution array */
1560  SCIP_CALL( SCIPrealarraySetVal(sol->vals, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, vals[v]) );
1561  }
1562  else
1563  {
1564  /* mark the variable invalid */
1565  SCIP_CALL( SCIPboolarraySetVal(sol->valid, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, FALSE) );
1566  }
1567  }
1568 
1569  /* free buffer */
1570  SCIPsetFreeBufferArray(set, &vals);
1571 
1572  return SCIP_OKAY;
1573 }
1574 
1575 /** checks primal CIP solution for feasibility
1576  *
1577  * @note The difference between SCIPsolCheck() and SCIPcheckSolOrig() is that modifiable constraints are handled
1578  * differently. There might be some variables which do not have an original counter part (e.g. in
1579  * branch-and-price). Therefore, modifiable constraints can not be double-checked in the original space.
1580  */
1582  SCIP_SOL* sol, /**< primal CIP solution */
1583  SCIP_SET* set, /**< global SCIP settings */
1584  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1585  BMS_BLKMEM* blkmem, /**< block memory */
1586  SCIP_STAT* stat, /**< problem statistics */
1587  SCIP_PROB* prob, /**< transformed problem data */
1588  SCIP_Bool printreason, /**< Should all reasons of violations be printed? */
1589  SCIP_Bool completely, /**< Should all violations be checked? */
1590  SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
1591  SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
1592  SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
1593  SCIP_Bool* feasible /**< stores whether solution is feasible */
1594  )
1595 {
1596  SCIP_RESULT result;
1597  int h;
1598 
1599  assert(sol != NULL);
1600  assert(!SCIPsolIsOriginal(sol));
1601  assert(set != NULL);
1602  assert(prob != NULL);
1603  assert(feasible != NULL);
1604 
1605  SCIPsetDebugMsg(set, "checking solution with objective value %g (nodenum=%" SCIP_LONGINT_FORMAT ", origin=%u)\n",
1606  sol->obj, sol->nodenum, sol->solorigin);
1607 
1608  *feasible = TRUE;
1609 
1610  if( !printreason )
1611  completely = FALSE;
1612 
1613  /* check whether the solution respects the global bounds of the variables */
1614  if( checkbounds || sol->hasinfval )
1615  {
1616  int v;
1617 
1618  for( v = 0; v < prob->nvars && (*feasible || completely); ++v )
1619  {
1620  SCIP_VAR* var;
1621  SCIP_Real solval;
1622 
1623  var = prob->vars[v];
1624  solval = SCIPsolGetVal(sol, set, stat, var);
1625 
1626  if( solval != SCIP_UNKNOWN ) /*lint !e777*/
1627  {
1628  SCIP_Real lb;
1629  SCIP_Real ub;
1630 
1631  lb = SCIPvarGetLbGlobal(var);
1632  ub = SCIPvarGetUbGlobal(var);
1633 
1634  /* if we have to check bound and one of the current bounds is violated */
1635  if( checkbounds && ((!SCIPsetIsInfinity(set, -lb) && SCIPsetIsFeasLT(set, solval, lb))
1636  || (!SCIPsetIsInfinity(set, ub) && SCIPsetIsFeasGT(set, solval, ub))) )
1637  {
1638  *feasible = FALSE;
1639 
1640  if( printreason )
1641  {
1642  SCIPmessagePrintInfo(messagehdlr, "solution value %g violates bounds of <%s>[%g,%g] by %g\n", solval, SCIPvarGetName(var),
1643  SCIPvarGetLbGlobal(var), SCIPvarGetUbGlobal(var), MAX(lb - solval, 0.0) + MAX(solval - ub, 0.0));
1644  }
1645 #ifdef SCIP_DEBUG
1646  else
1647  {
1648  SCIPsetDebugMsgPrint(set, " -> solution value %g violates bounds of <%s>[%g,%g]\n", solval, SCIPvarGetName(var),
1650  }
1651 #endif
1652  }
1653 
1654  /* check whether there are infinite variable values that lead to an objective value of +infinity */
1655  if( *feasible && sol->hasinfval )
1656  {
1657  *feasible = *feasible && (!SCIPsetIsInfinity(set, solval) || SCIPsetIsLE(set, SCIPvarGetObj(var), 0.0) );
1658  *feasible = *feasible && (!SCIPsetIsInfinity(set, -solval) || SCIPsetIsGE(set, SCIPvarGetObj(var), 0.0) );
1659 
1660  if( ((SCIPsetIsInfinity(set, solval) && SCIPsetIsGT(set, SCIPvarGetObj(var), 0.0)) || (SCIPsetIsInfinity(set, -solval) && SCIPsetIsLT(set, SCIPvarGetObj(var), 0.0))) )
1661  {
1662  if( printreason )
1663  {
1664  SCIPmessagePrintInfo(messagehdlr, "infinite solution value %g for variable <%s> with obj %g implies objective value +infinity\n",
1665  solval, SCIPvarGetName(var), SCIPvarGetObj(var));
1666  }
1667 #ifdef SCIP_DEBUG
1668  else
1669  {
1670  SCIPsetDebugMsgPrint(set, "infinite solution value %g for variable <%s> with obj %g implies objective value +infinity\n",
1671  solval, SCIPvarGetName(var), SCIPvarGetObj(var));
1672  }
1673 #endif
1674  }
1675  }
1676  }
1677  }
1678  }
1679 
1680  /* check whether the solution fulfills all constraints */
1681  for( h = 0; h < set->nconshdlrs && (*feasible || completely); ++h )
1682  {
1683  SCIP_CALL( SCIPconshdlrCheck(set->conshdlrs[h], blkmem, set, stat, sol,
1684  checkintegrality, checklprows, printreason, completely, &result) );
1685  *feasible = *feasible && (result == SCIP_FEASIBLE);
1686 
1687 #ifdef SCIP_DEBUG
1688  if( !(*feasible) )
1689  {
1690  SCIPdebugPrintf(" -> infeasibility detected in constraint handler <%s>\n",
1691  SCIPconshdlrGetName(set->conshdlrs[h]));
1692  }
1693 #endif
1694  }
1695 
1696 
1697  return SCIP_OKAY;
1698 }
1699 
1700 /** try to round given solution */
1702  SCIP_SOL* sol, /**< primal solution */
1703  SCIP_SET* set, /**< global SCIP settings */
1704  SCIP_STAT* stat, /**< problem statistics data */
1705  SCIP_PROB* prob, /**< transformed problem data */
1706  SCIP_TREE* tree, /**< branch and bound tree */
1707  SCIP_Bool* success /**< pointer to store whether rounding was successful */
1708  )
1709 {
1710  int nvars;
1711  int v;
1712 
1713  assert(sol != NULL);
1714  assert(!SCIPsolIsOriginal(sol));
1715  assert(prob != NULL);
1716  assert(prob->transformed);
1717  assert(success != NULL);
1718 
1719  /* round all roundable fractional variables in the corresponding direction as long as no unroundable var was found */
1720  nvars = prob->nbinvars + prob->nintvars;
1721  for( v = 0; v < nvars; ++v )
1722  {
1723  SCIP_VAR* var;
1724  SCIP_Real solval;
1725  SCIP_Bool mayrounddown;
1726  SCIP_Bool mayroundup;
1727 
1728  var = prob->vars[v];
1731  || sol->lpcount == stat->lpcount);
1732  solval = solGetArrayVal(sol, var);
1733 
1734  /* solutions with unknown entries cannot be rounded */
1735  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
1736  break;
1737 
1738  /* if solution value is already integral with feastol, continue */
1739  if( SCIPsetIsFeasIntegral(set, solval) )
1740  continue;
1741 
1742  /* get rounding possibilities */
1743  mayrounddown = SCIPvarMayRoundDown(var);
1744  mayroundup = SCIPvarMayRoundUp(var);
1745 
1746  /* choose rounding direction */
1747  if( mayrounddown && mayroundup )
1748  {
1749  /* we can round in both directions: round in objective function direction */
1750  if( SCIPvarGetUnchangedObj(var) >= 0.0 )
1751  solval = SCIPsetFeasFloor(set, solval);
1752  else
1753  solval = SCIPsetFeasCeil(set, solval);
1754  }
1755  else if( mayrounddown )
1756  solval = SCIPsetFeasFloor(set, solval);
1757  else if( mayroundup )
1758  solval = SCIPsetFeasCeil(set, solval);
1759  else
1760  break;
1761 
1762  /* store new solution value */
1763  SCIP_CALL( SCIPsolSetVal(sol, set, stat, tree, var, solval) );
1764  }
1765 
1766  /* check, if rounding was successful */
1767  *success = (v == nvars);
1768 
1769  return SCIP_OKAY;
1770 }
1771 
1772 /** updates the solution value sums in variables by adding the value in the given solution */
1774  SCIP_SOL* sol, /**< primal CIP solution */
1775  SCIP_SET* set, /**< global SCIP settings */
1776  SCIP_STAT* stat, /**< problem statistics data */
1777  SCIP_PROB* prob, /**< transformed problem data */
1778  SCIP_Real weight /**< weight of solution in weighted average */
1779  )
1780 {
1781  SCIP_Real solval;
1782  int v;
1783 
1784  assert(sol != NULL);
1785  assert(!SCIPsolIsOriginal(sol));
1786  assert(0.0 <= weight && weight <= 1.0);
1787 
1788  for( v = 0; v < prob->nvars; ++v )
1789  {
1790  assert(prob->vars[v] != NULL);
1791  solval = SCIPsolGetVal(sol, set, stat, prob->vars[v]);
1792  if( solval != SCIP_UNKNOWN ) /*lint !e777*/
1793  {
1794  prob->vars[v]->primsolavg *= (1.0-weight);
1795  prob->vars[v]->primsolavg += weight*solval;
1796  }
1797  }
1798 }
1799 
1800 /** retransforms solution to original problem space */
1802  SCIP_SOL* sol, /**< primal CIP solution */
1803  SCIP_SET* set, /**< global SCIP settings */
1804  SCIP_STAT* stat, /**< problem statistics data */
1805  SCIP_PROB* origprob, /**< original problem */
1806  SCIP_PROB* transprob, /**< transformed problem */
1807  SCIP_Bool* hasinfval /**< pointer to store whether the solution has infinite values */
1808  )
1809 {
1810  SCIP_VAR** transvars;
1811  SCIP_VAR** vars;
1812  SCIP_VAR** activevars;
1813  SCIP_Real* solvals;
1814  SCIP_Real* activevals;
1815  SCIP_Real* transsolvals;
1816  SCIP_Real constant;
1817  int requiredsize;
1818  int ntransvars;
1819  int nactivevars;
1820  int nvars;
1821  int v;
1822  int i;
1823 
1824  assert(sol != NULL);
1825  assert(sol->solorigin == SCIP_SOLORIGIN_ZERO);
1826  assert(origprob != NULL);
1827  assert(transprob != NULL);
1828  assert(hasinfval != NULL);
1829  assert(!origprob->transformed);
1830  assert(transprob->transformed);
1831 
1832  *hasinfval = FALSE;
1833 
1834  /* This method was a performance bottleneck when retransforming a solution during presolving, before flattening the
1835  * aggregation graph. In that case, calling SCIPsolGetVal() on the original variable consumed too much
1836  * time. Therefore, we now first compute the active representation of each original variable using
1837  * SCIPvarGetActiveRepresentatives(), which is much faster, and sum up the solution values of the active variables by
1838  * hand for each original variable.
1839  */
1840  vars = origprob->vars;
1841  nvars = origprob->nvars;
1842  transvars = transprob->vars;
1843  ntransvars = transprob->nvars;
1844 
1845  /* allocate temporary memory for getting the active representation of the original variables, buffering the solution
1846  * values of all active variables and storing the original solution values
1847  */
1848  SCIP_CALL( SCIPsetAllocBufferArray(set, &transsolvals, ntransvars + 1) );
1849  SCIP_CALL( SCIPsetAllocBufferArray(set, &activevars, ntransvars + 1) );
1850  SCIP_CALL( SCIPsetAllocBufferArray(set, &activevals, ntransvars + 1) );
1851  SCIP_CALL( SCIPsetAllocBufferArray(set, &solvals, nvars) );
1852  assert(transsolvals != NULL); /* for flexelint */
1853  assert(solvals != NULL); /* for flexelint */
1854 
1855  /* get the solution values of all active variables */
1856  for( v = 0; v < ntransvars; ++v )
1857  {
1858  transsolvals[v] = SCIPsolGetVal(sol, set, stat, transvars[v]);
1859  }
1860 
1861  /* get the solution in original problem variables */
1862  for( v = 0; v < nvars; ++v )
1863  {
1864  activevars[0] = vars[v];
1865  activevals[0] = 1.0;
1866  nactivevars = 1;
1867  constant = 0.0;
1868 
1869  /* get active representation of the original variable */
1870  SCIP_CALL( SCIPvarGetActiveRepresentatives(set, activevars, activevals, &nactivevars, ntransvars + 1, &constant,
1871  &requiredsize, TRUE) );
1872  assert(requiredsize <= ntransvars);
1873 
1874  /* compute solution value of the original variable */
1875  solvals[v] = constant;
1876  for( i = 0; i < nactivevars; ++i )
1877  {
1878  assert(0 <= SCIPvarGetProbindex(activevars[i]) && SCIPvarGetProbindex(activevars[i]) < ntransvars);
1879  assert(!SCIPsetIsInfinity(set, -solvals[v]) || !SCIPsetIsInfinity(set, activevals[i] * transsolvals[SCIPvarGetProbindex(activevars[i])]));
1880  assert(!SCIPsetIsInfinity(set, solvals[v]) || !SCIPsetIsInfinity(set, -activevals[i] * transsolvals[SCIPvarGetProbindex(activevars[i])]));
1881  solvals[v] += activevals[i] * transsolvals[SCIPvarGetProbindex(activevars[i])];
1882  }
1883 
1884  if( SCIPsetIsInfinity(set, solvals[v]) )
1885  {
1886  solvals[v] = SCIPsetInfinity(set);
1887  *hasinfval = TRUE;
1888  }
1889  else if( SCIPsetIsInfinity(set, -solvals[v]) )
1890  {
1891  solvals[v] = -SCIPsetInfinity(set);
1892  *hasinfval = TRUE;
1893  }
1894  }
1895 
1896  /* clear the solution and convert it into original space */
1897  SCIP_CALL( solClearArrays(sol) );
1899  sol->obj = origprob->objoffset;
1900 
1901  /* reinsert the values of the original variables */
1902  for( v = 0; v < nvars; ++v )
1903  {
1904  if( !SCIPsetIsZero(set, solvals[v]) )
1905  {
1906  SCIP_CALL( solSetArrayVal(sol, set, vars[v], solvals[v]) );
1907  if( solvals[v] != SCIP_UNKNOWN ) /*lint !e777*/
1908  sol->obj += SCIPvarGetObj(vars[v]) * solvals[v];
1909  }
1910  }
1911 
1912  /**@todo remember the variables without original counterpart (priced variables) in the solution */
1913 
1914  /* free temporary memory */
1915  SCIPsetFreeBufferArray(set, &solvals);
1916  SCIPsetFreeBufferArray(set, &activevals);
1917  SCIPsetFreeBufferArray(set, &activevars);
1918  SCIPsetFreeBufferArray(set, &transsolvals);
1919 
1920  return SCIP_OKAY;
1921 }
1922 
1923 /** recomputes the objective value of an original solution, e.g., when transferring solutions
1924  * from the solution pool (objective coefficients might have changed in the meantime)
1925  */
1927  SCIP_SOL* sol, /**< primal CIP solution */
1928  SCIP_SET* set, /**< global SCIP settings */
1929  SCIP_STAT* stat, /**< problem statistics data */
1930  SCIP_PROB* origprob /**< original problem */
1931  )
1932 {
1933  SCIP_VAR** vars;
1934  SCIP_Real solval;
1935  int nvars;
1936  int v;
1937 
1938  assert(sol != NULL);
1939  assert(SCIPsolIsOriginal(sol));
1940  assert(origprob != NULL);
1941 
1942  vars = origprob->vars;
1943  nvars = origprob->nvars;
1944 
1945  /* recompute the objective value */
1946  sol->obj = SCIPprobGetObjoffset(origprob);
1947  for( v = 0; v < nvars; ++v )
1948  {
1949  solval = SCIPsolGetVal(sol, set, stat, vars[v]);
1950  if( !SCIPsetIsZero(set, solval) && solval != SCIP_UNKNOWN ) /*lint !e777*/
1951  {
1952  sol->obj += SCIPvarGetUnchangedObj(vars[v]) * solval;
1953  }
1954  }
1955 
1956  if( SCIPsetIsInfinity(set, -sol->obj) )
1957  sol->obj = -SCIPsetInfinity(set);
1958 }
1959 
1960 /** returns whether the given solutions are equal */
1962  SCIP_SOL* sol1, /**< first primal CIP solution */
1963  SCIP_SOL* sol2, /**< second primal CIP solution */
1964  SCIP_SET* set, /**< global SCIP settings */
1965  SCIP_STAT* stat, /**< problem statistics data */
1966  SCIP_PROB* origprob, /**< original problem */
1967  SCIP_PROB* transprob /**< transformed problem after presolve, or NULL if both solution are
1968  * defined in the original problem space */
1969  )
1970 {
1971  SCIP_PROB* prob;
1972  SCIP_Real obj1;
1973  SCIP_Real obj2;
1974  int v;
1975 
1976  assert(sol1 != NULL);
1977  assert(sol2 != NULL);
1978  assert((SCIPsolIsOriginal(sol1) && SCIPsolIsOriginal(sol2)) || transprob != NULL);
1979 
1980  /* if both solutions are original or both are transformed, take the objective values stored in the solutions */
1981  if( SCIPsolIsOriginal(sol1) == SCIPsolIsOriginal(sol2) )
1982  {
1983  obj1 = sol1->obj;
1984  obj2 = sol2->obj;
1985  }
1986  /* one solution is original and the other not, so we have to get for both the objective in the transformed problem */
1987  else
1988  {
1989  obj1 = SCIPsolGetObj(sol1, set, transprob, origprob);
1990  obj2 = SCIPsolGetObj(sol2, set, transprob, origprob);
1991  }
1992 
1993  /* solutions with different objective values cannot be the same */
1994  if( !SCIPsetIsEQ(set, obj1, obj2) )
1995  return FALSE;
1996 
1997  /* if one of the solutions is defined in the original space, the comparison has to be performed in the original
1998  * space
1999  */
2000  prob = transprob;
2001  if( SCIPsolIsOriginal(sol1) || SCIPsolIsOriginal(sol2) )
2002  prob = origprob;
2003  assert(prob != NULL);
2004 
2005  /* compare each variable value */
2006  for( v = 0; v < prob->nvars; ++v )
2007  {
2008  SCIP_Real val1;
2009  SCIP_Real val2;
2010 
2011  val1 = SCIPsolGetVal(sol1, set, stat, prob->vars[v]);
2012  val2 = SCIPsolGetVal(sol2, set, stat, prob->vars[v]);
2013  if( !SCIPsetIsEQ(set, val1, val2) )
2014  return FALSE;
2015  }
2016 
2017  return TRUE;
2018 }
2019 
2020 /** outputs non-zero elements of solution to file stream */
2022  SCIP_SOL* sol, /**< primal CIP solution */
2023  SCIP_SET* set, /**< global SCIP settings */
2024  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
2025  SCIP_STAT* stat, /**< problem statistics data */
2026  SCIP_PROB* prob, /**< problem data (original or transformed) */
2027  SCIP_PROB* transprob, /**< transformed problem data or NULL (to display priced variables) */
2028  FILE* file, /**< output file (or NULL for standard output) */
2029  SCIP_Bool mipstart, /**< should only discrete variables be printed? */
2030  SCIP_Bool printzeros /**< should variables set to zero be printed? */
2031  )
2032 {
2033  SCIP_Real solval;
2034  int v;
2035 
2036  assert(sol != NULL);
2037  assert(prob != NULL);
2038  assert(SCIPsolIsOriginal(sol) || prob->transformed || transprob != NULL);
2039  assert(!mipstart || !SCIPsolIsPartial(sol));
2040 
2041  /* display variables of problem data */
2042  for( v = 0; v < prob->nfixedvars; ++v )
2043  {
2044  assert(prob->fixedvars[v] != NULL);
2045 
2046  /* skip non-discrete variables in a mip start */
2047  if( mipstart && !SCIPvarIsIntegral(prob->fixedvars[v]) )
2048  continue;
2049 
2050  solval = SCIPsolGetVal(sol, set, stat, prob->fixedvars[v]);
2051  if( printzeros || mipstart
2052  || (sol->solorigin != SCIP_SOLORIGIN_PARTIAL && !SCIPsetIsZero(set, solval))
2053  || (sol->solorigin == SCIP_SOLORIGIN_PARTIAL && solval != SCIP_UNKNOWN) ) /*lint !e777*/
2054  {
2055  SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(prob->fixedvars[v]));
2056  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
2057  SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
2058  else if( SCIPsetIsInfinity(set, solval) )
2059  SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
2060  else if( SCIPsetIsInfinity(set, -solval) )
2061  SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
2062  else
2063  SCIPmessageFPrintInfo(messagehdlr, file, " % 20.15g", solval);
2064  SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(prob->fixedvars[v]));
2065  }
2066  }
2067 
2068  for( v = 0; v < prob->nvars; ++v )
2069  {
2070  assert(prob->vars[v] != NULL);
2071 
2072  /* skip non-discrete variables in a mip start */
2073  if( mipstart && !SCIPvarIsIntegral(prob->vars[v]) )
2074  continue;
2075 
2076  solval = SCIPsolGetVal(sol, set, stat, prob->vars[v]);
2077  if( printzeros || mipstart
2078  || (sol->solorigin != SCIP_SOLORIGIN_PARTIAL && !SCIPsetIsZero(set, solval))
2079  || (sol->solorigin == SCIP_SOLORIGIN_PARTIAL && solval != SCIP_UNKNOWN) ) /*lint !e777*/
2080  {
2081  SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(prob->vars[v]));
2082  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
2083  SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
2084  else if( SCIPsetIsInfinity(set, solval) )
2085  SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
2086  else if( SCIPsetIsInfinity(set, -solval) )
2087  SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
2088  else
2089  SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g", solval);
2090  SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(prob->vars[v]));
2091  }
2092  }
2093 
2094  /* display additional priced variables (if given problem data is original problem) */
2095  if( !prob->transformed && !SCIPsolIsOriginal(sol) )
2096  {
2097  assert(transprob != NULL);
2098  for( v = 0; v < transprob->nfixedvars; ++v )
2099  {
2100  assert(transprob->fixedvars[v] != NULL);
2101  if( SCIPvarIsTransformedOrigvar(transprob->fixedvars[v]) )
2102  continue;
2103 
2104  /* skip non-discrete variables in a mip start */
2105  if( mipstart && !SCIPvarIsIntegral(transprob->fixedvars[v]) )
2106  continue;
2107 
2108  solval = SCIPsolGetVal(sol, set, stat, transprob->fixedvars[v]);
2109  if( printzeros || mipstart || !SCIPsetIsZero(set, solval) )
2110  {
2111  SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(transprob->fixedvars[v]));
2112  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
2113  SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
2114  else if( SCIPsetIsInfinity(set, solval) )
2115  SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
2116  else if( SCIPsetIsInfinity(set, -solval) )
2117  SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
2118  else
2119  SCIPmessageFPrintInfo(messagehdlr, file, " % 20.15g", solval);
2120  SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(transprob->fixedvars[v]));
2121  }
2122  }
2123  for( v = 0; v < transprob->nvars; ++v )
2124  {
2125  assert(transprob->vars[v] != NULL);
2126  if( SCIPvarIsTransformedOrigvar(transprob->vars[v]) )
2127  continue;
2128 
2129  /* skip non-discrete variables in a mip start */
2130  if( mipstart && !SCIPvarIsIntegral(transprob->vars[v]) )
2131  continue;
2132 
2133  solval = SCIPsolGetVal(sol, set, stat, transprob->vars[v]);
2134  if( printzeros || !SCIPsetIsZero(set, solval) )
2135  {
2136  SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(transprob->vars[v]));
2137  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
2138  SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
2139  else if( SCIPsetIsInfinity(set, solval) )
2140  SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
2141  else if( SCIPsetIsInfinity(set, -solval) )
2142  SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
2143  else
2144  SCIPmessageFPrintInfo(messagehdlr, file, " % 20.15g", solval);
2145  SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(transprob->vars[v]));
2146  }
2147  }
2148  }
2149 
2150  return SCIP_OKAY;
2151 }
2152 
2153 /** outputs non-zero elements of solution representing a ray to file stream */
2155  SCIP_SOL* sol, /**< primal CIP solution */
2156  SCIP_SET* set, /**< global SCIP settings */
2157  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
2158  SCIP_STAT* stat, /**< problem statistics data */
2159  SCIP_PROB* prob, /**< problem data (original or transformed) */
2160  SCIP_PROB* transprob, /**< transformed problem data or NULL (to display priced variables) */
2161  FILE* file, /**< output file (or NULL for standard output) */
2162  SCIP_Bool printzeros /**< should variables set to zero be printed? */
2163  )
2164 {
2165  SCIP_Real solval;
2166  int v;
2167 
2168  assert(sol != NULL);
2169  assert(prob != NULL);
2170  assert(SCIPsolIsOriginal(sol) || prob->transformed || transprob != NULL);
2171 
2172  /* display variables of problem data */
2173  for( v = 0; v < prob->nfixedvars; ++v )
2174  {
2175  assert(prob->fixedvars[v] != NULL);
2176  solval = SCIPsolGetRayVal(sol, set, stat, prob->fixedvars[v]);
2177  if( printzeros || !SCIPsetIsZero(set, solval) )
2178  {
2179  SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(prob->fixedvars[v]));
2180  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
2181  SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
2182  else if( SCIPsetIsInfinity(set, solval) )
2183  SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
2184  else if( SCIPsetIsInfinity(set, -solval) )
2185  SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
2186  else
2187  SCIPmessageFPrintInfo(messagehdlr, file, " % 20.15g", solval);
2188  SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(prob->fixedvars[v]));
2189  }
2190  }
2191  for( v = 0; v < prob->nvars; ++v )
2192  {
2193  assert(prob->vars[v] != NULL);
2194  solval = SCIPsolGetRayVal(sol, set, stat, prob->vars[v]);
2195  if( printzeros || !SCIPsetIsZero(set, solval) )
2196  {
2197  SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(prob->vars[v]));
2198  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
2199  SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
2200  else if( SCIPsetIsInfinity(set, solval) )
2201  SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
2202  else if( SCIPsetIsInfinity(set, -solval) )
2203  SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
2204  else
2205  SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g", solval);
2206  SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(prob->vars[v]));
2207  }
2208  }
2209 
2210  /* display additional priced variables (if given problem data is original problem) */
2211  if( !prob->transformed && !SCIPsolIsOriginal(sol) )
2212  {
2213  assert(transprob != NULL);
2214  for( v = 0; v < transprob->nfixedvars; ++v )
2215  {
2216  assert(transprob->fixedvars[v] != NULL);
2217  if( SCIPvarIsTransformedOrigvar(transprob->fixedvars[v]) )
2218  continue;
2219 
2220  solval = SCIPsolGetRayVal(sol, set, stat, transprob->fixedvars[v]);
2221  if( printzeros || !SCIPsetIsZero(set, solval) )
2222  {
2223  SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(transprob->fixedvars[v]));
2224  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
2225  SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
2226  else if( SCIPsetIsInfinity(set, solval) )
2227  SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
2228  else if( SCIPsetIsInfinity(set, -solval) )
2229  SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
2230  else
2231  SCIPmessageFPrintInfo(messagehdlr, file, " % 20.15g", solval);
2232  SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(transprob->fixedvars[v]));
2233  }
2234  }
2235  for( v = 0; v < transprob->nvars; ++v )
2236  {
2237  assert(transprob->vars[v] != NULL);
2238  if( SCIPvarIsTransformedOrigvar(transprob->vars[v]) )
2239  continue;
2240 
2241  solval = SCIPsolGetRayVal(sol, set, stat, transprob->vars[v]);
2242  if( printzeros || !SCIPsetIsZero(set, solval) )
2243  {
2244  SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(transprob->vars[v]));
2245  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
2246  SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
2247  else if( SCIPsetIsInfinity(set, solval) )
2248  SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
2249  else if( SCIPsetIsInfinity(set, -solval) )
2250  SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
2251  else
2252  SCIPmessageFPrintInfo(messagehdlr, file, " % 20.15g", solval);
2253  SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(transprob->vars[v]));
2254  }
2255  }
2256  }
2257 
2258  return SCIP_OKAY;
2259 }
2260 
2261 
2262 
2263 
2264 /*
2265  * simple functions implemented as defines
2266  */
2267 
2268 /* In debug mode, the following methods are implemented as function calls to ensure
2269  * type validity.
2270  * In optimized mode, the methods are implemented as defines to improve performance.
2271  * However, we want to have them in the library anyways, so we have to undef the defines.
2272  */
2273 
2274 #undef SCIPsolGetOrigin
2275 #undef SCIPsolIsOriginal
2276 #undef SCIPsolGetOrigObj
2277 #undef SCIPsolGetTime
2278 #undef SCIPsolGetNodenum
2279 #undef SCIPsolGetRunnum
2280 #undef SCIPsolGetDepth
2281 #undef SCIPsolGetHeur
2282 #undef SCIPsolOrigAddObjval
2283 #undef SCIPsolGetPrimalIndex
2284 #undef SCIPsolSetPrimalIndex
2285 #undef SCIPsolGetIndex
2286 #undef SCIPsolSetHeur
2287 
2288 /** gets origin of solution */
2290  SCIP_SOL* sol /**< primal CIP solution */
2291  )
2292 {
2293  assert(sol != NULL);
2294 
2295  return sol->solorigin;
2296 }
2297 
2298 /** returns whether the given solution is defined on original variables */
2300  SCIP_SOL* sol /**< primal CIP solution */
2301  )
2302 {
2303  assert(sol != NULL);
2304 
2306 }
2307 
2308 /** returns whether the given solution is defined on original variables and containes unknown solution values */
2310  SCIP_SOL* sol /**< primal CIP solution */
2311  )
2312 {
2313  assert(sol != NULL);
2314 
2315  return (sol->solorigin == SCIP_SOLORIGIN_PARTIAL);
2316 }
2317 
2318 /** gets objective value of primal CIP solution which lives in the original problem space */
2320  SCIP_SOL* sol /**< primal CIP solution */
2321  )
2322 {
2323  assert(sol != NULL);
2324  assert(SCIPsolIsOriginal(sol));
2325 
2326  return sol->obj;
2327 }
2328 
2329 /** adds value to the objective value of a given original primal CIP solution */
2331  SCIP_SOL* sol, /**< primal CIP solution */
2332  SCIP_Real addval /**< offset value to add */
2333  )
2334 {
2335  assert(sol != NULL);
2336  assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL);
2337 
2338  sol->obj += addval;
2339 }
2340 
2341 /** gets clock time, when this solution was found */
2343  SCIP_SOL* sol /**< primal CIP solution */
2344  )
2345 {
2346  assert(sol != NULL);
2347 
2348  return sol->time;
2349 }
2350 
2351 /** gets branch and bound run number, where this solution was found */
2353  SCIP_SOL* sol /**< primal CIP solution */
2354  )
2355 {
2356  assert(sol != NULL);
2357 
2358  return sol->runnum;
2359 }
2360 
2361 /** gets node number, where this solution was found */
2363  SCIP_SOL* sol /**< primal CIP solution */
2364  )
2365 {
2366  assert(sol != NULL);
2367 
2368  return sol->nodenum;
2369 }
2370 
2371 /** gets node's depth, where this solution was found */
2373  SCIP_SOL* sol /**< primal CIP solution */
2374  )
2375 {
2376  assert(sol != NULL);
2377 
2378  return sol->depth;
2379 }
2380 
2381 /** gets heuristic, that found this solution (or NULL if it's from the tree) */
2383  SCIP_SOL* sol /**< primal CIP solution */
2384  )
2385 {
2386  assert(sol != NULL);
2387 
2388  return sol->heur;
2389 }
2390 
2391 /** gets current position of solution in array of existing solutions of primal data */
2393  SCIP_SOL* sol /**< primal CIP solution */
2394  )
2395 {
2396  assert(sol != NULL);
2397 
2398  return sol->primalindex;
2399 }
2400 
2401 /** sets current position of solution in array of existing solutions of primal data */
2403  SCIP_SOL* sol, /**< primal CIP solution */
2404  int primalindex /**< new primal index of solution */
2405  )
2406 {
2407  assert(sol != NULL);
2408 
2409  sol->primalindex = primalindex;
2410 }
2411 
2412 /** returns unique index of given solution */
2414  SCIP_SOL* sol /**< primal CIP solution */
2415  )
2416 {
2417  assert(sol != NULL);
2418 
2419  return sol->index;
2420 }
2421 
2422 /** informs the solution that it now belongs to the given primal heuristic */
2424  SCIP_SOL* sol, /**< primal CIP solution */
2425  SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
2426  )
2427 {
2428  assert(sol != NULL);
2429 
2430  sol->heur = heur;
2431 }
2432 
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:2299
SCIP_RETCODE SCIPsolCreateRelaxSol(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_RELAXATION *relaxation, SCIP_HEUR *heur)
Definition: sol.c:604
SCIP_RETCODE SCIPsolUnlink(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *prob)
Definition: sol.c:986
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5522
SCIP_RETCODE SCIPsolRound(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_Bool *success)
Definition: sol.c:1701
SCIP_RETCODE SCIPsolCreatePartial(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_HEUR *heur)
Definition: sol.c:674
SCIP_RETCODE SCIPsolLinkPseudoSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:897
SCIP_Bool SCIPsetIsLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5580
SCIP_Bool SCIPsetIsFeasZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6030
internal methods for storing primal CIP solutions
int solindex
Definition: struct_stat.h:245
int SCIPprobGetNBinVars(SCIP_PROB *prob)
Definition: prob.c:2252
void SCIPvarMarkNotDeletable(SCIP_VAR *var)
Definition: var.c:16796
SCIP_Bool SCIPlpDiving(SCIP_LP *lp)
Definition: lp.c:16799
void SCIPprimalSolFreed(SCIP_PRIMAL *primal, SCIP_SOL *sol)
Definition: primal.c:1635
SCIP_Real * SCIPvarGetMultaggrScalars(SCIP_VAR *var)
Definition: var.c:16958
SCIP_Real SCIPrelaxationGetSolObj(SCIP_RELAXATION *relaxation)
Definition: relax.c:696
internal methods for branch and bound tree
#define SCIPstatDebugMsg
Definition: stat.h:304
SCIP_Real SCIPsetFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5709
int depth
Definition: struct_sol.h:66
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17166
SCIP_RETCODE SCIPsolLinkNLPSol(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_NLP *nlp)
Definition: sol.c:816
internal methods for clocks and timing issues
SCIP_Real * SCIPcolGetVals(SCIP_COL *col)
Definition: lp.c:16190
SCIP_Bool SCIPsetIsPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5645
SCIP_Longint nodenum
Definition: struct_sol.h:55
SCIP_VAR ** SCIPvarGetMultaggrVars(SCIP_VAR *var)
Definition: var.c:16946
SCIP_RETCODE SCIPrealarrayCreate(SCIP_REALARRAY **realarray, BMS_BLKMEM *blkmem)
Definition: misc.c:3183
SCIP_Bool SCIPboolarrayGetVal(SCIP_BOOLARRAY *boolarray, int idx)
Definition: misc.c:4166
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17222
int nintvars
Definition: struct_prob.h:63
SCIP_RETCODE SCIPsolLinkLPSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:758
SCIP_RETCODE SCIPsolCreateUnknown(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_HEUR *heur)
Definition: sol.c:707
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:5384
SCIP_RETCODE SCIPsolLinkCurrentSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:926
SCIP_HEUR * heur
Definition: struct_sol.h:64
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:16311
#define FALSE
Definition: def.h:64
SCIP_Bool SCIPsetIsFeasIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6063
SCIP_Real objoffset
Definition: struct_prob.h:41
SCIP_Bool solved
Definition: struct_lp.h:343
SCIP_RETCODE SCIPsolCopy(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_SOL *sourcesol)
Definition: sol.c:341
SCIP_Bool SCIPsetIsZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5634
#define TRUE
Definition: def.h:63
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_Real SCIPvarGetNegationConstant(SCIP_VAR *var)
Definition: var.c:17003
void SCIPsolSetPrimalIndex(SCIP_SOL *sol, int primalindex)
Definition: sol.c:2402
SCIP_Real SCIPprobInternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2032
#define SCIPsetAllocBufferArray(set, ptr, num)
Definition: set.h:1834
int SCIPtreeGetCurrentDepth(SCIP_TREE *tree)
Definition: tree.c:8103
SCIP_Real SCIPsolGetRayVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition: sol.c:1411
SCIP_RETCODE SCIPsolSetUnknown(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree)
Definition: sol.c:969
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:16859
SCIP_RETCODE SCIPboolarrayCopy(SCIP_BOOLARRAY **boolarray, BMS_BLKMEM *blkmem, SCIP_BOOLARRAY *sourceboolarray)
Definition: misc.c:3940
SCIP_Bool SCIPsolsAreEqual(SCIP_SOL *sol1, SCIP_SOL *sol2, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob)
Definition: sol.c:1961
SCIP_Real SCIPsolGetTime(SCIP_SOL *sol)
Definition: sol.c:2342
SCIP_Real SCIPvarGetAggrScalar(SCIP_VAR *var)
Definition: var.c:16912
SCIP_VAR ** fixedvars
Definition: struct_prob.h:56
SCIP_Real SCIPlpGetPseudoObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:12648
SCIP_Bool SCIPrelaxationIsSolValid(SCIP_RELAXATION *relaxation)
Definition: relax.c:675
SCIP_Bool SCIPsetIsNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5656
SCIP_RETCODE SCIPsolClear(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree)
Definition: sol.c:952
#define SCIPsetFreeBufferArray(set, ptr)
Definition: set.h:1841
SCIP_VAR * SCIPvarGetNegationVar(SCIP_VAR *var)
Definition: var.c:16992
SCIP_Real SCIPsetCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5720
int runnum
Definition: struct_sol.h:65
SCIP_Real SCIPvarGetRelaxSolTransVar(SCIP_VAR *var)
Definition: var.c:13297
internal methods for LP management
SCIP_Real SCIPsolGetOrigObj(SCIP_SOL *sol)
Definition: sol.c:2319
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:1286
SCIP_RETCODE SCIPboolarraySetVal(SCIP_BOOLARRAY *boolarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, SCIP_Bool val)
Definition: misc.c:4187
int SCIPlpGetNCols(SCIP_LP *lp)
Definition: lp.c:16574
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5616
SCIP_Bool SCIProwIsInLP(SCIP_ROW *row)
Definition: lp.c:16522
SCIP_RETCODE SCIPrealarrayIncVal(SCIP_REALARRAY *realarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, SCIP_Real incval)
Definition: misc.c:3517
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17176
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5562
SCIP_Real SCIPclockGetLastTime(SCIP_CLOCK *clck)
Definition: clock.c:508
SCIP_Bool SCIPtreeProbing(SCIP_TREE *tree)
Definition: tree.c:7985
SCIP_Bool SCIPnlpIsDivingObjChanged(SCIP_NLP *nlp)
Definition: nlp.c:6340
static void solStamp(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_Bool checktime)
Definition: sol.c:248
SCIP_Real SCIPsolGetObj(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition: sol.c:1480
int SCIPprobGetNImplVars(SCIP_PROB *prob)
Definition: prob.c:2270
void SCIPsolUpdateVarsum(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_Real weight)
Definition: sol.c:1773
SCIP_RETCODE SCIPrealarrayCopy(SCIP_REALARRAY **realarray, BMS_BLKMEM *blkmem, SCIP_REALARRAY *sourcerealarray)
Definition: misc.c:3203
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:45
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4113
#define SCIPdebugPrintf
Definition: pub_message.h:80
SCIP_Longint lpcount
Definition: struct_stat.h:168
SCIP_ROW ** SCIPcolGetRows(SCIP_COL *col)
Definition: lp.c:16180
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:647
SCIP_RETCODE SCIPboolarrayCreate(SCIP_BOOLARRAY **boolarray, BMS_BLKMEM *blkmem)
Definition: misc.c:3920
SCIP_COL ** SCIPlpGetCols(SCIP_LP *lp)
Definition: lp.c:16564
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
Definition: lp.c:16420
SCIP_Bool SCIPvarIsTransformedOrigvar(SCIP_VAR *var)
Definition: var.c:12167
SCIP_Real SCIPrealarrayGetVal(SCIP_REALARRAY *realarray, int idx)
Definition: misc.c:3427
SCIP_Real primsolavg
Definition: struct_var.h:211
SCIP_Real SCIPnlpGetObjval(SCIP_NLP *nlp)
Definition: nlp.c:5577
SCIP_RETCODE SCIPsolSetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real val)
Definition: sol.c:1015
SCIP_Real SCIPvarGetAggrConstant(SCIP_VAR *var)
Definition: var.c:16923
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16552
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
Definition: clock.c:428
internal methods for NLP management
SCIP_Real SCIPsetFeasCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6098
static SCIP_RETCODE solIncArrayVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_VAR *var, SCIP_Real incval)
Definition: sol.c:94
internal miscellaneous methods
SCIP_RETCODE SCIPboolarrayClear(SCIP_BOOLARRAY *boolarray)
Definition: misc.c:4135
#define NULL
Definition: lpi_spx1.cpp:137
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
Definition: sol.c:2382
#define REALABS(x)
Definition: def.h:159
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition: var.c:17540
static SCIP_RETCODE solUnlinkVar(SCIP_SOL *sol, SCIP_SET *set, SCIP_VAR *var)
Definition: sol.c:186
SCIP_RETCODE SCIPsolCreateOriginal(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_HEUR *heur)
Definition: sol.c:308
internal methods for global SCIP settings
#define SCIP_CALL(x)
Definition: def.h:306
SCIP_Longint lpcount
Definition: struct_sol.h:57
SCIP_Bool SCIPsetIsFeasGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6008
SCIP_Real SCIPvarGetMultaggrConstant(SCIP_VAR *var)
Definition: var.c:16970
void SCIPmessagePrintInfo(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:584
int primalindex
Definition: struct_sol.h:67
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:16321
internal methods for relaxators
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5544
SCIP_Real SCIPlpGetObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:12468
SCIP_Bool SCIPsetIsFeasLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5964
datastructures for storing primal CIP solutions
int SCIPprobGetNIntVars(SCIP_PROB *prob)
Definition: prob.c:2261
SCIP_RETCODE SCIPsolTransform(SCIP_SOL *sol, SCIP_SOL **transsol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PRIMAL *primal)
Definition: sol.c:379
void SCIPsolRecomputeObj(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob)
Definition: sol.c:1926
SCIP_Real SCIProwGetSolActivity(SCIP_ROW *row, SCIP_SET *set, SCIP_STAT *stat, SCIP_SOL *sol)
Definition: lp.c:6286
#define BMSfreeBlockMemory(mem, ptr)
Definition: memory.h:419
internal methods for problem variables
#define SCIP_UNKNOWN
Definition: def.h:156
SCIP_RETCODE SCIPprimalSolCreated(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_SOL *sol)
Definition: primal.c:1613
#define SCIP_Bool
Definition: def.h:61
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:2362
int nbinvars
Definition: struct_prob.h:62
SCIP_Real SCIPprobGetObjoffset(SCIP_PROB *prob)
Definition: prob.c:2306
SCIP_NLPSOLSTAT SCIPnlpGetSolstat(SCIP_NLP *nlp)
Definition: nlp.c:5967
SCIP_RETCODE SCIPsolIncVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real incval)
Definition: sol.c:1210
SCIP_Real SCIPvarGetNLPSol(SCIP_VAR *var)
Definition: var.c:17553
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
SCIP_RETCODE SCIPrealarrayFree(SCIP_REALARRAY **realarray)
Definition: misc.c:3227
void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
Definition: sol.c:2423
SCIP_Bool SCIPlpDivingObjChanged(SCIP_LP *lp)
Definition: lp.c:16809
int SCIPvarGetNLocksUp(SCIP_VAR *var)
Definition: var.c:3217
#define MAX(x, y)
Definition: tclique_def.h:75
SCIP_RETCODE SCIPsolRetransform(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_Bool *hasinfval)
Definition: sol.c:1801
SCIP_RETCODE SCIPsolMarkPartial(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR **vars, int nvars)
Definition: sol.c:1516
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:2021
SCIP_Real SCIPvarGetUnchangedObj(SCIP_VAR *var)
Definition: var.c:17024
#define SCIPsetDebugMsg
Definition: set.h:1870
void SCIPsolOrigAddObjval(SCIP_SOL *sol, SCIP_Real addval)
Definition: sol.c:2330
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17014
static SCIP_RETCODE solSetArrayVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_VAR *var, SCIP_Real val)
Definition: sol.c:63
SCIP_VAR * SCIPvarGetAggrVar(SCIP_VAR *var)
Definition: var.c:16901
SCIP_Bool SCIPtreeHasCurrentNodeLP(SCIP_TREE *tree)
Definition: tree.c:8120
int SCIPnlpGetNVars(SCIP_NLP *nlp)
Definition: nlp.c:5790
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:16880
int SCIPvarGetMultaggrNVars(SCIP_VAR *var)
Definition: var.c:16934
SCIP_Bool transformed
Definition: struct_prob.h:79
SCIP_RETCODE SCIPvarGetOrigvarSum(SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12080
SCIP_Bool SCIPsetIsFeasLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5942
int nfixedvars
Definition: struct_prob.h:68
SCIP_RETCODE SCIPsolPrintRay(SCIP_SOL *sol, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PROB *transprob, FILE *file, SCIP_Bool printzeros)
Definition: sol.c:2154
SCIP_RETCODE SCIPsolAdjustImplicitSolVals(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_Bool uselprows)
Definition: sol.c:425
SCIP_SOLORIGIN solorigin
Definition: struct_sol.h:69
static SCIP_RETCODE solClearArrays(SCIP_SOL *sol)
Definition: sol.c:49
SCIP_Real SCIPlpGetLooseObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:12507
SCIP_RETCODE SCIPsolLinkRelaxSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_RELAXATION *relaxation)
Definition: sol.c:867
SCIP_Real SCIPsetFeasFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6087
int SCIPcolGetNNonz(SCIP_COL *col)
Definition: lp.c:16155
int SCIPvarGetNLocksDown(SCIP_VAR *var)
Definition: var.c:3162
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
Definition: lp.c:16081
static const SCIP_Real scalars[]
Definition: lp.c:5563
SCIP_RETCODE SCIPsolCreateLPSol(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:560
SCIP_RETCODE SCIPvarGetActiveRepresentatives(SCIP_SET *set, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, int varssize, SCIP_Real *constant, int *requiredsize, SCIP_Bool mergemultiples)
Definition: var.c:3741
SCIP_CLOCK * solvingtime
Definition: struct_stat.h:139
SCIP_RETCODE SCIPboolarrayFree(SCIP_BOOLARRAY **boolarray)
Definition: misc.c:3964
public methods for message output
SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
Definition: sol.c:2289
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:608
SCIP_Bool SCIPsetIsGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5598
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16671
static SCIP_Real solGetArrayVal(SCIP_SOL *sol, SCIP_VAR *var)
Definition: sol.c:135
int SCIPsolGetPrimalIndex(SCIP_SOL *sol)
Definition: sol.c:2392
void SCIPsolUpdateVarObj(SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real oldobj, SCIP_Real newobj)
Definition: sol.c:1497
SCIP_Real time
Definition: struct_sol.h:54
#define SCIP_Real
Definition: def.h:135
internal methods for problem statistics
SCIP_VAR ** vars
Definition: struct_prob.h:55
SCIP_Bool SCIPlpIsSolved(SCIP_LP *lp)
Definition: lp.c:16779
SCIP_Bool SCIPsetIsFeasPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6041
#define SCIPsetDebugMsgPrint
Definition: set.h:1871
SCIP_VAR ** SCIPprobGetVars(SCIP_PROB *prob)
Definition: prob.c:2288
#define SCIP_INVALID
Definition: def.h:155
enum SCIP_SolOrigin SCIP_SOLORIGIN
Definition: type_sol.h:46
internal methods for constraints and constraint handlers
SCIP_Real primsol
Definition: struct_lp.h:137
int SCIPsolGetDepth(SCIP_SOL *sol)
Definition: sol.c:2372
SCIP_REALARRAY * vals
Definition: struct_sol.h:61
#define SCIP_Longint
Definition: def.h:120
SCIP_VAR ** SCIPnlpGetVars(SCIP_NLP *nlp)
Definition: nlp.c:5780
int SCIPvarGetIndex(SCIP_VAR *var)
Definition: var.c:16849
SCIP_RETCODE SCIPsolCreateNLPSol(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_NLP *nlp, SCIP_HEUR *heur)
Definition: sol.c:583
#define SCIPisFinite(x)
Definition: pub_misc.h:1601
SCIP_Bool SCIPsetIsFeasGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5986
SCIP_RETCODE SCIPrealarraySetVal(SCIP_REALARRAY *realarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, SCIP_Real val)
Definition: misc.c:3448
SCIP_BOOLARRAY * valid
Definition: struct_sol.h:62
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16717
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17232
SCIP_Bool SCIPvarIsTransformed(SCIP_VAR *var)
Definition: var.c:16694
#define BMSallocBlockMemory(mem, ptr)
Definition: memory.h:406
SCIP_RETCODE SCIPsolCreatePseudoSol(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:626
SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
Definition: sol.c:2309
common defines and data types used in all packages of SCIP
SCIP_Longint nnodes
Definition: struct_stat.h:71
int SCIPsolGetRunnum(SCIP_SOL *sol)
Definition: sol.c:2352
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:392
SCIP_RETCODE SCIPconshdlrCheck(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_SOL *sol, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_Bool completely, SCIP_RESULT *result)
Definition: cons.c:3676
SCIP_Real SCIPvarGetPseudoSol(SCIP_VAR *var)
Definition: var.c:17618
SCIP_VAR * SCIPvarGetTransVar(SCIP_VAR *var)
Definition: var.c:16869
#define SCIP_ALLOC(x)
Definition: def.h:317
#define SCIPABORT()
Definition: def.h:278
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:16743
SCIP_Bool hasinfval
Definition: struct_sol.h:70
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:1581
int SCIPsolGetIndex(SCIP_SOL *sol)
Definition: sol.c:2413
SCIP_Real obj
Definition: struct_sol.h:53
int index
Definition: struct_sol.h:68
SCIP_Bool SCIPvarMayRoundUp(SCIP_VAR *var)
Definition: var.c:3280
SCIP_Bool SCIPvarMayRoundDown(SCIP_VAR *var)
Definition: var.c:3272
SCIP_Bool SCIPsetIsFeasNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6052
SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)
Definition: var.c:16839
SCIP_RETCODE SCIPsolFree(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_PRIMAL *primal)
Definition: sol.c:739