API Reference
Main Functions
HPRLP.run_lp — Function
run_lp(A, AL, AU, c, l, u, obj_constant, params)Solve a linear program in standard form using the HPR-LP algorithm.
Arguments
A::SparseMatrixCSC: Constraint matrix (m × n)AL::Vector{Float64}: Lower bounds for constraints Ax (length m)AU::Vector{Float64}: Upper bounds for constraints Ax (length m)c::Vector{Float64}: Objective coefficients (length n)l::Vector{Float64}: Lower bounds for variables x (length n)u::Vector{Float64}: Upper bounds for variables x (length n)obj_constant::Float64: Constant term in objective functionparams::HPRLP_parameters: Solver parameters
Returns
HPRLP_results: Solution results including objective value, solution vector, and convergence info
Example
using SparseArrays, HPRLP
# min -3x - 5y
# s.t. x + 2y ≤ 10
# 3x + y ≤ 12
# x, y ≥ 0
A = sparse([1.0 2.0; 3.0 1.0])
AL = [-Inf, -Inf]
AU = [10.0, 12.0]
c = [-3.0, -5.0]
l = [0.0, 0.0]
u = [Inf, Inf]
params = HPRLP_parameters()
params.verbose = false
results = run_lp(A, AL, AU, c, l, u, 0.0, params)
println("Optimal value: ", results.primal_obj)
println("Solution: ", results.x)sourceHPRLP.run_single — Function
run_single(file_name, params)Solve a linear program from an MPS file using the HPR-LP algorithm.
Arguments
file_name::String: Path to the .mps fileparams::HPRLP_parameters: Solver parameters
Returns
HPRLP_results: Solution results including objective value, solution vector, and convergence info
Example
using HPRLP
params = HPRLP_parameters()
params.stoptol = 1e-6
params.verbose = true
results = run_single("problem.mps", params)
println("Status: ", results.status)
println("Objective: ", results.primal_obj)
println("Time: ", results.time, " seconds")
println("Iterations: ", results.iter)See also: run_lp, HPRLP_parameters, HPRLP_results
Types
Parameters
HPRLP.HPRLP_parameters — Type
HPRLP_parametersParameters for the HPR-LP solver.
Fields
stoptol::Float64: Stopping tolerance (default: 1e-4)max_iter::Int: Maximum number of iterations (default: typemax(Int32))time_limit::Float64: Time limit in seconds (default: 3600.0)check_iter::Int: Interval for residual checks (default: 150)use_Ruiz_scaling::Bool: Enable Ruiz scaling (default: true)use_Pock_Chambolle_scaling::Bool: Enable Pock-Chambolle scaling (default: true)use_bc_scaling::Bool: Enable b/c scaling (default: true)use_gpu::Bool: Use GPU acceleration (default: true)device_number::Int: GPU device number (default: 0)warm_up::Bool: Enable warm-up phase (default: true)print_frequency::Int: Print log every N iterations, -1 for auto (default: -1)verbose::Bool: Enable verbose output (default: true)
Example
params = HPRLP_parameters()
params.stoptol = 1e-6
params.use_gpu = false
params.verbose = falsesourceFields
| Field | Type | Default | Description |
|---|---|---|---|
stoptol | Float64 | 1e-4 | Stopping tolerance for convergence |
max_iter | Int | typemax(Int32) | Maximum number of iterations |
time_limit | Float64 | 3600.0 | Time limit in seconds |
check_iter | Int | 150 | Frequency of residual checks |
use_Ruiz_scaling | Bool | true | Enable Ruiz equilibration scaling |
use_Pock_Chambolle_scaling | Bool | true | Enable Pock-Chambolle scaling |
use_bc_scaling | Bool | true | Enable scaling for b and c vectors |
use_gpu | Bool | true | Use GPU acceleration if available |
device_number | Int | 0 | GPU device number (for multi-GPU systems) |
warm_up | Bool | true | Perform warm-up run to compile code |
print_frequency | Int | -1 | Print frequency (-1 for automatic) |
verbose | Bool | true | Print solver output |
Example
params = HPRLP_parameters()
params.stoptol = 1e-6 # Tighter tolerance
params.use_gpu = true # Enable GPU
params.verbose = false # Silent mode
params.time_limit = 3600 # 1 hour limitResults
HPRLP.HPRLP_results — Type
HPRLP_resultsResults from the HPR-LP solver.
Fields
iter::Int: Total number of iterationsiter_4::Int: Iterations to reach 1e-4 accuracyiter_6::Int: Iterations to reach 1e-6 accuracyiter_8::Int: Iterations to reach 1e-8 accuracytime::Float64: Total solve time in secondstime_4::Float64: Time to reach 1e-4 accuracytime_6::Float64: Time to reach 1e-6 accuracytime_8::Float64: Time to reach 1e-8 accuracyprimal_obj::Float64: Primal objective valuedual_obj::Float64: Dual objective valueprimal_residual::Float64: Final primal feasibility residualdual_residual::Float64: Final dual feasibility residualrelative_duality_gap::Float64: Final relative duality gapx::Vector{Float64}: Primal solution vectorstatus::String: Termination status ("Optimal", "TimeLimit", "IterationLimit")
Example
results = run_lp(A, b, c, l, u)
println("Status: ", results.status)
println("Objective: ", results.primal_obj)
println("Time: ", results.time, " seconds")sourceFields
| Field | Type | Description |
|---|---|---|
iter | Int | Total number of iterations |
iter_4, iter_6, iter_8 | Int | Iterations to reach 1e-4, 1e-6, 1e-8 accuracy |
time | Float64 | Total solve time in seconds |
time_4, time_6, time_8 | Float64 | Time to reach 1e-4, 1e-6, 1e-8 accuracy |
power_time | Float64 | Time spent in power method for eigenvalue estimation |
primal_obj | Float64 | Primal objective value |
residuals | Float64 | Relative residuals (primal, dual, gap) |
gap | Float64 | Duality gap |
output_type | String | Status: "OPTIMAL", "MAXITER", or "TIMELIMIT" |
x | Vector{Float64} | Primal solution vector |
y | Vector{Float64} | Dual solution vector (constraints) |
z | Vector{Float64} | Dual solution vector (bounds) |
Example
result = run_lp(A, AL, AU, c, l, u, 0.0, params)
println("Status: ", result.output_type)
println("Objective: ", result.primal_obj)
println("Solution: ", result.x)
println("Iterations: ", result.iter)
println("Time: ", result.time, " seconds")
println("Residuals: ", result.residuals)MOI/JuMP Integration
Optimizer
HPRLP.Optimizer — Type
Optimizer()Create a new HPRLP Optimizer object.
Set optimizer attributes using MOI.RawOptimizerAttribute or JuMP.set_optimizer_attribute.
Example
using JuMP, HPRLP
model = JuMP.Model(HPRLP.Optimizer)
set_optimizer_attribute(model, "stoptol", 1e-4)
set_optimizer_attribute(model, "use_gpu", true)sourceThe Optimizer type implements the MathOptInterface (MOI) for integration with JuMP and other optimization modeling frameworks.
Supported Attributes
Optimizer Attributes
MOI.Silent: Set totruefor silent mode (equivalent toverbose = false)MOI.TimeLimitSec: Set time limit in secondsMOI.SolveTimeSec: Get solve time (after optimization)
Custom Attributes (via MOI.RawOptimizerAttribute)
All fields from HPRLP_parameters can be set as raw optimizer attributes:
using JuMP, HPRLP
model = Model(HPRLP.Optimizer)
# Standard MOI attributes
set_silent(model)
set_time_limit_sec(model, 3600.0)
# Custom HPRLP attributes
set_optimizer_attribute(model, "stoptol", 1e-6)
set_optimizer_attribute(model, "use_gpu", true)
set_optimizer_attribute(model, "use_Ruiz_scaling", true)
set_optimizer_attribute(model, "device_number", 0)Supported Problem Types
HPRLP supports linear programming problems with:
- Objective: Linear minimization or maximization
- Variables: Continuous with optional bounds
- Constraints:
MOI.EqualTo: Equality constraints (Ax = b)MOI.LessThan: Upper bound constraints (Ax ≤ b)MOI.GreaterThan: Lower bound constraints (Ax ≥ b)MOI.Interval: Two-sided constraints (l ≤ Ax ≤ u)
Result Queries
After calling optimize!(model):
# Termination status
status = termination_status(model) # OPTIMAL, TIME_LIMIT, or ITERATION_LIMIT
# Solution
if has_values(model)
obj_val = objective_value(model)
x_val = value.(x) # where x is your variable(s)
end
# Timing
solve_time = solve_time(model)Internal Functions
The following functions are exported for advanced users but are primarily used internally:
solve(lp, scaling_info, params): Main solver routineformulation(lp, verbose): Convert QPS data to standard formscaling!(lp, use_Ruiz, use_PC, use_bc): Apply problem scalingpower_iteration_gpu(...): Estimate maximum eigenvalue on GPUpower_iteration_cpu(...): Estimate maximum eigenvalue on CPU
Function Reference
run_lp
run_lp(A::SparseMatrixCSC,
AL::Vector{Float64},
AU::Vector{Float64},
c::Vector{Float64},
l::Vector{Float64},
u::Vector{Float64},
obj_constant::Float64,
params::HPRLP_parameters) -> HPRLP_resultsSolve a linear programming problem directly from matrix inputs.
Arguments:
A: Sparse constraint matrix (m × n)AL: Lower bounds on constraints (m-vector)AU: Upper bounds on constraints (m-vector)c: Objective coefficients (n-vector)l: Lower bounds on variables (n-vector)u: Upper bounds on variables (n-vector)obj_constant: Constant term in objectiveparams: Solver parameters
Returns: HPRLP_results containing solution and statistics
run_single
run_single(file_name::String,
params::HPRLP_parameters) -> HPRLP_resultsSolve a linear programming problem from an MPS file.
Arguments:
file_name: Path to MPS file (must have.mpsextension)params: Solver parameters
Returns: HPRLP_results containing solution and statistics
Example:
params = HPRLP_parameters()
params.use_gpu = false
params.verbose = true
result = run_single("problem.mps", params)