| 26 | } |
| 27 | |
| 28 | void LargestIntervalDivider::createSubQueries( unsigned numNewSubqueries, |
| 29 | const String queryIdPrefix, |
| 30 | const unsigned previousDepth, |
| 31 | const PiecewiseLinearCaseSplit &previousSplit, |
| 32 | const unsigned timeoutInSeconds, |
| 33 | SubQueries &subQueries ) |
| 34 | { |
| 35 | unsigned numBisects = (unsigned)log2( numNewSubqueries ); |
| 36 | |
| 37 | List<InputRegion> inputRegions; |
| 38 | |
| 39 | // Create the first input region from the previous case split |
| 40 | InputRegion region; |
| 41 | List<Tightening> bounds = previousSplit.getBoundTightenings(); |
| 42 | for ( const auto &bound : bounds ) |
| 43 | { |
| 44 | if ( bound._type == Tightening::LB ) |
| 45 | { |
| 46 | region._lowerBounds[bound._variable] = bound._value; |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | ASSERT( bound._type == Tightening::UB ); |
| 51 | region._upperBounds[bound._variable] = bound._value; |
| 52 | } |
| 53 | } |
| 54 | inputRegions.append( region ); |
| 55 | |
| 56 | // Repeatedly bisect the dimension with the largest interval |
| 57 | for ( unsigned i = 0; i < numBisects; ++i ) |
| 58 | { |
| 59 | List<InputRegion> newInputRegions; |
| 60 | for ( const auto &inputRegion : inputRegions ) |
| 61 | { |
| 62 | unsigned dimensionToSplit = getLargestInterval( inputRegion ); |
| 63 | bisectInputRegion( inputRegion, dimensionToSplit, newInputRegions ); |
| 64 | } |
| 65 | inputRegions = newInputRegions; |
| 66 | } |
| 67 | |
| 68 | unsigned queryIdSuffix = 1; // For query id |
| 69 | // Create a new subquery for each newly created input region |
| 70 | for ( const auto &inputRegion : inputRegions ) |
| 71 | { |
| 72 | // Create a new query id |
| 73 | String queryId; |
| 74 | if ( queryIdPrefix == "" ) |
| 75 | queryId = queryIdPrefix + Stringf( "%u", queryIdSuffix++ ); |
| 76 | else |
| 77 | queryId = queryIdPrefix + Stringf( "-%u", queryIdSuffix++ ); |
| 78 | |
| 79 | // Create a new case split |
| 80 | auto split = std::unique_ptr<PiecewiseLinearCaseSplit>( new PiecewiseLinearCaseSplit() ); |
| 81 | // Add bound as equations for each input variable |
| 82 | for ( const auto &variable : _inputVariables ) |
| 83 | { |
| 84 | double lb = inputRegion._lowerBounds[variable]; |
| 85 | double ub = inputRegion._upperBounds[variable]; |
nothing calls this directly
no test coverage detected