Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 11 additions & 32 deletions src/Feasibility/analyze.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,16 @@ function MathOptAnalyzer.analyze(
dual_objective::Union{Nothing,Float64} = nothing,
atol::Float64 = 1e-6,
skip_missing::Bool = false,
dual_check = true,
dual_check::Bool = _can_dualize(model),
)
can_dualize = false
if dual_check
can_dualize = _can_dualize(model)
if !can_dualize
println(
"The model cannot be dualized. Automatically setting `dual_check = false`.",
)
dual_check = false
end
end

data = Data(
primal_point = primal_point,
dual_point = dual_point,
primal_objective = primal_objective,
dual_objective = dual_objective,
atol = atol,
skip_missing = skip_missing,
dual_check = dual_check,
data = Data(;
primal_point,
dual_point,
primal_objective,
dual_objective,
atol,
skip_missing,
dual_check,
)

if data.primal_point === nothing
Expand Down Expand Up @@ -423,24 +412,14 @@ function _last_dual_solution(model::MOI.ModelLike)
end

function _can_dualize(model::MOI.ModelLike)
types = MOI.get(model, MOI.ListOfConstraintTypesPresent())

for (F, S) in types
for (F, S) in MOI.get(model, MOI.ListOfConstraintTypesPresent())
if !Dualization.supported_constraint(F, S)
return false
end
end

F = MOI.get(model, MOI.ObjectiveFunctionType())

if !Dualization.supported_objective(F)
return false
end

sense = MOI.get(model, MOI.ObjectiveSense())
if sense == MOI.FEASIBILITY_SENSE
return false
end

return true
return MOI.get(model, MOI.ObjectiveSense()) != MOI.FEASIBILITY_SENSE
end
8 changes: 4 additions & 4 deletions src/Feasibility/structs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ julia> data = MathOptAnalyzer.analyze(
dual_objective::Union{Nothing, Float64} = nothing,
atol::Float64 = 1e-6,
skip_missing::Bool = false,
dual_check = true,
dual_check::Bool = true,
);
```

Expand All @@ -39,9 +39,9 @@ The additional parameters:
- `atol`: The absolute tolerance for feasibility checking.
- `skip_missing`: If `true`, constraints with missing variables in the provided
point will be ignored.
- `dual_check`: If `true`, it will perform dual feasibility checking. Disabling
the dual check will also disable complementarity checking and dual objective
checks.
- `dual_check`: If `true`, it will perform dual feasibility checking if the
model is compatible with Dualization.jl. Disabling the dual check will also
disable complementarity checking and dual objective checks.
"""
struct Analyzer <: MathOptAnalyzer.AbstractAnalyzer end

Expand Down
1 change: 0 additions & 1 deletion test/test_Numerical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,6 @@ function test_dyn_range_objective()
data,
MathOptAnalyzer.Numerical.LargeDynamicRangeObjective,
)
@show ret
@test length(ret) == 1
@test MathOptAnalyzer.variables(ret[], model) == [x, y]
@test MathOptAnalyzer.values(ret[]) == [1e-4, 7e4]
Expand Down
Loading