-
Notifications
You must be signed in to change notification settings - Fork 87
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
Implement DoubleDicts #1126
Implement DoubleDicts #1126
Conversation
# Conflicts: # src/Utilities/copy.jl # test/Utilities/copy.jl
src/Utilities/DoubleDicts.jl
Outdated
const MOI = MathOptInterface | ||
const CI{F,S} = MOI.ConstraintIndex{F,S} | ||
|
||
abstract type AbstractDoubleDict{V, D<:AbstractDict{Int64, V}, D2<:AbstractDict{Tuple{DataType, DataType}, D}} end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it an AbstractDict
? I would maybe do AbstractDoubleDict{K, V, ...}
<: AbstractDict{K, V}
.
For D
, I would just do D <: AbstractDict{Int64}
. Indeed, for instance, you might want DoubleDict
to contain F
. In this case you have D = AbstractDict{Int64, F}
so the type of the dict is different for each (F, S)
. If you impose it to be Dict{Int64, MO.AbstractFunction}
then this will convert the inner type-stable dicts to type unstable dicts Dict{Int64, MO.AbstractFunction}
. This is the case for UniversalFallback for instance which stores functions, sets pairs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it can be an AbstractDict
, if we add the key type K
to the parameters it will always be not concrete because the are CI{F,S}
for multiple F,S
pairs. By not typing the key type at all we have a special structure that can dispatch properly and well typed for those "unstable" keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the second part,
We might do that as a third DoubleDict
type, could be KeyDependentDoubleDict
, so we can have the inner dict values type depending on the keys.
The upper dict will not be type-stable for this third type, however, the lower dict could be type stable, which indeed might be more important for performance.
and make double dict a subtype of abstract dict
@blegat now there is a FunctionSetDoubleDict that can be used in universallfallback. |
Improve performance of IndexMap for constraints.
Open for name suggestions.