Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't call jac_structure if problem has no constraints #66

Closed
wants to merge 1 commit into from
Closed
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
26 changes: 12 additions & 14 deletions src/KnitroSolverInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type KnitroMathProgModel <: AbstractNonlinearModel
function KnitroMathProgModel(;options...)
new(options)
end
end
end

NonlinearModel(s::KnitroSolver) = KnitroMathProgModel(;s.options...)
LinearQuadraticModel(s::KnitroSolver) = NonlinearToLPQPBridge(NonlinearModel(s))
Expand Down Expand Up @@ -76,16 +76,14 @@ function loadproblem!(m::KnitroMathProgModel,
d::AbstractNLPEvaluator)
features = features_available(d)
has_hessian = (:Hess in features)
if has_hessian
initialize(d, [:Grad, :Jac, :Hess])
Ihess, Jhess = hesslag_structure(d)
else
initialize(d, [:Grad, :Jac])
Ihess = Int[]
Jhess = Int[]
end

Ijac, Jjac = jac_structure(d)
init_feat = [:Grad]
has_hessian && push!(init_feat, :Hess)
numConstr > 0 && push!(init_feat, :Jac)
initialize(d, init_feat)

Ihess, Jhess = has_hessian ? hesslag_structure(d) : (Int[], Int[])
Ijac, Jjac = numConstr > 0 && jac_structure(d) : (Int[], Int[])
Copy link
Contributor

Choose a reason for hiding this comment

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

&& should be ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree


m.nnzJ = length(Ijac)
m.nnzH = length(Ihess)
jac_tmp = Array(Float64, m.nnzJ)
Expand Down Expand Up @@ -207,9 +205,9 @@ function loadproblem!(m::KnitroMathProgModel,
end
end
end
# check and define default hessian option
if (!has_hessian && !defined_hessopt) || (!has_hessian && !in(hessopt_value,2:6))

# check and define default hessian option
if (!has_hessian && !defined_hessopt) || (!has_hessian && !in(hessopt_value,2:6))
setOption(m.inner,paramName2Indx["KTR_PARAM_HESSOPT"],6)
end

Expand Down