@@ -33,8 +33,8 @@ typedef struct clause_struct Clause;
33
33
struct clause_struct
34
34
{
35
35
Clause * next ;
36
- float totcost ;
37
- float maxcost ;
36
+ float totcost ; // Total cost of all connectors in the clause
37
+ float maxcost ; // Cost of the most costly lingle connector.
38
38
Tconnector * c ;
39
39
};
40
40
@@ -148,14 +148,10 @@ static Clause * build_clause(Exp *e, clause_context *ct, Clause **c_last)
148
148
{
149
149
for (Clause * c4 = c2 ; c4 != NULL ; c4 = c4 -> next )
150
150
{
151
- float maxcost = MAX (c3 -> maxcost ,c4 -> maxcost );
152
- /* Cannot use this shortcut due to negative costs. */
153
- //if (maxcost + e->cost > ct->cost_cutoff) continue;
154
-
155
151
Clause * c5 = pool_alloc (ct -> Clause_pool );
156
152
if ((c_head == NULL ) && (c_last != NULL )) * c_last = c5 ;
153
+ c5 -> maxcost = MAX (c3 -> maxcost , c4 -> maxcost );
157
154
c5 -> totcost = c3 -> totcost + c4 -> totcost ;
158
- c5 -> maxcost = maxcost ;
159
155
c5 -> c = catenate (c4 -> c , c3 -> c , ct -> Tconnector_pool );
160
156
c5 -> next = c_head ;
161
157
c_head = c5 ;
@@ -204,14 +200,19 @@ static Clause * build_clause(Exp *e, clause_context *ct, Clause **c_last)
204
200
/* c now points to the list of clauses */
205
201
for (Clause * c1 = c ; c1 != NULL ; c1 = c1 -> next )
206
202
{
207
- c1 -> totcost += e -> cost ;
208
- /* c1->maxcost = MAX(c1->maxcost,e->cost); */
209
- /* Above is how Dennis had it. Someone changed it to below.
210
- * However, this can sometimes lead to a maxcost that is less
211
- * than the cost ! -- which seems wrong to me ... seems Dennis
212
- * had it right!?
203
+ /* The maxcost is the most costly single connector in the
204
+ * expression. It is used, in conjunction with the cost_cutoff,
205
+ * to reject clauses which contain a single costly connector
206
+ * in them. This allows cost_cutoff to be raised for panic
207
+ * parses, thus allowing perhaps-dubious disjuncts into the
208
+ * parse. Note that maxcost can be less than totcost, because
209
+ * the totcost might be the sum of many low-cost connectors,
210
+ * sum sums can get large. (maxcost is the Banach l_0 norm,
211
+ * while totcost is the Banach l_1 norm).
213
212
*/
214
- c1 -> maxcost += e -> cost ;
213
+ c1 -> maxcost = MAX (c1 -> maxcost , e -> cost );
214
+ c1 -> totcost += e -> cost ;
215
+
215
216
/* Note: The above computation is used as a saving shortcut in
216
217
* the inner loop of AND_type. If it is changed here, it needs to be
217
218
* changed there too. */
0 commit comments