|
1 | | - |
| 1 | +const VI = MOI.VariableIndex |
2 | 2 |
|
3 | 3 | struct HS071 <: MOI.AbstractNLPEvaluator |
4 | 4 | enable_hessian::Bool |
|
24 | 24 |
|
25 | 25 | function MOI.features_available(d::HS071) |
26 | 26 | if d.enable_hessian |
27 | | - return [:Grad, :Jac, :Hess] |
| 27 | + return [:Grad, :Jac, :Hess, :ExprGraph] |
| 28 | + else |
| 29 | + return [:Grad, :Jac, :ExprGraph] |
| 30 | + end |
| 31 | +end |
| 32 | + |
| 33 | +MOI.objective_expr(d::HS071) = :(x[$(VI(1))] * x[$(VI(4))] * (x[$(VI(1))] + |
| 34 | + x[$(VI(2))] + x[$(VI(3))]) + x[$(VI(3))]) |
| 35 | + |
| 36 | +function MOI.constraint_expr(d::HS071, i::Int) |
| 37 | + if i == 1 |
| 38 | + return :(x[$(VI(1))] * x[$(VI(2))] * x[$(VI(3))] * x[$(VI(4))] >= 25.0) |
| 39 | + elseif i == 2 |
| 40 | + return :(x[$(VI(1))]^2 + x[$(VI(2))]^2 + |
| 41 | + x[$(VI(3))]^2 + x[$(VI(4))]^2 == 40.0) |
28 | 42 | else |
29 | | - return [:Grad, :Jac] |
| 43 | + error("Out of bounds constraint.") |
30 | 44 | end |
31 | 45 | end |
32 | 46 |
|
|
178 | 192 |
|
179 | 193 | function MOI.features_available(d::FeasibilitySenseEvaluator) |
180 | 194 | if d.enable_hessian |
181 | | - return [:Grad, :Jac, :Hess] |
| 195 | + return [:Grad, :Jac, :Hess, :ExprGraph] |
| 196 | + else |
| 197 | + return [:Grad, :Jac, :ExprGraph] |
| 198 | + end |
| 199 | +end |
| 200 | + |
| 201 | +MOI.objective_expr(d::FeasibilitySenseEvaluator) = :() |
| 202 | + |
| 203 | +function MOI.constraint_expr(d::FeasibilitySenseEvaluator, i::Int) |
| 204 | + if i == 1 |
| 205 | + return :(x[$(VI(1))]^2 == 1) |
182 | 206 | else |
183 | | - return [:Grad, :Jac] |
| 207 | + error("Out of bounds constraint.") |
184 | 208 | end |
185 | 209 | end |
186 | 210 |
|
@@ -253,7 +277,7 @@ function feasibility_sense_test_template(model::MOI.ModelLike, |
253 | 277 |
|
254 | 278 | @test MOI.get(model, MOI.ObjectiveValue()) ≈ 0.0 atol=atol rtol=rtol |
255 | 279 |
|
256 | | - @test MOI.get(model, MOI.VariablePrimal(), x) ≈ 1.0 atol=atol rtol=rtol |
| 280 | + @test abs(MOI.get(model, MOI.VariablePrimal(), x)) ≈ 1.0 atol=atol rtol=rtol |
257 | 281 | end |
258 | 282 | end |
259 | 283 |
|
|
0 commit comments