-
Notifications
You must be signed in to change notification settings - Fork 125
Add C api callbacks for getting and setting solutions #779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
943b632
41a3b68
1e7a2e5
fda3f4f
4e50db4
826b3c0
860e060
b28aba2
5d328b4
5b6c3d4
c666c32
f57f782
21f687c
0166f23
6350e4a
f5b5c3e
4c813c7
2d92a0a
81e477e
6c35c4d
a8776a2
203ce1c
ab7029c
f93dcfc
0547eaf
7094cd0
f770594
0000549
d5b28a5
d68957f
cd87d5c
c6dfaee
5084a08
e6b6642
02199cb
74e7515
4cac4f7
41a9592
1600789
6023885
fc3be68
3c2d55d
1f2523a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,41 @@ | ||
| /* clang-format off */ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| /* clang-format on */ | ||
| #pragma once | ||
|
|
||
| #include <atomic> | ||
| #include <limits> | ||
| namespace cuopt::linear_programming { | ||
|
|
||
| template <typename i_t, typename f_t> | ||
| struct solver_stats_t { | ||
| f_t total_solve_time = 0.; | ||
| f_t presolve_time = 0.; | ||
| f_t solution_bound = std::numeric_limits<f_t>::min(); | ||
| // Direction-neutral placeholder; solver_context initializes based on maximize/minimize. | ||
| solver_stats_t() : solution_bound(std::numeric_limits<f_t>::infinity()) {} | ||
|
|
||
| solver_stats_t(const solver_stats_t& other) { *this = other; } | ||
|
|
||
| solver_stats_t& operator=(const solver_stats_t& other) | ||
| { | ||
| if (this == &other) { return *this; } | ||
| total_solve_time = other.total_solve_time; | ||
| presolve_time = other.presolve_time; | ||
| solution_bound.store(other.solution_bound.load(std::memory_order_relaxed), | ||
| std::memory_order_relaxed); | ||
| num_nodes = other.num_nodes; | ||
| num_simplex_iterations = other.num_simplex_iterations; | ||
| return *this; | ||
| } | ||
|
|
||
| f_t get_solution_bound() const { return solution_bound.load(std::memory_order_relaxed); } | ||
|
|
||
| void set_solution_bound(f_t value) { solution_bound.store(value, std::memory_order_relaxed); } | ||
|
|
||
| f_t total_solve_time = 0.; | ||
| f_t presolve_time = 0.; | ||
| std::atomic<f_t> solution_bound; | ||
| i_t num_nodes = 0; | ||
| i_t num_simplex_iterations = 0; | ||
|
Comment on lines
+36
to
40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check f_t typedef definition and how solver_stats_t is used
rg -n "using f_t|typedef.*f_t|#define f_t" --type=cpp --type=hpp | head -20Repository: NVIDIA/cuopt Length of output: 83 🏁 Script executed: # Check the full context of solver_stats.hpp to see if there's documentation
cat -n cpp/include/cuopt/linear_programming/mip/solver_stats.hppRepository: NVIDIA/cuopt Length of output: 1791 🏁 Script executed: # Search for migration guides, release notes, or breaking change documentation
fd -e md -e rst | xargs rg -l "breaking\|migration\|ABI" 2>/dev/null | head -10Repository: NVIDIA/cuopt Length of output: 38 🏁 Script executed: # Check if solution_bound has any Doxygen or documentation comments
rg -B5 "solution_bound" cpp/include/cuopt --type=cpp --type=hpp | head -30Repository: NVIDIA/cuopt Length of output: 83 🏁 Script executed: # Search for f_t typedef/using declarations
rg -n "using f_t|f_t =" cpp/include/cuopt -A2 | head -40Repository: NVIDIA/cuopt Length of output: 38 🏁 Script executed: # Check if there are Doxygen comments in the header file
rg -B3 "struct solver_stats_t|solution_bound" cpp/include/cuopt/linear_programming/mip/solver_stats.hppRepository: NVIDIA/cuopt Length of output: 849 🏁 Script executed: # Search for any migration guides, docs, or breaking change notices in the repo
fd -type f \( -name "*.md" -o -name "*.rst" -o -name "CHANGELOG*" \) | xargs rg -l "solver_stats\|breaking.*ABI\|migration" 2>/dev/nullRepository: NVIDIA/cuopt Length of output: 228 🏁 Script executed: # Check if this struct is used elsewhere to understand access patterns
rg "solver_stats_t" cpp/src cpp/test --type=cpp -A2 | head -50Repository: NVIDIA/cuopt Length of output: 104 🏁 Script executed: # Find where solver_stats_t is instantiated to see what f_t is used as
rg "solver_stats_t<" cpp/include cpp/src --type=cpp -A1 -B1Repository: NVIDIA/cuopt Length of output: 1387 🏁 Script executed: # Check for any documentation or comments in the header about the atomic change
rg -n "solution_bound|atomic" cpp/include/cuopt/linear_programming/mip/solver_stats.hpp -B2Repository: NVIDIA/cuopt Length of output: 797 🏁 Script executed: # Search for any documentation files mentioning this struct
find . -name "*.md" -o -name "*.rst" | xargs grep -l "solver_stats" 2>/dev/nullRepository: NVIDIA/cuopt Length of output: 40 🏁 Script executed: # Check if there are any Doxygen-style comments in related headers
cat cpp/include/cuopt/linear_programming/mip/solver_stats.hpp | head -20Repository: NVIDIA/cuopt Length of output: 695 Add Doxygen documentation and breaking change notice for public API header. The
Consider adding: /// Solver statistics. Note: solution_bound is now atomic for thread-safe concurrent access.
/// Breaking change: struct layout changed. See migration guide in docs/ for upgrading.
template <typename i_t, typename f_t>
struct solver_stats_t {
// ...
/// Thread-safe solution bound (updated via set_solution_bound())
std::atomic<f_t> solution_bound;🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't officially support c++ api, so it is an intermediate class which is converted to public apis which are C and python. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I've noted this for future reviews so I don't flag similar internal C++ classes with the same concerns. ✏️ Learnings added
🧠 Learnings used |
||
| }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.