From 97fd43fbfbd4c2c205e765afda40a666f3c59178 Mon Sep 17 00:00:00 2001 From: Miles Lubin Date: Fri, 21 Aug 2026 13:08:23 -0400 Subject: [PATCH 1/2] Updates for 26.08; drop Julia 1.6 Signed-off-by: Miles Lubin --- Project.toml | 4 +- README.md | 4 +- src/cuOpt.jl | 2 +- src/gen/libcuopt.jl | 185 +++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 188 insertions(+), 7 deletions(-) diff --git a/Project.toml b/Project.toml index 07b466c..f175b96 100644 --- a/Project.toml +++ b/Project.toml @@ -17,7 +17,7 @@ name = "cuOpt" uuid = "29a73d17-8276-40b7-9ffb-d89e58023643" authors = ["Rajesh Gandham ", "Ramakrishna Prabhu ", "Miles Lubin "] -version = "0.3.1" +version = "0.4.0" [deps] MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" @@ -28,7 +28,7 @@ PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" MathOptInterface = "1.34" PrecompileTools = "1" Test = "1.6" -julia = "1.6" +julia = "1.10" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/README.md b/README.md index 0954d6e..4d0e0ec 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ To use cuOpt.jl, you must first separately install cuOpt. **Installing cuOpt requires Linux.** -Note: This version of cuOpt.jl supports the Nvidia cuOpt 26.06 release. +Note: This version of cuOpt.jl supports the Nvidia cuOpt 26.08 release. Please refer to the [NVIDIA cuOpt documentation](https://docs.nvidia.com/cuopt/user-guide/latest/cuopt-c/quick-start.html#installation) for installation instructions. @@ -48,7 +48,7 @@ Pkg.add("cuOpt") To install cuOpt on [Google Colab](https://colab.research.google.com), do: ```julia -julia> cmd = run(`pip install --extra-index-url=https://pypi.nvidia.com libcuopt-cu12==26.6.\* nvidia-cuda-runtime-cu12==12.8.\*`); +julia> cmd = run(`pip install --extra-index-url=https://pypi.nvidia.com libcuopt-cu12==26.8.\* nvidia-cuda-runtime-cu12==12.8.\*`); julia> push!(Base.DL_LOAD_PATH, "/usr/local/lib/python3.12/dist-packages/libcuopt/lib64") ``` diff --git a/src/cuOpt.jl b/src/cuOpt.jl index 4b875e7..79f386c 100644 --- a/src/cuOpt.jl +++ b/src/cuOpt.jl @@ -46,7 +46,7 @@ function __init__() error("Failed to get cuOpt library version (status code: $status)") end version = VersionNumber(major[], minor[], patch[]) - min, max = v"26.06", v"26.07" + min, max = v"26.08", v"26.09" if !(min <= version < max) error( "Incompatible cuOpt library version. Got $version, but supported versions are [$min, $max)", diff --git a/src/gen/libcuopt.jl b/src/gen/libcuopt.jl index 5bf40cb..48c73da 100644 --- a/src/gen/libcuopt.jl +++ b/src/gen/libcuopt.jl @@ -412,7 +412,11 @@ end """ cuOptGetConstraintMatrix(problem, constraint_matrix_row_offsets_ptr, constraint_matrix_column_indices_ptr, constraint_matrix_coefficients_ptr) -Get the constraint matrix of an optimization problem in compressed sparse row format. +Get the linear constraint matrix of an optimization problem in compressed sparse row format. This is the matrix of the linear constraints only. + +!!! note + + **Deprecated:** Use `[`cuOptGetConstraintMatrixCSR`](@ref)`. # Arguments * `problem`:\\[in\\] - The optimization problem. @@ -426,6 +430,40 @@ function cuOptGetConstraintMatrix(problem, constraint_matrix_row_offsets_ptr, co ccall((:cuOptGetConstraintMatrix, libcuopt), cuopt_int_t, (cuOptOptimizationProblem, Ptr{cuopt_int_t}, Ptr{cuopt_int_t}, Ptr{cuopt_float_t}), problem, constraint_matrix_row_offsets_ptr, constraint_matrix_column_indices_ptr, constraint_matrix_coefficients_ptr) end +""" + cuOptGetConstraintMatrixCSR(problem, constraint_matrix_row_offsets_ptr, constraint_matrix_column_indices_ptr, constraint_matrix_coefficients_ptr) + +Get the linear constraint matrix of an optimization problem in compressed sparse row format. This is the matrix of the linear constraints only. + +# Arguments +* `problem`:\\[in\\] - The optimization problem. +* `constraint_matrix_row_offsets_ptr`:\\[out\\] - A pointer to an array of type [`cuopt_int_t`](@ref) of size num\\_constraints + 1 that on output will contain the row offsets of the constraint matrix. +* `constraint_matrix_column_indices_ptr`:\\[out\\] - A pointer to an array of type [`cuopt_int_t`](@ref) of size equal to the number of nonzeros that on output will contain the column indices of the non-zero entries of the constraint matrix. +* `constraint_matrix_coefficients_ptr`:\\[out\\] - A pointer to an array of type [`cuopt_float_t`](@ref) of size equal to the number of nonzeros that on output will contain the coefficients of the non-zero entries of the constraint matrix. +# Returns +A status code indicating success or failure. +""" +function cuOptGetConstraintMatrixCSR(problem, constraint_matrix_row_offsets_ptr, constraint_matrix_column_indices_ptr, constraint_matrix_coefficients_ptr) + ccall((:cuOptGetConstraintMatrixCSR, libcuopt), cuopt_int_t, (cuOptOptimizationProblem, Ptr{cuopt_int_t}, Ptr{cuopt_int_t}, Ptr{cuopt_float_t}), problem, constraint_matrix_row_offsets_ptr, constraint_matrix_column_indices_ptr, constraint_matrix_coefficients_ptr) +end + +""" + cuOptGetConstraintMatrixCSC(problem, constraint_matrix_column_offsets_ptr, constraint_matrix_row_indices_ptr, constraint_matrix_coefficients_ptr) + +Get the linear constraint matrix of an optimization problem in compressed sparse column format. This is the matrix of the linear constraints only. + +# Arguments +* `problem`:\\[in\\] - The optimization problem. +* `constraint_matrix_column_offsets_ptr`:\\[out\\] - A pointer to an array of type [`cuopt_int_t`](@ref) of size num\\_variables + 1 (see [`cuOptGetProblemIntAttribute`](@ref)) that on output will contain the column offsets of the constraint matrix. +* `constraint_matrix_row_indices_ptr`:\\[out\\] - A pointer to an array of type [`cuopt_int_t`](@ref) of size equal to the number of nonzeros (see [`cuOptGetNumNonZeros`](@ref)) that on output will contain the row indices of the non-zero entries of the constraint matrix. +* `constraint_matrix_coefficients_ptr`:\\[out\\] - A pointer to an array of type [`cuopt_float_t`](@ref) of size equal to the number of nonzeros that on output will contain the coefficients of the non-zero entries of the constraint matrix. +# Returns +A status code indicating success or failure. +""" +function cuOptGetConstraintMatrixCSC(problem, constraint_matrix_column_offsets_ptr, constraint_matrix_row_indices_ptr, constraint_matrix_coefficients_ptr) + ccall((:cuOptGetConstraintMatrixCSC, libcuopt), cuopt_int_t, (cuOptOptimizationProblem, Ptr{cuopt_int_t}, Ptr{cuopt_int_t}, Ptr{cuopt_float_t}), problem, constraint_matrix_column_offsets_ptr, constraint_matrix_row_indices_ptr, constraint_matrix_coefficients_ptr) +end + """ cuOptGetConstraintSense(problem, constraint_sense_ptr) @@ -850,7 +888,7 @@ Get the termination reason of an optimization problem. # Arguments * `solution`:\\[in\\] - The solution object. -* `termination_reason_ptr`:\\[out\\] - A pointer to a [`cuopt_int_t`](@ref) that on output will contain the termination reason. +* `termination_status_ptr`:\\[out\\] - A pointer to a [`cuopt_int_t`](@ref) that on output will contain the termination status. # Returns A status code indicating success or failure. """ @@ -975,6 +1013,51 @@ function cuOptGetReducedCosts(solution, reduced_cost_ptr) ccall((:cuOptGetReducedCosts, libcuopt), cuopt_int_t, (cuOptSolution, Ptr{cuopt_float_t}), solution, reduced_cost_ptr) end +""" + cuOptGetProblemIntAttribute(problem, attribute, value_out) + +Get a scalar integer problem attribute (a CUOPT\\_ATTR\\_* with an integer value). +""" +function cuOptGetProblemIntAttribute(problem, attribute, value_out) + ccall((:cuOptGetProblemIntAttribute, libcuopt), cuopt_int_t, (cuOptOptimizationProblem, cuopt_int_t, Ptr{cuopt_int_t}), problem, attribute, value_out) +end + +""" + cuOptGetProblemFloatAttribute(problem, attribute, value_out) + +Get a scalar floating-point problem attribute (objective offset / scaling factor). +""" +function cuOptGetProblemFloatAttribute(problem, attribute, value_out) + ccall((:cuOptGetProblemFloatAttribute, libcuopt), cuopt_int_t, (cuOptOptimizationProblem, cuopt_int_t, Ptr{cuopt_float_t}), problem, attribute, value_out) +end + +""" + cuOptGetProblemFloatArrayAttribute(problem, attribute, out, count) + +Copy a floating-point array attribute into out. count must equal num\\_variables for variable-indexed attributes or num\\_constraints for constraint-indexed attributes (see [`cuOptGetProblemIntAttribute`](@ref)). +""" +function cuOptGetProblemFloatArrayAttribute(problem, attribute, out, count) + ccall((:cuOptGetProblemFloatArrayAttribute, libcuopt), cuopt_int_t, (cuOptOptimizationProblem, cuopt_int_t, Ptr{cuopt_float_t}, cuopt_int_t), problem, attribute, out, count) +end + +""" + cuOptGetProblemCharArrayAttribute(problem, attribute, out, count) + +Copy a char array attribute (constraint sense or variable types) into out. count must equal num\\_constraints (constraint sense) or num\\_variables (variable types) (see [`cuOptGetProblemIntAttribute`](@ref)). +""" +function cuOptGetProblemCharArrayAttribute(problem, attribute, out, count) + ccall((:cuOptGetProblemCharArrayAttribute, libcuopt), cuopt_int_t, (cuOptOptimizationProblem, cuopt_int_t, Ptr{Cchar}, cuopt_int_t), problem, attribute, out, count) +end + +""" + cuOptGetProblemStringArrayAttribute(problem, attribute, strings_out, count) + +Fill a caller-provided array of `count` pointers with borrowed pointers to cuOpt-owned strings ([`CUOPT_STRING_ARRAY_VARIABLE_NAMES`](@ref) or \\_ROW\\_NAMES). count must equal num\\_variables or num\\_constraints respectively. The returned pointers are valid until the problem is modified or destroyed; do not free them. +""" +function cuOptGetProblemStringArrayAttribute(problem, attribute, strings_out, count) + ccall((:cuOptGetProblemStringArrayAttribute, libcuopt), cuopt_int_t, (cuOptOptimizationProblem, cuopt_int_t, Ptr{Ptr{Cchar}}, cuopt_int_t), problem, attribute, strings_out, count) +end + const CUOPT_INSTANTIATE_FLOAT = 0 const CUOPT_INSTANTIATE_DOUBLE = 1 @@ -1037,6 +1120,8 @@ const CUOPT_ORDERING = "ordering" const CUOPT_BARRIER_DUAL_INITIAL_POINT = "barrier_dual_initial_point" +const CUOPT_POSTSOLVE_INFO = "postsolve_info" + const CUOPT_BARRIER_ITERATIVE_REFINEMENT = "barrier_iterative_refinement" const CUOPT_BARRIER_STEP_SCALE = "barrier_step_scale" @@ -1087,10 +1172,14 @@ const CUOPT_MIP_IMPLIED_BOUND_CUTS = "mip_implied_bound_cuts" const CUOPT_MIP_CLIQUE_CUTS = "mip_clique_cuts" +const CUOPT_MIP_ZERO_HALF_CUTS = "mip_zero_half_cuts" + const CUOPT_MIP_STRONG_CHVATAL_GOMORY_CUTS = "mip_strong_chvatal_gomory_cuts" const CUOPT_MIP_REDUCED_COST_STRENGTHENING = "mip_reduced_cost_strengthening" +const CUOPT_MIP_RINS = "mip_rins" + const CUOPT_MIP_OBJECTIVE_STEP = "mip_objective_step" const CUOPT_MIP_CUT_CHANGE_THRESHOLD = "mip_cut_change_threshold" @@ -1109,6 +1198,10 @@ const CUOPT_NUM_CPU_THREADS = "num_cpu_threads" const CUOPT_NUM_GPUS = "num_gpus" +const CUOPT_DISTRIBUTED_PDLP_PARTITIONER = "distributed_pdlp_partitioner" + +const CUOPT_USE_DISTRIBUTED_PDLP = "use_distributed_pdlp" + const CUOPT_USER_PROBLEM_FILE = "user_problem_file" const CUOPT_PRESOLVE_FILE = "presolve_file" @@ -1153,6 +1246,46 @@ const CUOPT_MIP_HYPER_HEURISTIC_RELAXED_LP_TIME_LIMIT = "mip_hyper_heuristic_rel const CUOPT_MIP_HYPER_HEURISTIC_RELATED_VARS_TIME_LIMIT = "mip_hyper_heuristic_related_vars_time_limit" +const CUOPT_MIP_HYPER_DIVING_LINE_SEARCH = "mip_hyper_diving_line_search" + +const CUOPT_MIP_HYPER_DIVING_PSEUDOCOST = "mip_hyper_diving_pseudocost" + +const CUOPT_MIP_HYPER_DIVING_GUIDED = "mip_hyper_diving_guided" + +const CUOPT_MIP_HYPER_DIVING_COEFFICIENT = "mip_hyper_diving_coefficient" + +const CUOPT_MIP_HYPER_DIVING_FARKAS = "mip_hyper_diving_farkas" + +const CUOPT_MIP_HYPER_DIVING_VECTOR_LENGTH = "mip_hyper_diving_vector_length" + +const CUOPT_MIP_HYPER_DIVING_MIN_NODE_DEPTH = "mip_hyper_diving_min_node_depth" + +const CUOPT_MIP_HYPER_DIVING_NODE_LIMIT = "mip_hyper_diving_node_limit" + +const CUOPT_MIP_HYPER_DIVING_ITERATION_LIMIT_FACTOR = "mip_hyper_diving_iteration_limit_factor" + +const CUOPT_MIP_HYPER_DIVING_BACKTRACK_LIMIT = "mip_hyper_diving_backtrack_limit" + +const CUOPT_MIP_HYPER_DIVING_SHOW_TYPE = "mip_hyper_diving_show_type" + +const CUOPT_MIP_HYPER_SUBMIP_BASE_TARGET_FIXRATE = "mip_hyper_submip_base_target_fixrate" + +const CUOPT_MIP_HYPER_SUBMIP_MIN_FIXRATE = "mip_hyper_submip_min_fixrate" + +const CUOPT_MIP_HYPER_SUBMIP_MIN_FIXRATE_CAP = "mip_hyper_submip_min_fixrate_cap" + +const CUOPT_MIP_HYPER_SUBMIP_TARGET_MIP_GAP = "mip_hyper_submip_target_mip_gap" + +const CUOPT_MIP_HYPER_SUBMIP_NODE_LIMIT_BASE = "mip_hyper_submip_node_limit_base" + +const CUOPT_MIP_HYPER_SUBMIP_MAX_LEVEL = "mip_hyper_submip_max_level" + +const CUOPT_MIP_HYPER_SUBMIP_ITERATION_LIMIT_RATIO = "mip_hyper_submip_iteration_limit_ratio" + +const CUOPT_MIP_HYPER_SUBMIP_ENABLE_CPUFJ = "mip_hyper_submip_enable_cpufj" + +const CUOPT_QCQP_HYPER_RUIZ_EQUILIBRATION = "qcqp_hyper_ruiz_equilibration" + const CUOPT_MODE_OPPORTUNISTIC = 0 const CUOPT_MODE_DETERMINISTIC = 1 @@ -1251,6 +1384,12 @@ const CUOPT_PRESOLVE_PAPILO = 1 const CUOPT_PRESOLVE_PSLP = 2 +const CUOPT_DISTRIBUTED_PDLP_PARTITIONER_AUTO = 0 + +const CUOPT_DISTRIBUTED_PDLP_PARTITIONER_KAMINPAR = 1 + +const CUOPT_DISTRIBUTED_PDLP_PARTITIONER_ROUND_ROBIN = 2 + const CUOPT_MIP_SCALING_OFF = 0 const CUOPT_MIP_SCALING_ON = 1 @@ -1260,3 +1399,45 @@ const CUOPT_MIP_SCALING_NO_OBJECTIVE = 2 const CUOPT_BARRIER_ITERATIVE_REFINEMENT_OFF = 0 const CUOPT_BARRIER_ITERATIVE_REFINEMENT_ON = 1 + +const CUOPT_ATTR_NUM_VARIABLES = 0 + +const CUOPT_ATTR_NUM_CONSTRAINTS = 1 + +const CUOPT_ATTR_NUM_NONZEROS = 2 + +const CUOPT_ATTR_NUM_INTEGERS = 3 + +const CUOPT_ATTR_OBJECTIVE_SENSE = 4 + +const CUOPT_ATTR_OBJECTIVE_OFFSET = 5 + +const CUOPT_ATTR_OBJECTIVE_SCALING_FACTOR = 6 + +const CUOPT_ATTR_PROBLEM_CATEGORY = 7 + +const CUOPT_ATTR_IS_MIP = 8 + +const CUOPT_ATTR_HAS_QUADRATIC_OBJECTIVE = 9 + +const CUOPT_ATTR_HAS_QUADRATIC_CONSTRAINTS = 10 + +const CUOPT_ARRAY_ATTR_OBJECTIVE_COEFFICIENTS = 100 + +const CUOPT_ARRAY_ATTR_VARIABLE_LOWER_BOUNDS = 101 + +const CUOPT_ARRAY_ATTR_VARIABLE_UPPER_BOUNDS = 102 + +const CUOPT_ARRAY_ATTR_CONSTRAINT_LOWER_BOUNDS = 103 + +const CUOPT_ARRAY_ATTR_CONSTRAINT_UPPER_BOUNDS = 104 + +const CUOPT_ARRAY_ATTR_CONSTRAINT_RHS = 105 + +const CUOPT_ARRAY_ATTR_CONSTRAINT_SENSE = 106 + +const CUOPT_ARRAY_ATTR_VARIABLE_TYPES = 107 + +const CUOPT_STRING_ARRAY_VARIABLE_NAMES = 200 + +const CUOPT_STRING_ARRAY_ROW_NAMES = 201 From 6c4eb5444656756ca7f96a861e352ff7aa8835b6 Mon Sep 17 00:00:00 2001 From: Miles Lubin Date: Fri, 21 Aug 2026 13:17:29 -0400 Subject: [PATCH 2/2] update path to cuopt_c.h Signed-off-by: Miles Lubin --- gen/README.md | 6 +++--- gen/gen.jl | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gen/README.md b/gen/README.md index ef4e3b0..223669d 100644 --- a/gen/README.md +++ b/gen/README.md @@ -11,14 +11,14 @@ Set the environment variable `CUOPT_INCLUDE_PATH` to the path of the cuOpt inclu You can search for the include path using the following command: ```bash -find / -path "*/cuopt/linear_programming/cuopt_c.h" +find / -path "*/cuopt/mathematical_optimization/cuopt_c.h" ``` ```bash export CUOPT_INCLUDE_PATH=/path/to/cuopt/include ``` -If the file path is something like this, ``/home/cuopt/.local/lib/python3.12/site-packages/libcuopt/include/cuopt/linear_programming/cuopt_c.h``, the path you would be setting is as followsm +If the file path is something like this, ``/home/cuopt/.local/lib/python3.12/site-packages/libcuopt/include/cuopt/mathematical_optimization/cuopt_c.h``, the path you would be setting is as follows: ```bash @@ -30,4 +30,4 @@ Run the following command to generate the C wrapper for cuOpt: ```bash julia --project=gen -e 'using Pkg; Pkg.instantiate()' julia --project=gen gen/gen.jl -``` \ No newline at end of file +``` diff --git a/gen/gen.jl b/gen/gen.jl index 301dcb8..32b143e 100644 --- a/gen/gen.jl +++ b/gen/gen.jl @@ -16,7 +16,7 @@ using Clang.Generators cuopt_include = get(ENV, "CUOPT_INCLUDE_PATH", "") -c_api = joinpath(cuopt_include, "cuopt/linear_programming/cuopt_c.h") +c_api = joinpath(cuopt_include, "cuopt/mathematical_optimization/cuopt_c.h") build!( create_context(