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

Pass option prod to ExaModel when instantiating from JuMP #97

Merged
merged 3 commits into from
Nov 6, 2024
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
4 changes: 2 additions & 2 deletions ext/ExaModelsJuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module ExaModelsJuMP
import ExaModels
import JuMP

function ExaModels.ExaModel(jm::JuMP.GenericModel{T}; backend = nothing) where {T}
return ExaModels.ExaModel(jm.moi_backend.model_cache; backend = backend)
function ExaModels.ExaModel(jm::JuMP.GenericModel{T}; options...) where {T}
return ExaModels.ExaModel(jm.moi_backend.model_cache; options...)
end

end # module ExaModelsJuMP
15 changes: 3 additions & 12 deletions ext/ExaModelsKernelAbstractions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -335,17 +335,6 @@ function ExaModels.jtprod_nln!(
) where {T,VT,E<:KAExtension{T,VT,Nothing}}
error("Prodhelper is not defined. Use ExaModels(c; prod=true) to use jtprod_nln!")
end
function ExaModels.hprod!(
m::ExaModels.ExaModel{T,VT,E},
x::AbstractVector,
y::AbstractVector,
v::AbstractVector,
Hv::AbstractVector;
obj_weight = one(eltype(x)),
) where {T,VT,E<:KAExtension{T,VT,Nothing}}
error("Prodhelper is not defined. Use ExaModels(c; prod=true) to use hprod!")
end

function ExaModels.jprod_nln!(
m::ExaModels.ExaModel{T,VT,E},
x::AbstractVector,
Expand Down Expand Up @@ -396,7 +385,9 @@ function ExaModels.hprod!(
Hv::AbstractVector;
obj_weight = one(eltype(x)),
) where {T,VT,E<:KAExtension}

if isnothing(m.ext.prodhelper)
error("Prodhelper is not defined. Use ExaModels(c; prod=true) to use hprod!")
end
fill!(Hv, zero(eltype(Hv)))
fill!(m.ext.prodhelper.hessbuffer, zero(eltype(Hv)))

Expand Down
4 changes: 2 additions & 2 deletions ext/ExaModelsMOI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end

float_type(::MOIU.Model{T}) where {T} = T

function ExaModels.ExaModel(jm_cache::MOI.ModelLike; backend = nothing)
function ExaModels.ExaModel(jm_cache::MOI.ModelLike; backend = nothing, prod=false)

T = float_type(jm_cache.model)
minimize = jm_cache.model.objective.sense == MOI.MIN_SENSE
Expand Down Expand Up @@ -116,7 +116,7 @@ function ExaModels.ExaModel(jm_cache::MOI.ModelLike; backend = nothing)
cons = ExaModels.constraint(c, offset; start = y0, lcon = lcon, ucon = ucon)
build_constraint!(c, cons, bin)

return ExaModels.ExaModel(c)
return ExaModels.ExaModel(c; prod=prod)
end

function exafy_con(cons::Nothing, bin, offset, lcon, ucon)
Expand Down
Loading