@@ -99,7 +99,8 @@ function MOI.is_empty(model::Optimizer)
99
99
#
100
100
isempty (model. multiplicative_parameters) &&
101
101
isempty (model. dual_value_of_parameters) &&
102
- model. number_of_parameters_in_model == 0
102
+ model. number_of_parameters_in_model == 0 &&
103
+ isempty (model. ext)
103
104
end
104
105
105
106
function MOI. empty! (model:: Optimizer{T} ) where {T}
@@ -133,6 +134,7 @@ function MOI.empty!(model::Optimizer{T}) where {T}
133
134
empty! (model. dual_value_of_parameters)
134
135
#
135
136
model. number_of_parameters_in_model = 0
137
+ empty! (model. ext)
136
138
return
137
139
end
138
140
@@ -1124,24 +1126,161 @@ end
1124
1126
# Special Attributes
1125
1127
#
1126
1128
1129
+ """
1130
+ ParametricObjectiveType <: MOI.AbstractModelAttribute
1131
+
1132
+ A model attribute for the type `P` of the ParametricOptInterface's parametric
1133
+ function type in the objective function. The value os `P` can be `Nothing` if
1134
+ the objective function is not parametric. The parametric function type can be
1135
+ queried using the [`ParametricObjectiveFunction{P}`](@ref) attribute. The type
1136
+ `P` can be `ParametricAffineFunction{T}` or `ParametricQuadraticFunction{T}`.
1137
+ """
1138
+ struct ParametricObjectiveType <: MOI.AbstractModelAttribute end
1139
+
1140
+ function MOI. get (model:: Optimizer{T} , :: ParametricObjectiveType ) where {T}
1141
+ if model. quadratic_objective_cache != = nothing
1142
+ return ParametricQuadraticFunction{T}
1143
+ elseif model. affine_objective_cache != = nothing
1144
+ return ParametricAffineFunction{T}
1145
+ end
1146
+ return Nothing
1147
+ end
1148
+
1149
+ """
1150
+ ParametricObjectiveFunction{P} <: MOI.AbstractModelAttribute
1151
+
1152
+ A model attribute for the parametric objective function of type `P`. The type
1153
+ `P` can be `ParametricAffineFunction{T}` or `ParametricQuadraticFunction{T}`.
1154
+ """
1155
+ struct ParametricObjectiveFunction{T} <: MOI.AbstractModelAttribute end
1156
+
1157
+ function MOI. get (
1158
+ model:: Optimizer{T} ,
1159
+ :: ParametricObjectiveFunction{ParametricQuadraticFunction{T}} ,
1160
+ ) where {T}
1161
+ if model. quadratic_objective_cache === nothing
1162
+ error ("
1163
+ There is no parametric quadratic objective function in the model.
1164
+ " )
1165
+ end
1166
+ return model. quadratic_objective_cache
1167
+ end
1168
+
1169
+ function MOI. get (
1170
+ model:: Optimizer{T} ,
1171
+ :: ParametricObjectiveFunction{ParametricAffineFunction{T}} ,
1172
+ ) where {T}
1173
+ if model. affine_objective_cache === nothing
1174
+ error ("
1175
+ There is no parametric affine objective function in the model.
1176
+ " )
1177
+ end
1178
+ return model. affine_objective_cache
1179
+ end
1180
+
1181
+ """
1182
+ ListOfParametricConstraintTypesPresent()
1183
+
1184
+ A model attribute for the list of tuples of the form `(F,S,P)`, where `F` is a
1185
+ MOI function type, `S` is a set type and `P` is a ParametricOptInterface
1186
+ parametric function type indicating that the attribute
1187
+ [`DictOfParametricConstraintIndicesAndFunctions{F,S,P}`](@ref) returns a
1188
+ non-empty dictionary.
1189
+ """
1190
+ struct ListOfParametricConstraintTypesPresent <: MOI.AbstractModelAttribute end
1191
+
1192
+ function MOI. get (
1193
+ model:: Optimizer{T} ,
1194
+ :: ListOfParametricConstraintTypesPresent ,
1195
+ ) where {T}
1196
+ output = Set {Tuple{DataType,DataType,DataType}} ()
1197
+ for (F, S) in MOI. Utilities. DoubleDicts. nonempty_outer_keys (
1198
+ model. affine_constraint_cache,
1199
+ )
1200
+ push! (output, (F, S, ParametricAffineFunction{T}))
1201
+ end
1202
+ for (F, S) in MOI. Utilities. DoubleDicts. nonempty_outer_keys (
1203
+ model. vector_affine_constraint_cache,
1204
+ )
1205
+ push! (output, (F, S, ParametricVectorAffineFunction{T}))
1206
+ end
1207
+ for (F, S) in MOI. Utilities. DoubleDicts. nonempty_outer_keys (
1208
+ model. quadratic_constraint_cache,
1209
+ )
1210
+ push! (output, (F, S, ParametricQuadraticFunction{T}))
1211
+ end
1212
+ return collect (output)
1213
+ end
1214
+
1215
+ """
1216
+ DictOfParametricConstraintIndicesAndFunctions{F,S,P}
1217
+
1218
+ A model attribute for a dictionary mapping constraint indices to parametric
1219
+ functions. The key is a constraint index with scalar function type `F`
1220
+ and set type `S` and the value is a parametric function of type `P`.
1221
+ """
1222
+ struct DictOfParametricConstraintIndicesAndFunctions{F,S,P} < :
1223
+ MOI. AbstractModelAttribute end
1224
+
1225
+ function MOI. get (
1226
+ model:: Optimizer ,
1227
+ :: DictOfParametricConstraintIndicesAndFunctions{F,S,P} ,
1228
+ ) where {F,S,P<: ParametricAffineFunction }
1229
+ return model. affine_constraint_cache[F, S]
1230
+ end
1231
+
1232
+ function MOI. get (
1233
+ model:: Optimizer ,
1234
+ :: DictOfParametricConstraintIndicesAndFunctions{F,S,P} ,
1235
+ ) where {F,S,P<: ParametricVectorAffineFunction }
1236
+ return model. vector_affine_constraint_cache[F, S]
1237
+ end
1238
+
1239
+ function MOI. get (
1240
+ model:: Optimizer ,
1241
+ :: DictOfParametricConstraintIndicesAndFunctions{F,S,P} ,
1242
+ ) where {F,S,P<: ParametricQuadraticFunction }
1243
+ return model. quadratic_constraint_cache[F, S]
1244
+ end
1245
+
1246
+ """
1247
+ NumberOfPureVariables
1248
+
1249
+ A model attribute for the number of pure variables in the model.
1250
+ """
1127
1251
struct NumberOfPureVariables <: MOI.AbstractModelAttribute end
1128
1252
1129
1253
function MOI. get (model:: Optimizer , :: NumberOfPureVariables )
1130
1254
return length (model. variables)
1131
1255
end
1132
1256
1257
+ """
1258
+ ListOfPureVariableIndices
1259
+
1260
+ A model attribute for the list of pure variable indices in the model.
1261
+ """
1133
1262
struct ListOfPureVariableIndices <: MOI.AbstractModelAttribute end
1134
1263
1135
1264
function MOI. get (model:: Optimizer , :: ListOfPureVariableIndices )
1136
1265
return collect (keys (model. variables)):: Vector{MOI.VariableIndex}
1137
1266
end
1138
1267
1268
+ """
1269
+ NumberOfParameters
1270
+
1271
+ A model attribute for the number of parameters in the model.
1272
+ """
1139
1273
struct NumberOfParameters <: MOI.AbstractModelAttribute end
1140
1274
1141
1275
function MOI. get (model:: Optimizer , :: NumberOfParameters )
1142
1276
return length (model. parameters)
1143
1277
end
1144
1278
1279
+ """
1280
+ ListOfParameterIndices
1281
+
1282
+ A model attribute for the list of parameter indices in the model.
1283
+ """
1145
1284
struct ListOfParameterIndices <: MOI.AbstractModelAttribute end
1146
1285
1147
1286
function MOI. get (model:: Optimizer , :: ListOfParameterIndices )
0 commit comments