| 71 | } |
| 72 | |
| 73 | void 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 | |
| 114 | const List<Simulator::Result> *Simulator::getResults() |
| 115 | { |
nothing calls this directly
no test coverage detected