Skip to content

Commit

Permalink
Merge pull request #6 from JuliaNonconvex/bump-NonconvexCore
Browse files Browse the repository at this point in the history
Bump NonconvexCore
  • Loading branch information
mohamed82008 authored Jan 20, 2022
2 parents 50946b3 + 91e1882 commit 3fac365
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NonconvexIpopt"
uuid = "bf347577-a06d-49ad-a669-8c0e005493b8"
authors = ["Mohamed Tarek <[email protected]> and contributors"]
version = "0.1.2"
version = "0.1.3"

[deps]
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
Expand All @@ -13,8 +13,8 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[compat]
Ipopt = "0.6, 0.7"
NonconvexCore = "0.1.3"
Ipopt = "0.9"
NonconvexCore = "1.0.0"
Parameters = "0.12"
Reexport = "1"
Zygote = "0.6"
Expand Down
23 changes: 16 additions & 7 deletions src/ipopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,23 @@ function optimize!(workspace::IpoptWorkspace)
counter[] = 0
foreach(keys(options.nt)) do k
v = options.nt[k]
Ipopt.addOption(problem, string(k), v)
addOption(problem, string(k), v)
end
solvestat = Ipopt.solveProblem(problem)
solvestat = Ipopt.IpoptSolve(problem)
return IpoptResult(
copy(problem.x), getobjective(model)(problem.x),
problem, solvestat, counter[]
)
end
function addOption(prob, name, val::Int)
return Ipopt.AddIpoptIntOption(prob, name, val)
end
function addOption(prob, name, val::String)
return Ipopt.AddIpoptStrOption(prob, name, val)
end
function addOption(prob, name, val)
return Ipopt.AddIpoptNumOption(prob, name, val)
end

struct IpoptAlg <: AbstractOptimizer end

Expand Down Expand Up @@ -130,8 +139,8 @@ function get_ipopt_problem(obj, ineq_constr, eq_constr, x0, xlb, xub, first_orde
grad_f .= grad
end
end
function eval_jac_g(x::Vector{Float64}, mode, rows::Vector{Int32}, cols::Vector{Int32}, values::Vector{Float64})
if mode == :Structure
function eval_jac_g(x::Vector{Float64}, rows::Vector{Int32}, cols::Vector{Int32}, values::Union{Nothing, Vector{Float64}})
if values === nothing
ineqJ0 === nothing || fill_indices!(rows, cols, ineqJ0)
eqJ0 === nothing || fill_indices!(rows, cols, eqJ0, offset = Joffset, row_offset = ineq_nconstr)
else
Expand All @@ -157,8 +166,8 @@ function get_ipopt_problem(obj, ineq_constr, eq_constr, x0, xlb, xub, first_orde
x0,
),
)
eval_h = function (x::Vector{Float64}, mode, rows::Vector{Int32}, cols::Vector{Int32}, obj_factor::Float64, lambda::Vector{Float64}, values::Vector{Float64})
if mode == :Structure
eval_h = function (x::Vector{Float64}, rows::Vector{Int32}, cols::Vector{Int32}, obj_factor::Float64, lambda::Vector{Float64}, values::Union{Nothing, Vector{Float64}})
if values === nothing
fill_indices!(rows, cols, HL0)
else
HL = LowerTriangular(
Expand All @@ -177,7 +186,7 @@ function get_ipopt_problem(obj, ineq_constr, eq_constr, x0, xlb, xub, first_orde
return Inf
end
end
prob = Ipopt.createProblem(
prob = Ipopt.CreateIpoptProblem(
nvars, xlb, xub, ineq_nconstr + eq_nconstr, clb, cub,
nvalues(ineqJ0) + nvalues(eqJ0), Hnvalues, _obj,
eval_g, eval_grad_f, eval_jac_g, eval_h,
Expand Down

2 comments on commit 3fac365

@mohamed82008
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/52881

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.3 -m "<description of version>" 3fac365c2e6c584d2de4a1d6ebca2b77de6d9a90
git push origin v0.1.3

Please sign in to comment.