Connect++ 0.5.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
schedule::Schedule Class Reference

Wrap up the parsing process and the operation of a schedule in a single class. More...

#include <Schedule.hpp>

Collaboration diagram for schedule::Schedule:

Public Member Functions

 Schedule ()
 You only need this constructor because everything will be filled in by the parser.
 
void reset_schedule ()
 Go back to the beginning of the schedule but leave everything else intact.
 
string step_to_string (size_t) const
 Make a string representation of a line in the schedule.
 
void read_schedule_from_file (fs::path)
 Self-explanatory.
 
pair< bool, unsigned int > set_next_schedule ()
 Apply the settings for the next step in the schedule.
 

Private Member Functions

void apply_item (const pair< schedule_step, unsigned int > &)
 Apply the settings for a single step in a schedule.
 

Private Attributes

vector< vector< pair< schedule_step, unsigned int > > > schedule
 Representation of a schedule.
 
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.
 

Friends

ostream & operator<< (ostream &, const Schedule &)
 

Detailed Description

Wrap up the parsing process and the operation of a schedule in a single class.

This covers parsing, and also the sequencing, including manipulation of parameters for each step, of a schedule stored in a file.

The main elements of a file exactly mimic the command line options, so a single step in a schedule acts exactly as though the relevant options had been supplied to a single call from the command line. Well, almost. There is less sanity-checking than the command line has, so be careful to specify options giving thought to how they might interact.

Aside from that, a line ends with a semicolon, and there is a number at the start of the line specifying a percentage of the timeout. The last line should start with 0, specifying "all remaining".

Definition at line 110 of file Schedule.hpp.

Constructor & Destructor Documentation

◆ Schedule()

schedule::Schedule::Schedule ( )
inline

You only need this constructor because everything will be filled in by the parser.

Definition at line 136 of file Schedule.hpp.

vector< vector< pair< schedule_step, unsigned int > > > schedule
Representation of a schedule.
Definition Schedule.hpp:118
vector< unsigned int > times
Times for each member of a schedule.
Definition Schedule.hpp:122
size_t schedule_step_number
Keep track of which step in the schedule we're on.
Definition Schedule.hpp:126

Member Function Documentation

◆ apply_item()

void schedule::Schedule::apply_item ( const pair< schedule_step, unsigned int > & item)
private

Apply the settings for a single step in a schedule.

Definition at line 270 of file Schedule.cpp.

270 {
271 schedule_step step = item.first;
272 unsigned int value = item.second;
273 switch (step) {
274 case schedule_step::all_definitional:
275 if (params::no_definitional) {
276 params::no_definitional = false;
277 cerr << "Warning: --all-definitional cancels --no-definitional." << endl;
278 }
279 params::all_definitional = true;
280 break;
281 case schedule_step::no_definitional:
282 if (params::all_definitional) {
283 params::all_definitional = false;
284 cerr << "Warning: --no-definitional cancels --all-definitional." << endl;
285 }
286 params::no_definitional = true;
287 break;
288 case schedule_step::reorder:
289 params::deterministic_reorder = true;
290 params::number_of_reorders = value;
291 break;
292 case schedule_step::rand_reorder:
293 params::random_reorder = true;
294 break;
295 case schedule_step::rand_lits:
296 params::random_reorder_literals = true;
297 break;
298 case schedule_step::all_start:
300 break;
301 case schedule_step::pos_neg_start:
302 if (params::all_start) {
303 cerr << "Warning: are you sure you want to mix --all-start with --pos-neg-start?" << endl;
304 }
305 params::all_pos_neg_start = true;
306 break;
307 case schedule_step::conjecture_start:
308 if (params::all_start) {
309 cerr << "Warning: are you sure you want to mix --all-start with --conjecture-start?" << endl;
310 }
311 params::conjecture_start = true;
312 break;
313 case schedule_step::restrict_start:
314 if (params::all_start) {
315 cerr << "Warning: are you sure you want to mix --all-start with --restrict-start?" << endl;
316 }
317 params::restrict_start = true;
318 break;
319 case schedule_step::no_regularity:
320 params::use_regularity_test = false;
321 break;
322 case schedule_step::all_lemmata:
323 params::limit_lemmata = false;
324 break;
325 case schedule_step::all_reductions:
326 params::limit_reductions = false;
327 break;
328 case schedule_step::all_extensions:
329 params::limit_extensions = false;
330 break;
331 case schedule_step::no_lemmata:
332 params::use_lemmata = false;
333 break;
334 case schedule_step::all_backtrack:
336 break;
337 case schedule_step::lemmata_backtrack:
338 params::limit_bt_lemmas = false;
339 break;
340 case schedule_step::reduction_backtrack:
341 params::limit_bt_reductions = false;
342 break;
343 case schedule_step::extension_backtrack:
344 params::limit_bt_extensions = false;
345 break;
346 case schedule_step::explore_left_trees:
347 params::limit_bt_extensions_left_tree = false;
348 break;
349 case schedule_step::complete:
350 params::switch_to_complete = value;
351 break;
352 case schedule_step::start_depth:
353 params::start_depth = value;
354 break;
355 case schedule_step::depth_inc:
356 params::depth_increment = value;
357 break;
358 case schedule_step::limit_by_tree_depth:
359 params::limit_by_tree_depth = true;
360 break;
361 default:
362 break;
363 }
364}
schedule_step
Possible kinds of schedule step.
Definition Schedule.hpp:63
static void set_all_backtrack()
Self-explanatory.
static void set_all_start()
Self-explanatory.

◆ read_schedule_from_file()

void schedule::Schedule::read_schedule_from_file ( fs::path path)

Self-explanatory.

Produces an empty schedule if parsing fails.

Parameters
pathPath of file to read from.

Definition at line 226 of file Schedule.cpp.

226 {
227 string file_contents;
228 if (path == "default") {
229 params::set_default_schedule();
230 file_contents = params::default_schedule;
231 }
232 else {
233 ifstream file;
234 file.open(path);
235 if (file.fail()) {
236 throw (file_open_exception(path));
237 }
238 string current_line;
239 std::getline(file, current_line);
240 file_contents += current_line;
241 while (file.good()) {
242 std::getline(file, current_line);
243 file_contents += current_line;
244 }
245 file.close();
246 }
247
248 Iter start = file_contents.begin();
249 Iter end = file_contents.end();
250
251 schedule_grammar<Iter> g;
252 bool result = qi::phrase_parse(start, end, g, ascii::space);
253
254 if (start != end || !result) {
255 std::cerr << "Failed to parse schedule file." << endl;
256 new_schedule.clear();
257 new_times.clear();
258 }
259 schedule = new_schedule;
260 times = new_times;
261 if (times.back() != 0)
262 std::cerr << "Warning: the last time entry in the schedule should be 0" << endl;
263 unsigned int total = 0;
264 for (unsigned int t : times)
265 total += t;
266 if (total > 100)
267 std::cerr << "Warning: your time percentages add up to more than 100" << endl;
268}
Exception used by the application in main(...).
Hide all the global stuff in this namespace.
Definition Schedule.cpp:27

◆ reset_schedule()

void schedule::Schedule::reset_schedule ( )
inline

Go back to the beginning of the schedule but leave everything else intact.

Definition at line 141 of file Schedule.hpp.

◆ set_next_schedule()

pair< bool, unsigned int > schedule::Schedule::set_next_schedule ( )

Apply the settings for the next step in the schedule.

Returns
True and the percentage of time to run for if successful, false and 0 otherwise.

Definition at line 366 of file Schedule.cpp.

366 {
368 pair<bool,unsigned int> result(false,0);
369 if (schedule_step_number == schedule.size())
370 return result;
371 for(size_t i = 0; i < schedule[schedule_step_number].size(); i++) {
373 }
374 result.first = true;
375 result.second = times[schedule_step_number];
377 /*
378 * Make sure there is something specified as a start clause.
379 */
382 }
383 return result;
384 }
void apply_item(const pair< schedule_step, unsigned int > &)
Apply the settings for a single step in a schedule.
Definition Schedule.cpp:270
static void set_default_schedule_parameters()
Self-explanatory.
static bool no_start_options()
Self-explanatory.
static void correct_missing_start_options()
Self-explanatory.

◆ step_to_string()

string schedule::Schedule::step_to_string ( size_t n) const

Make a string representation of a line in the schedule.

Parameters
nLine to convert.
Returns
String representation.

Definition at line 386 of file Schedule.cpp.

386 {
387 string result("Time: ");
388 if (n < schedule.size()) {
389 result += std::to_string(times[n]);
390 for (size_t j = 0; j < schedule[n].size(); j++) {
391 result += " (";
392 result += to_string((schedule[n])[j].first);
393 result += ", ";
394 result += std::to_string((schedule[n])[j].second);
395 result += ")";
396 }
397 }
398 return result;
399 }

Friends And Related Symbol Documentation

◆ operator<<

ostream & operator<< ( ostream & out,
const Schedule & s )
friend

Definition at line 401 of file Schedule.cpp.

401 {
402 for (size_t i = 0; i < s.schedule.size(); i++) {
403 out << s.step_to_string(i) << endl;
404 }
405 return out;
406 }

Member Data Documentation

◆ schedule

vector<vector<pair<schedule_step,unsigned int> > > schedule::Schedule::schedule
private

Representation of a schedule.

Each element is a vector of pairs. Each pair is an identifier for a step, and an integer. Times are dealt with elsewhere.

Definition at line 118 of file Schedule.hpp.

◆ schedule_step_number

size_t schedule::Schedule::schedule_step_number
private

Keep track of which step in the schedule we're on.

Definition at line 126 of file Schedule.hpp.

◆ times

vector<unsigned int> schedule::Schedule::times
private

Times for each member of a schedule.

Definition at line 122 of file Schedule.hpp.


The documentation for this class was generated from the following files: