GEDLIB  1.0
train_ring.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2018 by David B. Blumenthal *
4  * *
5  * This file is part of GEDLIB. *
6  * *
7  * GEDLIB is free software: you can redistribute it and/or modify it *
8  * under the terms of the GNU Lesser General Public License as published *
9  * by the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * GEDLIB is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU Lesser General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU Lesser General Public *
18  * License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 
31 #include "util.hpp"
32 
33 void train_on_dataset(const std::string & dataset) {
34 
35  // Initialize environment.
36  std::cout << "\n=== " << dataset << " ===\n";
37  std::cout << "\tInitializing the environment ...\n";
39  util::setup_environment(dataset, true, env);
40 
41  // Learn the parameters.
42  std::vector<std::string> led_methods{"GAMMA", "LSAPE_GREEDY", "LSAPE_OPTIMAL"};
43  for (auto led_method : led_methods) {
44  std::cout << "\n=== " << led_method << " ===\n";
45  env.set_method(ged::Options::GEDMethod::RING, util::init_options(dataset, std::string("ring_") + led_method) + " --led-method " + led_method);
46  env.init_method();
47  }
48 }
49 
50 int main(int argc, char* argv[]) {
51  std::vector<std::string> datasets;
52  for (int i{1}; i < argc; i++) {
53  datasets.push_back(std::string(argv[i]));
54  util::check_dataset(datasets.back());
55  }
56  if (datasets.empty()) {
57  util::setup_datasets(datasets);
58  }
59  for (auto dataset : datasets) {
60  try {
61  train_on_dataset(dataset);
62  }
63  catch (const std::exception & error) {
64  std::cerr << error.what() << ". " << "Error on " << dataset << ".\n";
65  }
66  }
67  return 0;
68 }
void init_method()
Initializes the method specified by call to set_method().
Definition: ged_env.ipp:521
Provides utility functions for tests of PR submission.
void set_method(Options::GEDMethod method, const std::string &options=std::string(""))
Sets the GEDMethod to be used by run_method().
Definition: ged_env.ipp:384
Provides the API of GEDLIB.
Definition: ged_data.hpp:48