Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions docs/cuopt/source/cuopt-python/lp-milp/lp-milp-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,44 @@
LP and MILP API Reference
=========================

.. autoclass:: cuopt.linear_programming.problem.VType
.. autoclass:: cuopt.linear_programming.problem.Problem
:members:
:member-order: bysource
:undoc-members:
:exclude-members: capitalize, casefold, center, count, encode, endswith, expandtabs, find, format, format_map, index, isalnum, isalpha, isascii, isdecimal, isdigit, isidentifier, islower, isnumeric, isprintable, isspace, istitle, isupper, join, ljust, lower, lstrip, maketrans, partition, removeprefix, removesuffix, replace, rfind, rindex, rjust, rpartition, rsplit, rstrip, split, splitlines, startswith, strip, swapcase, title, translate, upper, zfill
:exclude-members: reset_solved_values, populate_solution, dict_to_object, NumNZs, NumVariables, NumConstraints, IsMIP

.. autoclass:: cuopt.linear_programming.problem.CType
.. autoclass:: cuopt.linear_programming.problem.Variable
:members:
:member-order: bysource
:undoc-members:
:exclude-members: capitalize, casefold, center, count, encode, endswith, expandtabs, find, format, format_map, index, isalnum, isalpha, isascii, isdecimal, isdigit, isidentifier, islower, isnumeric, isprintable, isspace, istitle, isupper, join, ljust, lower, lstrip, maketrans, partition, removeprefix, removesuffix, replace, rfind, rindex, rjust, rpartition, rsplit, rstrip, split, splitlines, startswith, strip, swapcase, title, translate, upper, zfill
:exclude-members:

.. autoclass:: cuopt.linear_programming.problem.sense
.. autoclass:: cuopt.linear_programming.problem.LinearExpression
:members:
:member-order: bysource
:exclude-members: __new__, __init__, _generate_next_value_, as_integer_ratio, bit_count, bit_length, conjugate, denominator, from_bytes, imag, is_integer, numerator, real, to_bytes
:no-inherited-members:
:undoc-members:

.. autoclass:: cuopt.linear_programming.problem.Problem
.. autoclass:: cuopt.linear_programming.problem.Constraint
:members:
:undoc-members:
:exclude-members: compute_slack

.. autoclass:: cuopt.linear_programming.solver_settings.SolverSettings
:members:
:undoc-members:
:show-inheritance:
:exclude-members: reset_solved_values, post_solve, dict_to_object, NumNZs, NumVariables, NumConstraints, IsMIP
:exclude-members: to_base_type, toDict

.. autoclass:: cuopt.linear_programming.problem.Variable
.. autoclass:: cuopt.linear_programming.problem.VType
:members:
:member-order: bysource
:undoc-members:
:show-inheritance:
:exclude-members:
:exclude-members: capitalize, casefold, center, count, encode, endswith, expandtabs, find, format, format_map, index, isalnum, isalpha, isascii, isdecimal, isdigit, isidentifier, islower, isnumeric, isprintable, isspace, istitle, isupper, join, ljust, lower, lstrip, maketrans, partition, removeprefix, removesuffix, replace, rfind, rindex, rjust, rpartition, rsplit, rstrip, split, splitlines, startswith, strip, swapcase, title, translate, upper, zfill

.. autoclass:: cuopt.linear_programming.problem.LinearExpression
.. autoclass:: cuopt.linear_programming.problem.CType
:members:
:member-order: bysource
:undoc-members:
:show-inheritance:
:exclude-members: capitalize, casefold, center, count, encode, endswith, expandtabs, find, format, format_map, index, isalnum, isalpha, isascii, isdecimal, isdigit, isidentifier, islower, isnumeric, isprintable, isspace, istitle, isupper, join, ljust, lower, lstrip, maketrans, partition, removeprefix, removesuffix, replace, rfind, rindex, rjust, rpartition, rsplit, rstrip, split, splitlines, startswith, strip, swapcase, title, translate, upper, zfill

.. autoclass:: cuopt.linear_programming.problem.Constraint
.. autoclass:: cuopt.linear_programming.problem.sense
:members:
:member-order: bysource
:undoc-members:
:show-inheritance:
:exclude-members: compute_slack
:exclude-members: __new__, __init__, _generate_next_value_, as_integer_ratio, bit_count, bit_length, conjugate, denominator, from_bytes, imag, is_integer, numerator, real, to_bytes
75 changes: 75 additions & 0 deletions docs/cuopt/source/cuopt-python/lp-milp/lp-milp-examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,78 @@ The response is as follows:
Solve time: 0.16 seconds
Final solution: x=36.0, y=40.99999999999999
Final objective value: 303.00

Working with PDLP Warmstart Data
--------------------------------

Warmstart data allows to restart PDLP with a previous solution context. This should be used when you solve a new problem which is similar to the previous one.

.. note::
Warmstart data is only available for Linear Programming (LP) problems, not for Mixed Integer Linear Programming (MILP) problems.

.. code-block:: python

from cuopt.linear_programming.problem import Problem, CONTINUOUS, MAXIMIZE
from cuopt.linear_programming.solver.solver_parameters import CUOPT_METHOD
from cuopt.linear_programming.solver_settings import SolverSettings, SolverMethod

# Create a new problem
problem = Problem("Simple LP")

# Add variables
x = problem.addVariable(lb=0, vtype=CONTINUOUS, name="x")
y = problem.addVariable(lb=0, vtype=CONTINUOUS, name="y")

# Add constraints
problem.addConstraint(4*x + 10*y <= 130, name="c1")
problem.addConstraint(8*x - 3*y >= 40, name="c2")

# Set objective function
problem.setObjective(2*x + y, sense=MAXIMIZE)

# Configure solver settings
settings = SolverSettings()
settings.set_parameter(CUOPT_METHOD, SolverMethod.PDLP)

# Solve the problem
problem.solve(settings)

# Get the warmstart data
warmstart_data = problem.get_pdlp_warm_start_data()

print(warmstart_data.current_primal_solution)
# Create a new problem
new_problem = Problem("Warmstart LP")

# Add variables
x = new_problem.addVariable(lb=0, vtype=CONTINUOUS, name="x")
y = new_problem.addVariable(lb=0, vtype=CONTINUOUS, name="y")

# Add constraints
new_problem.addConstraint(4*x + 10*y <= 100, name="c1")
new_problem.addConstraint(8*x - 3*y >= 50, name="c2")

# Set objective function
new_problem.setObjective(2*x + y, sense=MAXIMIZE)

# Configure solver settings
settings.set_pdlp_warm_start_data(warmstart_data)

# Solve the problem
new_problem.solve(settings)

# Check solution status
if new_problem.Status.name == "Optimal":
print(f"Optimal solution found in {new_problem.SolveTime:.2f} seconds")
print(f"x = {x.getValue()}")
print(f"y = {y.getValue()}")
print(f"Objective value = {new_problem.ObjValue}")

The response is as follows:

.. code-block:: text

Optimal solution found in 0.01 seconds
x = 25.000000000639382
y = 0.0
Objective value = 50.000000001278764
Loading