Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#SCIPdebugMessage(" -> found gomory cut <%s>: act=%f, rhs=%f, norm=%f, eff=%f, min=%f, max=%f (range=%f)\n",
# cutname, SCIPgetRowLPActivity(scip, cut), SCIProwGetRhs(cut), SCIProwGetNorm(cut),
# SCIPgetCutEfficacy(scip, NULL, cut),
# SCIPgetRowMinCoef(scip, cut), SCIPgetRowMaxCoef(scip, cut),
# SCIPgetRowMaxCoef(scip, cut)/SCIPgetRowMinCoef(scip, cut))
# flush all changes before adding the cut
scip.flushRowExtensions(cut)
infeasible = scip.addCut(cut, forcecut=True)
self.ncuts += 1
if infeasible:
result = SCIP_RESULT.CUTOFF
else:
result = SCIP_RESULT.SEPARATED
scip.releaseRow(cut)
return {"result": result}
'node_depth': self.model.getCurrentNode().getDepth(),
'filename': filename,
})
self.sample_counter += 1
# if exploration and expert policies are the same, prevent running it twice
if not query_expert or (not self.follow_expert and self.exploration_policy != 'vanillafullstrong'):
result = self.model.executeBranchRule(self.exploration_policy, allowaddcons)
# apply 'vanillafullstrong' branching decision if needed
if query_expert and self.follow_expert or self.exploration_policy == 'vanillafullstrong':
assert result == scip.SCIP_RESULT.DIDNOTRUN
cands, scores, npriocands, bestcand = self.model.getVanillafullstrongData()
self.model.branchVar(cands[bestcand])
result = scip.SCIP_RESULT.BRANCHED
return {"result": result}
def conscheck(self, constraints, solution, checkintegrality, checklprows, printreason):
if self.addCuts(checkonly = True):
return {"result": SCIP_RESULT.INFEASIBLE}
else:
return {"result": SCIP_RESULT.FEASIBLE}