delpi
0.0.1
DElta-complete LP solver
Toggle main menu visibility
Loading...
Searching...
No Matches
Driver.cpp
1
6
#include "delpi/parser/Driver.h"
7
8
#include <fstream>
9
#include <iostream>
10
#include <sstream>
// IWYU pragma: keep for std::stringstream
11
#include <string>
12
13
#include "delpi/libs/gmp.h"
14
#include "delpi/util/Config.h"
15
#include "delpi/util/error.h"
16
17
namespace
delpi
{
18
19
Driver::Driver
(
LpSolver
& lp_solver,
const
std::string& class_name)
20
:
lp_solver_
{lp_solver},
stats_
{lp_solver.config().with_timings(), class_name,
"Total time spent in parsing"
} {}
21
22
bool
Driver::ParseStream
(std::istream& in,
const
std::string& sname) {
23
TimerGuard
timer_guard(&
stats_
.m_timer(),
stats_
.enabled());
24
input_name_
= sname;
25
return
ParseStreamCore
(in);
26
}
27
28
bool
Driver::ParseString
(std::string_view input,
const
std::string& sname) {
29
TimerGuard
timer_guard(&
stats_
.m_timer(),
stats_
.enabled());
30
input_name_
= sname;
31
return
ParseStringCore
(input);
32
}
33
34
bool
Driver::ParseFile
(
const
std::string& filename) {
35
TimerGuard
timer_guard(&
stats_
.m_timer(),
stats_
.enabled());
36
return
ParseFileCore
(filename);
37
}
38
39
void
Driver::Error
(
const
std::string& m) { std::cerr << m << std::endl; }
40
41
void
Driver::Solve
() {
42
// Don't consider the time spent solving the LP problem in the time spent parsing.
43
stats_
.m_timer().Pause();
44
lp_solver_
.Solve();
45
stats_
.m_timer().Resume();
46
}
47
48
void
Driver::GetInfo(
const
std::string& key)
const
{
49
if
(
lp_solver_
.config().silent())
return
;
50
std::cout <<
"get-info ( "
<< key <<
" ): "
<<
lp_solver_
.
GetInfo
(key) << std::endl;
51
}
52
void
Driver::SetInfo(
const
std::string& key,
const
std::string& value) {
lp_solver_
.
SetInfo
(key, value); }
53
void
Driver::SetOption(
const
std::string& key,
const
std::string& value) {
lp_solver_
.SetOption(key, value); }
54
void
Driver::Exit() { DELPI_DEBUG(
"Exit"
); }
55
56
}
// namespace delpi
delpi::Driver::ParseStreamCore
virtual bool ParseStreamCore(std::istream &in)=0
Parse the stream.
delpi::Driver::ParseFileCore
virtual bool ParseFileCore(const std::string &filename)=0
Parse the input file.
delpi::Driver::ParseString
bool ParseString(std::string_view input, const std::string &sname="string stream")
Invoke the scanner and parser on an input string.
Definition
Driver.cpp:28
delpi::Driver::lp_solver_
LpSolver & lp_solver_
LP parser that will store the parsed data.
Definition
Driver.h:113
delpi::Driver::Driver
Driver(LpSolver &lp_solver, const std::string &class_name="Driver")
construct a new parser driver context
Definition
Driver.cpp:19
delpi::Driver::input_name_
std::string input_name_
The name of the stream being parsed.
Definition
Driver.h:111
delpi::Driver::ParseStringCore
virtual bool ParseStringCore(std::string_view input)=0
Parse the string.
delpi::Driver::Error
static void Error(const std::string &m)
General error handling.
Definition
Driver.cpp:39
delpi::Driver::ParseFile
virtual bool ParseFile(const std::string &filename)
Invoke the scanner and parser on a file.
Definition
Driver.cpp:34
delpi::Driver::Solve
void Solve()
Call context_.CheckSat() and print proper output messages to the standard output.
Definition
Driver.cpp:41
delpi::Driver::stats_
IterationStats stats_
Statistics for the driver.
Definition
Driver.h:115
delpi::Driver::ParseStream
bool ParseStream(std::istream &in, const std::string &sname="stream input")
Invoke the scanner and parser for a stream.
Definition
Driver.cpp:22
delpi::LpSolver
Facade class that hides the underlying LP solver used by delpi.
Definition
LpSolver.h:60
delpi::LpSolver::SetInfo
void SetInfo(const std::string &key, const std::string &value)
Set the information stored under the given key to the given value.
Definition
LpSolver.cpp:165
delpi::LpSolver::GetInfo
const std::string & GetInfo(const std::string &key) const
Retrieve the information stored under the given key.
Definition
LpSolver.cpp:164
delpi::TimerGuard
The TimeGuard wraps a timer object and pauses it when the guard object is destructed.
Definition
Timer.h:132
delpi
Global namespace for the delpi library.
delpi
parser
Driver.cpp
Generated by
1.17.0