prune-trace: add switch to disable sample weighting

In the sampling step, the --no-weighting switch disables the
equivalence-class weighting by using a weight of one instead of the
equivalence-class size.  This is usually not a good idea, and should
only be used for demonstration purposes, or if the fault model
requires weight-less sampling.

Change-Id: Id903d1924c6ecbcd217815aa5ce9271560130071
This commit is contained in:
Horst Schirmeier
2014-12-06 00:19:17 +01:00
parent a1e3b31cd5
commit b2b53380f4
2 changed files with 12 additions and 4 deletions

View File

@ -32,6 +32,9 @@ bool FESamplingPruner::commandline_init()
USE_KNOWN_RESULTS = cmd.addOption("", "use-known-results", Arg::None,
"--use-known-results \tReuse known results from a campaign with the 'basic' pruner "
"(abuses the DB layout to a certain degree, use with caution)");
NO_WEIGHTING = cmd.addOption("", "no-weighting", Arg::None,
"--no-weighting \tDisable weighted sampling (weight = 1 for all ECs) "
"(don't do this unless you know what you're doing)");
return true;
}
@ -48,6 +51,10 @@ bool FESamplingPruner::prune_all()
m_use_known_results = true;
}
if (cmd[NO_WEIGHTING]) {
m_weighting = false;
}
// for each variant:
for (std::vector<fail::Database::Variant>::const_iterator it = m_variants.begin();
it != m_variants.end(); ++it) {
@ -105,7 +112,7 @@ bool FESamplingPruner::sampling_prune(const fail::Database::Variant& variant)
p.instr2 = strtoul(row[0], 0, 10);
p.instr2_absolute = strtoul(row[1], 0, 10);
p.data_address = strtoul(row[2], 0, 10);
p.duration = strtoull(row[3], 0, 10);
p.duration = m_weighting ? strtoull(row[3], 0, 10) : 1;
pop.add(p);
++pilotcount;
}
@ -132,7 +139,7 @@ bool FESamplingPruner::sampling_prune(const fail::Database::Variant& variant)
p.id = strtoul(row[0], 0, 10);
p.instr2 = strtoul(row[1], 0, 10);
p.data_address = strtoul(row[2], 0, 10);
p.duration = strtoull(row[3], 0, 10);
p.duration = m_weighting ? strtoull(row[3], 0, 10) : 1;
pop.add(p);
++pilotcount;
}

View File

@ -16,12 +16,13 @@
class FESamplingPruner : public Pruner {
fail::CommandLine::option_handle SAMPLESIZE;
fail::CommandLine::option_handle USE_KNOWN_RESULTS;
fail::CommandLine::option_handle NO_WEIGHTING;
unsigned m_samplesize;
bool m_use_known_results;
bool m_use_known_results, m_weighting;
public:
FESamplingPruner() : m_samplesize(0), m_use_known_results(false) { }
FESamplingPruner() : m_samplesize(0), m_use_known_results(false), m_weighting(true) { }
virtual std::string method_name() { return "FESampling"; }
virtual bool commandline_init();
virtual bool prune_all();