Skip to content

Commit 908a4df

Browse files
committed
compute and set value for objvar when having initsol in nl-reader
- fixes #92
1 parent a655215 commit 908a4df

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Fixed bugs
1010
- check knapsack constraints as linear constraints to avoid violations based on implicit integrality
1111
- make sure that symmetry detection callbacks report success
1212
- make arithmetics in cuts.c more robust to avoid invalid scg cuts due to numerical rounding sensitivity
13+
- set value for variable that is introduced to reformulate nonlinear objective function when reading .nl files with initial solution
1314

1415
Miscellaneous
1516
-------------

src/scip/reader_nl.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,20 @@ class AMPLProblemHandler : public mp::NLHandler<AMPLProblemHandler, SCIP_EXPR*>
15731573
SCIP_CALL_THROW( SCIPaddLinearVarNonlinear(scip, objcons, objvar, -1.0) );
15741574
SCIP_CALL_THROW( SCIPaddCons(scip, objcons) );
15751575

1576+
if( initsol != NULL )
1577+
{
1578+
/* compute value for objvar in initial solution from other variable values */
1579+
SCIP_CALL_THROW( SCIPevalExpr(scip, objexpr, initsol, 0) );
1580+
if( SCIPexprGetEvalValue(objexpr) != SCIP_INVALID )
1581+
{
1582+
SCIPsetSolVal(scip, initsol, objvar, SCIPexprGetEvalValue(objexpr));
1583+
}
1584+
else
1585+
{
1586+
SCIPwarningMessage(scip, "Objective function could not be evaluated in initial point. Domain error.");
1587+
}
1588+
}
1589+
15761590
SCIP_CALL_THROW( SCIPreleaseCons(scip, &objcons) );
15771591
SCIP_CALL_THROW( SCIPreleaseVar(scip, &objvar) );
15781592
}

0 commit comments

Comments
 (0)