#include "base/intutils.h"
#include "hash/compute.h"
#include "base/relation.h"
#include "dbm/constraints.h"
Go to the source code of this file.
Functions | |
void | dbm_init (raw_t *dbm, cindex_t dim) |
Initialize a DBM with:
| |
static void | dbm_zero (raw_t *dbm, cindex_t dim) |
Set the DBM so that it contains only 0. | |
BOOL | dbm_isEqualToInit (const raw_t *dbm, cindex_t dim) |
Equality test with trivial dbm as obtained from dbm_init(dbm, dim). | |
static BOOL | dbm_isEqualToZero (const raw_t *dbm, cindex_t dim) |
Equality test with dbm as obtained from dbm_zero(dbm, dim, tauClock). | |
void | dbm_convexUnion (raw_t *dbm1, const raw_t *dbm2, cindex_t dim) |
Convex hull union between 2 DBMs. | |
BOOL | dbm_intersection (raw_t *dbm1, const raw_t *dbm2, cindex_t dim) |
Intersection of 2 DBMs. | |
BOOL | dbm_relaxedIntersection (raw_t *dst, const raw_t *dbm1, const raw_t *dbm2, cindex_t dim) |
Relaxed intersection of 2 DBMs. | |
BOOL | dbm_haveIntersection (const raw_t *dbm1, const raw_t *dbm2, cindex_t dim) |
Test if 2 DBMs have an intersection. | |
BOOL | dbm_constrain (raw_t *dbm, cindex_t dim, cindex_t i, cindex_t j, raw_t constraint, uint32_t *touched) |
Constrain a DBM with a constraint. | |
BOOL | dbm_constrainN (raw_t *dbm, cindex_t dim, const constraint_t *constraints, size_t n) |
Constrain a DBM with several constraints. | |
BOOL | dbm_constrainIndexedN (raw_t *dbm, cindex_t dim, const cindex_t *indexTable, const constraint_t *constraints, size_t n) |
Constrain a DBM with several constraints using a table for index translation (translates absolute clock indices to local clock indices for this DBM). | |
BOOL | dbm_constrain1 (raw_t *dbm, cindex_t dim, cindex_t i, cindex_t j, raw_t constraint) |
Constrain a DBM with one constraint. | |
static BOOL | dbm_constrainC (raw_t *dbm, cindex_t dim, constraint_t c) |
Wrapper for constrain1. | |
void | dbm_up (raw_t *dbm, cindex_t dim) |
Delay operation. | |
void | dbm_downFrom (raw_t *dbm, cindex_t dim, cindex_t j0) |
Internal dbm_down, don't use directly. | |
static void | dbm_down (raw_t *dbm, cindex_t dim) |
Inverse delay operation. | |
void | dbm_updateValue (raw_t *dbm, cindex_t dim, cindex_t index, int32_t value) |
Former "reset" operation, properly called update. | |
void | dbm_freeClock (raw_t *dbm, cindex_t dim, cindex_t index) |
Free operation. | |
void | dbm_freeUp (raw_t *dbm, cindex_t dim, cindex_t index) |
Free all upper bounds for a given clock. | |
void | dbm_freeAllUp (raw_t *dbm, cindex_t dim) |
Free all upper bounds for all clocks. | |
BOOL | dbm_isFreedAllUp (const raw_t *dbm, cindex_t dim) |
uint32_t | dbm_testFreeAllDown (const raw_t *dbm, cindex_t dim) |
void | dbm_freeDown (raw_t *dbm, cindex_t dim, cindex_t index) |
Free all lower bounds for a given clock. | |
void | dbm_freeAllDown (raw_t *dbm, cindex_t dim) |
Free all lower bounds for all clocks. | |
void | dbm_updateClock (raw_t *dbm, cindex_t dim, cindex_t i, cindex_t j) |
Clock copy operation = update clock: xi := xj, where xi and xj are clocks. | |
void | dbm_updateIncrement (raw_t *dbm, cindex_t dim, cindex_t i, int32_t value) |
Increment operation: xi := xi + value, where xi is a clock. | |
void | dbm_update (raw_t *dbm, cindex_t dim, cindex_t i, cindex_t j, int32_t value) |
More general update operation: xi := xj + value, where xi and yi are clocks. | |
BOOL | dbm_constrainClock (raw_t *dbm, cindex_t dim, cindex_t clock, int32_t value) |
static BOOL | dbm_satisfies (const raw_t *dbm, cindex_t dim, cindex_t i, cindex_t j, raw_t constraint) |
Satisfy operation. | |
BOOL | dbm_isEmpty (const raw_t *dbm, cindex_t dim) |
Check if a DBM is empty by looking at its diagonal. | |
BOOL | dbm_close (raw_t *dbm, cindex_t dim) |
Close operation. | |
BOOL | dbm_isClosed (const raw_t *dbm, cindex_t dim) |
Check that a DBM is closed. | |
BOOL | dbm_closex (raw_t *dbm, cindex_t dim, const uint32_t *touched) |
Close operation. | |
BOOL | dbm_close1 (raw_t *dbm, cindex_t dim, cindex_t k) |
Close operation for 1 clock. | |
void | dbm_closeij (raw_t *dbm, cindex_t dim, cindex_t i, cindex_t j) |
Specialization of close valid if only one constraint cij is tightened, ie, DBM is closed, you tighten DBM[i,j] only, then this function recomputes the closure more efficiently than calling close1(i) and close1(j). | |
static void | dbm_tighten (raw_t *dbm, cindex_t dim, cindex_t i, cindex_t j, raw_t c) |
Tighten with a constraint c and maintain the closed form. | |
BOOL | dbm_isUnbounded (const raw_t *dbm, cindex_t dim) |
Check if a DBM is unbounded, i.e. | |
relation_t | dbm_relation (const raw_t *dbm1, const raw_t *dbm2, cindex_t dim) |
Relation between 2 dbms. | |
BOOL | dbm_isSubsetEq (const raw_t *dbm1, const raw_t *dbm2, cindex_t dim) |
Test only if dbm1 <= dbm2. | |
static BOOL | dbm_isSupersetEq (const raw_t *dbm1, const raw_t *dbm2, cindex_t dim) |
Symmetric relation, just for completeness. | |
void | dbm_relaxUpClock (raw_t *dbm, cindex_t dim, cindex_t clock) |
Relax upper bounds of a given clocks, ie, make them weak. | |
void | dbm_relaxDownClock (raw_t *dbm, cindex_t dim, cindex_t clock) |
Relax lower bounds of a given clocks, ie, make them weak. | |
void | dbm_relaxAll (raw_t *dbm, cindex_t dim) |
Relax all bounds so that they are non strict (except for infinity). | |
static void | dbm_relaxUp (raw_t *dbm, cindex_t dim) |
Smallest possible delay. | |
static void | dbm_relaxDown (raw_t *dbm, cindex_t dim) |
Smallest possible inverse delay. | |
static void | dbm_copy (raw_t *dst, const raw_t *src, cindex_t dim) |
Copy DBMs. | |
static BOOL | dbm_areEqual (const raw_t *dbm1, const raw_t *dbm2, cindex_t dim) |
Test equality. | |
static uint32_t | dbm_hash (const raw_t *dbm, cindex_t dim) |
Compute a hash value for a DBM. | |
BOOL | dbm_isPointIncluded (const int32_t *pt, const raw_t *dbm, cindex_t dim) |
Test if a (discrete) point is included in the zone represented by the DBM. | |
BOOL | dbm_isRealPointIncluded (const double *pt, const raw_t *dbm, cindex_t dim) |
Test if a (real) point is included in the zone represented by the DBM. | |
void | dbm_extrapolateMaxBounds (raw_t *dbm, cindex_t dim, const int32_t *max) |
Classical extrapolation based on maximal bounds, formerly called k-normalization. | |
void | dbm_diagonalExtrapolateMaxBounds (raw_t *dbm, cindex_t dim, const int32_t *max) |
Diagonal extrapolation based on maximal bounds. | |
void | dbm_extrapolateLUBounds (raw_t *dbm, cindex_t dim, const int32_t *lower, const int32_t *upper) |
Extrapolation based on lower-upper bounds. | |
void | dbm_diagonalExtrapolateLUBounds (raw_t *dbm, cindex_t dim, const int32_t *lower, const int32_t *upper) |
Diagonal extrapolation based on lower-upper bounds. | |
cindex_t | dbm_shrinkExpand (const raw_t *dbmSrc, raw_t *dbmDst, cindex_t dimSrc, const uint32_t *bitSrc, const uint32_t *bitDst, size_t bitSize, cindex_t *table) |
Shrink and expand a DBM:
| |
void | dbm_updateDBM (raw_t *dbmDst, const raw_t *dbmSrc, cindex_t dimDst, cindex_t dimSrc, const cindex_t *cols) |
Variant of dbm_shrinkExpand: Instead of giving bit arrays, you provide one array of the clocks you want in the destination. | |
void | dbm_swapClocks (raw_t *dbm, cindex_t dim, cindex_t x, cindex_t y) |
Swap clocks. | |
BOOL | dbm_isDiagonalOK (const raw_t *dbm, cindex_t dim) |
Test if the diagonal is correct. | |
BOOL | dbm_isValid (const raw_t *dbm, cindex_t dim) |
Test if
| |
const char * | dbm_relation2string (relation_t rel) |
Convert code to string. | |
raw_t | dbm_getMaxRange (const raw_t *dbm, cindex_t dim) |
Go through a DBM (dim*dim) and compute the max range needed to store the constraints, excluding infinity. |
|
Test equality.
|
|
Close operation. Complexity cubic in dim. Algorithm: for all k < dim do for all i < dim do for all j < dim do if dbm[i,j] > dbm[i,k]+dbm[k,j] dbm[i,j] = dbm[i,k]+dbm[k,j] |
|
Close operation for 1 clock. Complexity quadratic in dim * # of clocks to iterate on. Algorithm: for one k < dim do for all i < dim do for all j < dim do if dbm[i,j] > dbm[i,k]+dbm[k,j] dbm[i,j] = dbm[i,k]+dbm[k,j] |
|
Specialization of close valid if only one constraint cij is tightened, ie, DBM is closed, you tighten DBM[i,j] only, then this function recomputes the closure more efficiently than calling close1(i) and close1(j).
|
|
Close operation. Complexity quadratic in dim * # of clocks to iterate on. Algorithm: for all k < dim s.t. clock k is touched do for all i < dim do for all j < dim do if dbm[i,j] > dbm[i,k]+dbm[k,j] dbm[i,j] = dbm[i,k]+dbm[k,j] |
|
Constrain a DBM with a constraint. USAGE:
|
|
Constrain a DBM with one constraint. If you have several constraints, it may be better to use the previous functions.
|
|
Wrapper for constrain1.
|
|
|
|
Constrain a DBM with several constraints using a table for index translation (translates absolute clock indices to local clock indices for this DBM). USAGE:
|
|
Constrain a DBM with several constraints. USAGE:
|
|
Convex hull union between 2 DBMs.
|
|
Copy DBMs.
|
|
Diagonal extrapolation based on lower-upper bounds. Most general approximation. Update dbm[i,j] with
|
|
Diagonal extrapolation based on maximal bounds. Update dbm[i,j] with
|
|
Inverse delay operation. Also called weakest pre-condition.
|
|
Internal dbm_down, don't use directly.
|
|
Extrapolation based on lower-upper bounds.
|
|
Classical extrapolation based on maximal bounds, formerly called k-normalization. Extrapolate the zone using maximal constants:
|
|
Free all lower bounds for all clocks.
|
|
Free all upper bounds for all clocks.
|
|
Free operation. Remove all constraints (lower and upper bounds) for a given clock, i.e., set them to infinity, except for x0-xk <= 0.
|
|
Free all lower bounds for a given clock.
|
|
Free all upper bounds for a given clock.
|
|
Go through a DBM (dim*dim) and compute the max range needed to store the constraints, excluding infinity.
|
|
Compute a hash value for a DBM.
|
|
Test if 2 DBMs have an intersection.
|
|
Initialize a DBM with:
|
|
Intersection of 2 DBMs.
|
|
Check that a DBM is closed. Complexity cubic in dim. Algorithm: for all k < dim do for all i < dim do for all j < dim do if dbm[i,j] > dbm[i,k]+dbm[k,j] needs update -> return false |
|
Test if the diagonal is correct. Constraints on the diagonal should be <0 if the DBM is empty or <=0 for non empty DBMs. Positive constraints are allowed in principle but such DBMs are not canonical.
|
|
Check if a DBM is empty by looking at its diagonal. There should be only == 0 constraints. NOTE: one should never need to call this function manually, unless for debugging.
|
|
Equality test with trivial dbm as obtained from dbm_init(dbm, dim).
|
|
Equality test with dbm as obtained from dbm_zero(dbm, dim, tauClock).
|
|
|
|
Test if a (discrete) point is included in the zone represented by the DBM.
|
|
Test if a (real) point is included in the zone represented by the DBM.
|
|
Test only if dbm1 <= dbm2.
|
|
Symmetric relation, just for completeness.
|
|
Check if a DBM is unbounded, i.e. , if one point can delay infinitely.
|
|
Test if
|
|
Relation between 2 dbms. See relation_t.
|
|
Convert code to string.
|
|
Relax all bounds so that they are non strict (except for infinity).
|
|
Smallest possible inverse delay. Render lower bounds x0-xi <= c0i non strict if possible.
|
|
Relax lower bounds of a given clocks, ie, make them weak.
|
|
Relaxed intersection of 2 DBMs.
|
|
Smallest possible delay. Render upper bounds xi-x0 <= ci0 non strict if possible.
|
|
Relax upper bounds of a given clocks, ie, make them weak.
|
|
Satisfy operation. Check if a DBM satisfies a constraint. The DBM is not modified. WARNING: using this for conjunction of constraints is incorrect because the DBM is not modified.
|
|
Shrink and expand a DBM:
|
|
Swap clocks.
|
|
|
|
Tighten with a constraint c and maintain the closed form.
|
|
Delay operation. Remove constraints of the form xi-x0 <= ci and replace them by xi-x0 < infinity. It is also called strongest post-condition.
|
|
More general update operation: xi := xj + value, where xi and yi are clocks. WARNING: if offset is negative it may be incorrect to use this.
|
|
Clock copy operation = update clock: xi := xj, where xi and xj are clocks.
|
|
Variant of dbm_shrinkExpand: Instead of giving bit arrays, you provide one array of the clocks you want in the destination.
|
|
Increment operation: xi := xi + value, where xi is a clock. WARNING: if offset is negative it may be incorrect to use this.
|
|
Former "reset" operation, properly called update. Implement the operation x := v, where x is a clock and v a positive integer.
|
|
Set the DBM so that it contains only 0.
|