1 | #include "mdd.h" |
---|
2 | |
---|
3 | /* |
---|
4 | * MDD Package |
---|
5 | * |
---|
6 | * $Id: mdd_consensus.c,v 1.9 2002/08/24 20:44:27 fabio Exp $ |
---|
7 | * |
---|
8 | * Author: Timothy Kam |
---|
9 | * |
---|
10 | * Copyright 1992 by the Regents of the University of California. |
---|
11 | * |
---|
12 | * All rights reserved. Permission to use, copy, modify and distribute |
---|
13 | * this software is hereby granted, provided that the above copyright |
---|
14 | * notice and this permission notice appear in all copies. This software |
---|
15 | * is made available as is, with no warranties. |
---|
16 | */ |
---|
17 | |
---|
18 | mdd_t * |
---|
19 | mdd_consensus( |
---|
20 | mdd_manager *mgr, |
---|
21 | mdd_t *fn, |
---|
22 | array_t *mvars) |
---|
23 | { |
---|
24 | array_t *bdd_vars; |
---|
25 | int i, j, mv_no, num; |
---|
26 | mvar_type mv; |
---|
27 | mdd_t *top; |
---|
28 | bdd_t *tmp; |
---|
29 | array_t *mvar_list = mdd_ret_mvar_list(mgr); |
---|
30 | |
---|
31 | bdd_vars = array_alloc(bdd_t *, 0); |
---|
32 | |
---|
33 | |
---|
34 | if ( mvars == NIL( array_t ) ) { |
---|
35 | printf("\nWARNING: Empty Array of Consensus Variables\n"); |
---|
36 | array_free(bdd_vars); |
---|
37 | return ( mdd_dup(fn) ) ; |
---|
38 | } |
---|
39 | |
---|
40 | else if ( array_n(mvars) == 0) { |
---|
41 | printf("\nWARNING: Empty Array of Consensus Variables\n"); |
---|
42 | array_free(bdd_vars); |
---|
43 | return ( mdd_dup(fn) ) ; |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | for (i=0; i<array_n(mvars); i++) { |
---|
48 | mv_no = array_fetch(int, mvars, i); |
---|
49 | mv = array_fetch(mvar_type, mvar_list, mv_no); |
---|
50 | if (mv.status == MDD_BUNDLED) { |
---|
51 | (void) fprintf(stderr, |
---|
52 | "\nmdd_consensus: bundled variable %s used\n",mv.name); |
---|
53 | fail(""); |
---|
54 | } |
---|
55 | |
---|
56 | for (j = 0; j < mv.encode_length; j ++) { |
---|
57 | tmp = bdd_get_variable(mgr, (unsigned int) mdd_ret_bvar_id(&mv, j) ); |
---|
58 | array_insert_last(bdd_t *, bdd_vars, tmp); |
---|
59 | } |
---|
60 | } |
---|
61 | top = bdd_consensus(fn, bdd_vars); |
---|
62 | num = array_n(bdd_vars); |
---|
63 | for(i=0; i<num; i++){ |
---|
64 | bdd_free(array_fetch(bdd_t *, bdd_vars, i)); |
---|
65 | } |
---|
66 | array_free(bdd_vars); |
---|
67 | return top; |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | /*---------------------------------------------------------------------------*/ |
---|
72 | /* Static function prototypes */ |
---|
73 | /*---------------------------------------------------------------------------*/ |
---|
74 | |
---|
75 | |
---|