-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
68 lines (62 loc) · 1.69 KB
/
main.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
#include <iostream>
#include "solver.h"
#include "dataimporter.h"
#include "tester.h"
#include "analyze.h"
#include <boost/program_options.hpp>
int main(int argc, char **argv)
{
std::string filename;
bool isTest;
bool isAnalyze;
bool isSolve;
boost::program_options::options_description desc("General options");
desc.add_options()
("help,h", "Show help")
("filepath,f", boost::program_options::value<std::string>(&filename)->default_value("../taskData.csv"), "filename")
("test,t" , boost::program_options::bool_switch(&isTest)->default_value(false), "run test")
("analyze,a" , boost::program_options::bool_switch(&isAnalyze)->default_value(true), "run analyze")
("solve,s" , boost::program_options::bool_switch(&isSolve)->default_value(false), "run solve")
;
boost::program_options::variables_map vm;
boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
boost::program_options::notify(vm);
if (vm.count("help")) {
std::cout << desc << "\n";
return 0;
}
if(isTest)
{
Tester tester;
tester.Test();
}
if(isAnalyze)
{
Analyzer an;
an.Analyze(filename);
}
if(isSolve)
{
try
{
CSVDataImporter dataImporter;
Solver solver(std::make_unique<RegressionModelLn1>(dataImporter.read(filename)));
solver.SolverInit();
if(!solver.Solve())
{
std::cout<<"Solution not found"<<std::endl;
}
std::cout<<"Result model params"<<solver.GetResult().transpose()<<std::endl;
}
catch(std::exception &e)
{
std::cout<<"Exception:"<<e.what()<<std::endl;
return 1;
}
catch(...)
{
return 1;
}
return 0;
}
}