Skip to content

Commit 453c92f

Browse files
committed
only sets value of masterauxvar if it exists
1 parent 64aa9bc commit 453c92f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/scip/cons_benders.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,15 @@ SCIP_RETCODE constructValidSolution(
145145
/* looping through all Benders' decompositions to construct the new solution */
146146
for( i = 0; i < nactivebenders; i++ )
147147
{
148+
SCIP_VAR* masterauxvar;
148149
SCIP_BENDERSOBJTYPE objtype;
149150
SCIP_Real masterauxvarval = 0.0;
150151

151152
/* getting the objective type for the subproblems */
152153
objtype = SCIPbendersGetObjectiveType(benders[i]);
153154

154155
/* getting the auxiliary variables and the number of subproblems from the Benders' decomposition structure */
156+
masterauxvar = SCIPbenderGetMasterAuxiliaryVar(benders[i]);
155157
auxiliaryvars = SCIPbendersGetAuxiliaryVars(benders[i]);
156158
nsubproblems = SCIPbendersGetNSubproblems(benders[i]);
157159

@@ -184,8 +186,13 @@ SCIP_RETCODE constructValidSolution(
184186
}
185187
}
186188

187-
/* setting the value of the master auxiliary variable */
188-
SCIP_CALL( SCIPsetSolVal(scip, newsol, SCIPbenderGetMasterAuxiliaryVar(benders[i]), masterauxvarval) );
189+
/* setting the value of the master auxiliary variable. It is possible that the master auxiliary variable is
190+
* removed during presolve. As such, it could be NULL in sub-SCIPs or inactive in the original SCIP.
191+
*/
192+
if( masterauxvar != NULL && SCIPvarIsActive(masterauxvar) )
193+
{
194+
SCIP_CALL( SCIPsetSolVal(scip, newsol, SCIPbenderGetMasterAuxiliaryVar(benders[i]), masterauxvarval) );
195+
}
189196

190197
if( !success )
191198
break;

0 commit comments

Comments
 (0)