diff --git a/configure.ac b/configure.ac index 16ac4d11..3b282790 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ ## AC_PREREQ(2.60) AC_PREREQ(2.59) -AC_INIT(MEDDLY, 0.17.6, [asminer@iastate.edu], meddly, [https://asminer.github.io/meddly/]) +AC_INIT(MEDDLY, 0.17.7, [asminer@iastate.edu], meddly, [https://asminer.github.io/meddly/]) AM_INIT_AUTOMAKE([-Wall foreign parallel-tests color-tests subdir-objects]) # Allow silent builds, and make it the default, if we can: m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) diff --git a/developers/Release.sh b/developers/Release.sh index f501ed33..93e38cf2 100755 --- a/developers/Release.sh +++ b/developers/Release.sh @@ -32,7 +32,7 @@ update_defines() local ddate=`date +"%m/%d/%Y"` local versid=`tr '.' '_' <<< "$1"` mv -f ../$DEFFILE ../$DEFFILE.old - sed "1,/=======/s/$versid.*/$versid \"$ddate\"/" ../$DEFFILE.old > ../$DEFFILE + sed "1,/=======/s|$versid.*|$versid \"$ddate\"|" ../$DEFFILE.old > ../$DEFFILE git add ../$DEFFILE } diff --git a/src/defines.h b/src/defines.h index e69de29b..387af442 100644 --- a/src/defines.h +++ b/src/defines.h @@ -0,0 +1,212 @@ +/* + Meddly: Multi-terminal and Edge-valued Decision Diagram LibrarY. + Copyright (C) 2009, Iowa State University Research Foundation, Inc. + + This library is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library. If not, see . +*/ + +#ifndef MEDDLY_DEFINES_H +#define MEDDLY_DEFINES_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +// #define ALLOW_DEPRECATED_0_17_2 "11/11/2023" +// #define ALLOW_DEPRECATED_0_17_3 "12/03/2023" +// #define ALLOW_DEPRECATED_0_17_4 "12/19/2023" +// #define ALLOW_DEPRECATED_0_17_5 "04/05/2024" +#define ALLOW_DEPRECATED_0_17_6 "11/11/2024" +#define ALLOW_DEPRECATED_0_17_7 + +// ================================================================== +// ^ This line is important for the release script, don't remove it + + +#define REFCOUNTS_ON + +// #define DEBUG_CLEANUP +// #define DEBUG_SLOW +// #define TRACE_ALL_OPS +// #define DEBUG_READ_DD + +// Turn off extensible nodes for now +// #define ALLOW_EXTENSIBLE + +#include + +// Handy Constants + +namespace MEDDLY { + // const int INF = std::numeric_limits::max(); + // const float NAN = std::numeric_limits::quiet_NaN(); + template + inline T Inf() { return std::numeric_limits::max(); } + inline float Nan() { return std::numeric_limits::quiet_NaN(); } + // inline bool isNan(float t) { return t == Nan(); } + // inline bool isNan(int t) { return false; } + + // Handy Macros + + /// Standard MAX "macro". + template inline T MAX(T X,T Y) { return ((X>Y)?X:Y); } + /// Standard MIN "macro". + template inline T MIN(T X,T Y) { return ((X inline T ABS(T X) { return ((X<0)?(-X):(X)); } + /// SWAP "macro". + template inline void SWAP(T &x, T &y) { T tmp=x; x=y; y=tmp; } + /// POSITIVE "macro". + template inline bool POSITIVE(T X) { return (X>0) ? true : false; } + + /// Update a maximum + template inline void UPDATEMAX(T &X, T Y) { if (Y > X) X = Y; } + + // Number of digits + template + inline unsigned digits(T a) { + unsigned d; + for (d=1; a; d++) { a /= 10; } + return d; + } + + /// Get the "top level" of an operation. Works for primed & unprimed. + inline int topLevel(int k1, int k2) { + if (ABS(k1) > ABS(k2)) return k1; + if (ABS(k2) > ABS(k1)) return k2; + return MAX(k1, k2); + } + + /// Determine if level k1 is above k2. Works for primed & unprimed. + inline bool isLevelAbove(int k1, int k2) { + if (ABS(k1) > ABS(k2)) return true; + if (ABS(k2) > ABS(k1)) return false; + return k1 > k2; + } + +} + +/* + + There are now two modes of code generation: + "DEVELOPMENT_CODE" and "RELEASE_CODE". + + If "DEVELOPMENT_CODE" is defined (usually done in the makefile) then + debugging macros and assertions will be turned on. Otherwise we assume + that we have "RELEASE_CODE" and they are turned off. + + Macros useful for debugging "development code" that are turned off + for release code (for speed): + + MEDDLY_DCASSERT() + MEDDLY_CHECK_RANGE(low, x, high+1) + +*/ + +#ifdef DEBUG_PRINTS_ON +#define DEBUG_HASH_H +#define DEBUG_HASH_EXPAND_H +#define DEBUG_MDD_HASH_H +#define DEBUG_MDD_HASH_EXPAND_H +#define TRACE_REDUCE +#define MEMORY_TRACE +#endif + +// Safe typecasting for development code; fast casting otherwise + +#ifdef DEVELOPMENT_CODE +#define smart_cast dynamic_cast +#else +#define smart_cast static_cast +#endif + + +// Flags for development version only. Significant reduction in performance. +#ifdef DEVELOPMENT_CODE +#define RANGE_CHECK_ON +#define DCASSERTS_ON +#endif + +// #define TRACK_DELETIONS +// #define TRACK_CACHECOUNT +// #define TRACK_UNREACHABLE_NODES + + +// Use this for assertions that will fail only when your +// code is wrong. Handy for debugging. +#ifdef DCASSERTS_ON +#include +#define MEDDLY_DCASSERT(X) assert(X) +#else +#define MEDDLY_DCASSERT(X) +#endif + +// Use this for range checking assertions that should succeed. +#ifdef RANGE_CHECK_ON +#include +#include +#endif +namespace MEDDLY { + template + inline void CHECK_RANGE(const char* fn, unsigned ln, + INT min, INT value, INT max) + { +#ifdef RANGE_CHECK_ON + if (value < min || value >= max ) { + std::cerr << "Check range at " << fn << " line " << ln; + std::cerr << " failed:\n min: " << min; + std::cerr << "\n val: " << value; + std::cerr << "\n max: " << max << '\n'; + assert(false); + } +#endif + } +} + + +// +// Typedefs and constants +// + +namespace MEDDLY { + + /** Handles for nodes. + This should be either int or long, and effectively limits + the number of possible nodes per forest. + As an int, we get 2^32-1 possible nodes per forest, + which should be enough for most applications. + As a long on a 64-bit machine, we get 2^64-1 possible nodes + per forest, at the expense of nearly doubling the memory used. + This also specifies the incoming count range for each node. + */ + typedef int node_handle; + + /** Handles for relation nodes. + TBD: can we just use node_handle everywhere? + */ + typedef int rel_node_handle; + + /** Node addresses. + This is used for internal storage of a node, + and should probably not be changed. + The typedef is given simply to clarify the code + (hopefully :^) + */ + typedef unsigned long node_address; + +}; + + +#endif // #include guard +