@@ -58,6 +58,7 @@ Engine::Engine()
5858 , _lastIterationWithProgress( 0 )
5959 , _symbolicBoundTighteningType( Options::get()->getSymbolicBoundTighteningType() )
6060 , _solveWithMILP( Options::get()->getBool( Options::SOLVE_WITH_MILP ) )
61+ , _useKnapsackCuts( Options::get()->getBool( Options::KNAPSACK_CUTS ) )
6162 , _lpSolverType( Options::get()->getLPSolverType() )
6263 , _gurobi( nullptr )
6364 , _milpEncoder( nullptr )
@@ -200,6 +201,9 @@ bool Engine::solve( double timeoutInSeconds )
200201 // Before encoding, make sure all valid constraints are applied.
201202 applyAllValidConstraintCaseSplits ();
202203
204+ if ( _useKnapsackCuts )
205+ _knapsackCutManager.initialize ( _networkLevelReasoner, _plConstraints, &_boundManager );
206+
203207 if ( _solveWithMILP )
204208 return solveWithMILPEncoding ( timeoutInSeconds );
205209
@@ -243,6 +247,8 @@ bool Engine::solve( double timeoutInSeconds )
243247 _statistics.print ();
244248 }
245249
250+ if ( _useKnapsackCuts )
251+ _knapsackCutManager.printSummary ();
246252 _exitCode = Engine::TIMEOUT ;
247253 _statistics.timeout ();
248254 return false ;
@@ -257,6 +263,8 @@ bool Engine::solve( double timeoutInSeconds )
257263 _statistics.print ();
258264 }
259265
266+ if ( _useKnapsackCuts )
267+ _knapsackCutManager.printSummary ();
260268 _exitCode = Engine::QUIT_REQUESTED ;
261269 return false ;
262270 }
@@ -294,6 +302,9 @@ bool Engine::solve( double timeoutInSeconds )
294302 performBoundTighteningAfterCaseSplit ();
295303 informLPSolverOfBounds ();
296304 splitJustPerformed = false ;
305+
306+ if ( _useKnapsackCuts && _knapsackCutManager.checkPruning () )
307+ throw InfeasibleQueryException ();
297308 }
298309
299310 if ( _searchTreeHandler.needToSplit () )
@@ -342,6 +353,8 @@ bool Engine::solve( double timeoutInSeconds )
342353 ASSERT ( _UNSATCertificateCurrentPointer );
343354 ( **_UNSATCertificateCurrentPointer ).setSATSolutionFlag ();
344355 }
356+ if ( _useKnapsackCuts )
357+ _knapsackCutManager.printSummary ();
345358 _exitCode = Engine::SAT ;
346359 return true ;
347360 }
@@ -356,6 +369,8 @@ bool Engine::solve( double timeoutInSeconds )
356369 printf ( " \n Engine::solve: at leaf node but solving inconclusive\n " );
357370 _statistics.print ();
358371 }
372+ if ( _useKnapsackCuts )
373+ _knapsackCutManager.printSummary ();
359374 _exitCode = Engine::UNKNOWN ;
360375 return false ;
361376 }
@@ -407,6 +422,9 @@ bool Engine::solve( double timeoutInSeconds )
407422 if ( _produceUNSATProofs )
408423 explainSimplexFailure ();
409424
425+ if ( _useKnapsackCuts )
426+ _knapsackCutManager.collectFromCurrentLeaf ();
427+
410428 if ( !_searchTreeHandler.popSplit () )
411429 {
412430 mainLoopEnd = TimeUtils::sampleMicro ();
@@ -417,6 +435,8 @@ bool Engine::solve( double timeoutInSeconds )
417435 printf ( " \n Engine::solve: unsat query\n " );
418436 _statistics.print ();
419437 }
438+ if ( _useKnapsackCuts )
439+ _knapsackCutManager.printSummary ();
420440 _exitCode = Engine::UNSAT ;
421441 return false ;
422442 }
0 commit comments