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