Connect++ 0.6.1
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 &out, const Schedule &s)
 

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.

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 107 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 133 of file Schedule.hpp.

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

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 266 of file Schedule.cpp.

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

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

359 {
361 pair<bool,unsigned int> result(false,0);
362 if (schedule_step_number == schedule.size())
363 return result;
364 for(size_t i = 0; i < schedule[schedule_step_number].size(); i++) {
366 }
367 result.first = true;
368 result.second = times[schedule_step_number];
370 /*
371 * Make sure there is something specified as a start clause.
372 */
375 }
376 return result;
377 }
void apply_item(const pair< schedule_step, unsigned int > &)
Apply the settings for a single step in a schedule.
Definition Schedule.cpp:266
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 379 of file Schedule.cpp.

379 {
380 string result("Time: ");
381 if (n < schedule.size()) {
382 result += std::to_string(times[n]);
383 for (size_t j = 0; j < schedule[n].size(); j++) {
384 result += " (";
385 result += to_string((schedule[n])[j].first);
386 result += ", ";
387 result += std::to_string((schedule[n])[j].second);
388 result += ")";
389 }
390 }
391 return result;
392 }

Friends And Related Symbol Documentation

◆ operator<<

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

Definition at line 394 of file Schedule.cpp.

394 {
395 for (size_t i = 0; i < s.schedule.size(); i++) {
396 out << s.step_to_string(i) << endl;
397 }
398 return out;
399 }

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 115 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 123 of file Schedule.hpp.

◆ times

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

Times for each member of a schedule.

Definition at line 119 of file Schedule.hpp.


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