-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathOptionParser.cpp
128 lines (117 loc) · 4.96 KB
/
OptionParser.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/********************* */
/*! \file OptionParser.cpp
** \verbatim
** Top contributors (to current version):
** Guy Katz
** This file is part of the Marabou project.
** Copyright (c) 2017-2019 by the authors listed in the file AUTHORS
** in the top-level source directory) and their institutional affiliations.
** All rights reserved. See the file COPYING in the top-level source
** directory for licensing information.\endverbatim
**
** [[ Add lengthier description here ]]
**/
#include "Debug.h"
#include "OptionParser.h"
#include "Options.h"
OptionParser::OptionParser()
{
// This constructor should not be called
ASSERT( false );
}
OptionParser::OptionParser( Map<unsigned, bool> *boolOptions,
Map<unsigned, int> *intOptions,
Map<unsigned, float> *floatOptions,
Map<unsigned, std::string> *stringOptions )
: _optionDescription( "Supported options" )
, _boolOptions( boolOptions )
, _intOptions( intOptions )
, _floatOptions( floatOptions )
, _stringOptions( stringOptions )
{
}
void OptionParser::initialize()
{
// Possible options
_optionDescription.add_options()
( "pl-aux-eq",
boost::program_options::bool_switch( &((*_boolOptions)[Options::PREPROCESSOR_PL_CONSTRAINTS_ADD_AUX_EQUATIONS]) ),
"PL constraints generate auxiliary equations" )
( "dnc",
boost::program_options::bool_switch( &((*_boolOptions)[Options::DNC_MODE]) ),
"Use the divide-and-conquer solving mode" )
( "input",
boost::program_options::value<std::string>( &((*_stringOptions)[Options::INPUT_FILE_PATH]) ),
"Neural netowrk file" )
( "property",
boost::program_options::value<std::string>( &((*_stringOptions)[Options::PROPERTY_FILE_PATH]) ),
"Property file" )
( "input-query",
boost::program_options::value<std::string>( &((*_stringOptions)[Options::INPUT_QUERY_FILE_PATH]) ),
"Input Query file" )
( "summary-file",
boost::program_options::value<std::string>( &((*_stringOptions)[Options::SUMMARY_FILE]) ),
"Summary file" )
( "query-dump-file",
boost::program_options::value<std::string>( &((*_stringOptions)[Options::QUERY_DUMP_FILE]) ),
"Query dump file" )
( "num-workers",
boost::program_options::value<int>( &((*_intOptions)[Options::NUM_WORKERS]) ),
"(DNC) Number of workers" )
( "initial-divides",
boost::program_options::value<int>( &((*_intOptions)[Options::NUM_INITIAL_DIVIDES]) ),
"(DNC) Number of times to initially bisect the input region" )
( "initial-timeout",
boost::program_options::value<int>( &((*_intOptions)[Options::INITIAL_TIMEOUT]) ),
"(DNC) The initial timeout" )
( "num-online-divides",
boost::program_options::value<int>( &((*_intOptions)[Options::NUM_ONLINE_DIVIDES]) ),
"(DNC) Number of times to further bisect a sub-region when a timeout occurs" )
( "timeout",
boost::program_options::value<int>( &((*_intOptions)[Options::TIMEOUT]) ),
"Global timeout" )
( "verbosity",
boost::program_options::value<int>( &((*_intOptions)[Options::VERBOSITY]) ),
"Verbosity of engine::solve(). 0: does not print anything (for DnC), 1: print"
"out statistics in the beginning and end, 2: print out statistics during solving." )
( "split-threshold",
boost::program_options::value<int>( &((*_intOptions)[Options::SPLIT_THRESHOLD]) ),
"Max number of tries to repair a relu before splitting" )
( "timeout-factor",
boost::program_options::value<float>( &((*_floatOptions)[Options::TIMEOUT_FACTOR]) ),
"(DNC) The timeout factor" )
( "help",
boost::program_options::bool_switch( &((*_boolOptions)[Options::HELP]) ),
"Prints the help message")
( "version",
boost::program_options::bool_switch( &((*_boolOptions)[Options::VERSION]) ),
"Prints the version number")
;
// Positional options, for the mandatory options
_positionalOptions.add( "input", 1 );
_positionalOptions.add( "property", 2 );
}
void OptionParser::parse( int argc, char **argv )
{
boost::program_options::store
( boost::program_options::command_line_parser( argc, argv )
.options( _optionDescription ).positional( _positionalOptions ).run(),
_variableMap );
boost::program_options::notify( _variableMap );
}
bool OptionParser::valueExists( const String &option )
{
return _variableMap.count( option.ascii() ) != 0;
}
int OptionParser::extractIntValue( const String &option )
{
ASSERT( valueExists( option ) );
return _variableMap[option.ascii()].as<int>();
}
//
// Local Variables:
// compile-command: "make -C ../.. "
// tags-file-name: "../../TAGS"
// c-basic-offset: 4
// End:
//