Skip to content

Commit e160dcc

Browse files
authored
Merge pull request #1289 from NVIDIA/release/26.06
Forward-merge release/26.06 into main
2 parents 591df2d + f3dd013 commit e160dcc

58 files changed

Lines changed: 764 additions & 517 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

benchmarks/linear_programming/cuopt/benchmark_helper.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ void mps_file_to_binary(const std::filesystem::path& filename)
275275
std::string p = std::string(filename);
276276

277277
cuopt::linear_programming::io::mps_data_model_t<int, double> op_problem =
278-
cuopt::linear_programming::io::parse_mps<int, double>(p);
278+
cuopt::linear_programming::io::read_mps<int, double>(p);
279279

280280
auto filename_string = filename.filename().string();
281281

benchmarks/linear_programming/cuopt/run_mip.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ int run_single_file(std::string file_path,
172172
CUOPT_LOG_INFO("running file %s on gpu : %d", base_filename.c_str(), device);
173173
try {
174174
mps_data_model =
175-
cuopt::linear_programming::io::parse_mps<int, double>(file_path, input_mps_strict);
175+
cuopt::linear_programming::io::read_mps<int, double>(file_path, input_mps_strict);
176176
} catch (const std::logic_error& e) {
177177
CUOPT_LOG_ERROR("MPS parser execption: %s", e.what());
178178
parsing_failed = true;

benchmarks/linear_programming/cuopt/run_pdlp.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static int run_solver(const argparse::ArgumentParser& program, const raft::handl
149149

150150
// Parse MPS file
151151
cuopt::linear_programming::io::mps_data_model_t<int, double> op_problem =
152-
cuopt::linear_programming::io::parse_mps<int, double>(program.get<std::string>("--path"));
152+
cuopt::linear_programming::io::read_mps<int, double>(program.get<std::string>("--path"));
153153

154154
// Solve LP problem
155155
bool problem_checking = true;

ci/test_self_hosted_service.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,29 @@ if [ "$doservertest" -eq 1 ]; then
113113
# Success, small MILP problem with pure JSON which returns a solution with Optimal status
114114
run_cli_test "'status': 'Optimal'" cuopt_sh -s -c $CLIENT_CERT -p $CUOPT_SERVER_PORT -t LP ../../datasets/mixed_integer_programming/milp_data.json
115115

116-
# Succes, small LP problem with mps. Data will be transformed to JSON
116+
# Success, small LP problem with MPS. Data will be transformed to JSON
117117
run_cli_test "'status': 'Optimal'" cuopt_sh -s -c "$CLIENT_CERT" -p $CUOPT_SERVER_PORT -t LP ../../datasets/linear_programming/good-mps-1.mps
118118

119-
# Succes, small Batch LP problem with mps. Data will be transformed to JSON
119+
# Success, small Batch LP problem with MPS. Data will be transformed to JSON
120120
run_cli_test "'status': 'Optimal'" cuopt_sh -s -c "$CLIENT_CERT" -p $CUOPT_SERVER_PORT -t LP ../../datasets/linear_programming/good-mps-1.mps ../../datasets/linear_programming/good-mps-1.mps
121121

122-
# Error, local file mode is not allowed with mps
122+
# Success, small LP problem with LP format. Data will be transformed to JSON
123+
run_cli_test "'status': 'Optimal'" cuopt_sh -s -c "$CLIENT_CERT" -p $CUOPT_SERVER_PORT -t LP ../../datasets/linear_programming/good-mps-1.lp
124+
125+
# Success, small Batch LP problem with LP format. Data will be transformed to JSON
126+
run_cli_test "'status': 'Optimal'" cuopt_sh -s -c "$CLIENT_CERT" -p $CUOPT_SERVER_PORT -t LP ../../datasets/linear_programming/good-mps-1.lp ../../datasets/linear_programming/good-mps-1.lp
127+
128+
# Success, compressed LP inputs (.lp.gz / .lp.bz2) via Read dispatch
129+
run_cli_test "'status': 'Optimal'" cuopt_sh -s -c "$CLIENT_CERT" -p $CUOPT_SERVER_PORT -t LP ../../datasets/linear_programming/good-mps-1.lp.gz
130+
run_cli_test "'status': 'Optimal'" cuopt_sh -s -c "$CLIENT_CERT" -p $CUOPT_SERVER_PORT -t LP ../../datasets/linear_programming/good-mps-1.lp.bz2
131+
132+
# Success, compressed MPS inputs (.mps.gz / .mps.bz2) for parity
133+
run_cli_test "'status': 'Optimal'" cuopt_sh -s -c "$CLIENT_CERT" -p $CUOPT_SERVER_PORT -t LP ../../datasets/linear_programming/good-mps-1.mps.gz
134+
run_cli_test "'status': 'Optimal'" cuopt_sh -s -c "$CLIENT_CERT" -p $CUOPT_SERVER_PORT -t LP ../../datasets/linear_programming/good-mps-1.mps.bz2
135+
136+
# Error, local file mode is not allowed with MPS/LP file inputs
123137
run_cli_test "Cannot use local file mode with MPS/LP data" cuopt_sh -s -c "$CLIENT_CERT" -p $CUOPT_SERVER_PORT -t LP -f good-mps-1.mps
138+
run_cli_test "Cannot use local file mode with MPS/LP data" cuopt_sh -s -c "$CLIENT_CERT" -p $CUOPT_SERVER_PORT -t LP -f good-mps-1.lp
124139

125140
# Just run validator
126141
cp ../../datasets/cuopt_service_data/cuopt_problem_data.json "$CUOPT_DATA_DIR"

cpp/cuopt_cli.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ int run_single_file(const std::string& file_path,
108108
{
109109
CUOPT_LOG_INFO("Reading file %s", base_filename.c_str());
110110
try {
111-
mps_data_model = cuopt::linear_programming::io::parse_problem<int, double>(file_path);
111+
mps_data_model = cuopt::linear_programming::io::read<int, double>(file_path);
112112
} catch (const std::logic_error& e) {
113113
CUOPT_LOG_ERROR("Parser exception: %s", e.what());
114114
parsing_failed = true;

cpp/include/cuopt/linear_programming/io/parser.hpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
4242
template <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
*/
5757
template <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
*/
9191
template <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
*/
107107
template <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
*/
125127
template <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);

cpp/include/cuopt/linear_programming/io/utilities/cython_parser.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
namespace cuopt {
1515
namespace cython {
1616

17+
std::unique_ptr<cuopt::linear_programming::io::mps_data_model_t<int, double>> call_read(
18+
const std::string& file_path, bool fixed_mps_format);
19+
1720
std::unique_ptr<cuopt::linear_programming::io::mps_data_model_t<int, double>> call_parse_mps(
1821
const std::string& mps_file_path, bool fixed_mps_format);
1922

20-
std::unique_ptr<cuopt::linear_programming::io::mps_data_model_t<int, double>> call_parse_lp(
21-
const std::string& lp_file_path);
22-
2323
} // namespace cython
2424
} // namespace cuopt

cpp/src/io/lp_parser.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ template <typename i_t, typename f_t>
199199
class LpParseEngine {
200200
public:
201201
LpParseEngine(lp_parser_t<i_t, f_t>& out, const std::string& file);
202-
// Parses `text` directly (used by parse_lp_from_string()).
202+
// Parses `text` directly (used by read_lp_from_string()).
203203
LpParseEngine(lp_parser_t<i_t, f_t>& out, std::string_view text);
204204

205205
private:
@@ -1546,28 +1546,28 @@ template class lp_parser_t<int, float>;
15461546
template class lp_parser_t<int, double>;
15471547

15481548
// ===========================================================================
1549-
// Public parse_lp() / parse_lp_from_string()
1549+
// Public read_lp() / read_lp_from_string()
15501550
// ===========================================================================
15511551

15521552
template <typename i_t, typename f_t>
1553-
mps_data_model_t<i_t, f_t> parse_lp(const std::string& lp_file_path)
1553+
mps_data_model_t<i_t, f_t> read_lp(const std::string& lp_file_path)
15541554
{
15551555
mps_data_model_t<i_t, f_t> problem;
15561556
lp_parser_t<i_t, f_t> parser(problem, lp_file_path);
15571557
return problem;
15581558
}
15591559

15601560
template <typename i_t, typename f_t>
1561-
mps_data_model_t<i_t, f_t> parse_lp_from_string(std::string_view lp_contents)
1561+
mps_data_model_t<i_t, f_t> read_lp_from_string(std::string_view lp_contents)
15621562
{
15631563
mps_data_model_t<i_t, f_t> problem;
15641564
lp_parser_t<i_t, f_t> parser(problem, lp_contents);
15651565
return problem;
15661566
}
15671567

1568-
template mps_data_model_t<int, float> parse_lp<int, float>(const std::string&);
1569-
template mps_data_model_t<int, double> parse_lp<int, double>(const std::string&);
1570-
template mps_data_model_t<int, float> parse_lp_from_string<int, float>(std::string_view);
1571-
template mps_data_model_t<int, double> parse_lp_from_string<int, double>(std::string_view);
1568+
template mps_data_model_t<int, float> read_lp<int, float>(const std::string&);
1569+
template mps_data_model_t<int, double> read_lp<int, double>(const std::string&);
1570+
template mps_data_model_t<int, float> read_lp_from_string<int, float>(std::string_view);
1571+
template mps_data_model_t<int, double> read_lp_from_string<int, double>(std::string_view);
15721572

15731573
} // namespace cuopt::linear_programming::io

cpp/src/io/lp_parser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class lp_parser_t {
3636
lp_parser_t(mps_data_model_t<i_t, f_t>& problem, const std::string& file);
3737

3838
// Parses `input` (LP format text already loaded in memory) and populates
39-
// `problem`. Used by parse_lp_from_string() — compressed inputs are only
39+
// `problem`. Used by read_lp_from_string() — compressed inputs are only
4040
// supported via the file-path constructor since compression is detected
4141
// from the path suffix.
4242
lp_parser_t(mps_data_model_t<i_t, f_t>& problem, std::string_view input);

cpp/src/io/parser.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,27 @@
1212
namespace cuopt::linear_programming::io {
1313

1414
template <typename i_t, typename f_t>
15-
mps_data_model_t<i_t, f_t> parse_mps(const std::string& mps_file, bool fixed_mps_format)
15+
mps_data_model_t<i_t, f_t> read_mps(const std::string& mps_file, bool fixed_mps_format)
1616
{
1717
mps_data_model_t<i_t, f_t> problem;
1818
mps_parser_t<i_t, f_t> parser(problem, mps_file, fixed_mps_format);
1919
return problem;
2020
}
2121

2222
template <typename i_t, typename f_t>
23-
mps_data_model_t<i_t, f_t> parse_mps_from_string(std::string_view mps_contents,
24-
bool fixed_mps_format)
23+
mps_data_model_t<i_t, f_t> read_mps_from_string(std::string_view mps_contents,
24+
bool fixed_mps_format)
2525
{
2626
mps_data_model_t<i_t, f_t> problem;
2727
mps_parser_t<i_t, f_t> parser(problem, mps_contents, fixed_mps_format);
2828
return problem;
2929
}
3030

31-
template mps_data_model_t<int, float> parse_mps(const std::string& mps_file, bool fixed_mps_format);
32-
template mps_data_model_t<int, double> parse_mps(const std::string& mps_file,
33-
bool fixed_mps_format);
34-
template mps_data_model_t<int, float> parse_mps_from_string(std::string_view mps_contents,
31+
template mps_data_model_t<int, float> read_mps(const std::string& mps_file, bool fixed_mps_format);
32+
template mps_data_model_t<int, double> read_mps(const std::string& mps_file, bool fixed_mps_format);
33+
template mps_data_model_t<int, float> read_mps_from_string(std::string_view mps_contents,
34+
bool fixed_mps_format);
35+
template mps_data_model_t<int, double> read_mps_from_string(std::string_view mps_contents,
3536
bool fixed_mps_format);
36-
template mps_data_model_t<int, double> parse_mps_from_string(std::string_view mps_contents,
37-
bool fixed_mps_format);
3837

3938
} // namespace cuopt::linear_programming::io

0 commit comments

Comments
 (0)