1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
|
/*-----------------------------------------------------------------------
File : che_rawspecfeatures.c
Author: Stephan Schulz (schulz@eprover.org)
Contents
Code and datatypes for handling rough classification of raw problem
specs.
Copyright 2012 by the author.
This code is released under the GNU General Public Licence.
See the file COPYING in the main CLIB directory for details.
Run "eprover -h" for contact information.
Changes
<1> Tue May 22 01:16:15 CEST 2012
New
-----------------------------------------------------------------------*/
#include "che_rawspecfeatures.h"
/*---------------------------------------------------------------------*/
/* Global Variables */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* Forward Declarations */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* Internal Functions */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* Exported Functions */
/*---------------------------------------------------------------------*/
/*-----------------------------------------------------------------------
//
// Function: RawSpecFeaturesCompute()
//
// Compute the raw features of state.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
void RawSpecFeaturesCompute(RawSpecFeature_p features, ProofState_p state)
{
features->sentence_no = ClauseSetCardinality(state->axioms)+
ClauseSetCardinality(state->f_axioms);
features->term_size = ClauseSetStandardWeight(state->axioms)+
FormulaSetStandardWeight(state->f_axioms);
features->hypothesis_count = 0;
features->conjecture_count = 0;
features->conjecture_count +=
ClauseSetCountConjectures(state->axioms,
&(features->hypothesis_count));
features->conjecture_count +=
FormulaSetCountConjectures(state->f_axioms,
&(features->hypothesis_count));
features->sig_size = SigCountSymbols(state->terms->sig, true)+
SigCountSymbols(state->terms->sig,false);
features->predc_size = SigCountAritySymbols(state->terms->sig, 0, true);
features->func_size = SigCountAritySymbols(state->terms->sig, 0, false);
features->pred_size = SigCountSymbols(state->terms->sig, true)-
SigCountAritySymbols(state->terms->sig, 0, true);
features->fun_size = SigCountSymbols(state->terms->sig, false)-
SigCountAritySymbols(state->terms->sig, 0, false);
features->class[0] = '\0';
}
#define RAW_CLASSIFY(index, value, some, many)\
if((value) < (some))\
{ \
features->class[index] = 'S'; \
} \
else if((value) < (many)) \
{ \
features->class[index] = 'M'; \
} \
else \
{ \
features->class[index] = 'L'; \
}
/*-----------------------------------------------------------------------
//
// Function: RawSpecFeaturesClassify()
//
// Add a classifiction based on limits to the (initialized)
// features.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
void RawSpecFeaturesClassify(RawSpecFeature_p features, SpecLimits_p limits,
char* pattern)
{
RAW_CLASSIFY(0, features->sentence_no,
limits->ax_some_limit, limits->ax_many_limit);
RAW_CLASSIFY(1, features->term_size,
limits->term_medium_limit, limits->term_large_limit);
RAW_CLASSIFY(2, features->sig_size,
limits->symbols_medium_limit, limits->symbols_large_limit);
RAW_CLASSIFY(3, features->pred_size,
limits->pred_medium_limit, limits->pred_large_limit);
RAW_CLASSIFY(4, features->predc_size,
limits->predc_medium_limit, limits->predc_large_limit);
RAW_CLASSIFY(5, features->fun_size,
limits->fun_medium_limit, limits->fun_large_limit);
RAW_CLASSIFY(6, features->func_size,
limits->func_medium_limit, limits->func_large_limit);
if(pattern)
{
char* handle;
for(handle = features->class;*pattern; pattern++, handle++)
{
if(*pattern=='-')
{
*handle = '-';
}
}
}
features->class[7] = '\0';
}
/*-----------------------------------------------------------------------
//
// Function: RawSpecFeaturesParse()
//
// Parse a rawspecfeatures line.
//
// Global Variables:
//
// Side Effects :
//
/----------------------------------------------------------------------*/
void RawSpecFeaturesParse(Scanner_p in, RawSpecFeature_p features)
{
char *class;
AcceptInpTok(in, OpenBracket);
features->sentence_no = ParseInt(in);
AcceptInpTok(in, Comma);
features->term_size = ParseInt(in);
AcceptInpTok(in, Comma);
features->sig_size = ParseInt(in);
AcceptInpTok(in, Comma);
features->pred_size = ParseInt(in);
AcceptInpTok(in, Comma);
features->predc_size = ParseInt(in);
AcceptInpTok(in, Comma);
features->fun_size = ParseInt(in);
AcceptInpTok(in, Comma);
features->func_size = ParseInt(in);
AcceptInpTok(in, CloseBracket);
AcceptInpTok(in, Colon);
class = ParsePlainFilename(in);
if(strlen(class) != 7)
{
Error("Raw class name must have 7 characters", SYNTAX_ERROR);
}
strcpy(features->class, class);
FREE(class);
}
/*-----------------------------------------------------------------------
//
// Function: RawSpecFeaturesPrint()
//
// Print the features.
//
// Global Variables: -
//
// Side Effects : Output
//
/----------------------------------------------------------------------*/
void RawSpecFeaturesPrint(FILE* out, RawSpecFeature_p features)
{
fprintf(out, "(%7ld, %7lld, %6d, %6d, %6d, %6d, %6d) : %s",
features->sentence_no,
features->term_size,
features->sig_size,
features->pred_size,
features->predc_size,
features->fun_size,
features->func_size,
features->class);
}
/*---------------------------------------------------------------------*/
/* End of File */
/*---------------------------------------------------------------------*/
|