/* extrapolateMaxBounds will change the lower and upper bounds, thus * it is only safe for clocks with a cost rate of zero. Thus as a * preprocessing step, we change the maximum constant to infinity for * all clocks with a non-xero cost rate. */ void pdbm_extrapolateMaxBounds( PDBM &pdbm, cindex_t dim, int32_t *max) { assert(pdbm && dim); int32_t *rates = pdbm_rates(pdbm); for (uint32_t i = 1; i < dim; i++) { if (rates[i] != 0) { max[i] = dbm_INFINITY; } } pdbm_prepare(pdbm, dim); dbm_extrapolateMaxBounds(pdbm_matrix(pdbm), dim, max); }
/* test the 4 extrapolations */ static void test(uint32_t size) { ADBM(dbm1); ADBM(dbm2); ADBM(dbm3); ADBM(dbm4); ADBM(dbm5); ADBM(dbm6); ADBM(dbm7); ADBM(dbm8); ADBM(dbm9); ADBM(dbm10); AVECT(lower); AVECT(upper); AVECT(max); uint32_t k, l; printf("*** Testing size=%u\n", size); for (k = 0; k < 2000; ++k) { PROGRESS(); max[0] = lower[0] = upper[0] = 0; for (l = 1; l < size; l++) { int32_t low = RANGE() - (MAXRANGE / 2); int32_t up = RANGE() - (MAXRANGE / 2); /* low + RANGE()/2; */ lower[l] = (low < 0 ? -dbm_INFINITY : low); upper[l] = (up < 0 ? -dbm_INFINITY : up); max[l] = (lower[l] < upper[l] ? upper[l] : lower[l]); } DBM_GEN(dbm1); dbm_copy(dbm10, dbm1, size); dbm_copy(dbm9, dbm1, size); dbm_copy(dbm8, dbm1, size); dbm_copy(dbm7, dbm1, size); dbm_copy(dbm6, dbm1, size); dbm_copy(dbm5, dbm1, size); dbm_copy(dbm4, dbm1, size); dbm_copy(dbm3, dbm1, size); dbm_copy(dbm2, dbm1, size); assert(dbm_isClosed(dbm1, size)); dbm_extrapolateMaxBounds(dbm2, size, max); dbm_extrapolateLUBounds(dbm3, size, max, max); dbm_extrapolateLUBounds(dbm4, size, lower, upper); dbm_diagonalExtrapolateMaxBounds(dbm5, size, max); test_diagonalExtrapolateMaxBounds(dbm8, size, max); dbm_diagonalExtrapolateLUBounds(dbm6, size, max, max); test_diagonalExtrapolateLUBounds(dbm9, size, max, max); dbm_diagonalExtrapolateLUBounds(dbm7, size, lower, upper); test_diagonalExtrapolateLUBounds(dbm10, size, lower, upper); assert(dbm_areEqual(dbm5, dbm8, size)); assert(dbm_areEqual(dbm6, dbm9, size)); assert(dbm_areEqual(dbm7, dbm10, size)); /* 1 <= 2 == 3 <= 4 <= 7, 1 <= 2 == 3 <= 5 == 6 <= 7 */ assert(dbm_relation(dbm1, dbm2, size) & base_SUBSET); assert(dbm_relation(dbm2, dbm3, size) == base_EQUAL); assert(dbm_relation(dbm3, dbm4, size) & base_SUBSET); assert(dbm_relation(dbm4, dbm7, size) & base_SUBSET); assert(dbm_relation(dbm3, dbm5, size) & base_SUBSET); assert(dbm_relation(dbm5, dbm6, size) == base_EQUAL); assert(dbm_relation(dbm6, dbm7, size) & base_SUBSET); /* further checks */ assert(dbm_isValid(dbm2, size)); assert(dbm_isValid(dbm3, size)); assert(dbm_isValid(dbm4, size)); assert(dbm_isValid(dbm5, size)); assert(dbm_isValid(dbm6, size)); assert(dbm_isValid(dbm7, size)); } ENDL; free(lower); free(upper); free(max); free(dbm10); free(dbm9); free(dbm8); free(dbm7); free(dbm6); free(dbm5); free(dbm4); free(dbm3); free(dbm2); free(dbm1); }
void Clocks::extrapolateMaxBounds() { dbm_extrapolateMaxBounds( data, dim, &bounds[ 0 ] ); }