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