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