MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / writeRmatrixPicToFile

Function writeRmatrixPicToFile

highs/util/HighsMatrixPic.cpp:70–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70HighsStatus writeRmatrixPicToFile(const HighsOptions& options,
71 const std::string& fileprefix,
72 const HighsInt numRow, const HighsInt numCol,
73 const std::vector<HighsInt>& ARstart,
74 const std::vector<HighsInt>& ARindex) {
75 if (fileprefix == "") return HighsStatus::kError;
76 std::string filename = fileprefix + ".pbm";
77 std::ofstream f;
78 f.open(filename, std::ios::out);
79 const HighsInt border_width = 1;
80 const HighsInt max_num_pixel_wide = 1600;
81 const HighsInt max_num_pixel_deep = 900;
82 const HighsInt max_num_matrix_pixel_wide =
83 max_num_pixel_wide - 2 * border_width;
84 const HighsInt max_num_matrix_pixel_deep =
85 max_num_pixel_deep - 2 * border_width;
86 HighsInt num_col_per_pixel = 1;
87 HighsInt num_row_per_pixel = 1;
88 if (numCol > max_num_matrix_pixel_wide) {
89 num_col_per_pixel = numCol / max_num_matrix_pixel_wide;
90 if (num_col_per_pixel * max_num_matrix_pixel_wide < numCol)
91 num_col_per_pixel++;
92 }
93 if (numRow > max_num_matrix_pixel_deep) {
94 num_row_per_pixel = numRow / max_num_matrix_pixel_deep;
95 if (num_row_per_pixel * max_num_matrix_pixel_deep < numRow)
96 num_row_per_pixel++;
97 }
98 const HighsInt dim_per_pixel = std::max(num_col_per_pixel, num_row_per_pixel);
99 HighsInt num_pixel_wide = numCol / dim_per_pixel;
100 if (dim_per_pixel * num_pixel_wide < numCol) num_pixel_wide++;
101 HighsInt num_pixel_deep = numRow / dim_per_pixel;
102 if (dim_per_pixel * num_pixel_deep < numRow) num_pixel_deep++;
103 // Account for the borders
104 num_pixel_wide += 2;
105 num_pixel_deep += 2;
106 assert(num_pixel_wide <= max_num_pixel_wide);
107 assert(num_pixel_deep <= max_num_pixel_deep);
108
109 highsLogUser(options.log_options, HighsLogType::kInfo,
110 "Representing matrix sparsity pattern %" HIGHSINT_FORMAT
111 "x%" HIGHSINT_FORMAT
112 " .pbm file,"
113 " mapping entries in square of size %" HIGHSINT_FORMAT
114 " onto one pixel\n",
115 num_pixel_wide, num_pixel_deep, dim_per_pixel);
116
117 std::vector<HighsInt> value;
118 value.assign(num_pixel_wide, 0);
119 f << "P1" << std::endl;
120 f << num_pixel_wide << " " << num_pixel_deep << std::endl;
121 HighsInt pic_num_row = 0;
122 // Top border
123 for (HighsInt pixel = 0; pixel < num_pixel_wide; pixel++) f << "1 ";
124 f << std::endl;
125 pic_num_row++;
126 HighsInt from_row = 0;
127 for (;;) {

Callers 1

writeMatrixPicToFileFunction · 0.85

Calls 2

highsLogUserFunction · 0.85
openMethod · 0.45

Tested by

no test coverage detected