本文整理汇总了C++中oracle函数的典型用法代码示例。如果您正苦于以下问题:C++ oracle函数的具体用法?C++ oracle怎么用?C++ oracle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了oracle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_P
TEST_P(Int32Compare, UsingLoadParam) {
auto param = TRTest::to_struct(GetParam());
char inputTrees[120] = {0};
std::snprintf(inputTrees, 120,
"(method return=Int32 args=[Int32, Int32] "
"(block "
"(ireturn "
"(%s "
"(iload parm=0) "
"(iload parm=1)))))",
param.opcode.c_str());
auto trees = parseString(inputTrees);
ASSERT_NOTNULL(trees);
Tril::DefaultCompiler compiler{trees};
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;
auto entry_point = compiler.getEntryPoint<int32_t (*)(int32_t, int32_t)>();
volatile auto exp = param.oracle(param.lhs, param.rhs);
volatile auto act = entry_point(param.lhs, param.rhs);
ASSERT_EQ(exp, act);
}
示例2: TEST_P
TEST_P(DoubleToFloat, UsingConst) {
auto param = TRTest::to_struct(GetParam());
char inputTrees[512] = {0};
std::snprintf(inputTrees, 512,
"(method return=Float"
" (block"
" (freturn"
" (d2f"
" (dconst %f) ) ) ) )",
param.value);
auto trees = parseString(inputTrees);
ASSERT_NOTNULL(trees);
Tril::DefaultCompiler compiler{trees};
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;
auto entry_point = compiler.getEntryPoint<float (*)()>();
volatile auto exp = param.oracle(param.value);
volatile auto act = entry_point();
if (std::isnan(exp)) {
ASSERT_EQ(std::isnan(exp), std::isnan(act));
} else {
ASSERT_EQ(exp, act);
}
}
示例3: main
int
main(int argc, char *argv[])
{
if (argc < 4)
errx(1, "not enough arguments");
init_sli();
VexPtr<Oracle> oracle(new Oracle(NULL, NULL, NULL));
VexPtr<StateMachine, &ir_heap> readMachine(readStateMachine(open(argv[1], O_RDONLY)));
VexPtr<StateMachine, &ir_heap> writeMachine(readStateMachine(open(argv[2], O_RDONLY)));
VexPtr<IRExpr, &ir_heap> assumption(readIRExpr(open(argv[3], O_RDONLY)));
bool mightCrash;
bool mightSurvive;
evalCrossProductMachine(readMachine, writeMachine, oracle, assumption,
AllowableOptimisations::defaultOptimisations,
&mightSurvive, &mightCrash, ALLOW_GC);
printf("Might survive %d, might crash %d\n",
mightSurvive, mightCrash);
return 0;
}
示例4: rebuild
virtual void rebuild () { // insert must not happen at this time
if (flavor == KGRAPH_LINEAR) {
BOOST_VERIFY(indexed_size == 0);
return;
}
if (entries.size() == indexed_size) return;
if (flavor == KGRAPH_LITE) {
indexed_size = 0;
delete kg_index;
kg_index = nullptr;
return;
}
KGraph *kg = nullptr;
if (entries.size() >= min_index_size) {
kg = KGraph::create();
LOG(info) << "Rebuilding index for " << entries.size() << " features.";
IndexOracle oracle(this, index_params_l1);
kg->build(oracle, index_params, NULL);
LOG(info) << "Swapping on new index...";
}
indexed_size = entries.size();
std::swap(kg, kg_index);
if (kg) {
delete kg;
}
}
示例5: TEST_P
TEST_P(Int8ToInt32, UsingLoadParam) {
std::string arch = omrsysinfo_get_CPU_architecture();
SKIP_IF(OMRPORT_ARCH_S390 == arch || OMRPORT_ARCH_S390X == arch, KnownBug)
<< "The Z code generator incorrectly spills sub-integer types arguments (see issue #3525)";
auto param = TRTest::to_struct(GetParam());
char *inputTrees =
"(method return=Int32 args=[Int8]"
" (block"
" (ireturn"
" (b2i"
" (bload parm=0) ) ) ) )";
auto trees = parseString(inputTrees);
ASSERT_NOTNULL(trees);
Tril::DefaultCompiler compiler{trees};
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;
auto entry_point = compiler.getEntryPoint<int32_t (*)(int8_t)>();
volatile auto exp = param.oracle(param.value);
volatile auto act = entry_point(param.value);
ASSERT_EQ(exp, act);
}
示例6: main
int main()
{
int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
sea_hag, tribute, smithy};
int i, n, players, player, handCount, deckCount, seed;
//struct gameState state;
struct gameState state;
player = 0;
n = 0;
srand(time(NULL));
printf("Running Random Adventurer Test\n");
/*
--- Author's Note ---
So, I had problems running out of memory when I used the same gameState variable more than 12 times, and
I honestly don't know why. I momentarily solved this problem by adding more for loops and creating more gamestates;
I was still able to get decent coverage, though not up to the amount of tests I originally had in mind.
*/
for (i = 0; i < MAX_TESTS; i++)
{
players = rand() % 3 + 2;
seed = rand(); //pick random seed
initializeGame(players, k, seed, &state); //initialize Gamestate
//Initiate valid state variables
state.deckCount[player] = rand() % 20; //Pick random deck size out of MAX DECK size
state.discardCount[player] = rand() % 20;
handCount = rand() % 10;
state.hand[0][0] = adventurer;
//Copy state variables
deckCount = state.deckCount[player];
//1 in 3 chance of making empty deck for coverage
if (seed % 3 == 0)
{
state.deckCount[player] = 0;
}
printf("Test: %d\n", i);
oracle(state, deckCount, state.discardCount[0]); //Run adventurer card
}
printf("Tests Complete\n");
return 0;
}
示例7: ComputeLinearTreeLoss
int ComputeLinearTreeLoss(const CState & state,
const vector<CDepTree *> & nodes,
const CIDMap::ACTION_TYPE action) {
CDynamicOracleSearcher oracle(state, nodes);
oracle.InitStackCosts();
oracle.BuildStacks(action);
oracle.ComputeStackCost(action);
return oracle.LossLinearTree();
}
示例8: BestAction
int BestAction(const CState & state, const vector<CDepTree*> & nodes) {
set<CIDMap::ACTION_TYPE> actions;
CDynamicOracleSearcher oracle(state, nodes);
oracle.InitStackCosts();
// oracle.Oracle(0, &actions);
oracle.Oracle(&actions);
vector<double> scores(CIDMap::GetOutcomeNum(), 0.);
return oracle.BestAction(actions, scores);
}
示例9: main
int main(int argc, char **argv)
{
pool p[1] = { pool_create() };
random_init();
/* biases at 16 and 32, so we prefix our 30 byte secret with
* two bytes to start with, up to 17 */
byteblock prefix = { (uint8_t *) "AAAAAAAAAAAAAAAAAA", 2 };
assert(argc == 2);
byteblock secret = from_base64(p, argv[1]);
assert(secret.len == SECRET_LEN);
unsigned counts[SECRET_LEN][256];
memset(counts, 0, sizeof(counts));
while (prefix.len < 18)
{
uint8_t buf[64];
byteblock bb = { buf, 0 };
for (size_t i = 0; i < ROUNDS; i++)
{
oracle(&prefix, &secret, &bb);
if (prefix.len <= 15)
{
/* bias at 16 towards 240 (full) 0 (half) 16 (half) */
uint8_t b16 = buf[15];
counts[15 - prefix.len][b16 ^ 240] += FULL_WEIGHT;
counts[15 - prefix.len][b16 ^ 0] += HALF_WEIGHT;
counts[15 - prefix.len][b16 ^ 16] += HALF_WEIGHT;
}
/* bias at 32 towards 224 (full) 0 (half) 32 (half) */
uint8_t b32 = buf[31];
counts[31 - prefix.len][b32 ^ 224] += FULL_WEIGHT;
counts[31 - prefix.len][b32 ^ 0] += HALF_WEIGHT;
counts[31 - prefix.len][b32 ^ 32] += HALF_WEIGHT;
}
prefix.len++;
byteblock plaintext = recover(p, counts);
printf("guess: %s\n", to_ascii(p, &plaintext));
}
byteblock recovered = recover(p, counts);
printf("message: %s\n", to_ascii(p, &recovered));
p->finish(p);
return 0;
}
示例10: run_refactor
int run_refactor(optionst &options, messaget::mstreamt &result,
const symbol_tablet &st, const goto_functionst &gf)
{
refactor_preprocessingt preproc(options, st, gf);
refactor_symex_learnt learn_cfg(preproc.get_program());
refactor_symex_verifyt verify_cfg(preproc.get_program());
cegis_symex_learnt<refactor_preprocessingt, refactor_symex_learnt> learn(
options, preproc, learn_cfg);
cegis_symex_verifyt<refactor_symex_verifyt> oracle(options, verify_cfg);
return run_cegis_with_statistics_wrapper(
result, options, learn, oracle, preproc);
}
示例11: main
int main() {
int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
sea_hag, tribute, smithy};
int i, n, players, player, handCount, deckCount, seed;
//struct gameState state;
struct gameState state;
srand(time(NULL));
player = 0;
n = 1;
printf("Running Random Card Test for Village\n");
for (i = 0; i < MAX_TESTS; i++)
{
players = rand() % 3 + 2;
seed = rand(); //pick random seed
initializeGame(players, k, seed, &state); //initialize Gamestate
//Initiate valid state variables
state.deckCount[player] = rand() % MAX_DECK; //Pick random deck size out of MAX DECK size
state.discardCount[player] = rand() % MAX_DECK;
handCount = rand() % MAX_HAND;
state.hand[0][0] = village;
//Copy state variables
deckCount = state.deckCount[player];
printf("test: %d\n", n);
oracle(state, state.handCount[0], state.discardCount[0], state.numActions); //Run adventurer card
n++;
}
printf("Tests Complete\n");
return 0;
}
示例12: rebuild
virtual void rebuild () { // insert must not happen at this time
if (linear) {
indexed_size = entries.size();
return;
}
if (entries.size() == indexed_size) return;
KGraph *kg = nullptr;
if (entries.size() >= min_index_size) {
kg = KGraph::create();
LOG(info) << "Rebuilding index for " << entries.size() << " features.";
IndexOracle oracle(this);
kg->build(oracle, index_params, NULL);
LOG(info) << "Swapping on new index...";
}
indexed_size = entries.size();
std::swap(kg, kg_index);
if (kg) {
delete kg;
}
}
示例13: main
int main() {
// Generate input vectors
double *x = gen_array(ARRAY_SIZE);
double *y = gen_array(ARRAY_SIZE);
double result, answer;
answer = oracle(x, y);
// Test framework that sweeps the number of threads and times each ru
double start_time, run_time;
int num_threads = omp_get_max_threads();
for(int i=1; i<=num_threads; i++) {
omp_set_num_threads(i);
start_time = omp_get_wtime();
for(int j=0; j<REPEAT; j++) {
result = dotp(x,y);
if (result != answer) {
printf("Incorrect dotp %f %f\n", result, answer);
return 0;
}
}
run_time = omp_get_wtime() - start_time;
printf(" %d thread(s) took %f seconds\n",i,run_time);
}
}
示例14: main
//.........这里部分代码省略.........
project.readAndResize("edges", beEdges);
std::set<int> nodes;
for (int n : beNodes)
nodes.insert(n);
std::set<std::pair<int, int>> edges;
for (int i = 0; i < beEdges.shape(1); i++)
edges.insert(
std::make_pair(
std::min(beEdges(i, 0), beEdges(i, 1)),
std::max(beEdges(i, 0), beEdges(i, 1))));
for (Crag::NodeIt n(crag); n != lemon::INVALID; ++n)
bestEffort->node[n] = nodes.count(crag.id(n));
for (Crag::EdgeIt e(crag); e != lemon::INVALID; ++e)
bestEffort->edge[e] = edges.count(
std::make_pair(
std::min(crag.id(crag.u(e)), crag.id(crag.v(e))),
std::max(crag.id(crag.u(e)), crag.id(crag.v(e)))));
} else {
LOG_USER(logger::out) << "reading ground-truth" << std::endl;
ExplicitVolume<int> groundTruth;
volumeStore.retrieveGroundTruth(groundTruth);
LOG_USER(logger::out) << "finding best-effort solution" << std::endl;
overlapLoss = new OverlapLoss(crag, groundTruth);
bestEffort = new BestEffort(crag, *overlapLoss);
}
Loss* loss = 0;
bool destructLoss = false;
if (optionLoss.as<std::string>() == "hamming") {
LOG_USER(logger::out) << "using Hamming loss" << std::endl;
loss = new HammingLoss(crag, *bestEffort);
destructLoss = true;
} else if (optionLoss.as<std::string>() == "overlap") {
LOG_USER(logger::out) << "using overlap loss" << std::endl;
if (!overlapLoss) {
LOG_USER(logger::out) << "reading ground-truth" << std::endl;
ExplicitVolume<int> groundTruth;
volumeStore.retrieveGroundTruth(groundTruth);
LOG_USER(logger::out) << "finding best-effort solution" << std::endl;
overlapLoss = new OverlapLoss(crag, groundTruth);
}
loss = overlapLoss;
} else {
LOG_ERROR(logger::out)
<< "unknown loss: "
<< optionLoss.as<std::string>()
<< std::endl;
return 1;
}
if (optionNormalizeLoss) {
LOG_USER(logger::out) << "normalizing loss..." << std::endl;
loss->normalize(crag, MultiCut::Parameters());
}
Oracle oracle(
crag,
nodeFeatures,
edgeFeatures,
*loss,
*bestEffort);
std::vector<double> weights(nodeFeatures.dims() + edgeFeatures.dims(), 0);
optimizer.optimize(oracle, weights);
storeVector(weights, optionFeatureWeights);
if (destructLoss && loss != 0)
delete loss;
if (overlapLoss)
delete overlapLoss;
if (bestEffort)
delete bestEffort;
} catch (boost::exception& e) {
handleException(e, std::cerr);
}
}
示例15: main
//.........这里部分代码省略.........
("db_search_max_missed_cleavages", boost::program_options::value<int>(&db_search_max_missed_cleavages)->default_value(0), "db_search_max_missed_cleavages")
("db_search_max_dynamic_mods", boost::program_options::value<int>(&db_search_max_dynamic_mods)->default_value(0), "db_search_max_dynamic_mods")
("db_search_min_enzymatic_termini", boost::program_options::value<int>(&db_search_min_enzymatic_termini)->default_value(2), "db_search_min_enzymatic_termini")
("db_search_mass_tolerance", boost::program_options::value<double>(&db_search_mass_tolerance)->default_value(.05), "db_search_mass_tolerance")
("db_search_PTM", boost::program_options::value<std::vector<DBPTM> >(&PTMs)->multitoken(), "PTMs")
("db_search_enzyme", boost::program_options::value<std::vector<DBEnzyme>>(&enzymes)->multitoken(), "enzymes")
("db_search_null_lambda", boost::program_options::value<double>(&null_lambda)->default_value(6), "db_search_null_lambda")
("max_ms1_injection_time", boost::program_options::value<double>(&max_ms1_injection_time)->default_value(0.2), "max_ms1_injection_time")
("max_ms2_injection_time", boost::program_options::value<double>(&max_ms2_injection_time)->default_value(0.5), "max_ms2_injection_time")
("ms1_target_total_ion_count", boost::program_options::value<double>(&ms1_target_total_ion_count)->default_value(1e6), "ms1_target_total_ion_count")
("ms2_target_total_ion_count", boost::program_options::value<double>(&ms2_target_total_ion_count)->default_value(1e5), "ms2_target_total_ion_count")
;
boost::program_options::variables_map vm_config;
std::ifstream config_file(param_file_path.c_str());
if(!config_file.is_open()) {
std::cerr << "Unable to open configuration file: " << param_file_path << std::endl;
exit(1);
}
boost::program_options::store(boost::program_options::parse_config_file(config_file, config, true), vm_config);
boost::program_options::notify(vm_config);
//endregion
ElutionShapeSimulator elution_shape_simulator(elution_tau, elution_sigma);
std::unique_ptr<GroundTruthText> db = std::unique_ptr<GroundTruthText>(new GroundTruthText(sqlite_in_path, false));
std::unique_ptr<Instrument> instrument = std::unique_ptr<Instrument>(new Instrument(resolution, dynamic_range, ms1_scan_time, ms2_scan_time,
scan_overhead_time, max_ms1_injection_time,
max_ms2_injection_time, ms1_target_total_ion_count,
ms2_target_total_ion_count));
Sequencer sequencer(fasta_in_path, PTMs, enzymes, db_search_mass_tolerance, db_search_max_missed_cleavages, db_search_min_enzymatic_termini, db_search_min_mass, db_search_max_mass, db_search_max_dynamic_mods, null_lambda);
Oracle oracle(db.get(), instrument.get(), elution_shape_simulator);
MzMLWriter mzml_writer(mzml_out_path);
FidoWriter fido_writer(fido_out_path);
AcquisitionController* controller = get_controller(acquisition_algorithm_name, acquisition_param_values);
int ms1_count = 0;
int ms2_count = 0;
int quality_ms2_count = 0;
double current_time = 0;
std::cout << "Simulating Acquisition:" << std::endl;
while (current_time <= acquisition_length) {
std::unique_ptr<ScanRequest> scan_request = controller->get_scan_request(current_time);
std::unique_ptr<Scan> scan = oracle.get_scan_data(scan_request.get(), current_time);
if (scan->scan_type == Scan::ScanType::MS2) {
ms2_count++;
MS2Scan* tmp_scan = static_cast<MS2Scan*>(scan.get());
sequencer.sequence_ms2_scan(tmp_scan);
if (tmp_scan->probability >= 0 && tmp_scan->peptide != "DECOY") {
fido_writer.write_peptide(tmp_scan->probability, tmp_scan->peptide, tmp_scan->proteins);
if (tmp_scan->probability >= .9) quality_ms2_count++;
}
/*double max_int = 0;
std::string max_pep;
for (auto itr = tmp_scan->peptide2intensity.begin(); itr != tmp_scan->peptide2intensity.end(); ++itr) {
if (itr->second > max_int) {
max_int = itr->second;
max_pep = itr->first;