-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
139 lines (129 loc) · 5.23 KB
/
main.cpp
File metadata and controls
139 lines (129 loc) · 5.23 KB
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
129
130
131
132
133
134
135
136
137
138
139
// ReversibleLogicGenerator - generator of reversible logic circuits, based on permutation group theory.
// Copyright (C) 2015 <Dmitry Zakablukov>
// E-mail: dmitriy.zakablukov@gmail.com
// Web: https://github.com/dmitry-zakablukov/ReversibleLogicGenerator
//
// This file is part of ReversibleLogicGenerator.
//
// ReversibleLogicGenerator is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ReversibleLogicGenerator is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ReversibleLogicGenerator. If not, see <http://www.gnu.org/licenses/>.
#include "std.h"
void printUsage(const string& fullProgramPath)
{
cout <<
"Usage: " << getFileName(fullProgramPath) << " [config_file_name]\n"
" config_file_name - configuration file containing options (see config.ini);\n"
" if not specified, default options would be used\n"
"\n"
"General options:\n"
" work-mode = < general-synthesis | post-processing | discrete-log-synthesis | remove-negative-lines >\n"
" input-file = <filename>\n"
" truth-table-input = <filename>\n"
" tfc-input = <filename>\n"
" results-file = <filename>\n"
" schemes-folder = <foldername>\n"
" rm-generator-weight-threshold = <number>\n"
" transpositions-pack-size = <number>\n"
"\n"
"Optimization options:\n"
" do-post-optimization = <bool>\n"
" max-elements-distance-for-optimization = <number>\n"
" max-sub-scheme-size-for-optimization = <number>\n"
" do-last-optimizations-with-full-scheme = <bool>\n"
" remove-negative-control-inputs = <bool>\n"
" use-swap-results-optimization-technique = <bool>\n"
"\n"
"Tuning options:\n"
" enable-tuning = <bool>\n"
" do-not-alter-output-variables-order = <bool>\n"
" choose-output-order-only-by-hamming-distance = <bool>\n"
" pick-up-best-output-only-by-hamming-distance = <bool>\n"
" complete-permutation-to-even = <bool>\n"
" sort-by-weight-not-frequency = <bool>\n"
" search-for-boolean-edges = <bool>\n"
" compare-results-on-edge-search = <bool>\n"
" transpositions-pack-in-reverse-order = <bool>\n"
" sort-output-variables-order = <bool>\n"
" push-policy-force-left = <bool>\n"
" push-policy-force-right = <bool>\n"
" push-policy-auto-mode-min-hamming-distance = <bool>\n"
" push-policy-auto-mode-max-rm-cost-reduction = <bool>\n"
"\n"
"Debugging options:\n"
" enable-debug-behavior = <bool>\n"
" debug-log = <filename>\n"
" debug-context = <contextname>\n"
<< endl;
}
int main(int argc, const char* argv[])
{
const char* strWorkModeKey = "work-mode";
const char* strGeneralSynthesisMode = "general-synthesis";
const char* strDiscreteLogSynthesisMode = "discrete-log-synthesis";
const char* strPostProcessingMode = "post-processing";
const char* strRemoveNegativeLinesMode = "remove-negative-lines";
if (argc == 2)
{
string second = argv[1];
if (second == "/?" || second == "-?" || second == "-h" || second == "--help")
{
printUsage(argv[0]);
return 0;
}
}
int returnCode = 0;
try
{
Values values;
if (argc == 2)
{
ifstream ini(argv[1]);
values = IniParser::parse(ini);
}
ProgramOptions::init(values);
const Values& options = ProgramOptions::get().options;
string workMode = options.getString(strWorkModeKey);
if (workMode == strGeneralSynthesisMode)
generalSynthesis();
else if (workMode == strDiscreteLogSynthesisMode)
discreteLogSynthesis();
else if (workMode == strPostProcessingMode)
testOptimization();
else if (workMode == strRemoveNegativeLinesMode)
removeNegativeLines();
else
{
if (workMode.empty())
cerr << "Error: work mode is not specified, valid values are:\n";
else
cerr << "Error: unknown work mode \"" << workMode << "\", valid values are:\n";
cerr <<
" " << strGeneralSynthesisMode << '\n' <<
" " << strDiscreteLogSynthesisMode << '\n' <<
" " << strPostProcessingMode << '\n' <<
" " << strRemoveNegativeLinesMode << endl;
}
ProgramOptions::uninit();
}
catch (exception& ex)
{
cerr << "Exception: " << ex.what() << endl;
returnCode = -1;
}
catch (...)
{
cerr << "Unknown exception was caught" << endl;
returnCode = -1;
}
return returnCode;
}