static void Apply(HMMType& hmm, void* /* extraInfo */) { mat observations; Row<size_t> sequence; // Load the parameters. const size_t startState = (size_t) CLI::GetParam<int>("start_state"); const size_t length = (size_t) CLI::GetParam<int>("length"); const string outputFile = CLI::GetParam<string>("output_file"); const string sequenceFile = CLI::GetParam<string>("state_file"); Log::Info << "Generating sequence of length " << length << "..." << endl; if (startState >= hmm.Transition().n_rows) Log::Fatal << "Invalid start state (" << startState << "); must be " << "between 0 and number of states (" << hmm.Transition().n_rows << ")!" << endl; hmm.Generate(length, observations, sequence, startState); // Now save the output. if (CLI::HasParam("output_file")) data::Save(outputFile, observations, true); // Do we want to save the hidden sequence? if (CLI::HasParam("state_file")) data::Save(sequenceFile, sequence, true); if (outputFile == "" && sequenceFile == "") Log::Warn << "Neither --output_file nor --state_file are specified; no " << "output will be saved." << endl; }
static void Apply(HMMType& hmm, void* /* extraInfo */) { mat observations; Row<size_t> sequence; // Load the parameters. const size_t startState = (size_t) CLI::GetParam<int>("start_state"); const size_t length = (size_t) CLI::GetParam<int>("length"); Log::Info << "Generating sequence of length " << length << "..." << endl; if (startState >= hmm.Transition().n_rows) Log::Fatal << "Invalid start state (" << startState << "); must be " << "between 0 and number of states (" << hmm.Transition().n_rows << ")!" << endl; hmm.Generate(length, observations, sequence, startState); // Now save the output. if (CLI::HasParam("output")) CLI::GetParam<mat>("output") = std::move(observations); // Do we want to save the hidden sequence? if (CLI::HasParam("state")) CLI::GetParam<Mat<size_t>>("state") = std::move(sequence); }