25#include "Schedule.hpp"
32 case schedule_step::reorder:
33 return string(
"--reorder");
35 case schedule_step::all_start:
36 return string(
"--all-start");
38 case schedule_step::pos_neg_start:
39 return string(
"--pos-neg-start");
41 case schedule_step::conjecture_start:
42 return string(
"--conjecture-start");
44 case schedule_step::restrict_start:
45 return string(
"--restrict-start");
47 case schedule_step::no_regularity:
48 return string(
"--no-regularity");
50 case schedule_step::no_lemmata:
51 return string(
"--no-lemmata");
53 case schedule_step::all_lemmata:
54 return string(
"--all-lemmata");
56 case schedule_step::all_reductions:
57 return string(
"--all-reductions");
59 case schedule_step::all_extensions:
60 return string(
"--all-extensions");
62 case schedule_step::all_backtrack:
63 return string(
"--all-backtrack");
65 case schedule_step::lemmata_backtrack:
66 return string(
"--lemmata-backtrack");
68 case schedule_step::reduction_backtrack:
69 return string(
"--reduction-backtrack");
71 case schedule_step::extension_backtrack:
72 return string(
"--extension-backtrack");
74 case schedule_step::explore_left_trees:
75 return string(
"--explore-left-trees");
77 case schedule_step::hard_prune:
78 return string(
"--hard-prune");
80 case schedule_step::complete:
81 return string(
"--complete");
91unsigned int value = 0;
92unsigned int current_time = 0;
94vector<pair<schedule_step, unsigned int>> current_settings;
95vector<vector<pair<schedule_step, unsigned int>>> new_schedule;
96vector<unsigned int> new_times;
100void add_time::operator()(
unsigned int t, qi::unused_type,
101 qi::unused_type)
const {
104void set_value::operator()(
unsigned int v, qi::unused_type,
105 qi::unused_type)
const {
108void set_step::operator()(
string s, qi::unused_type,
109 qi::unused_type)
const {
112void add_step::operator()(qi::unused_type, qi::unused_type)
const {
114 if (step ==
"--reorder") step2 = schedule_step::reorder;
115 if (step ==
"--all-start") step2 = schedule_step::all_start;
116 if (step ==
"--pos-neg-start") step2 = schedule_step::pos_neg_start;
117 if (step ==
"--conjecture-start") step2 = schedule_step::conjecture_start;
118 if (step ==
"--restrict-start") step2 = schedule_step::restrict_start;
119 if (step ==
"--no-regularity") step2 = schedule_step::no_regularity;
120 if (step ==
"--no-lemmata") step2 = schedule_step::no_lemmata;
121 if (step ==
"--all-lemmata") step2 = schedule_step::all_lemmata;
122 if (step ==
"--all-reductions") step2 = schedule_step::all_reductions;
123 if (step ==
"--all-extensions") step2 = schedule_step::all_extensions;
124 if (step ==
"--all-backtrack") step2 = schedule_step::all_backtrack;
125 if (step ==
"--lemmata-backtrack") step2 = schedule_step::lemmata_backtrack;
126 if (step ==
"--reduction-backtrack") step2 = schedule_step::reduction_backtrack;
127 if (step ==
"--extension-backtrack") step2 = schedule_step::extension_backtrack;
128 if (step ==
"--explore-left-trees") step2 = schedule_step::explore_left_trees;
129 if (step ==
"--hard-prune") step2 = schedule_step::hard_prune;
130 if (step ==
"--complete") step2 = schedule_step::complete;
131 current_settings.push_back(pair<schedule_step, unsigned int>(step2, value));
135void next_settings::operator()(qi::unused_type, qi::unused_type)
const {
136 new_schedule.push_back(current_settings);
137 new_times.push_back(current_time);
139 current_settings.clear();
144qi::rule<Iter, string()> schedule_word =
145 ascii::string(
"--all-start")
146 | ascii::string(
"--pos-neg-start")
147 | ascii::string(
"--conjecture-start")
148 | ascii::string(
"--restrict-start")
149 | ascii::string(
"--no-regularity")
150 | ascii::string(
"--no-lemmata")
151 | ascii::string(
"--all-lemmata")
152 | ascii::string(
"--all-reductions")
153 | ascii::string(
"--all-extensions")
154 | ascii::string(
"--all-backtrack")
155 | ascii::string(
"--lemmata-backtrack")
156 | ascii::string(
"--reduction-backtrack")
157 | ascii::string(
"--extension-backtrack")
158 | ascii::string(
"--explore-left-trees")
159 | ascii::string(
"--hard-prune");
161qi::rule<Iter, string()> schedule_word_param =
162 ascii::string(
"--complete")
163 | ascii::string(
"--reorder");
169 : qi::grammar<It, ascii::space_type>
172 : schedule_grammar::base_type(
schedule) {
176 | ((schedule_word_param [
set_step()])
186 qi::rule<Iter, ascii::space_type> schedule_item;
187 qi::rule<Iter, ascii::space_type> schedule_line;
188 qi::rule<Iter, ascii::space_type>
schedule;
194 string file_contents;
195 if (path ==
"default") {
196 params::set_default_schedule();
197 file_contents = params::default_schedule;
206 std::getline(file, current_line);
207 file_contents += current_line;
208 while (file.good()) {
209 std::getline(file, current_line);
210 file_contents += current_line;
215 Iter start = file_contents.begin();
216 Iter end = file_contents.end();
219 bool result = qi::phrase_parse(start, end, g, ascii::space);
221 if (start != end || !result) {
222 std::cerr <<
"Failed to parse schedule file." << endl;
223 new_schedule.clear();
228 if (
times.back() != 0)
229 std::cerr <<
"Warning: the last time entry in the schedule should be 0" << endl;
230 unsigned int total = 0;
231 for (
unsigned int t :
times)
234 std::cerr <<
"Warning: your time percentages add up to more than 100" << endl;
239 unsigned int value = item.second;
241 case schedule_step::reorder:
242 params::deterministic_reorder =
true;
243 params::number_of_reorders = value;
245 case schedule_step::all_start:
248 case schedule_step::pos_neg_start:
249 params::all_pos_neg_start =
true;
251 case schedule_step::conjecture_start:
252 params::conjecture_start =
true;
254 case schedule_step::restrict_start:
255 params::restrict_start =
true;
257 case schedule_step::no_regularity:
258 params::use_regularity_test =
false;
260 case schedule_step::no_lemmata:
261 params::use_lemmata =
false;
263 case schedule_step::all_lemmata:
264 params::limit_lemmata =
false;
266 case schedule_step::all_reductions:
267 params::limit_reductions =
false;
269 case schedule_step::all_extensions:
270 params::limit_extensions =
false;
272 case schedule_step::all_backtrack:
275 case schedule_step::lemmata_backtrack:
276 params::limit_bt_lemmas =
false;
278 case schedule_step::reduction_backtrack:
279 params::limit_bt_reductions =
false;
281 case schedule_step::extension_backtrack:
282 params::limit_bt_extensions =
false;
284 case schedule_step::explore_left_trees:
285 params::limit_bt_extensions_left_tree =
false;
287 case schedule_step::hard_prune:
288 params::hard_prune =
true;
290 case schedule_step::complete:
291 params::switch_to_complete = value;
300 pair<bool,unsigned int> result(
false,0);
319 string result(
"Time: ");
321 result += std::to_string(
times[n]);
322 for (
size_t j = 0; j <
schedule[n].size(); j++) {
324 result += to_string((
schedule[n])[j].first);
326 result += std::to_string((
schedule[n])[j].second);
333 ostream& operator<<(ostream& out,
const Schedule& s) {
334 for (
size_t i = 0; i < s.
schedule.size(); i++) {
Exception used by the application in main(...).
Wrap up the parsing process and the operation of a schedule in a single class.
vector< vector< pair< schedule_step, unsigned int > > > schedule
Representation of a schedule.
void read_schedule_from_file(fs::path)
Self-explanatory.
vector< unsigned int > times
Times for each member of a schedule.
size_t schedule_step_number
Keep track of which step in the schedule we're on.
void apply_item(const pair< schedule_step, unsigned int > &)
Apply the settings for a single step in a schedule.
string step_to_string(size_t) const
Make a string representation of a line in the schedule.
pair< bool, unsigned int > set_next_schedule()
Apply the settings for the next step in the schedule.
Hide all the global stuff in this namespace.
schedule_step
Possible kinds of schedule step.
static void set_default_schedule_parameters()
Self-explanatory.
static void set_all_backtrack()
Self-explanatory.
static void set_all_start()
Self-explanatory.
static bool no_start_options()
Self-explanatory.
static void correct_missing_start_options()
Self-explanatory.
Semantic action for parser.
Semantic action for parser.
Semantic action for parser.
Semantic action for parser.
Semantic action for parser.