@@ -116,10 +116,18 @@ function MOI.add_constraint(
116
116
end
117
117
118
118
function MOI. supports_constraint (
119
- :: Optimizer{T} ,
120
- :: Type{MOI.ScalarNonlinearFunction} ,
121
- :: Type{<:Union{MOI.EqualTo{T},MOI.GreaterThan{T},MOI.LessThan{T}}} ,
122
- ) where {T}
119
+ :: Optimizer ,
120
+ :: Type{MOI.VectorNonlinearFunction} ,
121
+ :: Type{<:MOI.AbstractVectorSet} ,
122
+ )
123
+ # This can cause false positives because:
124
+ # 1) some sets might not be supported by Convex.jl (e.g., `vexity` might
125
+ # be missing)
126
+ # 2) whether we support the constraint can depend on the vexity of the
127
+ # function, which we currently don't know.
128
+ # Rather than attempt an enumeration of supported sets here, let's just
129
+ # pass things on and hope that there is a nice error message elsewhere in
130
+ # the callchain.
123
131
return true
124
132
end
125
133
@@ -189,28 +197,20 @@ function _expr(model::Optimizer, f::MOI.ScalarNonlinearFunction)
189
197
return throw (MOI. UnsupportedNonlinearOperator (f. head))
190
198
end
191
199
192
- function MOI. get (:: Optimizer , :: MOI.ListOfSupportedNonlinearOperators )
193
- return Symbol[:+ , :- , :* , :/ , :^ , :min , :max , :abs , :sqrt , :exp , :log ]
194
- end
195
-
196
- function _constraint (expr:: AbstractExpr , set:: MOI.EqualTo )
197
- return expr == MOI. constant (set)
200
+ function _expr (model:: Optimizer , f:: MOI.VectorNonlinearFunction )
201
+ return vcat (_expr .(model, f. rows)... )
198
202
end
199
203
200
- function _constraint (expr:: AbstractExpr , set:: MOI.LessThan )
201
- return expr <= MOI. constant (set)
202
- end
203
-
204
- function _constraint (expr:: AbstractExpr , set:: MOI.GreaterThan )
205
- return expr >= MOI. constant (set)
204
+ function MOI. get (:: Optimizer , :: MOI.ListOfSupportedNonlinearOperators )
205
+ return Symbol[:+ , :- , :* , :/ , :^ , :min , :max , :abs , :sqrt , :exp , :log ]
206
206
end
207
207
208
208
function MOI. add_constraint (
209
209
model:: Optimizer{T} ,
210
- func:: MOI.ScalarNonlinearFunction ,
211
- set:: MOI.AbstractScalarSet ,
210
+ func:: MOI.VectorNonlinearFunction ,
211
+ set:: MOI.AbstractVectorSet ,
212
212
) where {T}
213
- constraint = _constraint (_expr (model, func), set)
213
+ constraint = Constraint (_expr (model, func), set)
214
214
add_constraint! (model. context, constraint)
215
215
push! (model. constraint_map, model. context. constr_to_moi_inds[constraint])
216
216
return MOI. ConstraintIndex {typeof(func),typeof(set)} (
317
317
function MOI. get (
318
318
model:: Optimizer ,
319
319
attr:: Union{MOI.ConstraintDual,MOI.ConstraintPrimal} ,
320
- ci:: MOI.ConstraintIndex{MOI.ScalarNonlinearFunction,S} ,
321
- ) where {S<: MOI.AbstractScalarSet }
322
- ret = MOI. get (model. context. model, attr, model. constraint_map[ci. value])
323
- return ret[]
320
+ ci:: MOI.ConstraintIndex{MOI.VectorNonlinearFunction,S} ,
321
+ ) where {S<: MOI.AbstractVectorSet }
322
+ return MOI. get (model. context. model, attr, model. constraint_map[ci. value])
324
323
end
325
324
326
325
function MOI. get (model:: Optimizer , I:: Type{<:MOI.Index} , name:: String )
0 commit comments