00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include "espresso.h"
00049
00050 pcover espresso(F, D1, R)
00051 pcover F, D1, R;
00052 {
00053 pcover E, D, Fsave;
00054 pset last, p;
00055 cost_t cost, best_cost;
00056
00057 begin:
00058 Fsave = sf_save(F);
00059 D = sf_save(D1);
00060
00061
00062 if (recompute_onset) {
00063 EXEC(E = simplify(cube1list(F)), "SIMPLIFY ", E);
00064 free_cover(F);
00065 F = E;
00066 }
00067 cover_cost(F, &cost);
00068 if (unwrap_onset && (cube.part_size[cube.num_vars - 1] > 1)
00069 && (cost.out != cost.cubes*cube.part_size[cube.num_vars-1])
00070 && (cost.out < 5000))
00071 EXEC(F = sf_contain(unravel(F, cube.num_vars - 1)), "SETUP ", F);
00072
00073
00074 foreach_set(F, last, p) {
00075 RESET(p, PRIME);
00076 }
00077 EXECUTE(F = expand(F, R, FALSE), EXPAND_TIME, F, cost);
00078 EXECUTE(F = irredundant(F, D), IRRED_TIME, F, cost);
00079
00080 if (! single_expand) {
00081 if (remove_essential) {
00082 EXECUTE(E = essential(&F, &D), ESSEN_TIME, E, cost);
00083 } else {
00084 E = new_cover(0);
00085 }
00086
00087 cover_cost(F, &cost);
00088 do {
00089
00090
00091 do {
00092 copy_cost(&cost, &best_cost);
00093 EXECUTE(F = reduce(F, D), REDUCE_TIME, F, cost);
00094 EXECUTE(F = expand(F, R, FALSE), EXPAND_TIME, F, cost);
00095 EXECUTE(F = irredundant(F, D), IRRED_TIME, F, cost);
00096 } while (cost.cubes < best_cost.cubes);
00097
00098
00099 copy_cost(&cost, &best_cost);
00100 if (use_super_gasp) {
00101 F = super_gasp(F, D, R, &cost);
00102 if (cost.cubes >= best_cost.cubes)
00103 break;
00104 } else {
00105 F = last_gasp(F, D, R, &cost);
00106 }
00107
00108 } while (cost.cubes < best_cost.cubes ||
00109 (cost.cubes == best_cost.cubes && cost.total < best_cost.total));
00110
00111
00112 F = sf_append(F, E);
00113 if (trace) size_stamp(F, "ADJUST ");
00114 }
00115
00116
00117 free_cover(D);
00118
00119
00120 if (! skip_make_sparse) {
00121 F = make_sparse(F, D1, R);
00122 }
00123
00124
00125
00126
00127
00128
00129 if (Fsave->count < F->count) {
00130 free_cover(F);
00131 F = Fsave;
00132 unwrap_onset = FALSE;
00133 goto begin;
00134 } else {
00135 free_cover(Fsave);
00136 }
00137
00138 return F;
00139 }