-
Notifications
You must be signed in to change notification settings - Fork 3
/
smp_convertor.cpp
79 lines (63 loc) · 2.14 KB
/
smp_convertor.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
//
// Created by kazem on 2020-05-09.
//
#include <iostream>
#include <map>
#include <cmath>
//#include "qp_format_converter.h"
#include "utils.h"
#include "mp_format_converter.h"
using namespace format;
int main(int argc,const char *argv[]){
std::map<std::string,std::string> qp_args;
parse_args(argc, argv, qp_args);
if(qp_args.find("input") == qp_args.end())
return 0;
/*SMP *smp = new SMP(qp_args["H"]);
smp->load();
std::cout<<"\n";
smp->write("tmp.yml");
delete smp;*/
Description test;
std::string dtes=test.get_desc();
auto *qfc = new QPFormatConverter();
qfc->load_smp(qp_args["input"]);
//qfc->smp_->write("tmp2.yml");
qfc->smp_to_bounded();
auto *qfc2 = new QPFormatConverter(qfc->bf_);
//qfc->smp_->write("tmp2.yml");
qfc2->bounded_to_smp();
if(!sym_lib::are_equal(qfc->smp_, qfc2->smp_) )
std::cout<<"WRONG conversion\n";
if(!sym_lib::are_equal(qfc->bf_, qfc2->bf_) )
std::cout<<"WRONG conversion\n";
delete qfc;
delete qfc2;
auto *qfc3 = new QPFormatConverter();
qfc3->load_smp(qp_args["input"]);
//qfc->smp_->write("tmp2.yml");
qfc3->smp_to_ie();
auto *qfc4 = new QPFormatConverter(qfc3->ief_);
//qfc->smp_->write("tmp2.yml");
qfc4->ie_to_smp();
// if(!sym_lib::are_equal(qfc3->smp_, qfc4->smp_) )
// std::cout<<"WRONG IE conversion\n";
//
// if(!sym_lib::are_equal(qfc3->ief_, qfc4->ief_) )
// std::cout<<"WRONG conversion\n";
qfc3->smp_->set_description(dtes);
qfc3->smp_->write(qp_args["output"]);
delete qfc3;
delete qfc4;
/// Reading input matrices.
// Eigen::SparseMatrix<double,Eigen::ColMajor,int> H, A, C;
// Eigen::VectorXd q, b, d;
// std::string message = "Could not load ";
// if( !Eigen::loadMarket( H, qp_args["H"] ) ){ std::cout<<message<<"H"; return 1; }
// if( !Eigen::loadMarketVector( q, qp_args["q"] ) ){ std::cout<<message<<"q"; return 1; }
// if( !Eigen::loadMarket( A, qp_args["A"] ) ){ std::cout<<message<<"A"; return 1; }
// if( !Eigen::loadMarketVector( b, qp_args["b"] ) ){ std::cout<<message<<"b"; return 1; }
// if( !Eigen::loadMarket( C, qp_args["C"] ) ){ std::cout<<message<<"C"; return 1; }
// if( !Eigen::loadMarketVector( d, qp_args["d"] ) ){ std::cout<<message<<"d"; return 1; }
return 0;
}