@@ -40,23 +40,23 @@ namespace cuopt::linear_programming::io {
4040 * @return mps_data_model_t A fully formed LP/QP problem which represents the given file
4141 */
4242template <typename i_t , typename f_t >
43- mps_data_model_t <i_t , f_t > parse_mps (const std::string& mps_file_path,
44- bool fixed_mps_format = false );
43+ mps_data_model_t <i_t , f_t > read_mps (const std::string& mps_file_path,
44+ bool fixed_mps_format = false );
4545
4646/* *
4747 * @brief Reads an MPS problem from in-memory file contents.
4848 *
49- * This parses the same plain-text MPS format as parse_mps (), but the input is
49+ * This parses the same plain-text MPS format as read_mps (), but the input is
5050 * already loaded in memory. Compressed .mps.gz/.mps.bz2 inputs are only supported
51- * by parse_mps () because compression is detected from the file path.
51+ * by read_mps () because compression is detected from the file path.
5252 *
5353 * @param[in] mps_contents MPS file contents.
5454 * @param[in] fixed_mps_format If MPS content should be parsed as fixed, false by default.
5555 * @return mps_data_model_t A fully formed problem which represents the given content.
5656 */
5757template <typename i_t , typename f_t >
58- mps_data_model_t <i_t , f_t > parse_mps_from_string (std::string_view mps_contents,
59- bool fixed_mps_format = false );
58+ mps_data_model_t <i_t , f_t > read_mps_from_string (std::string_view mps_contents,
59+ bool fixed_mps_format = false );
6060
6161/* *
6262 * @brief Reads a linear, mixed-integer, or quadratic optimization problem from
@@ -82,62 +82,64 @@ mps_data_model_t<i_t, f_t> parse_mps_from_string(std::string_view mps_contents,
8282 * a ValidationError when encountered.
8383 *
8484 * Compressed inputs (.lp.gz, .lp.bz2) are supported when zlib / libbzip2
85- * are installed (same dispatching as parse_mps ).
85+ * are installed (same dispatching as read_mps ).
8686 *
8787 * @param[in] lp_file_path Path to the LP file.
8888 * @return mps_data_model_t A fully formed LP/MIP/QP problem representing the
8989 * given file.
9090 */
9191template <typename i_t , typename f_t >
92- mps_data_model_t <i_t , f_t > parse_lp (const std::string& lp_file_path);
92+ mps_data_model_t <i_t , f_t > read_lp (const std::string& lp_file_path);
9393
9494/* *
9595 * @brief Reads an LP, MIP, or QP problem from in-memory file contents.
9696 *
97- * This parses the same plain-text LP format as parse_lp (), but the input is
97+ * This parses the same plain-text LP format as read_lp (), but the input is
9898 * already loaded in memory. Compressed .lp.gz/.lp.bz2 inputs are only
99- * supported by parse_lp () because compression is detected from the file
100- * path. Supports the same scope as parse_lp () (LP, MIP, QP, plus
99+ * supported by read_lp () because compression is detected from the file
100+ * path. Supports the same scope as read_lp () (LP, MIP, QP, plus
101101 * semi-continuous variables).
102102 *
103103 * @param[in] lp_contents LP file contents.
104104 * @return mps_data_model_t A fully formed LP/MIP/QP problem representing the
105105 * given content.
106106 */
107107template <typename i_t , typename f_t >
108- mps_data_model_t <i_t , f_t > parse_lp_from_string (std::string_view lp_contents);
108+ mps_data_model_t <i_t , f_t > read_lp_from_string (std::string_view lp_contents);
109109
110110/* *
111111 * @brief Reads an optimization problem from a file, dispatching on the file
112112 * extension. Extension matching is case-insensitive.
113113 *
114114 * Routing:
115- * - .mps, .mps.gz, .mps.bz2, .qps, .qps.gz, .qps.bz2 → parse_mps ()
116- * - .lp, .lp.gz, .lp.bz2 → parse_lp ()
115+ * - .mps, .mps.gz, .mps.bz2, .qps, .qps.gz, .qps.bz2 → read_mps ()
116+ * - .lp, .lp.gz, .lp.bz2 → read_lp ()
117117 * - anything else → std::logic_error
118118 *
119119 * This is the entry point of choice for user-facing tools (CLI, C API) that
120120 * want both formats to "just work" without an explicit format flag.
121121 *
122122 * @param[in] path Path to the input file.
123+ * @param[in] fixed_mps_format If the MPS/QPS reader should use fixed format;
124+ * ignored for LP inputs. False by default.
123125 * @return mps_data_model_t The parsed problem.
124126 */
125127template <typename i_t , typename f_t >
126- inline mps_data_model_t <i_t , f_t > parse_problem (const std::string& path)
128+ inline mps_data_model_t <i_t , f_t > read (const std::string& path, bool fixed_mps_format = false )
127129{
128130 std::string lower (path);
129131 std::transform (lower.begin (), lower.end (), lower.begin (), [](unsigned char c) {
130132 return static_cast <char >(std::tolower (c));
131133 });
132134 if (lower.ends_with (" .mps" ) || lower.ends_with (" .mps.gz" ) || lower.ends_with (" .mps.bz2" ) ||
133135 lower.ends_with (" .qps" ) || lower.ends_with (" .qps.gz" ) || lower.ends_with (" .qps.bz2" )) {
134- return parse_mps <i_t , f_t >(path);
136+ return read_mps <i_t , f_t >(path, fixed_mps_format );
135137 }
136138 if (lower.ends_with (" .lp" ) || lower.ends_with (" .lp.gz" ) || lower.ends_with (" .lp.bz2" )) {
137- return parse_lp <i_t , f_t >(path);
139+ return read_lp <i_t , f_t >(path);
138140 }
139141 throw std::logic_error (
140- " parse_problem : unrecognized input file extension. Supported (case-insensitive): "
142+ " read : unrecognized input file extension. Supported (case-insensitive): "
141143 " .mps, .mps.gz, .mps.bz2, .qps, .qps.gz, .qps.bz2, .lp, .lp.gz, .lp.bz2. "
142144 " Given path: " +
143145 path);
0 commit comments