@@ -12,27 +12,16 @@ function MathOptAnalyzer.analyze(
1212 dual_objective:: Union{Nothing,Float64} = nothing ,
1313 atol:: Float64 = 1e-6 ,
1414 skip_missing:: Bool = false ,
15- dual_check = true ,
15+ dual_check:: Bool = _can_dualize (model) ,
1616)
17- can_dualize = false
18- if dual_check
19- can_dualize = _can_dualize (model)
20- if ! can_dualize
21- println (
22- " The model cannot be dualized. Automatically setting `dual_check = false`." ,
23- )
24- dual_check = false
25- end
26- end
27-
28- data = Data (
29- primal_point = primal_point,
30- dual_point = dual_point,
31- primal_objective = primal_objective,
32- dual_objective = dual_objective,
33- atol = atol,
34- skip_missing = skip_missing,
35- dual_check = dual_check,
17+ data = Data (;
18+ primal_point,
19+ dual_point,
20+ primal_objective,
21+ dual_objective,
22+ atol,
23+ skip_missing,
24+ dual_check,
3625 )
3726
3827 if data. primal_point === nothing
@@ -423,24 +412,14 @@ function _last_dual_solution(model::MOI.ModelLike)
423412end
424413
425414function _can_dualize (model:: MOI.ModelLike )
426- types = MOI. get (model, MOI. ListOfConstraintTypesPresent ())
427-
428- for (F, S) in types
415+ for (F, S) in MOI. get (model, MOI. ListOfConstraintTypesPresent ())
429416 if ! Dualization. supported_constraint (F, S)
430417 return false
431418 end
432419 end
433-
434420 F = MOI. get (model, MOI. ObjectiveFunctionType ())
435-
436421 if ! Dualization. supported_objective (F)
437422 return false
438423 end
439-
440- sense = MOI. get (model, MOI. ObjectiveSense ())
441- if sense == MOI. FEASIBILITY_SENSE
442- return false
443- end
444-
445- return true
424+ return MOI. get (model, MOI. ObjectiveSense ()) != MOI. FEASIBILITY_SENSE
446425end
0 commit comments