MCPcopy Create free account
hub / github.com/NeuralNetworkVerification/Marabou / solveWithMILPEncoding

Method solveWithMILPEncoding

src/engine/Engine.cpp:2940–2997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2938}
2939
2940bool Engine::solveWithMILPEncoding( double timeoutInSeconds )
2941{
2942 try
2943 {
2944 if ( _lpSolverType == LPSolverType::NATIVE && _tableau->basisMatrixAvailable() )
2945 {
2946 explicitBasisBoundTightening();
2947 applyAllBoundTightenings();
2948 applyAllValidConstraintCaseSplits();
2949 }
2950
2951 while ( applyAllValidConstraintCaseSplits() )
2952 {
2953 performSymbolicBoundTightening();
2954 }
2955 }
2956 catch ( const InfeasibleQueryException & )
2957 {
2958 _exitCode = Engine::UNSAT;
2959 return false;
2960 }
2961
2962 ENGINE_LOG( "Encoding the input query with Gurobi...\n" );
2963 _gurobi = std::unique_ptr<GurobiWrapper>( new GurobiWrapper() );
2964 _tableau->setGurobi( &( *_gurobi ) );
2965 _milpEncoder = std::unique_ptr<MILPEncoder>( new MILPEncoder( *_tableau ) );
2966 _milpEncoder->encodeInputQuery( *_gurobi, *_preprocessedQuery );
2967 ENGINE_LOG( "Query encoded in Gurobi...\n" );
2968
2969 double timeoutForGurobi = ( timeoutInSeconds == 0 ? FloatUtils::infinity() : timeoutInSeconds );
2970 ENGINE_LOG( Stringf( "Gurobi timeout set to %f\n", timeoutForGurobi ).ascii() )
2971 _gurobi->setTimeLimit( timeoutForGurobi );
2972 if ( !_sncMode )
2973 _gurobi->setNumberOfThreads( Options::get()->getInt( Options::NUM_WORKERS ) );
2974 _gurobi->setVerbosity( _verbosity > 0 );
2975 _gurobi->solve();
2976
2977 if ( _gurobi->haveFeasibleSolution() )
2978 {
2979 if ( allNonlinearConstraintsHold() )
2980 {
2981 _exitCode = IEngine::SAT;
2982 return true;
2983 }
2984 else
2985 {
2986 _exitCode = IEngine::UNKNOWN;
2987 return false;
2988 }
2989 }
2990 else if ( _gurobi->infeasible() )
2991 _exitCode = IEngine::UNSAT;
2992 else if ( _gurobi->timeout() )
2993 _exitCode = IEngine::TIMEOUT;
2994 else
2995 throw NLRError( NLRError::UNEXPECTED_RETURN_STATUS_FROM_GUROBI );
2996 return false;
2997}

Callers

nothing calls this directly

Calls 14

StringfClass · 0.85
NLRErrorClass · 0.85
encodeInputQueryMethod · 0.80
setTimeLimitMethod · 0.80
asciiMethod · 0.80
setNumberOfThreadsMethod · 0.80
getIntMethod · 0.80
basisMatrixAvailableMethod · 0.45
setGurobiMethod · 0.45
setVerbosityMethod · 0.45
solveMethod · 0.45
haveFeasibleSolutionMethod · 0.45

Tested by

no test coverage detected