00001 // -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; indent-tabs-mode: nil; -*- 00002 //////////////////////////////////////////////////////////////////// 00003 // 00004 // This file is a part of the UPPAAL toolkit. 00005 // Copyright (c) 1995 - 2005, Uppsala University and Aalborg University. 00006 // All right reserved. 00007 // 00008 // $Id: priced.h,v 1.15 2005/05/31 20:54:59 behrmann Exp $ 00009 // 00010 /////////////////////////////////////////////////////////////////// 00011 00012 #ifndef INCLUDE_DBM_PRICED_H 00013 #define INCLUDE_DBM_PRICED_H 00014 00015 #include <cstdio> 00016 #include <utility> 00017 #include "base/inttypes.h" 00018 #include "dbm/dbm.h" 00019 #include "dbm/mingraph.h" 00020 00021 /** 00022 * @file 00023 * 00024 * Functions for handling priced DBMs. 00025 * 00026 * A priced DBM is a data structure representing a zone with an affine 00027 * hyperplane over the zone assigning a cost to each point in the 00028 * zone. 00029 * 00030 * A few facts about priced DBMs: 00031 * 00032 * - Priced DBMs have a positive dimension. 00033 * 00034 * - Priced DBMs are stored continously in memory. 00035 * 00036 * - The clock with index zero is the reference clock. 00037 * 00038 * - The affine hyperplane is given by the cost in the offset point 00039 * and the coefficients of the hyperplane. 00040 * 00041 * - A closed DBM is never empty. 00042 * 00043 * Allocation can be handled by the library by using \c 00044 * pdbm_allocate() and \c pdbm_deallocate(). This can optionally be 00045 * combined with reference counting using \c pdbm_incRef() and \c 00046 * pdbm_decRef(), in which case \c pdbm_deallocate() is called 00047 * automatically as soon as the reference count reaches zero. 00048 * Reference counting is used to implement copy on write 00049 * semantics. Thus whenever you modify a priced DBM with a reference 00050 * count larger than 1, then that DBM is automatically copied. For 00051 * this reason, all functions modifying priced DBMs take a reference 00052 * parameter to the priced DBM to modify. 00053 * 00054 * A NULL pointer is equivalent to an empty DBM with a reference count 00055 * of 1. Functions that can cause the priced DBM to become empty can 00056 * choose to deallocate the DBM rather than to copy it. All functions 00057 * that do not require the input DBM to be closed will allocate a new 00058 * DBM when given a NULL pointer as input. 00059 * 00060 * Alternatively, memory can be allocated outside the library. In that 00061 * case \c pdbm_size() bytes need to be allocated and preinitialized 00062 * for the use by the library by calling \c pdbm_reserve(). Priced 00063 * DBMs allocated in this manner must not be reference counted. 00064 */ 00065 00066 /** 00067 * Data type for priced dbm. 00068 */ 00069 typedef struct PDBM_s *PDBM; 00070 00071 /** 00072 * Computes the size in number of bytes of a priced dbm of the given 00073 * dimension. 00074 * 00075 * @param dim is a dimension. 00076 * @pre dim > 0 00077 * @return Amount of memory in bytes. 00078 */ 00079 size_t pdbm_size(cindex_t dim); 00080 00081 /** 00082 * Reserves a memory area for use as a priced DBM. The priced DBM will 00083 * be unitialised, hence further initialised with e.g. \c pdbm_init() 00084 * or \c pdbm_zero() is required. 00085 * 00086 * @param dim is the dimension of the priced DBM to reserve. 00087 * @param p is a memory area of size \c pdbm_size(dim). 00088 * 00089 * @return An unitialised priced DBM of dimension \a dim. 00090 */ 00091 PDBM pdbm_reserve(cindex_t dim, void *p); 00092 00093 /** 00094 * Allocates a new priced DBM. The reference count is initialised to 00095 * 0. No other initialisation is performed. 00096 * 00097 * @param dim is the dimension. 00098 * @return A newly allocated priced DBM of dimension \a dim. 00099 * @pre dim is larger than 0. 00100 */ 00101 PDBM pdbm_allocate(cindex_t dim); 00102 00103 /** 00104 * Deallocates a priced DBM. 00105 * 00106 * @pre 00107 * - \a pdbm was allocated with \c pdbm_allocate(). 00108 * - The reference count of \a pdbm is zero. 00109 */ 00110 void pdbm_deallocate(PDBM &pdbm); 00111 00112 /** 00113 * Increases reference count on priced DBM. 00114 * 00115 * @param pdbm is a priced DBM. 00116 * @pre 00117 * \a pdbm has been allocated with \c pdbm_allocate() and is not NULL. 00118 */ 00119 inline static void pdbm_incRef(PDBM pdbm) 00120 { 00121 assert(pdbm); 00122 00123 (*(int32_t*)pdbm)++; 00124 } 00125 00126 /** 00127 * Decreases reference count on priced DBM. The DBM is deallocated 00128 * when the reference count reaches zero. 00129 * 00130 * @param pdbm is a priced DBM. 00131 * @pre \a pdbm has been allocated with \c pdbm_allocate(). 00132 */ 00133 inline static void pdbm_decRef(PDBM pdbm) 00134 { 00135 assert(pdbm == NULL || *(int32_t*)pdbm); 00136 00137 /* The following relies on the reference counter being the first 00138 * field of the structure. 00139 */ 00140 if (pdbm && !--*(int32_t*)pdbm) 00141 { 00142 pdbm_deallocate(pdbm); 00143 } 00144 } 00145 00146 /** 00147 * Copy a priced DBM. 00148 * 00149 * This function copies the data of the DBM. Hence, it is only 00150 * permissible if the reference count of \a dst is zero. If \a dst is 00151 * NULL, a new DBM is allocate with \c pdbm_allocate(). 00152 * 00153 * @param dst The destination. 00154 * @param src The source. 00155 * @param dim The dimension of \a dst and \a src. 00156 * @pre The reference count of \a dst is zero or dst is NULL. 00157 * @post The reference count of the return value is zero. 00158 * @return The destination. 00159 */ 00160 PDBM pdbm_copy(PDBM dst, const PDBM src, cindex_t dim); 00161 00162 /** 00163 * Initialises a priced DBM to the DBM containing all valuations. The 00164 * cost of all valuations will be zero. If \a pdbm is NULL, a new DBM 00165 * is allocated with \c pdbm_allocate(). 00166 * 00167 * @param pdbm is the priced DBM to initialize. 00168 * @param dim is the dimension of \a pdbm. 00169 */ 00170 void pdbm_init(PDBM &pdbm, cindex_t dim); 00171 00172 /** 00173 * Initialize a priced DBM to only contain the origin with a cost of 00174 * 0. If \a pdbm is NULL, a new DBM is allocated with \c 00175 * pdbm_allocate(). 00176 * 00177 * @param pdbm is the priced DBM to initialise. 00178 * @param dim is the dimension of \a pdbm. 00179 */ 00180 void pdbm_zero(PDBM &pdbm, cindex_t dim); 00181 00182 00183 /** 00184 * Constrain a priced DBM. 00185 * 00186 * After the call, the DBM will be constrained such that the 00187 * difference between clock \a i and clock \a j is smaller than \a 00188 * constraint. 00189 * 00190 * @see dbm_constrain1 00191 * @param pdbm is a closed priced DBM of dimension \a dim. 00192 * @param dim is the dimension of \a pdbm. 00193 * @param i is a clock index. 00194 * @param j is a clock index. 00195 * @param constraint is a raw_t bound. 00196 * @pre i != j 00197 * @post The DBM is empty or closed. 00198 * @return True if and only if the result is not empty. 00199 */ 00200 bool pdbm_constrain1(PDBM &pdbm, cindex_t dim, 00201 cindex_t i, cindex_t j, raw_t constraint); 00202 00203 00204 /** 00205 * Constrain a priced DBM with multiple constraints. 00206 * 00207 * @see dbm_constraint1 00208 * @param pdbm is a closed priced DBM of dimension \a dim. 00209 * @param dim is the dimension of \a pdbm. 00210 * @param constraints is an array of \a n constraints. 00211 * @param n is the length of \a constraints. 00212 * @pre the constraints are valid 00213 * @post The DBM is empty or closed. 00214 * @return 00215 * - TRUE if the DBM is non empty + 00216 * closed non empty DBM + updated consistent rates 00217 * - or FALSE if the DBM is empty + 00218 * empty DBM + inconsistent rates 00219 */ 00220 bool pdbm_constrainN(PDBM &pdbm, cindex_t dim, 00221 const constraint_t *constraints, size_t n); 00222 00223 /** 00224 * Constrain a priced DBM to a facet (\a i, \a j). 00225 * 00226 * @param pdbm is a closed priced DBM of dimension \a dim. 00227 * @param dim is the dimension of \a pdbm. 00228 * @param i is a clock index 00229 * @param j is a clock index 00230 * @post The DBM is empty or closed. 00231 * @return 00232 * TRUE if and only if the result is non empty. 00233 */ 00234 bool pdbm_constrainToFacet(PDBM &pdbm, cindex_t dim, cindex_t i, cindex_t j); 00235 00236 00237 /** 00238 * Relation between two priced DBMs. 00239 * 00240 * @see relation_t 00241 * @param pdbm1 is a closed priced DBMs of dimension \a dim. 00242 * @param pdbm2 is a closed priced DBMs of dimension \a dim. 00243 * @param dim is the dimension of \a pdbm1 and \a pdbm2. 00244 * @return The relation between pdbm1 and pdbm2 00245 */ 00246 relation_t pdbm_relation(const PDBM pdbm1, const PDBM pdbm2, cindex_t dim); 00247 00248 /** 00249 * Relation between 2 priced dbms where one is in compressed. Notice 00250 * that in constract to dbm_relationWithMinDBM, \a buffer may not be 00251 * NULL. 00252 * 00253 * @param pdbm is a closed priced DBM of dimension \a dim. 00254 * @param dim is the dimension of \a pdbm. 00255 * @param minDBM is the compressed priced dbm. 00256 * @param buffer is a buffer of size dim*dim. 00257 * @return The relation between pdbm1 and pdbm2 00258 * @see dbm_relationWithMinDBM 00259 * @see relation_t 00260 */ 00261 relation_t pdbm_relationWithMinDBM( 00262 const PDBM pdbm, cindex_t dim, const mingraph_t minDBM, raw_t *buffer); 00263 00264 /** 00265 * Computes the infimum cost of the priced DBM. 00266 * 00267 * @param pdbm is a closed priced DBM of dimension \a dim 00268 * @param dim is the dimension of \a pdbm. 00269 * @return The infimum cost of \a pdbm. 00270 */ 00271 int32_t pdbm_getInfimum(const PDBM pdbm, cindex_t dim); 00272 00273 /** 00274 * Generates a valuation which has the infimum cost of the priced DBM. 00275 * 00276 * There is no guarantee that the valuation will be contained in the 00277 * priced DBM, but if it is not it is arbitrarily close to a valuation 00278 * that is contained in the priced DBM. 00279 * 00280 * A \a false entry in \a free indicates that the value of this clock 00281 * has already been set in \a valuation and that this clock must not 00282 * be modified. The function will only modify free clocks. 00283 * 00284 * @param pdbm is a closed priced DBM of dimension \a dim 00285 * @param dim is the dimension of \a pdbm. 00286 * @param valuation is an array of at least \a dim elements to which the 00287 * the valuation will be written. 00288 * @param free is an array of at least \a dim elements. 00289 * 00290 * @return The cost of \a valuation. 00291 * 00292 * @throw out_of_range if no valuation with the given constraints can 00293 * be found. 00294 */ 00295 int32_t pdbm_getInfimumValuation( 00296 const PDBM pdbm, cindex_t dim, int32_t *valuation, const bool *free); 00297 00298 /** 00299 * Check if a priced DBM satisfies a given constraint. 00300 * 00301 * @param pdbm is a closed priced DBM of dimension \a dim. 00302 * @param dim is the dimension of \a pdbm. 00303 * @param i,j are theindices of clocks for the clock constraint. 00304 * @param constraint is the raw_t bound. 00305 * @return TRUE if the DBM satisfies the constraint. 00306 */ 00307 bool pdbm_satisfies(const PDBM pdbm, cindex_t dim, 00308 cindex_t i, cindex_t j, raw_t constraint); 00309 00310 /** 00311 * Returns true if the priced DBM is empty. 00312 * 00313 * @param pdbm is a closed or empty priced DBM of dimension \a dim. 00314 * @param dim is the dimension of \a pdbm. 00315 * @return TRUE if and only if the priced dbm is empty. 00316 */ 00317 bool pdbm_isEmpty(const PDBM pdbm, cindex_t dim); 00318 00319 /** 00320 * Check if at least one point can delay infinitely. 00321 * 00322 * @param pdbm is a closed priced DBM of dimension \a dim. 00323 * @param dim is the dimension of \a pdbm. 00324 * @return TRUE if unbounded, FALSE otherwise. 00325 */ 00326 bool pdbm_isUnbounded(const PDBM pdbm, cindex_t dim); 00327 00328 /** 00329 * Compute a hash value for a priced DBM. 00330 * 00331 * ISSUE: canonical form needed. 00332 * 00333 * @param pdbm is a closed priced DBM of dimension \a dim. 00334 * @param dim is the dimension of \a pdbm. 00335 * @param seed is a seed for the hash function. 00336 * @return hash value. 00337 */ 00338 uint32_t pdbm_hash(const PDBM pdbm, cindex_t dim, uint32_t seed); 00339 00340 /** 00341 * Test if a point is included in the priced DBM. 00342 * 00343 * @param pdbm is a closed priced DBM of dimension \a dim. 00344 * @param dim is the dimension of \a pdbm. 00345 * @param pt is a clock valuation. 00346 * @return TRUE if \a pt satisfies the constraints of dbm. 00347 */ 00348 bool pdbm_containsInt(const PDBM pdbm, cindex_t dim, const int32_t *pt); 00349 00350 /** 00351 * Test if a point is included in the priced DBM. 00352 * 00353 * @param pdbm is a closed priced DBM of dimension \a dim. 00354 * @param dim is the dimension of \a pdbm. 00355 * @param pt is a clock valuation. 00356 * @return TRUE if \a pt satisfies the constraints of dbm. 00357 */ 00358 bool pdbm_containsDouble(const PDBM pdbm, cindex_t dim, const double *pt); 00359 00360 /** 00361 * Delay with the current delay rate. 00362 * 00363 * @param pdbm is a closed priced dbm of dimension \a dim. 00364 * @param dim is the dimension of \a pdbm. 00365 * @see pdbm_delayRate() 00366 * @post The priced DBM is closed. 00367 */ 00368 void pdbm_up(PDBM &pdbm, cindex_t dim); 00369 00370 /** 00371 * Delay with delay rate \a rate. There must be at least one clock 00372 * forming a zero cycle with the reference clock. 00373 * 00374 * @param pdbm is a closed priced dbm of dimension \a dim. 00375 * @param dim is the dimension of \a pdbm. 00376 * @param rate is the cost of delaying. 00377 * @param zero is the index of a clock forming a zero cycle with the 00378 * reference clock. 00379 * @post The priced DBM is closed. 00380 */ 00381 void pdbm_upZero(PDBM &pdbm, cindex_t dim, uint32_t rate, cindex_t zero); 00382 00383 /** 00384 * Updates \a clock to \a value. This is only legitimate if the 00385 * current rate of \a clock is zero. 00386 * 00387 * @param pdbm is a closed priced dbm of dimension \a dim. 00388 * @param dim is the dimension of \a pdbm. 00389 * @param clock is the index of the clock to reset. 00390 * @param value is the value to which to set \a clock. 00391 * @pre pdbm_getRate(pdbm, dim, clock) == 0 00392 * @post The priced DBM is closed. 00393 */ 00394 void pdbm_updateValue(PDBM &pdbm, cindex_t dim, cindex_t clock, uint32_t value); 00395 00396 /** 00397 * Updates \a clock to \a value. This is only legitimate if the clock 00398 * forms a zero cycle with another clock (possibly the reference 00399 * clock). 00400 * 00401 * @param pdbm is a closed priced dbm of dimension \a dim. 00402 * @param dim is the dimension of \a pdbm. 00403 * @param clock is the index of the clock to reset. 00404 * @param value is the value to which to set \a clock. 00405 * @param zero is a clock (possibly zero) forming a zero cycle 00406 * with \a clock. 00407 * @post The priced DBM is closed. 00408 * @post pdbm_getRate(pdbm, dim, clock) == 0 00409 */ 00410 void pdbm_updateValueZero(PDBM &pdbm, cindex_t dim, 00411 cindex_t clock, uint32_t value, cindex_t zero); 00412 00413 /** 00414 * Unfinished extrapolation function. 00415 * 00416 * @see dbm_extrapolateMaxBounds 00417 */ 00418 void pdbm_extrapolateMaxBounds( 00419 PDBM &pdbm, cindex_t dim, int32_t *max); 00420 00421 /** 00422 * Unfinished extrapolation function. 00423 * 00424 * @see dbm_diagonalExtrapolateMaxBounds 00425 */ 00426 void pdbm_diagonalExtrapolateMaxBounds( 00427 PDBM &pdbm, cindex_t dim, int32_t *max); 00428 00429 /** 00430 * Extrapolate a priced zone. The extrapolation is based on a lower 00431 * and an upper bound for each clock. The output zone simulates the 00432 * input zone. 00433 * 00434 * The implementation is not finished. 00435 * 00436 * @param pdbm is a closed priced DBM of dimension \a dim. 00437 * @param dim is the dimension of \a pdbm. 00438 * @param lower is an array of lower bounds for each clock. 00439 * @param upper is an array of upper bounds for each clock. 00440 * @pre lower[0] = upper[0] = 0 00441 * @post The priced DBM is closed. 00442 * @see dbm_diagonalExtrapolateLUBounds 00443 */ 00444 void pdbm_diagonalExtrapolateLUBounds( 00445 PDBM &pdbm, cindex_t dim, int32_t *lower, int32_t *upper); 00446 00447 /** 00448 * Increments the cost of each point in a priced DBM by \a value. 00449 * 00450 * @param pdbm is a closed priced DBM of dimension \a dim. 00451 * @param dim is the dimension of \a pdbm. 00452 * @param value is the amount with which to increase the cost. 00453 * @post The priced DBM is closed. 00454 * @pre value >= 0 00455 */ 00456 void pdbm_incrementCost(PDBM &pdbm, cindex_t dim, int32_t value); 00457 00458 /** 00459 * Compute the closure of a priced DBM. This function is only relevant 00460 * if the DBM has been modified with \c pdbm_setBound(). 00461 * 00462 * @param pdbm is a priced DBM of dimension \a dim. 00463 * @param dim is the dimension of \a pdbm. 00464 * @post The priced DBM is closed or empty. 00465 * @see pdbm_setBound 00466 */ 00467 void pdbm_close(PDBM &pdbm, cindex_t dim); 00468 00469 /** 00470 * Analyze a priced DBM for its minimal graph representation. Computes 00471 * the smallest number of constraints needed to represent the same 00472 * zone. 00473 * 00474 * The result is returned as a bit matrix, where each bit indicates 00475 * whether that entry of the DBM is relevant. I.e. if the bit \f$ i 00476 * \cdot dim + j\f$ is set, then the constraint \f$(i,j)\f$ of \a dbm 00477 * is needed. 00478 * 00479 * @param pdbm is a closed priced DBM of dimension \a dim. 00480 * @param dim is the dimension of \a pdbm. 00481 * @param bitMatrix is bit matrix of size dim*dim 00482 * @return The number of bits marked one in \a bitMatrix. 00483 */ 00484 uint32_t pdbm_analyzeForMinDBM( 00485 const PDBM pdbm, cindex_t dim, uint32_t *bitMatrix); 00486 00487 00488 /** 00489 * Convert the DBM to a more compact representation. 00490 * 00491 * The API supports allocation of larger data structures than needed 00492 * for the actual zone representation. When the \a offset argument is 00493 * bigger than zero, \a offset extra integers are allocated and the 00494 * zone is written with the given offset. Thus when \c 00495 * int32_t[data_size] is needed to represent the reduced zone, an \c 00496 * int32_t array of size \c offset+data_size is allocated. The first 00497 * \a offset elements can be used by the caller. It is important to 00498 * notice that the other functions typically expect a pointer to the 00499 * actual zone data and not to the beginning of the allocated 00500 * block. Thus in the following piece of code, most functions expect 00501 * \c mg and not \c memory: 00502 * 00503 * \code 00504 * int32_t *memory = dbm_writeToMinDBMWithOffset(...); 00505 * mingraph_t mg = &memory[offset]; 00506 * \endcode 00507 * 00508 * @param pdbm is a closed priced DBM of dimension \a dim. 00509 * @param dim is the dimension of \a pdbm. 00510 * @param minimizeGraph when true, try to use minimal constraint form. 00511 * @param tryConstraints16 when true, try to save constraints on 16 bits. 00512 * @param c_alloc is a C allocator wrapper. 00513 * @param offset is the offset for allocation. 00514 * @return The converted priced DBM. The first \a offset integers are unused. 00515 * @pre allocFunction allocates memory in integer units 00516 */ 00517 int32_t *pdbm_writeToMinDBMWithOffset( 00518 const PDBM pdbm, cindex_t dim, bool minimizeGraph, bool tryConstraints16, 00519 allocator_t c_alloc, uint32_t offset); 00520 00521 00522 /** 00523 * Uncompresses a compressed priced DBM. The compressed priced DBM \a 00524 * src is written to \a dst. The destination does not need to 00525 * initialised beforehand. The dimension \a dim must match the 00526 * dimension of the compressed priced DBM. 00527 * 00528 * @param dst is a memory area of size pdbm_size(dim). 00529 * @param dim is the dimension of the priced DBM. 00530 * @param src is the compressed priced DBM. 00531 * @post dst is a closed priced DBM. 00532 */ 00533 void pdbm_readFromMinDBM(PDBM &dst, cindex_t dim, mingraph_t src); 00534 00535 /** 00536 * Finds a clock that is on a zero cycle with \a clock. Returns TRUE 00537 * if and only if such a clock is found. If multiple clocks are on a 00538 * zero cycle with \a clock, then the clock with the smallest index is 00539 * returned. 00540 * 00541 * This function is equivalent to calling \c pdbm_findNextZeroCyle 00542 * with \a output initialised to zero. 00543 * 00544 * @param pdbm is a closed priced DBM of dimension \a dim. 00545 * @param dim is the dimension of \a pdbm. 00546 * @param clock is the index of a clock. 00547 * @param out is where the clock found is written. 00548 * @return TRUE if and only if a clock is found. 00549 */ 00550 bool pdbm_findZeroCycle(const PDBM pdbm, cindex_t dim, cindex_t clock, cindex_t *out); 00551 00552 /** 00553 * Finds a clock that is on a zero cycle with \a clock. Returns TRUE 00554 * if and only if such a clock is found. Only clocks with a value 00555 * equal to or greater than the existing value of \a output are 00556 * considered. If multiple clocks are on a zero cycle with \a clock, 00557 * then the clock with the smallest index is returned. 00558 * 00559 * @param pdbm is a closed priced DBM of dimension \a dim. 00560 * @param dim is the dimension of \a pdbm. 00561 * @param clock is the index of a clock. 00562 * @param out is where the clock found is written. 00563 * @return TRUE if and only if a clock is found. 00564 */ 00565 bool pdbm_findNextZeroCycle(const PDBM pdbm, cindex_t dim, cindex_t x, cindex_t *out); 00566 00567 /** 00568 * Returns the slope of the cost plane along the delay trajectory. 00569 * 00570 * @param pdbm is a closed priced DBM of dimension \a dim. 00571 * @param dim is the dimension of \a pdbm. 00572 */ 00573 int32_t pdbm_getSlopeOfDelayTrajectory(const PDBM pdbm, cindex_t dim); 00574 00575 /** 00576 * Returns the rate (coefficient of the hyperplane) of \a clock. 00577 * 00578 * @param pdbm is a closed priced DBM of dimension \a dim. 00579 * @param dim is the dimension of \a pdbm. 00580 * @param clock is the clock for which to return the coefficient. 00581 * @return the rate of \a clock. 00582 */ 00583 int32_t pdbm_getRate(const PDBM pdbm, cindex_t dim, cindex_t clock); 00584 00585 const int32_t *pdbm_getRates(const PDBM pdbm, cindex_t dim); 00586 00587 /** 00588 * Returns the cost of the offset point. 00589 * 00590 * @param pdbm is a closed priced DBM of dimension \a dim. 00591 * @param dim is the dimension of \a pdbm. 00592 */ 00593 uint32_t pdbm_getCostAtOffset(const PDBM pdbm, cindex_t dim); 00594 00595 /** 00596 * Sets the cost at the offset point. 00597 * 00598 * Notice that the value must be large enough such that the infimum 00599 * cost of the priced DBM is not negative. Temporary inconsistencies 00600 * are allowed as long as no operations are performed on the priced 00601 * DBM. 00602 * 00603 * @param pdbm is a closed priced DBM of dimension \a dim. 00604 * @param dim is the dimension of \a pdbm. 00605 * @param value is the new cost of the offset point. 00606 */ 00607 void pdbm_setCostAtOffset(PDBM &pdbm, cindex_t dim, uint32_t value); 00608 00609 /** 00610 * Returns true if the DBM is valid. Useful for debugging. 00611 * 00612 * @param pdbm is a priced DBM of dimension \a dim. 00613 * @param dim is the dimension of \a pdbm. 00614 */ 00615 bool pdbm_isValid(const PDBM pdbm, cindex_t dim); 00616 00617 /** 00618 * Computes the lower facets of a priced DBM relative to \a clock. As 00619 * a side-effect, all lower facets relative to \a clock are converted 00620 * to weak facets. 00621 * 00622 * @param pdbm is a closed priced DBM of dimension \a dim. 00623 * @param dim is the dimension of \a pdbm. 00624 * @param clock is the clock for which to return the lower facets 00625 * @param facets is an array of at least \a dim elements to which 00626 * the lower facets will be written. 00627 * @return The number of facets written to \a facets. 00628 */ 00629 uint32_t pdbm_getLowerRelativeFacets( 00630 PDBM &pdbm, cindex_t dim, cindex_t clock, cindex_t *facets); 00631 00632 /** 00633 * Computes the upper facets of a priced DBM relative to \a clock. As 00634 * a side-effect, all upper facets relative to \a clock are converted 00635 * to weak facets. 00636 * 00637 * @param pdbm is a closed priced DBM of dimension \a dim. 00638 * @param dim is the dimension of \a pdbm. 00639 * @param clock is the clock for which to return the upper facets 00640 * @param facets is an array of at least \a dim elements to which 00641 * the upper facets will be written. 00642 * @return The number of facets written to \a facets. 00643 */ 00644 uint32_t pdbm_getUpperRelativeFacets( 00645 PDBM &pdbm, cindex_t dim, cindex_t clock, cindex_t *facets); 00646 00647 /** 00648 * Computes the lower facets of a priced DBM. 00649 * 00650 * @param pdbm is a closed priced DBM of dimension \a dim. 00651 * @param dim is the dimension of \a pdbm. 00652 * @param facets is an array of at least \a dim elements to which the 00653 * lower facets will be written. 00654 * @return The number of facets written to \a facets. 00655 */ 00656 uint32_t pdbm_getLowerFacets(PDBM &pdbm, cindex_t dim, cindex_t *facets); 00657 00658 /** 00659 * Computes the upper facets of a priced DBM. 00660 * 00661 * @param pdbm is a closed priced DBM of dimension \a dim. 00662 * @param dim is the dimension of \a pdbm. 00663 * @param facets is an array of at least \a dim elements to which the 00664 * upper facets will be written. 00665 * @return The number of facets written to \a facets. 00666 */ 00667 uint32_t pdbm_getUpperFacets(PDBM &pdbm, cindex_t dim, cindex_t *facets); 00668 00669 /** 00670 * Computes the cost of a valuation in a priced DBM. 00671 * 00672 * @param pdbm is a closed priced DBM of dimension \a dim. 00673 * @param dim is the dimension of \a pdbm. 00674 * @param valuation is a valuation in \a pdbm. 00675 * @pre pdbm_containsInt(pdbm, dim, valuation) 00676 * @return The cost of \a valuation in \a pdbm. 00677 */ 00678 int32_t pdbm_getCostOfValuation(const PDBM pdbm, cindex_t dim, const int32_t *valuation); 00679 00680 /** 00681 * Makes all strong constraints of a priced DBM weak. 00682 * 00683 * @param pdbm is a closed priced DBM of dimension \a dim. 00684 * @param dim is the dimension of \a pdbm. 00685 * @post The priced DBM is closed. 00686 */ 00687 void pdbm_relax(PDBM &pdbm, cindex_t dim); 00688 00689 /** 00690 * Computes the offset point of a priced DBM. 00691 * 00692 * @param pdbm is a closed priced DBM of dimension \a dim. 00693 * @param dim is the dimension of \a pdbm. 00694 * @param valuation is an array of at least \a dim elements to which the 00695 * offset point is written. 00696 */ 00697 void pdbm_getOffset(const PDBM pdbm, cindex_t dim, int32_t *valuation); 00698 00699 /** 00700 * Sets a coefficient of the hyperplane of a priced DBM. 00701 * 00702 * @param pdbm is a closed priced DBM of dimension \a dim. 00703 * @param dim is the dimension of \a pdbm. 00704 * @param clock is the index of a clock for which to set the coefficient. 00705 * @param rate is the coefficient. 00706 */ 00707 void pdbm_setRate(PDBM &pdbm, cindex_t dim, cindex_t clock, int32_t rate); 00708 00709 /** 00710 * Returns the inner matrix of a priced DBM. The matrix can be 00711 * modified as long as \c pdbm_close() is called before any other 00712 * operations are performed on the priced DBM. 00713 * 00714 * @param pdbm is a priced DBM of dimension \a dim. 00715 * @param dim is the dimension of \a pdbm. 00716 */ 00717 raw_t *pdbm_getMutableMatrix(PDBM &pdbm, cindex_t dim); 00718 00719 /** 00720 * Returns the inner matrix of a priced DBM. The matrix is read-only. 00721 * 00722 * @param pdbm is a closed priced DBM of dimension \a dim. 00723 * @param dim is the dimension of \a pdbm. 00724 */ 00725 const raw_t *pdbm_getMatrix(const PDBM pdbm, cindex_t dim); 00726 00727 /** 00728 * Frees a clock of a priced DBM. 00729 * 00730 * @param pdbm is a closed priced DBM of dimension \a dim. 00731 * @param dim is the dimension of \a pdbm. 00732 * @param clock is the index of the clock to free. 00733 */ 00734 void pdbm_freeClock(PDBM &pdbm, cindex_t dim, cindex_t clock); 00735 00736 00737 /** 00738 * Prints a priced DBM to a stream. 00739 * 00740 * @param f is the stream to print to. 00741 * @param pdbm is a closed priced DBM of dimension \a dim. 00742 * @param dim is the dimension of \a pdbm. 00743 * @see dbm_print 00744 */ 00745 void pdbm_print(FILE *f, const PDBM pdbm, cindex_t dim); 00746 00747 /** 00748 * Implementation of the free up operation for priced DBMs. 00749 * 00750 * @param pdbm is a closed priced DBM of dimension \a dim. 00751 * @param dim is the dimension of \a pdbm. 00752 * @param index is an index of a clock. 00753 * @see dbm_freeUp 00754 */ 00755 void pdbm_freeUp(PDBM &pdbm, cindex_t dim, cindex_t index); 00756 00757 /** 00758 * Implementation of the free down operation for priced DBMs. 00759 * 00760 * @param pdbm is a closed priced DBM of dimension \a dim. 00761 * @param dim is the dimension of \a pdbm. 00762 * @param index is an index of a clock. * 00763 * @see dbm_freeDown 00764 */ 00765 void pdbm_freeDown(PDBM &pdbm, cindex_t dim, cindex_t index); 00766 00767 /** 00768 * Checks whether a priced DBM is in normal form. 00769 * 00770 * @param pdbm is a closed priced DBM of dimension \a dim. 00771 * @param dim is the dimension of \a pdbm. 00772 */ 00773 bool pdbm_hasNormalForm(PDBM pdbm, cindex_t dim); 00774 00775 /** 00776 * Brings a priced DBM into normal form. 00777 * 00778 * @param pdbm is a closed priced DBM of dimension \a dim. 00779 * @param dim is the dimension of \a pdbm. 00780 */ 00781 void pdbm_normalise(PDBM pdbm, cindex_t dim); 00782 00783 /////////////////////////////////////////////////////////////////////////// 00784 00785 00786 00787 00788 00789 #endif /* INCLUDE_DBM_PRICED_H */ 00790