Skip to content

Commit

Permalink
Update cachingoptimizer.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Dec 21, 2023
1 parent b32ea60 commit 2259350
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/Utilities/cachingoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -927,15 +927,14 @@ function MOI.get(
end
_throw_if_get_attribute_not_allowed(model, attr; needs_optimizer_map = true)
if _has_fallback(attr, typeof(index))
return _caching_get_fallback(model, attr, index)
else
value = MOI.get(
model.optimizer,
attr,
model.model_to_optimizer_map[index],
)::MOI.attribute_value_type(attr)
return map_indices(model.optimizer_to_model_map, attr, value)
return _get_fallback(model, attr, index)

Check warning on line 930 in src/Utilities/cachingoptimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/cachingoptimizer.jl#L930

Added line #L930 was not covered by tests
end
value = MOI.get(
model.optimizer,
attr,
model.model_to_optimizer_map[index],
)::MOI.attribute_value_type(attr)
return map_indices(model.optimizer_to_model_map, attr, value)
end

function MOI.get(
Expand All @@ -948,15 +947,14 @@ function MOI.get(
end
_throw_if_get_attribute_not_allowed(model, attr; needs_optimizer_map = true)
if _has_fallback(attr, I)
return _caching_get_fallback(model, attr, indices)
else
value = MOI.get(
model.optimizer,
attr,
map(Base.Fix1(getindex, model.model_to_optimizer_map), indices),
)::Vector{<:MOI.attribute_value_type(attr)}
return map_indices(model.optimizer_to_model_map, attr, value)
return _get_fallback(model, attr, indices)

Check warning on line 950 in src/Utilities/cachingoptimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/cachingoptimizer.jl#L949-L950

Added lines #L949 - L950 were not covered by tests
end
value = MOI.get(
model.optimizer,
attr,
map(Base.Fix1(getindex, model.model_to_optimizer_map), indices),
)::Vector{<:MOI.attribute_value_type(attr)}
return map_indices(model.optimizer_to_model_map, attr, value)
end

###
Expand All @@ -970,14 +968,15 @@ end
# also be computed from the `ConstraintDual` of the other constraints.

_has_fallback(::MOI.ConstraintPrimal, ::Type{<:MOI.ConstraintIndex}) = true

Check warning on line 970 in src/Utilities/cachingoptimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/cachingoptimizer.jl#L970

Added line #L970 was not covered by tests

function _has_fallback(

Check warning on line 972 in src/Utilities/cachingoptimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/cachingoptimizer.jl#L972

Added line #L972 was not covered by tests
::MOI.ConstraintDual,
::Type{<:MOI.ConstraintIndex{F}},
) where {F<:Union{MOI.VariableIndex,MOI.VectorOfVariables}}
return true

Check warning on line 976 in src/Utilities/cachingoptimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/cachingoptimizer.jl#L976

Added line #L976 was not covered by tests
end

function _caching_get_fallback(
function _get_fallback(

Check warning on line 979 in src/Utilities/cachingoptimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/cachingoptimizer.jl#L979

Added line #L979 was not covered by tests
model::CachingOptimizer,
attr::MOI.AbstractConstraintAttribute,
index::MOI.ConstraintIndex,
Expand All @@ -997,7 +996,7 @@ function _caching_get_fallback(
end
end

function _caching_get_fallback(
function _get_fallback(

Check warning on line 999 in src/Utilities/cachingoptimizer.jl

View check run for this annotation

Codecov / codecov/patch

src/Utilities/cachingoptimizer.jl#L999

Added line #L999 was not covered by tests
model::CachingOptimizer,
attr::MOI.AbstractConstraintAttribute,
indices::Vector{<:MOI.ConstraintIndex},
Expand Down

0 comments on commit 2259350

Please sign in to comment.