@@ -108,6 +108,29 @@ function _dual_objective_value(
108
108
return set_dot (constant, dual, set)
109
109
end
110
110
111
+ function _dual_objective_value (
112
+ model:: MOI.ModelLike ,
113
+ ci:: MOI.ConstraintIndex{<:MOI.AbstractVectorFunction,<:MOI.HyperRectangle} ,
114
+ :: Type{T} ,
115
+ result_index:: Integer ,
116
+ ) where {T}
117
+ func_constant =
118
+ MOI. constant (MOI. get (model, MOI. ConstraintFunction (), ci), T)
119
+ set = MOI. get (model, MOI. ConstraintSet (), ci)
120
+ dual = MOI. get (model, MOI. ConstraintDual (result_index), ci)
121
+ constant = map (eachindex (func_constant)) do i
122
+ return func_constant[i] - if dual[i] < zero (dual[i])
123
+ # The dual is negative so it is in the dual of the MOI.LessThan cone
124
+ # hence the upper bound of the Interval set is tight
125
+ set. upper[i]
126
+ else
127
+ # the lower bound is tight
128
+ set. lower[i]
129
+ end
130
+ end
131
+ return set_dot (constant, dual, set)
132
+ end
133
+
111
134
function _dual_objective_value (
112
135
model:: MOI.ModelLike ,
113
136
:: Type{F} ,
@@ -116,23 +139,18 @@ function _dual_objective_value(
116
139
result_index:: Integer ,
117
140
) where {T,F<: MOI.AbstractFunction ,S<: MOI.AbstractSet }
118
141
value = zero (T)
142
+ if F == variable_function_type (S) && ! _has_constant (S)
143
+ return value # Shortcut
144
+ end
119
145
for ci in MOI. get (model, MOI. ListOfConstraintIndices {F,S} ())
120
146
value += _dual_objective_value (model, ci, T, result_index)
121
147
end
122
148
return value
123
149
end
124
150
125
- function _dual_objective_value (
126
- :: MOI.ModelLike ,
127
- :: Type{MOI.VectorOfVariables} ,
128
- :: Type{<:MOI.AbstractVectorSet} ,
129
- :: Type{T} ,
130
- :: Integer ,
131
- ) where {T}
132
- # No constant in the function nor set so no contribution to the dual
133
- # objective value.
134
- return zero (T)
135
- end
151
+ _has_constant (:: Type{<:MOI.AbstractScalarSet} ) = true
152
+ _has_constant (:: Type{<:MOI.AbstractVectorSet} ) = false
153
+ _has_constant (:: Type{<:MOI.HyperRectangle} ) = true
136
154
137
155
"""
138
156
get_fallback(
0 commit comments