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-2025 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file sol.c
26 * @ingroup OTHER_CFILES
27 * @brief methods for storing primal CIP solutions
28 * @author Tobias Achterberg
29 */
30
31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32#include "scip/clock.h"
33#include "scip/cons.h"
34#include "scip/lp.h"
35#include "scip/lpexact.h"
36#include "scip/misc.h"
37#include "scip/nlp.h"
38#include "scip/primal.h"
39#include "scip/prob.h"
40#include "scip/pub_lp.h"
41#include "scip/pub_message.h"
42#include "scip/pub_sol.h"
43#include "scip/pub_var.h"
44#include "scip/relax.h"
45#include "scip/set.h"
46#include "scip/sol.h"
47#include "scip/stat.h"
48#include "scip/struct_lp.h"
49#include "scip/struct_lpexact.h"
50#include "scip/struct_prob.h"
51#include "scip/struct_set.h"
52#include "scip/struct_sol.h"
53#include "scip/struct_stat.h"
54#include "scip/struct_var.h"
55#include "scip/tree.h"
56#include "scip/var.h"
57
58
59/** clears solution arrays of primal CIP solution */
60static
62 SCIP_SOL* sol /**< primal CIP solution */
63 )
64{
65 assert(sol != NULL);
66
68 sol->hasinfval = FALSE;
69
70 if( SCIPsolIsExact(sol) )
71 {
73 }
74
75 return SCIP_OKAY;
76}
77
78/** sets value of variable in the solution's array */
79static
81 SCIP_SOL* sol, /**< primal CIP solution */
82 SCIP_SET* set, /**< global SCIP settings */
83 SCIP_VAR* var, /**< problem variable */
84 SCIP_Real val /**< value to set variable to */
85 )
86{
87 int idx;
88
89 assert(sol != NULL);
90
91 idx = SCIPvarGetIndex(var);
92
93 /* from now on, variable must not be deleted */
95
96 /* mark the variable valid */
97 SCIP_CALL( SCIPboolarraySetVal(sol->valid, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, TRUE) );
98
99 /* set the value in the solution array */
100 SCIP_CALL( SCIPrealarraySetVal(sol->vals, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, val) );
101
102 /* store whether the solution has infinite values assigned to variables */
103 if( val != SCIP_UNKNOWN ) /*lint !e777*/
104 sol->hasinfval = (sol->hasinfval || SCIPsetIsInfinity(set, val) || SCIPsetIsInfinity(set, -val));
105
106 return SCIP_OKAY;
107}
108
109/** sets value of variable in the exact solution's array */
110static
112 SCIP_SOL* sol, /**< primal CIP solution */
113 SCIP_SET* set, /**< global SCIP settings */
114 SCIP_VAR* var, /**< problem variable */
115 SCIP_RATIONAL* val /**< value to set variable to */
116 )
117{
118 int idx;
119
120 assert(sol != NULL);
121 assert(SCIPsolIsExact(sol));
122
123 idx = SCIPvarGetIndex(var);
124
125 /* from now on, variable must not be deleted */
127
128 /* mark the variable valid */
129 SCIP_CALL( SCIPboolarraySetVal(sol->valsexact->valid, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, TRUE) );
130
131 /* set the value in the solution array */
133
134 /* store whether the solution has infinite values assigned to variables */
135 if( SCIPrationalIsAbsInfinity(val) ) /*lint !e777*/
136 sol->hasinfval = TRUE;
137
138 return SCIP_OKAY;
139}
140
141/** increases value of variable in the solution's array */
142static
144 SCIP_SOL* sol, /**< primal CIP solution */
145 SCIP_SET* set, /**< global SCIP settings */
146 SCIP_VAR* var, /**< problem variable */
147 SCIP_Real incval /**< increase of variable's solution value */
148 )
149{
150 int idx;
151
152 assert(sol != NULL);
153
154 idx = SCIPvarGetIndex(var);
155
156 /* from now on, variable must not be deleted */
158
159 /* 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) */
160 if( !SCIPboolarrayGetVal(sol->valid, idx) )
161 {
162 /* mark the variable valid */
163 SCIP_CALL( SCIPboolarraySetVal(sol->valid, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, TRUE) );
164
165 /* set the value in the solution array */
166 SCIP_CALL( SCIPrealarraySetVal(sol->vals, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, incval) );
167 }
168 else
169 {
170 /* increase the value in the solution array */
171 SCIP_CALL( SCIPrealarrayIncVal(sol->vals, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, incval) );
172 }
173
174 /* store whether the solution has infinite values assigned to variables */
175 incval = SCIPrealarrayGetVal(sol->vals, idx);
176 if( incval != SCIP_UNKNOWN ) /*lint !e777*/
177 sol->hasinfval = (sol->hasinfval || SCIPsetIsInfinity(set, incval) || SCIPsetIsInfinity(set, -incval));
178
179 return SCIP_OKAY;
180}
181
182/** returns the value of the variable in the given solution */
183static
185 SCIP_SOL* sol, /**< primal CIP solution */
186 SCIP_VAR* var /**< problem variable */
187 )
188{
189 int idx;
190
191 assert(sol != NULL);
192
193 idx = SCIPvarGetIndex(var);
194
195 /* check, if the variable's value is valid */
196 if( SCIPboolarrayGetVal(sol->valid, idx) )
197 {
198 return SCIPrealarrayGetVal(sol->vals, idx);
199 }
200 else
201 {
202 /* return the variable's value corresponding to the origin */
203 switch( sol->solorigin )
204 {
207 return 0.0;
208
210 return SCIPvarGetLPSol(var);
211
213 return SCIPvarGetNLPSol(var);
214
216 return SCIPvarGetRelaxSolTransVar(var);
217
219 return SCIPvarGetPseudoSol(var);
220
223 return SCIP_UNKNOWN;
224
225 default:
226 SCIPerrorMessage("unknown solution origin <%d>\n", sol->solorigin);
227 SCIPABORT();
228 return 0.0; /*lint !e527*/
229 }
230 }
231}
232
233/** returns the value of the variable in the given exact solution */
234static
236 SCIP_RATIONAL* res, /**< buffer to store result */
237 SCIP_SOL* sol, /**< primal CIP solution */
238 SCIP_VAR* var /**< problem variable */
239 )
240{
241 int idx;
242
243 assert(sol != NULL);
244 assert(SCIPsolIsExact(sol));
245
246 idx = SCIPvarGetIndex(var);
247
248 /* check, if the variable's value is valid */
249 if( SCIPboolarrayGetVal(sol->valsexact->valid, idx) )
250 {
251 SCIPrationalarrayGetVal(sol->valsexact->vals, idx, res);
252 }
253 else
254 {
255 /* return the variable's value corresponding to the origin */
256 switch( sol->solorigin )
257 {
260 SCIPrationalSetReal(res, 0.0);
261 break;
262
264 SCIPvarGetLPSolExact(var, res);
265 break;
266
269 break;
270
275 default:
276 SCIPerrorMessage("unknown solution origin <%d>\n", sol->solorigin);
277 SCIPABORT();
278 return; /*lint !e527*/
279 }
280 }
281}
282
283/** stores solution value of variable in solution's own array */
284static
286 SCIP_SOL* sol, /**< primal CIP solution */
287 SCIP_SET* set, /**< global SCIP settings */
288 SCIP_VAR* var /**< problem variable */
289 )
290{
291 SCIP_Real solval;
292
293 assert(sol != NULL);
294 assert(var != NULL);
295 assert(SCIPvarIsTransformed(var));
297
298 /* if variable is already valid, nothing has to be done */
300 return SCIP_OKAY;
301
302 SCIPsetDebugMsg(set, "unlinking solution value of variable <%s>\n", SCIPvarGetName(var));
303
304 /* store the correct solution value into the solution array */
305 switch( sol->solorigin )
306 {
308 SCIPerrorMessage("cannot unlink solutions of original problem space\n");
309 return SCIP_INVALIDDATA;
310
312 return SCIP_OKAY;
313
315 solval = SCIPvarGetLPSol(var);
316 SCIP_CALL( solSetArrayVal(sol, set, var, solval) );
317 return SCIP_OKAY;
318
320 solval = SCIPvarGetNLPSol(var);
321 SCIP_CALL( solSetArrayVal(sol, set, var, solval) );
322 return SCIP_OKAY;
323
325 solval = SCIPvarGetRelaxSolTransVar(var);
326 SCIP_CALL( solSetArrayVal(sol, set, var, solval) );
327 return SCIP_OKAY;
328
330 solval = SCIPvarGetPseudoSol(var);
331 SCIP_CALL( solSetArrayVal(sol, set, var, solval) );
332 return SCIP_OKAY;
333
337 return SCIP_OKAY;
338
339 default:
340 SCIPerrorMessage("unknown solution origin <%d>\n", sol->solorigin);
341 return SCIP_INVALIDDATA;
342 }
343}
344
345/** stores solution value of variable in exact solution's own array */
346static
348 SCIP_SOL* sol, /**< primal CIP solution */
349 SCIP_SET* set, /**< global SCIP settings */
350 SCIP_VAR* var /**< problem variable */
351 )
352{
353 SCIP_RATIONAL* solval;
354
355 assert(sol != NULL);
356 assert(var != NULL);
357 assert(SCIPsolIsExact(sol));
358 assert(SCIPvarIsTransformed(var));
360
361 /* if variable is already valid, nothing has to be done */
363 return SCIP_OKAY;
364
365 SCIPsetDebugMsg(set, "unlinking solution value of variable <%s>\n", SCIPvarGetName(var));
366
367 /* store the correct solution value into the solution array */
368 switch( sol->solorigin )
369 {
371 SCIPerrorMessage("cannot unlink solutions of original problem space\n");
372 return SCIP_INVALIDDATA;
373
375 return SCIP_OKAY;
376
378 SCIP_CALL( SCIPrationalCreateBuffer(set->buffer, &solval) );
379 SCIPvarGetLPSolExact(var, solval);
380 SCIP_CALL( solSetArrayValExact(sol, set, var, solval) );
381 SCIPrationalFreeBuffer(set->buffer, &solval);
382 return SCIP_OKAY;
383
386 return SCIP_OKAY;
387
392 default:
393 SCIPerrorMessage("unknown solution origin <%d>\n", sol->solorigin);
394 return SCIP_INVALIDDATA;
395 }
396}
397
398/** sets the solution time, nodenum, runnum, and depth stamp to the current values */
399static
401 SCIP_SOL* sol, /**< primal CIP solution */
402 SCIP_STAT* stat, /**< problem statistics data */
403 SCIP_TREE* tree, /**< branch and bound tree, or NULL */
404 SCIP_Bool checktime /**< should the time be updated? */
405 )
406{
407 assert(sol != NULL);
408 assert(stat != NULL);
409
410 if( checktime )
411 {
412 sol->time = SCIPclockGetTime(stat->solvingtime);
413#ifndef NDEBUG
414 sol->lpcount = stat->lpcount;
415#endif
416 }
417 else
419 sol->nodenum = stat->nnodes;
420 sol->runnum = stat->nruns;
421 if( tree == NULL )
422 sol->depth = -1;
423 else
424 sol->depth = SCIPtreeGetCurrentDepth(tree);
425}
426
427/** creates primal CIP solution, initialized to zero */
429 SCIP_SOL** sol, /**< pointer to primal CIP solution */
430 BMS_BLKMEM* blkmem, /**< block memory */
431 SCIP_SET* set, /**< global SCIP settings */
432 SCIP_STAT* stat, /**< problem statistics data */
433 SCIP_PRIMAL* primal, /**< primal data */
434 SCIP_TREE* tree, /**< branch and bound tree */
435 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
436 )
437{
438 assert(sol != NULL);
439 assert(blkmem != NULL);
440 assert(stat != NULL);
441
442 SCIP_ALLOC( BMSallocBlockMemory(blkmem, sol) );
443 SCIP_CALL( SCIPrealarrayCreate(&(*sol)->vals, blkmem) );
444 SCIP_CALL( SCIPboolarrayCreate(&(*sol)->valid, blkmem) );
445
446 (*sol)->solorigin = SCIP_SOLORIGIN_ZERO;
447 (*sol)->obj = 0.0;
448 (*sol)->primalindex = -1;
449 (*sol)->index = stat->solindex;
450 (*sol)->hasinfval = FALSE;
451 (*sol)->valsexact = NULL;
452#ifndef NDEBUG
453 (*sol)->scip = set->scip;
454#endif
455
457 stat->solindex++;
458 solStamp(*sol, stat, tree, TRUE);
460
461 /* set solution type and creator depending on whether a heuristic or NULL is passed */
462 SCIPsolSetHeur(*sol, heur);
463
464 SCIP_CALL( SCIPprimalSolCreated(primal, set, *sol) );
465
466 return SCIP_OKAY;
467}
468
469/** creates primal CIP solution with exact rational values, initialized to zero */
471 SCIP_SOL** sol, /**< pointer to primal CIP solution */
472 BMS_BLKMEM* blkmem, /**< block memory */
473 SCIP_SET* set, /**< global SCIP settings */
474 SCIP_STAT* stat, /**< problem statistics data */
475 SCIP_PRIMAL* primal, /**< primal data */
476 SCIP_TREE* tree, /**< branch and bound tree */
477 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
478 )
479{
480 assert(sol != NULL);
481 assert(blkmem != NULL);
482 assert(stat != NULL);
483
484 SCIP_CALL( SCIPsolCreate(sol, blkmem, set, stat, primal, tree, heur) );
485
486 SCIP_ALLOC( BMSallocBlockMemory(blkmem, &(*sol)->valsexact) );
487 SCIP_CALL( SCIPrationalarrayCreate(&(*sol)->valsexact->vals, blkmem) );
488 SCIP_CALL( SCIPboolarrayCreate(&(*sol)->valsexact->valid, blkmem) );
489 SCIP_CALL( SCIPrationalCreateBlock(blkmem, &(*sol)->valsexact->obj) );
490
491 assert(SCIPsolIsExact(*sol));
492
493 return SCIP_OKAY;
494}
495
496/** creates a copy of exact solution data */
498 SCIP_VALSEXACT** valsexact, /**< pointer to store the copy of the primal CIP solution */
499 BMS_BLKMEM* blkmem, /**< block memory */
500 SCIP_VALSEXACT* sourcevals /**< primal CIP solution to copy */
501 )
502{
503 assert(valsexact != NULL);
504
505 SCIP_ALLOC( BMSallocBlockMemory(blkmem, valsexact) );
506 SCIP_CALL( SCIPrationalarrayCopy(&(*valsexact)->vals, blkmem, sourcevals->vals) );
507 SCIP_CALL( SCIPboolarrayCopy(&(*valsexact)->valid, blkmem, sourcevals->valid) );
508 SCIP_CALL( SCIPrationalCopyBlock(blkmem, &(*valsexact)->obj, sourcevals->obj) );
509
510 return SCIP_OKAY;
511}
512
513/** creates primal CIP solution in original problem space, initialized to the offset in the original problem */
515 SCIP_SOL** sol, /**< pointer to primal CIP solution */
516 BMS_BLKMEM* blkmem, /**< block memory */
517 SCIP_SET* set, /**< global SCIP settings */
518 SCIP_STAT* stat, /**< problem statistics data */
519 SCIP_PROB* origprob, /**< original problem data */
520 SCIP_PRIMAL* primal, /**< primal data */
521 SCIP_TREE* tree, /**< branch and bound tree */
522 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
523 )
524{
525 assert(sol != NULL);
526 assert(blkmem != NULL);
527 assert(stat != NULL);
528
529 SCIP_ALLOC( BMSallocBlockMemory(blkmem, sol) );
530 SCIP_CALL( SCIPrealarrayCreate(&(*sol)->vals, blkmem) );
531 SCIP_CALL( SCIPboolarrayCreate(&(*sol)->valid, blkmem) );
532 (*sol)->solorigin = SCIP_SOLORIGIN_ORIGINAL;
533 (*sol)->obj = origprob->objoffset;
534 (*sol)->primalindex = -1;
535 (*sol)->index = stat->solindex;
536 (*sol)->hasinfval = FALSE;
537 (*sol)->valsexact = NULL;
538#ifndef NDEBUG
539 (*sol)->scip = set->scip;
540#endif
541 stat->solindex++;
542 solStamp(*sol, stat, tree, TRUE);
543
544 /* set solution type and creator depending on whether a heuristic or NULL is passed */
545 SCIPsolSetHeur(*sol, heur);
546
548
549 SCIP_CALL( SCIPprimalSolCreated(primal, set, *sol) );
550
551 return SCIP_OKAY;
552}
553
554/** creates exact primal CIP solution in original problem space, initialized to the offset in the original problem */
556 SCIP_SOL** sol, /**< pointer to primal CIP solution */
557 BMS_BLKMEM* blkmem, /**< block memory */
558 SCIP_SET* set, /**< global SCIP settings */
559 SCIP_STAT* stat, /**< problem statistics data */
560 SCIP_PROB* origprob, /**< original problem data */
561 SCIP_PRIMAL* primal, /**< primal data */
562 SCIP_TREE* tree, /**< branch and bound tree */
563 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
564 )
565{
566 assert(sol != NULL);
567 assert(blkmem != NULL);
568 assert(stat != NULL);
569
570 SCIP_CALL( SCIPsolCreateOriginal(sol, blkmem, set, stat, origprob, primal, tree, heur) );
571
572 SCIP_ALLOC( BMSallocBlockMemory(blkmem, &(*sol)->valsexact ) );
573 SCIP_CALL( SCIPrationalarrayCreate(&(*sol)->valsexact->vals, blkmem) );
574 SCIP_CALL( SCIPboolarrayCreate(&(*sol)->valsexact->valid, blkmem) );
575 SCIP_CALL( SCIPrationalCreateBlock(blkmem, &(*sol)->valsexact->obj) );
576
577 assert(SCIPsolIsExact(*sol));
578
579 return SCIP_OKAY;
580}
581
582/** creates a copy of a primal CIP solution */
584 SCIP_SOL** sol, /**< pointer to store the copy of the primal CIP solution */
585 BMS_BLKMEM* blkmem, /**< block memory */
586 SCIP_SET* set, /**< global SCIP settings */
587 SCIP_STAT* stat, /**< problem statistics data */
588 SCIP_PRIMAL* primal, /**< primal data */
589 SCIP_SOL* sourcesol /**< primal CIP solution to copy */
590 )
591{
592 assert(sol != NULL);
593 assert(sourcesol != NULL);
594
595 SCIP_ALLOC( BMSallocBlockMemory(blkmem, sol) );
596 SCIP_CALL( SCIPrealarrayCopy(&(*sol)->vals, blkmem, sourcesol->vals) );
597 SCIP_CALL( SCIPboolarrayCopy(&(*sol)->valid, blkmem, sourcesol->valid) );
598
599 /* copy solution type and creator information */
600 switch( sourcesol->type )
601 {
606 (*sol)->type = sourcesol->type;
607 break;
609 SCIPsolSetHeur((*sol), SCIPsolGetHeur(sourcesol));
610 break;
612 SCIPsolSetRelax((*sol), SCIPsolGetRelax(sourcesol));
613 break;
614 default:
615 SCIPerrorMessage("Unknown source solution type %d!\n", sourcesol->type);
616 return SCIP_INVALIDDATA;
617 }
618 (*sol)->obj = sourcesol->obj;
619 (*sol)->primalindex = -1;
620 (*sol)->time = sourcesol->time;
621#ifndef NDEBUG
622 (*sol)->lpcount = sourcesol->lpcount;
623#endif
624 (*sol)->nodenum = sourcesol->nodenum;
625 (*sol)->solorigin = sourcesol->solorigin;
626 (*sol)->runnum = sourcesol->runnum;
627 (*sol)->depth = sourcesol->depth;
628 (*sol)->index = stat->solindex;
629 (*sol)->hasinfval = sourcesol->hasinfval;
630 stat->solindex++;
631 (*sol)->viol.absviolbounds = sourcesol->viol.absviolbounds;
632 (*sol)->viol.absviolcons = sourcesol->viol.absviolcons;
633 (*sol)->viol.absviolintegrality = sourcesol->viol.absviolintegrality;
634 (*sol)->viol.absviollprows = sourcesol->viol.absviollprows;
635 (*sol)->viol.relviolbounds = sourcesol->viol.relviolbounds;
636 (*sol)->viol.relviolcons = sourcesol->viol.relviolcons;
637 (*sol)->viol.relviollprows = sourcesol->viol.relviollprows;
638#ifndef NDEBUG
639 (*sol)->scip = set->scip;
640#endif
641
642 /* copy rational values if solution is exact */
643 if( SCIPsolIsExact(sourcesol) )
644 {
645 SCIP_CALL( SCIPvalsExactCopy( &(*sol)->valsexact, blkmem, sourcesol->valsexact) );
646 }
647 else
648 (*sol)->valsexact = NULL;
649
650 SCIP_CALL( SCIPprimalSolCreated(primal, set, *sol) );
651
652 return SCIP_OKAY;
653}
654
655/** transformes given original solution to the transformed space; a corresponding transformed solution has to be given
656 * which is copied into the existing solution and freed afterwards
657 */
659 SCIP_SOL* sol, /**< primal CIP solution to change, living in original space */
660 SCIP_SOL** transsol, /**< pointer to corresponding transformed primal CIP solution */
661 BMS_BLKMEM* blkmem, /**< block memory */
662 SCIP_SET* set, /**< global SCIP settings */
663 SCIP_PRIMAL* primal /**< primal data */
664 )
665{ /*lint --e{715}*/
666 SCIP_REALARRAY* tmpvals;
667 SCIP_BOOLARRAY* tmpvalid;
668 SCIP_SOL* tsol;
669
670 assert(sol != NULL);
671 assert(transsol != NULL);
672 assert(set != NULL);
673 assert(SCIPsolIsOriginal(sol));
674 assert(sol->primalindex > -1);
675
676 tsol = *transsol;
677 assert(tsol != NULL);
678 assert(!SCIPsolIsOriginal(tsol));
679
680 /* switch vals and valid arrays; the exisiting solution gets the arrays of the transformed solution;
681 * the transformed one gets the original arrays, because they have to be freed anyway and freeing the transsol
682 * automatically frees its arrays
683 */
684 tmpvals = sol->vals;
685 tmpvalid = sol->valid;
686 sol->vals = tsol->vals;
687 sol->valid = tsol->valid;
688 tsol->vals = tmpvals;
689 tsol->valid = tmpvalid;
690 if( SCIPsolIsExact(sol) )
691 {
692 SCIP_VALSEXACT* tmpvalsexact;
693 tmpvalsexact = sol->valsexact;
694 sol->valsexact = tsol->valsexact;
695 tsol->valsexact = tmpvalsexact;
696 }
697
698 /* copy solorigin and objective (should be the same, only to avoid numerical issues);
699 * we keep the other statistics of the original solution, since that was the first time that this solution as found
700 */
701 sol->solorigin = tsol->solorigin;
702 sol->obj = tsol->obj;
703
704 SCIP_CALL( SCIPsolFree(transsol, blkmem, primal) );
705
706 return SCIP_OKAY;
707}
708
709/** adjusts solution values of implied integral variables in handed solution, solution objective value is not
710 * deteriorated by this method
711 */
713 SCIP_SOL* sol, /**< primal CIP solution */
714 SCIP_SET* set, /**< global SCIP settings */
715 SCIP_STAT* stat, /**< problem statistics data */
716 SCIP_PROB* prob, /**< either original or transformed problem, depending on sol origin */
717 SCIP_TREE* tree, /**< branch and bound tree */
718 SCIP_Bool uselprows /**< should LP row information be considered for none-objective variables */
719 )
720{
721 SCIP_VAR** vars;
722 int nimplvarsbegin;
723 int nimplvarsend;
724 int v;
725
726 assert(sol != NULL);
727 assert(prob != NULL);
728
729 /* get number of implied integral variables */
730 nimplvarsend = SCIPprobGetNImplVars(prob);
731
732 if( nimplvarsend == 0 )
733 return SCIP_OKAY;
734
735 /* get range of implied integral variables */
736 vars = SCIPprobGetVars(prob);
737 nimplvarsbegin = SCIPprobGetNBinVars(prob) + SCIPprobGetNIntVars(prob);
738 nimplvarsend += nimplvarsbegin;
739
740 /* loop over implied integral variables and round them up or down */
741 for( v = nimplvarsbegin; v < nimplvarsend; ++v )
742 {
743 SCIP_VAR* var;
744 SCIP_Real solval;
745 SCIP_Real obj;
746 SCIP_Real newsolval;
747 SCIP_Bool roundup;
748 SCIP_Bool rounddown;
749 int nuplocks;
750 int ndownlocks;
751
752 var = vars[v];
753
754 assert( SCIPvarIsImpliedIntegral(var) );
755 solval = SCIPsolGetVal(sol, set, stat, var);
756
757 /* we do not need to round integral solution values or those of variables which are not column variables */
759 continue;
760
763 obj = SCIPvarGetUnchangedObj(var);
764
765 roundup = FALSE;
766 rounddown = FALSE;
767
768 /* in case of a non-zero objective coefficient, there is only one possible rounding direction */
769 if( SCIPsetIsFeasNegative(set, obj) )
770 roundup = TRUE;
771 else if( SCIPsetIsFeasPositive(set, obj) )
772 rounddown = TRUE;
773 else if( uselprows )
774 {
775 /* determine rounding direction based on row violations */
776 SCIP_COL* col;
777 SCIP_ROW** rows;
778 SCIP_Real* vals;
779 int nrows;
780 int r;
781
782 col = SCIPvarGetCol(var);
783 vals = SCIPcolGetVals(col);
784 rows = SCIPcolGetRows(col);
785 nrows = SCIPcolGetNNonz(col);
786
787 /* loop over rows and search for equations whose violation can be decreased by rounding */
788 for( r = 0; r < nrows && !(roundup && rounddown); ++r )
789 {
790 SCIP_ROW* row;
791 SCIP_Real activity;
792 SCIP_Real rhs;
793 SCIP_Real lhs;
794
795 row = rows[r];
796
797 if( SCIProwIsLocal(row) || !SCIProwIsInLP(row) )
798 continue;
799
800 rhs = SCIProwGetRhs(row);
801 lhs = SCIProwGetLhs(row);
802
803 if( SCIPsetIsInfinity(set, rhs) || SCIPsetIsInfinity(set, -lhs) )
804 continue;
805
806 activity = SCIProwGetSolActivity(row, set, stat, sol);
807 if( SCIPsetIsFeasLE(set, activity, rhs) && SCIPsetIsFeasLE(set, lhs, activity) )
808 continue;
809
810 assert(! SCIPsetIsZero(set, vals[r]));
811 if( (SCIPsetIsFeasGT(set, activity, rhs) && SCIPsetIsPositive(set, vals[r]))
812 || (SCIPsetIsFeasLT(set, activity, lhs) && SCIPsetIsNegative(set, vals[r])) )
813 rounddown = TRUE;
814 else
815 roundup = TRUE;
816 }
817 }
818
819 /* in case of a tie, we select the rounding step based on the number of variable locks */
820 if( roundup == rounddown )
821 {
822 rounddown = ndownlocks <= nuplocks;
823 roundup = !rounddown;
824 }
825
826 /* round the variable up or down */
827 if( roundup )
828 {
829 newsolval = SCIPsetCeil(set, solval);
830 assert(SCIPsetIsFeasLE(set, newsolval, SCIPvarGetUbGlobal(var)));
831 }
832 else
833 {
834 assert( rounddown ); /* should be true because of the code above */
835 newsolval = SCIPsetFloor(set, solval);
836 assert(SCIPsetIsFeasGE(set, newsolval, SCIPvarGetLbGlobal(var)));
837 }
838
839 SCIP_CALL( SCIPsolSetVal(sol, set, stat, tree, var, newsolval) );
840 }
841
842 return SCIP_OKAY;
843}
844
845/** creates primal CIP solution, initialized to the current LP solution */
847 SCIP_SOL** sol, /**< pointer to primal CIP solution */
848 BMS_BLKMEM* blkmem, /**< block memory */
849 SCIP_SET* set, /**< global SCIP settings */
850 SCIP_STAT* stat, /**< problem statistics data */
851 SCIP_PROB* prob, /**< transformed problem data */
852 SCIP_PRIMAL* primal, /**< primal data */
853 SCIP_TREE* tree, /**< branch and bound tree */
854 SCIP_LP* lp, /**< current LP data */
855 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
856 )
857{
858 assert(sol != NULL);
859 assert(lp != NULL);
860 assert(SCIPlpIsSolved(lp));
861
862 SCIP_CALL( SCIPsolCreate(sol, blkmem, set, stat, primal, tree, heur) );
863 SCIP_CALL( SCIPsolLinkLPSol(*sol, set, stat, prob, tree, lp) );
864
865 return SCIP_OKAY;
866}
867
868/** creates primal CIP solution with exact rational values, initialized to the current exact LP solution
869 * (will use exact safe dual solution if lp was not solved exactly)
870 */
872 SCIP_SOL** sol, /**< pointer to primal CIP solution */
873 BMS_BLKMEM* blkmem, /**< block memory */
874 SCIP_SET* set, /**< global SCIP settings */
875 SCIP_STAT* stat, /**< problem statistics data */
876 SCIP_PRIMAL* primal, /**< primal data */
877 SCIP_TREE* tree, /**< branch and bound tree */
878 SCIP_LPEXACT* lp, /**< current LP data */
879 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
880 )
881{
882 assert(sol != NULL);
883 assert(lp != NULL);
884 assert(lp->solved);
885
886 SCIP_CALL( SCIPsolCreateExact(sol, blkmem, set, stat, primal, tree, heur) );
887 SCIP_CALL( SCIPsolLinkLPSolExact(*sol, set, lp) );
888
889 return SCIP_OKAY;
890}
891
892/** creates primal CIP solution, initialized to the current NLP solution */
894 SCIP_SOL** sol, /**< pointer to primal CIP solution */
895 BMS_BLKMEM* blkmem, /**< block memory */
896 SCIP_SET* set, /**< global SCIP settings */
897 SCIP_STAT* stat, /**< problem statistics data */
898 SCIP_PRIMAL* primal, /**< primal data */
899 SCIP_TREE* tree, /**< branch and bound tree */
900 SCIP_NLP* nlp, /**< current NLP data */
901 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
902 )
903{
904 assert(sol != NULL);
905 assert(nlp != NULL);
906
907 SCIP_CALL( SCIPsolCreate(sol, blkmem, set, stat, primal, tree, heur) );
908 SCIP_CALL( SCIPsolLinkNLPSol(*sol, stat, tree, nlp) );
909
910 return SCIP_OKAY;
911}
912
913/** creates primal CIP solution, initialized to the current relaxation solution */
915 SCIP_SOL** sol, /**< pointer to primal CIP solution */
916 BMS_BLKMEM* blkmem, /**< block memory */
917 SCIP_SET* set, /**< global SCIP settings */
918 SCIP_STAT* stat, /**< problem statistics data */
919 SCIP_PRIMAL* primal, /**< primal data */
920 SCIP_TREE* tree, /**< branch and bound tree */
921 SCIP_RELAXATION* relaxation, /**< global relaxation data */
922 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
923 )
924{
925 assert(sol != NULL);
926 assert(relaxation != NULL);
927 assert(SCIPrelaxationIsSolValid(relaxation));
928
929 SCIP_CALL( SCIPsolCreate(sol, blkmem, set, stat, primal, tree, heur) );
930 SCIP_CALL( SCIPsolLinkRelaxSol(*sol, set, stat, tree, relaxation) );
931
932 /* update solution type and store relaxator as creator only if no heuristic is specified as creator */
933 if( heur == NULL )
935
936 return SCIP_OKAY;
937}
938
939/** creates primal CIP solution, initialized to the current pseudo solution */
941 SCIP_SOL** sol, /**< pointer to primal CIP solution */
942 BMS_BLKMEM* blkmem, /**< block memory */
943 SCIP_SET* set, /**< global SCIP settings */
944 SCIP_STAT* stat, /**< problem statistics data */
945 SCIP_PROB* prob, /**< transformed problem data */
946 SCIP_PRIMAL* primal, /**< primal data */
947 SCIP_TREE* tree, /**< branch and bound tree, or NULL */
948 SCIP_LP* lp, /**< current LP data */
949 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
950 )
951{
952 assert(sol != NULL);
953
954 SCIP_CALL( SCIPsolCreate(sol, blkmem, set, stat, primal, tree, heur) );
955 SCIP_CALL( SCIPsolLinkPseudoSol(*sol, set, stat, prob, tree, lp) );
956
957 /* update solution type to pseudo solution */
958 if( heur == NULL )
959 SCIPsolSetPseudo(*sol);
960
961 return SCIP_OKAY;
962}
963
964/** creates primal CIP solution, initialized to the current exact pseudo solution */
966 SCIP_SOL** sol, /**< pointer to primal CIP solution */
967 BMS_BLKMEM* blkmem, /**< block memory */
968 SCIP_SET* set, /**< global SCIP settings */
969 SCIP_STAT* stat, /**< problem statistics data */
970 SCIP_PRIMAL* primal, /**< primal data */
971 SCIP_TREE* tree, /**< branch and bound tree, or NULL */
972 SCIP_LPEXACT* lp, /**< current LP data */
973 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
974 )
975{
976 assert(sol != NULL);
977
978 SCIP_CALL( SCIPsolCreateExact(sol, blkmem, set, stat, primal, tree, heur) );
980
981 return SCIP_OKAY;
982}
983
984/** creates primal CIP solution, initialized to the current solution */
986 SCIP_SOL** sol, /**< pointer to primal CIP solution */
987 BMS_BLKMEM* blkmem, /**< block memory */
988 SCIP_SET* set, /**< global SCIP settings */
989 SCIP_STAT* stat, /**< problem statistics data */
990 SCIP_PROB* prob, /**< transformed problem data */
991 SCIP_PRIMAL* primal, /**< primal data */
992 SCIP_TREE* tree, /**< branch and bound tree */
993 SCIP_LP* lp, /**< current LP data */
994 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
995 )
996{
997 assert(tree != NULL);
998
999 if( SCIPtreeHasCurrentNodeLP(tree) )
1000 {
1001 SCIP_CALL( SCIPsolCreateLPSol(sol, blkmem, set, stat, prob, primal, tree, lp, heur) );
1002 }
1003 else
1004 {
1005 SCIP_CALL( SCIPsolCreatePseudoSol(sol, blkmem, set, stat, prob, primal, tree, lp, heur) );
1006 }
1007
1008 return SCIP_OKAY;
1009}
1010
1011/** creates primal CIP solution with exact rational values, initialized to the current solution */
1013 SCIP_SOL** sol, /**< pointer to primal CIP solution */
1014 BMS_BLKMEM* blkmem, /**< block memory */
1015 SCIP_SET* set, /**< global SCIP settings */
1016 SCIP_STAT* stat, /**< problem statistics data */
1017 SCIP_PRIMAL* primal, /**< primal data */
1018 SCIP_TREE* tree, /**< branch and bound tree */
1019 SCIP_LPEXACT* lp, /**< current LP data */
1020 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
1021 )
1022{
1023 assert(tree != NULL);
1024
1025 if( SCIPtreeHasCurrentNodeLP(tree) )
1026 {
1027 assert(lp->solved);
1028 SCIP_CALL( SCIPsolCreateLPSolExact(sol, blkmem, set, stat, primal, tree, lp, heur) );
1029 }
1030 else
1031 {
1032 SCIP_CALL( SCIPsolCreatePseudoSolExact(sol, blkmem, set, stat, primal, tree, lp, heur) );
1033 }
1034
1035 return SCIP_OKAY;
1036}
1037
1038/** creates partial primal CIP solution, initialized to unknown values */
1040 SCIP_SOL** sol, /**< pointer to primal CIP solution */
1041 BMS_BLKMEM* blkmem, /**< block memory */
1042 SCIP_SET* set, /**< global SCIP settings */
1043 SCIP_STAT* stat, /**< problem statistics data */
1044 SCIP_PRIMAL* primal, /**< primal data */
1045 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
1046 )
1047{
1048 assert(sol != NULL);
1049 assert(blkmem != NULL);
1050 assert(set != NULL);
1051 assert(stat != NULL);
1052 assert(primal != NULL);
1053
1054 SCIP_ALLOC( BMSallocBlockMemory(blkmem, sol) );
1055 SCIP_CALL( SCIPrealarrayCreate(&(*sol)->vals, blkmem) );
1056 SCIP_CALL( SCIPboolarrayCreate(&(*sol)->valid, blkmem) );
1057 (*sol)->solorigin = SCIP_SOLORIGIN_PARTIAL;
1058 (*sol)->obj = SCIP_UNKNOWN;
1059 (*sol)->primalindex = -1;
1060 (*sol)->index = stat->solindex;
1061 (*sol)->hasinfval = FALSE;
1062 (*sol)->valsexact = NULL;
1063#ifndef NDEBUG
1064 (*sol)->scip = set->scip;
1065#endif
1066 stat->solindex++;
1067 solStamp(*sol, stat, NULL, TRUE);
1069
1070 /* set solution type and creator depending on whether a heuristic or NULL is passed */
1071 SCIPsolSetHeur(*sol, heur);
1072
1073 SCIP_CALL( SCIPprimalSolCreated(primal, set, *sol) );
1074
1075 return SCIP_OKAY;
1076}
1077
1078/** creates primal CIP solution, initialized to unknown values */
1080 SCIP_SOL** sol, /**< pointer to primal CIP solution */
1081 BMS_BLKMEM* blkmem, /**< block memory */
1082 SCIP_SET* set, /**< global SCIP settings */
1083 SCIP_STAT* stat, /**< problem statistics data */
1084 SCIP_PRIMAL* primal, /**< primal data */
1085 SCIP_TREE* tree, /**< branch and bound tree */
1086 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
1087 )
1088{
1089 assert(sol != NULL);
1090 assert(blkmem != NULL);
1091 assert(stat != NULL);
1092
1093 SCIP_ALLOC( BMSallocBlockMemory(blkmem, sol) );
1094 SCIP_CALL( SCIPrealarrayCreate(&(*sol)->vals, blkmem) );
1095 SCIP_CALL( SCIPboolarrayCreate(&(*sol)->valid, blkmem) );
1096 (*sol)->solorigin = SCIP_SOLORIGIN_UNKNOWN;
1097 (*sol)->obj = 0.0;
1098 (*sol)->primalindex = -1;
1099 (*sol)->index = stat->solindex;
1100 (*sol)->hasinfval = FALSE;
1101 (*sol)->valsexact = NULL;
1102 stat->solindex++;
1103 solStamp(*sol, stat, tree, TRUE);
1105
1106 /* set solution type and creator depending on whether a heuristic or NULL is passed */
1107 SCIPsolSetHeur(*sol, heur);
1108
1109 SCIP_CALL( SCIPprimalSolCreated(primal, set, *sol) );
1110
1111 return SCIP_OKAY;
1112}
1113
1114/** frees exact solution values */
1115static
1117 SCIP_VALSEXACT** valsexact, /**< pointer to primal CIP solution */
1118 BMS_BLKMEM* blkmem /**< block memory */
1119 )
1120{
1121 assert(valsexact != NULL);
1122 assert(*valsexact != NULL);
1123
1124 SCIPrationalFreeBlock(blkmem, &(*valsexact)->obj);
1125 SCIP_CALL( SCIPrationalarrayFree(&(*valsexact)->vals, blkmem) );
1126 SCIP_CALL( SCIPboolarrayFree(&(*valsexact)->valid) );
1127 BMSfreeBlockMemory(blkmem, valsexact);
1128
1129 return SCIP_OKAY;
1130}
1131
1132/** frees primal CIP solution */
1134 SCIP_SOL** sol, /**< pointer to primal CIP solution */
1135 BMS_BLKMEM* blkmem, /**< block memory */
1136 SCIP_PRIMAL* primal /**< primal data */
1137 )
1138{
1139 assert(sol != NULL);
1140 assert(*sol != NULL);
1141
1142 SCIPprimalSolFreed(primal, *sol);
1143
1144 SCIP_CALL( SCIPrealarrayFree(&(*sol)->vals) );
1145 SCIP_CALL( SCIPboolarrayFree(&(*sol)->valid) );
1146 if( SCIPsolIsExact(*sol) )
1147 {
1148 SCIP_CALL( valsExactFree(&((*sol)->valsexact), blkmem) );
1149 }
1150 BMSfreeBlockMemory(blkmem, sol);
1151
1152 return SCIP_OKAY;
1153}
1154
1155/** copies current LP solution into CIP solution by linking */
1157 SCIP_SOL* sol, /**< primal CIP solution */
1158 SCIP_SET* set, /**< global SCIP settings */
1159 SCIP_STAT* stat, /**< problem statistics data */
1160 SCIP_PROB* prob, /**< transformed problem data */
1161 SCIP_TREE* tree, /**< branch and bound tree */
1162 SCIP_LP* lp /**< current LP data */
1163 )
1164{
1165 assert(sol != NULL);
1166 assert(stat != NULL);
1167 assert(tree != NULL);
1168 assert(lp != NULL);
1169 assert(lp->solved);
1170 assert(SCIPlpDiving(lp) || SCIPtreeProbing(tree) || !SCIPlpDivingObjChanged(lp));
1171
1172 SCIPsetDebugMsg(set, "linking solution to LP\n");
1173
1174 /* clear the old solution arrays */
1175 SCIP_CALL( solClearArrays(sol) );
1176
1177 /* link solution to LP solution */
1178 if( SCIPlpDivingObjChanged(lp) )
1179 {
1180 /* the objective value has to be calculated manually, because the LP's value is invalid;
1181 * use objective values of variables, because columns objective values are changed to dive values
1182 */
1183 sol->obj = SCIPlpGetLooseObjval(lp, set, prob);
1184 if( !SCIPsetIsInfinity(set, -sol->obj) )
1185 {
1186 SCIP_VAR* var;
1187 SCIP_COL** cols;
1188 int ncols;
1189 int c;
1190
1191 cols = SCIPlpGetCols(lp);
1192 ncols = SCIPlpGetNCols(lp);
1193 for( c = 0; c < ncols; ++c )
1194 {
1195 var = SCIPcolGetVar(cols[c]);
1196 sol->obj += SCIPvarGetUnchangedObj(var) * cols[c]->primsol;
1197 }
1198 }
1199 }
1200 else
1201 {
1202 /* the objective value in the columns is correct, s.t. the LP's objective value is also correct */
1203 sol->obj = SCIPlpGetObjval(lp, set, prob);
1204 }
1206 solStamp(sol, stat, tree, TRUE);
1207
1208 SCIPsetDebugMsg(set, " -> objective value: %g\n", sol->obj);
1209
1210 return SCIP_OKAY;
1211}
1212
1213/** copies current exact LP solution into exact CIP solution by linking */
1215 SCIP_SOL* sol, /**< primal CIP solution */
1216 SCIP_SET* set, /**< global SCIP settings */
1217 SCIP_LPEXACT* lp /**< current LP data */
1218 )
1219{
1220 assert(sol != NULL);
1221 assert(lp != NULL);
1222 assert(lp->solved);
1223 assert(SCIPsolIsExact(sol));
1224
1225 /* clear the old solution arrays */
1226 SCIP_CALL( solClearArrays(sol) );
1227
1228 /* the objective value in the columns is correct, s.t. the LP's objective value is also correct */
1232
1233 return SCIP_OKAY;
1234}
1235
1236/** copies current NLP solution into CIP solution by linking */
1238 SCIP_SOL* sol, /**< primal CIP solution */
1239 SCIP_STAT* stat, /**< problem statistics data */
1240 SCIP_TREE* tree, /**< branch and bound tree */
1241 SCIP_NLP* nlp /**< current NLP data */
1242 )
1243{
1244 assert(sol != NULL);
1245 assert(stat != NULL);
1246 assert(tree != NULL);
1247 assert(nlp != NULL);
1248 assert(SCIPnlpHasSolution(nlp));
1249
1250 SCIPstatDebugMsg(stat, "linking solution to NLP\n");
1251
1252 /* clear the old solution arrays */
1253 SCIP_CALL( solClearArrays(sol) );
1254
1255 /* get objective value of NLP solution */
1256 if( SCIPnlpIsDivingObjChanged(nlp) )
1257 {
1258 /* the objective value has to be calculated manually, because the NLP's value is invalid */
1259
1260 SCIP_VAR** vars;
1261 int nvars;
1262 int v;
1263
1264 sol->obj = 0.0;
1265
1266 vars = SCIPnlpGetVars(nlp);
1267 nvars = SCIPnlpGetNVars(nlp);
1268 for( v = 0; v < nvars; ++v )
1269 {
1270 assert(SCIPvarIsActive(vars[v]));
1271 sol->obj += SCIPvarGetUnchangedObj(vars[v]) * SCIPvarGetNLPSol(vars[v]);
1272 }
1273 }
1274 else
1275 {
1276 sol->obj = SCIPnlpGetObjval(nlp);
1277 }
1278
1280 solStamp(sol, stat, tree, TRUE);
1281
1282 SCIPstatDebugMsg(stat, " -> objective value: %g\n", sol->obj);
1283
1284 return SCIP_OKAY;
1285}
1286
1287/** copies current relaxation solution into CIP solution by linking */
1289 SCIP_SOL* sol, /**< primal CIP solution */
1290 SCIP_SET* set, /**< global SCIP settings */
1291 SCIP_STAT* stat, /**< problem statistics data */
1292 SCIP_TREE* tree, /**< branch and bound tree */
1293 SCIP_RELAXATION* relaxation /**< global relaxation data */
1294 )
1295{ /*lint --e{715}*/
1296 assert(sol != NULL);
1297 assert(stat != NULL);
1298 assert(tree != NULL);
1299 assert(relaxation != NULL);
1300 assert(SCIPrelaxationIsSolValid(relaxation));
1301
1302 SCIPsetDebugMsg(set, "linking solution to relaxation\n");
1303
1304 /* clear the old solution arrays */
1305 SCIP_CALL( solClearArrays(sol) );
1306
1307 /* the objective value in the columns is correct, s.t. the LP's objective value is also correct */
1308 sol->obj = SCIPrelaxationGetSolObj(relaxation);
1310 solStamp(sol, stat, tree, TRUE);
1311
1312 SCIPsetDebugMsg(set, " -> objective value: %g\n", sol->obj);
1313
1314 return SCIP_OKAY;
1315}
1316
1317/** copies current pseudo solution into CIP solution by linking */
1319 SCIP_SOL* sol, /**< primal CIP solution */
1320 SCIP_SET* set, /**< global SCIP settings */
1321 SCIP_STAT* stat, /**< problem statistics data */
1322 SCIP_PROB* prob, /**< transformed problem data */
1323 SCIP_TREE* tree, /**< branch and bound tree, or NULL */
1324 SCIP_LP* lp /**< current LP data */
1325 )
1326{
1327 assert(sol != NULL);
1328 assert(stat != NULL);
1329 assert(tree != NULL);
1330
1331 SCIPsetDebugMsg(set, "linking solution to pseudo solution\n");
1332
1333 /* clear the old solution arrays */
1334 SCIP_CALL( solClearArrays(sol) );
1335
1336 /* link solution to pseudo solution */
1337 sol->obj = SCIPlpGetPseudoObjval(lp, set, prob);
1339 solStamp(sol, stat, tree, TRUE);
1340
1341 SCIPsetDebugMsg(set, " -> objective value: %g\n", sol->obj);
1342
1343 return SCIP_OKAY;
1344}
1345
1346/** copies current exact pseudo solution into exact CIP solution by linking */
1348 SCIP_SOL* sol, /**< primal CIP solution */
1349 SCIP_SET* set, /**< global SCIP settings */
1350 SCIP_LPEXACT* lp /**< current LP data */
1351 )
1352{
1353 assert(sol != NULL);
1354 assert(SCIPsolIsExact(sol));
1355
1356 /* clear the old solution arrays */
1357 SCIP_CALL( solClearArrays(sol) );
1358
1359 /* link solution to pseudo solution */
1361
1362 SCIPsetDebugMsg(set, " -> objective value: %g\n", sol->obj);
1363
1364 return SCIP_OKAY;
1365}
1366
1367/** copies current solution (LP or pseudo solution) into CIP solution by linking */
1369 SCIP_SOL* sol, /**< primal CIP solution */
1370 SCIP_SET* set, /**< global SCIP settings */
1371 SCIP_STAT* stat, /**< problem statistics data */
1372 SCIP_PROB* prob, /**< transformed problem data */
1373 SCIP_TREE* tree, /**< branch and bound tree */
1374 SCIP_LP* lp /**< current LP data */
1375 )
1376{
1377 assert(tree != NULL);
1378
1379 SCIPsetDebugMsg(set, "linking solution to current solution\n");
1380
1381 if( SCIPtreeHasCurrentNodeLP(tree) && SCIPlpIsSolved(lp) )
1382 {
1383 SCIP_CALL( SCIPsolLinkLPSol(sol, set, stat, prob, tree, lp) );
1384 }
1385 else
1386 {
1387 SCIP_CALL( SCIPsolLinkPseudoSol(sol, set, stat, prob, tree, lp) );
1388 }
1389
1390 return SCIP_OKAY;
1391}
1392
1393/** clears primal CIP solution */
1395 SCIP_SOL* sol, /**< primal CIP solution */
1396 SCIP_STAT* stat, /**< problem statistics data */
1397 SCIP_TREE* tree /**< branch and bound tree */
1398 )
1399{
1400 assert(sol != NULL);
1401
1402 SCIP_CALL( solClearArrays(sol) );
1404 sol->obj = 0.0;
1405 solStamp(sol, stat, tree, TRUE);
1406
1407 if( SCIPsolIsExact(sol) )
1408 SCIPrationalSetReal(sol->valsexact->obj, 0.0);
1409
1410 return SCIP_OKAY;
1411}
1412
1413/** declares all entries in the primal CIP solution to be unknown */
1415 SCIP_SOL* sol, /**< primal CIP solution */
1416 SCIP_STAT* stat, /**< problem statistics data */
1417 SCIP_TREE* tree /**< branch and bound tree */
1418 )
1419{
1420 assert(sol != NULL);
1421
1422 SCIP_CALL( solClearArrays(sol) );
1424 sol->obj = 0.0;
1425 solStamp(sol, stat, tree, TRUE);
1426
1427 return SCIP_OKAY;
1428}
1429
1430/** stores solution values of variables in solution's own array */
1432 SCIP_SOL* sol, /**< primal CIP solution */
1433 SCIP_SET* set, /**< global SCIP settings */
1434 SCIP_PROB* prob /**< transformed problem data */
1435 )
1436{
1437 int v;
1438
1439 assert(sol != NULL);
1440 assert(prob != NULL);
1441 assert(prob->nvars == 0 || prob->vars != NULL);
1442
1445 {
1446 SCIPsetDebugMsg(set, "completing solution %p\n", (void*)sol);
1447
1448 for( v = 0; v < prob->nvars; ++v )
1449 {
1450 SCIP_CALL( solUnlinkVar(sol, set, prob->vars[v]) );
1451 }
1452
1453 sol->solorigin = SCIP_SOLORIGIN_ZERO;
1454 }
1455
1456 return SCIP_OKAY;
1457}
1458
1459/** stores solution values of variables in exact solution's own array */
1461 SCIP_SOL* sol, /**< primal CIP solution */
1462 SCIP_SET* set, /**< global SCIP settings */
1463 SCIP_PROB* prob /**< transformed problem data */
1464 )
1465{
1466 int v;
1467
1468 assert(sol != NULL);
1469 assert(prob != NULL);
1470 assert(prob->nvars == 0 || prob->vars != NULL);
1471 assert(SCIPsolIsExact(sol));
1472
1475 {
1476 SCIPsetDebugMsg(set, "completing solution %p\n", (void*)sol);
1477
1478 for( v = 0; v < prob->nvars; ++v )
1479 {
1480 SCIP_CALL( solUnlinkVarExact(sol, set, prob->vars[v]) );
1481 }
1482 }
1483
1484 SCIP_CALL( SCIPsolUnlink(sol, set, prob) );
1485
1486 return SCIP_OKAY;
1487}
1488
1489/** sets value of variable in primal CIP solution */
1491 SCIP_SOL* sol, /**< primal CIP solution */
1492 SCIP_SET* set, /**< global SCIP settings */
1493 SCIP_STAT* stat, /**< problem statistics data */
1494 SCIP_TREE* tree, /**< branch and bound tree, or NULL */
1495 SCIP_VAR* var, /**< variable to add to solution */
1496 SCIP_Real val /**< solution value of variable */
1497 )
1498{
1499 SCIP_Real oldval;
1500
1501 assert(sol != NULL);
1502 assert(stat != NULL);
1503 assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL
1507 || (sol->nodenum == stat->nnodes && sol->runnum == stat->nruns));
1508 assert(var != NULL);
1509 assert(var->scip == sol->scip);
1510 assert(SCIPisFinite(val));
1511
1512 SCIPsetDebugMsg(set, "setting value of <%s> in solution %p to %g\n", SCIPvarGetName(var), (void*)sol, val);
1513
1514 /* we want to store only values for non fixed variables (LOOSE or COLUMN); others have to be transformed */
1515 switch( SCIPvarGetStatus(var) )
1516 {
1518 if( SCIPsolIsOriginal(sol) )
1519 {
1520 oldval = solGetArrayVal(sol, var);
1521
1522 if( val != oldval ) /*lint !e777*/
1523 {
1524 SCIP_CALL( solSetArrayVal(sol, set, var, val) );
1525
1526 /* update the objective value; we do not need to do this for invalid objectives or partial solutions */
1527 if( sol->obj != SCIP_INVALID && !SCIPsolIsPartial(sol) ) /*lint !e777*/
1528 {
1529 SCIP_Real obj;
1530 SCIP_Real oldobjcont;
1531 SCIP_Real newobjcont;
1532
1533 /* an unknown solution value does not count towards the objective */
1534 obj = SCIPvarGetUnchangedObj(var);
1535 oldobjcont = (oldval == SCIP_UNKNOWN ? 0.0 : obj * oldval); /*lint !e777*/
1536 newobjcont = (val == SCIP_UNKNOWN ? 0.0 : obj * val); /*lint !e777*/
1537
1538 /* we want to use a safe invalid if the contribution exchange contradicts the infinity status of the objective value */
1539 if( SCIPsetIsInfinity(set, sol->obj) )
1540 {
1541 if( ( SCIPsetIsInfinity(set, oldobjcont) && !SCIPsetIsInfinity(set, newobjcont) )
1542 || ( !SCIPsetIsInfinity(set, -oldobjcont) && SCIPsetIsInfinity(set, -newobjcont) ) )
1543 sol->obj = SCIP_INVALID;
1544 }
1545 else if( SCIPsetIsInfinity(set, -sol->obj) )
1546 {
1547 if( ( SCIPsetIsInfinity(set, -oldobjcont) && !SCIPsetIsInfinity(set, -newobjcont) )
1548 || ( !SCIPsetIsInfinity(set, oldobjcont) && SCIPsetIsInfinity(set, newobjcont) ) )
1549 sol->obj = SCIP_INVALID;
1550 }
1551 /* we want to use a clean infinity if the contribution exchange or the resulting objective hits the infinity bound */
1552 else
1553 {
1554 if( !SCIPsetIsInfinity(set, MAX(ABS(oldobjcont), ABS(newobjcont))) )
1555 {
1556 sol->obj -= oldobjcont;
1557 sol->obj += newobjcont;
1558
1559 if( SCIPsetIsInfinity(set, sol->obj) )
1560 sol->obj = SCIPsetInfinity(set);
1561 else if( SCIPsetIsInfinity(set, -sol->obj) )
1562 sol->obj = -SCIPsetInfinity(set);
1563 }
1564 else if( !SCIPsetIsInfinity(set, MAX(oldobjcont, -newobjcont)) )
1565 sol->obj = SCIPsetInfinity(set);
1566 else if( !SCIPsetIsInfinity(set, MAX(-oldobjcont, newobjcont)) )
1567 sol->obj = -SCIPsetInfinity(set);
1568 }
1569 }
1570
1571 solStamp(sol, stat, tree, FALSE);
1572 }
1573 return SCIP_OKAY;
1574 }
1575 else
1576 return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetTransVar(var), val);
1577
1580 assert(!SCIPsolIsOriginal(sol));
1582 || sol->lpcount == stat->lpcount);
1583 oldval = solGetArrayVal(sol, var);
1584
1585 if( val != oldval ) /*lint !e777*/
1586 {
1587 SCIP_CALL( solSetArrayVal(sol, set, var, val) );
1588
1589 /* update the objective value; we do not need to do this for invalid objectives */
1590 if( sol->obj != SCIP_INVALID ) /*lint !e777*/
1591 {
1592 SCIP_Real obj;
1593 SCIP_Real oldobjcont;
1594 SCIP_Real newobjcont;
1595
1596 /* an unknown solution value does not count towards the objective */
1597 obj = SCIPvarGetUnchangedObj(var);
1598 oldobjcont = (oldval == SCIP_UNKNOWN ? 0.0 : obj * oldval); /*lint !e777*/
1599 newobjcont = (val == SCIP_UNKNOWN ? 0.0 : obj * val); /*lint !e777*/
1600
1601 /* we want to use a safe invalid if the contribution exchange contradicts the infinity status of the objective value */
1602 if( SCIPsetIsInfinity(set, sol->obj) )
1603 {
1604 if( ( SCIPsetIsInfinity(set, oldobjcont) && !SCIPsetIsInfinity(set, newobjcont) )
1605 || ( !SCIPsetIsInfinity(set, -oldobjcont) && SCIPsetIsInfinity(set, -newobjcont) ) )
1606 sol->obj = SCIP_INVALID;
1607 }
1608 else if( SCIPsetIsInfinity(set, -sol->obj) )
1609 {
1610 if( ( SCIPsetIsInfinity(set, -oldobjcont) && !SCIPsetIsInfinity(set, -newobjcont) )
1611 || ( !SCIPsetIsInfinity(set, oldobjcont) && SCIPsetIsInfinity(set, newobjcont) ) )
1612 sol->obj = SCIP_INVALID;
1613 }
1614 /* we want to use a clean infinity if the contribution exchange or the resulting objective hits the infinity bound */
1615 else
1616 {
1617 if( !SCIPsetIsInfinity(set, MAX(ABS(oldobjcont), ABS(newobjcont))) )
1618 {
1619 sol->obj -= oldobjcont;
1620 sol->obj += newobjcont;
1621
1622 if( SCIPsetIsInfinity(set, sol->obj) )
1623 sol->obj = SCIPsetInfinity(set);
1624 else if( SCIPsetIsInfinity(set, -sol->obj) )
1625 sol->obj = -SCIPsetInfinity(set);
1626 }
1627 else if( !SCIPsetIsInfinity(set, MAX(oldobjcont, -newobjcont)) )
1628 sol->obj = SCIPsetInfinity(set);
1629 else if( !SCIPsetIsInfinity(set, MAX(-oldobjcont, newobjcont)) )
1630 sol->obj = -SCIPsetInfinity(set);
1631 }
1632 }
1633
1634 solStamp(sol, stat, tree, FALSE);
1635 }
1636 return SCIP_OKAY;
1637
1639 assert(!SCIPsolIsOriginal(sol));
1640 oldval = SCIPvarGetLbGlobal(var);
1641 if( val != oldval ) /*lint !e777*/
1642 {
1643 SCIPerrorMessage("cannot set solution value for variable <%s> fixed to %.15g to different value %.15g\n",
1644 SCIPvarGetName(var), oldval, val);
1645 return SCIP_INVALIDDATA;
1646 }
1647 return SCIP_OKAY;
1648
1649 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
1650 assert(!SCIPsetIsZero(set, SCIPvarGetAggrScalar(var)));
1653
1654 if( val == SCIP_UNKNOWN )/*lint !e777*/
1655 return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetAggrVar(var), val);
1656 if( SCIPsetIsInfinity(set, val) || SCIPsetIsInfinity(set, -val) )
1657 return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetAggrVar(var), SCIPvarGetAggrScalar(var) > 0 ? val : -val);
1658 else
1659 return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetAggrVar(var), (val - SCIPvarGetAggrConstant(var))/SCIPvarGetAggrScalar(var));
1660
1662 if ( SCIPvarGetMultaggrNVars(var) == 1 )
1663 {
1664 SCIP_VAR** multaggrvars;
1665 SCIP_Real* multaggrscalars;
1666 SCIP_Real multaggrconstant;
1667
1668 multaggrvars = SCIPvarGetMultaggrVars(var);
1669 multaggrscalars = SCIPvarGetMultaggrScalars(var);
1670 multaggrconstant = SCIPvarGetMultaggrConstant(var);
1671
1672 if( SCIPsetIsInfinity(set, multaggrconstant) || SCIPsetIsInfinity(set, -multaggrconstant) )
1673 {
1674 if( (SCIPsetIsInfinity(set, multaggrconstant) && !SCIPsetIsInfinity(set, val))
1675 || (SCIPsetIsInfinity(set, -multaggrconstant) && !SCIPsetIsInfinity(set, -val)) )
1676 {
1677 SCIPerrorMessage("cannot set solution value for variable <%s> fixed to %.15g to different value %.15g\n",
1678 SCIPvarGetName(var), multaggrconstant, val);
1679 return SCIP_INVALIDDATA;
1680 }
1681 return SCIP_OKAY;
1682 }
1683 else
1684 {
1685 if( SCIPsetIsInfinity(set, val) || SCIPsetIsInfinity(set, -val) )
1686 return SCIPsolSetVal(sol, set, stat, tree, multaggrvars[0], multaggrscalars[0] > 0 ? val : -val);
1687 else
1688 return SCIPsolSetVal(sol, set, stat, tree, multaggrvars[0], (val - multaggrconstant)/multaggrscalars[0]);
1689 }
1690 }
1691 SCIPerrorMessage("cannot set solution value for multiple aggregated variable\n");
1692 return SCIP_INVALIDDATA;
1693
1696
1697 if( val == SCIP_UNKNOWN )/*lint !e777*/
1698 return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetNegationVar(var), val);
1699 else if( SCIPsetIsInfinity(set, val) || SCIPsetIsInfinity(set, -val) )
1700 return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetNegationVar(var), -val);
1701 else
1702 return SCIPsolSetVal(sol, set, stat, tree, SCIPvarGetNegationVar(var), SCIPvarGetNegationConstant(var) - val);
1703
1704 default:
1705 SCIPerrorMessage("unknown variable status\n");
1706 return SCIP_INVALIDDATA;
1707 }
1708}
1709
1710/** sets value of variable in exact primal CIP solution */
1712 SCIP_SOL* sol, /**< primal CIP solution */
1713 SCIP_SET* set, /**< global SCIP settings */
1714 SCIP_STAT* stat, /**< problem statistics data */
1715 SCIP_TREE* tree, /**< branch and bound tree, or NULL */
1716 SCIP_VAR* var, /**< variable to add to solution */
1717 SCIP_RATIONAL* val /**< solution value of variable */
1718 )
1719{
1720 SCIP_RATIONAL* oldval;
1721 SCIP_RATIONAL* tmp;
1722 SCIP_RETCODE retcode;
1723
1724 assert(sol != NULL);
1725 assert(stat != NULL);
1726 assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL
1730 assert(var != NULL);
1731 assert(!SCIPrationalIsAbsInfinity(val));
1732 assert(SCIPsolIsExact(sol));
1733
1734 SCIPsetDebugMsg(set, "setting value of <%s> in exact solution %p to %g\n", SCIPvarGetName(var), (void*)sol, SCIPrationalGetReal(val));
1735
1736 /* we want to store only values for non fixed variables (LOOSE or COLUMN); others have to be transformed */
1737 switch( SCIPvarGetStatusExact(var) )
1738 {
1741 {
1742 SCIP_CALL( SCIPrationalCreateBuffer(set->buffer, &oldval) );
1743
1744 solGetArrayValExact(oldval, sol, var);
1745
1746 if( !SCIPrationalIsEQ(val, oldval) )
1747 {
1748 SCIP_RATIONAL* obj;
1749
1750 SCIP_CALL( solSetArrayValExact(sol, set, var, val) );
1751 obj = SCIPvarGetObjExact(var);
1752 SCIPrationalDiffProd(sol->valsexact->obj, obj, oldval);
1753
1754 SCIPrationalAddProd(sol->valsexact->obj, obj, val);
1755 }
1756
1757 SCIPrationalFreeBuffer(set->buffer, &oldval);
1758 return SCIP_OKAY;
1759 }
1760 else
1761 return SCIPsolSetValExact(sol, set, stat, tree, SCIPvarGetTransVar(var), val);
1762
1765 assert(sol->solorigin != SCIP_SOLORIGIN_ORIGINAL);
1766 SCIP_CALL( SCIPrationalCreateBuffer(set->buffer, &oldval) );
1767
1768 solGetArrayValExact(oldval, sol, var);
1769
1770 if( !SCIPrationalIsEQ(val, oldval) )
1771 {
1772 SCIP_RATIONAL* obj;
1773 SCIP_CALL( solSetArrayValExact(sol, set, var, val) );
1774 obj = SCIPvarGetObjExact(var);
1775 SCIPrationalDiffProd(sol->valsexact->obj, obj, oldval);
1776 SCIPrationalAddProd(sol->valsexact->obj, obj, val);
1777 }
1778
1779 SCIPrationalFreeBuffer(set->buffer, &oldval);
1780 return SCIP_OKAY;
1781
1783 assert(sol->solorigin != SCIP_SOLORIGIN_ORIGINAL);
1785 {
1786 SCIPerrorMessage("cannot set solution value for variable <%s> fixed to %.15g to different value %.15g\n",
1788 return SCIP_INVALIDDATA;
1789 }
1790 return SCIP_OKAY;
1791
1792 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
1796
1797 SCIP_CALL( SCIPrationalCreateBuffer(set->buffer, &tmp) );
1798
1799 if( SCIPrationalIsAbsInfinity(val) )
1800 {
1802 SCIPrationalNegate(tmp, val);
1803 retcode = SCIPsolSetValExact(sol, set, stat, tree, SCIPvarGetAggrVar(var), tmp);
1804 }
1805 else
1806 {
1809 retcode = SCIPsolSetValExact(sol, set, stat, tree, SCIPvarGetAggrVar(var), tmp);
1810 }
1811
1812 SCIPrationalFreeBuffer(set->buffer, &tmp);
1813 return retcode;
1814
1816 SCIPerrorMessage("cannot set solution value for multiple aggregated variable\n");
1817 SCIPABORT();
1818 return SCIP_INVALIDDATA;
1819
1822
1823 return SCIPsolSetValExact(sol, set, stat, tree, SCIPvarGetNegationVar(var), val);
1824
1825 default:
1826 SCIPerrorMessage("unknown variable status\n");
1827 return SCIP_INVALIDDATA;
1828 }
1829}
1830
1831/** increases value of variable in primal CIP solution */
1833 SCIP_SOL* sol, /**< primal CIP solution */
1834 SCIP_SET* set, /**< global SCIP settings */
1835 SCIP_STAT* stat, /**< problem statistics data */
1836 SCIP_TREE* tree, /**< branch and bound tree */
1837 SCIP_VAR* var, /**< variable to increase solution value for */
1838 SCIP_Real incval /**< increment for solution value of variable */
1839 )
1840{
1841 SCIP_Real oldval;
1842
1843 assert(sol != NULL);
1844 assert(stat != NULL);
1845 assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL
1847 || (sol->nodenum == stat->nnodes && sol->runnum == stat->nruns));
1848 assert(var != NULL);
1849 assert(!SCIPsetIsInfinity(set, incval) && !SCIPsetIsInfinity(set, -incval));
1850
1851 SCIPsetDebugMsg(set, "increasing value of <%s> in solution %p by %g\n", SCIPvarGetName(var), (void*)sol, incval);
1852
1853 if( incval == 0.0 )
1854 return SCIP_OKAY;
1855
1857 || sol->lpcount == stat->lpcount);
1858
1859 oldval = solGetArrayVal(sol, var);
1860 if( SCIPsetIsInfinity(set, oldval) || SCIPsetIsInfinity(set, -oldval) )
1861 return SCIP_OKAY;
1862
1863 /* we want to store only values for non fixed variables (LOOSE or COLUMN); others have to be transformed */
1864 /* @todo: handle strange cases, such as sums that yield infinite values */
1865 switch( SCIPvarGetStatus(var) )
1866 {
1868 if( SCIPsolIsOriginal(sol) )
1869 {
1870 SCIP_CALL( solIncArrayVal(sol, set, var, incval) );
1871 sol->obj += SCIPvarGetUnchangedObj(var) * incval;
1872 solStamp(sol, stat, tree, FALSE);
1873 return SCIP_OKAY;
1874 }
1875 else
1876 return SCIPsolIncVal(sol, set, stat, tree, SCIPvarGetTransVar(var), incval);
1877
1880 assert(!SCIPsolIsOriginal(sol));
1881 SCIP_CALL( solIncArrayVal(sol, set, var, incval) );
1882 sol->obj += SCIPvarGetUnchangedObj(var) * incval;
1883 solStamp(sol, stat, tree, FALSE);
1884 return SCIP_OKAY;
1885
1887 SCIPerrorMessage("cannot increase solution value for fixed variable\n");
1888 return SCIP_INVALIDDATA;
1889
1890 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
1891 assert(!SCIPsetIsZero(set, SCIPvarGetAggrScalar(var)));
1892 return SCIPsolIncVal(sol, set, stat, tree, SCIPvarGetAggrVar(var), incval/SCIPvarGetAggrScalar(var));
1893
1895 SCIPerrorMessage("cannot increase solution value for multiple aggregated variable\n");
1896 return SCIP_INVALIDDATA;
1897
1899 return SCIPsolIncVal(sol, set, stat, tree, SCIPvarGetNegationVar(var), -incval);
1900
1901 default:
1902 SCIPerrorMessage("unknown variable status\n");
1903 return SCIP_INVALIDDATA;
1904 }
1905}
1906
1907/** returns value of variable in primal CIP solution */
1909 SCIP_SOL* sol, /**< primal CIP solution */
1910 SCIP_SET* set, /**< global SCIP settings */
1911 SCIP_STAT* stat, /**< problem statistics data */
1912 SCIP_VAR* var /**< variable to get value for */
1913 )
1914{
1915 SCIP_VAR** vars;
1917 SCIP_Real solval;
1918 SCIP_Real solvalsum;
1919 int nvars;
1920 int i;
1921
1922 assert(sol != NULL);
1923 assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL
1927 || (sol->nodenum == stat->nnodes && sol->runnum == stat->nruns));
1928 assert(var != NULL);
1929 assert(var->scip == sol->scip);
1930
1931 /* if the value of a transformed variable in an original solution is requested, we need to project the variable back
1932 * to the original space, the opposite case is handled below
1933 */
1934 if( SCIPsolIsOriginal(sol) && SCIPvarIsTransformed(var) )
1935 {
1936 SCIP_RETCODE retcode;
1937 SCIP_VAR* origvar;
1938 SCIP_Real scalar;
1939 SCIP_Real constant;
1940
1941 /* we cannot get the value of a transformed variable for a solution that lives in the original problem space
1942 * -> get the corresponding original variable first
1943 */
1944 origvar = var;
1945 scalar = 1.0;
1946 constant = 0.0;
1947 retcode = SCIPvarGetOrigvarSum(&origvar, &scalar, &constant);
1948 if ( retcode != SCIP_OKAY )
1949 return SCIP_INVALID;
1950 if( origvar == NULL )
1951 {
1952 /* the variable has no original counterpart: in the original solution, it has a value of zero */
1953 return 0.0;
1954 }
1955 assert(!SCIPvarIsTransformed(origvar));
1956
1957 solval = SCIPsolGetVal(sol, set, stat, origvar);
1958 if( solval == SCIP_UNKNOWN ) /*lint !e777*/
1959 return SCIP_UNKNOWN;
1960 else
1961 return scalar * solval + constant;
1962 }
1963
1964 /* only values for non fixed variables (LOOSE or COLUMN) are stored; others have to be transformed */
1965 switch( SCIPvarGetStatus(var) )
1966 {
1968 if( SCIPsolIsOriginal(sol) )
1969 return solGetArrayVal(sol, var);
1970 else
1971 return SCIPsolGetVal(sol, set, stat, SCIPvarGetTransVar(var));
1972
1975 assert(!SCIPsolIsOriginal(sol));
1977 || sol->lpcount == stat->lpcount);
1978 return solGetArrayVal(sol, var);
1979
1981 assert(!SCIPsolIsOriginal(sol));
1982 assert(SCIPvarGetLbGlobal(var) == SCIPvarGetUbGlobal(var) || (set->exact_enable && SCIPrationalIsEQ(SCIPvarGetLbGlobalExact(var), SCIPvarGetUbGlobalExact(var)))) ; /*lint !e777*/
1983 assert(SCIPvarGetLbLocal(var) == SCIPvarGetUbLocal(var) || (set->exact_enable && SCIPrationalIsEQ(SCIPvarGetLbLocalExact(var), SCIPvarGetUbLocalExact(var)))); /*lint !e777*/
1984 assert(SCIPvarGetLbGlobal(var) == SCIPvarGetLbLocal(var) || (set->exact_enable && SCIPrationalIsEQ(SCIPvarGetLbGlobalExact(var), SCIPvarGetLbLocalExact(var)))); /*lint !e777*/
1985 return SCIPvarGetLbGlobal(var);
1986
1987 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
1988 solval = SCIPsolGetVal(sol, set, stat, SCIPvarGetAggrVar(var));
1989 if( solval == SCIP_UNKNOWN ) /*lint !e777*/
1990 return SCIP_UNKNOWN;
1991 if( SCIPsetIsInfinity(set, solval) || SCIPsetIsInfinity(set, -solval) )
1992 {
1993 if( SCIPvarGetAggrScalar(var) * solval > 0.0 )
1994 return SCIPsetInfinity(set);
1995 if( SCIPvarGetAggrScalar(var) * solval < 0.0 )
1996 return -SCIPsetInfinity(set);
1997 }
1998 return SCIPvarGetAggrScalar(var) * solval + SCIPvarGetAggrConstant(var);
1999
2001 nvars = SCIPvarGetMultaggrNVars(var);
2002 vars = SCIPvarGetMultaggrVars(var);
2004 solvalsum = SCIPvarGetMultaggrConstant(var);
2005 for( i = 0; i < nvars; ++i )
2006 {
2007 solval = SCIPsolGetVal(sol, set, stat, vars[i]);
2008 if( solval == SCIP_UNKNOWN ) /*lint !e777*/
2009 return SCIP_UNKNOWN;
2010 if( SCIPsetIsInfinity(set, solval) || SCIPsetIsInfinity(set, -solval) )
2011 {
2012 if( scalars[i] * solval > 0.0 )
2013 return SCIPsetInfinity(set);
2014 if( scalars[i] * solval < 0.0 )
2015 return -SCIPsetInfinity(set);
2016 }
2017 solvalsum += scalars[i] * solval;
2018 }
2019 return solvalsum;
2020
2022 solval = SCIPsolGetVal(sol, set, stat, SCIPvarGetNegationVar(var));
2023 if( solval == SCIP_UNKNOWN ) /*lint !e777*/
2024 return SCIP_UNKNOWN;
2025 if( SCIPsetIsInfinity(set, solval) )
2026 return -SCIPsetInfinity(set);
2027 if( SCIPsetIsInfinity(set, -solval) )
2028 return SCIPsetInfinity(set);
2029 return SCIPvarGetNegationConstant(var) - solval;
2030
2031 default:
2032 SCIPerrorMessage("unknown variable status\n");
2033 SCIPABORT();
2034 return 0.0; /*lint !e527*/
2035 }
2036}
2037
2038/** returns value of variable in exact primal CIP solution */
2040 SCIP_RATIONAL* res, /**< resulting rational */
2041 SCIP_SOL* sol, /**< primal CIP solution */
2042 SCIP_SET* set, /**< global SCIP settings */
2043 SCIP_STAT* stat, /**< problem statistics data */
2044 SCIP_VAR* var /**< variable to get value for */
2045 )
2046{
2047 SCIP_VAR** vars;
2049 SCIP_RATIONAL* solval;
2050 int nvars;
2051 int i;
2052
2053 assert(sol != NULL);
2054 assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL
2059 assert(var != NULL);
2060 assert(SCIPsolIsExact(sol));
2061
2062 /* if the value of a transformed variable in an original solution is requested, we need to project the variable back
2063 * to the original space, the opposite case is handled below
2064 */
2066 {
2067 SCIP_RETCODE retcode;
2068 SCIP_VAR* origvar;
2069 SCIP_RATIONAL* scalar;
2070 SCIP_RATIONAL* constant;
2071
2072 (void) SCIPrationalCreateBuffer(set->buffer, &scalar);
2073 (void) SCIPrationalCreateBuffer(set->buffer, &constant);
2074
2075 /* we cannot get the value of a transformed variable for a solution that lives in the original problem space
2076 * -> get the corresponding original variable first
2077 */
2078 origvar = var;
2079 SCIPrationalSetFraction(scalar, 1LL, 1LL);
2080 SCIPrationalSetReal(constant, 0.0);
2081 retcode = SCIPvarGetOrigvarSumExact(&origvar, scalar, constant);
2082 if ( retcode != SCIP_OKAY )
2083 {
2084 SCIPABORT();
2085 return;
2086 }
2087 if( origvar == NULL )
2088 {
2089 /* the variable has no original counterpart: in the original solution, it has a value of zero */
2090 SCIPrationalSetReal(res, 0.0);
2091 return;
2092 }
2093
2094 assert(!SCIPvarIsTransformed(origvar));
2095
2096 SCIPsolGetValExact(res, sol, set, stat, origvar);
2097 SCIPrationalMult(res, res, scalar);
2098 SCIPrationalAdd(res, res, constant);
2099
2100 SCIPrationalFreeBuffer(set->buffer, &constant);
2101 SCIPrationalFreeBuffer(set->buffer, &scalar);
2102
2103 return;
2104 }
2105
2106 /* only values for non fixed variables (LOOSE or COLUMN) are stored; others have to be transformed */
2107 switch( SCIPvarGetStatusExact(var) )
2108 {
2111 solGetArrayValExact(res, sol, var);
2112 else
2113 SCIPsolGetValExact(res, sol, set, stat, SCIPvarGetTransVar(var));
2114 break;
2115
2118 assert(sol->solorigin != SCIP_SOLORIGIN_ORIGINAL);
2120 || sol->lpcount == stat->lpcount );
2121 solGetArrayValExact(res, sol, var);
2122 break;
2123
2125 assert(sol->solorigin != SCIP_SOLORIGIN_ORIGINAL);
2126 assert(SCIPrationalIsEQ(SCIPvarGetLbGlobalExact(var), SCIPvarGetUbGlobalExact(var))); /*lint !e777*/
2127 assert(SCIPrationalIsEQ(SCIPvarGetLbLocalExact(var), SCIPvarGetUbLocalExact(var))); /*lint !e777*/
2128 assert(SCIPrationalIsEQ(SCIPvarGetLbGlobalExact(var), SCIPvarGetLbLocalExact(var))); /*lint !e777*/
2130 break;
2131
2132 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
2133 SCIPsolGetValExact(res, sol, set, stat, SCIPvarGetAggrVar(var));
2134 if( SCIPrationalIsAbsInfinity(res) )
2135 {
2137 {
2139 return;
2140 }
2142 {
2144 return;
2145 }
2146 }
2149 break;
2150
2152 (void) SCIPrationalCreateBuffer(set->buffer, &solval);
2153
2154 nvars = SCIPvarGetMultaggrNVars(var);
2155 vars = SCIPvarGetMultaggrVars(var);
2158 for( i = 0; i < nvars; ++i )
2159 {
2160 SCIPsolGetValExact(solval, sol, set, stat, vars[i]);
2161 if( SCIPrationalIsAbsInfinity(solval) )
2162 {
2167 break;
2168 }
2169 SCIPrationalAddProd(res, scalars[i], solval);
2170 }
2171 SCIPrationalFreeBuffer(set->buffer, &solval);
2172 break;
2173
2175 SCIPsolGetValExact(res, sol, set, stat, SCIPvarGetNegationVar(var));
2177 SCIPrationalNegate(res, res);
2178 break;
2179
2180 default:
2181 SCIPerrorMessage("unknown variable status\n");
2182 SCIPABORT();
2183 SCIPrationalSetReal(res, 0.0); /*lint !e527*/
2184 }
2185}
2186
2187/** returns value of variable in primal ray represented by primal CIP solution */
2189 SCIP_SOL* sol, /**< primal CIP solution, representing a primal ray */
2190 SCIP_SET* set, /**< global SCIP settings */
2191 SCIP_STAT* stat, /**< problem statistics data */
2192 SCIP_VAR* var /**< variable to get value for */
2193 )
2194{
2195 SCIP_VAR** vars;
2197 SCIP_Real solval;
2198 SCIP_Real solvalsum;
2199 int nvars;
2200 int i;
2201
2202 assert(sol != NULL);
2203 assert(sol->solorigin == SCIP_SOLORIGIN_ZERO);
2204 assert(var != NULL);
2205
2206 /* only values for non fixed variables (LOOSE or COLUMN) are stored; others have to be transformed */
2207 switch( SCIPvarGetStatus(var) )
2208 {
2210 return SCIPsolGetRayVal(sol, set, stat, SCIPvarGetTransVar(var));
2211
2214 return solGetArrayVal(sol, var);
2215
2217 assert(!SCIPsolIsOriginal(sol));
2218 assert(SCIPvarGetLbGlobal(var) == SCIPvarGetUbGlobal(var)); /*lint !e777*/
2219 assert(SCIPvarGetLbLocal(var) == SCIPvarGetUbLocal(var)); /*lint !e777*/
2220 assert(SCIPvarGetLbGlobal(var) == SCIPvarGetLbLocal(var)); /*lint !e777*/
2221 return 0.0; /* constants are ignored for computing the ray direction */
2222
2223 case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
2224 solval = SCIPsolGetRayVal(sol, set, stat, SCIPvarGetAggrVar(var));
2225 assert(solval != SCIP_UNKNOWN); /*lint !e777*/
2226 assert(!SCIPsetIsInfinity(set, REALABS(solval)));
2227 return SCIPvarGetAggrScalar(var) * solval; /* constants are ignored for computing the ray direction */
2228
2230 nvars = SCIPvarGetMultaggrNVars(var);
2231 vars = SCIPvarGetMultaggrVars(var);
2233 solvalsum = 0.0; /* constants are ignored for computing the ray direction */
2234 for( i = 0; i < nvars; ++i )
2235 {
2236 solval = SCIPsolGetRayVal(sol, set, stat, vars[i]);
2237 assert(solval != SCIP_UNKNOWN ); /*lint !e777*/
2238 assert(!SCIPsetIsInfinity(set, REALABS(solval)));
2239 solvalsum += scalars[i] * solval;
2240 }
2241 return solvalsum;
2242
2244 solval = SCIPsolGetRayVal(sol, set, stat, SCIPvarGetNegationVar(var));
2245 assert(solval != SCIP_UNKNOWN); /*lint !e777*/
2246 assert(!SCIPsetIsInfinity(set, REALABS(solval)));
2247 return -solval; /* constants are ignored for computing the ray direction */
2248
2249 default:
2250 SCIPerrorMessage("unknown variable status\n");
2251 SCIPABORT();
2252 return 0.0; /*lint !e527*/
2253 }
2254}
2255
2256/** gets objective value of primal CIP solution in transformed problem */
2258 SCIP_SOL* sol, /**< primal CIP solution */
2259 SCIP_SET* set, /**< global SCIP settings */
2260 SCIP_PROB* transprob, /**< tranformed problem data */
2261 SCIP_PROB* origprob /**< original problem data */
2262 )
2263{
2264 assert(sol != NULL);
2265
2266 /* for original solutions, sol->obj contains the external objective value */
2267 if( SCIPsolIsOriginal(sol) )
2268 return SCIPprobInternObjval(transprob, origprob, set, sol->obj);
2269 else
2270 return sol->obj;
2271}
2272
2273/** gets objective value of exact primal CIP solution in transformed problem */
2275 SCIP_SOL* sol, /**< primal CIP solution */
2276 SCIP_SET* set, /**< global SCIP settings */
2277 SCIP_PROB* transprob, /**< tranformed problem data */
2278 SCIP_PROB* origprob, /**< original problem data */
2279 SCIP_RATIONAL* objval /**< store the result here */
2280 )
2281{
2282 assert(sol != NULL);
2283 assert(SCIPsolIsExact(sol));
2284
2285 /* for original solutions, sol->obj contains the external objective value */
2286 if( SCIPsolIsOriginal(sol) )
2287 SCIPprobInternObjvalExact(transprob, origprob, set, sol->valsexact->obj, objval);
2288 else
2289 SCIPrationalSetRational(objval, sol->valsexact->obj);
2290}
2291
2292/** updates primal solutions after a change in a variable's objective value */
2294 SCIP_SOL* sol, /**< primal CIP solution */
2295 SCIP_VAR* var, /**< problem variable */
2296 SCIP_Real oldobj, /**< old objective value */
2297 SCIP_Real newobj /**< new objective value */
2298 )
2299{
2300 SCIP_Real solval;
2301
2302 assert(sol != NULL);
2303 assert(!SCIPsolIsOriginal(sol));
2305
2306 solval = solGetArrayVal(sol, var);
2307 if( solval != SCIP_UNKNOWN ) /*lint !e777*/
2308 sol->obj += (newobj - oldobj) * solval;
2309}
2310
2311/* mark the given solution as partial solution */
2313 SCIP_SOL* sol, /**< primal CIP solution */
2314 SCIP_SET* set, /**< global SCIP settings */
2315 SCIP_STAT* stat, /**< problem statistics */
2316 SCIP_VAR** vars, /**< problem variables */
2317 int nvars /**< number of problem variables */
2318 )
2319{
2320 SCIP_Real* vals;
2321 int v;
2322
2323 assert(sol != NULL);
2324 assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL);
2325 assert(nvars == 0 || vars != NULL);
2326
2327 if( nvars == 0 )
2328 return SCIP_OKAY;;
2329
2330 SCIP_CALL( SCIPsetAllocBufferArray(set, &vals, nvars) );
2331
2332 /* get values */
2333 for( v = 0; v < nvars; v++ )
2334 {
2335 assert(!SCIPvarIsTransformed(vars[v]));
2336 vals[v] = SCIPsolGetVal(sol, set, stat, vars[v]);
2337 }
2338
2339 /* change origin to partial */
2341
2342 /* set values */
2343 for( v = 0; v < nvars; v++ )
2344 {
2345 int idx = SCIPvarGetIndex(vars[v]);
2346
2347 if( vals[v] != SCIP_UNKNOWN ) /*lint !e777*/
2348 {
2349 /* from now on, variable must not be deleted */
2350 SCIPvarMarkNotDeletable(vars[v]);
2351
2352 /* mark the variable valid */
2353 SCIP_CALL( SCIPboolarraySetVal(sol->valid, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, TRUE) );
2354
2355 /* set the value in the solution array */
2356 SCIP_CALL( SCIPrealarraySetVal(sol->vals, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, vals[v]) );
2357 }
2358 else
2359 {
2360 /* mark the variable invalid */
2361 SCIP_CALL( SCIPboolarraySetVal(sol->valid, set->mem_arraygrowinit, set->mem_arraygrowfac, idx, FALSE) );
2362 }
2363 }
2364
2365 /* free buffer */
2367
2368 return SCIP_OKAY;
2369}
2370
2371/** checks primal CIP solution for exact feasibility
2372 * (either checks fp values exactly or rational values if it is a rational solution)
2373 */
2374static
2376 SCIP_SOL* sol, /**< primal CIP solution */
2377 SCIP_SET* set, /**< global SCIP settings */
2378 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
2379 BMS_BLKMEM* blkmem, /**< block memory */
2380 SCIP_STAT* stat, /**< problem statistics */
2381 SCIP_PROB* prob, /**< transformed problem data */
2382 SCIP_Bool printreason, /**< Should all reasons of violations be printed? */
2383 SCIP_Bool completely, /**< Should all violations be checked? */
2384 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
2385 SCIP_Bool* feasible /**< stores whether solution is feasible */
2386 )
2387{
2388 SCIP_RESULT result;
2389 SCIP_RATIONAL* solval;
2390 int h;
2391
2392 assert(sol != NULL);
2393 assert(!SCIPsolIsOriginal(sol));
2394 assert(set != NULL);
2395 assert(prob != NULL);
2396 assert(feasible != NULL);
2397
2398 SCIPsetDebugMsg(set, "checking solution with objective value %g (nodenum=%" SCIP_LONGINT_FORMAT ", origin=%u)\n",
2399 sol->obj, sol->nodenum, sol->solorigin);
2400
2401 *feasible = TRUE;
2402
2403 if( !printreason )
2404 completely = FALSE;
2405
2406 SCIP_CALL( SCIPrationalCreateBuffer(set->buffer, &solval) );
2407
2408 /* check whether the solution respects the global bounds of the variables */
2409 {
2410 int v;
2411
2412 for( v = 0; v < prob->nvars && (*feasible || completely); ++v )
2413 {
2414 SCIP_VAR* var;
2415
2416 var = prob->vars[v];
2417 if( SCIPsolIsExact(sol) )
2418 SCIPsolGetValExact(solval, sol, set, stat, var);
2419 else
2420 SCIPrationalSetReal(solval, SCIPsolGetVal(sol, set, stat, var));
2421
2422 if( !SCIPrationalIsAbsInfinity(solval) ) /*lint !e777*/
2423 {
2424 SCIP_RATIONAL* lb;
2425 SCIP_RATIONAL* ub;
2426
2427 lb = SCIPvarGetLbGlobalExact(var);
2428 ub = SCIPvarGetUbGlobalExact(var);
2429
2430 /* if we have to check bound and one of the current bounds is violated */
2431 if( (!SCIPrationalIsNegInfinity(lb) && SCIPrationalIsLT(solval, lb)) || (!SCIPrationalIsInfinity(ub) && SCIPrationalIsGT(solval, ub)) )
2432 {
2433 *feasible = FALSE;
2434
2435 if( printreason )
2436 {
2437 SCIPmessagePrintInfo(messagehdlr, "solution value %g violates bounds of <%s>[%g,%g] by %g\n", SCIPrationalGetReal(solval), SCIPvarGetName(var),
2439 }
2440#ifdef SCIP_DEBUG
2441 else
2442 {
2443 SCIPrationalDebugMessage(" -> solution value %q violates bounds of <%s>[%g,%g]\n", solval, SCIPvarGetName(var),
2445 }
2446#endif
2447 }
2448
2449 /* check whether there are infinite variable values that lead to an objective value of +infinity */
2450 if( *feasible && sol->hasinfval )
2451 {
2452 *feasible = *feasible && (!SCIPrationalIsInfinity(solval) || !SCIPrationalIsPositive(SCIPvarGetObjExact(var)) );
2453 *feasible = *feasible && (!SCIPrationalIsNegInfinity(solval) || !SCIPrationalIsNegative(SCIPvarGetObjExact(var)) );
2454
2457 {
2458 if( printreason )
2459 {
2460 SCIPrationalDebugMessage("infinite solution value %q for variable <%s> with obj %q implies objective value +infinity\n",
2462 }
2463#ifdef SCIP_DEBUG
2464 else
2465 {
2466 SCIPrationalDebugMessage("infinite solution value %q for variable <%s> with obj %g implies objective value +infinity\n",
2467 solval, SCIPvarGetName(var), SCIPvarGetUnchangedObj(var));
2468 }
2469#endif
2470 }
2471 }
2472 }
2473 }
2474 }
2475
2476 /* check whether the solution fulfills all constraints */
2477 for( h = 0; h < set->nconshdlrs && (*feasible || completely); ++h )
2478 {
2479 SCIP_CALL( SCIPconshdlrCheck(set->conshdlrs[h], blkmem, set, stat, sol,
2480 TRUE, checklprows, printreason, completely, &result) );
2481 *feasible = *feasible && (result == SCIP_FEASIBLE);
2482
2483#ifdef SCIP_DEBUG
2484 if( !(*feasible) )
2485 {
2486 SCIPdebugPrintf(" -> infeasibility detected in constraint handler <%s>\n",
2487 SCIPconshdlrGetName(set->conshdlrs[h]));
2488 }
2489#endif
2490 }
2491
2492 SCIPrationalFreeBuffer(set->buffer, &solval);
2493
2494 return SCIP_OKAY;
2495}
2496
2497/** checks solution for feasibility in original problem without adding it to the solution store
2498 *
2499 * We first check the variable bounds. Then we loop over all constraint handlers and constraints, checking each in the
2500 * order of their check priority.
2501 */
2503 SCIP_SOL* sol, /**< primal CIP solution */
2504 SCIP_SET* set, /**< global SCIP settings */
2505 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
2506 BMS_BLKMEM* blkmem, /**< block memory */
2507 SCIP_STAT* stat, /**< problem statistics */
2508 SCIP_PROB* prob, /**< transformed problem data */
2509 SCIP_PRIMAL* primal, /**< primal data */
2510 SCIP_Bool printreason, /**< Should the reason for the violation be printed? */
2511 SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
2512 SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
2513 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
2514 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
2515 SCIP_Bool checkmodifiable, /**< have modifiable constraint to be checked? */
2516 SCIP_Bool* feasible /**< stores whether given solution is feasible */
2517 )
2518{
2519 SCIP_RESULT result;
2520#ifndef NDEBUG
2521 int oldpriority;
2522#endif
2523 int v;
2524 int c;
2525 int h;
2526
2527 assert(sol != NULL);
2528 assert(set != NULL);
2529 assert(prob != NULL);
2530 assert(!prob->transformed);
2531 assert(feasible != NULL);
2532
2533 *feasible = TRUE;
2534
2536
2537 if( !printreason )
2538 completely = FALSE;
2539
2540 /* check bounds */
2541 if( checkbounds )
2542 {
2543 for( v = 0; v < prob->nvars; ++v )
2544 {
2545 SCIP_VAR* var;
2546 SCIP_Real solval;
2547 SCIP_Real lb;
2548 SCIP_Real ub;
2549
2550 var = prob->vars[v];
2551 solval = SCIPsolGetVal(sol, set, stat, var);
2552
2553 lb = SCIPvarGetLbOriginal(var);
2554 ub = SCIPvarGetUbOriginal(var);
2555
2556 if( SCIPprimalUpdateViolations(primal) )
2557 {
2558 SCIPsolUpdateBoundViolation(sol, lb - solval, SCIPrelDiff(lb, solval));
2559 SCIPsolUpdateBoundViolation(sol, solval - ub, SCIPrelDiff(solval, ub));
2560 }
2561
2562 if( SCIPsetIsFeasLT(set, solval, lb) || SCIPsetIsFeasGT(set, solval, ub) )
2563 {
2564 *feasible = FALSE;
2565
2566 if( printreason )
2567 {
2568 SCIPmessagePrintInfo(messagehdlr, "solution violates original bounds of variable <%s> [%g,%g] solution value <%g>\n",
2569 SCIPvarGetName(var), lb, ub, solval);
2570 }
2571
2572 if( !completely )
2573 return SCIP_OKAY;
2574 }
2575 }
2576 }
2577
2578 /* sort original constraint according to check priority */
2580
2581 /* check original constraints
2582 *
2583 * in general modifiable constraints can not be checked, because the variables to fulfill them might be missing in
2584 * the original problem; however, if the solution comes from a heuristic during presolving, modifiable constraints
2585 * have to be checked;
2586 */
2587#ifndef NDEBUG
2588 oldpriority = INT_MAX;
2589#endif
2590 h = 0;
2591 for( c = 0; c < prob->nconss; ++c )
2592 {
2593 SCIP_CONS* cons;
2594 int priority;
2595
2596 cons = prob->origcheckconss[c];
2597 assert( SCIPconsGetHdlr(cons) != NULL );
2599
2600#ifndef NDEBUG
2601 assert( priority <= oldpriority );
2602 oldpriority = priority;
2603#endif
2604
2605 /* check constraints handlers without constraints that have a check priority at least as high as current
2606 * constraint */
2607 while( h < set->nconshdlrs && SCIPconshdlrGetCheckPriority(set->conshdlrs[h]) >= priority )
2608 {
2609 if( !SCIPconshdlrNeedsCons(set->conshdlrs[h]) )
2610 {
2611 SCIP_CALL( SCIPconshdlrCheck(set->conshdlrs[h], blkmem, set, stat, sol,
2612 checkintegrality, checklprows, printreason, completely, &result) );
2613
2614 if( result != SCIP_FEASIBLE )
2615 {
2616 *feasible = FALSE;
2617
2618 if( !completely )
2619 return SCIP_OKAY;
2620 }
2621 }
2622 ++h;
2623 }
2624
2625 /* now check constraint */
2626 if( SCIPconsIsChecked(cons) && (checkmodifiable || !SCIPconsIsModifiable(cons)) )
2627 {
2628 /* check solution */
2629 SCIP_CALL( SCIPconsCheck(cons, set, sol, checkintegrality, checklprows, printreason, &result) );
2630
2631 if( result != SCIP_FEASIBLE )
2632 {
2633 *feasible = FALSE;
2634
2635 if( !completely )
2636 return SCIP_OKAY;
2637 }
2638 }
2639 }
2640
2641 /* one final loop over the remaining constraints handlers without constraints */
2642 while( h < set->nconshdlrs )
2643 {
2644 if( !SCIPconshdlrNeedsCons(set->conshdlrs[h]) )
2645 {
2646 SCIP_CALL( SCIPconshdlrCheck(set->conshdlrs[h], blkmem, set, stat, sol,
2647 checkintegrality, checklprows, printreason, completely, &result) );
2648
2649 if( result != SCIP_FEASIBLE )
2650 {
2651 *feasible = FALSE;
2652
2653 if( !completely )
2654 return SCIP_OKAY;
2655 }
2656 }
2657 ++h;
2658 }
2659
2660 return SCIP_OKAY;
2661}
2662
2663/** checks primal CIP solution for feasibility
2664 *
2665 * @note The difference between SCIPsolCheck() and SCIPcheckSolOrig() is that modifiable constraints are handled
2666 * differently. There might be some variables which do not have an original counter part (e.g. in
2667 * branch-and-price). Therefore, modifiable constraints can not be double-checked in the original space.
2668 */
2670 SCIP_SOL* sol, /**< primal CIP solution */
2671 SCIP_SET* set, /**< global SCIP settings */
2672 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
2673 BMS_BLKMEM* blkmem, /**< block memory */
2674 SCIP_STAT* stat, /**< problem statistics */
2675 SCIP_PROB* prob, /**< transformed problem data */
2676 SCIP_Bool printreason, /**< Should all reasons of violations be printed? */
2677 SCIP_Bool completely, /**< Should all violations be checked? */
2678 SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
2679 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
2680 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
2681 SCIP_Bool* feasible /**< stores whether solution is feasible */
2682 )
2683{
2684 SCIP_RESULT result;
2685 int h;
2686
2687 assert(sol != NULL);
2688 assert(!SCIPsolIsOriginal(sol));
2689 assert(set != NULL);
2690 assert(prob != NULL);
2691 assert(feasible != NULL);
2692
2693 SCIPsetDebugMsg(set, "checking solution with objective value %g (nodenum=%" SCIP_LONGINT_FORMAT ", origin=%d)\n",
2694 sol->obj, sol->nodenum, sol->solorigin);
2695
2696 *feasible = TRUE;
2697
2698 /* have to check bounds without tolerances in exact solving mode */
2699 if( set->exact_enable )
2700 {
2701 SCIP_CALL( solCheckExact(sol, set, messagehdlr, blkmem, stat, prob, printreason,
2702 completely, checklprows, feasible) );
2703 }
2704
2706
2707 if( !printreason )
2708 completely = FALSE;
2709
2710 /* check whether the solution respects the global bounds of the variables */
2711 if( checkbounds || sol->hasinfval )
2712 {
2713 int v;
2714
2715 for( v = 0; v < prob->nvars && (*feasible || completely); ++v )
2716 {
2717 SCIP_VAR* var;
2718 SCIP_Real solval;
2719
2720 var = prob->vars[v];
2721 solval = SCIPsolGetVal(sol, set, stat, var);
2722
2723 if( solval != SCIP_UNKNOWN ) /*lint !e777*/
2724 {
2725 SCIP_Real lb;
2726 SCIP_Real ub;
2727
2728 lb = SCIPvarGetLbGlobal(var);
2729 ub = SCIPvarGetUbGlobal(var);
2730
2731 /* if we have to check bound and one of the current bounds is violated */
2732 if( checkbounds && ((!SCIPsetIsInfinity(set, -lb) && SCIPsetIsFeasLT(set, solval, lb))
2733 || (!SCIPsetIsInfinity(set, ub) && SCIPsetIsFeasGT(set, solval, ub))) )
2734 {
2735 *feasible = FALSE;
2736
2737 if( printreason )
2738 {
2739 SCIPmessagePrintInfo(messagehdlr, "solution value %g violates bounds of <%s>[%g,%g] by %g\n", solval, SCIPvarGetName(var),
2740 SCIPvarGetLbGlobal(var), SCIPvarGetUbGlobal(var), MAX(lb - solval, 0.0) + MAX(solval - ub, 0.0));
2741 }
2742#ifdef SCIP_DEBUG
2743 else
2744 {
2745 SCIPsetDebugMsgPrint(set, " -> solution value %g violates bounds of <%s>[%g,%g]\n", solval, SCIPvarGetName(var),
2747 }
2748#endif
2749 }
2750
2751 /* check whether there are infinite variable values that lead to an objective value of +infinity */
2752 if( *feasible && sol->hasinfval )
2753 {
2754 *feasible = *feasible && (!SCIPsetIsInfinity(set, solval) || SCIPsetIsLE(set, SCIPvarGetUnchangedObj(var), 0.0) );
2755 *feasible = *feasible && (!SCIPsetIsInfinity(set, -solval) || SCIPsetIsGE(set, SCIPvarGetUnchangedObj(var), 0.0) );
2756
2757 if( ((SCIPsetIsInfinity(set, solval) && SCIPsetIsGT(set, SCIPvarGetUnchangedObj(var), 0.0)) || (SCIPsetIsInfinity(set, -solval) && SCIPsetIsLT(set, SCIPvarGetUnchangedObj(var), 0.0))) )
2758 {
2759 if( printreason )
2760 {
2761 SCIPmessagePrintInfo(messagehdlr, "infinite solution value %g for variable <%s> with obj %g implies objective value +infinity\n",
2762 solval, SCIPvarGetName(var), SCIPvarGetUnchangedObj(var));
2763 }
2764#ifdef SCIP_DEBUG
2765 else
2766 {
2767 SCIPsetDebugMsgPrint(set, "infinite solution value %g for variable <%s> with obj %g implies objective value +infinity\n",
2768 solval, SCIPvarGetName(var), SCIPvarGetUnchangedObj(var));
2769 }
2770#endif
2771 }
2772 }
2773 }
2774 }
2775 }
2776
2777 /* check whether the solution fulfills all constraints */
2778 for( h = 0; h < set->nconshdlrs && (*feasible || completely); ++h )
2779 {
2780 SCIP_CALL( SCIPconshdlrCheck(set->conshdlrs[h], blkmem, set, stat, sol,
2781 checkintegrality, checklprows, printreason, completely, &result) );
2782 *feasible = *feasible && (result == SCIP_FEASIBLE);
2783
2784#ifdef SCIP_DEBUG
2785 if( !(*feasible) )
2786 {
2787 SCIPdebugPrintf(" -> infeasibility detected in constraint handler <%s>\n",
2788 SCIPconshdlrGetName(set->conshdlrs[h]));
2789 }
2790#endif
2791 }
2792
2793 return SCIP_OKAY;
2794}
2795
2796/** try to round given solution */
2798 SCIP_SOL* sol, /**< primal solution */
2799 SCIP_SET* set, /**< global SCIP settings */
2800 SCIP_STAT* stat, /**< problem statistics data */
2801 SCIP_PROB* prob, /**< transformed problem data */
2802 SCIP_TREE* tree, /**< branch and bound tree */
2803 SCIP_Bool* success /**< pointer to store whether rounding was successful */
2804 )
2805{
2806 int nvars;
2807 int v;
2808
2809 assert(sol != NULL);
2810 assert(!SCIPsolIsOriginal(sol));
2811 assert(prob != NULL);
2812 assert(prob->transformed);
2813 assert(success != NULL);
2814
2815 /* round all roundable fractional enforced integral variables as long as no unroundable var was found */
2816 nvars = prob->nvars - prob->ncontvars - prob->ncontimplvars;
2817 assert(nvars >= 0);
2818 for( v = 0; v < nvars; ++v )
2819 {
2820 SCIP_VAR* var;
2821 SCIP_Real solval;
2822 SCIP_Bool mayrounddown;
2823 SCIP_Bool mayroundup;
2824
2825 var = prob->vars[v];
2828 || sol->lpcount == stat->lpcount);
2829 solval = solGetArrayVal(sol, var);
2830
2831 /* solutions with unknown entries cannot be rounded */
2832 if( solval == SCIP_UNKNOWN ) /*lint !e777*/
2833 break;
2834
2835 /* if solution value is already integral with feastol, continue */
2836 if( SCIPsetIsFeasIntegral(set, solval) )
2837 continue;
2838
2839 /* get rounding possibilities */
2840 mayrounddown = SCIPvarMayRoundDown(var);
2841 mayroundup = SCIPvarMayRoundUp(var);
2842
2843 /* choose rounding direction */
2844 if( mayrounddown && mayroundup )
2845 {
2846 /* we can round in both directions: round in objective function direction */
2847 if( SCIPvarGetUnchangedObj(var) >= 0.0 )
2848 solval = SCIPsetFeasFloor(set, solval);
2849 else
2850 solval = SCIPsetFeasCeil(set, solval);
2851 }
2852 else if( mayrounddown )
2853 solval = SCIPsetFeasFloor(set, solval);
2854 else if( mayroundup )
2855 solval = SCIPsetFeasCeil(set, solval);
2856 else
2857 break;
2858
2859 /* store new solution value */
2860 SCIP_CALL( SCIPsolSetVal(sol, set, stat, tree, var, solval) );
2861 }
2862
2863 /* check, if rounding was successful */
2864 *success = (v == nvars);
2865
2866 return SCIP_OKAY;
2867}
2868
2869/** copies the real values to the exact arrays of the solution */
2871 SCIP_SOL* sol, /**< primal solution */
2872 BMS_BLKMEM* blkmem, /**< block memory */
2873 SCIP_SET* set, /**< global SCIP settings */
2874 SCIP_STAT* stat, /**< problem statistics data */
2875 SCIP_PROB* prob /**< transformed problem data */
2876 )
2877{
2878 SCIP_RATIONAL* tmp;
2879 int v;
2880
2881 if( SCIPsolIsExact(sol) )
2882 return SCIP_OKAY;
2883
2884 SCIP_ALLOC( BMSallocBlockMemory(blkmem, &sol->valsexact) );
2886 SCIP_CALL( SCIPboolarrayCreate(&sol->valsexact->valid, blkmem) );
2888 SCIP_CALL( SCIPrationalCreateBuffer(set->buffer, &tmp) );
2889
2890 SCIP_CALL( SCIPsolUnlink(sol, set, prob) );
2891
2892 for( v = 0; v < prob->nvars; ++v )
2893 {
2894 SCIPrationalSetReal(tmp, solGetArrayVal(sol, prob->vars[v]));
2895 SCIP_CALL( solSetArrayValExact(sol, set, prob->vars[v], tmp) );
2896 }
2897
2898 SCIPsolRecomputeInternObjExact(sol, set, stat, prob);
2899
2900 SCIPrationalFreeBuffer(set->buffer, &tmp);
2901
2902 return SCIP_OKAY;
2903}
2904
2905/** approximates and copies the exact values to the real arrays of the solution and frees the exact data */
2907 SCIP_SOL* sol, /**< primal solution */
2908 BMS_BLKMEM* blkmem, /**< block memory */
2909 SCIP_SET* set, /**< global SCIP settings */
2910 SCIP_STAT* stat, /**< problem statistics data */
2911 SCIP_PROB* prob /**< transformed problem data */
2912 )
2913{
2914 SCIP_RATIONAL* tmp;
2915 int v;
2916
2917 if( !SCIPsolIsExact(sol) )
2918 return SCIP_OKAY;
2919
2920 SCIP_CALL( SCIPrationalCreateBuffer(set->buffer, &tmp) );
2921
2922 SCIP_CALL( SCIPsolUnlinkExact(sol, set, prob) );
2923
2924 for( v = 0; v < prob->nvars; ++v )
2925 {
2926 solGetArrayValExact(tmp, sol, prob->vars[v]);
2927 SCIP_CALL( solSetArrayVal(sol, set, prob->vars[v], SCIPrationalGetReal(tmp)) );
2928 }
2929
2930 SCIPsolRecomputeObj(sol, set, stat, prob);
2931
2932 SCIPrationalFreeBuffer(set->buffer, &tmp);
2933 SCIPrationalFreeBlock(blkmem, &sol->valsexact->obj);
2935 SCIP_CALL( SCIPrationalarrayFree(&sol->valsexact->vals, blkmem) );
2936 BMSfreeBlockMemory(blkmem, &sol->valsexact);
2937
2938 return SCIP_OKAY;
2939}
2940
2941/** updates the solution value sums in variables by adding the value in the given solution */
2943 SCIP_SOL* sol, /**< primal CIP solution */
2944 SCIP_SET* set, /**< global SCIP settings */
2945 SCIP_STAT* stat, /**< problem statistics data */
2946 SCIP_PROB* prob, /**< transformed problem data */
2947 SCIP_Real weight /**< weight of solution in weighted average */
2948 )
2949{
2950 SCIP_Real solval;
2951 int v;
2952
2953 assert(sol != NULL);
2954 assert(!SCIPsolIsOriginal(sol));
2955 assert(0.0 <= weight && weight <= 1.0);
2956
2957 for( v = 0; v < prob->nvars; ++v )
2958 {
2959 assert(prob->vars[v] != NULL);
2960 solval = SCIPsolGetVal(sol, set, stat, prob->vars[v]);
2961 if( solval != SCIP_UNKNOWN ) /*lint !e777*/
2962 {
2963 prob->vars[v]->primsolavg *= (1.0-weight);
2964 prob->vars[v]->primsolavg += weight*solval;
2965 }
2966 }
2967}
2968
2969/** retransforms solution to original problem space */
2971 SCIP_SOL* sol, /**< primal CIP solution */
2972 SCIP_SET* set, /**< global SCIP settings */
2973 SCIP_STAT* stat, /**< problem statistics data */
2974 SCIP_PROB* origprob, /**< original problem */
2975 SCIP_PROB* transprob, /**< transformed problem */
2976 SCIP_Bool* hasinfval /**< pointer to store whether the solution has infinite values */
2977 )
2978{
2979 SCIP_VAR** transvars;
2980 SCIP_VAR** vars;
2981 SCIP_VAR** activevars;
2982 SCIP_Real* solvals;
2983 SCIP_Real* activevals;
2984 SCIP_Real* transsolvals;
2985 SCIP_Real constant;
2986 int requiredsize;
2987 int ntransvars;
2988 int nactivevars;
2989 int nvars;
2990 int v;
2991 int i;
2992
2993 assert(sol != NULL);
2994 assert(sol->solorigin == SCIP_SOLORIGIN_ZERO);
2995 assert(origprob != NULL);
2996 assert(transprob != NULL);
2997 assert(hasinfval != NULL);
2998 assert(!origprob->transformed);
2999 assert(transprob->transformed);
3000
3001 *hasinfval = FALSE;
3002
3003 /* transform exact values first (needs unchanged solorigin) */
3004 if( SCIPsolIsExact(sol) )
3005 {
3006 SCIP_CALL( SCIPsolRetransformExact(sol, set, stat, origprob, transprob, hasinfval) );
3007 SCIP_CALL( SCIPsolOverwriteFPSolWithExact(sol, set, stat, origprob, transprob, NULL) );
3008 return SCIP_OKAY;
3009 }
3010
3011 /* This method was a performance bottleneck when retransforming a solution during presolving, before flattening the
3012 * aggregation graph. In that case, calling SCIPsolGetVal() on the original variable consumed too much
3013 * time. Therefore, we now first compute the active representation of each original variable using
3014 * SCIPvarGetActiveRepresentatives(), which is much faster, and sum up the solution values of the active variables by
3015 * hand for each original variable.
3016 */
3017 vars = origprob->vars;
3018 nvars = origprob->nvars;
3019 transvars = transprob->vars;
3020 ntransvars = transprob->nvars;
3021
3022 /* allocate temporary memory for getting the active representation of the original variables, buffering the solution
3023 * values of all active variables and storing the original solution values
3024 */
3025 SCIP_CALL( SCIPsetAllocBufferArray(set, &transsolvals, ntransvars + 1) );
3026 SCIP_CALL( SCIPsetAllocBufferArray(set, &activevars, ntransvars + 1) );
3027 SCIP_CALL( SCIPsetAllocBufferArray(set, &activevals, ntransvars + 1) );
3028 SCIP_CALL( SCIPsetAllocBufferArray(set, &solvals, nvars) );
3029 assert(transsolvals != NULL); /* for flexelint */
3030 assert(solvals != NULL); /* for flexelint */
3031
3032 /* get the solution values of all active variables */
3033 for( v = 0; v < ntransvars; ++v )
3034 {
3035 transsolvals[v] = SCIPsolGetVal(sol, set, stat, transvars[v]);
3036 }
3037
3038 /* get the solution in original problem variables */
3039 for( v = 0; v < nvars; ++v )
3040 {
3041 activevars[0] = vars[v];
3042 activevals[0] = 1.0;
3043 nactivevars = 1;
3044 constant = 0.0;
3045
3046 /* get active representation of the original variable */
3047 SCIP_CALL( SCIPvarGetActiveRepresentatives(set, activevars, activevals, &nactivevars, ntransvars + 1, &constant,
3048 &requiredsize) );
3049 assert(requiredsize <= ntransvars);
3050
3051 /* compute solution value of the original variable */
3052 solvals[v] = constant;
3053 for( i = 0; i < nactivevars; ++i )
3054 {
3055 assert(0 <= SCIPvarGetProbindex(activevars[i]) && SCIPvarGetProbindex(activevars[i]) < ntransvars);
3056 assert(!SCIPsetIsInfinity(set, -solvals[v]) || !SCIPsetIsInfinity(set, activevals[i] * transsolvals[SCIPvarGetProbindex(activevars[i])]));
3057 assert(!SCIPsetIsInfinity(set, solvals[v]) || !SCIPsetIsInfinity(set, -activevals[i] * transsolvals[SCIPvarGetProbindex(activevars[i])]));
3058 solvals[v] += activevals[i] * transsolvals[SCIPvarGetProbindex(activevars[i])];
3059 }
3060
3061 if( SCIPsetIsInfinity(set, solvals[v]) )
3062 {
3063 solvals[v] = SCIPsetInfinity(set);
3064 *hasinfval = TRUE;
3065 }
3066 else if( SCIPsetIsInfinity(set, -solvals[v]) )
3067 {
3068 solvals[v] = -SCIPsetInfinity(set);
3069 *hasinfval = TRUE;
3070 }
3071 }
3072
3073 /* clear the solution and convert it into original space */
3074 SCIP_CALL( solClearArrays(sol) );
3076 sol->obj = origprob->objoffset;
3077
3078 /* reinsert the values of the original variables */
3079 for( v = 0; v < nvars; ++v )
3080 {
3081 assert(SCIPvarGetUnchangedObj(vars[v]) == SCIPvarGetObj(vars[v])); /*lint !e777*/
3082
3083 if( solvals[v] != 0.0 )
3084 {
3085 SCIP_CALL( solSetArrayVal(sol, set, vars[v], solvals[v]) );
3086 if( solvals[v] != SCIP_UNKNOWN ) /*lint !e777*/
3087 sol->obj += SCIPvarGetUnchangedObj(vars[v]) * solvals[v];
3088 }
3089 }
3090
3091 /**@todo remember the variables without original counterpart (priced variables) in the solution */
3092
3093 /* free temporary memory */
3094 SCIPsetFreeBufferArray(set, &solvals);
3095 SCIPsetFreeBufferArray(set, &activevals);
3096 SCIPsetFreeBufferArray(set, &activevars);
3097 SCIPsetFreeBufferArray(set, &transsolvals);
3098
3099 return SCIP_OKAY;
3100}
3101
3102/** retransforms exact solution to original problem space */
3104 SCIP_SOL* sol, /**< primal CIP solution */
3105 SCIP_SET* set, /**< global SCIP settings */
3106 SCIP_STAT* stat, /**< problem statistics data */
3107 SCIP_PROB* origprob, /**< original problem */
3108 SCIP_PROB* transprob, /**< transformed problem */
3109 SCIP_Bool* hasinfval /**< pointer to store whether the solution has infinite values */
3110 )
3111{
3112 SCIP_VAR** transvars;
3113 SCIP_VAR** vars;
3114 SCIP_VAR** activevars;
3115 SCIP_RATIONAL** solvals;
3116 SCIP_RATIONAL** activevals;
3117 SCIP_RATIONAL** transsolvals;
3118 SCIP_RATIONAL* constant;
3119 int requiredsize;
3120 int ntransvars;
3121 int nactivevars;
3122 int nvars;
3123 int v;
3124 int i;
3125
3126 assert(sol != NULL);
3127 assert(sol->solorigin == SCIP_SOLORIGIN_ZERO);
3128 assert(origprob != NULL);
3129 assert(transprob != NULL);
3130 assert(hasinfval != NULL);
3131 assert(!origprob->transformed);
3132 assert(transprob->transformed);
3133 assert(SCIPsolIsExact(sol));
3134
3135 *hasinfval = FALSE;
3136
3137 /* This method was a performance bottleneck when retransforming a solution during presolving, before flattening the
3138 * aggregation graph. In that case, calling SCIPsolGetVal() on the original variable consumed too much
3139 * time. Therefore, we now first compute the active representation of each original variable using
3140 * SCIPvarGetActiveRepresentatives(), which is much faster, and sum up the solution values of the active variables by
3141 * hand for each original variable.
3142 */
3143 vars = origprob->vars;
3144 nvars = origprob->nvars;
3145 transvars = transprob->vars;
3146 ntransvars = transprob->nvars;
3147
3148 /* allocate temporary memory for getting the active representation of the original variables, buffering the solution
3149 * values of all active variables and storing the original solution values
3150 */
3151 SCIP_CALL( SCIPrationalCreateBufferArray(set->buffer, &transsolvals, ntransvars + 1) );
3152 SCIP_CALL( SCIPsetAllocBufferArray(set, &activevars, ntransvars + 1) );
3153 SCIP_CALL( SCIPrationalCreateBufferArray(set->buffer, &activevals, ntransvars + 1) );
3154 SCIP_CALL( SCIPrationalCreateBufferArray(set->buffer, &solvals, nvars) );
3155 SCIP_CALL( SCIPrationalCreateBuffer(set->buffer, &constant) );
3156
3157 assert(transsolvals != NULL); /* for flexelint */
3158
3159 /* get the solution values of all active variables */
3160 for( v = 0; v < ntransvars; ++v )
3161 {
3162 SCIPsolGetValExact(transsolvals[v], sol, set, stat, transvars[v]);
3163 }
3164
3165 /* get the solution in original problem variables */
3166 for( v = 0; v < nvars; ++v )
3167 {
3168 activevars[0] = vars[v];
3169 SCIPrationalSetReal(activevals[0], 1.0);
3170 nactivevars = 1;
3171 SCIPrationalSetReal(constant, 0.0);
3172
3173 /* get active representation of the original variable */
3174 SCIP_CALL( SCIPvarGetActiveRepresentativesExact(set, activevars, activevals, &nactivevars, ntransvars + 1, constant,
3175 &requiredsize, TRUE) );
3176 assert(requiredsize <= ntransvars);
3177
3178 /* compute solution value of the original variable */
3179 SCIPrationalSetRational(solvals[v], constant);
3180 for( i = 0; i < nactivevars; ++i )
3181 {
3182 assert(0 <= SCIPvarGetProbindex(activevars[i]) && SCIPvarGetProbindex(activevars[i]) < ntransvars);
3183 SCIPrationalAddProd(solvals[v], activevals[i], transsolvals[SCIPvarGetProbindex(activevars[i])]);
3184 }
3185
3186 if( SCIPrationalIsAbsInfinity(solvals[v]) )
3187 *hasinfval = TRUE;
3188 }
3189
3190 /* clear the solution and convert it into original space */
3191 SCIP_CALL( solClearArrays(sol) );
3192 SCIPrationalSetReal(sol->valsexact->obj, origprob->objoffset);
3194
3195 /* reinsert the values of the original variables */
3196 for( v = 0; v < nvars; ++v )
3197 {
3198 /* we might require unchangedObjexact for this assert if exact probing mode is implemented */
3199 assert(SCIPvarGetUnchangedObj(vars[v]) == SCIPvarGetObj(vars[v])); /*lint !e777*/
3200
3201 if( !SCIPrationalIsZero(solvals[v]) )
3202 {
3203 SCIP_CALL( solSetArrayValExact(sol, set, vars[v], solvals[v]) );
3204 SCIPrationalAddProd(sol->valsexact->obj, SCIPvarGetObjExact(vars[v]), solvals[v]);
3205 }
3206 }
3207
3208 /* free temporary memory */
3209 SCIPrationalFreeBuffer(set->buffer, &constant);
3210 SCIPrationalFreeBufferArray(set->buffer, &solvals, nvars);
3211 SCIPrationalFreeBufferArray(set->buffer, &activevals, ntransvars + 1);
3212 SCIPsetFreeBufferArray(set, &activevars);
3213 SCIPrationalFreeBufferArray(set->buffer, &transsolvals, ntransvars + 1);
3214
3215 return SCIP_OKAY;
3216}
3217
3218/** recomputes the objective value of an original solution, e.g., when transferring solutions
3219 * from the solution pool (objective coefficients might have changed in the meantime)
3220 */
3222 SCIP_SOL* sol, /**< primal CIP solution */
3223 SCIP_SET* set, /**< global SCIP settings */
3224 SCIP_STAT* stat, /**< problem statistics data */
3225 SCIP_PROB* origprob /**< original problem */
3226 )
3227{
3228 SCIP_VAR** vars;
3229 SCIP_Real solval;
3230 int nvars;
3231 int v;
3232
3233 assert(sol != NULL);
3234 assert(SCIPsolIsOriginal(sol));
3235 assert(origprob != NULL);
3236
3237 vars = origprob->vars;
3238 nvars = origprob->nvars;
3239
3240 /* recompute the objective value */
3241 sol->obj = SCIPprobGetObjoffset(origprob);
3242 for( v = 0; v < nvars; ++v )
3243 {
3244 solval = SCIPsolGetVal(sol, set, stat, vars[v]);
3245 if( solval != 0.0 && solval != SCIP_UNKNOWN ) /*lint !e777*/
3246 {
3247 sol->obj += SCIPvarGetUnchangedObj(vars[v]) * solval;
3248 }
3249 }
3250
3251 if( SCIPsetIsInfinity(set, -sol->obj) )
3252 sol->obj = -SCIPsetInfinity(set);
3253}
3254
3255/** recomputes the objective value of an exact solution, e.g., when initialized from a real solution */
3257 SCIP_SOL* sol, /**< primal CIP solution */
3258 SCIP_SET* set, /**< global SCIP settings */
3259 SCIP_STAT* stat, /**< problem statistics data */
3260 SCIP_PROB* prob /**< scip problem */
3261 )
3262{
3263 SCIP_VAR** vars;
3264 SCIP_RATIONAL* solval;
3265 int nvars;
3266 int v;
3267
3268 assert(sol != NULL);
3269 assert(SCIPsolIsExact(sol));
3270 assert(prob != NULL);
3271
3272 vars = prob->vars;
3273 nvars = prob->nvars;
3274 (void) SCIPrationalCreateBuffer(set->buffer, &solval);
3275
3276 SCIPrationalSetFraction(sol->valsexact->obj, 0LL, 1LL);
3277
3278 /* recompute the objective value */
3279 for( v = 0; v < nvars; ++v )
3280 {
3281 SCIPsolGetValExact(solval, sol, set, stat, vars[v]);
3282 if( !SCIPrationalIsZero(solval) ) /*lint !e777*/
3283 {
3284 SCIPrationalAddProd(sol->valsexact->obj, SCIPvarGetObjExact(vars[v]), solval);
3285 }
3286 }
3287
3288 SCIPrationalFreeBuffer(set->buffer, &solval);
3289}
3290
3291/** returns whether the given solutions (exact or floating point) are exactly equal */
3292static
3294 SCIP_SOL* sol1, /**< first primal CIP solution */
3295 SCIP_SOL* sol2, /**< second primal CIP solution */
3296 SCIP_SET* set, /**< global SCIP settings */
3297 SCIP_STAT* stat, /**< problem statistics data */
3298 SCIP_PROB* origprob, /**< original problem */
3299 SCIP_PROB* transprob /**< transformed problem after presolve, or NULL if both solution are
3300 * defined in the original problem space */
3301 )
3302{
3303 SCIP_PROB* prob;
3304 SCIP_RATIONAL* tmp1;
3305 SCIP_RATIONAL* tmp2;
3306 int v;
3307 SCIP_Bool result = TRUE;
3308
3309 assert(sol1 != NULL);
3310 assert(sol2 != NULL);
3311 assert(((SCIPsolGetOrigin(sol1) == SCIP_SOLORIGIN_ORIGINAL) && (SCIPsolGetOrigin(sol2) == SCIP_SOLORIGIN_ORIGINAL)) || transprob != NULL);
3312
3313 (void) SCIPrationalCreateBuffer(set->buffer, &tmp1);
3314 (void) SCIPrationalCreateBuffer(set->buffer, &tmp2);
3315
3316 /* if both solutions are original or both are transformed, take the objective values stored in the solutions */
3318 {
3319 SCIPsolIsExact(sol1) ? SCIPrationalSetRational(tmp1, sol1->valsexact->obj) : SCIPrationalSetReal(tmp1, sol1->obj);
3320 SCIPsolIsExact(sol2) ? SCIPrationalSetRational(tmp2, sol2->valsexact->obj) : SCIPrationalSetReal(tmp2, sol2->obj);
3321 }
3322 /* one solution is original and the other not, so we have to get for both the objective in the transformed problem */
3323 else
3324 {
3325 if( SCIPsolIsExact(sol1) )
3326 SCIPsolGetObjExact(sol1, set, transprob, origprob, tmp1);
3327 else
3328 SCIPrationalSetReal(tmp1, SCIPsolGetObj(sol1, set, transprob, origprob));
3329 if( SCIPsolIsExact(sol2) )
3330 SCIPsolGetObjExact(sol2, set, transprob, origprob, tmp2);
3331 else
3332 SCIPrationalSetReal(tmp2, SCIPsolGetObj(sol2, set, transprob, origprob));
3333 }
3334
3335 /* solutions with different objective values cannot be the same */
3336 if( !SCIPrationalIsEQ(tmp1, tmp2) )
3337 result = FALSE;
3338
3339 /* if one of the solutions is defined in the original space, the comparison has to be performed in the original
3340 * space
3341 */
3342 prob = transprob;
3344 prob = origprob;
3345 assert(prob != NULL);
3346
3347 /* compare each variable value */
3348 for( v = 0; v < prob->nvars; ++v )
3349 {
3350 if( SCIPsolIsExact(sol1) )
3351 SCIPsolGetValExact(tmp1, sol1, set, stat, prob->vars[v]);
3352 else
3353 SCIPrationalSetReal(tmp1, SCIPsolGetVal(sol1, set, stat, prob->vars[v]));
3354 if( SCIPsolIsExact(sol2) )
3355 SCIPsolGetValExact(tmp2, sol2, set, stat, prob->vars[v]);
3356 else
3357 SCIPrationalSetReal(tmp2, SCIPsolGetVal(sol2, set, stat, prob->vars[v]));
3358
3359 if( !SCIPrationalIsEQ(tmp1, tmp2) )
3360 result = FALSE;
3361 }
3362
3363 SCIPrationalFreeBuffer(set->buffer, &tmp2);
3364 SCIPrationalFreeBuffer(set->buffer, &tmp1);
3365
3366 return result;
3367}
3368
3369/** returns whether the given solutions are equal */
3371 SCIP_SOL* sol1, /**< first primal CIP solution */
3372 SCIP_SOL* sol2, /**< second primal CIP solution */
3373 SCIP_SET* set, /**< global SCIP settings */
3374 SCIP_STAT* stat, /**< problem statistics data */
3375 SCIP_PROB* origprob, /**< original problem */
3376 SCIP_PROB* transprob /**< transformed problem after presolve, or NULL if both solution are
3377 * defined in the original problem space */
3378 )
3379{
3380 SCIP_PROB* prob;
3381 SCIP_Bool infobjs;
3382 SCIP_Real obj1;
3383 SCIP_Real obj2;
3384 int v;
3385
3386 assert(sol1 != NULL);
3387 assert(sol2 != NULL);
3388 assert((SCIPsolIsOriginal(sol1) && SCIPsolIsOriginal(sol2)) || transprob != NULL);
3389
3390 /* exact solutions should be checked exactly */
3391 if( set->exact_enable )
3392 {
3393 return solsAreEqualExact(sol1, sol2, set, stat, origprob, transprob);
3394 }
3395
3396 /* if both solutions are original or both are transformed, take the objective values stored in the solutions */
3397 if( SCIPsolIsOriginal(sol1) == SCIPsolIsOriginal(sol2) )
3398 {
3399 obj1 = sol1->obj;
3400 obj2 = sol2->obj;
3401 }
3402 /* one solution is original and the other not, so we have to get for both the objective in the transformed problem */
3403 else
3404 {
3405 obj1 = SCIPsolGetObj(sol1, set, transprob, origprob);
3406 obj2 = SCIPsolGetObj(sol2, set, transprob, origprob);
3407 }
3408
3409 /* solutions with different objective values cannot be the same; we consider two infinite objective values with the
3410 * same sign always to be different
3411 */
3412 infobjs = (SCIPsetIsInfinity(set, obj1) && SCIPsetIsInfinity(set, obj2))
3413 || (SCIPsetIsInfinity(set, -obj1) && SCIPsetIsInfinity(set, -obj2));
3414 if( !infobjs && !SCIPsetIsEQ(set, obj1, obj2) )
3415 return FALSE;
3416
3417 /* if one of the solutions is defined in the original space, the comparison has to be performed in the original
3418 * space
3419 */
3420 prob = transprob;
3421 if( SCIPsolIsOriginal(sol1) || SCIPsolIsOriginal(sol2) )
3422 prob = origprob;
3423 assert(prob != NULL);
3424
3425 /* compare each variable value */
3426 for( v = 0; v < prob->nvars; ++v )
3427 {
3428 SCIP_Real val1;
3429 SCIP_Real val2;
3430
3431 val1 = SCIPsolGetVal(sol1, set, stat, prob->vars[v]);
3432 val2 = SCIPsolGetVal(sol2, set, stat, prob->vars[v]);
3433 if( !SCIPsetIsEQ(set, val1, val2) )
3434 return FALSE;
3435 }
3436
3437 return TRUE;
3438}
3439
3440/** outputs non-zero elements of solution to file stream */
3442 SCIP_SOL* sol, /**< primal CIP solution */
3443 SCIP_SET* set, /**< global SCIP settings */
3444 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
3445 SCIP_STAT* stat, /**< problem statistics data */
3446 SCIP_PROB* prob, /**< problem data (original or transformed) */
3447 SCIP_PROB* transprob, /**< transformed problem data or NULL (to display priced variables) */
3448 FILE* file, /**< output file (or NULL for standard output) */
3449 SCIP_Bool mipstart, /**< should only discrete variables be printed? */
3450 SCIP_Bool printzeros /**< should variables set to zero be printed? */
3451 )
3452{
3453 SCIP_Real solval;
3454 int v;
3455
3456 assert(sol != NULL);
3457 assert(prob != NULL);
3458 assert(SCIPsolIsOriginal(sol) || prob->transformed || transprob != NULL);
3459 assert(!mipstart || !SCIPsolIsPartial(sol));
3460
3461 /* display variables of problem data */
3462 for( v = 0; v < prob->nfixedvars; ++v )
3463 {
3464 assert(prob->fixedvars[v] != NULL);
3465
3466 /* skip non-discrete variables in a mip start */
3467 if( mipstart && !SCIPvarIsIntegral(prob->fixedvars[v]) )
3468 continue;
3469
3470 solval = SCIPsolGetVal(sol, set, stat, prob->fixedvars[v]);
3471 if( printzeros || mipstart
3472 || (sol->solorigin != SCIP_SOLORIGIN_PARTIAL && !SCIPsetIsZero(set, solval))
3473 || (sol->solorigin == SCIP_SOLORIGIN_PARTIAL && solval != SCIP_UNKNOWN) ) /*lint !e777*/
3474 {
3475 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(prob->fixedvars[v]));
3476 if( solval == SCIP_UNKNOWN ) /*lint !e777*/
3477 SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
3478 else if( SCIPsetIsInfinity(set, solval) )
3479 SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
3480 else if( SCIPsetIsInfinity(set, -solval) )
3481 SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
3482 else
3483 SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g", solval);
3484 SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(prob->fixedvars[v]));
3485 }
3486 }
3487
3488 for( v = 0; v < prob->nvars; ++v )
3489 {
3490 assert(prob->vars[v] != NULL);
3491
3492 /* skip non-discrete variables in a mip start */
3493 if( mipstart && !SCIPvarIsIntegral(prob->vars[v]) )
3494 continue;
3495
3496 solval = SCIPsolGetVal(sol, set, stat, prob->vars[v]);
3497 if( printzeros || mipstart
3498 || (sol->solorigin != SCIP_SOLORIGIN_PARTIAL && !SCIPsetIsZero(set, solval))
3499 || (sol->solorigin == SCIP_SOLORIGIN_PARTIAL && solval != SCIP_UNKNOWN) ) /*lint !e777*/
3500 {
3501 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(prob->vars[v]));
3502 if( solval == SCIP_UNKNOWN ) /*lint !e777*/
3503 SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
3504 else if( SCIPsetIsInfinity(set, solval) )
3505 SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
3506 else if( SCIPsetIsInfinity(set, -solval) )
3507 SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
3508 else
3509 SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g", solval);
3510 SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(prob->vars[v]));
3511 }
3512 }
3513
3514 /* display additional priced variables (if given problem data is original problem); consider these variables only
3515 * if there is at least one active pricer, otherwise we might print variables that have been added by, e.g., the
3516 * dual sparsify presolver (see #2946)
3517 */
3518 if( !prob->transformed && !SCIPsolIsOriginal(sol) && set->nactivepricers > 0 )
3519 {
3520 assert(transprob != NULL);
3521 for( v = 0; v < transprob->nfixedvars; ++v )
3522 {
3523 assert(transprob->fixedvars[v] != NULL);
3524 if( SCIPvarIsTransformedOrigvar(transprob->fixedvars[v]) )
3525 continue;
3526
3527 /* skip non-discrete variables in a mip start */
3528 if( mipstart && !SCIPvarIsIntegral(transprob->fixedvars[v]) )
3529 continue;
3530
3531 solval = SCIPsolGetVal(sol, set, stat, transprob->fixedvars[v]);
3532 if( printzeros || mipstart || !SCIPsetIsZero(set, solval) )
3533 {
3534 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(transprob->fixedvars[v]));
3535 if( solval == SCIP_UNKNOWN ) /*lint !e777*/
3536 SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
3537 else if( SCIPsetIsInfinity(set, solval) )
3538 SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
3539 else if( SCIPsetIsInfinity(set, -solval) )
3540 SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
3541 else
3542 SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g", solval);
3543 SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(transprob->fixedvars[v]));
3544 }
3545 }
3546 for( v = 0; v < transprob->nvars; ++v )
3547 {
3548 assert(transprob->vars[v] != NULL);
3549 if( SCIPvarIsTransformedOrigvar(transprob->vars[v]) )
3550 continue;
3551
3552 /* skip non-discrete variables in a mip start */
3553 if( mipstart && !SCIPvarIsIntegral(transprob->vars[v]) )
3554 continue;
3555
3556 solval = SCIPsolGetVal(sol, set, stat, transprob->vars[v]);
3557 if( printzeros || !SCIPsetIsZero(set, solval) )
3558 {
3559 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(transprob->vars[v]));
3560 if( solval == SCIP_UNKNOWN ) /*lint !e777*/
3561 SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
3562 else if( SCIPsetIsInfinity(set, solval) )
3563 SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
3564 else if( SCIPsetIsInfinity(set, -solval) )
3565 SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
3566 else
3567 SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g", solval);
3568 SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(transprob->vars[v]));
3569 }
3570 }
3571 }
3572
3573 return SCIP_OKAY;
3574}
3575
3576/** outputs non-zero elements of exact solution to file stream */
3578 SCIP_SOL* sol, /**< primal CIP solution */
3579 SCIP_SET* set, /**< global SCIP settings */
3580 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
3581 SCIP_STAT* stat, /**< problem statistics data */
3582 SCIP_PROB* prob, /**< problem data (original or transformed) */
3583 SCIP_PROB* transprob, /**< transformed problem data or NULL (to display priced variables) */
3584 FILE* file, /**< output file (or NULL for standard output) */
3585 SCIP_Bool mipstart, /**< should only discrete variables be printed? */
3586 SCIP_Bool printzeros /**< should variables set to zero be printed? */
3587 )
3588{
3589 SCIP_RATIONAL* solval;
3590 char* solvalstr;
3591 int solvallen;
3592 int solvalsize = SCIP_MAXSTRLEN;
3593 int v;
3594
3595 assert(sol != NULL);
3596 assert(prob != NULL);
3597 assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL || prob->transformed || transprob != NULL);
3598 assert(SCIPsolIsExact(sol));
3599
3600 SCIP_CALL( SCIPrationalCreateBuffer(set->buffer, &solval) );
3601 SCIP_CALL( SCIPsetAllocBufferArray(set, &solvalstr, solvalsize) );
3602
3603 /* display variables of problem data */
3604 for( v = 0; v < prob->nfixedvars; ++v )
3605 {
3606 assert(prob->fixedvars[v] != NULL);
3607
3608 /* skip non-discrete variables in a mip start */
3609 if( mipstart && !SCIPvarIsIntegral(prob->fixedvars[v]) )
3610 continue;
3611
3612 SCIPsolGetValExact(solval, sol, set, stat, prob->fixedvars[v]);
3613 if( printzeros || mipstart
3614 || (sol->solorigin != SCIP_SOLORIGIN_PARTIAL && !SCIPrationalIsZero(solval))
3615 || (sol->solorigin == SCIP_SOLORIGIN_PARTIAL) ) /*lint !e777*/
3616 {
3617 solvallen = SCIPrationalToString(solval, solvalstr, solvalsize);
3618 if( solvallen >= solvalsize )
3619 {
3620 solvalsize = SCIPrationalStrLen(solval) + 1;
3621 SCIP_CALL( SCIPsetReallocBufferArray(set, &solvalstr, solvalsize) );
3622 solvallen = SCIPrationalToString(solval, solvalstr, solvalsize);
3623 assert(solvallen < solvalsize);
3624 }
3625
3626 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(prob->fixedvars[v]));
3627 SCIPmessageFPrintInfo(messagehdlr, file, " %20s", solvalstr);
3628
3629 solvallen = SCIPrationalToString(SCIPvarGetObjExact(prob->fixedvars[v]), solvalstr, solvalsize);
3630 if( solvallen >= solvalsize )
3631 {
3632 solvalsize = SCIPrationalStrLen(solval) + 1;
3633 SCIP_CALL( SCIPsetReallocBufferArray(set, &solvalstr, solvalsize) );
3634 solvallen = SCIPrationalToString(solval, solvalstr, solvalsize);
3635 assert(solvallen < solvalsize);
3636 }
3637
3638 SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%s)\n", solvalstr);
3639 }
3640 }
3641
3642 for( v = 0; v < prob->nvars; ++v )
3643 {
3644 assert(prob->vars[v] != NULL);
3645
3646 /* skip non-discrete variables in a mip start */
3647 if( mipstart && !SCIPvarIsIntegral(prob->vars[v]) )
3648 continue;
3649
3650 SCIPsolGetValExact(solval, sol, set, stat, prob->vars[v]);
3651 if( printzeros || mipstart
3652 || (sol->solorigin != SCIP_SOLORIGIN_PARTIAL && !SCIPrationalIsZero(solval)) ) /*lint !e777*/
3653 {
3654 solvallen = SCIPrationalToString(solval, solvalstr, solvalsize);
3655 if( solvallen >= solvalsize )
3656 {
3657 solvalsize = SCIPrationalStrLen(solval) + 1;
3658 SCIP_CALL( SCIPsetReallocBufferArray(set, &solvalstr, solvalsize) );
3659 solvallen = SCIPrationalToString(solval, solvalstr, solvalsize);
3660 assert(solvallen < solvalsize);
3661 }
3662
3663 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(prob->vars[v]));
3664 SCIPmessageFPrintInfo(messagehdlr, file, " %20s", solvalstr);
3665
3666 solvallen = SCIPrationalToString(SCIPvarGetObjExact(prob->vars[v]), solvalstr, solvalsize);
3667 if( solvallen >= solvalsize )
3668 {
3669 solvalsize = SCIPrationalStrLen(solval) + 1;
3670 SCIP_CALL( SCIPsetReallocBufferArray(set, &solvalstr, solvalsize) );
3671 solvallen = SCIPrationalToString(solval, solvalstr, solvalsize);
3672 assert(solvallen < solvalsize);
3673 }
3674
3675 SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%s)\n", solvalstr);
3676 }
3677 }
3678
3679 /* display additional priced variables (if given problem data is original problem) */
3680 if( !prob->transformed && sol->solorigin != SCIP_SOLORIGIN_ORIGINAL )
3681 {
3682 assert(transprob != NULL);
3683 for( v = 0; v < transprob->nfixedvars; ++v )
3684 {
3685 assert(transprob->fixedvars[v] != NULL);
3686 if( SCIPvarIsTransformedOrigvar(transprob->fixedvars[v]) )
3687 continue;
3688
3689 /* skip non-discrete variables in a mip start */
3690 if( mipstart && !SCIPvarIsIntegral(transprob->fixedvars[v]) )
3691 continue;
3692
3693 SCIPsolGetValExact(solval, sol, set, stat, transprob->fixedvars[v]);
3694 if( printzeros || mipstart || !SCIPrationalIsZero(solval) )
3695 {
3696 solvallen = SCIPrationalToString(solval, solvalstr, solvalsize);
3697 if( solvallen >= solvalsize )
3698 {
3699 solvalsize = SCIPrationalStrLen(solval) + 1;
3700 SCIP_CALL( SCIPsetReallocBufferArray(set, &solvalstr, solvalsize) );
3701 solvallen = SCIPrationalToString(solval, solvalstr, solvalsize);
3702 assert(solvallen < solvalsize);
3703 }
3704
3705 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(transprob->fixedvars[v]));
3706 SCIPmessageFPrintInfo(messagehdlr, file, " %20s", solvalstr);
3707
3708 solvallen = SCIPrationalToString(SCIPvarGetObjExact(transprob->fixedvars[v]), solvalstr, solvalsize);
3709 if( solvallen >= solvalsize )
3710 {
3711 solvalsize = SCIPrationalStrLen(solval) + 1;
3712 SCIP_CALL( SCIPsetReallocBufferArray(set, &solvalstr, solvalsize) );
3713 solvallen = SCIPrationalToString(solval, solvalstr, solvalsize);
3714 assert(solvallen < solvalsize);
3715 }
3716
3717 SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%s)\n", solvalstr);
3718 }
3719 }
3720 for( v = 0; v < transprob->nvars; ++v )
3721 {
3722 assert(transprob->vars[v] != NULL);
3723 if( SCIPvarIsTransformedOrigvar(transprob->vars[v]) )
3724 continue;
3725
3726 /* skip non-discrete variables in a mip start */
3727 if( mipstart && !SCIPvarIsIntegral(transprob->vars[v]) )
3728 continue;
3729
3730 SCIPsolGetValExact(solval, sol, set, stat, transprob->vars[v]);
3731 if( printzeros || !SCIPrationalIsZero(solval) )
3732 {
3733 solvallen = SCIPrationalToString(solval, solvalstr, solvalsize);
3734 if( solvallen >= solvalsize )
3735 {
3736 solvalsize = SCIPrationalStrLen(solval) + 1;
3737 SCIP_CALL( SCIPsetReallocBufferArray(set, &solvalstr, solvalsize) );
3738 solvallen = SCIPrationalToString(solval, solvalstr, solvalsize);
3739 assert(solvallen < solvalsize);
3740 }
3741
3742 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(transprob->vars[v]));
3743 SCIPmessageFPrintInfo(messagehdlr, file, " %20s", solvalstr);
3744
3745 solvallen = SCIPrationalToString(SCIPvarGetObjExact(transprob->vars[v]), solvalstr, solvalsize);
3746 if( solvallen >= solvalsize )
3747 {
3748 solvalsize = SCIPrationalStrLen(solval) + 1;
3749 SCIP_CALL( SCIPsetReallocBufferArray(set, &solvalstr, solvalsize) );
3750 solvallen = SCIPrationalToString(solval, solvalstr, solvalsize);
3751 assert(solvallen < solvalsize);
3752 }
3753
3754 SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%s)\n", solvalstr);
3755 }
3756 }
3757 }
3758
3759 SCIPsetFreeBufferArray(set, &solvalstr);
3760 SCIPrationalFreeBuffer(set->buffer, &solval);
3761
3762 return SCIP_OKAY;
3763}
3764
3765/** outputs non-zero elements of solution representing a ray to file stream */
3767 SCIP_SOL* sol, /**< primal CIP solution */
3768 SCIP_SET* set, /**< global SCIP settings */
3769 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
3770 SCIP_STAT* stat, /**< problem statistics data */
3771 SCIP_PROB* prob, /**< problem data (original or transformed) */
3772 SCIP_PROB* transprob, /**< transformed problem data or NULL (to display priced variables) */
3773 FILE* file, /**< output file (or NULL for standard output) */
3774 SCIP_Bool printzeros /**< should variables set to zero be printed? */
3775 )
3776{
3777 SCIP_Real solval;
3778 int v;
3779
3780 assert(sol != NULL);
3781 assert(prob != NULL);
3782 assert(SCIPsolIsOriginal(sol) || prob->transformed || transprob != NULL);
3783
3784 /* display variables of problem data */
3785 for( v = 0; v < prob->nfixedvars; ++v )
3786 {
3787 assert(prob->fixedvars[v] != NULL);
3788 solval = SCIPsolGetRayVal(sol, set, stat, prob->fixedvars[v]);
3789 if( printzeros || !SCIPsetIsZero(set, solval) )
3790 {
3791 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(prob->fixedvars[v]));
3792 if( solval == SCIP_UNKNOWN ) /*lint !e777*/
3793 SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
3794 else if( SCIPsetIsInfinity(set, solval) )
3795 SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
3796 else if( SCIPsetIsInfinity(set, -solval) )
3797 SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
3798 else
3799 SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g", solval);
3800 SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(prob->fixedvars[v]));
3801 }
3802 }
3803 for( v = 0; v < prob->nvars; ++v )
3804 {
3805 assert(prob->vars[v] != NULL);
3806 solval = SCIPsolGetRayVal(sol, set, stat, prob->vars[v]);
3807 if( printzeros || !SCIPsetIsZero(set, solval) )
3808 {
3809 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(prob->vars[v]));
3810 if( solval == SCIP_UNKNOWN ) /*lint !e777*/
3811 SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
3812 else if( SCIPsetIsInfinity(set, solval) )
3813 SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
3814 else if( SCIPsetIsInfinity(set, -solval) )
3815 SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
3816 else
3817 SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g", solval);
3818 SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(prob->vars[v]));
3819 }
3820 }
3821
3822 /* display additional priced variables (if given problem data is original problem) */
3823 if( !prob->transformed && !SCIPsolIsOriginal(sol) )
3824 {
3825 assert(transprob != NULL);
3826 for( v = 0; v < transprob->nfixedvars; ++v )
3827 {
3828 assert(transprob->fixedvars[v] != NULL);
3829 if( SCIPvarIsTransformedOrigvar(transprob->fixedvars[v]) )
3830 continue;
3831
3832 solval = SCIPsolGetRayVal(sol, set, stat, transprob->fixedvars[v]);
3833 if( printzeros || !SCIPsetIsZero(set, solval) )
3834 {
3835 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(transprob->fixedvars[v]));
3836 if( solval == SCIP_UNKNOWN ) /*lint !e777*/
3837 SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
3838 else if( SCIPsetIsInfinity(set, solval) )
3839 SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
3840 else if( SCIPsetIsInfinity(set, -solval) )
3841 SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
3842 else
3843 SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g", solval);
3844 SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(transprob->fixedvars[v]));
3845 }
3846 }
3847 for( v = 0; v < transprob->nvars; ++v )
3848 {
3849 assert(transprob->vars[v] != NULL);
3850 if( SCIPvarIsTransformedOrigvar(transprob->vars[v]) )
3851 continue;
3852
3853 solval = SCIPsolGetRayVal(sol, set, stat, transprob->vars[v]);
3854 if( printzeros || !SCIPsetIsZero(set, solval) )
3855 {
3856 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPvarGetName(transprob->vars[v]));
3857 if( solval == SCIP_UNKNOWN ) /*lint !e777*/
3858 SCIPmessageFPrintInfo(messagehdlr, file, " unknown");
3859 else if( SCIPsetIsInfinity(set, solval) )
3860 SCIPmessageFPrintInfo(messagehdlr, file, " +infinity");
3861 else if( SCIPsetIsInfinity(set, -solval) )
3862 SCIPmessageFPrintInfo(messagehdlr, file, " -infinity");
3863 else
3864 SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g", solval);
3865 SCIPmessageFPrintInfo(messagehdlr, file, " \t(obj:%.15g)\n", SCIPvarGetUnchangedObj(transprob->vars[v]));
3866 }
3867 }
3868 }
3869
3870 return SCIP_OKAY;
3871}
3872
3873/** set new origin type for a solution */
3875 SCIP_SOL* sol, /**< primal CIP solution */
3876 SCIP_SOLORIGIN origin /**< new origin type of the solution */
3877 )
3878{
3879 assert( sol != NULL );
3880 sol->solorigin = origin;
3881}
3882
3883/*
3884 * methods for accumulated numerical violations of a solution
3885 */
3886
3887/** reset violations of a solution */
3889 SCIP_SOL* sol /**< primal CIP solution */
3890 )
3891{
3892 assert(sol != NULL);
3893
3894 sol->viol.absviolbounds = 0.0;
3895 sol->viol.relviolbounds = 0.0;
3896 sol->viol.absviolintegrality = 0.0;
3897 sol->viol.absviollprows = 0.0;
3898 sol->viol.relviollprows = 0.0;
3899 sol->viol.absviolcons = 0.0;
3900 sol->viol.relviolcons = 0.0;
3901}
3902
3903/** update integrality violation of a solution */
3905 SCIP_SOL* sol, /**< primal CIP solution */
3906 SCIP_Real absviolintegrality /**< absolute violation of integrality */
3907 )
3908{
3909 assert(sol != NULL);
3910
3911 sol->viol.absviolintegrality = MAX(sol->viol.absviolintegrality, absviolintegrality);
3912}
3913
3914/** update bound violation of a solution */
3916 SCIP_SOL* sol, /**< primal CIP solution */
3917 SCIP_Real absviolbounds, /**< absolute violation of bounds */
3918 SCIP_Real relviolbounds /**< relative violation of bounds */
3919 )
3920{
3921 assert(sol != NULL);
3922
3923 sol->viol.absviolbounds = MAX(sol->viol.absviolbounds, absviolbounds);
3924 sol->viol.relviolbounds = MAX(sol->viol.relviolbounds, relviolbounds);
3925}
3926
3927/** update LP row violation of a solution */
3929 SCIP_SOL* sol, /**< primal CIP solution */
3930 SCIP_Real absviollprows, /**< absolute violation of LP rows */
3931 SCIP_Real relviollprows /**< relative violation of LP rows */
3932 )
3933{
3934 assert(sol != NULL);
3935
3936 sol->viol.absviollprows = MAX(sol->viol.absviollprows, absviollprows);
3937 sol->viol.relviollprows = MAX(sol->viol.relviollprows, relviollprows);
3938}
3939
3940/** update constraint violation of a solution */
3942 SCIP_SOL* sol, /**< primal CIP solution */
3943 SCIP_Real absviolcons, /**< absolute violation of constraint */
3944 SCIP_Real relviolcons /**< relative violation of constraint */
3945 )
3946{
3947 assert(sol != NULL);
3948
3949 sol->viol.absviolcons = MAX(sol->viol.absviolcons, absviolcons);
3950 sol->viol.relviolcons = MAX(sol->viol.relviolcons, relviolcons);
3951}
3952
3953/** update violation of a constraint that is represented in the LP */
3955 SCIP_SOL* sol, /**< primal CIP solution */
3956 SCIP_Real absviol, /**< absolute violation of constraint */
3957 SCIP_Real relviol /**< relative violation of constraint */
3958 )
3959{
3960 assert(sol != NULL);
3961
3962 SCIPsolUpdateConsViolation(sol, absviol, relviol);
3963 SCIPsolUpdateLPRowViolation(sol, absviol, relviol);
3964}
3965
3966/** get maximum absolute bound violation of solution */
3968 SCIP_SOL* sol /**< primal CIP solution */
3969 )
3970{
3971 assert(sol != NULL);
3972
3973 return sol->viol.absviolbounds;
3974}
3975
3976/** get maximum relative bound violation of solution */
3978 SCIP_SOL* sol /**< primal CIP solution */
3979 )
3980{
3981 assert(sol != NULL);
3982
3983 return sol->viol.relviolbounds;
3984}
3985
3986/** get maximum absolute integrality violation of solution */
3988 SCIP_SOL* sol /**< primal CIP solution */
3989 )
3990{
3991 assert(sol != NULL);
3992
3993 return sol->viol.absviolintegrality;
3994}
3995
3996/** get maximum absolute LP row violation of solution */
3998 SCIP_SOL* sol /**< primal CIP solution */
3999 )
4000{
4001 assert(sol != NULL);
4002
4003 return sol->viol.absviollprows;
4004}
4005
4006/** get maximum relative LP row violation of solution */
4008 SCIP_SOL* sol /**< primal CIP solution */
4009 )
4010{
4011 assert(sol != NULL);
4012
4013 return sol->viol.relviollprows;
4014}
4015
4016/** get maximum absolute constraint violation of solution */
4018 SCIP_SOL* sol /**< primal CIP solution */
4019 )
4020{
4021 assert(sol != NULL);
4022
4023 return sol->viol.absviolcons;
4024}
4025
4026/** get maximum relative constraint violation of solution */
4028 SCIP_SOL* sol /**< primal CIP solution */
4029 )
4030{
4031 assert(sol != NULL);
4032
4033 return sol->viol.relviolcons;
4034}
4035
4036/** overwrite FP solution with exact values */
4038 SCIP_SOL* sol, /**< exact primal CIP solution */
4039 SCIP_SET* set, /**< global SCIP settings */
4040 SCIP_STAT* stat, /**< problem statistics data */
4041 SCIP_PROB* origprob, /**< problem data */
4042 SCIP_PROB* transprob, /**< problem data */
4043 SCIP_TREE* tree /**< branch and bound tree, or NULL */
4044 )
4045{
4046 SCIP_VAR** vars;
4047 SCIP_RATIONAL* solval;
4048 int nvars;
4049 int i;
4050
4051 assert(sol != NULL);
4052 assert(SCIPsolIsExact(sol));
4053
4054 vars = SCIPsolIsOriginal(sol) ? SCIPprobGetVars(origprob) : SCIPprobGetVars(transprob);
4055 nvars = SCIPsolIsOriginal(sol) ? SCIPprobGetNVars(origprob) : SCIPprobGetNVars(transprob);
4056
4057 SCIP_CALL( SCIPrationalCreateBuffer(set->buffer, &solval) );
4058
4059 /* overwrite all the variables */
4060 for( i = 0; i < nvars; i++ )
4061 {
4062 SCIP_ROUNDMODE_RAT roundmode;
4063 SCIPsolGetValExact(solval, sol, set, stat, vars[i]);
4064 roundmode = vars[i]->obj > 0 ? SCIP_R_ROUND_UPWARDS : SCIP_R_ROUND_DOWNWARDS;
4065
4066 SCIPrationalDebugMessage("overwriting value %g of var %s with value %g (%q) \n", SCIPsolGetVal(sol, set, stat, vars[i]),
4067 vars[i]->name, SCIPrationalRoundReal(solval, roundmode), solval);
4068
4069 SCIP_CALL( SCIPsolSetVal(sol, set, stat, tree, vars[i],
4070 SCIPrationalRoundReal(solval, roundmode)) );
4071 }
4072
4073 if( SCIPsolIsOriginal(sol) )
4074 {
4076 }
4077 else
4078 {
4079 SCIPsolGetObjExact(sol, set, transprob, origprob, solval);
4080 }
4081
4082 /* hard-set the obj value of the solution */
4084
4085 SCIPrationalFreeBuffer(set->buffer, &solval);
4086
4087 return SCIP_OKAY;
4088}
4089
4090/** comparison method for sorting solution by decreasing objective value (best solution will be sorted to the end) */
4092{
4093 if( ((SCIP_SOL*)elem1)->obj - ((SCIP_SOL*)elem2)->obj < 0 )
4094 return 1;
4095 else if( ((SCIP_SOL*)elem1)->obj - ((SCIP_SOL*)elem2)->obj > 0 )
4096 return -1;
4097 else
4098 return 0;
4099}
4100
4101/*
4102 * simple functions implemented as defines
4103 */
4104
4105/* In debug mode, the following methods are implemented as function calls to ensure
4106 * type validity.
4107 * In optimized mode, the methods are implemented as defines to improve performance.
4108 * However, we want to have them in the library anyways, so we have to undef the defines.
4109 */
4110
4111#undef SCIPsolGetOrigin
4112#undef SCIPsolIsOriginal
4113#undef SCIPsolGetOrigObj
4114#undef SCIPsolGetTime
4115#undef SCIPsolGetNodenum
4116#undef SCIPsolGetRunnum
4117#undef SCIPsolGetDepth
4118#undef SCIPsolGetHeur
4119#undef SCIPsolGetRelax
4120#undef SCIPsolOrigAddObjval
4121#undef SCIPsolGetPrimalIndex
4122#undef SCIPsolSetPrimalIndex
4123#undef SCIPsolGetIndex
4124#undef SCIPsolGetType
4125#undef SCIPsolSetLPRelaxation
4126#undef SCIPsolSetStrongbranching
4127#undef SCIPsolSetPseudo
4128
4129/** gets origin of solution */
4131 SCIP_SOL* sol /**< primal CIP solution */
4132 )
4133{
4134 assert(sol != NULL);
4135
4136 return sol->solorigin;
4137}
4138
4139/** returns whether the given solution is defined on original variables */
4141 SCIP_SOL* sol /**< primal CIP solution */
4142 )
4143{
4144 assert(sol != NULL);
4145
4147}
4148
4149/** returns whether a solution is an exact rational solution */
4151 SCIP_SOL* sol /**< primal CIP solution */
4152 )
4153{
4154 assert(sol != NULL);
4155
4156 return sol->valsexact != NULL;
4157}
4158
4159/** returns whether the given solution is defined on original variables and containes unknown solution values */
4161 SCIP_SOL* sol /**< primal CIP solution */
4162 )
4163{
4164 assert(sol != NULL);
4165
4166 return (sol->solorigin == SCIP_SOLORIGIN_PARTIAL);
4167}
4168
4169/** gets objective value of primal CIP solution which lives in the original problem space */
4171 SCIP_SOL* sol /**< primal CIP solution */
4172 )
4173{
4174 assert(sol != NULL);
4175 assert(SCIPsolIsOriginal(sol));
4176
4177 return sol->obj;
4178}
4179
4180/** gets objective value of primal CIP solution which lives in the original problem space */
4182 SCIP_SOL* sol /**< primal CIP solution */
4183 )
4184{
4185 assert(sol != NULL);
4186 assert(SCIPsolIsOriginal(sol));
4187 assert(SCIPsolIsExact(sol));
4188
4189 return sol->valsexact->obj;
4190}
4191
4192/** adds value to the objective value of a given original primal CIP solution */
4194 SCIP_SOL* sol, /**< primal CIP solution */
4195 SCIP_Real addval /**< offset value to add */
4196 )
4197{
4198 assert(sol != NULL);
4199 assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL);
4200
4201 sol->obj += addval;
4202}
4203
4204/** adds value to the objective value of a given original primal CIP solution */
4206 SCIP_SOL* sol, /**< primal CIP solution */
4207 SCIP_RATIONAL* addval /**< offset value to add */
4208 )
4209{
4210 assert(sol != NULL);
4211 assert(sol->solorigin == SCIP_SOLORIGIN_ORIGINAL);
4212 assert(SCIPsolIsExact(sol));
4213
4214 SCIPrationalAdd(sol->valsexact->obj, sol->valsexact->obj, addval);
4215 sol->obj = SCIPrationalGetReal(sol->valsexact->obj);
4216}
4217
4218/** gets clock time, when this solution was found */
4220 SCIP_SOL* sol /**< primal CIP solution */
4221 )
4222{
4223 assert(sol != NULL);
4224
4225 return sol->time;
4226}
4227
4228/** gets branch and bound run number, where this solution was found */
4230 SCIP_SOL* sol /**< primal CIP solution */
4231 )
4232{
4233 assert(sol != NULL);
4234
4235 return sol->runnum;
4236}
4237
4238/** gets node number, where this solution was found */
4240 SCIP_SOL* sol /**< primal CIP solution */
4241 )
4242{
4243 assert(sol != NULL);
4244
4245 return sol->nodenum;
4246}
4247
4248/** gets node's depth, where this solution was found */
4250 SCIP_SOL* sol /**< primal CIP solution */
4251 )
4252{
4253 assert(sol != NULL);
4254
4255 return sol->depth;
4256}
4257
4258/** gets heuristic, that found this solution or NULL if solution has type different than SCIP_SOLTYPE_HEUR */
4260 SCIP_SOL* sol /**< primal CIP solution */
4261 )
4262{
4263 assert(sol != NULL);
4264
4265 return sol->type == SCIP_SOLTYPE_HEUR ? sol->creator.heur : NULL;
4266}
4267
4268/** gets current position of solution in array of existing solutions of primal data */
4270 SCIP_SOL* sol /**< primal CIP solution */
4271 )
4272{
4273 assert(sol != NULL);
4274
4275 return sol->primalindex;
4276}
4277
4278/** sets current position of solution in array of existing solutions of primal data */
4280 SCIP_SOL* sol, /**< primal CIP solution */
4281 int primalindex /**< new primal index of solution */
4282 )
4283{
4284 assert(sol != NULL);
4285
4286 sol->primalindex = primalindex;
4287}
4288
4289/** returns unique index of given solution */
4291 SCIP_SOL* sol /**< primal CIP solution */
4292 )
4293{
4294 assert(sol != NULL);
4295
4296 return sol->index;
4297}
4298
4299/** informs the solution that it now belongs to the given primal heuristic. For convenience and backwards compatibility,
4300 * the method accepts NULL as input for \p heur, in which case the solution type is set to SCIP_SOLTYPE_LPRELAX.
4301 *
4302 * @note Relaxation handlers should use SCIPsolSetRelax() instead.
4303 */
4305 SCIP_SOL* sol, /**< primal CIP solution */
4306 SCIP_HEUR* heur /**< primal heuristic that found the solution, or NULL for LP solutions */
4307 )
4308{
4309 assert(sol != NULL);
4310
4311 if( heur == NULL )
4313 else
4314 {
4315 sol->type = SCIP_SOLTYPE_HEUR;
4316 sol->creator.heur = heur;
4317 }
4318}
4319
4320/** gets information if solution was found by the LP, a primal heuristic, or a custom relaxator */
4322 SCIP_SOL* sol /**< primal CIP solution */
4323 )
4324{
4325 assert(sol != NULL);
4326
4327 return sol->type;
4328}
4329
4330/** gets relaxation handler that found this solution, or NULL if solution has different type than SCIP_SOLTYPE_RELAX */
4332 SCIP_SOL* sol /**< primal CIP solution */
4333 )
4334{
4335 assert(sol != NULL);
4336
4337 return sol->type == SCIP_SOLTYPE_RELAX ? sol->creator.relax : NULL;
4338}
4339
4340/** informs the solution that it now belongs to the given relaxation handler */
4342 SCIP_SOL* sol, /**< primal CIP solution */
4343 SCIP_RELAX* relax /**< relaxator that found the solution */
4344 )
4345{
4346 assert(sol != NULL);
4347 assert(relax != NULL);
4348
4349 sol->type = SCIP_SOLTYPE_RELAX;
4350 sol->creator.relax = relax;
4351}
4352
4353/** informs the solution that it is an LP relaxation solution */
4355 SCIP_SOL* sol /**< primal CIP solution */
4356 )
4357{
4358 assert(sol != NULL);
4359
4361}
4362
4363/** informs the solution that it is a solution found during strong branching */
4365 SCIP_SOL* sol /**< primal CIP solution */
4366 )
4367{
4368 assert(sol != NULL);
4369
4371}
4372
4373/** informs the solution that it originates from a pseudo solution */
4375 SCIP_SOL* sol /**< primal CIP solution */
4376 )
4377{
4378 assert(sol != NULL);
4379
4381}
4382
SCIP_VAR * h
Definition: circlepacking.c:68
SCIP_Real * r
Definition: circlepacking.c:59
SCIP_Real SCIPclockGetLastTime(SCIP_CLOCK *clck)
Definition: clock.c:529
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
Definition: clock.c:438
internal methods for clocks and timing issues
SCIP_RETCODE SCIPconsCheck(SCIP_CONS *cons, SCIP_SET *set, SCIP_SOL *sol, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_RESULT *result)
Definition: cons.c:7599
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:3838
internal methods for constraints and constraint handlers
#define NULL
Definition: def.h:248
#define SCIP_MAXSTRLEN
Definition: def.h:269
#define SCIP_Longint
Definition: def.h:141
#define SCIP_INVALID
Definition: def.h:178
#define SCIP_Bool
Definition: def.h:91
#define SCIP_ALLOC(x)
Definition: def.h:366
#define SCIP_Real
Definition: def.h:156
#define SCIP_UNKNOWN
Definition: def.h:179
#define ABS(x)
Definition: def.h:216
#define TRUE
Definition: def.h:93
#define FALSE
Definition: def.h:94
#define MAX(x, y)
Definition: def.h:220
#define SCIP_LONGINT_FORMAT
Definition: def.h:148
#define SCIPABORT()
Definition: def.h:327
#define REALABS(x)
Definition: def.h:182
#define SCIP_CALL(x)
Definition: def.h:355
SCIP_Real SCIPrelDiff(SCIP_Real val1, SCIP_Real val2)
Definition: misc.c:11162
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
Definition: lp.c:17425
int SCIPcolGetNNonz(SCIP_COL *col)
Definition: lp.c:17520
SCIP_Real * SCIPcolGetVals(SCIP_COL *col)
Definition: lp.c:17555
SCIP_ROW ** SCIPcolGetRows(SCIP_COL *col)
Definition: lp.c:17545
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4316
SCIP_Bool SCIPconshdlrNeedsCons(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:5302
int SCIPconshdlrGetCheckPriority(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:5262
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:8409
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:8588
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
Definition: cons.c:8638
SCIP_RETCODE SCIPrationalCreateBlock(BMS_BLKMEM *blkmem, SCIP_RATIONAL **rational)
Definition: rational.cpp:108
void SCIPrationalMult(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:1066
void SCIPrationalSetInfinity(SCIP_RATIONAL *res)
Definition: rational.cpp:618
void SCIPrationalAdd(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:935
SCIP_Real SCIPrationalGetReal(SCIP_RATIONAL *rational)
Definition: rational.cpp:2085
void SCIPrationalFreeBlock(BMS_BLKMEM *mem, SCIP_RATIONAL **rational)
Definition: rational.cpp:461
int SCIPrationalToString(SCIP_RATIONAL *rational, char *str, int strlen)
Definition: rational.cpp:1743
void SCIPrationalarrayGetVal(SCIP_RATIONALARRAY *rationalarray, int idx, SCIP_RATIONAL *result)
Definition: rational.cpp:2729
#define SCIPrationalDebugMessage
Definition: rational.h:641
void SCIPrationalDiv(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:1132
SCIP_Bool SCIPrationalIsAbsInfinity(SCIP_RATIONAL *rational)
Definition: rational.cpp:1680
SCIP_Bool SCIPrationalIsLT(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
Definition: rational.cpp:1503
void SCIPrationalSetReal(SCIP_RATIONAL *res, SCIP_Real real)
Definition: rational.cpp:603
SCIP_Bool SCIPrationalIsGT(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
Definition: rational.cpp:1474
SCIP_RETCODE SCIPrationalCopyBlock(BMS_BLKMEM *mem, SCIP_RATIONAL **result, SCIP_RATIONAL *src)
Definition: rational.cpp:151
void SCIPrationalFreeBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
Definition: rational.cpp:473
void SCIPrationalDiff(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:983
SCIP_Bool SCIPrationalIsPositive(SCIP_RATIONAL *rational)
Definition: rational.cpp:1640
int SCIPrationalGetSign(const SCIP_RATIONAL *rational)
Definition: rational.cpp:2048
SCIP_RETCODE SCIPrationalCreateBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
Definition: rational.cpp:123
void SCIPrationalAddProd(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:1173
SCIP_Bool SCIPrationalIsZero(SCIP_RATIONAL *rational)
Definition: rational.cpp:1624
void SCIPrationalSetRational(SCIP_RATIONAL *res, SCIP_RATIONAL *src)
Definition: rational.cpp:569
SCIP_RETCODE SCIPrationalarraySetVal(SCIP_RATIONALARRAY *rationalarray, int idx, SCIP_RATIONAL *val)
Definition: rational.cpp:2746
void SCIPrationalSetNegInfinity(SCIP_RATIONAL *res)
Definition: rational.cpp:630
void SCIPrationalSetFraction(SCIP_RATIONAL *res, SCIP_Longint nom, SCIP_Longint denom)
Definition: rational.cpp:582
void SCIPrationalNegate(SCIP_RATIONAL *res, SCIP_RATIONAL *op)
Definition: rational.cpp:1297
SCIP_RETCODE SCIPrationalarrayCreate(SCIP_RATIONALARRAY **rationalarray, BMS_BLKMEM *blkmem)
Definition: rational.cpp:2668
SCIP_Bool SCIPrationalIsNegative(SCIP_RATIONAL *rational)
Definition: rational.cpp:1650
void SCIPrationalDiffReal(SCIP_RATIONAL *res, SCIP_RATIONAL *rat, SCIP_Real real)
Definition: rational.cpp:1009
SCIP_Bool SCIPrationalIsInfinity(SCIP_RATIONAL *rational)
Definition: rational.cpp:1660
SCIP_Real SCIPrationalRoundReal(SCIP_RATIONAL *rational, SCIP_ROUNDMODE_RAT roundmode)
Definition: rational.cpp:2110
SCIP_RETCODE SCIPrationalCreateBufferArray(BMS_BUFMEM *mem, SCIP_RATIONAL ***rational, int size)
Definition: rational.cpp:214
SCIP_RETCODE SCIPrationalarrayCopy(SCIP_RATIONALARRAY **rationalarray, BMS_BLKMEM *blkmem, SCIP_RATIONALARRAY *sourcerationalarray)
Definition: rational.cpp:2697
SCIP_Bool SCIPrationalIsNegInfinity(SCIP_RATIONAL *rational)
Definition: rational.cpp:1670
SCIP_RETCODE SCIPrationalarrayFree(SCIP_RATIONALARRAY **rationalarray, BMS_BLKMEM *blkmem)
Definition: rational.cpp:2714
SCIP_Bool SCIPrationalIsEQ(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
Definition: rational.cpp:1404
void SCIPrationalDiffProd(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:1239
void SCIPrationalFreeBufferArray(BMS_BUFMEM *mem, SCIP_RATIONAL ***ratbufarray, int size)
Definition: rational.cpp:518
int SCIPrationalStrLen(SCIP_RATIONAL *rational)
Definition: rational.cpp:1774
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:17686
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:17696
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
Definition: lp.c:17795
SCIP_Bool SCIProwIsInLP(SCIP_ROW *row)
Definition: lp.c:17917
SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
Definition: sol.c:4130
SCIP_Real SCIPsolGetOrigObj(SCIP_SOL *sol)
Definition: sol.c:4170
void SCIPsolSetLPRelaxation(SCIP_SOL *sol)
Definition: sol.c:4354
void SCIPsolOrigAddObjvalExact(SCIP_SOL *sol, SCIP_RATIONAL *addval)
Definition: sol.c:4205
void SCIPsolSetStrongbranching(SCIP_SOL *sol)
Definition: sol.c:4364
SCIP_Real SCIPsolGetRelBoundViolation(SCIP_SOL *sol)
Definition: sol.c:3977
SCIP_Real SCIPsolGetAbsConsViolation(SCIP_SOL *sol)
Definition: sol.c:4017
SCIP_Real SCIPsolGetTime(SCIP_SOL *sol)
Definition: sol.c:4219
SCIP_RELAX * SCIPsolGetRelax(SCIP_SOL *sol)
Definition: sol.c:4331
SCIP_Real SCIPsolGetAbsBoundViolation(SCIP_SOL *sol)
Definition: sol.c:3967
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:4239
SCIP_Real SCIPsolGetAbsIntegralityViolation(SCIP_SOL *sol)
Definition: sol.c:3987
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
Definition: sol.c:4259
SCIP_Real SCIPsolGetAbsLPRowViolation(SCIP_SOL *sol)
Definition: sol.c:3997
void SCIPsolSetRelax(SCIP_SOL *sol, SCIP_RELAX *relax)
Definition: sol.c:4341
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:4140
int SCIPsolGetIndex(SCIP_SOL *sol)
Definition: sol.c:4290
int SCIPsolGetDepth(SCIP_SOL *sol)
Definition: sol.c:4249
SCIP_Real SCIPsolGetRelLPRowViolation(SCIP_SOL *sol)
Definition: sol.c:4007
SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
Definition: sol.c:4160
int SCIPsolGetRunnum(SCIP_SOL *sol)
Definition: sol.c:4229
SCIP_SOLTYPE SCIPsolGetType(SCIP_SOL *sol)
Definition: sol.c:4321
SCIP_Real SCIPsolGetRelConsViolation(SCIP_SOL *sol)
Definition: sol.c:4027
void SCIPsolSetPseudo(SCIP_SOL *sol)
Definition: sol.c:4374
void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
Definition: sol.c:4304
SCIP_DECL_SORTPTRCOMP(SCIPsolComp)
Definition: sol.c:4091
SCIP_Bool SCIPsolIsExact(SCIP_SOL *sol)
Definition: sol.c:4150
SCIP_RETCODE SCIPvarGetOrigvarSum(SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:18320
SCIP_Real SCIPvarGetNegationConstant(SCIP_VAR *var)
Definition: var.c:23889
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:23683
SCIP_Bool SCIPvarMayRoundUp(SCIP_VAR *var)
Definition: var.c:4484
SCIP_Real SCIPvarGetMultaggrConstant(SCIP_VAR *var)
Definition: var.c:23843
SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)
Definition: var.c:23642
SCIP_RATIONAL * SCIPvarGetAggrScalarExact(SCIP_VAR *var)
Definition: var.c:23760
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:23386
int SCIPvarGetNLocksUpType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
Definition: var.c:4386
SCIP_Real SCIPvarGetAggrConstant(SCIP_VAR *var)
Definition: var.c:23771
SCIP_Bool SCIPvarIsImpliedIntegral(SCIP_VAR *var)
Definition: var.c:23498
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:24268
SCIP_Real SCIPvarGetLbOriginal(SCIP_VAR *var)
Definition: var.c:24020
SCIP_RATIONAL * SCIPvarGetAggrConstantExact(SCIP_VAR *var)
Definition: var.c:23783
SCIP_RATIONAL * SCIPvarGetPseudoSolExact(SCIP_VAR *var)
Definition: var.c:24769
SCIP_Bool SCIPvarIsTransformed(SCIP_VAR *var)
Definition: var.c:23430
SCIP_Bool SCIPvarMayRoundDown(SCIP_VAR *var)
Definition: var.c:4473
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:23900
SCIP_Real SCIPvarGetAggrScalar(SCIP_VAR *var)
Definition: var.c:23748
SCIP_RETCODE SCIPvarGetOrigvarSumExact(SCIP_VAR **var, SCIP_RATIONAL *scalar, SCIP_RATIONAL *constant)
Definition: var.c:18409
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:24142
SCIP_VARSTATUS SCIPvarGetStatusExact(SCIP_VAR *var)
Definition: var.c:23396
int SCIPvarGetIndex(SCIP_VAR *var)
Definition: var.c:23652
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:23662
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:23267
SCIP_Real SCIPvarGetUbOriginal(SCIP_VAR *var)
Definition: var.c:24063
SCIP_RATIONAL * SCIPvarGetMultaggrConstantExact(SCIP_VAR *var)
Definition: var.c:23855
SCIP_RATIONAL * SCIPvarGetUbLocalExact(SCIP_VAR *var)
Definition: var.c:24278
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:23490
SCIP_Bool SCIPvarIsTransformedOrigvar(SCIP_VAR *var)
Definition: var.c:18497
SCIP_Real SCIPvarGetPseudoSol(SCIP_VAR *var)
Definition: var.c:24756
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition: var.c:24664
SCIP_VAR ** SCIPvarGetMultaggrVars(SCIP_VAR *var)
Definition: var.c:23806
int SCIPvarGetMultaggrNVars(SCIP_VAR *var)
Definition: var.c:23794
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:24234
SCIP_RATIONAL * SCIPvarGetLbGlobalExact(SCIP_VAR *var)
Definition: var.c:24130
SCIP_VAR * SCIPvarGetNegationVar(SCIP_VAR *var)
Definition: var.c:23878
SCIP_RATIONAL ** SCIPvarGetMultaggrScalarsExact(SCIP_VAR *var)
Definition: var.c:23830
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:24120
void SCIPvarMarkNotDeletable(SCIP_VAR *var)
Definition: var.c:23557
SCIP_RATIONAL * SCIPvarGetLbLocalExact(SCIP_VAR *var)
Definition: var.c:24244
SCIP_VAR * SCIPvarGetTransVar(SCIP_VAR *var)
Definition: var.c:23672
SCIP_Real SCIPvarGetNLPSol(SCIP_VAR *var)
Definition: var.c:24691
void SCIPvarGetLPSolExact(SCIP_VAR *var, SCIP_RATIONAL *res)
Definition: var.c:24677
int SCIPvarGetNLocksDownType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
Definition: var.c:4328
SCIP_RATIONAL * SCIPvarGetObjExact(SCIP_VAR *var)
Definition: var.c:23910
SCIP_RATIONAL * SCIPvarGetUbGlobalExact(SCIP_VAR *var)
Definition: var.c:24152
SCIP_Real SCIPvarGetUnchangedObj(SCIP_VAR *var)
Definition: var.c:23932
SCIP_Real * SCIPvarGetMultaggrScalars(SCIP_VAR *var)
Definition: var.c:23818
SCIP_VAR * SCIPvarGetAggrVar(SCIP_VAR *var)
Definition: var.c:23736
SCIP_Real SCIPlpGetLooseObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:13475
SCIP_Bool SCIPlpDivingObjChanged(SCIP_LP *lp)
Definition: lp.c:18261
SCIP_Real SCIPlpGetObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:13436
SCIP_Real SCIProwGetSolActivity(SCIP_ROW *row, SCIP_SET *set, SCIP_STAT *stat, SCIP_SOL *sol)
Definition: lp.c:6696
SCIP_Bool SCIPlpDiving(SCIP_LP *lp)
Definition: lp.c:18251
SCIP_Bool SCIPlpIsSolved(SCIP_LP *lp)
Definition: lp.c:18211
SCIP_COL ** SCIPlpGetCols(SCIP_LP *lp)
Definition: lp.c:17969
int SCIPlpGetNCols(SCIP_LP *lp)
Definition: lp.c:17979
static const SCIP_Real scalars[]
Definition: lp.c:5959
SCIP_Real SCIPlpGetPseudoObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:13619
internal methods for LP management
void SCIPlpExactGetPseudoObjval(SCIP_LPEXACT *lpexact, SCIP_SET *set, SCIP_RATIONAL *res)
Definition: lpexact.c:7438
void SCIPlpExactGetObjval(SCIP_LPEXACT *lpexact, SCIP_SET *set, SCIP_RATIONAL *res)
Definition: lpexact.c:7416
internal methods for exact LP management
#define BMSfreeBlockMemory(mem, ptr)
Definition: memory.h:465
#define BMSallocBlockMemory(mem, ptr)
Definition: memory.h:451
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:437
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:618
void SCIPmessagePrintInfo(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:594
SCIP_Bool SCIPboolarrayGetVal(SCIP_BOOLARRAY *boolarray, int idx)
Definition: misc.c:5056
SCIP_RETCODE SCIPboolarrayFree(SCIP_BOOLARRAY **boolarray)
Definition: misc.c:4854
SCIP_RETCODE SCIPboolarrayCopy(SCIP_BOOLARRAY **boolarray, BMS_BLKMEM *blkmem, SCIP_BOOLARRAY *sourceboolarray)
Definition: misc.c:4830
SCIP_RETCODE SCIPrealarraySetVal(SCIP_REALARRAY *realarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, SCIP_Real val)
Definition: misc.c:4338
SCIP_Real SCIPrealarrayGetVal(SCIP_REALARRAY *realarray, int idx)
Definition: misc.c:4317
SCIP_RETCODE SCIPrealarrayIncVal(SCIP_REALARRAY *realarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, SCIP_Real incval)
Definition: misc.c:4407
SCIP_RETCODE SCIPrealarrayCreate(SCIP_REALARRAY **realarray, BMS_BLKMEM *blkmem)
Definition: misc.c:4073
SCIP_RETCODE SCIPrealarrayCopy(SCIP_REALARRAY **realarray, BMS_BLKMEM *blkmem, SCIP_REALARRAY *sourcerealarray)
Definition: misc.c:4093
SCIP_RETCODE SCIPboolarrayCreate(SCIP_BOOLARRAY **boolarray, BMS_BLKMEM *blkmem)
Definition: misc.c:4810
SCIP_RETCODE SCIPboolarrayClear(SCIP_BOOLARRAY *boolarray)
Definition: misc.c:5025
SCIP_RETCODE SCIPrealarrayFree(SCIP_REALARRAY **realarray)
Definition: misc.c:4117
SCIP_RETCODE SCIPboolarraySetVal(SCIP_BOOLARRAY *boolarray, int arraygrowinit, SCIP_Real arraygrowfac, int idx, SCIP_Bool val)
Definition: misc.c:5077
internal miscellaneous methods
SCIP_Bool SCIPnlpIsDivingObjChanged(SCIP_NLP *nlp)
Definition: nlp.c:4781
SCIP_Bool SCIPnlpHasSolution(SCIP_NLP *nlp)
Definition: nlp.c:4544
SCIP_VAR ** SCIPnlpGetVars(SCIP_NLP *nlp)
Definition: nlp.c:4292
int SCIPnlpGetNVars(SCIP_NLP *nlp)
Definition: nlp.c:4302
SCIP_Real SCIPnlpGetObjval(SCIP_NLP *nlp)
Definition: nlp.c:4077
internal methods for NLP management
void SCIPprimalSolFreed(SCIP_PRIMAL *primal, SCIP_SOL *sol)
Definition: primal.c:2024
SCIP_Bool SCIPprimalUpdateViolations(SCIP_PRIMAL *primal)
Definition: primal.c:2301
SCIP_RETCODE SCIPprimalSolCreated(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_SOL *sol)
Definition: primal.c:2002
internal methods for collecting primal CIP solutions and primal informations
void SCIPprobInternObjvalExact(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_RATIONAL *objval, SCIP_RATIONAL *objvalint)
Definition: prob.c:2599
SCIP_Real SCIPprobGetObjoffset(SCIP_PROB *prob)
Definition: prob.c:2994
int SCIPprobGetNImplVars(SCIP_PROB *prob)
Definition: prob.c:2895
int SCIPprobGetNIntVars(SCIP_PROB *prob)
Definition: prob.c:2886
int SCIPprobGetNVars(SCIP_PROB *prob)
Definition: prob.c:2868
int SCIPprobGetNBinVars(SCIP_PROB *prob)
Definition: prob.c:2877
SCIP_VAR ** SCIPprobGetVars(SCIP_PROB *prob)
Definition: prob.c:2913
SCIP_Real SCIPprobInternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2573
SCIP_RETCODE SCIPprobSortConssCheck(SCIP_PROB *prob)
Definition: prob.c:748
internal methods for storing and manipulating the main problem
public methods for LP management
public methods for message output
#define SCIPerrorMessage
Definition: pub_message.h:64
#define SCIPdebugPrintf
Definition: pub_message.h:99
#define SCIPisFinite(x)
Definition: pub_misc.h:82
public methods for primal CIP solutions
public methods for problem variables
SCIP_Real SCIPrelaxationGetSolObj(SCIP_RELAXATION *relaxation)
Definition: relax.c:854
SCIP_RELAX * SCIPrelaxationGetSolRelax(SCIP_RELAXATION *relaxation)
Definition: relax.c:906
SCIP_Bool SCIPrelaxationIsSolValid(SCIP_RELAXATION *relaxation)
Definition: relax.c:823
internal methods for relaxators
SCIP_Real SCIPsetFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6716
SCIP_Bool SCIPsetIsFeasPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:7076
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6617
SCIP_Real SCIPsetFeasCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:7136
SCIP_Bool SCIPsetIsFeasNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:7087
SCIP_Real SCIPsetCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6728
SCIP_Bool SCIPsetIsFeasGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:7017
SCIP_Bool SCIPsetIsFeasLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6993
SCIP_Bool SCIPsetIsPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6648
SCIP_Bool SCIPsetIsLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6577
SCIP_Real SCIPsetFeasFloor(SCIP_SET *set, SCIP_Real val)
Definition: set.c:7124
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6537
SCIP_Bool SCIPsetIsFeasLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6969
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:6380
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6557
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6515
SCIP_Bool SCIPsetIsGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6597
SCIP_Bool SCIPsetIsZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6637
SCIP_Bool SCIPsetIsFeasGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:7041
SCIP_Bool SCIPsetIsFeasIntegral(SCIP_SET *set, SCIP_Real val)
Definition: set.c:7098
SCIP_Bool SCIPsetIsNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6659
internal methods for global SCIP settings
#define SCIPsetFreeBufferArray(set, ptr)
Definition: set.h:1782
#define SCIPsetDebugMsgPrint
Definition: set.h:1812
#define SCIPsetAllocBufferArray(set, ptr, num)
Definition: set.h:1775
#define SCIPsetDebugMsg
Definition: set.h:1811
#define SCIPsetReallocBufferArray(set, ptr, num)
Definition: set.h:1779
void SCIPsolUpdateVarObj(SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real oldobj, SCIP_Real newobj)
Definition: sol.c:2293
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:914
void SCIPsolUpdateConsViolation(SCIP_SOL *sol, SCIP_Real absviolcons, SCIP_Real relviolcons)
Definition: sol.c:3941
SCIP_RETCODE SCIPsolMakeReal(SCIP_SOL *sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob)
Definition: sol.c:2906
SCIP_RETCODE SCIPsolLinkPseudoSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:1318
void SCIPsolSetPrimalIndex(SCIP_SOL *sol, int primalindex)
Definition: sol.c:4279
static void solStamp(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_Bool checktime)
Definition: sol.c:400
SCIP_RETCODE SCIPsolCreatePartial(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_HEUR *heur)
Definition: sol.c:1039
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:1079
void SCIPsolUpdateBoundViolation(SCIP_SOL *sol, SCIP_Real absviolbounds, SCIP_Real relviolbounds)
Definition: sol.c:3915
static SCIP_RETCODE solSetArrayVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_VAR *var, SCIP_Real val)
Definition: sol.c:80
void SCIPsolGetValExact(SCIP_RATIONAL *res, SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition: sol.c:2039
int SCIPsolGetPrimalIndex(SCIP_SOL *sol)
Definition: sol.c:4269
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:893
SCIP_RETCODE SCIPsolMakeExact(SCIP_SOL *sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob)
Definition: sol.c:2870
SCIP_RETCODE SCIPsolLinkCurrentSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:1368
static SCIP_RETCODE solIncArrayVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_VAR *var, SCIP_Real incval)
Definition: sol.c:143
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:2669
SCIP_RETCODE SCIPsolMarkPartial(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR **vars, int nvars)
Definition: sol.c:2312
void SCIPsolRecomputeInternObjExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob)
Definition: sol.c:3256
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:514
SCIP_RETCODE SCIPsolSetValExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_RATIONAL *val)
Definition: sol.c:1711
static SCIP_RETCODE solUnlinkVar(SCIP_SOL *sol, SCIP_SET *set, SCIP_VAR *var)
Definition: sol.c:285
static SCIP_RETCODE solUnlinkVarExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_VAR *var)
Definition: sol.c:347
SCIP_RETCODE SCIPsolAdjustImplicitSolVals(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_Bool uselprows)
Definition: sol.c:712
SCIP_RETCODE SCIPsolFree(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_PRIMAL *primal)
Definition: sol.c:1133
SCIP_RETCODE SCIPsolRetransformExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_Bool *hasinfval)
Definition: sol.c:3103
static SCIP_RETCODE valsExactFree(SCIP_VALSEXACT **valsexact, BMS_BLKMEM *blkmem)
Definition: sol.c:1116
void SCIPsolRecomputeObj(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob)
Definition: sol.c:3221
SCIP_RETCODE SCIPsolOverwriteFPSolWithExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree)
Definition: sol.c:4037
static void solGetArrayValExact(SCIP_RATIONAL *res, SCIP_SOL *sol, SCIP_VAR *var)
Definition: sol.c:235
void SCIPsolUpdateIntegralityViolation(SCIP_SOL *sol, SCIP_Real absviolintegrality)
Definition: sol.c:3904
void SCIPsolUpdateLPRowViolation(SCIP_SOL *sol, SCIP_Real absviollprows, SCIP_Real relviollprows)
Definition: sol.c:3928
SCIP_RETCODE SCIPsolLinkLPSolExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_LPEXACT *lp)
Definition: sol.c:1214
SCIP_RETCODE SCIPsolIncVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real incval)
Definition: sol.c:1832
SCIP_RETCODE SCIPsolLinkNLPSol(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_NLP *nlp)
Definition: sol.c:1237
SCIP_RETCODE SCIPsolPrintExact(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:3577
SCIP_RETCODE SCIPsolRetransform(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_Bool *hasinfval)
Definition: sol.c:2970
static SCIP_Real solGetArrayVal(SCIP_SOL *sol, SCIP_VAR *var)
Definition: sol.c:184
SCIP_RETCODE SCIPsolCreatePseudoSolExact(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_LPEXACT *lp, SCIP_HEUR *heur)
Definition: sol.c:965
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:985
SCIP_RETCODE SCIPsolRound(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_Bool *success)
Definition: sol.c:2797
SCIP_RETCODE SCIPsolTransform(SCIP_SOL *sol, SCIP_SOL **transsol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PRIMAL *primal)
Definition: sol.c:658
SCIP_RETCODE SCIPsolSetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real val)
Definition: sol.c:1490
SCIP_RETCODE SCIPvalsExactCopy(SCIP_VALSEXACT **valsexact, BMS_BLKMEM *blkmem, SCIP_VALSEXACT *sourcevals)
Definition: sol.c:497
static SCIP_RETCODE solClearArrays(SCIP_SOL *sol)
Definition: sol.c:61
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:940
SCIP_RETCODE SCIPsolClear(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree)
Definition: sol.c:1394
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:846
SCIP_RETCODE SCIPsolSetUnknown(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree)
Definition: sol.c:1414
SCIP_RETCODE SCIPsolLinkRelaxSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_RELAXATION *relaxation)
Definition: sol.c:1288
SCIP_RETCODE SCIPsolCreateOriginalExact(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:555
SCIP_Real SCIPsolGetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition: sol.c:1908
static SCIP_RETCODE solCheckExact(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 checklprows, SCIP_Bool *feasible)
Definition: sol.c:2375
static SCIP_RETCODE solSetArrayValExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_VAR *var, SCIP_RATIONAL *val)
Definition: sol.c:111
SCIP_RETCODE SCIPsolLinkPseudoSolExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_LPEXACT *lp)
Definition: sol.c:1347
SCIP_RETCODE SCIPsolCreateExact(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_HEUR *heur)
Definition: sol.c:470
SCIP_RETCODE SCIPsolCreateCurrentSolExact(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_LPEXACT *lp, SCIP_HEUR *heur)
Definition: sol.c:1012
SCIP_RETCODE SCIPsolUnlink(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *prob)
Definition: sol.c:1431
void SCIPsolGetObjExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_RATIONAL *objval)
Definition: sol.c:2274
SCIP_Real SCIPsolGetRayVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition: sol.c:2188
static SCIP_Bool solsAreEqualExact(SCIP_SOL *sol1, SCIP_SOL *sol2, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob)
Definition: sol.c:3293
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:3766
void SCIPsolResetViolations(SCIP_SOL *sol)
Definition: sol.c:3888
void SCIPsolSetOrigin(SCIP_SOL *sol, SCIP_SOLORIGIN origin)
Definition: sol.c:3874
SCIP_RETCODE SCIPsolLinkLPSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:1156
SCIP_Bool SCIPsolsAreEqual(SCIP_SOL *sol1, SCIP_SOL *sol2, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob)
Definition: sol.c:3370
SCIP_RATIONAL * SCIPsolGetOrigObjExact(SCIP_SOL *sol)
Definition: sol.c:4181
SCIP_Real SCIPsolGetObj(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition: sol.c:2257
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:3441
void SCIPsolUpdateVarsum(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_Real weight)
Definition: sol.c:2942
SCIP_RETCODE SCIPsolCopy(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_SOL *sourcesol)
Definition: sol.c:583
SCIP_RETCODE SCIPsolCheckOrig(SCIP_SOL *sol, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PRIMAL *primal, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool checkmodifiable, SCIP_Bool *feasible)
Definition: sol.c:2502
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:428
SCIP_RETCODE SCIPsolCreateLPSolExact(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_LPEXACT *lp, SCIP_HEUR *heur)
Definition: sol.c:871
void SCIPsolUpdateLPConsViolation(SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition: sol.c:3954
SCIP_RETCODE SCIPsolUnlinkExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *prob)
Definition: sol.c:1460
void SCIPsolOrigAddObjval(SCIP_SOL *sol, SCIP_Real addval)
Definition: sol.c:4193
internal methods for storing primal CIP solutions
internal methods for problem statistics
#define SCIPstatDebugMsg
Definition: stat.h:322
SCIP_Real primsol
Definition: struct_lp.h:150
SCIP_Bool solved
SCIP_Bool solved
Definition: struct_lp.h:373
int ncontimplvars
Definition: struct_prob.h:79
SCIP_VAR ** fixedvars
Definition: struct_prob.h:68
SCIP_Real objoffset
Definition: struct_prob.h:50
SCIP_Bool transformed
Definition: struct_prob.h:94
int ncontvars
Definition: struct_prob.h:80
SCIP_CONS ** origcheckconss
Definition: struct_prob.h:72
int nfixedvars
Definition: struct_prob.h:83
SCIP_VAR ** vars
Definition: struct_prob.h:67
int nconss
Definition: struct_prob.h:88
int depth
Definition: struct_sol.h:89
int runnum
Definition: struct_sol.h:88
SCIP_Longint lpcount
Definition: struct_sol.h:99
SCIP_SOLORIGIN solorigin
Definition: struct_sol.h:92
SCIP_REALARRAY * vals
Definition: struct_sol.h:78
SCIP_VIOL viol
Definition: struct_sol.h:87
int primalindex
Definition: struct_sol.h:90
SCIP_Bool hasinfval
Definition: struct_sol.h:93
SCIP_Real time
Definition: struct_sol.h:76
SCIP_SOLTYPE type
Definition: struct_sol.h:97
SCIP_Longint nodenum
Definition: struct_sol.h:77
int index
Definition: struct_sol.h:91
SCIP_RELAX * relax
Definition: struct_sol.h:85
union SCIP_Sol::@20 creator
SCIP_BOOLARRAY * valid
Definition: struct_sol.h:79
SCIP_HEUR * heur
Definition: struct_sol.h:84
SCIP_VALSEXACT * valsexact
Definition: struct_sol.h:81
SCIP_Real obj
Definition: struct_sol.h:75
SCIP * scip
Definition: struct_sol.h:101
SCIP_Longint nnodes
Definition: struct_stat.h:84
SCIP_Longint lpcount
Definition: struct_stat.h:205
int solindex
Definition: struct_stat.h:306
SCIP_CLOCK * solvingtime
Definition: struct_stat.h:168
SCIP_RATIONAL * obj
Definition: struct_sol.h:112
SCIP_BOOLARRAY * valid
Definition: struct_sol.h:114
SCIP_RATIONALARRAY * vals
Definition: struct_sol.h:113
SCIP * scip
Definition: struct_var.h:345
SCIP_Real obj
Definition: struct_var.h:263
SCIP_Real primsolavg
Definition: struct_var.h:272
SCIP_Real absviolcons
Definition: struct_sol.h:57
SCIP_Real absviollprows
Definition: struct_sol.h:54
SCIP_Real absviolintegrality
Definition: struct_sol.h:56
SCIP_Real relviollprows
Definition: struct_sol.h:55
SCIP_Real absviolbounds
Definition: struct_sol.h:52
SCIP_Real relviolbounds
Definition: struct_sol.h:53
SCIP_Real relviolcons
Definition: struct_sol.h:58
data structures for LP management
data structures for exact LP management
datastructures for storing and manipulating the main problem
datastructures for global SCIP settings
datastructures for storing primal CIP solutions
datastructures for problem statistics
datastructures for problem variables
Definition: heur_padm.c:135
SCIP_Bool SCIPtreeProbing(SCIP_TREE *tree)
Definition: tree.c:9361
SCIP_Bool SCIPtreeHasCurrentNodeLP(SCIP_TREE *tree)
Definition: tree.c:9496
int SCIPtreeGetCurrentDepth(SCIP_TREE *tree)
Definition: tree.c:9479
internal methods for branch and bound tree
enum SCIP_RoundModeRational SCIP_ROUNDMODE_RAT
Definition: type_rational.h:61
@ SCIP_R_ROUND_UPWARDS
Definition: type_rational.h:58
@ SCIP_R_ROUND_DOWNWARDS
Definition: type_rational.h:57
@ SCIP_FEASIBLE
Definition: type_result.h:45
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:61
@ SCIP_INVALIDDATA
Definition: type_retcode.h:52
@ SCIP_OKAY
Definition: type_retcode.h:42
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
@ SCIP_SOLTYPE_HEUR
Definition: type_sol.h:65
@ SCIP_SOLTYPE_STRONGBRANCH
Definition: type_sol.h:68
@ SCIP_SOLTYPE_RELAX
Definition: type_sol.h:66
@ SCIP_SOLTYPE_PSEUDO
Definition: type_sol.h:69
@ SCIP_SOLTYPE_LPRELAX
Definition: type_sol.h:67
@ SCIP_SOLTYPE_UNKNOWN
Definition: type_sol.h:64
@ SCIP_SOLORIGIN_ZERO
Definition: type_sol.h:43
@ SCIP_SOLORIGIN_UNKNOWN
Definition: type_sol.h:51
@ SCIP_SOLORIGIN_RELAXSOL
Definition: type_sol.h:46
@ SCIP_SOLORIGIN_PSEUDOSOL
Definition: type_sol.h:47
@ SCIP_SOLORIGIN_LPSOL
Definition: type_sol.h:44
@ SCIP_SOLORIGIN_PARTIAL
Definition: type_sol.h:48
@ SCIP_SOLORIGIN_ORIGINAL
Definition: type_sol.h:42
@ SCIP_SOLORIGIN_NLPSOL
Definition: type_sol.h:45
enum SCIP_SolType SCIP_SOLTYPE
Definition: type_sol.h:71
enum SCIP_SolOrigin SCIP_SOLORIGIN
Definition: type_sol.h:55
@ SCIP_VARSTATUS_ORIGINAL
Definition: type_var.h:51
@ SCIP_VARSTATUS_FIXED
Definition: type_var.h:54
@ SCIP_VARSTATUS_COLUMN
Definition: type_var.h:53
@ SCIP_VARSTATUS_MULTAGGR
Definition: type_var.h:56
@ SCIP_VARSTATUS_NEGATED
Definition: type_var.h:57
@ SCIP_VARSTATUS_AGGREGATED
Definition: type_var.h:55
@ SCIP_VARSTATUS_LOOSE
Definition: type_var.h:52
@ SCIP_LOCKTYPE_MODEL
Definition: type_var.h:141
SCIP_Real SCIPvarGetRelaxSolTransVar(SCIP_VAR *var)
Definition: var.c:19760
SCIP_RETCODE SCIPvarGetActiveRepresentatives(SCIP_SET *set, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, int varssize, SCIP_Real *constant, int *requiredsize)
Definition: var.c:5180
SCIP_RETCODE SCIPvarGetActiveRepresentativesExact(SCIP_SET *set, SCIP_VAR **vars, SCIP_RATIONAL **scalars, int *nvars, int varssize, SCIP_RATIONAL *constant, int *requiredsize, SCIP_Bool mergemultiples)
Definition: var.c:5511
internal methods for problem variables