本文整理汇总了C++中Trace::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Trace::clear方法的具体用法?C++ Trace::clear怎么用?C++ Trace::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Trace
的用法示例。
在下文中一共展示了Trace::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: putchar
static int
TestOLC(DebugReplay &replay)
{
for (int i = 1; replay.Next(); i++) {
if (i % 500 == 0) {
putchar('.');
fflush(stdout);
}
const AircraftState state =
ToAircraftState(replay.Basic(), replay.Calculated());
full_trace.append(state);
sprint_trace.append(state);
full_trace.optimise_if_old();
sprint_trace.optimise_if_old();
olc_sprint.UpdateIdle();
}
olc_classic.SolveExhaustive();
olc_fai.SolveExhaustive();
olc_league.SolveExhaustive();
olc_plus.SolveExhaustive();
putchar('\n');
std::cout << "classic\n";
PrintHelper::print(olc_classic.GetStats().get_contest_result());
std::cout << "league\n";
PrintHelper::print(olc_league.GetStats().get_contest_result());
std::cout << "fai\n";
PrintHelper::print(olc_fai.GetStats().get_contest_result());
std::cout << "sprint\n";
PrintHelper::print(olc_sprint.GetStats().get_contest_result());
std::cout << "plus\n";
PrintHelper::print(olc_plus.GetStats().get_contest_result());
olc_classic.Reset();
olc_fai.Reset();
olc_sprint.Reset();
olc_league.Reset();
olc_plus.Reset();
full_trace.clear();
sprint_trace.clear();
return 0;
}
示例2: second_subproblem
/* We resolve the second subproblem through sky-plane projection */
Sequence second_subproblem (Tensor5D& W_1, Tensor5D& W_2, Tensor5D& Y, double& mu, SequenceSet& allSeqs, vector<int> lenSeqs) {
/*{{{*/
int numSeq = allSeqs.size();
int T2 = W_2[0][0].size();
// reinitialize W_2 to all-zero matrix
for (int n = 0; REINIT_W_ZERO_TOGGLE and n < numSeq; n ++) {
int T1 = W_2[n].size();
for (int i = 0; i < T1; i ++)
for (int j = 0; j < T2; j ++)
for (int d = 0; d < NUM_DNA_TYPE; d ++)
for (int m = 0; m < NUM_MOVEMENT; m ++)
W_2[n][i][j][d][m] = 0.0;
}
vector<Tensor4D> delta (numSeq, Tensor4D(0, Tensor(T2, Matrix(NUM_DNA_TYPE,
vector<double>(NUM_MOVEMENT, 0.0)))));
tensor5D_init (delta, allSeqs, lenSeqs, T2);
Tensor tensor (T2, Matrix (NUM_DNA_TYPE, vector<double>(NUM_DNA_TYPE, 0.0)));
Matrix mat_insertion (T2, vector<double>(NUM_DNA_TYPE, 0.0));
Trace trace (0, Cell(2)); // 1d: j, 2d: ATCG
int fw_iter = -1;
while (fw_iter < MAX_2nd_FW_ITER) {
fw_iter ++;
// 1. compute delta
#ifdef PARRALLEL_COMPUTING
//#pragma omp parallel for
#endif
for (int n = 0; n < numSeq; n ++) {
int T1 = W_2[n].size();
for (int i = 0; i < T1; i ++) {
for (int j = 0; j < T2; j ++)
for (int d = 0; d < NUM_DNA_TYPE; d ++)
for (int m = 0; m < NUM_MOVEMENT; m ++) {
delta[n][i][j][d][m] = -1.0* mu * (W_2[n][i][j][d][m] - W_1[n][i][j][d][m]) + Y[n][i][j][d][m];
#ifdef SECOND_SUBPROBLEM_DEBUG
if (delta[n][i][j][d][m] > 0)
cout <<"delta: " << n << "," << i << "," << j << "," << d << "," << m << ": "
<< delta[n][i][j][d][m] << endl;
#endif
if (m == DELETION_A or m == MATCH_A)
tensor[j][d][dna2T3idx('A')] += max(0.0, delta[n][i][j][d][m]);
else if (m == DELETION_T or m == MATCH_T)
tensor[j][d][dna2T3idx('T')] += max(0.0, delta[n][i][j][d][m]);
else if (m == DELETION_C or m == MATCH_C)
tensor[j][d][dna2T3idx('C')] += max(0.0, delta[n][i][j][d][m]);
else if (m == DELETION_G or m == MATCH_G)
tensor[j][d][dna2T3idx('G')] += max(0.0, delta[n][i][j][d][m]);
else if (m == DELETION_START or m == MATCH_START)
tensor[j][d][dna2T3idx('*')] += max(0.0, delta[n][i][j][d][m]);
else if (m == DELETION_END or m == MATCH_END)
tensor[j][d][dna2T3idx('#')] += max(0.0, delta[n][i][j][d][m]);
else if (m == INSERTION) {
mat_insertion[j][d] += max(0.0, delta[n][i][j][d][m]);
}
}
}
}
#ifdef SECOND_SUBPROBLEM_DEBUG
cout << "tensor transition input list:" << endl;
for (int j = 0; j < T2; j ++)
for (int d = 0; d < NUM_DNA_TYPE; d ++)
for (int k = 0; k < NUM_DNA_TYPE; k ++) {
if (tensor[j][d][k] > 0)
cout << "(" << j << ", " << d << ", " << k << ")=" << tensor[j][d][k] << endl;
}
#endif
double delta_square = 0.0;
for (int n = 0; n < numSeq; n ++)
delta_square += tensor4D_frob_prod (delta[n], delta[n]);
//cout << "delta_square: " << delta_square << endl;
if ( delta_square < 1e-12 ) {
//cout << "small delta. early stop." << endl;
break;
}
// 2. determine the trace: run viterbi algorithm
trace.clear();
refined_viterbi_algo (trace, tensor, mat_insertion);
Tensor5D S (numSeq, Tensor4D(0, Tensor(T2, Matrix(NUM_DNA_TYPE, vector<double>(NUM_MOVEMENT, 0.0)))));
tensor5D_init (S, allSeqs, lenSeqs, T2);
// 3. recover values for S
// 3b. set a number of selected elements to 1
for (int t = 0; t < trace.size(); t++) {
int sj = trace[t].location[0];
int sd = trace[t].location[1];
int sm = dna2T3idx(trace[t].acidB);
// cout << trace[t].acidB;
for (int n = 0; n < numSeq; n ++) {
int T1 = S[n].size();
for (int i = 0; i < T1; i ++) {
for (int m = 0; m < NUM_MOVEMENT; m ++)
if (delta[n][i][sj][sd][m] > 0.0) {
if (m == DEL_BASE_IDX + sm or m == MTH_BASE_IDX + sm)
S[n][i][sj][sd][m] = 1.0;
else if (m == INSERTION and trace[t].action == INSERTION) {
S[n][i][sj][sd][m] = 1.0;
//.........这里部分代码省略.........
示例3: point
static int
TestOLC(DebugReplay &replay)
{
bool released = false;
for (int i = 1; replay.Next(); i++) {
if (i % 500 == 0) {
putchar('.');
fflush(stdout);
}
const MoreData &basic = replay.Basic();
if (!basic.time_available || !basic.location_available ||
!basic.NavAltitudeAvailable())
continue;
if (!released && !negative(replay.Calculated().flight.release_time)) {
released = true;
triangle_trace.EraseEarlierThan(replay.Calculated().flight.release_time);
full_trace.EraseEarlierThan(replay.Calculated().flight.release_time);
sprint_trace.EraseEarlierThan(replay.Calculated().flight.release_time);
}
const TracePoint point(basic);
triangle_trace.push_back(point);
full_trace.push_back(point);
sprint_trace.push_back(point);
olc_sprint.UpdateIdle();
olc_league.UpdateIdle();
}
olc_classic.SolveExhaustive();
olc_fai.SolveExhaustive();
olc_league.SolveExhaustive();
olc_plus.SolveExhaustive();
dmst.SolveExhaustive();
xcontest.SolveExhaustive();
sis_at.SolveExhaustive();
olc_netcoupe.SolveExhaustive();
putchar('\n');
std::cout << "classic\n";
PrintHelper::print(olc_classic.GetStats().GetResult());
std::cout << "league\n";
std::cout << "# league\n";
PrintHelper::print(olc_league.GetStats().GetResult(0));
std::cout << "# classic\n";
PrintHelper::print(olc_league.GetStats().GetResult(1));
std::cout << "fai\n";
PrintHelper::print(olc_fai.GetStats().GetResult());
std::cout << "sprint\n";
PrintHelper::print(olc_sprint.GetStats().GetResult());
std::cout << "plus\n";
std::cout << "# classic\n";
PrintHelper::print(olc_plus.GetStats().GetResult(0));
std::cout << "# triangle\n";
PrintHelper::print(olc_plus.GetStats().GetResult(1));
std::cout << "# plus\n";
PrintHelper::print(olc_plus.GetStats().GetResult(2));
std::cout << "dmst\n";
PrintHelper::print(dmst.GetStats().GetResult());
std::cout << "xcontest\n";
std::cout << "# free\n";
PrintHelper::print(xcontest.GetStats().GetResult(0));
std::cout << "# triangle\n";
PrintHelper::print(xcontest.GetStats().GetResult(1));
std::cout << "sis_at\n";
PrintHelper::print(sis_at.GetStats().GetResult(0));
std::cout << "netcoupe\n";
PrintHelper::print(olc_netcoupe.GetStats().GetResult());
olc_classic.Reset();
olc_fai.Reset();
olc_sprint.Reset();
olc_league.Reset();
olc_plus.Reset();
dmst.Reset();
olc_netcoupe.Reset();
full_trace.clear();
sprint_trace.clear();
return 0;
}