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:
parent
805b6fb70b
commit
aa4a582f1b
27 changed files with 130 additions and 796 deletions
|
|
@ -1,11 +1,10 @@
|
|||
SUBDIRS = \
|
||||
adder \
|
||||
calculator \
|
||||
bddcalc \
|
||||
bddtest \
|
||||
cmilner \
|
||||
fdd \
|
||||
internal \
|
||||
milner \
|
||||
money \
|
||||
queen \
|
||||
solitare
|
||||
|
||||
|
|
|
|||
|
|
@ -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++)
|
||||
|
|
|
|||
8
buddy/examples/bddcalc/.cvsignore
Normal file
8
buddy/examples/bddcalc/.cvsignore
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Makefile.in
|
||||
Makefile
|
||||
lexer.cxx
|
||||
parser.cxx
|
||||
parser.h
|
||||
.deps
|
||||
.libs
|
||||
bddcalc
|
||||
24
buddy/examples/bddcalc/Makefile.am
Normal file
24
buddy/examples/bddcalc/Makefile.am
Normal 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
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
%{
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "parser_.h"
|
||||
#include "parser.h"
|
||||
#include "tokens.h"
|
||||
%}
|
||||
|
||||
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -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)
|
||||
|
|
@ -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
|
||||
4
buddy/examples/bddtest/.cvsignore
Normal file
4
buddy/examples/bddtest/.cvsignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Makefile
|
||||
Makefile.in
|
||||
.deps
|
||||
bddtest
|
||||
3
buddy/examples/bddtest/Makefile.am
Normal file
3
buddy/examples/bddtest/Makefile.am
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
include ../Makefile.def
|
||||
check_PROGRAMS = bddtest
|
||||
bddtest_SOURCES = bddtest.cxx
|
||||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
include ../Makefile.def
|
||||
EXTRA_DIST = readme
|
||||
check_PROGRAMS = milner
|
||||
milner_SOURCES = milner.c
|
||||
check_PROGRAMS = cmilner
|
||||
cmilner_SOURCES = cmilner.c
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
include ../Makefile.def
|
||||
check_PROGRAMS = statespace
|
||||
statespace_SOURCES = statespace.cxx
|
||||
check_PROGRAMS = fdd
|
||||
fdd_SOURCES = fdd.cxx
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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\"");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue