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

Method runSingleSimulation

src/engine/Simulator.cpp:73–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void Simulator::runSingleSimulation()
74{
75 InputQuery query = _originalQuery;
76
77 List<unsigned> inputs = query.getInputVariables();
78 for ( const auto &input : inputs )
79 {
80 double lb = query.getLowerBound( input );
81 double ub = query.getUpperBound( input );
82
83 double factor = ( (double)rand() ) / RAND_MAX;
84 double value = lb + factor * ( ub - lb );
85
86 query.setLowerBound( input, value );
87 query.setUpperBound( input, value );
88 }
89
90 // Propagate the random values through the network using the preprocessor
91 Preprocessor preprocessor;
92
93 // If we set elimination to true, the PL constraints will be removed
94 query = *( preprocessor.preprocess( query, false ) );
95
96 // Extract the result
97 Simulator::Result result;
98 for ( unsigned i = 0; i < _originalQuery.getNumberOfVariables(); ++i )
99 {
100 // Make sure that a value has been calculated for every variable
101 ASSERT( !preprocessor.variableIsMerged( i ) );
102 if ( !preprocessor.variableIsFixed( i ) )
103 throw MarabouError( MarabouError::SIMULATOR_ERROR,
104 "Could not calculate an exact assignment" );
105
106 ASSERT( FloatUtils::areEqual( query.getLowerBound( i ), query.getUpperBound( i ) ) );
107
108 result[i] = query.getLowerBound( i );
109 }
110
111 _results.append( result );
112}
113
114const List<Simulator::Result> *Simulator::getResults()
115{

Callers

nothing calls this directly

Calls 11

MarabouErrorClass · 0.85
preprocessMethod · 0.80
variableIsMergedMethod · 0.80
variableIsFixedMethod · 0.80
getInputVariablesMethod · 0.45
getLowerBoundMethod · 0.45
getUpperBoundMethod · 0.45
setLowerBoundMethod · 0.45
setUpperBoundMethod · 0.45
getNumberOfVariablesMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected