Merge BuDDy 2.3.

* examples/calculator/, examples/internal/: Were renamed as ...
* examples/bddcalc/, examples/bddtest/: ... these.
* configure.ac: Adjust version and output Makefiles.
* examples/Makefile.am (SUBDIRS): Adjust subdir renaming.
* examples/cmilner/milner.c, examples/fdd/statespace.cxx: Were
renamed as ...
* examples/cmilner/cmilner.c, examples/fdd/fdd.cxx: ... these.
* examples/cmilner/Makefile.am, examples/fdd/Makefile.am: Adjust
accordingly.
* src/Makefile.am (AM_CPPFLAGS): Define VERSION.
This commit is contained in:
Alexandre Duret-Lutz 2004-06-28 15:22:11 +00:00
parent 805b6fb70b
commit aa4a582f1b
27 changed files with 130 additions and 796 deletions

View file

@ -1,3 +1,17 @@
2004-06-28 Alexandre Duret-Lutz <adl@src.lip6.fr>
Merge BuDDy 2.3.
* examples/calculator/, examples/internal/: Were renamed as ...
* examples/bddcalc/, examples/bddtest/: ... these.
* configure.ac: Adjust version and output Makefiles.
* examples/Makefile.am (SUBDIRS): Adjust subdir renaming.
* examples/cmilner/milner.c, examples/fdd/statespace.cxx: Were
renamed as ...
* examples/cmilner/cmilner.c, examples/fdd/fdd.cxx: ... these.
* examples/cmilner/Makefile.am, examples/fdd/Makefile.am: Adjust
accordingly.
* src/Makefile.am (AM_CPPFLAGS): Define VERSION.
2004-01-07 Alexandre Duret-Lutz <adl@src.lip6.fr>
* src/bddop.c (bdd_support): Free supportSet if it needs to be

View file

@ -1,7 +1,7 @@
==========================================================================
*** BuDDy ***
Binary Decision Diagrams
Library Package v2.2a
Library Package v2.3a
--------------------------------------------------------------------------
Copyright (C) 1996-2002 by Jorn Lind-Nielsen
All rights reserved
@ -32,12 +32,27 @@
==========================================================================
---------------------------------------------------------------------
--- PREFACE --------------------------------------------------------
---------------------------------------------------------------------
BuDDy was originally developed by Jorn Lind-Nielsen as a part of his
Phd thesis.
After using BuDDy as a BDD library for long time ( while getting some
support from Jorn through Email ), I have been suggested by Jorn to take
ownership of the project and move it to SourceForge.
I invite all users who are interested to participate in the development
to contact me. ( I always have desired tasks / features awaiting... )
I hope that BuDDy will prosper under my management.
Haim Cohen
haimcohen2002@hotmail.com
---------------------------------------------------------------------
--- REQUIREMENTS ----------------------------------------------------
---------------------------------------------------------------------
* A (not to old) C++ compiler
* A (not too old) C++ compiler. I use g++ 3.3.3
* A machine that supports 32 bit integers
@ -54,10 +69,10 @@ The following commands should build and install the library.
`./configure' accepts many arguments to tune your installation.
The following options are noteworthy:
--includedir=/somewhere/include
--includedir=/somewhere/include
Specify where header files will be installed.
--libdir=/somewhere/lib
--libdir=/somewhere/lib
Specify where libraries will be installed.
--disable-shared
@ -70,7 +85,7 @@ The following options are noteworthy:
Count number of fundamental variable swaps (for debugging)
--enable-cache-stats
Gather statistical information about operator and unique node
Gather statistical information about operator and unique node
caching (for debugging)
Run `./configure --help' for a complete listing, and see
@ -89,8 +104,8 @@ could be:
g++ -I/usr/local/include myfile.cc -o myfile -L/usr/local/lib -lbdd
Your machine may be setup to use the above directories auto-
matically, so you might be able to do:
Your machine may be setup to use the above directories automatically,
so you might be able to do:
g++ myfile.cc -o myfile -lbdd
@ -102,41 +117,17 @@ matically, so you might be able to do:
src: All files needed for the BuDDy package.
examples: Example files
fdd: An example of use of the FDD interface.
calculator: An example of a BDD calculator. Uses reordering.
bddcalc: An example of a BDD calculator. Uses reordering.
adder: Construction of a N-bit adder. Uses reordering.
milner: A calculation of the reachable statespace for Milner's
milner: A calculation of the reachable state space for Milner's
scheduler. C++.
cmilner: As above but purely in ANSI-C.
queen: Solution to the N-queen chess problem.
solitare: Solution to a solitare game.
money: Solution to the send-more-money problem (bvec demo).
internal: Some internal regression tests.
bddtest : Some internal tests.
doc: Documentation.
buddy.ps: Package documentation.
bddnotes.ps: BDD introduction notes.
tools: Tools used during the build.
m4: A couple of macros used to build ./configure.
---------------------------------------------------------------------
--- FEEDBACK --------------------------------------------------------
---------------------------------------------------------------------
Please do not hesitate to send any questions or bug reports to:
Jorn Lind-Nielsen: buddy@itu.dk
(or maybe jorn_lind_nielsen@hotmail.com or jln@fjeldgruppen.dk)
It may take some time to get an answer since BuDDy do not have that
much focus any more - but I'll try to give a reasonable answer
in (finite) time.
New updates and other info can be found at:
http://www.it-c.dk/research/buddy/
(or http://www.itu.dk/research/buddy)
Hope you find some use for this software
Jorn Lind-Nielsen

View file

@ -1,5 +1,5 @@
AC_PREREQ([2.57])
AC_INIT([buddy], [2.2a])
AC_INIT([buddy], [2.3a])
AC_CONFIG_AUX_DIR([tools])
AM_INIT_AUTOMAKE([foreign nostdinc no-define 1.7.3])
@ -22,10 +22,10 @@ AC_CONFIG_FILES([
doc/Makefile
examples/Makefile
examples/adder/Makefile
examples/calculator/Makefile
examples/bddcalc/Makefile
examples/bddtest/Makefile
examples/cmilner/Makefile
examples/fdd/Makefile
examples/internal/Makefile
examples/milner/Makefile
examples/money/Makefile
examples/queen/Makefile

View file

@ -1 +1 @@
EXTRA_DIST = bddnotes.ps buddy.pdf tech.txt
EXTRA_DIST = bddnotes.ps buddy.pdf

View file

@ -1,186 +0,0 @@
****************************************************************************
How to create your own internal BDD functions.
****************************************************************************
PLEASE NOTE
That interrupting variable reordering has been introduced after this document was written.
===[ Functions that do not change or produce new BDDs ]=====================
I'll do this by example. Take "bdd_satcount" that counts the number of
satisfying assignments that makes a BDD true.
Almost all functions consists of some introduction followed by a
recursion through the BDD.
* Use the type BDD for all references (numbers) to BDD nodes.
* External BDD variables used internally in the package are
defined in "kernel.h"
* Macros for reading BDD nodes are:
LEVEL(r)
LOW(r)
HIGH(r)
ISCONST(r) => true if r is one of the terminals
double bdd_satcount(BDD r)
{
double size=1;
int n;
CHECKa(r, 0.0); /* CHECK for valid nodes - defined in kernel.h */
miscid = CACHEID_SATCOU; /* Setup global variables. This is
used extensively instead of passing
arguments to the recursive functions,
for faster recursive calls */
for (n=0 ; n<LEVEL(r) ; n++) /* Setup whatever is needed for the */
size *= 2; /* recursion */
return size * bdd_satcount_rec(r); /* Do the recurison */
}
Cache tables are used for storing intermidiate results when doing BDD
operations. These are defined as static in the top of bddop.c (the
code is in cache.c) and they should be setup, cleared and delete at
the top of bddop.c in the functions bdd_operator_init,
bdd_operator_done, bdd_operator_reset.
static double bdd_satcount_rec(BDD root)
{
BddCacheData *entry; /* Entry pointer in the cache */
BddNode *node;
double size, s;
int m;
if (ISCONST(root)) /* Check for the constant terminals */
return root;
/* Lookup entry in the cache table used for this function */
entry = BddCache_lookup(&misccache, SATCOUHASH(root));
if (entry->a == root && entry->c == miscid)
return entry->r.dres;
/* Do whatever calculations are needed */
size = 0;
s = 1;
for (m=LEVEL(root)+1 ; m<LEVEL(LOW(root)) ; m++)
s *= 2;
size += s * bdd_satcount_rec(LOW(root)); /* Recurse on low part */
s = 1;
for (m=LEVEL(root)+1 ; m<LEVEL(HIGH(root)) ; m++)
s *= 2;
size += s * bdd_satcount_rec(HIGH(root)); /* Recurse on high part */
/* Insert result in cache table */
entry->a = root;
entry->c = miscid;
entry->r.dres = size;
return size; /* Return result */
}
===[ Functions that produces new BDDs ]=====================================
Functions that produces BDD nodes must take great care to avoid
loosing intermidiate nodes when automatic garbage collections
occur. This is doneby stacking each intermidiate result until they are no more used. This stack is check by the garbage collector.
Macros for accessing the stack:
INITREF: Reset the stack
PUSHREF(n): Push the node 'n' on the stack
READREF(p): Read 'p' positions down the stack
POPREF(p): Pop 'p' nodes off the stack.
Again I'll illustrate this with an example - the NOT operator.
BDD bdd_not(BDD r)
{
int res;
CHECKa(r, bddfalse); /* Validate arguments */
INITREF; /* Important! resets the stack */
res = not_rec(r); /* Recurse */
checkreorder(res); /* Check to see if a reordering was called for */
return res; /* Return result */
}
static BDD not_rec(BDD r)
{
BddCacheData *entry; /* Cache entry pointer */
BDD res;
if (ISZERO(r)) /* Check constant terminals */
return BDDONE;
if (ISONE(r))
return BDDZERO;
/* Lookup in cache */
entry = BddCache_lookup(&applycache, NOTHASH(r));
if (entry->a == r && entry->c == bddop_not)
return entry->r.res;
/* Recurse AND push result on the reference stack */
PUSHREF( not_rec(LOW(r)) );
PUSHREF( not_rec(HIGH(r)) );
/* Create a new BDD node */
res = bdd_makenode(LEVEL(r), READREF(2), READREF(1));
/* Pop result off the stack */
POPREF(2);
/* Insert in cache */
entry->a = r;
entry->c = bddop_not;
entry->r.res = res;
/* Return the result */
return res;
}
===[ Documentation ]========================================================
ALL entries visible to the user should be documentet by an commented
section like the one shown here, placed right before the code.
Each doc. entry consist of a keyword followed by {* ... text
... *}. The entries are:
NAME: Name of the function.
SECTION: Which part to place the documentation in.
SHORT: One line description of the code.
PROTO: The exact prototype.
DESCR: Multiline description of the code.
ALSO: Other relevant stuff.
RETURN: The returned value.
/*
NAME {* bdd\_satcount *}
SECTION {* info *}
SHORT {* Calculates the number of satisfying variable assignments *}
PROTO {* double bdd_satcount(BDD r) *}
DESCR {* Calculates how many possible variable assignments there exists
such that {\tt r} is satisfied, taking all defined variables
into account. *}
ALSO {* bdd\_satone, bdd\_fullsatone, bdd\_satcountln *}
RETURN {* The number of possible assignments. *}
*/

View file

@ -1,11 +1,10 @@
SUBDIRS = \
adder \
calculator \
bddcalc \
bddtest \
cmilner \
fdd \
internal \
milner \
money \
queen \
solitare

View file

@ -27,7 +27,7 @@ bdd *xout;
void build_adder(void)
{
int n;
for (n=0 ; n<N ; n++)
{
if (n > 0)
@ -48,9 +48,10 @@ void build_adder(void)
int main(int argc, char **argv)
{
using namespace std ;
int method=BDD_REORDER_NONE;
int n;
if(argc < 2 || argc > 3)
{
cout << "usage: adder N R\n";
@ -59,7 +60,7 @@ int main(int argc, char **argv)
cout << " in this case 'adder' starts with a worst case ordering\n";
exit(1);
}
N = atoi(argv[1]);
if (N <= 0)
{
@ -90,17 +91,15 @@ int main(int argc, char **argv)
if (strcmp(argv[2], "rand") == 0)
method = BDD_REORDER_RANDOM;
}
long c0 = clock();
bdd_init(500,1000);
bdd_setvarnum(2*N);
ainp = new bdd[N];
binp = new bdd[N];
co = new bdd[N];
xout = new bdd[N];
for (n=0 ; n<N ; n++)
{
if (method == BDD_REORDER_NONE)
@ -124,28 +123,22 @@ int main(int argc, char **argv)
//bdd_autoreorder(method);
//bdd_reorder_verbose(2);
build_adder();
if (method != BDD_REORDER_NONE)
{
cout << "Sizes before reordering:\n";
for (n=0 ; n<N ; n++)
cout << "Out[" << n << "]: " << bdd_nodecount(xout[n]) << " nodes\n";
long c1 = clock();
cout << (float)(c1-c0)/(float)(CLOCKS_PER_SEC) << " sec.\n";
bdd_reorder(method);
cout << "Sizes after reordering:\n";
}
else
cout << "Sizes:\n";
long c1 = clock();
for (n=0 ; n<N ; n++)
cout << "Out[" << n << "]: " << bdd_nodecount(xout[n]) << " nodes\n";
cout << (float)(c1-c0)/(float)(CLOCKS_PER_SEC) << " sec.\n";
}
@ -155,7 +148,7 @@ int main(int argc, char **argv)
bdd setval(int val, int v)
{
bdd x = bddtrue;
for (int n=0 ; n<N ; n++)
{
if (val & 1)
@ -187,7 +180,7 @@ int test_vector(bdd av, bdd bv, int a, int b)
for (int n=0 ; n<N ; n++)
{
bdd resv = av & bv & xout[n];
if (resv == bddfalse && (res & 1) || resv != bddfalse && !(res & 1))
return 0;
@ -201,7 +194,7 @@ int test_vector(bdd av, bdd bv, int a, int b)
int test_adder(void)
{
int m = 1 << N;
for (int a=0 ; a<m ; a++)
{
for (int b=0 ; b<m ; b++)

View file

@ -0,0 +1,8 @@
Makefile.in
Makefile
lexer.cxx
parser.cxx
parser.h
.deps
.libs
bddcalc

View file

@ -0,0 +1,24 @@
include ../Makefile.def
EXTRA_DIST = \
readme \
example.cal \
examples/c432.cal \
examples/c499.cal \
examples/c1355.cal \
examples/c1908.cal \
examples/c2670.cal \
examples/c3540.cal \
examples/readme
AM_YFLAGS = -d
BUILT_SOURCES = parser.h
check_PROGRAMS = bddcalc
bddcalc_SOURCES = \
hashtbl.h \
hashtbl.cxx \
lexer.lxx \
parser.yxx \
parser_.h \
slist.h

View file

@ -7,8 +7,8 @@
%{
#include <string.h>
#include <stdlib.h>
#include "parser_.h"
#include "parser.h"
#include "tokens.h"
%}

View file

@ -1,45 +0,0 @@
# ---------------------------
# Makefile for BDD calculator
# ---------------------------
all: bddcalc
# --- Compiler flags
CFLAGS = -O3 -pedantic -Wall -ansi -L../../src -I../../src
# --- C++ compiler
CPP = g++
# --- C compiler
CC = gcc
# --- You may need to change these according to your flex and bison versions
parser.cxx: parser.h parser.y
yacc -d -o parser.cxx parser.y
mv parser.cxx.h tokens.h
lexer.cxx: tokens.h parser.h lexer.l
flex -olexer.cxx lexer.l
# --- Do not touch ---
.SUFFIXES: .cxx .c
.cxx.o:
$(CPP) $(CFLAGS) -c $<
.c.o:
$(CC) $(CFLAGS) -c $<
bddcalc: parser.o lexer.o hashtbl.o bddlib
$(CPP) $(CFLAGS) parser.o lexer.o hashtbl.o -o bddcalc -lbdd -lm
bddlib:
cd ../../src ; make
clean:
rm -f *~ examples/*~
rm -f *.o
rm -f bddcalc parser.cxx lexer.cxx

View file

@ -6,15 +6,17 @@
*************************************************************************/
%{
#include <string>
#include <string.h>
#include <stdarg.h>
#include <fstream>
#include <getopt.h>
#define IMPLEMENTSLIST /* Special for list template handling */
#include "slist.h"
#include "hashtbl.h"
#include "parser.h"
#include "parser_.h"
using namespace std;
/* Definitions for storing and caching of identifiers */
#define inputTag 0
#define exprTag 1
@ -64,23 +66,23 @@ void actPrint(token *id);
Token definitions
*************************************************************************/
%token T_id, T_str, T_intval, T_true, T_false
%token T_id T_str T_intval T_true T_false
%token T_initial, T_inputs, T_actions
%token T_size, T_dumpdot
%token T_autoreorder, T_reorder, T_win2, T_win2ite, T_sift, T_siftite, T_none
%token T_cache, T_tautology, T_print
%token T_initial T_inputs T_actions
%token T_size T_dumpdot
%token T_autoreorder T_reorder T_win2 T_win2ite T_sift T_siftite T_none
%token T_cache T_tautology T_print
%token T_lpar, T_rpar
%token T_lpar T_rpar
%token T_equal
%token T_semi, T_dot
%token T_semi T_dot
%right T_exist, T_forall, T_dot
%right T_exist T_forall T_dot
%left T_biimp
%left T_imp
%left T_or, T_nor
%left T_or T_nor
%left T_xor
%left T_nand, T_and
%left T_nand T_and
%right T_not
/*************************************************************************
@ -201,7 +203,6 @@ print:
void usage(void)
{
using namespace std ;
cerr << "USAGE: bddcalc [-hg] file\n";
cerr << " -h : print this message\n";
cerr << " -g : disable garbage collection info\n";
@ -210,7 +211,6 @@ void usage(void)
int main(int ac, char **av)
{
using namespace std ;
int c;
while ((c=getopt(ac, av, "hg")) != EOF)
@ -389,7 +389,6 @@ void actQuantVar1(token *res, token *id)
void actSize(token *id)
{
using namespace std ;
hashData hd;
if (names.lookup(id->id,hd) == 0)
@ -404,7 +403,6 @@ void actSize(token *id)
void actDot(token *fname, token *id)
{
using namespace std ;
hashData hd;
if (names.lookup(id->id,hd) == 0)
@ -434,7 +432,6 @@ void actCache(void)
void actTautology(token *id)
{
using namespace std ;
hashData hd;
if (names.lookup(id->id,hd) == 0)
@ -451,7 +448,6 @@ void actTautology(token *id)
void actPrint(token *id)
{
using namespace std ;
hashData hd;
if (names.lookup(id->id,hd) == 0)

View file

@ -1,39 +0,0 @@
#ifndef YYERRCODE
#define YYERRCODE 256
#endif
#define T_id 257
#define T_str 258
#define T_intval 259
#define T_true 260
#define T_false 261
#define T_initial 262
#define T_inputs 263
#define T_actions 264
#define T_size 265
#define T_dumpdot 266
#define T_autoreorder 267
#define T_reorder 268
#define T_win2 269
#define T_win2ite 270
#define T_sift 271
#define T_siftite 272
#define T_none 273
#define T_cache 274
#define T_tautology 275
#define T_print 276
#define T_lpar 277
#define T_rpar 278
#define T_equal 279
#define T_semi 280
#define T_dot 281
#define T_exist 282
#define T_forall 283
#define T_biimp 284
#define T_imp 285
#define T_or 286
#define T_nor 287
#define T_xor 288
#define T_nand 289
#define T_and 290
#define T_not 291

View file

@ -0,0 +1,4 @@
Makefile
Makefile.in
.deps
bddtest

View file

@ -0,0 +1,3 @@
include ../Makefile.def
check_PROGRAMS = bddtest
bddtest_SOURCES = bddtest.cxx

View file

@ -1,38 +0,0 @@
# --------------------------------
# Makefile for internal tests
# --------------------------------
# --- Compiler flags
CFLAGS = -g -pedantic -Wall -ansi -L../../src -I../../src
# --- C++ compiler
CPP = g++
# --- C compiler
CC = gcc
# --- Do not touch ---
.SUFFIXES: .cxx .c
.cxx.o:
$(CPP) $(CFLAGS) -c $<
.c.o:
$(CC) $(CFLAGS) -c $<
bddtest: bddtest.o bddlib
$(CPP) $(CFLAGS) bddtest.o -o bddtest -lbdd -lm
bddlib:
cd ../../src ; make
clean:
rm -f *~
rm -f *.o
rm -f bddtest
bddtest.o: ../../src/bdd.h

View file

@ -1,4 +1,4 @@
include ../Makefile.def
EXTRA_DIST = readme
check_PROGRAMS = milner
milner_SOURCES = milner.c
check_PROGRAMS = cmilner
cmilner_SOURCES = cmilner.c

View file

@ -1,299 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include "bdd.h"
int N; /* Number of cyclers */
int *normvar; /* Current state variables */
int *primvar; /* Next state variables */
bdd normvarset;
bddPair *pairs;
bdd A(bdd* x, bdd* y, int z)
{
bdd res = bddtrue, tmp1, tmp2;
int i;
for(i=0 ; i<N ; i++)
if(i != z)
{
bdd_addref(res);
tmp1 = bdd_addref(bdd_apply(x[i],y[i],bddop_biimp));
tmp2 = bdd_apply(res, tmp1, bddop_and);
bdd_delref(tmp1);
bdd_delref(res);
res = tmp2;
}
return res;
}
bdd transitions(bdd* t, bdd* tp, bdd* h, bdd* hp, bdd* c, bdd* cp)
{
int i;
bdd P, E, T = bddfalse;
bdd tmp1, tmp2, tmp3, tmp4, tmp5, tmp6;
for(i=0; i<N; i++)
{
bdd_addref(T);
tmp1 = bdd_addref( bdd_apply(c[i], cp[i], bddop_diff) );
tmp2 = bdd_addref( bdd_apply(tp[i], t[i], bddop_diff) );
tmp3 = bdd_addref( A(c, cp, i) );
tmp4 = bdd_addref( A(t, tp, i) );
tmp5 = bdd_addref( A(h, hp, i) );
tmp6 = bdd_addref( bdd_apply(tmp1, tmp2, bddop_and) );
bdd_delref(tmp1);
bdd_delref(tmp2);
tmp1 = bdd_addref( bdd_apply(tmp6, hp[i], bddop_and) );
bdd_delref(tmp6);
tmp2 = bdd_addref( bdd_apply(tmp1, tmp3, bddop_and) );
bdd_delref(tmp1);
bdd_delref(tmp3);
tmp3 = bdd_addref( bdd_apply(tmp2, tmp4, bddop_and) );
bdd_delref(tmp2);
bdd_delref(tmp4);
tmp1 = bdd_addref( bdd_apply(tmp3, tmp5, bddop_and) );
bdd_delref(tmp3);
bdd_delref(tmp5);
tmp4 = bdd_addref( bdd_apply(h[i], hp[i], bddop_diff) );
tmp5 = bdd_addref( bdd_apply(tmp4, cp[(i+1)%N], bddop_and) );
bdd_delref(tmp4);
tmp6 = bdd_addref( A(c, cp, (i+1)%N) );
tmp2 = bdd_addref( bdd_apply(tmp5, tmp6, bddop_and) );
bdd_delref(tmp5);
bdd_delref(tmp6);
tmp3 = bdd_addref( A(h, hp, i) );
tmp4 = bdd_addref( bdd_apply(tmp2, tmp3, bddop_and) );
bdd_delref(tmp2);
bdd_delref(tmp3);
tmp5 = bdd_addref( A(t, tp, N) );
tmp6 = bdd_addref( bdd_apply(tmp4, tmp5, bddop_and) );
bdd_delref(tmp4);
bdd_delref(tmp5);
P = bdd_addref( bdd_apply(tmp1, tmp6, bddop_or) );
bdd_delref(tmp1);
bdd_delref(tmp6);
tmp1 = bdd_addref( bdd_apply(t[i], tp[i], bddop_diff) );
tmp2 = bdd_addref( A(t, tp, i) );
tmp3 = bdd_addref( bdd_apply(tmp1, tmp2, bddop_and) );
bdd_delref(tmp1);
bdd_delref(tmp2);
tmp4 = bdd_addref( A(h, hp, N) );
tmp5 = bdd_addref( A(c, cp, N) );
tmp6 = bdd_addref( bdd_apply(tmp3, tmp4, bddop_and) );
bdd_delref(tmp3);
bdd_delref(tmp4);
E = bdd_addref( bdd_apply(tmp6, tmp5, bddop_and) );
bdd_delref(tmp6);
bdd_delref(tmp5);
tmp1 = bdd_addref( bdd_apply(P, E, bddop_or) );
bdd_delref(P);
bdd_delref(E);
tmp2 = bdd_apply(T, tmp1, bddop_or);
bdd_delref(T);
T = tmp2;
}
return T;
}
bdd initial_state(bdd* t, bdd* h, bdd* c)
{
int i;
bdd I, tmp1, tmp2, tmp3;
tmp1 = bdd_addref( bdd_not(h[0]) );
tmp2 = bdd_addref( bdd_apply(c[0], tmp1, bddop_and) );
bdd_delref(tmp1);
tmp1 = bdd_addref( bdd_not(t[0]) );
I = bdd_apply(tmp1, tmp2, bddop_and);
bdd_delref(tmp1);
bdd_delref(tmp2);
for(i=1; i<N; i++)
{
bdd_addref(I);
tmp1 = bdd_addref( bdd_not(c[i]) );
tmp2 = bdd_addref( bdd_not(h[i]) );
tmp3 = bdd_addref( bdd_apply(tmp1, tmp2, bddop_and) );
bdd_delref(tmp1);
bdd_delref(tmp2);
tmp1 = bdd_addref( bdd_not(t[i]) );
tmp2 = bdd_addref( bdd_apply(tmp3, tmp1, bddop_and) );
bdd_delref(tmp3);
bdd_delref(tmp1);
tmp1 = bdd_apply(I, tmp2, bddop_and);
bdd_delref(tmp2);
bdd_delref(I);
I = tmp1;
}
return I;
}
bdd reachable_states(bdd I, bdd T)
{
bdd C, by, bx = bddfalse;
bdd tmp1;
do
{
bdd_addref(bx);
by = bx;
#if 1
tmp1 = bdd_addref( bdd_apply(T, bx, bddop_and) );
C = bdd_addref( bdd_exist(tmp1, normvarset) );
bdd_delref(tmp1);
#else
C = bdd_addref( bdd_appex(bx, T, bddop_and, normvar, N*3) );
#endif
tmp1 = bdd_addref( bdd_replace(C, pairs) );
bdd_delref(C);
C = tmp1;
tmp1 = bdd_apply(I, C, bddop_or);
bdd_delref(C);
bdd_delref(bx);
bx = tmp1;
/*printf("."); fflush(stdout);*/
}
while(bx != by);
printf("\n");
return bx;
}
#if 0
int has_deadlocks(bdd R, bdd T)
{
bdd C = bddtrue;
for(int i=0; i<N; i++)
C &= bdd_exist(T, primvar, N*3);
//C &= bdd_exist(bdd_exist(bdd_exist(T,i*6+3),i*6+5),i*6+1);
if(C != bddfalse && R != bddfalse)
return 0;
return 1;
}
#endif
int main(int argc, char** argv)
{
bdd *c, *cp, *h, *hp, *t, *tp;
bdd I, T, R;
long clk1, clk2;
int n;
if(argc < 2)
{
printf("usage: %s N\n",argv[0]);
printf("\tN number of cyclers\n");
exit(1);
}
N = atoi(argv[1]);
if (N <= 0)
{
printf("The number of cyclers must more than zero\n");
exit(2);
}
clk1 = clock();
bdd_init(100000, 10000);
bdd_setvarnum(N*6);
c = (bdd *)malloc(sizeof(bdd)*N);
cp = (bdd *)malloc(sizeof(bdd)*N);
t = (bdd *)malloc(sizeof(bdd)*N);
tp = (bdd *)malloc(sizeof(bdd)*N);
h = (bdd *)malloc(sizeof(bdd)*N);
hp = (bdd *)malloc(sizeof(bdd)*N);
normvar = (int *)malloc(sizeof(int)*N*3);
primvar = (int *)malloc(sizeof(int)*N*3);
for (n=0 ; n<N*3 ; n++)
{
normvar[n] = n*2;
primvar[n] = n*2+1;
}
normvarset = bdd_addref( bdd_makeset(normvar, N*3) );
pairs = bdd_newpair();
bdd_setpairs(pairs, primvar, normvar, N*3);
for (n=0 ; n<N ; n++)
{
c[n] = bdd_ithvar(n*6);
cp[n] = bdd_ithvar(n*6+1);
t[n] = bdd_ithvar(n*6+2);
tp[n] = bdd_ithvar(n*6+3);
h[n] = bdd_ithvar(n*6+4);
hp[n] = bdd_ithvar(n*6+5);
}
I = bdd_addref( initial_state(t,h,c) );
T = bdd_addref( transitions(t,tp,h,hp,c,cp) );
R = bdd_addref( reachable_states(I,T) );
/*if(has_deadlocks(R,T))
printf("Milner's Scheduler has deadlocks!\n"); */
clk2 = clock();
printf("SatCount R = %.0f\n", bdd_satcount(R));
printf("Calc = %.0f\n", (double)N*pow(2.0,1.0+N)*pow(2.0,3.0*N));
printf("%.2f sec.\n", (float)(clk2 - clk1)/(float)(CLOCKS_PER_SEC));
bdd_done();
return 0;
}

View file

@ -1,3 +1,3 @@
include ../Makefile.def
check_PROGRAMS = statespace
statespace_SOURCES = statespace.cxx
check_PROGRAMS = fdd
fdd_SOURCES = fdd.cxx

View file

@ -1,79 +0,0 @@
/* This program creates a transition relation for a finite state machine.
* This transition relation is then used to find the reachable statespace
* of the state machine. The state machine has 8 states with state 0 being
* the initial state. The transitions form a ring:
*
* 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> -> 7 -> 0
*/
#include <iostream>
#include "fdd.h"
using namespace std;
/* Use the transition relation "transRel" to iterate through the statespace
*/
void findStateSpace(bdd transRel)
{
/* Create a new pair for renaming the next-state variables to
* current-state variables */
bddPair *p = bdd_newpair();
fdd_setpair(p,1,0);
/* Get a BDD that represents all the current-state variables */
bdd currentStateVar = fdd_ithset(0);
/* Start with the initial state */
bdd reachedStates = fdd_ithvar(0,0);
bdd tmp = bddfalse;
/* Repeat until no new states are found */
do
{
tmp = reachedStates;
/* Calculate: Newset = (exists V_cur. transRel & Reached)[cur/next] */
bdd newset;
newset = reachedStates & transRel;
newset = bdd_exist(newset, currentStateVar);
newset = bdd_replace(newset, p);
cout << "Front: " << (newset - reachedStates) << endl;
/* Add the new states to the found states */
reachedStates = reachedStates | newset;
}
while (tmp != reachedStates);
}
main()
{
/* Initialize BuDDy and declare two interleaved FDD variable blocks
* with the domain [0..7] */
int domain[2] = {8,8};
bdd_init(100,100);
fdd_extdomain(domain, 2);
/* Initialize the transition relation with no transitions */
bdd T = bddfalse;
/* Add all the transitions (from state 'i' to state 'i+1') */
for (int i=0 ; i<8 ; i++)
{
/* Set the current state to be state 'i' */
bdd current = fdd_ithvar(0,i);
/* Set the next state to be state 'i+1' */
bdd next = fdd_ithvar(1, (i+1) % 8);
/* Add the transition */
T = T | (current & next);
}
cout << fddset << "Transition relation: " << T << endl << endl;
/* Calculate the reachable statespace */
findStateSpace(T);
}

View file

@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include "bdd.h"
#include <iostream>
@ -98,6 +97,7 @@ bdd reachable_states(bdd I, bdd T)
int main(int argc, char** argv)
{
using namespace std ;
int n;
if(argc < 2)
{
@ -113,8 +113,6 @@ int main(int argc, char** argv)
exit(2);
}
long clk1 = clock();
bdd_init(500000, 50000);
bdd_setvarnum(N*6);
@ -164,8 +162,6 @@ int main(int argc, char** argv)
bdd T = transitions(t,tp,h,hp,c,cp);
bdd R = reachable_states(I,T);
long clk2 = clock();
bddStat s;
bdd_stats(&s);
@ -175,8 +171,6 @@ int main(int argc, char** argv)
cout << endl << "Number of nodes in T is " << bdd_nodecount( T ) << endl;
cout << "Number of nodes in R is " << bdd_nodecount( R ) << endl << endl;
cout << (float)(clk2 - clk1)/(float)(CLOCKS_PER_SEC) << " sec.\n";
//bdd_printstat();
cout << "Nodenum: " << bdd_getnodenum() << endl;
bdd_done();

View file

@ -16,7 +16,8 @@ using namespace std;
int main(void)
{
// Allocate 11 domains with room for up to 3*10
using namespace std ;
// Allocate 11 domains with room for up to 3*10
static int dom[11] = {30,30,30,30,30,30,30,30,30,30,30};
bdd_init(10000,10000);

View file

@ -76,6 +76,7 @@ void build(int i, int j)
int main(int ac, char **av)
{
using namespace std ;
int n,i,j;
if (ac != 2)

View file

@ -1,5 +1,4 @@
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <stdlib.h>
#include <iostream>
@ -121,6 +120,7 @@ bdd make_move(int src, int tmp, int dst)
void make_transition_relation(void)
{
using namespace std ;
T = bddfalse;
for (int n=0 ; moves[n][0]!=moves[n][1] ; n++)
@ -160,9 +160,9 @@ void iterate(void)
next = bdd_replace(next, pair);
reachable |= next;
cout << cou << ": " << bdd_nodecount(reachable)
std::cout << cou << ": " << bdd_nodecount(reachable)
<< " nodes, " << bdd_satcount(reachable)/dummyStateNum
<< " states\n" << flush;
<< " states\n" << std::endl ;
cou++;
}
while (tmp != reachable);
@ -186,10 +186,10 @@ void iterate_front(void)
front = next - reachable;
reachable |= front;
cout << cou << ": " << bdd_nodecount(reachable)
<< " , " << bdd_satcount(reachable)/dummyStateNum << endl;
cout << cou << ": " << bdd_nodecount(front)
<< " , " << bdd_satcount(front)/dummyStateNum << endl;
std::cout << cou << ": " << bdd_nodecount(reachable)
<< " , " << bdd_satcount(reachable)/dummyStateNum << std::endl;
std::cout << cou << ": " << bdd_nodecount(front)
<< " , " << bdd_satcount(front)/dummyStateNum << std::endl;
cou++;
}
while (tmp != reachable);
@ -212,15 +212,9 @@ void setup(void)
int main(void)
{
long c1, c2;
c1 = clock();
setup();
iterate();
c2 = clock();
printf("Time: %.1f sec.\n", ((float)(c2-c1))/CLOCKS_PER_SEC);
system("ps aux | grep \"./solitare\" | grep -v \"grep\"");
}

View file

@ -1,5 +1,5 @@
# For
AM_CPPFLAGS = -I$(top_builddir)
# For
AM_CPPFLAGS = -I$(top_builddir) -DVERSION=23
include_HEADERS = bdd.h fdd.h bvec.h

View file

@ -28,7 +28,7 @@
========================================================================*/
/*************************************************************************
$Header: /Volumes/CVS/repository/spot/spot/buddy/src/kernel.h,v 1.4 2003/05/20 08:22:36 aduret Exp $
$Header: /Volumes/CVS/repository/spot/spot/buddy/src/kernel.h,v 1.5 2004/06/28 15:22:13 adl Exp $
FILE: kernel.h
DESCR: Kernel specific definitions for BDD package
AUTH: Jorn Lind
@ -119,8 +119,6 @@ extern bddCacheStat bddcachestats;
/*=== KERNEL DEFINITIONS ===============================================*/
#define VERSION 22
#define MAXVAR 0x1FFFFF
#define MAXREF 0x3FF