-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathexample_json.cpp
More file actions
38 lines (27 loc) · 866 Bytes
/
example_json.cpp
File metadata and controls
38 lines (27 loc) · 866 Bytes
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
// #define FEATURE_SDP
#include "utils.h"
#include <clarabel.hpp>
#include <iostream>
using namespace clarabel;
using namespace std;
#define STRING(string) #string
#define TO_STRING(string) STRING(string)
int main(void)
{
#ifndef FEATURE_SERDE
printf("This example requires JSON serde support.\n");
return 1;
#else
std::string rootdir = TO_STRING(EXAMPLES_ROOT_DIR);
std::string filepath = "/data/hs35.json";
std::string filename = rootdir + filepath;
std::cout << "Read from file: " << filename << endl;
DefaultSolver<double> solver = DefaultSolver<double>::load_from_file(filename);
solver.solve();
// write it back to a file
// std::string outpath = "/data/output.json";
// std::string filename_out = rootdir + outpath;
// solver.save_to_file(filename_out);
return 0;
#endif // FEATURE_SERDE
}