#include <cstdlib>
#include <algorithm>
#include <functional>
#include <stdexcept>
#include <iostream>
#include "debug/macros.h"
#include "dbm/priced.h"
#include "infimum.h"
#include "dbm/fed.h"
#include "dbm/print.h"
Defines | |
#define | DBM(I, J) dbm[(I)*dim+(J)] |
Convenient macro for accessing DBM entries. | |
#define | pdbm_cost(pdbm) ((pdbm)->cost) |
Returns the cost at the offset point. | |
#define | pdbm_rates(pdbm) ((pdbm)->data) |
Returns the vectors of coefficients. | |
#define | pdbm_matrix(pdbm) ((pdbm)->data + dim) |
Returns the matrix. | |
#define | pdbm_cache(pdbm) ((pdbm)->infimum) |
Returns the cache infimum. | |
#define | pdbm_count(pdbm) ((pdbm)->count) |
Returns the reference count. | |
#define | INVALID INT_MAX |
Constant to mark the cached infimum as void. | |
Functions | |
static bool | pdbm_areOnZeroCycle (const PDBM pdbm, cindex_t dim, cindex_t i, cindex_t j) |
Returns true if two clocks form a zero cycle in a priced DBM. | |
static void | dbm_findZeroCycles (const raw_t *dbm, cindex_t dim, cindex_t *next) |
Find the zero cycles of a DBM. | |
static void | pdbm_prepare (PDBM &pdbm, cindex_t dim) |
Prepares a priced DBM for modification. | |
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. | |
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. | |
static int32_t | costAtOtherOffset (const raw_t *dbm1, const int32_t *rates1, uint32_t cost1, const raw_t *dbm2, cindex_t dim) |
Returns the cost of the offset point of dbm2 in dbm1. | |
static bool | leq (const int32_t *first, const int32_t *last, const int32_t *rate) |
Given two planes, returns true if the slope of the first is less than or equal to the slope of the other. | |
static int32_t | infOfDiff (const raw_t *dbm, uint32_t dim, int32_t cost1, const int32_t *rate1, int32_t cost2, const int32_t *rate2) |
Given a zone and two hyperplanes over that zone, returns the infimum of the difference of the two planes. | |
relation_t | pdbm_relation (const PDBM pdbm1, const PDBM pdbm2, cindex_t dim) |
Relation between two priced DBMs. | |
relation_t | pdbm_relationWithMinDBM (const PDBM pdbm1, cindex_t dim, const mingraph_t pdbm2, raw_t *dbm2) |
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 allocator, 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_findNextZeroCycle (const PDBM pdbm, cindex_t dim, cindex_t x, cindex_t *out) |
Finds a clock that is on a zero cycle with clock. | |
bool | pdbm_findZeroCycle (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. | |
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. | |
static bool | isRedundant (const raw_t *dbm, cindex_t dim, cindex_t i, cindex_t j, cindex_t *next) |
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. | |
bool | pdbm_isValid (const PDBM pdbm, cindex_t dim) |
Returns true if the DBM is valid. | |
void | pdbm_freeClock (PDBM &pdbm, cindex_t dim, cindex_t clock) |
Frees a clock of a priced DBM. | |
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. | |
const int32_t * | pdbm_getRates (const PDBM pdbm, cindex_t dim) |
bool | pdbm_constrainToFacet (PDBM &pdbm, cindex_t dim, cindex_t i, cindex_t j) |
Constrain a priced DBM to a facet (i, j). | |
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. | |
void | pdbm_normalise (PDBM pdbm, cindex_t dim) |
Brings a priced DBM into normal form. | |
bool | pdbm_hasNormalForm (PDBM pdbm, cindex_t dim) |
Checks whether a priced DBM is in normal form. |
|
Convenient macro for accessing DBM entries.
|
|
Constant to mark the cached infimum as void.
|
|
Returns the cache infimum.
|
|
Returns the cost at the offset point.
|
|
Returns the reference count.
|
|
Returns the matrix.
|
|
Returns the vectors of coefficients.
|
|
Returns the cost of the offset point of dbm2 in dbm1.
|
|
Find the zero cycles of a DBM. The zero cycles are represented by an array which for each clock contains the next element on the zero cycle, or * 0 if the clock is the last element. I.e. next[i] is the index of the next clock on a zero cycle with i.
|
|
Given a zone and two hyperplanes over that zone, returns the infimum of the difference of the two planes.
|
|
|
|
Given two planes, returns true if the slope of the first is less than or equal to the slope of the other.
|
|
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
|
|
Returns true if two clocks form a zero cycle in a priced DBM.
|
|
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.
|
|
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.
|
|
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.
|
|
Prepares a priced DBM for modification. If it is shared, a copy will be created. |
|
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
|