#include <cstdio>
#include <utility>
#include "base/inttypes.h"
#include "dbm/dbm.h"
#include "dbm/mingraph.h"
Go to the source code of this file.
Typedefs | |
typedef PDBM_s * | PDBM |
Data type for priced dbm. | |
Functions | |
size_t | pdbm_size (cindex_t dim) |
Computes the size in number of bytes of a priced dbm of the given dimension. | |
PDBM | pdbm_reserve (cindex_t dim, void *p) |
Reserves a memory area for use as a priced DBM. | |
PDBM | pdbm_allocate (cindex_t dim) |
Allocates a new priced DBM. | |
void | pdbm_deallocate (PDBM &pdbm) |
Deallocates a priced DBM. | |
static void | pdbm_incRef (PDBM pdbm) |
Increases reference count on priced DBM. | |
static void | pdbm_decRef (PDBM pdbm) |
Decreases reference count on priced DBM. | |
PDBM | pdbm_copy (PDBM dst, const PDBM src, cindex_t dim) |
Copy a priced DBM. | |
void | pdbm_init (PDBM &pdbm, cindex_t dim) |
Initialises a priced DBM to the DBM containing all valuations. | |
void | pdbm_zero (PDBM &pdbm, cindex_t dim) |
Initialize a priced DBM to only contain the origin with a cost of 0. | |
bool | pdbm_constrain1 (PDBM &pdbm, cindex_t dim, cindex_t i, cindex_t j, raw_t constraint) |
Constrain a priced DBM. | |
bool | pdbm_constrainN (PDBM &pdbm, cindex_t dim, const constraint_t *constraints, size_t n) |
Constrain a priced DBM with multiple constraints. | |
bool | pdbm_constrainToFacet (PDBM &pdbm, cindex_t dim, cindex_t i, cindex_t j) |
Constrain a priced DBM to a facet (i, j). | |
relation_t | pdbm_relation (const PDBM pdbm1, const PDBM pdbm2, cindex_t dim) |
Relation between two priced DBMs. | |
relation_t | pdbm_relationWithMinDBM (const PDBM pdbm, cindex_t dim, const mingraph_t minDBM, raw_t *buffer) |
Relation between 2 priced dbms where one is in compressed. | |
int32_t | pdbm_getInfimum (const PDBM pdbm, cindex_t dim) |
Computes the infimum cost of the priced DBM. | |
int32_t | pdbm_getInfimumValuation (const PDBM pdbm, cindex_t dim, int32_t *valuation, const bool *free) |
Generates a valuation which has the infimum cost of the priced DBM. | |
bool | pdbm_satisfies (const PDBM pdbm, cindex_t dim, cindex_t i, cindex_t j, raw_t constraint) |
Check if a priced DBM satisfies a given constraint. | |
bool | pdbm_isEmpty (const PDBM pdbm, cindex_t dim) |
Returns true if the priced DBM is empty. | |
bool | pdbm_isUnbounded (const PDBM pdbm, cindex_t dim) |
Check if at least one point can delay infinitely. | |
uint32_t | pdbm_hash (const PDBM pdbm, cindex_t dim, uint32_t seed) |
Compute a hash value for a priced DBM. | |
bool | pdbm_containsInt (const PDBM pdbm, cindex_t dim, const int32_t *pt) |
Test if a point is included in the priced DBM. | |
bool | pdbm_containsDouble (const PDBM pdbm, cindex_t dim, const double *pt) |
Test if a point is included in the priced DBM. | |
void | pdbm_up (PDBM &pdbm, cindex_t dim) |
Delay with the current delay rate. | |
void | pdbm_upZero (PDBM &pdbm, cindex_t dim, uint32_t rate, cindex_t zero) |
Delay with delay rate rate. | |
void | pdbm_updateValue (PDBM &pdbm, cindex_t dim, cindex_t clock, uint32_t value) |
Updates clock to value. | |
void | pdbm_updateValueZero (PDBM &pdbm, cindex_t dim, cindex_t clock, uint32_t value, cindex_t zero) |
Updates clock to value. | |
void | pdbm_extrapolateMaxBounds (PDBM &pdbm, cindex_t dim, int32_t *max) |
Unfinished extrapolation function. | |
void | pdbm_diagonalExtrapolateMaxBounds (PDBM &pdbm, cindex_t dim, int32_t *max) |
Unfinished extrapolation function. | |
void | pdbm_diagonalExtrapolateLUBounds (PDBM &pdbm, cindex_t dim, int32_t *lower, int32_t *upper) |
Extrapolate a priced zone. | |
void | pdbm_incrementCost (PDBM &pdbm, cindex_t dim, int32_t value) |
Increments the cost of each point in a priced DBM by value. | |
void | pdbm_close (PDBM &pdbm, cindex_t dim) |
Compute the closure of a priced DBM. | |
uint32_t | pdbm_analyzeForMinDBM (const PDBM pdbm, cindex_t dim, uint32_t *bitMatrix) |
Analyze a priced DBM for its minimal graph representation. | |
int32_t * | pdbm_writeToMinDBMWithOffset (const PDBM pdbm, cindex_t dim, bool minimizeGraph, bool tryConstraints16, allocator_t c_alloc, uint32_t offset) |
Convert the DBM to a more compact representation. | |
void | pdbm_readFromMinDBM (PDBM &dst, cindex_t dim, mingraph_t src) |
Uncompresses a compressed priced DBM. | |
bool | pdbm_findZeroCycle (const PDBM pdbm, cindex_t dim, cindex_t clock, cindex_t *out) |
Finds a clock that is on a zero cycle with clock. | |
bool | pdbm_findNextZeroCycle (const PDBM pdbm, cindex_t dim, cindex_t x, cindex_t *out) |
Finds a clock that is on a zero cycle with clock. | |
int32_t | pdbm_getSlopeOfDelayTrajectory (const PDBM pdbm, cindex_t dim) |
Returns the slope of the cost plane along the delay trajectory. | |
int32_t | pdbm_getRate (const PDBM pdbm, cindex_t dim, cindex_t clock) |
Returns the rate (coefficient of the hyperplane) of clock. | |
const int32_t * | pdbm_getRates (const PDBM pdbm, cindex_t dim) |
uint32_t | pdbm_getCostAtOffset (const PDBM pdbm, cindex_t dim) |
Returns the cost of the offset point. | |
void | pdbm_setCostAtOffset (PDBM &pdbm, cindex_t dim, uint32_t value) |
Sets the cost at the offset point. | |
bool | pdbm_isValid (const PDBM pdbm, cindex_t dim) |
Returns true if the DBM is valid. | |
uint32_t | pdbm_getLowerRelativeFacets (PDBM &pdbm, cindex_t dim, cindex_t clock, cindex_t *facets) |
Computes the lower facets of a priced DBM relative to clock. | |
uint32_t | pdbm_getUpperRelativeFacets (PDBM &pdbm, cindex_t dim, cindex_t clock, cindex_t *facets) |
Computes the upper facets of a priced DBM relative to clock. | |
uint32_t | pdbm_getLowerFacets (PDBM &pdbm, cindex_t dim, cindex_t *facets) |
Computes the lower facets of a priced DBM. | |
uint32_t | pdbm_getUpperFacets (PDBM &pdbm, cindex_t dim, cindex_t *facets) |
Computes the upper facets of a priced DBM. | |
int32_t | pdbm_getCostOfValuation (const PDBM pdbm, cindex_t dim, const int32_t *valuation) |
Computes the cost of a valuation in a priced DBM. | |
void | pdbm_relax (PDBM &pdbm, cindex_t dim) |
Makes all strong constraints of a priced DBM weak. | |
void | pdbm_getOffset (const PDBM pdbm, cindex_t dim, int32_t *valuation) |
Computes the offset point of a priced DBM. | |
void | pdbm_setRate (PDBM &pdbm, cindex_t dim, cindex_t clock, int32_t rate) |
Sets a coefficient of the hyperplane of a priced DBM. | |
raw_t * | pdbm_getMutableMatrix (PDBM &pdbm, cindex_t dim) |
Returns the inner matrix of a priced DBM. | |
const raw_t * | pdbm_getMatrix (const PDBM pdbm, cindex_t dim) |
Returns the inner matrix of a priced DBM. | |
void | pdbm_freeClock (PDBM &pdbm, cindex_t dim, cindex_t clock) |
Frees a clock of a priced DBM. | |
void | pdbm_print (FILE *f, const PDBM pdbm, cindex_t dim) |
Prints a priced DBM to a stream. | |
void | pdbm_freeUp (PDBM &pdbm, cindex_t dim, cindex_t index) |
Implementation of the free up operation for priced DBMs. | |
void | pdbm_freeDown (PDBM &pdbm, cindex_t dim, cindex_t index) |
Implementation of the free down operation for priced DBMs. | |
bool | pdbm_hasNormalForm (PDBM pdbm, cindex_t dim) |
Checks whether a priced DBM is in normal form. | |
void | pdbm_normalise (PDBM pdbm, cindex_t dim) |
Brings a priced DBM into normal form. |
A priced DBM is a data structure representing a zone with an affine hyperplane over the zone assigning a cost to each point in the zone.
A few facts about priced DBMs:
Allocation can be handled by the library by using pdbm_allocate()
and pdbm_deallocate()
. This can optionally be combined with reference counting using pdbm_incRef()
and pdbm_decRef()
, in which case pdbm_deallocate()
is called automatically as soon as the reference count reaches zero. Reference counting is used to implement copy on write semantics. Thus whenever you modify a priced DBM with a reference count larger than 1, then that DBM is automatically copied. For this reason, all functions modifying priced DBMs take a reference parameter to the priced DBM to modify.
A NULL pointer is equivalent to an empty DBM with a reference count of 1. Functions that can cause the priced DBM to become empty can choose to deallocate the DBM rather than to copy it. All functions that do not require the input DBM to be closed will allocate a new DBM when given a NULL pointer as input.
Alternatively, memory can be allocated outside the library. In that case pdbm_size()
bytes need to be allocated and preinitialized for the use by the library by calling pdbm_reserve()
. Priced DBMs allocated in this manner must not be reference counted.
|
Data type for priced dbm.
|
|
Allocates a new priced DBM. The reference count is initialised to 0. No other initialisation is performed.
|
|
Analyze a priced DBM for its minimal graph representation. Computes the smallest number of constraints needed to represent the same zone.
The result is returned as a bit matrix, where each bit indicates whether that entry of the DBM is relevant. I.e. if the bit
|
|
Compute the closure of a priced DBM.
This function is only relevant if the DBM has been modified with
|
|
Constrain a priced DBM. After the call, the DBM will be constrained such that the difference between clock i and clock j is smaller than constraint.
|
|
Constrain a priced DBM with multiple constraints.
|
|
Constrain a priced DBM to a facet (i, j).
|
|
Test if a point is included in the priced DBM.
|
|
Test if a point is included in the priced DBM.
|
|
Copy a priced DBM.
This function copies the data of the DBM. Hence, it is only permissible if the reference count of dst is zero. If dst is NULL, a new DBM is allocate with
|
|
Deallocates a priced DBM.
|
|
Decreases reference count on priced DBM. The DBM is deallocated when the reference count reaches zero.
|
|
Extrapolate a priced zone. The extrapolation is based on a lower and an upper bound for each clock. The output zone simulates the input zone. The implementation is not finished.
|
|
Unfinished extrapolation function.
|
|
Unfinished extrapolation function.
|
|
Finds a clock that is on a zero cycle with clock. Returns TRUE if and only if such a clock is found. Only clocks with a value equal to or greater than the existing value of output are considered. If multiple clocks are on a zero cycle with clock, then the clock with the smallest index is returned.
|
|
Finds a clock that is on a zero cycle with clock. Returns TRUE if and only if such a clock is found. If multiple clocks are on a zero cycle with clock, then the clock with the smallest index is returned.
This function is equivalent to calling
|
|
Frees a clock of a priced DBM.
|
|
Implementation of the free down operation for priced DBMs.
|
|
Implementation of the free up operation for priced DBMs.
|
|
Returns the cost of the offset point.
|
|
Computes the cost of a valuation in a priced DBM.
|
|
Computes the infimum cost of the priced DBM.
|
|
Generates a valuation which has the infimum cost of the priced DBM. There is no guarantee that the valuation will be contained in the priced DBM, but if it is not it is arbitrarily close to a valuation that is contained in the priced DBM. A false entry in free indicates that the value of this clock has already been set in valuation and that this clock must not be modified. The function will only modify free clocks.
|
|
Computes the lower facets of a priced DBM.
|
|
Computes the lower facets of a priced DBM relative to clock. As a side-effect, all lower facets relative to clock are converted to weak facets.
|
|
Returns the inner matrix of a priced DBM. The matrix is read-only.
|
|
Returns the inner matrix of a priced DBM.
The matrix can be modified as long as
|
|
Computes the offset point of a priced DBM.
|
|
Returns the rate (coefficient of the hyperplane) of clock.
|
|
|
|
Returns the slope of the cost plane along the delay trajectory.
|
|
Computes the upper facets of a priced DBM.
|
|
Computes the upper facets of a priced DBM relative to clock. As a side-effect, all upper facets relative to clock are converted to weak facets.
|
|
Compute a hash value for a priced DBM. ISSUE: canonical form needed.
|
|
Checks whether a priced DBM is in normal form.
|
|
Increases reference count on priced DBM.
|
|
Increments the cost of each point in a priced DBM by value.
|
|
Initialises a priced DBM to the DBM containing all valuations.
The cost of all valuations will be zero. If pdbm is NULL, a new DBM is allocated with
|
|
Returns true if the priced DBM is empty.
|
|
Check if at least one point can delay infinitely.
|
|
Returns true if the DBM is valid. Useful for debugging.
|
|
Brings a priced DBM into normal form.
|
|
Prints a priced DBM to a stream.
|
|
Uncompresses a compressed priced DBM. The compressed priced DBM src is written to dst. The destination does not need to initialised beforehand. The dimension dim must match the dimension of the compressed priced DBM.
|
|
Relation between two priced DBMs.
|
|
Relation between 2 priced dbms where one is in compressed. Notice that in constract to dbm_relationWithMinDBM, buffer may not be NULL.
|
|
Makes all strong constraints of a priced DBM weak.
|
|
Reserves a memory area for use as a priced DBM.
The priced DBM will be unitialised, hence further initialised with e.g.
|
|
Check if a priced DBM satisfies a given constraint.
|
|
Sets the cost at the offset point. Notice that the value must be large enough such that the infimum cost of the priced DBM is not negative. Temporary inconsistencies are allowed as long as no operations are performed on the priced DBM.
|
|
Sets a coefficient of the hyperplane of a priced DBM.
|
|
Computes the size in number of bytes of a priced dbm of the given dimension.
|
|
Delay with the current delay rate.
|
|
Updates clock to value. This is only legitimate if the current rate of clock is zero.
|
|
Updates clock to value. This is only legitimate if the clock forms a zero cycle with another clock (possibly the reference clock).
|
|
Delay with delay rate rate. There must be at least one clock forming a zero cycle with the reference clock.
|
|
Convert the DBM to a more compact representation.
The API supports allocation of larger data structures than needed for the actual zone representation. When the offset argument is bigger than zero, offset extra integers are allocated and the zone is written with the given offset. Thus when
int32_t *memory = dbm_writeToMinDBMWithOffset(...); mingraph_t mg = &memory[offset];
|
|
Initialize a priced DBM to only contain the origin with a cost of 0.
If pdbm is NULL, a new DBM is allocated with
|