diff --git a/cpp/include/cuopt/mathematical_optimization/cuopt_c.h b/cpp/include/cuopt/mathematical_optimization/cuopt_c.h index 2fdcbe84f4..643918655b 100644 --- a/cpp/include/cuopt/mathematical_optimization/cuopt_c.h +++ b/cpp/include/cuopt/mathematical_optimization/cuopt_c.h @@ -623,8 +623,8 @@ cuopt_int_t cuOptGetConstraintMatrixCSR(cuOptOptimizationProblem problem, * @param[in] problem - The optimization problem. * * @param[out] constraint_matrix_column_offsets_ptr - A pointer to an array of type cuopt_int_t of - * size num_variables + 1 (see cuOptGetProblemIntAttribute) that on output will contain the column - * offsets of the constraint matrix. + * size num_variables + 1 that on output will contain the column offsets of the constraint + * matrix. * * @param[out] constraint_matrix_row_indices_ptr - A pointer to an array of type cuopt_int_t of size * equal to the number of nonzeros (see cuOptGetNumNonZeros) that on output will contain the row diff --git a/docs/cuopt/source/cuopt-c/convex/convex-c-api.rst b/docs/cuopt/source/cuopt-c/convex/convex-c-api.rst index 1c10fdbf71..1a67a71764 100644 --- a/docs/cuopt/source/cuopt-c/convex/convex-c-api.rst +++ b/docs/cuopt/source/cuopt-c/convex/convex-c-api.rst @@ -70,7 +70,7 @@ For problems with quadratic constraints, first create a problem, and then use Support for quadratic constraints is currently in **beta**. ``cuOptAddQuadraticConstraint`` supports three types of quadratic constraints: - **Convex quadratic constraints** of the form ``x^T Q x + d^T x <= alpha`` where ``H=(Q+Q^T)/2`` is a symmetric positive semidefinite matrix. `Q` need not be symmetric. - - **Second-order cone constraints** of the form ``sum_{i=1}^n x_i^2 <= x_0``, ``x_0 >= 0`` + - **Second-order cone constraints** of the form ``sum_{i=1}^n x_i^2 <= x_0^2``, ``x_0 >= 0`` - **Rotated second-order cone constraints** of the form ``sum_{i=2}^n x_i^2 - 2 * x_0 * x_1 <= 0``, ``x_0 >= 0``, ``x_1 >= 0`` (supply ``Q[x_0, x_1] = -2`` in COO, or ``-x_0*x_1`` for the ``<= x_0*x_1`` cone form; see :doc:`/convex-features`) Only ``CUOPT_LESS_THAN`` and ``CUOPT_GREATER_THAN`` sense is supported; equality constraints are not supported. @@ -134,6 +134,7 @@ The following functions may be used to get information about an `cuOptimizationP .. doxygenfunction:: cuOptGetNumNonZeros .. doxygenfunction:: cuOptGetConstraintMatrix .. doxygenfunction:: cuOptGetConstraintMatrixCSR +.. doxygenfunction:: cuOptGetConstraintMatrixCSC .. doxygenfunction:: cuOptGetConstraintSense .. doxygenfunction:: cuOptGetConstraintRightHandSide .. doxygenfunction:: cuOptGetConstraintLowerBounds @@ -300,6 +301,16 @@ These constants are used to configure `CUOPT_MULTIGPU_PDLP_PARTITIONER` via :c:f .. doxygendefine:: CUOPT_MULTIGPU_PDLP_PARTITIONER_KAMINPAR .. doxygendefine:: CUOPT_MULTIGPU_PDLP_PARTITIONER_ROUND_ROBIN +Presolve Constants +------------------ + +These constants are used to configure `CUOPT_PRESOLVE` via :c:func:`cuOptSetIntegerParameter`. + +.. doxygendefine:: CUOPT_PRESOLVE_DEFAULT +.. doxygendefine:: CUOPT_PRESOLVE_OFF +.. doxygendefine:: CUOPT_PRESOLVE_PAPILO +.. doxygendefine:: CUOPT_PRESOLVE_PSLP + .. _barrier-iterative-refinement-constants: Barrier Iterative Refinement Constants diff --git a/docs/cuopt/source/cuopt-c/convex/convex-examples.rst b/docs/cuopt/source/cuopt-c/convex/convex-examples.rst index 6df2a9e267..2ded010099 100644 --- a/docs/cuopt/source/cuopt-c/convex/convex-examples.rst +++ b/docs/cuopt/source/cuopt-c/convex/convex-examples.rst @@ -8,7 +8,7 @@ LP Example with Data This example demonstrates how to use the LP solver in C. More details on the API can be found in :doc:`C API `. -The example code is available at ``examples/cuopt-c/lp/simple_lp_example.c`` (:download:`download `): +The example code is available at ``docs/cuopt/source/cuopt-c/convex/examples/simple_lp_example.c`` (:download:`download `): .. literalinclude:: examples/simple_lp_example.c :language: c @@ -22,9 +22,9 @@ If you have built it locally, libcuopt.so will be in the build directory ``cpp/b .. code-block:: bash # Find the cuopt header file and assign to INCLUDE_PATH - INCLUDE_PATH=$(find / -name "cuopt_c.h" -path "*/linear_programming/*" -printf "%h\n" | sed 's/\/linear_programming//' 2>/dev/null) - # Find the libcuopt library and assign to LIBCUOPT_LIBRARY_PATH - LIBCUOPT_LIBRARY_PATH=$(find / -name "libcuopt.so" 2>/dev/null) + INCLUDE_PATH=$(find / -name "cuopt_c.h" -path "*/mathematical_optimization/*" -printf "%h\n" 2>/dev/null | head -1 | sed 's/\/cuopt\/mathematical_optimization$//') + # Find the libcuopt library directory and assign to LIBCUOPT_LIBRARY_PATH + LIBCUOPT_LIBRARY_PATH=$(dirname $(find / -name "libcuopt.so" 2>/dev/null | head -1)) Build and run the example @@ -79,7 +79,7 @@ format is dispatched from the filename extension (case-insensitive): their ``.gz`` / ``.bz2`` variants → MPS parser. Unknown extensions are rejected. See :ref:`lp-file-example-c` for an LP counterpart. -The example code is available at ``examples/cuopt-c/lp/mps_file_example.c`` (:download:`download `): +The example code is available at ``docs/cuopt/source/cuopt-c/convex/examples/mps_file_example.c`` (:download:`download `): .. literalinclude:: examples/mps_file_example.c :language: c @@ -93,9 +93,9 @@ If you have built it locally, libcuopt.so will be in the build directory ``cpp/b .. code-block:: bash # Find the cuopt header file and assign to INCLUDE_PATH - INCLUDE_PATH=$(find / -name "cuopt_c.h" -path "*/linear_programming/*" -printf "%h\n" | sed 's/\/linear_programming//' 2>/dev/null) - # Find the libcuopt library and assign to LIBCUOPT_LIBRARY_PATH - LIBCUOPT_LIBRARY_PATH=$(find / -name "libcuopt.so" 2>/dev/null) + INCLUDE_PATH=$(find / -name "cuopt_c.h" -path "*/mathematical_optimization/*" -printf "%h\n" 2>/dev/null | head -1 | sed 's/\/cuopt\/mathematical_optimization$//') + # Find the libcuopt library directory and assign to LIBCUOPT_LIBRARY_PATH + LIBCUOPT_LIBRARY_PATH=$(dirname $(find / -name "libcuopt.so" 2>/dev/null | head -1)) A sample MPS file (:download:`download sample.mps `): @@ -157,7 +157,7 @@ rejected. See the ``read_lp`` declaration in ``cuopt/mathematical_optimization/io/parser.hpp`` for the supported subset of the LP format. -The example code is available at ``examples/cuopt-c/lp/lp_file_example.c`` (:download:`download `): +The example code is available at ``docs/cuopt/source/cuopt-c/convex/examples/lp_file_example.c`` (:download:`download `): .. literalinclude:: examples/lp_file_example.c :language: c @@ -187,7 +187,7 @@ Simple Quadratic Programming Example This example demonstrates how to use the cuOpt C API for quadratic programming. -The example code is available at ``examples/cuopt-c/lp/simple_qp_example.c`` (:download:`download `): +The example code is available at ``docs/cuopt/source/cuopt-c/convex/examples/simple_qp_example.c`` (:download:`download `): .. literalinclude:: examples/simple_qp_example.c :language: c @@ -227,7 +227,7 @@ Simple Second-Order Cone Programming Example This example builds an SOCP directly with the C API: a linear problem is created with :c:func:`cuOptCreateProblem`, then a second-order cone constraint is added with :c:func:`cuOptAddQuadraticConstraint`. It minimizes ``x3`` subject to ``x1 + x2 >= 2`` and the cone ``||(x1, x2)||_2 <= x3``, written as the quadratic inequality ``x1^2 + x2^2 - x3^2 <= 0``. cuOpt detects the second-order cone structure and solves with the barrier method. -The example code is available at ``examples/cuopt-c/lp/simple_socp_example.c`` (:download:`download `): +The example code is available at ``docs/cuopt/source/cuopt-c/convex/examples/simple_socp_example.c`` (:download:`download `): .. literalinclude:: examples/simple_socp_example.c :language: c @@ -273,7 +273,7 @@ cone ``x1^2 + x2^2 <= x3*x4`` is expressed as ``x1^2 + x2^2 - x3*x4 <= 0``. See for other RSOC forms. It minimizes ``x3 + x4`` subject to ``x1 + x2 >= 2`` and the rotated cone. -The example code is available at ``examples/cuopt-c/lp/rotated_socp_example.c`` (:download:`download `): +The example code is available at ``docs/cuopt/source/cuopt-c/convex/examples/rotated_socp_example.c`` (:download:`download `): .. literalinclude:: examples/rotated_socp_example.c :language: c @@ -320,7 +320,7 @@ This example adds a general convex quadratic constraint with ``2*x^2 + 2*x*y + 2*y^2 <= 6``. Note that the quadratic matrix Q that encodes this constraint need not be symmetric. Here the term ``2*x*y`` is supplied as a single entry ``Q[0,1] = 2``. -The example code is available at ``examples/cuopt-c/lp/general_quadratic_example.c`` (:download:`download `): +The example code is available at ``docs/cuopt/source/cuopt-c/convex/examples/general_quadratic_example.c`` (:download:`download `): .. literalinclude:: examples/general_quadratic_example.c :language: c diff --git a/docs/cuopt/source/cuopt-c/convex/examples/simple_qp_example.c b/docs/cuopt/source/cuopt-c/convex/examples/simple_qp_example.c index 2b3de3ae7c..7571a5b75c 100644 --- a/docs/cuopt/source/cuopt-c/convex/examples/simple_qp_example.c +++ b/docs/cuopt/source/cuopt-c/convex/examples/simple_qp_example.c @@ -83,13 +83,14 @@ cuopt_int_t test_simple_qp() // 0 is the coefficient of the linear term on y cuopt_float_t linear_objective_coefficients[] = {0.0, 0.0}; - // Quadratic objective matrix + // Quadratic objective matrix in COO format // From the objective function: minimize x^2 + y^2 // 1 is the coefficient of the quadratic term on x^2 // 1 is the coefficient of the quadratic term on y^2 - cuopt_float_t quadratic_objective_matrix_values[] = {1.0, 1.0}; - cuopt_int_t quadratic_objective_matrix_row_offsets[] = {0, 1, 2}; - cuopt_int_t quadratic_objective_matrix_column_indices[] = {0, 1}; + cuopt_int_t quadratic_num_entries = 2; + cuopt_int_t quadratic_objective_row_indices[] = {0, 1}; + cuopt_int_t quadratic_objective_column_indices[] = {0, 1}; + cuopt_float_t quadratic_objective_values[] = {1.0, 1.0}; // Constraint bounds // From the constraints: @@ -115,28 +116,37 @@ cuopt_int_t test_simple_qp() printf("Creating and solving simple QP problem...\n"); - // Create the problem - status = cuOptCreateQuadraticProblem(num_constraints, - num_variables, - CUOPT_MINIMIZE, - 0.0, // objective offset - linear_objective_coefficients, - quadratic_objective_matrix_row_offsets, - quadratic_objective_matrix_column_indices, - quadratic_objective_matrix_values, - row_offsets, - column_indices, - values, - constraint_sense, - constraint_rhs, - var_lower_bounds, - var_upper_bounds, - &problem); + // Create the problem with its linear data + status = cuOptCreateProblem(num_constraints, + num_variables, + CUOPT_MINIMIZE, + 0.0, // objective offset + linear_objective_coefficients, + row_offsets, + column_indices, + values, + constraint_sense, + constraint_rhs, + var_lower_bounds, + var_upper_bounds, + variable_types, + &problem); if (status != CUOPT_SUCCESS) { printf("Error creating problem: %d\n", status); goto DONE; } + // Set the quadratic objective + status = cuOptSetQuadraticObjective(problem, + quadratic_num_entries, + quadratic_objective_row_indices, + quadratic_objective_column_indices, + quadratic_objective_values); + if (status != CUOPT_SUCCESS) { + printf("Error setting quadratic objective: %d\n", status); + goto DONE; + } + // Create solver settings status = cuOptCreateSolverSettings(&settings); if (status != CUOPT_SUCCESS) { diff --git a/docs/cuopt/source/cuopt-c/mip/mip-c-api.rst b/docs/cuopt/source/cuopt-c/mip/mip-c-api.rst index ee2e7b1447..56d59187bb 100644 --- a/docs/cuopt/source/cuopt-c/mip/mip-c-api.rst +++ b/docs/cuopt/source/cuopt-c/mip/mip-c-api.rst @@ -77,3 +77,12 @@ These constants are used to configure `CUOPT_MIP_DETERMINISM_MODE` via :c:func:` .. doxygendefine:: CUOPT_MODE_OPPORTUNISTIC .. doxygendefine:: CUOPT_MODE_DETERMINISTIC + +MIP Scaling Constants +--------------------- + +These constants are used to configure `CUOPT_MIP_SCALING` via :c:func:`cuOptSetIntegerParameter`. + +.. doxygendefine:: CUOPT_MIP_SCALING_OFF +.. doxygendefine:: CUOPT_MIP_SCALING_ON +.. doxygendefine:: CUOPT_MIP_SCALING_NO_OBJECTIVE diff --git a/docs/cuopt/source/cuopt-c/mip/mip-examples.rst b/docs/cuopt/source/cuopt-c/mip/mip-examples.rst index 624e4b001a..74f65d3642 100644 --- a/docs/cuopt/source/cuopt-c/mip/mip-examples.rst +++ b/docs/cuopt/source/cuopt-c/mip/mip-examples.rst @@ -7,7 +7,7 @@ Example with Data This example demonstrates how to use the MIP solver in C. More details on the API can be found in :doc:`MIP C API `. -The example code is available at ``../lp-milp/examples/simple_milp_example.c`` (:download:`download `): +The example code is available at ``docs/cuopt/source/cuopt-c/mip/examples/simple_milp_example.c`` (:download:`download `): .. literalinclude:: examples/simple_milp_example.c :language: c @@ -21,9 +21,9 @@ If you have built it locally, libcuopt.so will be in the build directory ``cpp/b .. code-block:: bash # Find the cuopt header file and assign to INCLUDE_PATH - INCLUDE_PATH=$(find / -name "cuopt_c.h" -path "*/linear_programming/*" -printf "%h\n" | sed 's/\/linear_programming//' 2>/dev/null) + INCLUDE_PATH=$(find / -name "cuopt_c.h" -path "*/mathematical_optimization/*" -printf "%h\n" 2>/dev/null | head -1 | sed 's/\/cuopt\/mathematical_optimization$//') # Find the libcuopt library directory and assign to LIBCUOPT_LIBRARY_PATH - LIBCUOPT_LIBRARY_PATH=$(dirname $(find / -name "libcuopt.so" 2>/dev/null)) + LIBCUOPT_LIBRARY_PATH=$(dirname $(find / -name "libcuopt.so" 2>/dev/null | head -1)) Build and run the example @@ -80,7 +80,7 @@ Example with MPS File This example demonstrates how to use the cuOpt solver in C to solve an MPS file. -The example code is available at ``examples/milp_mps_example.c`` (:download:`download `): +The example code is available at ``docs/cuopt/source/cuopt-c/mip/examples/milp_mps_example.c`` (:download:`download `): .. literalinclude:: examples/milp_mps_example.c :language: c @@ -94,9 +94,9 @@ If you have built it locally, libcuopt.so will be in the build directory ``cpp/b .. code-block:: bash # Find the cuopt header file and assign to INCLUDE_PATH - INCLUDE_PATH=$(find / -name "cuopt_c.h" -path "*/linear_programming/*" -printf "%h\n" | sed 's/\/linear_programming//' 2>/dev/null) + INCLUDE_PATH=$(find / -name "cuopt_c.h" -path "*/mathematical_optimization/*" -printf "%h\n" 2>/dev/null | head -1 | sed 's/\/cuopt\/mathematical_optimization$//') # Find the libcuopt library directory and assign to LIBCUOPT_LIBRARY_PATH - LIBCUOPT_LIBRARY_PATH=$(dirname $(find / -name "libcuopt.so" 2>/dev/null)) + LIBCUOPT_LIBRARY_PATH=$(dirname $(find / -name "libcuopt.so" 2>/dev/null | head -1)) A sample MIP MPS file (:download:`download mip_sample.mps `): diff --git a/docs/cuopt/source/cuopt-server/examples/milp-examples.rst b/docs/cuopt/source/cuopt-server/examples/milp-examples.rst index 8eef2d51a6..322ef969fc 100644 --- a/docs/cuopt/source/cuopt-server/examples/milp-examples.rst +++ b/docs/cuopt/source/cuopt-server/examples/milp-examples.rst @@ -217,11 +217,11 @@ Aborting a Running Job In CLI UUID that is returned by the solver while the solver is trying to find a solution so users can come back and check the status or query for results. -This aborts a job with UUID if it's in running state. +This aborts a job with UUID if it's queued or running. .. code-block:: bash # Please update ip and port if the server is running on a different IP address or port export ip="localhost" export port=5000 - cuopt_sh -d -r -q -i $ip -p $port + cuopt_sh -d -i $ip -p $port diff --git a/docs/cuopt/source/cuopt-server/examples/milp/examples/abort_job_example.py b/docs/cuopt/source/cuopt-server/examples/milp/examples/abort_job_example.py index f08b5f6b7e..1abeaacda1 100644 --- a/docs/cuopt/source/cuopt-server/examples/milp/examples/abort_job_example.py +++ b/docs/cuopt/source/cuopt-server/examples/milp/examples/abort_job_example.py @@ -34,15 +34,8 @@ def main(): ip="localhost", port=5000 ) - # Delete the job if it is still queued or running - # Parameters: - # - job_uuid: The UUID of the job to abort - # - running=True: Abort if the job is currently running - # - queued=True: Abort if the job is in the queue - # - cached=False: Don't delete from cache (only abort active/queued jobs) - response = cuopt_service_client.delete( - job_uuid, running=True, queued=True, cached=False - ) + # Abort the job if it is still queued or running + response = cuopt_service_client.delete(job_uuid) print(f"Response: {response}") diff --git a/docs/cuopt/source/cuopt-server/examples/milp/examples/abort_job_example.sh b/docs/cuopt/source/cuopt-server/examples/milp/examples/abort_job_example.sh index 95082aee0d..dfac2bc873 100755 --- a/docs/cuopt/source/cuopt-server/examples/milp/examples/abort_job_example.sh +++ b/docs/cuopt/source/cuopt-server/examples/milp/examples/abort_job_example.sh @@ -27,9 +27,7 @@ echo "Aborting job with UUID: $UUID" # Abort the job # -d: Delete/abort -# -r: If running -# -q: If queued -cuopt_sh -d -r -q $UUID -i $ip -p $port +cuopt_sh -d $UUID -i $ip -p $port echo "Job abort request sent" echo "" diff --git a/docs/cuopt/source/cuopt-server/examples/routing-examples.rst b/docs/cuopt/source/cuopt-server/examples/routing-examples.rst index fdef42f318..e3b4c1a2ea 100644 --- a/docs/cuopt/source/cuopt-server/examples/routing-examples.rst +++ b/docs/cuopt/source/cuopt-server/examples/routing-examples.rst @@ -76,6 +76,9 @@ Initial Solution Previously run solutions or uploaded solutions can be used as the initial solution for new requests using previously run reqIds as follows: +.. note:: + This example uploads a solution, which is only supported by the :ref:`legacy HTTP server `. The HTTP proxy server returns 501 for uploaded solutions. See :ref:`legacy-http-differences`. + :download:`initial_solution_example.py ` .. literalinclude:: routing/examples/initial_solution_example.py @@ -255,6 +258,9 @@ Uploading a Solution Users can also upload a solution which might have been saved for later runs. +.. note:: + Uploaded solutions are only supported by the :ref:`legacy HTTP server `. The HTTP proxy server returns 501. See :ref:`legacy-http-differences`. + .. code-block:: shell # Please update ip and port if the server is running on a different IP address or port