Skip to content

Commit 86b2ef7

Browse files
committed
Merge remote-tracking branch 'origin/v10-minor'
2 parents 8da10cd + c14e538 commit 86b2ef7

File tree

5 files changed

+42
-27
lines changed

5 files changed

+42
-27
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ Fixed bugs
7171
- avoid crash when initial IIS solve fails while reporting errors explicitly
7272
- fixed failure in nl writing on big endian machines
7373
- correct memory reallocation in storeSubproblemMasterVar() of benders.c to avoid freeing errors
74+
- also set real solution in SCIPsolSetValExact() to maintain approximation
75+
- handle exact solutions in SCIPsolCheckOrig(), SCIPcheckSolOrig(), and SCIPrecomputeSolObj() to correctly check exact initial solutions in SCIPtransformProb()
7476

7577
Miscellaneous
7678
-------------

src/scip/scip_sol.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,6 +2069,7 @@ void SCIPgetSolTransObjExact(
20692069
* SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
20702070
*
20712071
* @pre This method can be called if SCIP is in one of the following stages:
2072+
* - \ref SCIP_STAGE_TRANSFORMED
20722073
* - \ref SCIP_STAGE_PRESOLVING
20732074
* - \ref SCIP_STAGE_SOLVING
20742075
*
@@ -2082,9 +2083,12 @@ SCIP_RETCODE SCIPrecomputeSolObj(
20822083
assert(sol != NULL);
20832084
assert(sol->scip == scip);
20842085

2085-
SCIP_CALL( SCIPcheckStage(scip, "SCIPrecomputeSolObj", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2086+
SCIP_CALL( SCIPcheckStage(scip, "SCIPrecomputeSolObj", FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
20862087

2087-
SCIPsolRecomputeObj(sol, scip->set, scip->stat, scip->origprob);
2088+
if( SCIPsolIsExact(sol) )
2089+
SCIPsolRecomputeInternObjExact(sol, scip->set, scip->stat, scip->origprob);
2090+
else
2091+
SCIPsolRecomputeObj(sol, scip->set, scip->stat, scip->origprob);
20882092

20892093
return SCIP_OKAY;
20902094
}

src/scip/scip_sol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ void SCIPgetSolTransObjExact(
802802
* SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
803803
*
804804
* @pre This method can be called if SCIP is in one of the following stages:
805+
* - \ref SCIP_STAGE_TRANSFORMED
805806
* - \ref SCIP_STAGE_PRESOLVING
806807
* - \ref SCIP_STAGE_SOLVING
807808
*

src/scip/scip_solve.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ SCIP_RETCODE SCIPtransformProb(
322322
sol = scip->origprimal->sols[s];
323323

324324
/* recompute objective function, since the objective might have changed in the meantime */
325-
SCIPsolRecomputeObj(sol, scip->set, scip->stat, scip->origprob);
325+
SCIP_CALL( SCIPrecomputeSolObj(scip, sol) );
326326

327327
/* SCIPprimalTrySol() can only be called on transformed solutions; therefore check solutions in original problem
328328
* including modifiable constraints
@@ -333,27 +333,20 @@ SCIP_RETCODE SCIPtransformProb(
333333

334334
if( feasible )
335335
{
336-
SCIP_Real abssolobj;
336+
SCIP_SOL* bestsol = SCIPgetBestSol(scip);
337+
SCIP_Bool stored;
337338

338-
abssolobj = REALABS(SCIPsolGetObj(sol, scip->set, scip->transprob, scip->origprob));
339+
/* add primal solution to solution storage by copying it */
340+
SCIP_CALL( SCIPprimalAddSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
341+
scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue,
342+
scip->eventfilter, sol, &stored) );
339343

340-
/* we do not want to add solutions with objective value +infinity */
341-
if( !SCIPisInfinity(scip, abssolobj) )
344+
if( stored )
342345
{
343-
SCIP_SOL* bestsol = SCIPgetBestSol(scip);
344-
SCIP_Bool stored;
346+
nfeassols++;
345347

346-
/* add primal solution to solution storage by copying it */
347-
SCIP_CALL( SCIPprimalAddSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat, scip->origprob, scip->transprob,
348-
scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter, sol, &stored) );
349-
350-
if( stored )
351-
{
352-
nfeassols++;
353-
354-
if( bestsol != SCIPgetBestSol(scip) )
355-
SCIPstoreSolutionGap(scip);
356-
}
348+
if( bestsol != SCIPgetBestSol(scip) )
349+
SCIPstoreSolutionGap(scip);
357350
}
358351
}
359352

src/scip/sol.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,7 @@ SCIP_RETCODE SCIPsolSetValExact(
17551755
}
17561756

17571757
SCIPrationalFreeBuffer(set->buffer, &oldval);
1758-
return SCIP_OKAY;
1758+
break;
17591759
}
17601760
else
17611761
return SCIPsolSetValExact(sol, set, stat, tree, SCIPvarGetTransVar(var), val);
@@ -1777,7 +1777,7 @@ SCIP_RETCODE SCIPsolSetValExact(
17771777
}
17781778

17791779
SCIPrationalFreeBuffer(set->buffer, &oldval);
1780-
return SCIP_OKAY;
1780+
break;
17811781

17821782
case SCIP_VARSTATUS_FIXED:
17831783
assert(sol->solorigin != SCIP_SOLORIGIN_ORIGINAL);
@@ -1787,7 +1787,7 @@ SCIP_RETCODE SCIPsolSetValExact(
17871787
SCIPvarGetName(var), SCIPrationalGetReal(SCIPvarGetLbGlobalExact(var)), SCIPrationalGetReal(val));
17881788
return SCIP_INVALIDDATA;
17891789
}
1790-
return SCIP_OKAY;
1790+
break;
17911791

17921792
case SCIP_VARSTATUS_AGGREGATED: /* x = a*y + c => y = (x-c)/a */
17931793
assert(!SCIPrationalIsZero(SCIPvarGetAggrScalarExact(var)));
@@ -1819,13 +1819,17 @@ SCIP_RETCODE SCIPsolSetValExact(
18191819

18201820
case SCIP_VARSTATUS_NEGATED:
18211821
assert(!SCIPsetIsInfinity(set, SCIPvarGetNegationConstant(var)) && !SCIPsetIsInfinity(set, -SCIPvarGetNegationConstant(var)));
1822-
18231822
return SCIPsolSetValExact(sol, set, stat, tree, SCIPvarGetNegationVar(var), val);
18241823

18251824
default:
18261825
SCIPerrorMessage("unknown variable status\n");
18271826
return SCIP_INVALIDDATA;
18281827
}
1828+
1829+
/* set real approximation */
1830+
SCIP_CALL( SCIPsolSetVal(sol, set, stat, tree, var, SCIPrationalGetReal(val)) );
1831+
1832+
return SCIP_OKAY;
18291833
}
18301834

18311835
/** increases value of variable in primal CIP solution */
@@ -2390,7 +2394,6 @@ SCIP_RETCODE solCheckExact(
23902394
int h;
23912395

23922396
assert(sol != NULL);
2393-
assert(!SCIPsolIsOriginal(sol));
23942397
assert(set != NULL);
23952398
assert(prob != NULL);
23962399
assert(feasible != NULL);
@@ -2530,6 +2533,15 @@ SCIP_RETCODE SCIPsolCheckOrig(
25302533
assert(!prob->transformed);
25312534
assert(feasible != NULL);
25322535

2536+
/* have to check bounds without tolerances in exact solving mode */
2537+
if( set->exact_enable )
2538+
{
2539+
SCIP_CALL( solCheckExact(sol, set, messagehdlr, blkmem, stat, prob, printreason,
2540+
completely, checklprows, feasible) );
2541+
2542+
return SCIP_OKAY;
2543+
}
2544+
25332545
*feasible = TRUE;
25342546

25352547
SCIPsolResetViolations(sol);
@@ -2693,15 +2705,17 @@ SCIP_RETCODE SCIPsolCheck(
26932705
SCIPsetDebugMsg(set, "checking solution with objective value %g (nodenum=%" SCIP_LONGINT_FORMAT ", origin=%d)\n",
26942706
sol->obj, sol->nodenum, sol->solorigin);
26952707

2696-
*feasible = TRUE;
2697-
26982708
/* have to check bounds without tolerances in exact solving mode */
26992709
if( set->exact_enable )
27002710
{
27012711
SCIP_CALL( solCheckExact(sol, set, messagehdlr, blkmem, stat, prob, printreason,
27022712
completely, checklprows, feasible) );
2713+
2714+
return SCIP_OKAY;
27032715
}
27042716

2717+
*feasible = TRUE;
2718+
27052719
SCIPsolResetViolations(sol);
27062720

27072721
if( !printreason )
@@ -3232,6 +3246,7 @@ void SCIPsolRecomputeObj(
32323246

32333247
assert(sol != NULL);
32343248
assert(SCIPsolIsOriginal(sol));
3249+
assert(!SCIPsolIsExact(sol));
32353250
assert(origprob != NULL);
32363251

32373252
vars = origprob->vars;

0 commit comments

Comments
 (0)