diff --git a/README.md b/README.md index 50aa4b2d..2eb68cee 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ pkg> add MadNLPHSL, MadNLPPardiso, MadNLPMumps, MadNLPGPU, MadNLPGraph, MadNLPIt These packages are stored in the `lib` subdirectory within the main MadNLP repository. Some extension packages may require additional dependencies or specific hardware. For the instructions for the build procedure, see the following links: [MadNLPHSL](https://github.com/sshin23/MadNLP.jl/tree/master/lib/MadNLPHSL), [MadNLPPardiso](https://github.com/sshin23/MadNLP.jl/tree/master/lib/MadNLPHSL), [MadNLPGPU](https://github.com/sshin23/MadNLP.jl/tree/master/lib/MadNLPGPU). -## Usage +## Usage ### Interfaces MadNLP is interfaced with modeling packages: - [JuMP](https://github.com/jump-dev/JuMP.jl) diff --git a/lib/MadNLPGPU/src/kernels.jl b/lib/MadNLPGPU/src/kernels.jl index 9a903ce4..da447d2d 100644 --- a/lib/MadNLPGPU/src/kernels.jl +++ b/lib/MadNLPGPU/src/kernels.jl @@ -69,7 +69,7 @@ end end end -function MadNLP.treat_fixed_variable!(kkt::MadNLP.AbstractKKTSystem{T, MT}) where {T, MT<:CuMatrix{T}} +function MadNLP.treat_fixed_variable!(kkt::MadNLP.AbstractKKTSystem{T, VT, MT}) where {T, VT, MT<:CuMatrix{T}} length(kkt.ind_fixed) == 0 && return aug = kkt.aug_com d_ind_fixed = kkt.ind_fixed |> CuVector # TODO: allocate ind_fixed directly on the GPU diff --git a/lib/MadNLPGraph/src/MadNLPGraph.jl b/lib/MadNLPGraph/src/MadNLPGraph.jl index bdc7f60a..8898b965 100644 --- a/lib/MadNLPGraph/src/MadNLPGraph.jl +++ b/lib/MadNLPGraph/src/MadNLPGraph.jl @@ -7,7 +7,7 @@ import MadNLP: eval_objective_gradient, eval_function, eval_constraint, eval_hessian_lagrangian, eval_constraint_jacobian, @kwdef, Logger, @debug, @warn, @error, @sprintf, AbstractOptions, AbstractLinearSolver, EmptyLinearSolver, set_options!, - SparseMatrixCSC, SubVector, StrideOneVector, + SparseMatrixCSC, SubVector, SymbolicException,FactorizationException,SolveException,InertiaException, introduce, factorize!, solve!, improve!, is_inertia, inertia, default_linear_solver, default_dense_solver, get_csc_view, get_cscsy_view, nnz, mul!, diff --git a/lib/MadNLPGraph/src/schur.jl b/lib/MadNLPGraph/src/schur.jl index 1c28f23c..9876f382 100644 --- a/lib/MadNLPGraph/src/schur.jl +++ b/lib/MadNLPGraph/src/schur.jl @@ -2,7 +2,7 @@ module MadNLPSchur import ..MadNLPGraph: @kwdef, Logger, @debug, @warn, @error, - AbstractOptions, AbstractLinearSolver, EmptyLinearSolver, set_options!, SparseMatrixCSC, SubVector, StrideOneVector, + AbstractOptions, AbstractLinearSolver, EmptyLinearSolver, set_options!, SparseMatrixCSC, SubVector, SymbolicException,FactorizationException,SolveException,InertiaException, introduce, factorize!, solve!, improve!, is_inertia, inertia, default_linear_solver, default_dense_solver, get_csc_view, get_cscsy_view, nnz, mul!, @@ -92,7 +92,7 @@ function SolverWorker(tsp,V_0,csc::SparseMatrixCSC{Float64},inds::Vector{Int},k, SubproblemSolverModule::Module,logger::Logger,option_dict::Dict{Symbol,Any}) V = findall(tsp.part.==k) - + csc_k,csc_k_view = get_cscsy_view(csc,V,inds=inds) compl,compl_view = get_csc_view(csc,V,V_0,inds=inds) V_0_nz = findnz(compl.colptr) diff --git a/lib/MadNLPGraph/src/schwarz.jl b/lib/MadNLPGraph/src/schwarz.jl index c4160fa8..e2d40ad4 100644 --- a/lib/MadNLPGraph/src/schwarz.jl +++ b/lib/MadNLPGraph/src/schwarz.jl @@ -2,7 +2,7 @@ module MadNLPSchwarz import ..MadNLPGraph: @kwdef, Logger, @debug, @warn, @error, - default_linear_solver,SparseMatrixCSC, SubVector, StrideOneVector, get_cscsy_view, nnz, + default_linear_solver,SparseMatrixCSC, SubVector, get_cscsy_view, nnz, SymbolicException,FactorizationException,SolveException,InertiaException, AbstractOptions, AbstractLinearSolver, set_options!, MonolevelPartition, MonolevelStruc, BilevelPartition, BilevelStruc, diff --git a/lib/MadNLPHSL/src/MadNLPHSL.jl b/lib/MadNLPHSL/src/MadNLPHSL.jl index 01bb797c..890fa855 100644 --- a/lib/MadNLPHSL/src/MadNLPHSL.jl +++ b/lib/MadNLPHSL/src/MadNLPHSL.jl @@ -2,10 +2,10 @@ module MadNLPHSL import Libdl: dlopen, RTLD_DEEPBIND import MadNLP: @kwdef, Logger, @debug, @warn, @error, - AbstractOptions, AbstractLinearSolver, set_options!, SparseMatrixCSC, SubVector, StrideOneVector, + AbstractOptions, AbstractLinearSolver, set_options!, SparseMatrixCSC, SubVector, SymbolicException,FactorizationException,SolveException,InertiaException, introduce, factorize!, solve!, improve!, is_inertia, inertia, findIJ, nnz, - get_tril_to_full, transfer!, input_type + get_tril_to_full, transfer!, input_type, _madnlp_unsafe_wrap include(joinpath("..","deps","deps.jl")) diff --git a/lib/MadNLPHSL/src/ma27.jl b/lib/MadNLPHSL/src/ma27.jl index f52231a9..418b98a2 100644 --- a/lib/MadNLPHSL/src/ma27.jl +++ b/lib/MadNLPHSL/src/ma27.jl @@ -1,6 +1,3 @@ -# MadNLP.jl -# Created by Sungho Shin (sungho.shin@wisc.edu) - const ma27_default_icntl = Int32[ 6,6,0,2139062143,1,32639,32639,32639,32639,14,9,8,8,9,10,32639,32639,32639,32689,24,11,9,8,9,10,0,0,0,0,0] const ma27_default_cntl = [.1,1.0,0.,0.,0.] @@ -24,7 +21,7 @@ mutable struct Ma27Solver <: AbstractLinearSolver info::Vector{Int32} a::Vector{Float64} - a_view::StrideOneVector{Float64} + a_view::Vector{Float64} la::Int32 ikeep::Vector{Int32} @@ -39,7 +36,7 @@ mutable struct Ma27Solver <: AbstractLinearSolver logger::Logger end -ma27ad!(n::Cint,nz::Cint,I::StrideOneVector{Cint},J::StrideOneVector{Cint}, +ma27ad!(n::Cint,nz::Cint,I::Vector{Cint},J::Vector{Cint}, iw::Vector{Cint},liw::Cint,ikeep::Vector{Cint},iw1::Vector{Cint}, nsteps::Vector{Cint},iflag::Cint,icntl::Vector{Cint},cntl::Vector{Cdouble}, info::Vector{Cint},ops::Cdouble) = ccall( @@ -51,8 +48,8 @@ ma27ad!(n::Cint,nz::Cint,I::StrideOneVector{Cint},J::StrideOneVector{Cint}, Ptr{Cint},Ref{Cdouble}), n,nz,I,J,iw,liw,ikeep,iw1,nsteps,iflag,icntl,cntl,info,ops) -ma27bd!(n::Cint,nz::Cint,I::StrideOneVector{Cint},J::StrideOneVector{Cint}, - a::StrideOneVector{Cdouble},la::Cint,iw::Vector{Cint},liw::Cint, +ma27bd!(n::Cint,nz::Cint,I::Vector{Cint},J::Vector{Cint}, + a::Vector{Cdouble},la::Cint,iw::Vector{Cint},liw::Cint, ikeep::Vector{Cint},nsteps::Vector{Cint},maxfrt::Vector{Cint},iw1::Vector{Cint}, icntl::Vector{Cint},cntl::Vector{Cdouble},info::Vector{Cint}) = ccall( (:ma27bd_,libhsl), @@ -101,7 +98,7 @@ function Ma27Solver(csc::SparseMatrixCSC; la = ceil(Int32,max(nz,opt.ma27_la_init_factor*info[5])) a = Vector{Float64}(undef,la) - a_view = view(a,1:nnz(csc)) + a_view = _madnlp_unsafe_wrap(a,nnz(csc)) liw= ceil(Int32,opt.ma27_liw_init_factor*info[6]) resize!(iw,liw) maxfrt=Int32[1] @@ -134,7 +131,7 @@ function factorize!(M::Ma27Solver) return M end -function solve!(M::Ma27Solver,rhs::StrideOneVector{Float64}) +function solve!(M::Ma27Solver,rhs::Vector{Float64}) length(M.w)