Scippy

SCIP

Solving Constraint Integer Programs

primal.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 primal.c
26 * @ingroup OTHER_CFILES
27 * @brief methods for collecting primal CIP solutions and primal informations
28 * @author Tobias Achterberg
29 */
30
31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32
33#include <assert.h>
34
35#include "scip/def.h"
36#include "scip/set.h"
37#include "scip/stat.h"
38#include "scip/visual.h"
39#include "scip/event.h"
40#include "scip/lp.h"
41#include "scip/var.h"
42#include "scip/prob.h"
43#include "scip/sol.h"
44#include "scip/primal.h"
45#include "scip/tree.h"
46#include "scip/reopt.h"
47#include "scip/disp.h"
48#include "scip/struct_event.h"
49#include "scip/pub_message.h"
50#include "scip/pub_var.h"
52
53
54/*
55 * memory growing methods for dynamically allocated arrays
56 */
57
58/** ensures, that sols array can store at least num entries */
59static
61 SCIP_PRIMAL* primal, /**< primal data */
62 SCIP_SET* set, /**< global SCIP settings */
63 int num /**< minimum number of entries to store */
64 )
65{
66 assert(primal->nsols <= primal->solssize);
67
68 if( num > primal->solssize )
69 {
70 int newsize;
71
72 newsize = SCIPsetCalcMemGrowSize(set, num);
73 SCIP_ALLOC( BMSreallocMemoryArray(&primal->sols, newsize) );
74 primal->solssize = newsize;
75 }
76 assert(num <= primal->solssize);
77
78 return SCIP_OKAY;
79}
80
81/** ensures, that partialsols array can store at least num entries */
82static
84 SCIP_PRIMAL* primal, /**< primal data */
85 SCIP_SET* set, /**< global SCIP settings */
86 int num /**< minimum number of entries to store */
87 )
88{
89 assert(primal->npartialsols <= primal->partialsolssize);
90
91 if( num > primal->partialsolssize )
92 {
93 int newsize;
94
95 newsize = SCIPsetCalcMemGrowSize(set, num);
96 newsize = MIN(newsize, set->limit_maxorigsol);
97
98 SCIP_ALLOC( BMSreallocMemoryArray(&primal->partialsols, newsize) );
99 primal->partialsolssize = newsize;
100 }
101 assert(num <= primal->partialsolssize);
102
103 return SCIP_OKAY;
104}
105
106/** ensures, that existingsols array can store at least num entries */
107static
109 SCIP_PRIMAL* primal, /**< primal data */
110 SCIP_SET* set, /**< global SCIP settings */
111 int num /**< minimum number of entries to store */
112 )
113{
114 assert(primal->nexistingsols <= primal->existingsolssize);
115
116 if( num > primal->existingsolssize )
117 {
118 int newsize;
119
120 newsize = SCIPsetCalcMemGrowSize(set, num);
121 SCIP_ALLOC( BMSreallocMemoryArray(&primal->existingsols, newsize) );
122 primal->existingsolssize = newsize;
123 }
124 assert(num <= primal->existingsolssize);
125
126 return SCIP_OKAY;
127}
128
129/** creates primal data */
131 SCIP_PRIMAL** primal /**< pointer to primal data */
132 )
133{
134 assert(primal != NULL);
135
136 SCIP_ALLOC( BMSallocMemory(primal) );
137 (*primal)->sols = NULL;
138 (*primal)->partialsols = NULL;
139 (*primal)->existingsols = NULL;
140 (*primal)->currentsol = NULL;
141 (*primal)->primalray = NULL;
142 (*primal)->solssize = 0;
143 (*primal)->partialsolssize = 0;
144 (*primal)->nsols = 0;
145 (*primal)->npartialsols = 0;
146 (*primal)->existingsolssize = 0;
147 (*primal)->nexistingsols = 0;
148 (*primal)->nsolsfound = 0;
149 (*primal)->nlimsolsfound = 0;
150 (*primal)->nbestsolsfound = 0;
151 (*primal)->nlimbestsolsfound = 0;
152 (*primal)->upperbound = SCIP_INVALID;
153 (*primal)->cutoffbound = SCIP_INVALID;
154 (*primal)->updateviolations = TRUE;
155
156 return SCIP_OKAY;
157}
158
159/** frees primal data */
161 SCIP_PRIMAL** primal, /**< pointer to primal data */
162 BMS_BLKMEM* blkmem /**< block memory */
163 )
164{
165 assert(primal != NULL);
166 assert(*primal != NULL);
167
168 SCIP_CALL( SCIPprimalClear(*primal, blkmem) );
169
170 BMSfreeMemoryArrayNull(&(*primal)->sols);
171 BMSfreeMemoryArrayNull(&(*primal)->partialsols);
172 BMSfreeMemoryArrayNull(&(*primal)->existingsols);
173 BMSfreeMemory(primal);
174
175 return SCIP_OKAY;
176}
177
178/** clears primal data */
180 SCIP_PRIMAL* primal, /**< pointer to primal data */
181 BMS_BLKMEM* blkmem /**< block memory */
182 )
183{
184 int s;
185
186 assert(primal != NULL);
187
188 /* free temporary solution for storing current solution */
189 if( primal->currentsol != NULL )
190 {
191 SCIP_CALL( SCIPsolFree(&primal->currentsol, blkmem, primal) );
192 }
193
194 /* free solution for storing primal ray */
195 if( primal->primalray != NULL )
196 {
197 SCIP_CALL( SCIPsolFree(&primal->primalray, blkmem, primal) );
198 }
199
200 /* free feasible primal CIP solutions */
201 for( s = 0; s < primal->nsols; ++s )
202 {
203 SCIP_CALL( SCIPsolFree(&primal->sols[s], blkmem, primal) );
204 }
205
206 /* free partial CIP solutions */
207 for( s = 0; s < primal->npartialsols; ++s )
208 {
209 SCIP_CALL( SCIPsolFree(&primal->partialsols[s], blkmem, primal) );
210 }
211 assert(primal->nexistingsols == 0);
212
213 primal->currentsol = NULL;
214 primal->primalray = NULL;
215 primal->nsols = 0;
216 primal->nsolsfound = 0;
217 primal->npartialsols = 0;
218 primal->nlimsolsfound = 0;
219 primal->nbestsolsfound = 0;
220 primal->nlimbestsolsfound = 0;
221 primal->upperbound = SCIP_INVALID;
222 primal->cutoffbound = SCIP_INVALID;
223 primal->updateviolations = TRUE;
224
225 return SCIP_OKAY;
226}
227
228/** sorts primal solutions by objective value */
229static
231 SCIP_PRIMAL* primal, /**< primal data */
232 SCIP_SET* set, /**< global SCIP settings */
233 SCIP_PROB* origprob, /**< original problem */
234 SCIP_PROB* transprob /**< transformed problem */
235 )
236{
237 int i;
238
239 for( i = 1; i < primal->nsols; ++i )
240 {
241 SCIP_SOL* sol;
242 SCIP_Real objval;
243 int j;
244
245 sol = primal->sols[i];
246 objval = SCIPsolGetObj(sol, set, transprob, origprob);
247 for( j = i; j > 0 && objval < SCIPsolGetObj(primal->sols[j-1], set, transprob, origprob); --j )
248 primal->sols[j] = primal->sols[j-1];
249 primal->sols[j] = sol;
250 }
251
252 return;
253}
254
255/** sets the cutoff bound in primal data and in LP solver */
256static
258 SCIP_PRIMAL* primal, /**< primal data */
259 BMS_BLKMEM* blkmem, /**< block memory */
260 SCIP_SET* set, /**< global SCIP settings */
261 SCIP_STAT* stat, /**< problem statistics data */
262 SCIP_PROB* prob, /**< problem data */
263 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
264 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
265 SCIP_TREE* tree, /**< branch and bound tree */
266 SCIP_REOPT* reopt, /**< reoptimization data structure */
267 SCIP_LP* lp, /**< current LP data */
268 SCIP_Real cutoffbound /**< new cutoff bound */
269 )
270{
271 assert(primal != NULL);
272 assert(cutoffbound <= SCIPsetInfinity(set));
273 assert(primal->upperbound == SCIP_INVALID || SCIPsetIsLE(set, cutoffbound, primal->upperbound)); /*lint !e777*/
274 assert(!SCIPtreeInRepropagation(tree));
275
276 SCIPsetDebugMsg(set, "changing cutoff bound from %g to %g\n", primal->cutoffbound, cutoffbound);
277
278 primal->cutoffbound = MIN(cutoffbound, primal->upperbound); /* get rid of numerical issues */
279
280 /* set cut off value in LP solver */
281 SCIP_CALL( SCIPlpSetCutoffbound(lp, set, prob, primal->cutoffbound) );
282
283 /* cut off leaves of the tree */
284 SCIP_CALL( SCIPtreeCutoff(tree, reopt, blkmem, set, stat, eventfilter, eventqueue, lp, primal->cutoffbound) );
285
286 return SCIP_OKAY;
287}
288
289/** sets the cutoff bound in primal data and in LP solver */
291 SCIP_PRIMAL* primal, /**< primal data */
292 BMS_BLKMEM* blkmem, /**< block memory */
293 SCIP_SET* set, /**< global SCIP settings */
294 SCIP_STAT* stat, /**< problem statistics data */
295 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
296 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
297 SCIP_PROB* transprob, /**< transformed problem data */
298 SCIP_PROB* origprob, /**< original problem data */
299 SCIP_TREE* tree, /**< branch and bound tree */
300 SCIP_REOPT* reopt, /**< reoptimization data structure */
301 SCIP_LP* lp, /**< current LP data */
302 SCIP_Real cutoffbound, /**< new cutoff bound */
303 SCIP_Bool useforobjlimit /**< should the cutoff bound be used to update the objective limit, if
304 * better? */
305 )
306{
307 assert(primal != NULL);
308 assert(cutoffbound <= SCIPsetInfinity(set));
309 assert(cutoffbound <= primal->upperbound);
310 assert(transprob != NULL);
311 assert(origprob != NULL);
312
313 if( cutoffbound < primal->cutoffbound )
314 {
315 if( useforobjlimit )
316 {
317 SCIP_Real objval;
318
319 objval = SCIPprobExternObjval(transprob, origprob, set, cutoffbound);
320
321 if( objval < SCIPprobGetObjlim(origprob, set) )
322 {
323 SCIPsetDebugMsg(set, "changing cutoff bound from %g to %g changes objective limit from %g to %g\n",
324 primal->cutoffbound, cutoffbound, SCIPprobGetObjlim(origprob, set), objval);
325 SCIPprobSetObjlim(origprob, objval);
326 SCIPprobSetObjlim(transprob, objval);
327 }
328 }
329
330 /* update cutoff bound */
331 SCIP_CALL( primalSetCutoffbound(primal, blkmem, set, stat, transprob, eventfilter, eventqueue, tree, reopt, lp, cutoffbound) );
332 }
333 else if( cutoffbound > primal->cutoffbound )
334 {
335 SCIPerrorMessage("invalid increase in cutoff bound\n");
336 return SCIP_INVALIDDATA;
337 }
338
339 return SCIP_OKAY;
340}
341
342/** sets upper bound in primal data and in LP solver */
343static
345 SCIP_PRIMAL* primal, /**< primal data */
346 BMS_BLKMEM* blkmem, /**< block memory */
347 SCIP_SET* set, /**< global SCIP settings */
348 SCIP_STAT* stat, /**< problem statistics data */
349 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
350 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
351 SCIP_PROB* prob, /**< transformed problem after presolve */
352 SCIP_TREE* tree, /**< branch and bound tree */
353 SCIP_REOPT* reopt, /**< reoptimization data structure */
354 SCIP_LP* lp, /**< current LP data */
355 SCIP_Real upperbound /**< new upper bound */
356 )
357{
358 SCIP_Real cutoffbound;
359
360 assert(primal != NULL);
361 assert(stat != NULL);
362 assert(upperbound <= SCIPsetInfinity(set));
363 assert(upperbound <= primal->upperbound || stat->nnodes == 0);
364
365 SCIPsetDebugMsg(set, "changing upper bound from %g to %g\n", primal->upperbound, upperbound);
366
367 primal->upperbound = upperbound;
368
369 /* if objective value is always integral, the cutoff bound can be reduced to nearly the previous integer number */
370 if( SCIPprobIsObjIntegral(prob) && !SCIPsetIsInfinity(set, upperbound) )
371 {
372 SCIP_Real delta;
373
375
376 cutoffbound = SCIPsetFeasCeil(set, upperbound) - (1.0 - delta);
377 cutoffbound = MIN(cutoffbound, upperbound); /* SCIPsetFeasCeil() can increase bound by almost 1.0 due to numerics
378 * and very large upperbound value */
379 }
380 else
381 cutoffbound = upperbound;
382
383 /* update cutoff bound */
384 if( cutoffbound < primal->cutoffbound )
385 {
386 SCIP_CALL( primalSetCutoffbound(primal, blkmem, set, stat, prob, eventfilter, eventqueue, tree, reopt, lp, cutoffbound) );
387 }
388
389 /* update upper bound in visualization output */
390 if( SCIPtreeGetCurrentDepth(tree) >= 0 )
391 {
392 SCIPvisualUpperbound(stat->visual, set, stat, primal->upperbound);
393 }
394
395 return SCIP_OKAY;
396}
397
398/** sets upper bound in primal data and in LP solver */
400 SCIP_PRIMAL* primal, /**< primal data */
401 BMS_BLKMEM* blkmem, /**< block memory */
402 SCIP_SET* set, /**< global SCIP settings */
403 SCIP_STAT* stat, /**< problem statistics data */
404 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
405 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
406 SCIP_PROB* prob, /**< transformed problem after presolve */
407 SCIP_TREE* tree, /**< branch and bound tree */
408 SCIP_REOPT* reopt, /**< reoptimization data structure */
409 SCIP_LP* lp, /**< current LP data */
410 SCIP_Real upperbound /**< new upper bound */
411 )
412{
413 assert(primal != NULL);
414 assert(upperbound <= SCIPsetInfinity(set));
415
416 if( upperbound < primal->upperbound )
417 {
418 /* update primal bound */
419 SCIP_CALL( primalSetUpperbound(primal, blkmem, set, stat, eventfilter, eventqueue, prob, tree, reopt, lp, upperbound) );
420 }
421 else if( upperbound > primal->upperbound )
422 {
423 SCIPerrorMessage("invalid increase in upper bound\n");
424 return SCIP_INVALIDDATA;
425 }
426
427 return SCIP_OKAY;
428}
429
430/** updates upper bound and cutoff bound in primal data after a tightening of the problem's objective limit */
432 SCIP_PRIMAL* primal, /**< primal data */
433 BMS_BLKMEM* blkmem, /**< block memory */
434 SCIP_SET* set, /**< global SCIP settings */
435 SCIP_STAT* stat, /**< problem statistics data */
436 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
437 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
438 SCIP_PROB* transprob, /**< transformed problem data */
439 SCIP_PROB* origprob, /**< original problem data */
440 SCIP_TREE* tree, /**< branch and bound tree */
441 SCIP_REOPT* reopt, /**< reoptimization data structure */
442 SCIP_LP* lp /**< current LP data */
443 )
444{
445 SCIP_Real objlimit;
446 SCIP_Real inf;
447
448 assert(primal != NULL);
449
450 /* get internal objective limit */
451 objlimit = SCIPprobInternObjval(transprob, origprob, set, SCIPprobGetObjlim(origprob, set));
452 inf = SCIPsetInfinity(set);
453 objlimit = MIN(objlimit, inf);
454
455 /* update the cutoff bound */
456 if( objlimit < primal->cutoffbound )
457 {
458 SCIP_CALL( primalSetCutoffbound(primal, blkmem, set, stat, transprob, eventfilter, eventqueue, tree, reopt, lp, objlimit) );
459 }
460
461 /* set new upper bound (and decrease cutoff bound, if objective value is always integral) */
462 if( objlimit < primal->upperbound )
463 {
464 SCIP_CALL( primalSetUpperbound(primal, blkmem, set, stat, eventfilter, eventqueue, transprob, tree, reopt, lp, objlimit) );
465 }
466
467 return SCIP_OKAY;
468}
469
470/** recalculates upper bound and cutoff bound in primal data after a change of the problem's objective offset */
472 SCIP_PRIMAL* primal, /**< primal data */
473 BMS_BLKMEM* blkmem, /**< block memory */
474 SCIP_SET* set, /**< global SCIP settings */
475 SCIP_STAT* stat, /**< problem statistics data */
476 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
477 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
478 SCIP_PROB* transprob, /**< tranformed problem data */
479 SCIP_PROB* origprob, /**< original problem data */
480 SCIP_TREE* tree, /**< branch and bound tree */
481 SCIP_REOPT* reopt, /**< reoptimization data structure */
482 SCIP_LP* lp /**< current LP data */
483 )
484{
485 SCIP_Real upperbound;
486 SCIP_Real inf;
487
488 assert(primal != NULL);
490
491 /* recalculate internal objective limit */
492 upperbound = SCIPprobInternObjval(transprob, origprob, set, SCIPprobGetObjlim(origprob, set));
493 inf = SCIPsetInfinity(set);
494 upperbound = MIN(upperbound, inf);
495
496 /* resort current primal solutions */
497 sortPrimalSols(primal, set, origprob, transprob);
498
499 /* compare objective limit to currently best solution */
500 if( primal->nsols > 0 )
501 {
502 SCIP_Real obj;
503
504 assert(SCIPsolIsOriginal(primal->sols[0]));
505 obj = SCIPsolGetObj(primal->sols[0], set, transprob, origprob);
506
507 upperbound = MIN(upperbound, obj);
508 }
509
510 /* invalidate old upper bound */
511 SCIP_CALL( primalSetUpperbound(primal, blkmem, set, stat, eventfilter, eventqueue, transprob, tree, reopt, lp, SCIPsetInfinity(set)) );
512
513 /* reset the cutoff bound
514 *
515 * @note we might need to relax the bound since in presolving the objective correction of an
516 * aggregation is still in progress
517 */
518 SCIP_CALL( primalSetCutoffbound(primal, blkmem, set, stat, transprob, eventfilter, eventqueue, tree, reopt, lp, upperbound) );
519
520 /* set new upper bound (and decrease cutoff bound, if objective value is always integral) */
521 SCIP_CALL( primalSetUpperbound(primal, blkmem, set, stat, eventfilter, eventqueue, transprob, tree, reopt, lp, upperbound) );
522
523 return SCIP_OKAY;
524}
525
526/** adds additional objective offset in original space to all existing solution (in original space) */
528 SCIP_PRIMAL* primal, /**< primal data */
529 SCIP_SET* set, /**< global SCIP settings */
530 SCIP_Real addval /**< additional objective offset in original space */
531 )
532{
533 int i;
534
535 assert(primal != NULL);
536 assert(set != NULL);
538
539#ifndef NDEBUG
540 assert(primal->nsols == 0 || SCIPsolGetOrigin(primal->sols[0]) == SCIP_SOLORIGIN_ORIGINAL);
541
542 /* check current order of primal solutions */
543 for( i = 1; i < primal->nsols; ++i )
544 {
545 assert(SCIPsolGetOrigin(primal->sols[i]) == SCIP_SOLORIGIN_ORIGINAL);
546 assert(SCIPsetIsLE(set, SCIPsolGetOrigObj(primal->sols[i-1]), SCIPsolGetOrigObj(primal->sols[i])));
547 }
548#endif
549
550 /* check current order of primal solutions */
551 for( i = 0; i < primal->nexistingsols; ++i )
552 {
553 assert(primal->existingsols[i] != NULL);
554 SCIPsolOrigAddObjval(primal->existingsols[i], addval);
555 }
556}
557
558/** returns whether the current primal bound is justified with a feasible primal solution; if not, the primal bound
559 * was set from the user as objective limit
560 */
562 SCIP_PRIMAL* primal, /**< primal data */
563 SCIP_SET* set, /**< global SCIP settings */
564 SCIP_PROB* transprob, /**< tranformed problem data */
565 SCIP_PROB* origprob /**< original problem data */
566 )
567{
568 assert(primal != NULL);
569
570 return (primal->nsols > 0 && SCIPsetIsEQ(set, primal->upperbound, SCIPsolGetObj(primal->sols[0], set, transprob, origprob)));
571}
572
573/** returns the primal ray thats proves unboundedness */
575 SCIP_PRIMAL* primal /**< primal data */
576 )
577{
578 assert(primal != NULL);
579
580 return primal->primalray;
581}
582
583/** update the primal ray thats proves unboundedness */
585 SCIP_PRIMAL* primal, /**< primal data */
586 SCIP_SET* set, /**< global SCIP settings */
587 SCIP_STAT* stat, /**< dynamic SCIP statistics */
588 SCIP_SOL* primalray, /**< the new primal ray */
589 BMS_BLKMEM* blkmem /**< block memory */
590 )
591{
592 assert(primal != NULL);
593 assert(set != NULL);
594 assert(stat != NULL);
595 assert(primalray != NULL);
596 assert(blkmem != NULL);
597
598 /* clear previously stored primal ray, if any */
599 if( primal->primalray != NULL )
600 {
601 SCIP_CALL( SCIPsolFree(&primal->primalray, blkmem, primal) );
602 }
603
604 assert(primal->primalray == NULL);
605
606 SCIP_CALL( SCIPsolCopy(&primal->primalray, blkmem, set, stat, primal, primalray) );
607
608 return SCIP_OKAY;
609}
610
611/** adds primal solution to solution storage at given position */
612static
614 SCIP_PRIMAL* primal, /**< primal data */
615 BMS_BLKMEM* blkmem, /**< block memory */
616 SCIP_SET* set, /**< global SCIP settings */
617 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
618 SCIP_STAT* stat, /**< problem statistics data */
619 SCIP_PROB* origprob, /**< original problem */
620 SCIP_PROB* transprob, /**< transformed problem after presolve */
621 SCIP_TREE* tree, /**< branch and bound tree */
622 SCIP_REOPT* reopt, /**< reoptimization data structure */
623 SCIP_LP* lp, /**< current LP data */
624 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
625 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
626 SCIP_SOL** solptr, /**< pointer to primal CIP solution */
627 int insertpos, /**< position in solution storage to add solution to */
628 SCIP_Bool replace /**< should the solution at insertpos be replaced by the new solution? */
629 )
630{
631 SCIP_SOL* sol;
632 /* cppcheck-suppress unassignedVariable */
633 SCIP_EVENT event;
634 SCIP_Real obj;
635 int pos;
636
637 assert(primal != NULL);
638 assert(set != NULL);
639 assert(solptr != NULL);
640 assert(stat != NULL);
641 assert(transprob != NULL);
642 assert(origprob != NULL);
643 assert(0 <= insertpos && insertpos < set->limit_maxsol);
644 assert(tree == NULL || !SCIPtreeInRepropagation(tree));
645
646 sol = *solptr;
647 assert(sol != NULL);
648
649 /* if the solution is added during presolving and it is not defined on original variables,
650 * presolving operations will destroy its validity, so we retransform it to the original space
651 */
652 if( set->stage < SCIP_STAGE_PRESOLVED && !SCIPsolIsOriginal(sol) )
653 {
654 SCIP_Bool hasinfval;
655
656 SCIP_CALL( SCIPsolUnlink(sol, set, transprob) );
657 SCIP_CALL( SCIPsolRetransform(sol, set, stat, origprob, transprob, &hasinfval) );
658 }
659
660 obj = SCIPsolGetObj(sol, set, transprob, origprob);
661
662 SCIPsetDebugMsg(set, "insert primal solution %p with obj %g at position %d (replace=%u):\n",
663 (void*)sol, obj, insertpos, replace);
664
665 /* make sure that the primal bound is at least the lower bound */
667 {
669 {
670 SCIPmessagePrintWarning(messagehdlr, "Dual bound %g is larger than the objective of the primal solution %g. The solution might not be optimal.\n",
671 SCIPprobExternObjval(transprob, origprob, set, SCIPgetLowerbound(set->scip)), SCIPprobExternObjval(transprob, origprob, set, obj));
672 }
673 else
674 {
675 SCIPmessagePrintWarning(messagehdlr, "Dual bound %g is smaller than the objective of the primal solution %g. The solution might not be optimal.\n",
676 SCIPprobExternObjval(transprob, origprob, set, SCIPgetLowerbound(set->scip)), SCIPprobExternObjval(transprob, origprob, set, obj));
677 }
678#ifdef WITH_DEBUG_SOLUTION
679 SCIPABORT();
680#endif
681 }
682
683 SCIPdebug( SCIP_CALL( SCIPsolPrint(sol, set, messagehdlr, stat, transprob, NULL, NULL, FALSE, FALSE) ) );
684
685#ifdef SCIP_DISABLED_CODE
686 /* this is not a valid debug check, but can be used to track down numerical troubles */
687#ifndef NDEBUG
688 /* check solution again completely
689 * it fail for different reasons:
690 * - in the LP solver, the feasibility tolerance is a relative measure against the row's norm
691 * - in SCIP, the feasibility tolerance is a relative measure against the row's rhs/lhs
692 * - the rhs/lhs of a row might drastically change during presolving when variables are fixed or (multi-)aggregated
693 */
694 if( !SCIPsolIsOriginal(sol) )
695 {
696 SCIP_Bool feasible;
697
698 SCIP_CALL( SCIPsolCheck(sol, set, messagehdlr, blkmem, stat, transprob, TRUE, TRUE, TRUE, TRUE, &feasible) );
699
700 if( !feasible )
701 {
702 SCIPerrorMessage("infeasible solution accepted:\n");
703 SCIP_CALL( SCIPsolPrint(sol, set, messagehdlr, stat, origprob, transprob, NULL, FALSE, FALSE) );
704 }
705 assert(feasible);
706 }
707#endif
708#endif
709
710 /* completely fill the solution's own value array to unlink it from the LP or pseudo solution */
711 SCIP_CALL( SCIPsolUnlink(sol, set, transprob) );
712
713 /* allocate memory for solution storage */
714 SCIP_CALL( ensureSolsSize(primal, set, set->limit_maxsol) );
715
716 /* if set->limit_maxsol was decreased in the meantime, free all solutions exceeding the limit */
717 for( pos = set->limit_maxsol; pos < primal->nsols; ++pos )
718 {
719 SCIP_CALL( SCIPsolFree(&primal->sols[pos], blkmem, primal) );
720 }
721 primal->nsols = MIN(primal->nsols, set->limit_maxsol);
722
723 /* if the solution should replace an existing one, free this solution, otherwise,
724 * free the last solution if the solution storage is full;
725 */
726 if( replace )
727 {
728 SCIP_CALL( SCIPsolTransform(primal->sols[insertpos], solptr, blkmem, set, primal) );
729 sol = primal->sols[insertpos];
730 }
731 else
732 {
733 if( primal->nsols == set->limit_maxsol )
734 {
735 SCIP_CALL( SCIPsolFree(&primal->sols[set->limit_maxsol - 1], blkmem, primal) );
736 }
737 else
738 {
739 primal->nsols = primal->nsols + 1;
740 assert(primal->nsols <= set->limit_maxsol);
741 }
742
743 /* move all solutions with worse objective value than the new solution */
744 for( pos = primal->nsols-1; pos > insertpos; --pos )
745 primal->sols[pos] = primal->sols[pos-1];
746
747 /* insert solution at correct position */
748 assert(0 <= insertpos && insertpos < primal->nsols);
749 primal->sols[insertpos] = sol;
750 primal->nsolsfound++;
751
752 /* check if solution is better than objective limit */
753 if( SCIPsetIsFeasLE(set, obj, SCIPprobInternObjval(transprob, origprob, set, SCIPprobGetObjlim(origprob, set))) )
754 primal->nlimsolsfound++;
755 }
756
757 /* if its the first primal solution, store the relevant statistics */
758 if( primal->nsolsfound == 1 )
759 {
760 SCIP_Real primalsolval;
761
764 stat->firstprimalheur = SCIPsolGetHeur(sol);
765 stat->firstprimaltime = SCIPsolGetTime(sol);
767
768 primalsolval = obj;
769 stat->firstprimalbound = SCIPprobExternObjval(transprob, origprob, set, primalsolval);
770
771 SCIPsetDebugMsg(set, "First Solution stored in problem specific statistics.\n");
772 SCIPsetDebugMsg(set, "-> %" SCIP_LONGINT_FORMAT " nodes, %d runs, %.2g time, %d depth, %.15g objective\n", stat->nnodesbeforefirst, stat->nrunsbeforefirst,
774 }
775
776 SCIPsetDebugMsg(set, " -> stored at position %d of %d solutions, found %" SCIP_LONGINT_FORMAT " solutions\n",
777 insertpos, primal->nsols, primal->nsolsfound);
778
779 /* update the solution value sums in variables */
780 if( !SCIPsolIsOriginal(sol) )
781 {
782 SCIPsolUpdateVarsum(sol, set, stat, transprob,
783 (SCIP_Real)(primal->nsols - insertpos)/(SCIP_Real)(2.0*primal->nsols - 1.0));
784 }
785
786 /* change color of node in visualization output */
787 SCIPvisualFoundSolution(stat->visual, set, stat, SCIPtreeGetCurrentNode(tree), insertpos == 0 ? TRUE : FALSE, sol);
788
789 /* check, if the global upper bound has to be updated */
790 if( obj < primal->cutoffbound && insertpos == 0 )
791 {
792 /* issue BESTSOLFOUND event */
794 SCIP_CALL( SCIPeventChgSol(&event, sol) );
795 SCIP_CALL( SCIPeventProcess(&event, set, NULL, NULL, NULL, eventfilter) );
796
797 /* update the upper bound */
798 SCIP_CALL( SCIPprimalSetUpperbound(primal, blkmem, set, stat, eventfilter, eventqueue, transprob, tree, reopt, lp, obj) );
799
800 primal->nbestsolsfound++;
801 stat->bestsolnode = stat->nnodes;
802 }
803 else
804 {
805 /* issue POORSOLFOUND event */
807 SCIP_CALL( SCIPeventChgSol(&event, sol) );
808 SCIP_CALL( SCIPeventProcess(&event, set, NULL, NULL, NULL, eventfilter) );
809 }
810
811
812 /* display node information line */
813 if( insertpos == 0 && !replace && set->stage >= SCIP_STAGE_SOLVING )
814 {
815 SCIP_CALL( SCIPdispPrintLine(set, messagehdlr, stat, NULL, TRUE, TRUE) );
816 }
817
818 /* if an original solution was added during solving, try to transfer it to the transformed space */
819 if( SCIPsolIsOriginal(sol) && SCIPsetGetStage(set) == SCIP_STAGE_SOLVING && set->misc_transorigsols )
820 {
821 SCIP_Bool added;
822
823 SCIP_CALL( SCIPprimalTransformSol(primal, sol, blkmem, set, messagehdlr, stat, origprob, transprob, tree, reopt,
824 lp, eventqueue, eventfilter, NULL, NULL, 0, &added) );
825
826 SCIPsetDebugMsg(set, "original solution %p was successfully transferred to the transformed problem space\n",
827 (void*)sol);
828 } /*lint !e438*/
829
830 return SCIP_OKAY;
831}
832
833/** adds primal solution to solution storage at given position */
834static
836 SCIP_PRIMAL* primal, /**< primal data */
837 BMS_BLKMEM* blkmem, /**< block memory */
838 SCIP_SET* set, /**< global SCIP settings */
839 SCIP_PROB* prob, /**< original problem data */
840 SCIP_SOL* sol, /**< primal CIP solution */
841 int insertpos /**< position in solution storage to add solution to */
842 )
843{
844 int pos;
845
846 assert(primal != NULL);
847 assert(set != NULL);
848 assert(prob != NULL);
849 assert(sol != NULL);
850 assert(0 <= insertpos && insertpos < set->limit_maxorigsol);
851 assert(!set->reopt_enable);
852
853 SCIPsetDebugMsg(set, "insert primal solution candidate %p with obj %g at position %d:\n", (void*)sol, SCIPsolGetOrigObj(sol), insertpos);
854
855 /* allocate memory for solution storage */
856 SCIP_CALL( ensureSolsSize(primal, set, set->limit_maxorigsol) );
857
858 /* if the solution storage is full, free the last solution(s)
859 * more than one solution may be freed, if set->limit_maxorigsol was decreased in the meantime
860 */
861 for( pos = set->limit_maxorigsol-1; pos < primal->nsols; ++pos )
862 {
863 SCIP_CALL( SCIPsolFree(&primal->sols[pos], blkmem, primal) );
864 }
865
866 /* insert solution at correct position */
867 primal->nsols = MIN(primal->nsols+1, set->limit_maxorigsol);
868 for( pos = primal->nsols-1; pos > insertpos; --pos )
869 primal->sols[pos] = primal->sols[pos-1];
870
871 assert(0 <= insertpos && insertpos < primal->nsols);
872 primal->sols[insertpos] = sol;
873 primal->nsolsfound++;
874
875 /* check if solution is better than objective limit */
877 primal->nlimsolsfound++;
878
879 SCIPsetDebugMsg(set, " -> stored at position %d of %d solutions, found %" SCIP_LONGINT_FORMAT " solutions\n",
880 insertpos, primal->nsols, primal->nsolsfound);
881
882 return SCIP_OKAY;
883}
884
885/** adds primal solution to solution storage */
886static
888 SCIP_PRIMAL* primal, /**< primal data */
889 SCIP_SET* set, /**< global SCIP settings */
890 SCIP_PROB* prob, /**< original problem data */
891 SCIP_SOL* sol /**< primal CIP solution */
892 )
893{ /*lint --e{715}*/
894 assert(primal != NULL);
895 assert(set != NULL);
896 assert(prob != NULL);
897 assert(sol != NULL);
898
899 if( primal->npartialsols >= set->limit_maxorigsol )
900 {
901 SCIPerrorMessage("Cannot add partial solution to storage: limit reached.\n");
902 return SCIP_INVALIDCALL;
903 }
904
905 SCIPsetDebugMsg(set, "insert partial solution candidate %p:\n", (void*)sol);
906
907 /* allocate memory for solution storage */
908 SCIP_CALL( ensurePartialsolsSize(primal, set, primal->npartialsols+1) );
909
910 primal->partialsols[primal->npartialsols] = sol;
911 ++primal->npartialsols;
912
913 return SCIP_OKAY;
914}
915
916/** uses binary search to find position in solution storage */
917static
919 SCIP_PRIMAL* primal, /**< primal data */
920 SCIP_SET* set, /**< global SCIP settings */
921 SCIP_PROB* transprob, /**< tranformed problem data */
922 SCIP_PROB* origprob, /**< original problem data */
923 SCIP_SOL* sol /**< primal solution to search position for */
924 )
925{
926 SCIP_SOL** sols;
927 SCIP_Real obj;
928 SCIP_Real middleobj;
929 int left;
930 int right;
931 int middle;
932
933 assert(primal != NULL);
934
935 obj = SCIPsolGetObj(sol, set, transprob, origprob);
936 sols = primal->sols;
937
938 left = -1;
939 right = primal->nsols;
940 while( left < right-1 )
941 {
942 middle = (left+right)/2;
943 assert(left < middle && middle < right);
944 assert(0 <= middle && middle < primal->nsols);
945
946 middleobj = SCIPsolGetObj(sols[middle], set, transprob, origprob);
947
948 if( obj < middleobj )
949 right = middle;
950 else
951 left = middle;
952 }
953 assert(left == right-1);
954
955 /* prefer solutions that live in the transformed space */
956 if( !SCIPsolIsOriginal(sol) )
957 {
958 while( right > 0 && SCIPsolIsOriginal(sols[right-1])
959 && SCIPsetIsEQ(set, SCIPsolGetObj(sols[right-1], set, transprob, origprob), obj) )
960 --right;
961 }
962
963 return right;
964}
965
966/** uses binary search to find position in solution storage */
967static
969 SCIP_PRIMAL* primal, /**< primal data */
970 SCIP_SOL* sol /**< primal solution to search position for */
971 )
972{
973 SCIP_Real obj;
974 SCIP_Real middleobj;
975 int left;
976 int right;
977 int middle;
978
979 assert(primal != NULL);
980
981 obj = SCIPsolGetOrigObj(sol);
982
983 left = -1;
984 right = primal->nsols;
985 while( left < right-1 )
986 {
987 middle = (left+right)/2;
988 assert(left < middle && middle < right);
989 assert(0 <= middle && middle < primal->nsols);
990 middleobj = SCIPsolGetOrigObj(primal->sols[middle]);
991 if( obj < middleobj )
992 right = middle;
993 else
994 left = middle;
995 }
996 assert(left == right-1);
997
998 return right;
999}
1000
1001/** returns whether the given primal solution is already existent in the solution storage */
1002static
1004 SCIP_PRIMAL* primal, /**< primal data */
1005 SCIP_SET* set, /**< global SCIP settings */
1006 SCIP_STAT* stat, /**< problem statistics data */
1007 SCIP_PROB* origprob, /**< original problem */
1008 SCIP_PROB* transprob, /**< transformed problem after presolve */
1009 SCIP_SOL* sol, /**< primal solution to search position for */
1010 int* insertpos, /**< pointer to insertion position returned by primalSearchSolPos(); the
1011 * position might be changed if an existing solution should be replaced */
1012 SCIP_Bool* replace /**< pointer to store whether the solution at insertpos should be replaced */
1013 )
1014{
1015 SCIP_Real obj;
1016 int i;
1017
1018 assert(primal != NULL);
1019 assert(insertpos != NULL);
1020 assert(replace != NULL);
1021 assert(0 <= (*insertpos) && (*insertpos) <= primal->nsols);
1022
1023 obj = SCIPsolGetObj(sol, set, transprob, origprob);
1024
1025 assert(primal->sols != NULL || primal->nsols == 0);
1026 assert(primal->sols != NULL || (*insertpos) == 0);
1027
1028 /* search in the better solutions */
1029 for( i = (*insertpos)-1; i >= 0; --i )
1030 {
1031 SCIP_Real solobj;
1032
1033 solobj = SCIPsolGetObj(primal->sols[i], set, transprob, origprob);
1034
1035 /* due to transferring the objective value of transformed solutions to the original space, small numerical errors might occur
1036 * which can lead to SCIPsetIsLE() failing in case of high absolute numbers
1037 */
1038 assert(SCIPsetIsLE(set, solobj, obj) || (REALABS(obj) > 1e+13 * SCIPsetEpsilon(set) && SCIPsetIsFeasLE(set, solobj, obj)));
1039
1040 if( SCIPsetIsLT(set, solobj, obj) )
1041 break;
1042
1043 if( SCIPsolsAreEqual(sol, primal->sols[i], set, stat, origprob, transprob) )
1044 {
1045 if( set->stage >= SCIP_STAGE_PRESOLVED && SCIPsolIsOriginal(primal->sols[i]) && !SCIPsolIsOriginal(sol) )
1046 {
1047 (*insertpos) = i;
1048 (*replace) = TRUE;
1049 }
1050 return TRUE;
1051 }
1052 }
1053
1054 /* search in the worse solutions */
1055 for( i = (*insertpos); i < primal->nsols; ++i )
1056 {
1057 SCIP_Real solobj;
1058
1059 solobj = SCIPsolGetObj(primal->sols[i], set, transprob, origprob);
1060
1061 /* due to transferring the objective value of transformed solutions to the original space, small numerical errors might occur
1062 * which can lead to SCIPsetIsLE() failing in case of high absolute numbers
1063 */
1064 assert( SCIPsetIsGE(set, solobj, obj) || (REALABS(obj) > 1e+13 * SCIPsetEpsilon(set) && SCIPsetIsFeasGE(set, solobj, obj)));
1065
1066 if( SCIPsetIsGT(set, solobj, obj) )
1067 break;
1068
1069 if( SCIPsolsAreEqual(sol, primal->sols[i], set, stat, origprob, transprob) )
1070 {
1071 if( set->stage >= SCIP_STAGE_PRESOLVED && SCIPsolIsOriginal(primal->sols[i]) && !SCIPsolIsOriginal(sol) )
1072 {
1073 (*insertpos) = i;
1074 (*replace) = TRUE;
1075 }
1076 return TRUE;
1077 }
1078 }
1079
1080 return FALSE;
1081}
1082
1083/** returns whether the given primal solution is already existent in the original solution candidate storage */
1084static
1086 SCIP_PRIMAL* primal, /**< primal data */
1087 SCIP_SET* set, /**< global SCIP settings */
1088 SCIP_STAT* stat, /**< problem statistics data */
1089 SCIP_PROB* prob, /**< original problem */
1090 SCIP_SOL* sol, /**< primal solution to search position for */
1091 int insertpos /**< insertion position returned by primalSearchOrigSolPos() */
1092 )
1093{
1094 SCIP_Real obj;
1095 int i;
1096
1097 assert(primal != NULL);
1098 assert(0 <= insertpos && insertpos <= primal->nsols);
1099
1100 obj = SCIPsolGetOrigObj(sol);
1101
1102 /* search in the better solutions */
1103 for( i = insertpos-1; i >= 0; --i )
1104 {
1105 SCIP_Real solobj;
1106
1107 solobj = SCIPsolGetOrigObj(primal->sols[i]);
1108 assert( SCIPsetIsLE(set, solobj, obj) );
1109
1110 if( SCIPsetIsLT(set, solobj, obj) )
1111 break;
1112
1113 if( SCIPsolsAreEqual(sol, primal->sols[i], set, stat, prob, NULL) )
1114 return TRUE;
1115 }
1116
1117 /* search in the worse solutions */
1118 for( i = insertpos; i < primal->nsols; ++i )
1119 {
1120 SCIP_Real solobj;
1121
1122 solobj = SCIPsolGetOrigObj(primal->sols[i]);
1123 assert( SCIPsetIsGE(set, solobj, obj) );
1124
1125 if( SCIPsetIsGT(set, solobj, obj) )
1126 break;
1127
1128 if( SCIPsolsAreEqual(sol, primal->sols[i], set, stat, prob, NULL) )
1129 return TRUE;
1130 }
1131
1132 return FALSE;
1133}
1134
1135/** check if we are willing to check the solution for feasibility */
1136static
1138 SCIP_PRIMAL* primal, /**< primal data */
1139 SCIP_SET* set, /**< global SCIP settings */
1140 SCIP_STAT* stat, /**< problem statistics data */
1141 SCIP_PROB* origprob, /**< original problem */
1142 SCIP_PROB* transprob, /**< transformed problem after presolve */
1143 SCIP_SOL* sol, /**< primal CIP solution */
1144 int* insertpos, /**< pointer to store the insert position of that solution */
1145 SCIP_Bool* replace /**< pointer to store whether the solution at insertpos should be replaced
1146 * (e.g., because it lives in the original space) */
1147 )
1148{
1149 SCIP_Real obj;
1150
1151 obj = SCIPsolGetObj(sol, set, transprob, origprob);
1152
1153 /* check if we are willing to check worse solutions; a solution is better if the objective is smaller than the
1154 * current cutoff bound; solutions with infinite objective value are never accepted
1155 */
1156 if( (!set->misc_improvingsols || obj < primal->cutoffbound) && !SCIPsetIsInfinity(set, obj) )
1157 {
1158 /* find insert position for the solution */
1159 (*insertpos) = primalSearchSolPos(primal, set, transprob, origprob, sol);
1160 (*replace) = FALSE;
1161
1162 /* the solution should be added, if the insertpos is smaller than the maximum number of solutions to be stored
1163 * and it does not already exist or it does exist, but the existing solution should be replaced by the new one
1164 */
1165 if( (*insertpos) < set->limit_maxsol &&
1166 (!primalExistsSol(primal, set, stat, origprob, transprob, sol, insertpos, replace) || (*replace)) )
1167 return TRUE;
1168 }
1169
1170 return FALSE;
1171}
1172
1173/** check if we are willing to store the solution candidate for later checking */
1174static
1176 SCIP_PRIMAL* primal, /**< primal data */
1177 SCIP_SET* set, /**< global SCIP settings */
1178 SCIP_STAT* stat, /**< problem statistics data */
1179 SCIP_PROB* origprob, /**< original problem */
1180 SCIP_SOL* sol, /**< primal CIP solution */
1181 int* insertpos /**< pointer to store the insert position of that solution */
1182 )
1183{
1184 assert(SCIPsolIsOriginal(sol));
1185
1186 /* find insert position for the solution */
1187 (*insertpos) = primalSearchOrigSolPos(primal, sol);
1188
1189 if( !set->reopt_enable && (*insertpos) < set->limit_maxorigsol && !primalExistsOrigSol(primal, set, stat, origprob, sol, *insertpos) )
1190 return TRUE;
1191
1192 return FALSE;
1193}
1194
1195/** adds primal solution to solution storage by copying it */
1197 SCIP_PRIMAL* primal, /**< primal data */
1198 BMS_BLKMEM* blkmem, /**< block memory */
1199 SCIP_SET* set, /**< global SCIP settings */
1200 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1201 SCIP_STAT* stat, /**< problem statistics data */
1202 SCIP_PROB* origprob, /**< original problem */
1203 SCIP_PROB* transprob, /**< transformed problem after presolve */
1204 SCIP_TREE* tree, /**< branch and bound tree */
1205 SCIP_REOPT* reopt, /**< reoptimization data structure */
1206 SCIP_LP* lp, /**< current LP data */
1207 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1208 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1209 SCIP_SOL* sol, /**< primal CIP solution */
1210 SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
1211 )
1212{
1213 SCIP_Bool replace;
1214 int insertpos;
1215
1216 assert(primal != NULL);
1217 assert(blkmem != NULL);
1218 assert(set != NULL);
1219 assert(messagehdlr != NULL);
1220 assert(stat != NULL);
1221 assert(origprob != NULL);
1222 assert(transprob != NULL);
1223 assert(tree != NULL);
1224 assert(lp != NULL);
1225 assert(eventqueue != NULL);
1226 assert(eventfilter != NULL);
1227 assert(sol != NULL);
1228 assert(stored != NULL);
1229
1230 insertpos = -1;
1231
1232 assert(!SCIPsolIsPartial(sol));
1233
1234 if( solOfInterest(primal, set, stat, origprob, transprob, sol, &insertpos, &replace) )
1235 {
1236 SCIP_SOL* solcopy;
1237#ifdef SCIP_MORE_DEBUG
1238 int i;
1239#endif
1240
1241 assert(insertpos >= 0 && insertpos < set->limit_maxsol);
1242
1243 /* create a copy of the solution */
1244 SCIP_CALL( SCIPsolCopy(&solcopy, blkmem, set, stat, primal, sol) );
1245
1246 /* insert copied solution into solution storage */
1247 SCIP_CALL( primalAddSol(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1248 tree, reopt, lp, eventqueue, eventfilter, &solcopy, insertpos, replace) );
1249#ifdef SCIP_MORE_DEBUG
1250 for( i = 0; i < primal->nsols - 1; ++i )
1251 {
1252 assert(SCIPsetIsLE(set, SCIPsolGetObj(primal->sols[i], set, transprob, origprob), SCIPsolGetObj(primal->sols[i+1], set, transprob, origprob)));
1253 }
1254#endif
1255 *stored = TRUE;
1256 }
1257 else
1258 *stored = FALSE;
1259
1260 return SCIP_OKAY;
1261}
1262
1263/** adds primal solution to solution storage, frees the solution afterwards */
1265 SCIP_PRIMAL* primal, /**< primal data */
1266 BMS_BLKMEM* blkmem, /**< block memory */
1267 SCIP_SET* set, /**< global SCIP settings */
1268 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1269 SCIP_STAT* stat, /**< problem statistics data */
1270 SCIP_PROB* origprob, /**< original problem */
1271 SCIP_PROB* transprob, /**< transformed problem after presolve */
1272 SCIP_TREE* tree, /**< branch and bound tree */
1273 SCIP_REOPT* reopt, /**< reoptimization data structure */
1274 SCIP_LP* lp, /**< current LP data */
1275 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1276 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1277 SCIP_SOL** sol, /**< pointer to primal CIP solution; is cleared in function call */
1278 SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
1279 )
1280{
1281 SCIP_Bool replace;
1282 int insertpos;
1283
1284 assert(primal != NULL);
1285 assert(transprob != NULL);
1286 assert(origprob != NULL);
1287 assert(sol != NULL);
1288 assert(*sol != NULL);
1289 assert(stored != NULL);
1290
1291 insertpos = -1;
1292
1293 if( solOfInterest(primal, set, stat, origprob, transprob, *sol, &insertpos, &replace) )
1294 {
1295 assert(insertpos >= 0 && insertpos < set->limit_maxsol);
1296
1297 /* insert solution into solution storage */
1298 SCIP_CALL( primalAddSol(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1299 tree, reopt, lp, eventqueue, eventfilter, sol, insertpos, replace) );
1300
1301 /* clear the pointer, such that the user cannot access the solution anymore */
1302 *sol = NULL;
1303
1304 *stored = TRUE;
1305 }
1306 else
1307 {
1308 /* the solution is too bad -> free it immediately */
1309 SCIP_CALL( SCIPsolFree(sol, blkmem, primal) );
1310
1311 *stored = FALSE;
1312 }
1313 assert(*sol == NULL);
1314
1315 return SCIP_OKAY;
1316}
1317
1318/** adds primal solution to solution candidate storage of original problem space */
1320 SCIP_PRIMAL* primal, /**< primal data */
1321 BMS_BLKMEM* blkmem, /**< block memory */
1322 SCIP_SET* set, /**< global SCIP settings */
1323 SCIP_STAT* stat, /**< problem statistics data */
1324 SCIP_PROB* prob, /**< original problem data */
1325 SCIP_SOL* sol, /**< primal CIP solution; is cleared in function call */
1326 SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
1327 )
1328{
1329 int insertpos;
1330
1331 assert(primal != NULL);
1332 assert(blkmem != NULL);
1333 assert(set != NULL);
1334 assert(stat != NULL);
1335 assert(sol != NULL);
1336 assert(SCIPsolIsOriginal(sol));
1337 assert(stored != NULL);
1338
1339 insertpos = -1;
1340
1341 if( SCIPsolIsPartial(sol) )
1342 {
1343 SCIP_SOL* solcopy;
1344
1345 /* create a copy of the solution */
1346 SCIP_CALL( SCIPsolCopy(&solcopy, blkmem, set, stat, primal, sol) );
1347
1348 SCIP_CALL( primalAddOrigPartialSol(primal, set, prob, solcopy) );
1349
1350 *stored = TRUE;
1351 }
1352 else if( origsolOfInterest(primal, set, stat, prob, sol, &insertpos) )
1353 {
1354 SCIP_SOL* solcopy;
1355
1356 assert(insertpos >= 0 && insertpos < set->limit_maxorigsol);
1357 assert(!set->reopt_enable);
1358
1359 /* create a copy of the solution */
1360 SCIP_CALL( SCIPsolCopy(&solcopy, blkmem, set, stat, primal, sol) );
1361
1362 /* insert solution into solution storage */
1363 SCIP_CALL( primalAddOrigSol(primal, blkmem, set, prob, solcopy, insertpos) );
1364
1365 *stored = TRUE;
1366 }
1367 else
1368 *stored = FALSE;
1369
1370 return SCIP_OKAY;
1371}
1372
1373/** adds primal solution to solution candidate storage of original problem space, frees the solution afterwards */
1375 SCIP_PRIMAL* primal, /**< primal data */
1376 BMS_BLKMEM* blkmem, /**< block memory */
1377 SCIP_SET* set, /**< global SCIP settings */
1378 SCIP_STAT* stat, /**< problem statistics data */
1379 SCIP_PROB* prob, /**< original problem data */
1380 SCIP_SOL** sol, /**< pointer to primal CIP solution; is cleared in function call */
1381 SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
1382 )
1383{
1384 int insertpos;
1385
1386 assert(primal != NULL);
1387 assert(sol != NULL);
1388 assert(*sol != NULL);
1389 assert(SCIPsolIsOriginal(*sol));
1390 assert(stored != NULL);
1391
1392 insertpos = -1;
1393
1394 if( SCIPsolIsPartial(*sol) )
1395 {
1396 /* insert solution into solution storage */
1397 SCIP_CALL( primalAddOrigPartialSol(primal, set, prob, *sol) );
1398
1399 /* clear the pointer, such that the user cannot access the solution anymore */
1400 *sol = NULL;
1401
1402 *stored = TRUE;
1403 }
1404 else if( origsolOfInterest(primal, set, stat, prob, *sol, &insertpos) )
1405 {
1406 assert(insertpos >= 0 && insertpos < set->limit_maxorigsol);
1407 assert(!set->reopt_enable);
1408
1409 /* insert solution into solution storage */
1410 SCIP_CALL( primalAddOrigSol(primal, blkmem, set, prob, *sol, insertpos) );
1411
1412 /* clear the pointer, such that the user cannot access the solution anymore */
1413 *sol = NULL;
1414
1415 *stored = TRUE;
1416 }
1417 else
1418 {
1419 /* the solution is too bad -> free it immediately */
1420 SCIP_CALL( SCIPsolFree(sol, blkmem, primal) );
1421
1422 *stored = FALSE;
1423 }
1424 assert(*sol == NULL);
1425
1426 return SCIP_OKAY;
1427}
1428
1429/** links temporary solution of primal data to current solution */
1430static
1432 SCIP_PRIMAL* primal, /**< primal data */
1433 BMS_BLKMEM* blkmem, /**< block memory */
1434 SCIP_SET* set, /**< global SCIP settings */
1435 SCIP_STAT* stat, /**< problem statistics data */
1436 SCIP_PROB* prob, /**< transformed problem data */
1437 SCIP_TREE* tree, /**< branch and bound tree */
1438 SCIP_LP* lp, /**< current LP data */
1439 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
1440 )
1441{
1442 assert(primal != NULL);
1443
1444 if( primal->currentsol == NULL )
1445 {
1446 SCIP_CALL( SCIPsolCreateCurrentSol(&primal->currentsol, blkmem, set, stat, prob, primal, tree, lp, heur) );
1447 }
1448 else
1449 {
1450 SCIP_CALL( SCIPsolLinkCurrentSol(primal->currentsol, set, stat, prob, tree, lp) );
1451 SCIPsolSetHeur(primal->currentsol, heur);
1452 }
1453
1454 return SCIP_OKAY;
1455}
1456
1457/** adds current LP/pseudo solution to solution storage */
1459 SCIP_PRIMAL* primal, /**< primal data */
1460 BMS_BLKMEM* blkmem, /**< block memory */
1461 SCIP_SET* set, /**< global SCIP settings */
1462 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1463 SCIP_STAT* stat, /**< problem statistics data */
1464 SCIP_PROB* origprob, /**< original problem */
1465 SCIP_PROB* transprob, /**< transformed problem after presolve */
1466 SCIP_TREE* tree, /**< branch and bound tree */
1467 SCIP_REOPT* reopt, /**< reoptimization data structure */
1468 SCIP_LP* lp, /**< current LP data */
1469 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1470 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1471 SCIP_HEUR* heur, /**< heuristic that found the solution (or NULL if it's from the tree) */
1472 SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
1473 )
1474{
1475 assert(primal != NULL);
1476
1477 /* link temporary solution to current solution */
1478 SCIP_CALL( primalLinkCurrentSol(primal, blkmem, set, stat, transprob, tree, lp, heur) );
1479
1480 /* add solution to solution storage */
1481 SCIP_CALL( SCIPprimalAddSol(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1482 tree, reopt, lp, eventqueue, eventfilter, primal->currentsol, stored) );
1483
1484 return SCIP_OKAY;
1485}
1486
1487/** checks primal solution; if feasible, adds it to storage by copying it */
1489 SCIP_PRIMAL* primal, /**< primal data */
1490 BMS_BLKMEM* blkmem, /**< block memory */
1491 SCIP_SET* set, /**< global SCIP settings */
1492 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1493 SCIP_STAT* stat, /**< problem statistics data */
1494 SCIP_PROB* origprob, /**< original problem */
1495 SCIP_PROB* transprob, /**< transformed problem after presolve */
1496 SCIP_TREE* tree, /**< branch and bound tree */
1497 SCIP_REOPT* reopt, /**< reoptimization data structure */
1498 SCIP_LP* lp, /**< current LP data */
1499 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1500 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1501 SCIP_SOL* sol, /**< primal CIP solution */
1502 SCIP_Bool printreason, /**< Should all reasons of violations be printed? */
1503 SCIP_Bool completely, /**< Should all violations be checked? */
1504 SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
1505 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
1506 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
1507 SCIP_Bool* stored /**< stores whether given solution was feasible and good enough to keep */
1508 )
1509{
1510 SCIP_Bool feasible;
1511 SCIP_Bool replace;
1512 int insertpos;
1513
1514 assert(primal != NULL);
1515 assert(set != NULL);
1516 assert(transprob != NULL);
1517 assert(origprob != NULL);
1518 assert(tree != NULL);
1519 assert(sol != NULL);
1520 assert(stored != NULL);
1521
1522 /* if we want to solve exactly, the constraint handlers cannot rely on the LP's feasibility */
1523 checklprows = checklprows || set->misc_exactsolve;
1524
1525 insertpos = -1;
1526
1527 if( solOfInterest(primal, set, stat, origprob, transprob, sol, &insertpos, &replace) )
1528 {
1529 /* check solution for feasibility */
1530 SCIP_CALL( SCIPsolCheck(sol, set, messagehdlr, blkmem, stat, transprob, printreason, completely, checkbounds,
1531 checkintegrality, checklprows, &feasible) );
1532 }
1533 else
1534 feasible = FALSE;
1535
1536 if( feasible )
1537 {
1538 SCIP_SOL* solcopy;
1539
1540 assert(insertpos >= 0 && insertpos < set->limit_maxsol);
1541
1542 /* create a copy of the solution */
1543 SCIP_CALL( SCIPsolCopy(&solcopy, blkmem, set, stat, primal, sol) );
1544
1545 /* insert copied solution into solution storage */
1546 SCIP_CALL( primalAddSol(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1547 tree, reopt, lp, eventqueue, eventfilter, &solcopy, insertpos, replace) );
1548
1549 *stored = TRUE;
1550 }
1551 else
1552 *stored = FALSE;
1553
1554 return SCIP_OKAY;
1555}
1556
1557/** checks primal solution; if feasible, adds it to storage; solution is freed afterwards */
1559 SCIP_PRIMAL* primal, /**< primal data */
1560 BMS_BLKMEM* blkmem, /**< block memory */
1561 SCIP_SET* set, /**< global SCIP settings */
1562 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1563 SCIP_STAT* stat, /**< problem statistics data */
1564 SCIP_PROB* origprob, /**< original problem */
1565 SCIP_PROB* transprob, /**< transformed problem after presolve */
1566 SCIP_TREE* tree, /**< branch and bound tree */
1567 SCIP_REOPT* reopt, /**< reoptimization data structure */
1568 SCIP_LP* lp, /**< current LP data */
1569 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1570 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1571 SCIP_SOL** sol, /**< pointer to primal CIP solution; is cleared in function call */
1572 SCIP_Bool printreason, /**< Should all the reasons of violations be printed? */
1573 SCIP_Bool completely, /**< Should all violations be checked? */
1574 SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
1575 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
1576 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
1577 SCIP_Bool* stored /**< stores whether solution was feasible and good enough to keep */
1578 )
1579{
1580 SCIP_Bool feasible;
1581 SCIP_Bool replace;
1582 int insertpos;
1583
1584 assert(primal != NULL);
1585 assert(transprob != NULL);
1586 assert(origprob != NULL);
1587 assert(tree != NULL);
1588 assert(sol != NULL);
1589 assert(*sol != NULL);
1590 assert(stored != NULL);
1591
1592 *stored = FALSE;
1593
1594 /* if we want to solve exactly, the constraint handlers cannot rely on the LP's feasibility */
1595 checklprows = checklprows || set->misc_exactsolve;
1596
1597 insertpos = -1;
1598
1599 if( solOfInterest(primal, set, stat, origprob, transprob, *sol, &insertpos, &replace) )
1600 {
1601 /* check solution for feasibility */
1602 SCIP_CALL( SCIPsolCheck(*sol, set, messagehdlr, blkmem, stat, transprob, printreason, completely, checkbounds,
1603 checkintegrality, checklprows, &feasible) );
1604 }
1605 else
1606 feasible = FALSE;
1607
1608 if( feasible )
1609 {
1610 assert(insertpos >= 0 && insertpos < set->limit_maxsol);
1611
1612 /* insert solution into solution storage */
1613 SCIP_CALL( primalAddSol(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1614 tree, reopt, lp, eventqueue, eventfilter, sol, insertpos, replace) );
1615
1616 /* clear the pointer, such that the user cannot access the solution anymore */
1617 *sol = NULL;
1618 *stored = TRUE;
1619 }
1620 else
1621 {
1622 /* the solution is too bad or infeasible -> free it immediately */
1623 SCIP_CALL( SCIPsolFree(sol, blkmem, primal) );
1624 *stored = FALSE;
1625 }
1626 assert(*sol == NULL);
1627
1628 return SCIP_OKAY;
1629}
1630
1631/** checks current LP/pseudo solution; if feasible, adds it to storage */
1633 SCIP_PRIMAL* primal, /**< primal data */
1634 BMS_BLKMEM* blkmem, /**< block memory */
1635 SCIP_SET* set, /**< global SCIP settings */
1636 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1637 SCIP_STAT* stat, /**< problem statistics data */
1638 SCIP_PROB* origprob, /**< original problem */
1639 SCIP_PROB* transprob, /**< transformed problem after presolve */
1640 SCIP_TREE* tree, /**< branch and bound tree */
1641 SCIP_REOPT* reopt, /**< reoptimization data structure */
1642 SCIP_LP* lp, /**< current LP data */
1643 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1644 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1645 SCIP_HEUR* heur, /**< heuristic that found the solution (or NULL if it's from the tree) */
1646 SCIP_Bool printreason, /**< Should all reasons of violations be printed? */
1647 SCIP_Bool completely, /**< Should all violations be checked? */
1648 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
1649 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
1650 SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
1651 )
1652{
1653 assert(primal != NULL);
1654
1655 /* link temporary solution to current solution */
1656 SCIP_CALL( primalLinkCurrentSol(primal, blkmem, set, stat, transprob, tree, lp, heur) );
1657
1658 /* add solution to solution storage */
1659 SCIP_CALL( SCIPprimalTrySol(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1660 tree, reopt, lp, eventqueue, eventfilter, primal->currentsol,
1661 printreason, completely, FALSE, checkintegrality, checklprows, stored) );
1662
1663 return SCIP_OKAY;
1664}
1665
1666/** inserts solution into the global array of all existing primal solutions */
1668 SCIP_PRIMAL* primal, /**< primal data */
1669 SCIP_SET* set, /**< global SCIP settings */
1670 SCIP_SOL* sol /**< primal CIP solution */
1671 )
1672{
1673 assert(primal != NULL);
1674 assert(sol != NULL);
1675 assert(SCIPsolGetPrimalIndex(sol) == -1);
1676
1677 /* allocate memory for solution storage */
1678 SCIP_CALL( ensureExistingsolsSize(primal, set, primal->nexistingsols+1) );
1679
1680 /* append solution */
1682 primal->existingsols[primal->nexistingsols] = sol;
1683 primal->nexistingsols++;
1684
1685 return SCIP_OKAY;
1686}
1687
1688/** removes solution from the global array of all existing primal solutions */
1690 SCIP_PRIMAL* primal, /**< primal data */
1691 SCIP_SOL* sol /**< primal CIP solution */
1692 )
1693{
1694 int idx;
1695
1696 assert(primal != NULL);
1697 assert(sol != NULL);
1698
1699#ifndef NDEBUG
1700 for( idx = 0; idx < primal->nexistingsols; ++idx )
1701 {
1702 assert(idx == SCIPsolGetPrimalIndex(primal->existingsols[idx]));
1703 }
1704#endif
1705
1706 /* remove solution */
1707 idx = SCIPsolGetPrimalIndex(sol);
1708 assert(0 <= idx && idx < primal->nexistingsols);
1709 assert(sol == primal->existingsols[idx]);
1710 if( idx < primal->nexistingsols-1 )
1711 {
1712 primal->existingsols[idx] = primal->existingsols[primal->nexistingsols-1];
1713 SCIPsolSetPrimalIndex(primal->existingsols[idx], idx);
1714 }
1715 primal->nexistingsols--;
1716}
1717
1718/** updates all existing primal solutions after a change in a variable's objective value */
1720 SCIP_PRIMAL* primal, /**< primal data */
1721 SCIP_VAR* var, /**< problem variable */
1722 SCIP_Real oldobj, /**< old objective value */
1723 SCIP_Real newobj /**< new objective value */
1724 )
1725{
1726 int i;
1727
1728 assert(primal != NULL);
1729
1730 for( i = 0; i < primal->nexistingsols; ++i )
1731 {
1732 if( !SCIPsolIsOriginal(primal->existingsols[i]) )
1733 SCIPsolUpdateVarObj(primal->existingsols[i], var, oldobj, newobj);
1734 }
1735}
1736
1737/** retransforms all existing solutions to original problem space
1738 *
1739 * @note as a side effect, the objective value of the solutions can change (numerical errors)
1740 * so we update the objective cutoff value and upper bound accordingly
1741 */
1743 SCIP_PRIMAL* primal, /**< primal data */
1744 BMS_BLKMEM* blkmem, /**< block memory */
1745 SCIP_SET* set, /**< global SCIP settings */
1746 SCIP_STAT* stat, /**< problem statistics data */
1747 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1748 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1749 SCIP_PROB* origprob, /**< original problem */
1750 SCIP_PROB* transprob, /**< transformed problem */
1751 SCIP_TREE* tree, /**< branch and bound tree */
1752 SCIP_REOPT* reopt, /**< reoptimization data structure */
1753 SCIP_LP* lp /**< current LP data */
1754 )
1755{
1756 SCIP_Bool hasinfval;
1757 int i;
1758
1759 assert(primal != NULL);
1760
1761 for( i = 0; i < primal->nsols; ++i )
1762 {
1763 if( SCIPsolGetOrigin(primal->sols[i]) == SCIP_SOLORIGIN_ZERO )
1764 {
1765 SCIP_CALL( SCIPsolRetransform(primal->sols[i], set, stat, origprob, transprob, &hasinfval) );
1766 }
1767 }
1768
1769 sortPrimalSols(primal, set, origprob, transprob);
1770
1771 /* check if the global upper bound has to be updated
1772 * @todo we do not inform anybody about this change; if this leads to some
1773 * problem, a possible solution is to issue a BESTSOLFOUND event
1774 */
1775 if( primal->nsols > 0 )
1776 {
1777 SCIP_Real obj;
1778
1779 obj = SCIPsolGetObj(primal->sols[0], set, transprob, origprob);
1780 if( obj < primal->cutoffbound )
1781 {
1782 /* update the upper bound */
1783 SCIP_CALL( SCIPprimalSetUpperbound(primal, blkmem, set, stat, eventfilter, eventqueue, transprob, tree, reopt, lp, obj) );
1784 }
1785 }
1786
1787 return SCIP_OKAY;
1788}
1789
1790/** tries to transform original solution to the transformed problem space */
1792 SCIP_PRIMAL* primal, /**< primal data */
1793 SCIP_SOL* sol, /**< primal solution */
1794 BMS_BLKMEM* blkmem, /**< block memory */
1795 SCIP_SET* set, /**< global SCIP settings */
1796 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1797 SCIP_STAT* stat, /**< problem statistics data */
1798 SCIP_PROB* origprob, /**< original problem */
1799 SCIP_PROB* transprob, /**< transformed problem after presolve */
1800 SCIP_TREE* tree, /**< branch and bound tree */
1801 SCIP_REOPT* reopt, /**< reoptimization data structure */
1802 SCIP_LP* lp, /**< current LP data */
1803 SCIP_EVENTQUEUE* eventqueue, /**< event queue */
1804 SCIP_EVENTFILTER* eventfilter, /**< event filter for global (not variable dependent) events */
1805 SCIP_Real* solvals, /**< array for internal use to store solution values, or NULL;
1806 * if the method is called multiple times in a row, an array with size >=
1807 * number of active variables should be given for performance reasons */
1808 SCIP_Bool* solvalset, /**< array for internal use to store which solution values were set, or NULL;
1809 * if the method is called multiple times in a row, an array with size >=
1810 * number of active variables should be given for performance reasons */
1811 int solvalssize, /**< size of solvals and solvalset arrays, should be >= number of active
1812 * variables */
1813 SCIP_Bool* added /**< pointer to store whether the solution was added */
1814 )
1815{
1816 SCIP_VAR** origvars;
1817 SCIP_VAR** transvars;
1818 SCIP_VAR* var;
1819 SCIP_Real* localsolvals;
1820 SCIP_Bool* localsolvalset;
1821 SCIP_Real solval;
1822 SCIP_Real scalar;
1823 SCIP_Real constant;
1824 SCIP_Bool localarrays;
1825 SCIP_Bool feasible;
1826 int norigvars;
1827 int ntransvars;
1828 int nvarsset;
1829 int v;
1830
1831 assert(origprob != NULL);
1832 assert(transprob != NULL);
1833 assert(SCIPsolIsOriginal(sol));
1834 assert(solvalssize == 0 || solvals != NULL);
1835 assert(solvalssize == 0 || solvalset != NULL);
1836
1837 origvars = SCIPprobGetVars(origprob);
1838 norigvars = SCIPprobGetNVars(origprob);
1839 transvars = SCIPprobGetVars(transprob);
1840 ntransvars = SCIPprobGetNVars(transprob);
1841 assert(solvalssize == 0 || solvalssize >= ntransvars);
1842
1843 SCIPsetDebugMsg(set, "try to transfer original solution %p with objective %g into the transformed problem space\n",
1844 (void*)sol, SCIPsolGetOrigObj(sol));
1845
1846 /* if no solvals and solvalset arrays are given, allocate local ones, otherwise use the given ones */
1847 localarrays = (solvalssize == 0);
1848 if( localarrays )
1849 {
1850 SCIP_CALL( SCIPsetAllocBufferArray(set, &localsolvals, ntransvars) );
1851 SCIP_CALL( SCIPsetAllocBufferArray(set, &localsolvalset, ntransvars) );
1852 }
1853 else
1854 {
1855 localsolvals = solvals;
1856 localsolvalset = solvalset;
1857 }
1858
1859 BMSclearMemoryArray(localsolvalset, ntransvars);
1860 feasible = TRUE;
1861 (*added) = FALSE;
1862 nvarsset = 0;
1863
1864 /* for each original variable, get the corresponding active, fixed or multi-aggregated variable;
1865 * if it resolves to an active variable, we set its solution value or check whether an already stored solution value
1866 * is consistent; if it resolves to a fixed variable, we check that the fixing matches the original solution value;
1867 * multi-aggregated variables are skipped, because their value is defined by setting solution values for the active
1868 * variables, anyway
1869 */
1870 for( v = 0; v < norigvars && feasible; ++v )
1871 {
1872 var = origvars[v];
1873
1874 solval = SCIPsolGetVal(sol, set, stat, var);
1875
1876 /* get corresponding active, fixed, or multi-aggregated variable */
1877 scalar = 1.0;
1878 constant = 0.0;
1879 SCIP_CALL( SCIPvarGetProbvarSum(&var, set, &scalar, &constant) );
1882
1883 /* check whether the fixing corresponds to the solution value of the original variable */
1884 if( scalar == 0.0 )
1885 {
1886 assert(SCIPvarGetStatus(var) == SCIP_VARSTATUS_FIXED ||
1887 (SCIPsetIsInfinity(set, constant) || SCIPsetIsInfinity(set, -constant)));
1888
1889 if( !SCIPsetIsEQ(set, solval, constant) )
1890 {
1891 SCIPsetDebugMsg(set, "original variable <%s> (solval=%g) resolves to fixed variable <%s> (original solval=%g)\n",
1892 SCIPvarGetName(origvars[v]), solval, SCIPvarGetName(var), constant);
1893 feasible = FALSE;
1894 }
1895 }
1896 else if( SCIPvarIsActive(var) )
1897 {
1898 /* if we already assigned a solution value to the transformed variable, check that it corresponds to the
1899 * value obtained from the currently regarded original variable
1900 */
1901 if( localsolvalset[SCIPvarGetProbindex(var)] )
1902 {
1903 if( !SCIPsetIsEQ(set, solval, scalar * localsolvals[SCIPvarGetProbindex(var)] + constant) )
1904 {
1905 SCIPsetDebugMsg(set, "original variable <%s> (solval=%g) resolves to active variable <%s> with assigned solval %g (original solval=%g)\n",
1906 SCIPvarGetName(origvars[v]), solval, SCIPvarGetName(var), localsolvals[SCIPvarGetProbindex(var)],
1907 scalar * localsolvals[SCIPvarGetProbindex(var)] + constant);
1908 feasible = FALSE;
1909 }
1910 }
1911 /* assign solution value to the transformed variable */
1912 else
1913 {
1914 assert(scalar != 0.0);
1915
1916 localsolvals[SCIPvarGetProbindex(var)] = (solval - constant) / scalar;
1917 localsolvalset[SCIPvarGetProbindex(var)] = TRUE;
1918 ++nvarsset;
1919 }
1920 }
1921#ifndef NDEBUG
1922 /* we do not have to handle multi-aggregated variables here, since by assigning values to all active variabes,
1923 * we implicitly assign values to the multi-aggregated variables, too
1924 */
1925 else
1927#endif
1928 }
1929
1930 /* if the solution values of fixed and active variables lead to no contradiction, construct solution and try it */
1931 if( feasible )
1932 {
1933 SCIP_SOL* transsol;
1934
1935 SCIP_CALL( SCIPsolCreate(&transsol, blkmem, set, stat, primal, tree, SCIPsolGetHeur(sol)) );
1936
1937 /* set solution values for variables to which we assigned a value */
1938 for( v = 0; v < ntransvars; ++v )
1939 {
1940 if( localsolvalset[v] )
1941 {
1942 SCIP_CALL( SCIPsolSetVal(transsol, set, stat, tree, transvars[v], localsolvals[v]) );
1943 }
1944 }
1945
1946 SCIP_CALL( SCIPprimalTrySolFree(primal, blkmem, set, messagehdlr, stat, origprob, transprob,
1947 tree, reopt, lp, eventqueue, eventfilter, &transsol, FALSE, FALSE, TRUE, TRUE, TRUE, added) );
1948
1949 SCIPsetDebugMsg(set, "solution transferred, %d/%d active variables set (stored=%u)\n", nvarsset, ntransvars, *added);
1950 }
1951 else
1952 (*added) = FALSE;
1953
1954 /* free local arrays, if needed */
1955 if( localarrays )
1956 {
1957 SCIPsetFreeBufferArray(set, &localsolvalset);
1958 SCIPsetFreeBufferArray(set, &localsolvals);
1959 }
1960
1961 return SCIP_OKAY;
1962}
1963
1964
1965/** is the updating of violations enabled for this problem? */
1967 SCIP_PRIMAL* primal /**< problem data */
1968 )
1969{
1970 assert(primal != NULL);
1971
1972 return primal->updateviolations;
1973}
1974
1975/** set whether the updating of violations is turned on */
1977 SCIP_PRIMAL* primal, /**< problem data */
1978 SCIP_Bool updateviolations /**< marks whether the updating of violations is turned on */
1979 )
1980{
1981 assert(primal != NULL);
1982
1983 primal->updateviolations = updateviolations;
1984}
common defines and data types used in all packages of SCIP
#define NULL
Definition: def.h:266
#define SCIP_INVALID
Definition: def.h:192
#define SCIP_Bool
Definition: def.h:91
#define MIN(x, y)
Definition: def.h:242
#define SCIP_ALLOC(x)
Definition: def.h:384
#define SCIP_Real
Definition: def.h:172
#define TRUE
Definition: def.h:93
#define FALSE
Definition: def.h:94
#define SCIP_LONGINT_FORMAT
Definition: def.h:164
#define SCIPABORT()
Definition: def.h:345
#define REALABS(x)
Definition: def.h:196
#define SCIP_CALL(x)
Definition: def.h:373
SCIP_RETCODE SCIPdispPrintLine(SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, FILE *file, SCIP_Bool forcedisplay, SCIP_Bool endline)
Definition: disp.c:415
internal methods for displaying runtime statistics
SCIP_RETCODE SCIPeventChgSol(SCIP_EVENT *event, SCIP_SOL *sol)
Definition: event.c:1354
SCIP_RETCODE SCIPeventProcess(SCIP_EVENT *event, SCIP_SET *set, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter)
Definition: event.c:1574
SCIP_RETCODE SCIPeventChgType(SCIP_EVENT *event, SCIP_EVENTTYPE eventtype)
Definition: event.c:1040
internal methods for managing events
SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
Definition: sol.c:2711
SCIP_Real SCIPsolGetOrigObj(SCIP_SOL *sol)
Definition: sol.c:2741
SCIP_Real SCIPsolGetTime(SCIP_SOL *sol)
Definition: sol.c:2764
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:2784
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
Definition: sol.c:2804
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:2721
int SCIPsolGetDepth(SCIP_SOL *sol)
Definition: sol.c:2794
SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
Definition: sol.c:2731
int SCIPsolGetRunnum(SCIP_SOL *sol)
Definition: sol.c:2774
void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
Definition: sol.c:2849
SCIP_Real SCIPgetLowerbound(SCIP *scip)
SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)
Definition: var.c:17768
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:17558
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:17788
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:17439
SCIP_RETCODE SCIPlpSetCutoffbound(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob, SCIP_Real cutoffbound)
Definition: lp.c:10199
internal methods for LP management
#define BMSfreeMemory(ptr)
Definition: memory.h:145
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:127
#define BMSclearMemoryArray(ptr, num)
Definition: memory.h:130
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:437
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:148
#define BMSallocMemory(ptr)
Definition: memory.h:118
void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:427
SCIP_RETCODE SCIPprimalAddCurrentSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_HEUR *heur, SCIP_Bool *stored)
Definition: primal.c:1458
void SCIPprimalSetUpdateViolations(SCIP_PRIMAL *primal, SCIP_Bool updateviolations)
Definition: primal.c:1976
SCIP_RETCODE SCIPprimalUpdateRay(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_STAT *stat, SCIP_SOL *primalray, BMS_BLKMEM *blkmem)
Definition: primal.c:584
void SCIPprimalSolFreed(SCIP_PRIMAL *primal, SCIP_SOL *sol)
Definition: primal.c:1689
static SCIP_RETCODE primalAddSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL **solptr, int insertpos, SCIP_Bool replace)
Definition: primal.c:613
static SCIP_Bool origsolOfInterest(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_SOL *sol, int *insertpos)
Definition: primal.c:1175
SCIP_RETCODE SCIPprimalSetUpperbound(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_Real upperbound)
Definition: primal.c:399
static int primalSearchSolPos(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SOL *sol)
Definition: primal.c:918
SCIP_RETCODE SCIPprimalAddOrigSolFree(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_SOL **sol, SCIP_Bool *stored)
Definition: primal.c:1374
SCIP_RETCODE SCIPprimalTryCurrentSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_HEUR *heur, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: primal.c:1632
static SCIP_RETCODE ensureExistingsolsSize(SCIP_PRIMAL *primal, SCIP_SET *set, int num)
Definition: primal.c:108
void SCIPprimalAddOrigObjoffset(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_Real addval)
Definition: primal.c:527
SCIP_RETCODE SCIPprimalFree(SCIP_PRIMAL **primal, BMS_BLKMEM *blkmem)
Definition: primal.c:160
static SCIP_Bool primalExistsOrigSol(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_SOL *sol, int insertpos)
Definition: primal.c:1085
static SCIP_RETCODE primalAddOrigSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PROB *prob, SCIP_SOL *sol, int insertpos)
Definition: primal.c:835
SCIP_SOL * SCIPprimalGetRay(SCIP_PRIMAL *primal)
Definition: primal.c:574
SCIP_RETCODE SCIPprimalTrySolFree(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: primal.c:1558
SCIP_Bool SCIPprimalUpdateViolations(SCIP_PRIMAL *primal)
Definition: primal.c:1966
SCIP_Bool SCIPprimalUpperboundIsSol(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition: primal.c:561
static SCIP_RETCODE ensureSolsSize(SCIP_PRIMAL *primal, SCIP_SET *set, int num)
Definition: primal.c:60
static void sortPrimalSols(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_PROB *origprob, SCIP_PROB *transprob)
Definition: primal.c:230
SCIP_RETCODE SCIPprimalAddOrigSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_SOL *sol, SCIP_Bool *stored)
Definition: primal.c:1319
static SCIP_RETCODE primalSetCutoffbound(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_Real cutoffbound)
Definition: primal.c:257
void SCIPprimalUpdateVarObj(SCIP_PRIMAL *primal, SCIP_VAR *var, SCIP_Real oldobj, SCIP_Real newobj)
Definition: primal.c:1719
SCIP_RETCODE SCIPprimalCreate(SCIP_PRIMAL **primal)
Definition: primal.c:130
SCIP_RETCODE SCIPprimalUpdateObjoffset(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp)
Definition: primal.c:471
static SCIP_RETCODE primalLinkCurrentSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp, SCIP_HEUR *heur)
Definition: primal.c:1431
SCIP_RETCODE SCIPprimalTrySol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: primal.c:1488
SCIP_RETCODE SCIPprimalTransformSol(SCIP_PRIMAL *primal, SCIP_SOL *sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_Real *solvals, SCIP_Bool *solvalset, int solvalssize, SCIP_Bool *added)
Definition: primal.c:1791
SCIP_RETCODE SCIPprimalUpdateObjlimit(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp)
Definition: primal.c:431
SCIP_RETCODE SCIPprimalAddSolFree(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL **sol, SCIP_Bool *stored)
Definition: primal.c:1264
static SCIP_RETCODE primalSetUpperbound(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_Real upperbound)
Definition: primal.c:344
SCIP_RETCODE SCIPprimalAddSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL *sol, SCIP_Bool *stored)
Definition: primal.c:1196
static int primalSearchOrigSolPos(SCIP_PRIMAL *primal, SCIP_SOL *sol)
Definition: primal.c:968
SCIP_RETCODE SCIPprimalSetCutoffbound(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_Real cutoffbound, SCIP_Bool useforobjlimit)
Definition: primal.c:290
static SCIP_Bool solOfInterest(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_SOL *sol, int *insertpos, SCIP_Bool *replace)
Definition: primal.c:1137
SCIP_RETCODE SCIPprimalSolCreated(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_SOL *sol)
Definition: primal.c:1667
SCIP_RETCODE SCIPprimalRetransformSolutions(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp)
Definition: primal.c:1742
SCIP_RETCODE SCIPprimalClear(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem)
Definition: primal.c:179
static SCIP_Bool primalExistsSol(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_SOL *sol, int *insertpos, SCIP_Bool *replace)
Definition: primal.c:1003
static SCIP_RETCODE ensurePartialsolsSize(SCIP_PRIMAL *primal, SCIP_SET *set, int num)
Definition: primal.c:83
static SCIP_RETCODE primalAddOrigPartialSol(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_PROB *prob, SCIP_SOL *sol)
Definition: primal.c:887
internal methods for collecting primal CIP solutions and primal informations
SCIP_Real SCIPprobGetObjlim(SCIP_PROB *prob, SCIP_SET *set)
Definition: prob.c:2370
SCIP_OBJSENSE SCIPprobGetObjsense(SCIP_PROB *prob)
Definition: prob.c:2518
void SCIPprobSetObjlim(SCIP_PROB *prob, SCIP_Real objlim)
Definition: prob.c:1505
SCIP_Bool SCIPprobIsObjIntegral(SCIP_PROB *prob)
Definition: prob.c:2346
int SCIPprobGetNVars(SCIP_PROB *prob)
Definition: prob.c:2401
SCIP_Real SCIPprobExternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2157
SCIP_VAR ** SCIPprobGetVars(SCIP_PROB *prob)
Definition: prob.c:2446
SCIP_Real SCIPprobInternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2179
internal methods for storing and manipulating the main problem
public methods for message output
#define SCIPerrorMessage
Definition: pub_message.h:64
#define SCIPdebug(x)
Definition: pub_message.h:93
public methods for problem variables
data structures and methods for collecting reoptimization information
public methods for querying solving statistics
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6293
SCIP_Real SCIPsetFeasCeil(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6775
SCIP_Bool SCIPsetIsFeasGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6663
SCIP_Bool SCIPsetIsFeasLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6641
SCIP_Bool SCIPsetIsLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6257
SCIP_Real SCIPsetEpsilon(SCIP_SET *set)
Definition: set.c:6086
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6221
SCIP_STAGE SCIPsetGetStage(SCIP_SET *set)
Definition: set.c:2952
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:6064
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6239
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6199
SCIP_Bool SCIPsetIsGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6275
SCIP_Real SCIPsetCutoffbounddelta(SCIP_SET *set)
Definition: set.c:6164
SCIP_Bool SCIPsetIsFeasGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6685
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:5764
internal methods for global SCIP settings
#define SCIPsetFreeBufferArray(set, ptr)
Definition: set.h:1755
#define SCIPsetAllocBufferArray(set, ptr, num)
Definition: set.h:1748
#define SCIPsetDebugMsg
Definition: set.h:1784
void SCIPsolUpdateVarObj(SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real oldobj, SCIP_Real newobj)
Definition: sol.c:1588
void SCIPsolSetPrimalIndex(SCIP_SOL *sol, int primalindex)
Definition: sol.c:2824
int SCIPsolGetPrimalIndex(SCIP_SOL *sol)
Definition: sol.c:2814
SCIP_RETCODE SCIPsolLinkCurrentSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:988
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:1838
SCIP_RETCODE SCIPsolFree(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_PRIMAL *primal)
Definition: sol.c:801
SCIP_RETCODE SCIPsolRetransform(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_Bool *hasinfval)
Definition: sol.c:2059
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:703
SCIP_RETCODE SCIPsolTransform(SCIP_SOL *sol, SCIP_SOL **transsol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PRIMAL *primal)
Definition: sol.c:426
SCIP_RETCODE SCIPsolSetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real val)
Definition: sol.c:1077
SCIP_Real SCIPsolGetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition: sol.c:1372
SCIP_RETCODE SCIPsolUnlink(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *prob)
Definition: sol.c:1048
SCIP_Bool SCIPsolsAreEqual(SCIP_SOL *sol1, SCIP_SOL *sol2, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob)
Definition: sol.c:2221
SCIP_Real SCIPsolGetObj(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition: sol.c:1571
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:2286
void SCIPsolUpdateVarsum(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_Real weight)
Definition: sol.c:2031
SCIP_RETCODE SCIPsolCopy(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_SOL *sourcesol)
Definition: sol.c:362
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:288
void SCIPsolOrigAddObjval(SCIP_SOL *sol, SCIP_Real addval)
Definition: sol.c:2752
internal methods for storing primal CIP solutions
internal methods for problem statistics
SCIP_SOL * currentsol
Definition: struct_primal.h:60
int partialsolssize
Definition: struct_primal.h:64
int existingsolssize
Definition: struct_primal.h:67
SCIP_SOL ** partialsols
Definition: struct_primal.h:58
SCIP_SOL ** sols
Definition: struct_primal.h:57
SCIP_Longint nlimbestsolsfound
Definition: struct_primal.h:52
SCIP_Longint nbestsolsfound
Definition: struct_primal.h:51
SCIP_Bool updateviolations
Definition: struct_primal.h:70
SCIP_SOL * primalray
Definition: struct_primal.h:61
SCIP_Longint nsolsfound
Definition: struct_primal.h:48
SCIP_Longint nlimsolsfound
Definition: struct_primal.h:49
SCIP_Real cutoffbound
Definition: struct_primal.h:55
SCIP_SOL ** existingsols
Definition: struct_primal.h:59
SCIP_Real upperbound
Definition: struct_primal.h:54
SCIP_Longint nnodes
Definition: struct_stat.h:82
int firstprimaldepth
Definition: struct_stat.h:272
SCIP_VISUAL * visual
Definition: struct_stat.h:184
SCIP_Real firstprimaltime
Definition: struct_stat.h:134
int nrunsbeforefirst
Definition: struct_stat.h:271
SCIP_HEUR * firstprimalheur
Definition: struct_stat.h:185
SCIP_Longint nnodesbeforefirst
Definition: struct_stat.h:122
SCIP_Longint bestsolnode
Definition: struct_stat.h:113
SCIP_Real firstprimalbound
Definition: struct_stat.h:133
datastructures for managing events
Definition: heur_padm.c:135
SCIP_NODE * SCIPtreeGetCurrentNode(SCIP_TREE *tree)
Definition: tree.c:8490
int SCIPtreeGetCurrentDepth(SCIP_TREE *tree)
Definition: tree.c:8507
SCIP_RETCODE SCIPtreeCutoff(SCIP_TREE *tree, SCIP_REOPT *reopt, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTFILTER *eventfilter, SCIP_EVENTQUEUE *eventqueue, SCIP_LP *lp, SCIP_Real cutoffbound)
Definition: tree.c:5227
SCIP_Bool SCIPtreeInRepropagation(SCIP_TREE *tree)
Definition: tree.c:8480
internal methods for branch and bound tree
#define SCIP_EVENTTYPE_POORSOLFOUND
Definition: type_event.h:104
#define SCIP_EVENTTYPE_BESTSOLFOUND
Definition: type_event.h:105
@ SCIP_OBJSENSE_MINIMIZE
Definition: type_prob.h:48
@ SCIP_INVALIDDATA
Definition: type_retcode.h:52
@ SCIP_OKAY
Definition: type_retcode.h:42
@ SCIP_INVALIDCALL
Definition: type_retcode.h:51
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
@ SCIP_STAGE_PROBLEM
Definition: type_set.h:45
@ SCIP_STAGE_SOLVING
Definition: type_set.h:53
@ SCIP_STAGE_PRESOLVED
Definition: type_set.h:51
@ SCIP_SOLORIGIN_ZERO
Definition: type_sol.h:43
@ SCIP_SOLORIGIN_ORIGINAL
Definition: type_sol.h:42
@ SCIP_VARSTATUS_FIXED
Definition: type_var.h:52
@ SCIP_VARSTATUS_MULTAGGR
Definition: type_var.h:54
SCIP_RETCODE SCIPvarGetProbvarSum(SCIP_VAR **var, SCIP_SET *set, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12667
internal methods for problem variables
void SCIPvisualUpperbound(SCIP_VISUAL *visual, SCIP_SET *set, SCIP_STAT *stat, SCIP_Real upperbound)
Definition: visual.c:805
void SCIPvisualFoundSolution(SCIP_VISUAL *visual, SCIP_SET *set, SCIP_STAT *stat, SCIP_NODE *node, SCIP_Bool bettersol, SCIP_SOL *sol)
Definition: visual.c:669
methods for creating output for visualization tools (VBC, BAK)