diff --git a/Project.toml b/Project.toml index 46d6f91..3cfcd32 100644 --- a/Project.toml +++ b/Project.toml @@ -1,4 +1,4 @@ -name = "ModelAnalyzer" +name = "MathOptAnalyzer" uuid = "d1179b25-476b-425c-b826-c7787f0fff83" version = "0.1.0" @@ -12,7 +12,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" JuMP = "4076af6c-e467-56ae-b986-b466b2749572" [extensions] -ModelAnalyzerJuMPExt = "JuMP" +MathOptAnalyzerJuMPExt = "JuMP" [compat] Dualization = "0.6.0" diff --git a/README.md b/README.md index cff924c..62b818c 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,32 @@ -# ModelAnalyzer.jl +# MathOptAnalyzer.jl -[![Build Status](https://github.com/jump-dev/ModelAnalyzer.jl/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/jump-dev/ModelAnalyzer.jl/actions?query=workflow%3ACI) -[![codecov](https://codecov.io/gh/jump-dev/ModelAnalyzer.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/jump-dev/ModelAnalyzer.jl) +[![Build Status](https://github.com/jump-dev/MathOptAnalyzer.jl/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/jump-dev/MathOptAnalyzer.jl/actions?query=workflow%3ACI) +[![codecov](https://codecov.io/gh/jump-dev/MathOptAnalyzer.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/jump-dev/MathOptAnalyzer.jl) -[ModelAnalyzer.jl](https://github.com/jump-dev/ModelAnalyzer.jl) is an +[MathOptAnalyzer.jl](https://github.com/jump-dev/MathOptAnalyzer.jl) is an experimental package with analysis and debugging tools for JuMP and MathOptInterface. ## License -`ModelAnalyzer.jl` is licensed under the [MIT License](https://github.com/jump-dev/MultiObjectiveAlgorithms.jl/blob/main/LICENSE.md). +`MathOptAnalyzer.jl` is licensed under the [MIT License](https://github.com/jump-dev/MultiObjectiveAlgorithms.jl/blob/main/LICENSE.md). ## Getting help If you need help, please ask a question on the [JuMP community forum](https://jump.dev/forum). -If you have a reproducible example of a bug, please [open a GitHub issue](https://github.com/jump-dev/ModelAnalyzer.jl/issues/new). +If you have a reproducible example of a bug, please [open a GitHub issue](https://github.com/jump-dev/MathOptAnalyzer.jl/issues/new). ## Installation -Install `ModelAnalyzer` using `Pkg.add`: +Install `MathOptAnalyzer` using `Pkg.add`: ```julia import Pkg -Pkg.add(; url = "https://github.com/jump-dev/ModelAnalyzer.jl") +Pkg.add(; url = "https://github.com/jump-dev/MathOptAnalyzer.jl") ``` ## Documentation -The [documentation for ModelAnalyzer.jl](https://jump.dev/ModelAnalyzer.jl/dev/) +The [documentation for MathOptAnalyzer.jl](https://jump.dev/MathOptAnalyzer.jl/dev/) describes how to use the package. diff --git a/docs/Project.toml b/docs/Project.toml index 32b49dc..2500c67 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,6 +1,6 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -ModelAnalyzer = "d1179b25-476b-425c-b826-c7787f0fff83" +MathOptAnalyzer = "d1179b25-476b-425c-b826-c7787f0fff83" JuMP = "4076af6c-e467-56ae-b986-b466b2749572" [compat] diff --git a/docs/make.jl b/docs/make.jl index bf2d820..73e19b4 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,8 +1,8 @@ -using Documenter, ModelAnalyzer, JuMP +using Documenter, MathOptAnalyzer, JuMP -makedocs(; sitename = "ModelAnalyzer.jl documentation") +makedocs(; sitename = "MathOptAnalyzer.jl documentation") deploydocs(; - repo = "github.com/jump-dev/ModelAnalyzer.jl.git", + repo = "github.com/jump-dev/MathOptAnalyzer.jl.git", push_preview = true, ) diff --git a/docs/src/analyzer.md b/docs/src/analyzer.md index e2854f1..56bd4a2 100644 --- a/docs/src/analyzer.md +++ b/docs/src/analyzer.md @@ -1,36 +1,36 @@ -# ModelAnalyzer main API +# MathOptAnalyzer main API -All the analysis modules in `ModelAnalyzer` follow the same main API. +All the analysis modules in `MathOptAnalyzer` follow the same main API. The main function to perform an analysis is: ```@docs -ModelAnalyzer.analyze +MathOptAnalyzer.analyze ``` Once the analysis is performed, the resulting data structure can be summarized using: ```@docs -ModelAnalyzer.summarize +MathOptAnalyzer.summarize ``` Alternatively, you can also query the types of issues found in the analysis and summarize them individually. The following functions are useful for this: ```@docs -ModelAnalyzer.list_of_issue_types -ModelAnalyzer.list_of_issues +MathOptAnalyzer.list_of_issue_types +MathOptAnalyzer.list_of_issues ``` It is possible to extract data from the issues with the methods: ```@docs -ModelAnalyzer.variables -ModelAnalyzer.variable -ModelAnalyzer.constraints -ModelAnalyzer.constraint -ModelAnalyzer.set -ModelAnalyzer.values -ModelAnalyzer.value +MathOptAnalyzer.variables +MathOptAnalyzer.variable +MathOptAnalyzer.constraints +MathOptAnalyzer.constraint +MathOptAnalyzer.set +MathOptAnalyzer.values +MathOptAnalyzer.value ``` diff --git a/docs/src/feasibility.md b/docs/src/feasibility.md index 3fac140..c019960 100644 --- a/docs/src/feasibility.md +++ b/docs/src/feasibility.md @@ -5,30 +5,30 @@ This module provides functionality to perform feasibility analysis on a JuMP mod This module follows the main API and is activated by the struct: ```@docs -ModelAnalyzer.Feasibility.Analyzer +MathOptAnalyzer.Feasibility.Analyzer ``` The analysis will return issues of the abstract type: ```@docs -ModelAnalyzer.Feasibility.AbstractFeasibilityIssue +MathOptAnalyzer.Feasibility.AbstractFeasibilityIssue ``` Specifically, the possible issues are: ```@docs -ModelAnalyzer.Feasibility.PrimalViolation -ModelAnalyzer.Feasibility.DualConstraintViolation -ModelAnalyzer.Feasibility.DualConstrainedVariableViolation -ModelAnalyzer.Feasibility.ComplemetarityViolation -ModelAnalyzer.Feasibility.DualObjectiveMismatch -ModelAnalyzer.Feasibility.PrimalObjectiveMismatch -ModelAnalyzer.Feasibility.PrimalDualMismatch -ModelAnalyzer.Feasibility.PrimalDualSolverMismatch +MathOptAnalyzer.Feasibility.PrimalViolation +MathOptAnalyzer.Feasibility.DualConstraintViolation +MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation +MathOptAnalyzer.Feasibility.ComplemetarityViolation +MathOptAnalyzer.Feasibility.DualObjectiveMismatch +MathOptAnalyzer.Feasibility.PrimalObjectiveMismatch +MathOptAnalyzer.Feasibility.PrimalDualMismatch +MathOptAnalyzer.Feasibility.PrimalDualSolverMismatch ``` These issues are saved in the data structure that is returned from the -`ModelAnalyzer.analyze` function: +`MathOptAnalyzer.analyze` function: ```@docs -ModelAnalyzer.Feasibility.Data +MathOptAnalyzer.Feasibility.Data ``` \ No newline at end of file diff --git a/docs/src/index.md b/docs/src/index.md index fca6e27..6560131 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -1,11 +1,11 @@ ```@meta -CurrentModule = ModelAnalyzer +CurrentModule = MathOptAnalyzer DocTestSetup = quote - using ModelAnalyzer + using MathOptAnalyzer end ``` -# ModelAnalyzer.jl +# MathOptAnalyzer.jl This package provides tools for analyzing (and debugging) [JuMP](https://github.com/jump-dev/JuMP.jl) models. @@ -39,7 +39,7 @@ run: ```julia using Pkg -Pkg.add(url = "https://github.com/jump-dev/ModelAnalyzer.jl") +Pkg.add(url = "https://github.com/jump-dev/MathOptAnalyzer.jl") ``` ## Usage @@ -50,7 +50,7 @@ Here is a simple example of how to use the package: ```julia using JuMP -using ModelAnalyzer +using MathOptAnalyzer using HiGHS # or any other supported solver # Create a simple JuMP model model = Model(HiGHS.Optimizer) @@ -65,39 +65,39 @@ optimize!(model) # either # Perform a numerical analysis of the model -data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) +data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) # print report -ModelAnalyzer.summarize(data) +MathOptAnalyzer.summarize(data) # or # Check for solution feasibility and optimality -data = ModelAnalyzer.analyze(ModelAnalyzer.Feasibility.Analyzer(), model) +data = MathOptAnalyzer.analyze(MathOptAnalyzer.Feasibility.Analyzer(), model) # print report -ModelAnalyzer.summarize(data) +MathOptAnalyzer.summarize(data) # or # Infeasibility analysis (if the model was infeasible) -data = ModelAnalyzer.analyze( - ModelAnalyzer.Infeasibility.Analyzer(), +data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Infeasibility.Analyzer(), model, optimizer = HiGHS.Optimizer, ) # print report to the screen -ModelAnalyzer.summarize(data) +MathOptAnalyzer.summarize(data) # or print the report to a file # open a file open("my_report.txt", "w") do io # print report - ModelAnalyzer.summarize(io, data) + MathOptAnalyzer.summarize(io, data) end ``` -The `ModelAnalyzer.analyze(...)` function can always take the keyword arguments: +The `MathOptAnalyzer.analyze(...)` function can always take the keyword arguments: * `verbose = false` to condense the print output. * `max_issues = n` to limit the maximum number of issues to report for each type. @@ -107,27 +107,27 @@ arguments. ### Advanced usage -After any `ModelAnalyzer.analyze(...)` call is performed, the resulting data -structure can be summarized using `ModelAnalyzer.summarize(data)` as show above, +After any `MathOptAnalyzer.analyze(...)` call is performed, the resulting data +structure can be summarized using `MathOptAnalyzer.summarize(data)` as show above, or it can be further inspected programmatically. ```julia -# given a `data` object obtained from `ModelAnalyzer.analyze(...)` +# given a `data` object obtained from `MathOptAnalyzer.analyze(...)` # query the types of issues found in the analysis -list = ModelAnalyzer.list_of_issue_types(data) +list = MathOptAnalyzer.list_of_issue_types(data) # information about the types of issues found can be printed out -ModelAnalyzer.summarize(list[1]) +MathOptAnalyzer.summarize(list[1]) # for each issue type, you can get the actual issues found in the analysis -issues = ModelAnalyzer.list_of_issues(data, list[1]) +issues = MathOptAnalyzer.list_of_issues(data, list[1]) # the list of issues of the given type can be summarized with: -ModelAnalyzer.summarize(issues) +MathOptAnalyzer.summarize(issues) # individual issues can also be summarized -ModelAnalyzer.summarize(issues[1]) +MathOptAnalyzer.summarize(issues[1]) ``` ### Non JuMP (or MOI) models diff --git a/docs/src/infeasibility.md b/docs/src/infeasibility.md index befe1a1..abc7409 100644 --- a/docs/src/infeasibility.md +++ b/docs/src/infeasibility.md @@ -5,27 +5,27 @@ This module provides functionality to perform infeasibility analysis on a JuMP m This module follows the main API and is activated by the struct: ```@docs -ModelAnalyzer.Infeasibility.Analyzer +MathOptAnalyzer.Infeasibility.Analyzer ``` The analysis will return issues of the abstract type: ```@docs -ModelAnalyzer.Infeasibility.AbstractInfeasibilitylIssue +MathOptAnalyzer.Infeasibility.AbstractInfeasibilitylIssue ``` Specifically, the possible issues are: ```@docs -ModelAnalyzer.Infeasibility.InfeasibleBounds -ModelAnalyzer.Infeasibility.InfeasibleIntegrality -ModelAnalyzer.Infeasibility.InfeasibleConstraintRange -ModelAnalyzer.Infeasibility.IrreducibleInfeasibleSubset +MathOptAnalyzer.Infeasibility.InfeasibleBounds +MathOptAnalyzer.Infeasibility.InfeasibleIntegrality +MathOptAnalyzer.Infeasibility.InfeasibleConstraintRange +MathOptAnalyzer.Infeasibility.IrreducibleInfeasibleSubset ``` These issues are saved in the data structure that is returned from the -`ModelAnalyzer.analyze` function: +`MathOptAnalyzer.analyze` function: ```@docs -ModelAnalyzer.Infeasibility.Data +MathOptAnalyzer.Infeasibility.Data ``` \ No newline at end of file diff --git a/docs/src/numerical.md b/docs/src/numerical.md index ed38aff..647ee2d 100644 --- a/docs/src/numerical.md +++ b/docs/src/numerical.md @@ -5,40 +5,40 @@ This module provides functionality to perform numerical analysis on a JuMP model This module follows the main API and is activated by the struct: ```@docs -ModelAnalyzer.Numerical.Analyzer +MathOptAnalyzer.Numerical.Analyzer ``` The analysis will return issues of the abstract type: ```@docs -ModelAnalyzer.Numerical.AbstractNumericalIssue +MathOptAnalyzer.Numerical.AbstractNumericalIssue ``` Specifically the possible issues are: ```@docs -ModelAnalyzer.Numerical.VariableNotInConstraints -ModelAnalyzer.Numerical.EmptyConstraint -ModelAnalyzer.Numerical.VariableBoundAsConstraint -ModelAnalyzer.Numerical.DenseConstraint -ModelAnalyzer.Numerical.SmallMatrixCoefficient -ModelAnalyzer.Numerical.LargeMatrixCoefficient -ModelAnalyzer.Numerical.SmallBoundCoefficient -ModelAnalyzer.Numerical.LargeBoundCoefficient -ModelAnalyzer.Numerical.SmallRHSCoefficient -ModelAnalyzer.Numerical.LargeRHSCoefficient -ModelAnalyzer.Numerical.SmallObjectiveCoefficient -ModelAnalyzer.Numerical.LargeObjectiveCoefficient -ModelAnalyzer.Numerical.SmallObjectiveQuadraticCoefficient -ModelAnalyzer.Numerical.LargeObjectiveQuadraticCoefficient -ModelAnalyzer.Numerical.SmallMatrixQuadraticCoefficient -ModelAnalyzer.Numerical.LargeMatrixQuadraticCoefficient -ModelAnalyzer.Numerical.NonconvexQuadraticObjective -ModelAnalyzer.Numerical.NonconvexQuadraticConstraint +MathOptAnalyzer.Numerical.VariableNotInConstraints +MathOptAnalyzer.Numerical.EmptyConstraint +MathOptAnalyzer.Numerical.VariableBoundAsConstraint +MathOptAnalyzer.Numerical.DenseConstraint +MathOptAnalyzer.Numerical.SmallMatrixCoefficient +MathOptAnalyzer.Numerical.LargeMatrixCoefficient +MathOptAnalyzer.Numerical.SmallBoundCoefficient +MathOptAnalyzer.Numerical.LargeBoundCoefficient +MathOptAnalyzer.Numerical.SmallRHSCoefficient +MathOptAnalyzer.Numerical.LargeRHSCoefficient +MathOptAnalyzer.Numerical.SmallObjectiveCoefficient +MathOptAnalyzer.Numerical.LargeObjectiveCoefficient +MathOptAnalyzer.Numerical.SmallObjectiveQuadraticCoefficient +MathOptAnalyzer.Numerical.LargeObjectiveQuadraticCoefficient +MathOptAnalyzer.Numerical.SmallMatrixQuadraticCoefficient +MathOptAnalyzer.Numerical.LargeMatrixQuadraticCoefficient +MathOptAnalyzer.Numerical.NonconvexQuadraticObjective +MathOptAnalyzer.Numerical.NonconvexQuadraticConstraint ``` -These issues are saved in the data structure that is returned from the `ModelAnalyzer.analyze` function: +These issues are saved in the data structure that is returned from the `MathOptAnalyzer.analyze` function: ```@docs -ModelAnalyzer.Numerical.Data +MathOptAnalyzer.Numerical.Data ``` \ No newline at end of file diff --git a/ext/ModelAnalyzerJuMPExt/ModelAnalyzerJuMPExt.jl b/ext/MathOptAnalyzerJuMPExt/MathOptAnalyzerJuMPExt.jl similarity index 57% rename from ext/ModelAnalyzerJuMPExt/ModelAnalyzerJuMPExt.jl rename to ext/MathOptAnalyzerJuMPExt/MathOptAnalyzerJuMPExt.jl index 222b311..b719fba 100644 --- a/ext/ModelAnalyzerJuMPExt/ModelAnalyzerJuMPExt.jl +++ b/ext/MathOptAnalyzerJuMPExt/MathOptAnalyzerJuMPExt.jl @@ -3,23 +3,23 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -module ModelAnalyzerJuMPExt +module MathOptAnalyzerJuMPExt import JuMP import MathOptInterface as MOI -import ModelAnalyzer +import MathOptAnalyzer -function ModelAnalyzer.analyze( - analyzer::ModelAnalyzer.AbstractAnalyzer, +function MathOptAnalyzer.analyze( + analyzer::MathOptAnalyzer.AbstractAnalyzer, model::JuMP.GenericModel; kwargs..., ) moi_model = JuMP.backend(model) - result = ModelAnalyzer.analyze(analyzer, moi_model; kwargs...) + result = MathOptAnalyzer.analyze(analyzer, moi_model; kwargs...) return result end -function ModelAnalyzer._name( +function MathOptAnalyzer._name( ref::MOI.VariableIndex, model::JuMP.GenericModel{T}, ) where {T} @@ -31,7 +31,10 @@ function ModelAnalyzer._name( return "$jump_ref" end -function ModelAnalyzer._name(ref::MOI.ConstraintIndex, model::JuMP.GenericModel) +function MathOptAnalyzer._name( + ref::MOI.ConstraintIndex, + model::JuMP.GenericModel, +) jump_ref = JuMP.constraint_ref_with_index(model, ref) name = JuMP.name(jump_ref) if !isempty(name) @@ -40,7 +43,10 @@ function ModelAnalyzer._name(ref::MOI.ConstraintIndex, model::JuMP.GenericModel) return "$jump_ref" end -function ModelAnalyzer._show(ref::MOI.ConstraintIndex, model::JuMP.GenericModel) +function MathOptAnalyzer._show( + ref::MOI.ConstraintIndex, + model::JuMP.GenericModel, +) jump_ref = JuMP.constraint_ref_with_index(model, ref) io = IOBuffer() show(io, jump_ref) @@ -48,55 +54,55 @@ function ModelAnalyzer._show(ref::MOI.ConstraintIndex, model::JuMP.GenericModel) end """ - variable(issue::ModelAnalyzer.AbstractIssue, model::JuMP.GenericModel) + variable(issue::MathOptAnalyzer.AbstractIssue, model::JuMP.GenericModel) Return the **JuMP** variable reference associated to a particular issue. """ -function ModelAnalyzer.variable( - issue::ModelAnalyzer.AbstractIssue, +function MathOptAnalyzer.variable( + issue::MathOptAnalyzer.AbstractIssue, model::JuMP.GenericModel{T}, ) where {T} - ref = ModelAnalyzer.variable(issue) + ref = MathOptAnalyzer.variable(issue) return JuMP.GenericVariableRef{T}(model, ref) end """ - variables(issue::ModelAnalyzer.AbstractIssue, model::JuMP.GenericModel) + variables(issue::MathOptAnalyzer.AbstractIssue, model::JuMP.GenericModel) Return the **JuMP** variable references associated to a particular issue. """ -function ModelAnalyzer.variables( - issue::ModelAnalyzer.AbstractIssue, +function MathOptAnalyzer.variables( + issue::MathOptAnalyzer.AbstractIssue, model::JuMP.GenericModel{T}, ) where {T} - refs = ModelAnalyzer.variables(issue) + refs = MathOptAnalyzer.variables(issue) return JuMP.GenericVariableRef{T}.(model, refs) end """ - constraint(issue::ModelAnalyzer.AbstractIssue, model::JuMP.GenericModel) + constraint(issue::MathOptAnalyzer.AbstractIssue, model::JuMP.GenericModel) Return the **JuMP** constraint reference associated to a particular issue. """ -function ModelAnalyzer.constraint( - issue::ModelAnalyzer.AbstractIssue, +function MathOptAnalyzer.constraint( + issue::MathOptAnalyzer.AbstractIssue, model::JuMP.GenericModel, ) - ref = ModelAnalyzer.constraint(issue) + ref = MathOptAnalyzer.constraint(issue) return JuMP.constraint_ref_with_index(model, ref) end """ - constraintss(issue::ModelAnalyzer.AbstractIssue, model::JuMP.GenericModel) + constraintss(issue::MathOptAnalyzer.AbstractIssue, model::JuMP.GenericModel) Return the **JuMP** constraints reference associated to a particular issue. """ -function ModelAnalyzer.constraints( - issue::ModelAnalyzer.AbstractIssue, +function MathOptAnalyzer.constraints( + issue::MathOptAnalyzer.AbstractIssue, model::JuMP.GenericModel, ) - ref = ModelAnalyzer.constraints(issue) + ref = MathOptAnalyzer.constraints(issue) return JuMP.constraint_ref_with_index.(model, ref) end -end # module ModelAnalyzerJuMPExt +end # module MathOptAnalyzerJuMPExt diff --git a/src/Feasibility/Feasibility.jl b/src/Feasibility/Feasibility.jl index d21c0bc..bca65a6 100644 --- a/src/Feasibility/Feasibility.jl +++ b/src/Feasibility/Feasibility.jl @@ -7,7 +7,7 @@ module Feasibility import Dualization import MathOptInterface as MOI -import ModelAnalyzer +import MathOptAnalyzer import Printf include("structs.jl") diff --git a/src/Feasibility/analyze.jl b/src/Feasibility/analyze.jl index cebe6c2..65eccdb 100644 --- a/src/Feasibility/analyze.jl +++ b/src/Feasibility/analyze.jl @@ -3,7 +3,7 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -function ModelAnalyzer.analyze( +function MathOptAnalyzer.analyze( ::Analyzer, model::MOI.ModelLike; primal_point = nothing, diff --git a/src/Feasibility/structs.jl b/src/Feasibility/structs.jl index e8225ea..90ef6f9 100644 --- a/src/Feasibility/structs.jl +++ b/src/Feasibility/structs.jl @@ -4,15 +4,15 @@ # in the LICENSE.md file or at https://opensource.org/licenses/MIT. """ - Analyzer() <: ModelAnalyzer.AbstractAnalyzer + Analyzer() <: MathOptAnalyzer.AbstractAnalyzer The `Analyzer` type is used to perform feasibility analysis on a model. ## Example ```julia -julia> data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), +julia> data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model; primal_point::Union{Nothing, Dict} = nothing, dual_point::Union{Nothing, Dict} = nothing, @@ -43,14 +43,14 @@ The additional parameters: the dual check will also disable complementarity checking and dual objective checks. """ -struct Analyzer <: ModelAnalyzer.AbstractAnalyzer end +struct Analyzer <: MathOptAnalyzer.AbstractAnalyzer end """ AbstractFeasibilityIssue <: AbstractNumericalIssue Abstract type for feasibility issues found during the analysis of a model. """ -abstract type AbstractFeasibilityIssue <: ModelAnalyzer.AbstractIssue end +abstract type AbstractFeasibilityIssue <: MathOptAnalyzer.AbstractIssue end """ PrimalViolation <: AbstractFeasibilityIssue @@ -60,7 +60,7 @@ left-hand-side value that is not within the constraint's set. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Feasibility.PrimalViolation) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Feasibility.PrimalViolation) ``` """ struct PrimalViolation <: AbstractFeasibilityIssue @@ -68,9 +68,9 @@ struct PrimalViolation <: AbstractFeasibilityIssue violation::Float64 end -ModelAnalyzer.constraint(issue::PrimalViolation) = issue.ref +MathOptAnalyzer.constraint(issue::PrimalViolation) = issue.ref -ModelAnalyzer.value(issue::PrimalViolation) = issue.violation +MathOptAnalyzer.value(issue::PrimalViolation) = issue.violation """ DualConstraintViolation <: AbstractFeasibilityIssue @@ -81,7 +81,7 @@ This dual constraint corresponds to a primal variable. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Feasibility.DualConstraintViolation) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Feasibility.DualConstraintViolation) ``` """ struct DualConstraintViolation <: AbstractFeasibilityIssue @@ -89,9 +89,9 @@ struct DualConstraintViolation <: AbstractFeasibilityIssue violation::Float64 end -ModelAnalyzer.variable(issue::DualConstraintViolation) = issue.ref +MathOptAnalyzer.variable(issue::DualConstraintViolation) = issue.ref -ModelAnalyzer.value(issue::DualConstraintViolation) = issue.violation +MathOptAnalyzer.value(issue::DualConstraintViolation) = issue.violation """ DualConstrainedVariableViolation <: AbstractFeasibilityIssue @@ -108,7 +108,7 @@ This dual constraint corresponds to a primal (non-equality) constraint. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Feasibility.DualConstrainedVariableViolation) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation) ``` """ struct DualConstrainedVariableViolation <: AbstractFeasibilityIssue @@ -116,9 +116,9 @@ struct DualConstrainedVariableViolation <: AbstractFeasibilityIssue violation::Float64 end -ModelAnalyzer.constraint(issue::DualConstrainedVariableViolation) = issue.ref +MathOptAnalyzer.constraint(issue::DualConstrainedVariableViolation) = issue.ref -ModelAnalyzer.value(issue::DualConstrainedVariableViolation) = issue.violation +MathOptAnalyzer.value(issue::DualConstrainedVariableViolation) = issue.violation """ ComplemetarityViolation <: AbstractFeasibilityIssue @@ -130,7 +130,7 @@ violation is not zero. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Feasibility.ComplemetarityViolation) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Feasibility.ComplemetarityViolation) ``` """ struct ComplemetarityViolation <: AbstractFeasibilityIssue @@ -138,9 +138,9 @@ struct ComplemetarityViolation <: AbstractFeasibilityIssue violation::Float64 end -ModelAnalyzer.constraint(issue::ComplemetarityViolation) = issue.ref +MathOptAnalyzer.constraint(issue::ComplemetarityViolation) = issue.ref -ModelAnalyzer.value(issue::ComplemetarityViolation) = issue.violation +MathOptAnalyzer.value(issue::ComplemetarityViolation) = issue.violation """ DualObjectiveMismatch <: AbstractFeasibilityIssue @@ -151,7 +151,7 @@ dual objective value. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Feasibility.DualObjectiveMismatch) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Feasibility.DualObjectiveMismatch) ``` """ struct DualObjectiveMismatch <: AbstractFeasibilityIssue @@ -159,7 +159,7 @@ struct DualObjectiveMismatch <: AbstractFeasibilityIssue obj_solver::Float64 end -# ModelAnalyzer.values(issue::DualObjectiveMismatch) = [issue.obj, issue.obj_solver] +# MathOptAnalyzer.values(issue::DualObjectiveMismatch) = [issue.obj, issue.obj_solver] """ PrimalObjectiveMismatch <: AbstractFeasibilityIssue @@ -170,7 +170,7 @@ the solver's primal objective value. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Feasibility.PrimalObjectiveMismatch) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Feasibility.PrimalObjectiveMismatch) ``` """ struct PrimalObjectiveMismatch <: AbstractFeasibilityIssue @@ -178,7 +178,7 @@ struct PrimalObjectiveMismatch <: AbstractFeasibilityIssue obj_solver::Float64 end -# ModelAnalyzer.values(issue::PrimalObjectiveMismatch) = [issue.obj, issue.obj_solver] +# MathOptAnalyzer.values(issue::PrimalObjectiveMismatch) = [issue.obj, issue.obj_solver] """ PrimalDualMismatch <: AbstractFeasibilityIssue @@ -189,7 +189,7 @@ objective value computed from problem data and the dual solution. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Feasibility.PrimalDualMismatch) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Feasibility.PrimalDualMismatch) ``` """ struct PrimalDualMismatch <: AbstractFeasibilityIssue @@ -197,7 +197,7 @@ struct PrimalDualMismatch <: AbstractFeasibilityIssue dual::Float64 end -ModelAnalyzer.values(issue::PrimalDualMismatch) = [issue.primal, issue.dual] +MathOptAnalyzer.values(issue::PrimalDualMismatch) = [issue.primal, issue.dual] """ PrimalDualSolverMismatch <: AbstractFeasibilityIssue @@ -208,7 +208,7 @@ by the solver. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Feasibility.PrimalDualSolverMismatch) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Feasibility.PrimalDualSolverMismatch) ``` """ struct PrimalDualSolverMismatch <: AbstractFeasibilityIssue @@ -216,17 +216,17 @@ struct PrimalDualSolverMismatch <: AbstractFeasibilityIssue dual::Float64 end -# ModelAnalyzer.values(issue::PrimalDualSolverMismatch) = [issue.primal, issue.dual] +# MathOptAnalyzer.values(issue::PrimalDualSolverMismatch) = [issue.primal, issue.dual] """ Data The `Data` structure holds the results of the feasibility analysis performed -by the `ModelAnalyzer.analyze` function for a model. It contains +by the `MathOptAnalyzer.analyze` function for a model. It contains the configuration used for the analysis, the primal and dual points, and the lists of various feasibility issues found during the analysis. """ -Base.@kwdef mutable struct Data <: ModelAnalyzer.AbstractData +Base.@kwdef mutable struct Data <: MathOptAnalyzer.AbstractData # analysis configuration primal_point::Union{Nothing,AbstractDict} dual_point::Union{Nothing,AbstractDict} diff --git a/src/Feasibility/summarize.jl b/src/Feasibility/summarize.jl index 8ff6917..29120f9 100644 --- a/src/Feasibility/summarize.jl +++ b/src/Feasibility/summarize.jl @@ -3,42 +3,42 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -function ModelAnalyzer._summarize(io::IO, ::Type{PrimalViolation}) +function MathOptAnalyzer._summarize(io::IO, ::Type{PrimalViolation}) return print(io, "# PrimalViolation") end -function ModelAnalyzer._summarize(io::IO, ::Type{DualConstraintViolation}) +function MathOptAnalyzer._summarize(io::IO, ::Type{DualConstraintViolation}) return print(io, "# DualConstraintViolation") end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, ::Type{DualConstrainedVariableViolation}, ) return print(io, "# DualConstrainedVariableViolation") end -function ModelAnalyzer._summarize(io::IO, ::Type{ComplemetarityViolation}) +function MathOptAnalyzer._summarize(io::IO, ::Type{ComplemetarityViolation}) return print(io, "# ComplemetarityViolation") end -function ModelAnalyzer._summarize(io::IO, ::Type{DualObjectiveMismatch}) +function MathOptAnalyzer._summarize(io::IO, ::Type{DualObjectiveMismatch}) return print(io, "# DualObjectiveMismatch") end -function ModelAnalyzer._summarize(io::IO, ::Type{PrimalObjectiveMismatch}) +function MathOptAnalyzer._summarize(io::IO, ::Type{PrimalObjectiveMismatch}) return print(io, "# PrimalObjectiveMismatch") end -function ModelAnalyzer._summarize(io::IO, ::Type{PrimalDualMismatch}) +function MathOptAnalyzer._summarize(io::IO, ::Type{PrimalDualMismatch}) return print(io, "# PrimalDualMismatch") end -function ModelAnalyzer._summarize(io::IO, ::Type{PrimalDualSolverMismatch}) +function MathOptAnalyzer._summarize(io::IO, ::Type{PrimalDualSolverMismatch}) return print(io, "# PrimalDualSolverMismatch") end -function ModelAnalyzer._verbose_summarize(io::IO, ::Type{PrimalViolation}) +function MathOptAnalyzer._verbose_summarize(io::IO, ::Type{PrimalViolation}) return print( io, """ @@ -77,7 +77,7 @@ function ModelAnalyzer._verbose_summarize(io::IO, ::Type{PrimalViolation}) ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{DualConstraintViolation}, ) @@ -118,7 +118,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{DualConstrainedVariableViolation}, ) @@ -165,7 +165,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{ComplemetarityViolation}, ) @@ -209,7 +209,10 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize(io::IO, ::Type{DualObjectiveMismatch}) +function MathOptAnalyzer._verbose_summarize( + io::IO, + ::Type{DualObjectiveMismatch}, +) return print( io, """ @@ -244,7 +247,7 @@ function ModelAnalyzer._verbose_summarize(io::IO, ::Type{DualObjectiveMismatch}) ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{PrimalObjectiveMismatch}, ) @@ -282,7 +285,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize(io::IO, ::Type{PrimalDualMismatch}) +function MathOptAnalyzer._verbose_summarize(io::IO, ::Type{PrimalDualMismatch}) return print( io, """ @@ -314,7 +317,7 @@ function ModelAnalyzer._verbose_summarize(io::IO, ::Type{PrimalDualMismatch}) ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{PrimalDualSolverMismatch}, ) @@ -345,77 +348,93 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._summarize(io::IO, issue::PrimalViolation, model) +function MathOptAnalyzer._summarize(io::IO, issue::PrimalViolation, model) return print( io, - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " : ", issue.violation, ) end -function ModelAnalyzer._summarize(io::IO, issue::DualConstraintViolation, model) +function MathOptAnalyzer._summarize( + io::IO, + issue::DualConstraintViolation, + model, +) return print( io, - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " : ", issue.violation, ) end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, issue::DualConstrainedVariableViolation, model, ) return print( io, - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " : ", issue.violation, ) end -function ModelAnalyzer._summarize(io::IO, issue::ComplemetarityViolation, model) +function MathOptAnalyzer._summarize( + io::IO, + issue::ComplemetarityViolation, + model, +) return print( io, - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " : ", issue.violation, ) end -function ModelAnalyzer._summarize(io::IO, issue::DualObjectiveMismatch, model) - return ModelAnalyzer._verbose_summarize(io, issue, model) +function MathOptAnalyzer._summarize(io::IO, issue::DualObjectiveMismatch, model) + return MathOptAnalyzer._verbose_summarize(io, issue, model) end -function ModelAnalyzer._summarize(io::IO, issue::PrimalObjectiveMismatch, model) - return ModelAnalyzer._verbose_summarize(io, issue, model) +function MathOptAnalyzer._summarize( + io::IO, + issue::PrimalObjectiveMismatch, + model, +) + return MathOptAnalyzer._verbose_summarize(io, issue, model) end -function ModelAnalyzer._summarize(io::IO, issue::PrimalDualMismatch, model) - return ModelAnalyzer._verbose_summarize(io, issue, model) +function MathOptAnalyzer._summarize(io::IO, issue::PrimalDualMismatch, model) + return MathOptAnalyzer._verbose_summarize(io, issue, model) end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, issue::PrimalDualSolverMismatch, model, ) - return ModelAnalyzer._verbose_summarize(io, issue, model) + return MathOptAnalyzer._verbose_summarize(io, issue, model) end -function ModelAnalyzer._verbose_summarize(io::IO, issue::PrimalViolation, model) +function MathOptAnalyzer._verbose_summarize( + io::IO, + issue::PrimalViolation, + model, +) return print( io, "Constraint ", - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " has primal violation ", issue.violation, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::DualConstraintViolation, model, @@ -423,13 +442,13 @@ function ModelAnalyzer._verbose_summarize( return print( io, "Variables ", - ModelAnalyzer._name.(issue.ref, model), + MathOptAnalyzer._name.(issue.ref, model), " have dual violation ", issue.violation, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::DualConstrainedVariableViolation, model, @@ -437,13 +456,13 @@ function ModelAnalyzer._verbose_summarize( return print( io, "Constraint ", - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " has dual violation ", issue.violation, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::ComplemetarityViolation, model, @@ -451,13 +470,13 @@ function ModelAnalyzer._verbose_summarize( return print( io, "Constraint ", - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " has complementarty violation ", issue.violation, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::DualObjectiveMismatch, model, @@ -472,7 +491,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::PrimalObjectiveMismatch, model, @@ -487,7 +506,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::PrimalDualMismatch, model, @@ -502,7 +521,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::PrimalDualSolverMismatch, model, @@ -517,54 +536,57 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer.list_of_issues(data::Data, ::Type{PrimalViolation}) +function MathOptAnalyzer.list_of_issues(data::Data, ::Type{PrimalViolation}) return data.primal end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{DualConstraintViolation}, ) return data.dual end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{DualConstrainedVariableViolation}, ) return data.dual_convar end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{ComplemetarityViolation}, ) return data.complementarity end -function ModelAnalyzer.list_of_issues(data::Data, ::Type{DualObjectiveMismatch}) +function MathOptAnalyzer.list_of_issues( + data::Data, + ::Type{DualObjectiveMismatch}, +) return data.dual_objective_mismatch end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{PrimalObjectiveMismatch}, ) return data.primal_objective_mismatch end -function ModelAnalyzer.list_of_issues(data::Data, ::Type{PrimalDualMismatch}) +function MathOptAnalyzer.list_of_issues(data::Data, ::Type{PrimalDualMismatch}) return data.primal_dual_mismatch end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{PrimalDualSolverMismatch}, ) return data.primal_dual_solver_mismatch end -function ModelAnalyzer.list_of_issue_types(data::Data) +function MathOptAnalyzer.list_of_issue_types(data::Data) ret = Type[] for type in ( PrimalViolation, @@ -576,7 +598,7 @@ function ModelAnalyzer.list_of_issue_types(data::Data) PrimalDualMismatch, PrimalDualSolverMismatch, ) - if !isempty(ModelAnalyzer.list_of_issues(data, type)) + if !isempty(MathOptAnalyzer.list_of_issues(data, type)) push!(ret, type) end end @@ -591,12 +613,12 @@ function summarize_configurations(io::IO, data::Data) return end -function ModelAnalyzer.summarize( +function MathOptAnalyzer.summarize( io::IO, data::Data; model = nothing, verbose = true, - max_issues = ModelAnalyzer.DEFAULT_MAX_ISSUES, + max_issues = MathOptAnalyzer.DEFAULT_MAX_ISSUES, configurations = true, ) print(io, "## Feasibility Analysis\n\n") @@ -606,10 +628,10 @@ function ModelAnalyzer.summarize( end # add maximum primal, dual and compl # add sum of primal, dual and compl - for issue_type in ModelAnalyzer.list_of_issue_types(data) - issues = ModelAnalyzer.list_of_issues(data, issue_type) + for issue_type in MathOptAnalyzer.list_of_issue_types(data) + issues = MathOptAnalyzer.list_of_issues(data, issue_type) print(io, "\n\n") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( io, issues, model = model, @@ -622,8 +644,8 @@ end function Base.show(io::IO, data::Data) n = sum( - length(ModelAnalyzer.list_of_issues(data, T)) for - T in ModelAnalyzer.list_of_issue_types(data); + length(MathOptAnalyzer.list_of_issues(data, T)) for + T in MathOptAnalyzer.list_of_issue_types(data); init = 0, ) return print(io, "Feasibility analysis found $n issues") diff --git a/src/Infeasibility/Infeasibility.jl b/src/Infeasibility/Infeasibility.jl index d3e2f7d..9034d40 100644 --- a/src/Infeasibility/Infeasibility.jl +++ b/src/Infeasibility/Infeasibility.jl @@ -6,7 +6,7 @@ module Infeasibility import MathOptInterface as MOI -import ModelAnalyzer +import MathOptAnalyzer include("intervals.jl") include("_eval_variables.jl") diff --git a/src/Infeasibility/analyze.jl b/src/Infeasibility/analyze.jl index 7c94ddb..4262cb2 100644 --- a/src/Infeasibility/analyze.jl +++ b/src/Infeasibility/analyze.jl @@ -3,7 +3,7 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -function ModelAnalyzer.analyze( +function MathOptAnalyzer.analyze( ::Analyzer, model::MOI.ModelLike; optimizer = nothing, diff --git a/src/Infeasibility/structs.jl b/src/Infeasibility/structs.jl index f24a2c3..ab34fe8 100644 --- a/src/Infeasibility/structs.jl +++ b/src/Infeasibility/structs.jl @@ -4,13 +4,13 @@ # in the LICENSE.md file or at https://opensource.org/licenses/MIT. """ - Analyzer() <: ModelAnalyzer.AbstractAnalyzer + Analyzer() <: MathOptAnalyzer.AbstractAnalyzer The `Analyzer` type is used to perform infeasibility analysis on a model. ## Example ```julia -julia> data = ModelAnalyzer.analyze( +julia> data = MathOptAnalyzer.analyze( Analyzer(), model, optimizer = nothing,, @@ -20,7 +20,7 @@ julia> data = ModelAnalyzer.analyze( The additional keyword argument `optimizer` is used to specify the optimizer to use for the IIS resolver. """ -struct Analyzer <: ModelAnalyzer.AbstractAnalyzer end +struct Analyzer <: MathOptAnalyzer.AbstractAnalyzer end """ AbstractInfeasibilitylIssue @@ -28,7 +28,7 @@ struct Analyzer <: ModelAnalyzer.AbstractAnalyzer end Abstract type for infeasibility issues found during the analysis of a model. """ -abstract type AbstractInfeasibilitylIssue <: ModelAnalyzer.AbstractIssue end +abstract type AbstractInfeasibilitylIssue <: MathOptAnalyzer.AbstractIssue end """ InfeasibleBounds{T} <: AbstractInfeasibilitylIssue @@ -38,7 +38,7 @@ that is greater than its upper bound. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Infeasibility.InfeasibleBounds) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Infeasibility.InfeasibleBounds) ```` """ struct InfeasibleBounds{T} <: AbstractInfeasibilitylIssue @@ -47,9 +47,9 @@ struct InfeasibleBounds{T} <: AbstractInfeasibilitylIssue ub::T end -ModelAnalyzer.variable(issue::InfeasibleBounds) = issue.variable +MathOptAnalyzer.variable(issue::InfeasibleBounds) = issue.variable -ModelAnalyzer.values(issue::InfeasibleBounds) = [issue.lb, issue.ub] +MathOptAnalyzer.values(issue::InfeasibleBounds) = [issue.lb, issue.ub] """ InfeasibleIntegrality{T} <: AbstractInfeasibilitylIssue @@ -61,8 +61,8 @@ integer value to be feasible. For more information, run: ```julia -julia> ModelAnalyzer.summarize( - ModelAnalyzer.Infeasibility.InfeasibleIntegrality +julia> MathOptAnalyzer.summarize( + MathOptAnalyzer.Infeasibility.InfeasibleIntegrality ) ``` """ @@ -73,11 +73,11 @@ struct InfeasibleIntegrality{T} <: AbstractInfeasibilitylIssue set::Union{MOI.Integer,MOI.ZeroOne}#, MOI.Semicontinuous{T}, MOI.Semiinteger{T}} end -ModelAnalyzer.variable(issue::InfeasibleIntegrality) = issue.variable +MathOptAnalyzer.variable(issue::InfeasibleIntegrality) = issue.variable -ModelAnalyzer.values(issue::InfeasibleIntegrality) = [issue.lb, issue.ub] +MathOptAnalyzer.values(issue::InfeasibleIntegrality) = [issue.lb, issue.ub] -ModelAnalyzer.set(issue::InfeasibleIntegrality) = issue.set +MathOptAnalyzer.set(issue::InfeasibleIntegrality) = issue.set """ InfeasibleConstraintRange{T} <: AbstractInfeasibilitylIssue @@ -91,8 +91,8 @@ no issues of type `InfeasibleBounds` were found in the first layer of analysis. For more information, run: ```julia -julia> ModelAnalyzer.summarize( - ModelAnalyzer.Infeasibility.InfeasibleConstraintRange +julia> MathOptAnalyzer.summarize( + MathOptAnalyzer.Infeasibility.InfeasibleConstraintRange ) ``` """ @@ -103,11 +103,11 @@ struct InfeasibleConstraintRange{T} <: AbstractInfeasibilitylIssue set::Union{MOI.EqualTo{T},MOI.LessThan{T},MOI.GreaterThan{T}} end -ModelAnalyzer.constraint(issue::InfeasibleConstraintRange) = issue.constraint +MathOptAnalyzer.constraint(issue::InfeasibleConstraintRange) = issue.constraint -ModelAnalyzer.values(issue::InfeasibleConstraintRange) = [issue.lb, issue.ub] +MathOptAnalyzer.values(issue::InfeasibleConstraintRange) = [issue.lb, issue.ub] -ModelAnalyzer.set(issue::InfeasibleConstraintRange) = issue.set +MathOptAnalyzer.set(issue::InfeasibleConstraintRange) = issue.set """ IrreducibleInfeasibleSubset <: AbstractInfeasibilitylIssue @@ -120,8 +120,8 @@ were found. For more information, run: ```julia -julia> ModelAnalyzer.summarize( - ModelAnalyzer.Infeasibility.IrreducibleInfeasibleSubset +julia> MathOptAnalyzer.summarize( + MathOptAnalyzer.Infeasibility.IrreducibleInfeasibleSubset ) ``` """ @@ -129,17 +129,19 @@ struct IrreducibleInfeasibleSubset <: AbstractInfeasibilitylIssue constraint::Vector{<:MOI.ConstraintIndex} end -ModelAnalyzer.constraints(issue::IrreducibleInfeasibleSubset) = issue.constraint +function MathOptAnalyzer.constraints(issue::IrreducibleInfeasibleSubset) + return issue.constraint +end """ - Data <: ModelAnalyzer.AbstractData + Data <: MathOptAnalyzer.AbstractData The `Data` type is used to store the results of the infeasibility analysis. This type contains vectors of the various infeasibility issues found during the analysis, including `InfeasibleBounds`, `InfeasibleIntegrality`, `InfeasibleConstraintRange`, and `IrreducibleInfeasibleSubset`. """ -Base.@kwdef mutable struct Data <: ModelAnalyzer.AbstractData +Base.@kwdef mutable struct Data <: MathOptAnalyzer.AbstractData infeasible_bounds::Vector{InfeasibleBounds} = InfeasibleBounds[] infeasible_integrality::Vector{InfeasibleIntegrality} = InfeasibleIntegrality[] diff --git a/src/Infeasibility/summarize.jl b/src/Infeasibility/summarize.jl index 93aa15e..660e081 100644 --- a/src/Infeasibility/summarize.jl +++ b/src/Infeasibility/summarize.jl @@ -3,23 +3,26 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -function ModelAnalyzer._summarize(io::IO, ::Type{<:InfeasibleBounds}) +function MathOptAnalyzer._summarize(io::IO, ::Type{<:InfeasibleBounds}) return print(io, "# InfeasibleBounds") end -function ModelAnalyzer._summarize(io::IO, ::Type{<:InfeasibleIntegrality}) +function MathOptAnalyzer._summarize(io::IO, ::Type{<:InfeasibleIntegrality}) return print(io, "# InfeasibleIntegrality") end -function ModelAnalyzer._summarize(io::IO, ::Type{<:InfeasibleConstraintRange}) +function MathOptAnalyzer._summarize(io::IO, ::Type{<:InfeasibleConstraintRange}) return print(io, "# InfeasibleConstraintRange") end -function ModelAnalyzer._summarize(io::IO, ::Type{<:IrreducibleInfeasibleSubset}) +function MathOptAnalyzer._summarize( + io::IO, + ::Type{<:IrreducibleInfeasibleSubset}, +) return print(io, "# IrreducibleInfeasibleSubset") end -function ModelAnalyzer._verbose_summarize(io::IO, ::Type{<:InfeasibleBounds}) +function MathOptAnalyzer._verbose_summarize(io::IO, ::Type{<:InfeasibleBounds}) return print( io, """ @@ -46,7 +49,7 @@ function ModelAnalyzer._verbose_summarize(io::IO, ::Type{<:InfeasibleBounds}) ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{<:InfeasibleIntegrality}, ) @@ -77,7 +80,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{<:InfeasibleConstraintRange}, ) @@ -108,7 +111,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{<:IrreducibleInfeasibleSubset}, ) @@ -138,10 +141,10 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._summarize(io::IO, issue::InfeasibleBounds, model) +function MathOptAnalyzer._summarize(io::IO, issue::InfeasibleBounds, model) return print( io, - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " : ", issue.lb, " !<= ", @@ -149,10 +152,10 @@ function ModelAnalyzer._summarize(io::IO, issue::InfeasibleBounds, model) ) end -function ModelAnalyzer._summarize(io::IO, issue::InfeasibleIntegrality, model) +function MathOptAnalyzer._summarize(io::IO, issue::InfeasibleIntegrality, model) return print( io, - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " : [", issue.lb, "; ", @@ -162,14 +165,14 @@ function ModelAnalyzer._summarize(io::IO, issue::InfeasibleIntegrality, model) ) end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, issue::InfeasibleConstraintRange, model, ) return print( io, - ModelAnalyzer._name(issue.constraint, model), + MathOptAnalyzer._name(issue.constraint, model), " : [", issue.lb, "; ", @@ -179,7 +182,7 @@ function ModelAnalyzer._summarize( ) end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, issue::IrreducibleInfeasibleSubset, model, @@ -187,11 +190,11 @@ function ModelAnalyzer._summarize( return print( io, "IIS: ", - join(map(x -> ModelAnalyzer._name(x, model), issue.constraint), ", "), + join(map(x -> MathOptAnalyzer._name(x, model), issue.constraint), ", "), ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::InfeasibleBounds, model, @@ -199,7 +202,7 @@ function ModelAnalyzer._verbose_summarize( return print( io, "Variable: ", - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " with lower bound ", issue.lb, " and upper bound ", @@ -207,7 +210,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::InfeasibleIntegrality, model, @@ -215,7 +218,7 @@ function ModelAnalyzer._verbose_summarize( return print( io, "Variable: ", - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " with lower bound ", issue.lb, " and upper bound ", @@ -225,7 +228,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::InfeasibleConstraintRange, model, @@ -233,7 +236,7 @@ function ModelAnalyzer._verbose_summarize( return print( io, "Constraint: ", - ModelAnalyzer._name(issue.constraint, model), + MathOptAnalyzer._name(issue.constraint, model), " with computed lower bound ", issue.lb, " and computed upper bound ", @@ -243,7 +246,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::IrreducibleInfeasibleSubset, model, @@ -252,34 +255,37 @@ function ModelAnalyzer._verbose_summarize( for constraint in issue.constraint println(io) print(io, " ") - print(io, ModelAnalyzer._show(constraint, model)) + print(io, MathOptAnalyzer._show(constraint, model)) end return end -function ModelAnalyzer.list_of_issues(data::Data, ::Type{InfeasibleBounds}) +function MathOptAnalyzer.list_of_issues(data::Data, ::Type{InfeasibleBounds}) return data.infeasible_bounds end -function ModelAnalyzer.list_of_issues(data::Data, ::Type{InfeasibleIntegrality}) +function MathOptAnalyzer.list_of_issues( + data::Data, + ::Type{InfeasibleIntegrality}, +) return data.infeasible_integrality end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{InfeasibleConstraintRange}, ) return data.constraint_range end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{IrreducibleInfeasibleSubset}, ) return data.iis end -function ModelAnalyzer.list_of_issue_types(data::Data) +function MathOptAnalyzer.list_of_issue_types(data::Data) ret = Type[] for type in ( InfeasibleBounds, @@ -287,26 +293,26 @@ function ModelAnalyzer.list_of_issue_types(data::Data) InfeasibleConstraintRange, IrreducibleInfeasibleSubset, ) - if !isempty(ModelAnalyzer.list_of_issues(data, type)) + if !isempty(MathOptAnalyzer.list_of_issues(data, type)) push!(ret, type) end end return ret end -function ModelAnalyzer.summarize( +function MathOptAnalyzer.summarize( io::IO, data::Data; model = nothing, verbose = true, - max_issues = ModelAnalyzer.DEFAULT_MAX_ISSUES, + max_issues = MathOptAnalyzer.DEFAULT_MAX_ISSUES, ) print(io, "## Infeasibility Analysis\n\n") - for issue_type in ModelAnalyzer.list_of_issue_types(data) - issues = ModelAnalyzer.list_of_issues(data, issue_type) + for issue_type in MathOptAnalyzer.list_of_issue_types(data) + issues = MathOptAnalyzer.list_of_issues(data, issue_type) print(io, "\n\n") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( io, issues, model = model, @@ -319,8 +325,8 @@ end function Base.show(io::IO, data::Data) n = sum( - length(ModelAnalyzer.list_of_issues(data, T)) for - T in ModelAnalyzer.list_of_issue_types(data); + length(MathOptAnalyzer.list_of_issues(data, T)) for + T in MathOptAnalyzer.list_of_issue_types(data); init = 0, ) return print(io, "Infeasibility analysis found $n issues") diff --git a/src/ModelAnalyzer.jl b/src/MathOptAnalyzer.jl similarity index 99% rename from src/ModelAnalyzer.jl rename to src/MathOptAnalyzer.jl index 1f2cdd7..986db69 100644 --- a/src/ModelAnalyzer.jl +++ b/src/MathOptAnalyzer.jl @@ -3,7 +3,7 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -module ModelAnalyzer +module MathOptAnalyzer import MathOptInterface as MOI @@ -227,4 +227,4 @@ include("Numerical/Numerical.jl") include("Feasibility/Feasibility.jl") include("Infeasibility/Infeasibility.jl") -end # module ModelAnalyzer +end # module MathOptAnalyzer diff --git a/src/Numerical/Numerical.jl b/src/Numerical/Numerical.jl index 6ac45cc..f82c9be 100644 --- a/src/Numerical/Numerical.jl +++ b/src/Numerical/Numerical.jl @@ -7,7 +7,7 @@ module Numerical import LinearAlgebra import MathOptInterface as MOI -import ModelAnalyzer +import MathOptAnalyzer import Printf include("structs.jl") diff --git a/src/Numerical/analyze.jl b/src/Numerical/analyze.jl index ae2c539..d7f1545 100644 --- a/src/Numerical/analyze.jl +++ b/src/Numerical/analyze.jl @@ -9,7 +9,7 @@ Analyze the coefficients of a model. """ -function ModelAnalyzer.analyze( +function MathOptAnalyzer.analyze( ::Analyzer, model::MOI.ModelLike, ; diff --git a/src/Numerical/structs.jl b/src/Numerical/structs.jl index a6e3882..463465d 100644 --- a/src/Numerical/structs.jl +++ b/src/Numerical/structs.jl @@ -4,7 +4,7 @@ # in the LICENSE.md file or at https://opensource.org/licenses/MIT. """ - Analyzer() <: ModelAnalyzer.AbstractAnalyzer + Analyzer() <: MathOptAnalyzer.AbstractAnalyzer The `Analyzer` type is used to analyze the coefficients of a model for numerical issues. @@ -12,8 +12,8 @@ numerical issues. ## Example ```julia -julia> data = ModelAnalyzer.analyze( - ModelAnalyzer.Numerical.Analyzer(), +julia> data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Numerical.Analyzer(), model; threshold_dense_fill_in = 0.10, threshold_dense_entries = 1000, @@ -31,14 +31,14 @@ The additional parameters: - `threshold_large`: The threshold for large coefficients in the model. """ -struct Analyzer <: ModelAnalyzer.AbstractAnalyzer end +struct Analyzer <: MathOptAnalyzer.AbstractAnalyzer end """ AbstractNumericalIssue <: AbstractNumericalIssue Abstract type for numerical issues found during the analysis of a model. """ -abstract type AbstractNumericalIssue <: ModelAnalyzer.AbstractIssue end +abstract type AbstractNumericalIssue <: MathOptAnalyzer.AbstractIssue end """ VariableNotInConstraints <: AbstractNumericalIssue @@ -48,14 +48,14 @@ constraints. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Numerical.VariableNotInConstraints) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Numerical.VariableNotInConstraints) ``` """ struct VariableNotInConstraints <: AbstractNumericalIssue ref::MOI.VariableIndex end -ModelAnalyzer.variable(issue::VariableNotInConstraints) = issue.ref +MathOptAnalyzer.variable(issue::VariableNotInConstraints) = issue.ref """ EmptyConstraint <: AbstractNumericalIssue @@ -65,14 +65,14 @@ different from zero. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Numerical.EmptyConstraint) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Numerical.EmptyConstraint) ``` """ struct EmptyConstraint <: AbstractNumericalIssue ref::MOI.ConstraintIndex end -ModelAnalyzer.constraint(issue::EmptyConstraint) = issue.ref +MathOptAnalyzer.constraint(issue::EmptyConstraint) = issue.ref """ VariableBoundAsConstraint <: AbstractNumericalIssue @@ -83,14 +83,14 @@ coefficient, and this coefficient is equal to one. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Numerical.VariableBoundAsConstraint) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Numerical.VariableBoundAsConstraint) ``` """ struct VariableBoundAsConstraint <: AbstractNumericalIssue ref::MOI.ConstraintIndex end -ModelAnalyzer.constraint(issue::VariableBoundAsConstraint) = issue.ref +MathOptAnalyzer.constraint(issue::VariableBoundAsConstraint) = issue.ref """ DenseConstraint <: AbstractNumericalIssue @@ -101,7 +101,7 @@ non-zero entries is greater than `threshold_dense_entries`. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Numerical.DenseConstraint) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Numerical.DenseConstraint) ``` """ struct DenseConstraint <: AbstractNumericalIssue @@ -109,9 +109,9 @@ struct DenseConstraint <: AbstractNumericalIssue nnz::Int end -ModelAnalyzer.constraint(issue::DenseConstraint) = issue.ref +MathOptAnalyzer.constraint(issue::DenseConstraint) = issue.ref -ModelAnalyzer.value(issue::DenseConstraint) = issue.nnz +MathOptAnalyzer.value(issue::DenseConstraint) = issue.nnz """ SmallMatrixCoefficient <: AbstractNumericalIssue @@ -121,7 +121,7 @@ constraint is smaller than `threshold_small`. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Numerical.SmallMatrixCoefficient) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Numerical.SmallMatrixCoefficient) ``` """ struct SmallMatrixCoefficient <: AbstractNumericalIssue @@ -130,11 +130,11 @@ struct SmallMatrixCoefficient <: AbstractNumericalIssue coefficient::Float64 end -ModelAnalyzer.variable(issue::SmallMatrixCoefficient) = issue.variable +MathOptAnalyzer.variable(issue::SmallMatrixCoefficient) = issue.variable -ModelAnalyzer.constraint(issue::SmallMatrixCoefficient) = issue.ref +MathOptAnalyzer.constraint(issue::SmallMatrixCoefficient) = issue.ref -ModelAnalyzer.value(issue::SmallMatrixCoefficient) = issue.coefficient +MathOptAnalyzer.value(issue::SmallMatrixCoefficient) = issue.coefficient """ LargeMatrixCoefficient <: AbstractNumericalIssue @@ -144,7 +144,7 @@ constraint is larger than `threshold_large`. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Numerical.LargeMatrixCoefficient) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Numerical.LargeMatrixCoefficient) ``` """ struct LargeMatrixCoefficient <: AbstractNumericalIssue @@ -153,11 +153,11 @@ struct LargeMatrixCoefficient <: AbstractNumericalIssue coefficient::Float64 end -ModelAnalyzer.variable(issue::LargeMatrixCoefficient) = issue.variable +MathOptAnalyzer.variable(issue::LargeMatrixCoefficient) = issue.variable -ModelAnalyzer.constraint(issue::LargeMatrixCoefficient) = issue.ref +MathOptAnalyzer.constraint(issue::LargeMatrixCoefficient) = issue.ref -ModelAnalyzer.value(issue::LargeMatrixCoefficient) = issue.coefficient +MathOptAnalyzer.value(issue::LargeMatrixCoefficient) = issue.coefficient """ SmallBoundCoefficient <: AbstractNumericalIssue @@ -167,7 +167,7 @@ The `SmallBoundCoefficient` issue is identified when a variable's bound For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Numerical.SmallBoundCoefficient) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Numerical.SmallBoundCoefficient) ``` """ struct SmallBoundCoefficient <: AbstractNumericalIssue @@ -175,9 +175,9 @@ struct SmallBoundCoefficient <: AbstractNumericalIssue coefficient::Float64 end -ModelAnalyzer.variable(issue::SmallBoundCoefficient) = issue.variable +MathOptAnalyzer.variable(issue::SmallBoundCoefficient) = issue.variable -ModelAnalyzer.value(issue::SmallBoundCoefficient) = issue.coefficient +MathOptAnalyzer.value(issue::SmallBoundCoefficient) = issue.coefficient """ LargeBoundCoefficient <: AbstractNumericalIssue @@ -187,7 +187,7 @@ The `LargeBoundCoefficient` issue is identified when a variable's bound For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Numerical.LargeBoundCoefficient) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Numerical.LargeBoundCoefficient) ``` """ struct LargeBoundCoefficient <: AbstractNumericalIssue @@ -195,9 +195,9 @@ struct LargeBoundCoefficient <: AbstractNumericalIssue coefficient::Float64 end -ModelAnalyzer.variable(issue::LargeBoundCoefficient) = issue.variable +MathOptAnalyzer.variable(issue::LargeBoundCoefficient) = issue.variable -ModelAnalyzer.value(issue::LargeBoundCoefficient) = issue.coefficient +MathOptAnalyzer.value(issue::LargeBoundCoefficient) = issue.coefficient """ SmallRHSCoefficient <: AbstractNumericalIssue @@ -207,7 +207,7 @@ coefficient of a constraint is smaller than `threshold_small`. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Numerical.SmallRHSCoefficient) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Numerical.SmallRHSCoefficient) ``` """ struct SmallRHSCoefficient <: AbstractNumericalIssue @@ -215,9 +215,9 @@ struct SmallRHSCoefficient <: AbstractNumericalIssue coefficient::Float64 end -ModelAnalyzer.constraint(issue::SmallRHSCoefficient) = issue.ref +MathOptAnalyzer.constraint(issue::SmallRHSCoefficient) = issue.ref -ModelAnalyzer.value(issue::SmallRHSCoefficient) = issue.coefficient +MathOptAnalyzer.value(issue::SmallRHSCoefficient) = issue.coefficient """ LargeRHSCoefficient <: AbstractNumericalIssue @@ -227,7 +227,7 @@ coefficient of a constraint is larger than `threshold_large`. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Numerical.LargeRHSCoefficient) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Numerical.LargeRHSCoefficient) ``` """ struct LargeRHSCoefficient <: AbstractNumericalIssue @@ -235,9 +235,9 @@ struct LargeRHSCoefficient <: AbstractNumericalIssue coefficient::Float64 end -ModelAnalyzer.constraint(issue::LargeRHSCoefficient) = issue.ref +MathOptAnalyzer.constraint(issue::LargeRHSCoefficient) = issue.ref -ModelAnalyzer.value(issue::LargeRHSCoefficient) = issue.coefficient +MathOptAnalyzer.value(issue::LargeRHSCoefficient) = issue.coefficient """ SmallObjectiveCoefficient <: AbstractNumericalIssue @@ -247,7 +247,7 @@ objective function is smaller than `threshold_small`. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Numerical.SmallObjectiveCoefficient) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Numerical.SmallObjectiveCoefficient) ``` """ struct SmallObjectiveCoefficient <: AbstractNumericalIssue @@ -255,9 +255,9 @@ struct SmallObjectiveCoefficient <: AbstractNumericalIssue coefficient::Float64 end -ModelAnalyzer.variable(issue::SmallObjectiveCoefficient) = issue.variable +MathOptAnalyzer.variable(issue::SmallObjectiveCoefficient) = issue.variable -ModelAnalyzer.value(issue::SmallObjectiveCoefficient) = issue.coefficient +MathOptAnalyzer.value(issue::SmallObjectiveCoefficient) = issue.coefficient """ LargeObjectiveCoefficient <: AbstractNumericalIssue @@ -267,7 +267,7 @@ objective function is larger than `threshold_large`. For more information, run: ```julia -julia> ModelAnalyzer.summarize(ModelAnalyzer.Numerical.LargeObjectiveCoefficient) +julia> MathOptAnalyzer.summarize(MathOptAnalyzer.Numerical.LargeObjectiveCoefficient) ``` """ struct LargeObjectiveCoefficient <: AbstractNumericalIssue @@ -275,9 +275,9 @@ struct LargeObjectiveCoefficient <: AbstractNumericalIssue coefficient::Float64 end -ModelAnalyzer.variable(issue::LargeObjectiveCoefficient) = issue.variable +MathOptAnalyzer.variable(issue::LargeObjectiveCoefficient) = issue.variable -ModelAnalyzer.value(issue::LargeObjectiveCoefficient) = issue.coefficient +MathOptAnalyzer.value(issue::LargeObjectiveCoefficient) = issue.coefficient """ SmallObjectiveQuadraticCoefficient <: AbstractNumericalIssue @@ -287,8 +287,8 @@ coefficient in the objective function is smaller than `threshold_small`. For more information, run: ```julia -julia> ModelAnalyzer.summarize( - ModelAnalyzer.Numerical.SmallObjectiveQuadraticCoefficient +julia> MathOptAnalyzer.summarize( + MathOptAnalyzer.Numerical.SmallObjectiveQuadraticCoefficient ) ``` """ @@ -298,11 +298,11 @@ struct SmallObjectiveQuadraticCoefficient <: AbstractNumericalIssue coefficient::Float64 end -function ModelAnalyzer.variables(issue::SmallObjectiveQuadraticCoefficient) +function MathOptAnalyzer.variables(issue::SmallObjectiveQuadraticCoefficient) return [issue.variable1, issue.variable2] end -function ModelAnalyzer.value(issue::SmallObjectiveQuadraticCoefficient) +function MathOptAnalyzer.value(issue::SmallObjectiveQuadraticCoefficient) return issue.coefficient end @@ -314,8 +314,8 @@ coefficient in the objective function is larger than `threshold_large`. For more information, run: ```julia -julia> ModelAnalyzer.summarize( - ModelAnalyzer.Numerical.LargeObjectiveQuadraticCoefficient +julia> MathOptAnalyzer.summarize( + MathOptAnalyzer.Numerical.LargeObjectiveQuadraticCoefficient ) ``` """ @@ -325,11 +325,11 @@ struct LargeObjectiveQuadraticCoefficient <: AbstractNumericalIssue coefficient::Float64 end -function ModelAnalyzer.variables(issue::LargeObjectiveQuadraticCoefficient) +function MathOptAnalyzer.variables(issue::LargeObjectiveQuadraticCoefficient) return [issue.variable1, issue.variable2] end -function ModelAnalyzer.value(issue::LargeObjectiveQuadraticCoefficient) +function MathOptAnalyzer.value(issue::LargeObjectiveQuadraticCoefficient) return issue.coefficient end @@ -341,8 +341,8 @@ coefficient in a constraint is smaller than `threshold_small`. For more information, run: ```julia -julia> ModelAnalyzer.summarize( - ModelAnalyzer.Numerical.SmallMatrixQuadraticCoefficient +julia> MathOptAnalyzer.summarize( + MathOptAnalyzer.Numerical.SmallMatrixQuadraticCoefficient ) ``` """ @@ -353,15 +353,17 @@ struct SmallMatrixQuadraticCoefficient <: AbstractNumericalIssue coefficient::Float64 end -function ModelAnalyzer.variables(issue::SmallMatrixQuadraticCoefficient) +function MathOptAnalyzer.variables(issue::SmallMatrixQuadraticCoefficient) return [issue.variable1, issue.variable2] end -function ModelAnalyzer.constraint(issue::SmallMatrixQuadraticCoefficient) +function MathOptAnalyzer.constraint(issue::SmallMatrixQuadraticCoefficient) return issue.ref end -ModelAnalyzer.value(issue::SmallMatrixQuadraticCoefficient) = issue.coefficient +function MathOptAnalyzer.value(issue::SmallMatrixQuadraticCoefficient) + return issue.coefficient +end """ LargeMatrixQuadraticCoefficient <: AbstractNumericalIssue @@ -371,8 +373,8 @@ coefficient in a constraint is larger than `threshold_large`. For more information, run: ```julia -julia> ModelAnalyzer.summarize( - ModelAnalyzer.Numerical.LargeMatrixQuadraticCoefficient +julia> MathOptAnalyzer.summarize( + MathOptAnalyzer.Numerical.LargeMatrixQuadraticCoefficient ) ``` """ @@ -383,15 +385,17 @@ struct LargeMatrixQuadraticCoefficient <: AbstractNumericalIssue coefficient::Float64 end -function ModelAnalyzer.variables(issue::LargeMatrixQuadraticCoefficient) +function MathOptAnalyzer.variables(issue::LargeMatrixQuadraticCoefficient) return [issue.variable1, issue.variable2] end -function ModelAnalyzer.constraint(issue::LargeMatrixQuadraticCoefficient) +function MathOptAnalyzer.constraint(issue::LargeMatrixQuadraticCoefficient) return issue.ref end -ModelAnalyzer.value(issue::LargeMatrixQuadraticCoefficient) = issue.coefficient +function MathOptAnalyzer.value(issue::LargeMatrixQuadraticCoefficient) + return issue.coefficient +end """ NonconvexQuadraticObjective <: AbstractNumericalIssue @@ -401,8 +405,8 @@ objective function is non-convex. For more information, run: ```julia -julia> ModelAnalyzer.summarize( - ModelAnalyzer.Numerical.NonconvexQuadraticObjective +julia> MathOptAnalyzer.summarize( + MathOptAnalyzer.Numerical.NonconvexQuadraticObjective ) ``` """ @@ -416,24 +420,24 @@ constraint is non-convex. For more information, run: ```julia -julia> ModelAnalyzer.summarize( - ModelAnalyzer.Numerical.NonconvexQuadraticConstraint +julia> MathOptAnalyzer.summarize( + MathOptAnalyzer.Numerical.NonconvexQuadraticConstraint ) ``` """ struct NonconvexQuadraticConstraint <: AbstractNumericalIssue ref::MOI.ConstraintIndex end -ModelAnalyzer.constraint(issue::NonconvexQuadraticConstraint) = issue.ref +MathOptAnalyzer.constraint(issue::NonconvexQuadraticConstraint) = issue.ref """ Data The `Data` structure holds the results of the analysis performed by the -`ModelAnalyzer.Numerical.Analyzer`. It contains various thresholds and the +`MathOptAnalyzer.Numerical.Analyzer`. It contains various thresholds and the information about the model's variables, constraints, and objective function. """ -Base.@kwdef mutable struct Data <: ModelAnalyzer.AbstractData +Base.@kwdef mutable struct Data <: MathOptAnalyzer.AbstractData # analysis configuration threshold_dense_fill_in::Float64 = 0.10 threshold_dense_entries::Int = 1000 diff --git a/src/Numerical/summarize.jl b/src/Numerical/summarize.jl index 02ff118..5c971a8 100644 --- a/src/Numerical/summarize.jl +++ b/src/Numerical/summarize.jl @@ -3,91 +3,94 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -function ModelAnalyzer._summarize(io::IO, ::Type{VariableNotInConstraints}) +function MathOptAnalyzer._summarize(io::IO, ::Type{VariableNotInConstraints}) return print(io, "# VariableNotInConstraints") end -function ModelAnalyzer._summarize(io::IO, ::Type{EmptyConstraint}) +function MathOptAnalyzer._summarize(io::IO, ::Type{EmptyConstraint}) return print(io, "# EmptyConstraint") end -function ModelAnalyzer._summarize(io::IO, ::Type{VariableBoundAsConstraint}) +function MathOptAnalyzer._summarize(io::IO, ::Type{VariableBoundAsConstraint}) return print(io, "# VariableBoundAsConstraint") end -function ModelAnalyzer._summarize(io::IO, ::Type{DenseConstraint}) +function MathOptAnalyzer._summarize(io::IO, ::Type{DenseConstraint}) return print(io, "# DenseConstraint") end -function ModelAnalyzer._summarize(io::IO, ::Type{SmallMatrixCoefficient}) +function MathOptAnalyzer._summarize(io::IO, ::Type{SmallMatrixCoefficient}) return print(io, "# SmallMatrixCoefficient") end -function ModelAnalyzer._summarize(io::IO, ::Type{LargeMatrixCoefficient}) +function MathOptAnalyzer._summarize(io::IO, ::Type{LargeMatrixCoefficient}) return print(io, "# LargeMatrixCoefficient") end -function ModelAnalyzer._summarize(io::IO, ::Type{SmallBoundCoefficient}) +function MathOptAnalyzer._summarize(io::IO, ::Type{SmallBoundCoefficient}) return print(io, "# SmallBoundCoefficient") end -function ModelAnalyzer._summarize(io::IO, ::Type{LargeBoundCoefficient}) +function MathOptAnalyzer._summarize(io::IO, ::Type{LargeBoundCoefficient}) return print(io, "# LargeBoundCoefficient") end -function ModelAnalyzer._summarize(io::IO, ::Type{SmallRHSCoefficient}) +function MathOptAnalyzer._summarize(io::IO, ::Type{SmallRHSCoefficient}) return print(io, "# SmallRHSCoefficient") end -function ModelAnalyzer._summarize(io::IO, ::Type{LargeRHSCoefficient}) +function MathOptAnalyzer._summarize(io::IO, ::Type{LargeRHSCoefficient}) return print(io, "# LargeRHSCoefficient") end -function ModelAnalyzer._summarize(io::IO, ::Type{SmallObjectiveCoefficient}) +function MathOptAnalyzer._summarize(io::IO, ::Type{SmallObjectiveCoefficient}) return print(io, "# SmallObjectiveCoefficient") end -function ModelAnalyzer._summarize(io::IO, ::Type{LargeObjectiveCoefficient}) +function MathOptAnalyzer._summarize(io::IO, ::Type{LargeObjectiveCoefficient}) return print(io, "# LargeObjectiveCoefficient") end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, ::Type{SmallObjectiveQuadraticCoefficient}, ) return print(io, "# SmallObjectiveQuadraticCoefficient") end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, ::Type{LargeObjectiveQuadraticCoefficient}, ) return print(io, "# LargeObjectiveQuadraticCoefficient") end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, ::Type{SmallMatrixQuadraticCoefficient}, ) return print(io, "# SmallMatrixQuadraticCoefficient") end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, ::Type{LargeMatrixQuadraticCoefficient}, ) return print(io, "# LargeMatrixQuadraticCoefficient") end -function ModelAnalyzer._summarize(io::IO, ::Type{NonconvexQuadraticObjective}) +function MathOptAnalyzer._summarize(io::IO, ::Type{NonconvexQuadraticObjective}) return print(io, "# NonconvexQuadraticObjective") end -function ModelAnalyzer._summarize(io::IO, ::Type{NonconvexQuadraticConstraint}) +function MathOptAnalyzer._summarize( + io::IO, + ::Type{NonconvexQuadraticConstraint}, +) return print(io, "# NonconvexQuadraticConstraint") end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{VariableNotInConstraints}, ) @@ -121,7 +124,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize(io::IO, ::Type{EmptyConstraint}) +function MathOptAnalyzer._verbose_summarize(io::IO, ::Type{EmptyConstraint}) return print( io, """ @@ -150,7 +153,7 @@ function ModelAnalyzer._verbose_summarize(io::IO, ::Type{EmptyConstraint}) ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{VariableBoundAsConstraint}, ) @@ -182,7 +185,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize(io::IO, ::Type{DenseConstraint}) +function MathOptAnalyzer._verbose_summarize(io::IO, ::Type{DenseConstraint}) return print( io, """ @@ -214,7 +217,7 @@ function ModelAnalyzer._verbose_summarize(io::IO, ::Type{DenseConstraint}) ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{SmallMatrixCoefficient}, ) @@ -247,7 +250,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{LargeMatrixCoefficient}, ) @@ -280,7 +283,10 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize(io::IO, ::Type{SmallBoundCoefficient}) +function MathOptAnalyzer._verbose_summarize( + io::IO, + ::Type{SmallBoundCoefficient}, +) return print( io, """ @@ -309,7 +315,10 @@ function ModelAnalyzer._verbose_summarize(io::IO, ::Type{SmallBoundCoefficient}) ) end -function ModelAnalyzer._verbose_summarize(io::IO, ::Type{LargeBoundCoefficient}) +function MathOptAnalyzer._verbose_summarize( + io::IO, + ::Type{LargeBoundCoefficient}, +) return print( io, """ @@ -338,7 +347,7 @@ function ModelAnalyzer._verbose_summarize(io::IO, ::Type{LargeBoundCoefficient}) ) end -function ModelAnalyzer._verbose_summarize(io::IO, ::Type{SmallRHSCoefficient}) +function MathOptAnalyzer._verbose_summarize(io::IO, ::Type{SmallRHSCoefficient}) return print( io, """ @@ -368,7 +377,7 @@ function ModelAnalyzer._verbose_summarize(io::IO, ::Type{SmallRHSCoefficient}) ) end -function ModelAnalyzer._verbose_summarize(io::IO, ::Type{LargeRHSCoefficient}) +function MathOptAnalyzer._verbose_summarize(io::IO, ::Type{LargeRHSCoefficient}) return print( io, """ @@ -398,7 +407,7 @@ function ModelAnalyzer._verbose_summarize(io::IO, ::Type{LargeRHSCoefficient}) ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{SmallObjectiveCoefficient}, ) @@ -431,7 +440,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{LargeObjectiveCoefficient}, ) @@ -464,7 +473,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{SmallObjectiveQuadraticCoefficient}, ) @@ -497,7 +506,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{LargeObjectiveQuadraticCoefficient}, ) @@ -530,7 +539,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{SmallMatrixQuadraticCoefficient}, ) @@ -563,7 +572,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{NonconvexQuadraticObjective}, ) @@ -599,7 +608,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{NonconvexQuadraticConstraint}, ) @@ -634,7 +643,7 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, ::Type{LargeMatrixQuadraticCoefficient}, ) @@ -667,222 +676,242 @@ function ModelAnalyzer._verbose_summarize( ) end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, issue::VariableNotInConstraints, model, ) - return print(io, ModelAnalyzer._name(issue.ref, model)) + return print(io, MathOptAnalyzer._name(issue.ref, model)) end -function ModelAnalyzer._summarize(io::IO, issue::EmptyConstraint, model) - return print(io, ModelAnalyzer._name(issue.ref, model)) +function MathOptAnalyzer._summarize(io::IO, issue::EmptyConstraint, model) + return print(io, MathOptAnalyzer._name(issue.ref, model)) end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, issue::VariableBoundAsConstraint, model, ) - return print(io, ModelAnalyzer._name(issue.ref, model)) + return print(io, MathOptAnalyzer._name(issue.ref, model)) end -function ModelAnalyzer._summarize(io::IO, issue::DenseConstraint, model) - return print(io, ModelAnalyzer._name(issue.ref, model), " : ", issue.nnz) +function MathOptAnalyzer._summarize(io::IO, issue::DenseConstraint, model) + return print(io, MathOptAnalyzer._name(issue.ref, model), " : ", issue.nnz) end -function ModelAnalyzer._summarize(io::IO, issue::SmallMatrixCoefficient, model) +function MathOptAnalyzer._summarize( + io::IO, + issue::SmallMatrixCoefficient, + model, +) return print( io, - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " -- ", - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " : ", issue.coefficient, ) end -function ModelAnalyzer._summarize(io::IO, issue::LargeMatrixCoefficient, model) +function MathOptAnalyzer._summarize( + io::IO, + issue::LargeMatrixCoefficient, + model, +) return print( io, - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " -- ", - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " : ", issue.coefficient, ) end -function ModelAnalyzer._summarize(io::IO, issue::SmallBoundCoefficient, model) +function MathOptAnalyzer._summarize(io::IO, issue::SmallBoundCoefficient, model) return print( io, - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " : ", issue.coefficient, ) end -function ModelAnalyzer._summarize(io::IO, issue::LargeBoundCoefficient, model) +function MathOptAnalyzer._summarize(io::IO, issue::LargeBoundCoefficient, model) return print( io, - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " : ", issue.coefficient, ) end -function ModelAnalyzer._summarize(io::IO, issue::SmallRHSCoefficient, model) +function MathOptAnalyzer._summarize(io::IO, issue::SmallRHSCoefficient, model) return print( io, - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " : ", issue.coefficient, ) end -function ModelAnalyzer._summarize(io::IO, issue::LargeRHSCoefficient, model) +function MathOptAnalyzer._summarize(io::IO, issue::LargeRHSCoefficient, model) return print( io, - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " : ", issue.coefficient, ) end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, issue::SmallObjectiveCoefficient, model, ) return print( io, - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " : ", issue.coefficient, ) end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, issue::LargeObjectiveCoefficient, model, ) return print( io, - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " : ", issue.coefficient, ) end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, issue::SmallObjectiveQuadraticCoefficient, model, ) return print( io, - ModelAnalyzer._name(issue.variable1, model), + MathOptAnalyzer._name(issue.variable1, model), " -- ", - ModelAnalyzer._name(issue.variable2, model), + MathOptAnalyzer._name(issue.variable2, model), " : ", issue.coefficient, ) end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, issue::LargeObjectiveQuadraticCoefficient, model, ) return print( io, - ModelAnalyzer._name(issue.variable1, model), + MathOptAnalyzer._name(issue.variable1, model), " -- ", - ModelAnalyzer._name(issue.variable2, model), + MathOptAnalyzer._name(issue.variable2, model), " : ", issue.coefficient, ) end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, issue::SmallMatrixQuadraticCoefficient, model, ) return print( io, - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " -- ", - ModelAnalyzer._name(issue.variable1, model), + MathOptAnalyzer._name(issue.variable1, model), " -- ", - ModelAnalyzer._name(issue.variable2, model), + MathOptAnalyzer._name(issue.variable2, model), " : ", issue.coefficient, ) end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, issue::LargeMatrixQuadraticCoefficient, model, ) return print( io, - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " -- ", - ModelAnalyzer._name(issue.variable1, model), + MathOptAnalyzer._name(issue.variable1, model), " -- ", - ModelAnalyzer._name(issue.variable2, model), + MathOptAnalyzer._name(issue.variable2, model), " : ", issue.coefficient, ) end -function ModelAnalyzer._summarize(io::IO, ::NonconvexQuadraticObjective, model) +function MathOptAnalyzer._summarize( + io::IO, + ::NonconvexQuadraticObjective, + model, +) return print(io, "Objective is Nonconvex quadratic") end -function ModelAnalyzer._summarize( +function MathOptAnalyzer._summarize( io::IO, issue::NonconvexQuadraticConstraint, model, ) - return print(io, ModelAnalyzer._name(issue.ref, model)) + return print(io, MathOptAnalyzer._name(issue.ref, model)) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::VariableNotInConstraints, model, ) - return print(io, "Variable: ", ModelAnalyzer._name(issue.ref, model)) + return print(io, "Variable: ", MathOptAnalyzer._name(issue.ref, model)) end -function ModelAnalyzer._verbose_summarize(io::IO, issue::EmptyConstraint, model) - return print(io, "Constraint: ", ModelAnalyzer._name(issue.ref, model)) +function MathOptAnalyzer._verbose_summarize( + io::IO, + issue::EmptyConstraint, + model, +) + return print(io, "Constraint: ", MathOptAnalyzer._name(issue.ref, model)) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::VariableBoundAsConstraint, model, ) - return print(io, "Constraint: ", ModelAnalyzer._name(issue.ref, model)) + return print(io, "Constraint: ", MathOptAnalyzer._name(issue.ref, model)) end -function ModelAnalyzer._verbose_summarize(io::IO, issue::DenseConstraint, model) +function MathOptAnalyzer._verbose_summarize( + io::IO, + issue::DenseConstraint, + model, +) return print( io, "Constraint: ", - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " with ", issue.nnz, " non zero coefficients", ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::SmallMatrixCoefficient, model, @@ -890,15 +919,15 @@ function ModelAnalyzer._verbose_summarize( return print( io, "(Constraint -- Variable): (", - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " -- ", - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), ") with coefficient ", issue.coefficient, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::LargeMatrixCoefficient, model, @@ -906,15 +935,15 @@ function ModelAnalyzer._verbose_summarize( return print( io, "(Constraint -- Variable): (", - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " -- ", - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), ") with coefficient ", issue.coefficient, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::SmallBoundCoefficient, model, @@ -922,13 +951,13 @@ function ModelAnalyzer._verbose_summarize( return print( io, "Variable: ", - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " with bound ", issue.coefficient, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::LargeBoundCoefficient, model, @@ -936,13 +965,13 @@ function ModelAnalyzer._verbose_summarize( return print( io, "Variable: ", - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " with bound ", issue.coefficient, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::SmallRHSCoefficient, model, @@ -950,13 +979,13 @@ function ModelAnalyzer._verbose_summarize( return print( io, "Constraint: ", - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " with right-hand-side ", issue.coefficient, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::LargeRHSCoefficient, model, @@ -964,13 +993,13 @@ function ModelAnalyzer._verbose_summarize( return print( io, "Constraint: ", - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " with right-hand-side ", issue.coefficient, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::SmallObjectiveCoefficient, model, @@ -978,13 +1007,13 @@ function ModelAnalyzer._verbose_summarize( return print( io, "Variable: ", - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " with coefficient ", issue.coefficient, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::LargeObjectiveCoefficient, model, @@ -992,13 +1021,13 @@ function ModelAnalyzer._verbose_summarize( return print( io, "Variable: ", - ModelAnalyzer._name(issue.variable, model), + MathOptAnalyzer._name(issue.variable, model), " with coefficient ", issue.coefficient, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::SmallObjectiveQuadraticCoefficient, model, @@ -1006,15 +1035,15 @@ function ModelAnalyzer._verbose_summarize( return print( io, "(Variable -- Variable): (", - ModelAnalyzer._name(issue.variable1, model), + MathOptAnalyzer._name(issue.variable1, model), " -- ", - ModelAnalyzer._name(issue.variable2, model), + MathOptAnalyzer._name(issue.variable2, model), ") with coefficient ", issue.coefficient, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::LargeObjectiveQuadraticCoefficient, model, @@ -1022,15 +1051,15 @@ function ModelAnalyzer._verbose_summarize( return print( io, "(Variable -- Variable): (", - ModelAnalyzer._name(issue.variable1, model), + MathOptAnalyzer._name(issue.variable1, model), " -- ", - ModelAnalyzer._name(issue.variable2, model), + MathOptAnalyzer._name(issue.variable2, model), ") with coefficient ", issue.coefficient, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::SmallMatrixQuadraticCoefficient, model, @@ -1038,17 +1067,17 @@ function ModelAnalyzer._verbose_summarize( return print( io, "(Constraint -- Variable -- Variable): (", - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " -- ", - ModelAnalyzer._name(issue.variable1, model), + MathOptAnalyzer._name(issue.variable1, model), " -- ", - ModelAnalyzer._name(issue.variable2, model), + MathOptAnalyzer._name(issue.variable2, model), ") with coefficient ", issue.coefficient, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::LargeMatrixQuadraticCoefficient, model, @@ -1056,141 +1085,147 @@ function ModelAnalyzer._verbose_summarize( return print( io, "(Constraint -- Variable -- Variable): (", - ModelAnalyzer._name(issue.ref, model), + MathOptAnalyzer._name(issue.ref, model), " -- ", - ModelAnalyzer._name(issue.variable1, model), + MathOptAnalyzer._name(issue.variable1, model), " -- ", - ModelAnalyzer._name(issue.variable2, model), + MathOptAnalyzer._name(issue.variable2, model), ") with coefficient ", issue.coefficient, ) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::NonconvexQuadraticObjective, model, ) - return ModelAnalyzer._summarize(io, issue, model) + return MathOptAnalyzer._summarize(io, issue, model) end -function ModelAnalyzer._verbose_summarize( +function MathOptAnalyzer._verbose_summarize( io::IO, issue::NonconvexQuadraticConstraint, model, ) - return print(io, "Constraint: ", ModelAnalyzer._name(issue.ref, model)) + return print(io, "Constraint: ", MathOptAnalyzer._name(issue.ref, model)) end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{VariableNotInConstraints}, ) return data.variables_not_in_constraints end -function ModelAnalyzer.list_of_issues(data::Data, ::Type{EmptyConstraint}) +function MathOptAnalyzer.list_of_issues(data::Data, ::Type{EmptyConstraint}) return data.empty_rows end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{VariableBoundAsConstraint}, ) return data.bound_rows end -function ModelAnalyzer.list_of_issues(data::Data, ::Type{DenseConstraint}) +function MathOptAnalyzer.list_of_issues(data::Data, ::Type{DenseConstraint}) return data.dense_rows end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{SmallMatrixCoefficient}, ) return data.matrix_small end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{LargeMatrixCoefficient}, ) return data.matrix_large end -function ModelAnalyzer.list_of_issues(data::Data, ::Type{SmallBoundCoefficient}) +function MathOptAnalyzer.list_of_issues( + data::Data, + ::Type{SmallBoundCoefficient}, +) return data.bounds_small end -function ModelAnalyzer.list_of_issues(data::Data, ::Type{LargeBoundCoefficient}) +function MathOptAnalyzer.list_of_issues( + data::Data, + ::Type{LargeBoundCoefficient}, +) return data.bounds_large end -function ModelAnalyzer.list_of_issues(data::Data, ::Type{SmallRHSCoefficient}) +function MathOptAnalyzer.list_of_issues(data::Data, ::Type{SmallRHSCoefficient}) return data.rhs_small end -function ModelAnalyzer.list_of_issues(data::Data, ::Type{LargeRHSCoefficient}) +function MathOptAnalyzer.list_of_issues(data::Data, ::Type{LargeRHSCoefficient}) return data.rhs_large end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{SmallObjectiveCoefficient}, ) return data.objective_small end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{LargeObjectiveCoefficient}, ) return data.objective_large end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{SmallObjectiveQuadraticCoefficient}, ) return data.objective_quadratic_small end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{LargeObjectiveQuadraticCoefficient}, ) return data.objective_quadratic_large end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{SmallMatrixQuadraticCoefficient}, ) return data.matrix_quadratic_small end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{LargeMatrixQuadraticCoefficient}, ) return data.matrix_quadratic_large end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{NonconvexQuadraticObjective}, ) return data.nonconvex_objective end -function ModelAnalyzer.list_of_issues( +function MathOptAnalyzer.list_of_issues( data::Data, ::Type{NonconvexQuadraticConstraint}, ) return data.nonconvex_rows end -function ModelAnalyzer.list_of_issue_types(data::Data) +function MathOptAnalyzer.list_of_issue_types(data::Data) ret = Type[] for type in ( VariableNotInConstraints, @@ -1212,7 +1247,7 @@ function ModelAnalyzer.list_of_issue_types(data::Data) NonconvexQuadraticConstraint, NonconvexQuadraticObjective, ) - if !isempty(ModelAnalyzer.list_of_issues(data, type)) + if !isempty(MathOptAnalyzer.list_of_issues(data, type)) push!(ret, type) end end @@ -1266,12 +1301,12 @@ function summarize_ranges(io::IO, data::Data) return end -function ModelAnalyzer.summarize( +function MathOptAnalyzer.summarize( io::IO, data::Data; model = nothing, verbose = true, - max_issues = ModelAnalyzer.DEFAULT_MAX_ISSUES, + max_issues = MathOptAnalyzer.DEFAULT_MAX_ISSUES, configurations = true, dimensions = true, ranges = true, @@ -1289,10 +1324,10 @@ function ModelAnalyzer.summarize( summarize_ranges(io, data) print(io, "\n") end - for issue_type in ModelAnalyzer.list_of_issue_types(data) - issues = ModelAnalyzer.list_of_issues(data, issue_type) + for issue_type in MathOptAnalyzer.list_of_issue_types(data) + issues = MathOptAnalyzer.list_of_issues(data, issue_type) print(io, "\n\n") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( io, issues, model = model, @@ -1305,8 +1340,8 @@ end function Base.show(io::IO, data::Data) n = sum( - length(ModelAnalyzer.list_of_issues(data, T)) for - T in ModelAnalyzer.list_of_issue_types(data); + length(MathOptAnalyzer.list_of_issues(data, T)) for + T in MathOptAnalyzer.list_of_issue_types(data); init = 0, ) return print(io, "Numerical analysis found $n issues") diff --git a/test/runtests.jl b/test/runtests.jl index 3c8b08f..cdafea7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,7 +5,7 @@ using Test -@testset "ModelAnalyzer" begin +@testset "MathOptAnalyzer" begin for file in readdir(@__DIR__) if startswith(file, "test_") && endswith(file, ".jl") @testset "$file" begin diff --git a/test/test_Feasibility.jl b/test/test_Feasibility.jl index 3948fab..7902a67 100644 --- a/test/test_Feasibility.jl +++ b/test/test_Feasibility.jl @@ -5,7 +5,7 @@ module TestFeasibility -using ModelAnalyzer +using MathOptAnalyzer using Test using JuMP import HiGHS @@ -25,36 +25,36 @@ function test_no_solution() model = Model() @variable(model, x, Bin) # do not support binary - @test_throws "No primal" ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + @test_throws "No primal" MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, ) # no dual solutions available # @test_throws ErrorException - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 1.0), dual_point = Dict(), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test isempty(list) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 1.0), # dual_point = Dict(), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test isempty(list) # non linear in primal accepted @constraint(model, c, x^4 >= 0) # this will make the model non-linear - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 1.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test isempty(list) end @@ -63,127 +63,129 @@ function test_only_bounds() @variable(model, x >= 0) @objective(model, Min, x) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.0), dual_point = Dict(JuMP.index(LowerBoundRef(x)) => 1.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test isempty(list) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => -1.0), dual_point = Dict(JuMP.index(LowerBoundRef(x)) => 1.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test list == Type[ - ModelAnalyzer.Feasibility.PrimalViolation, - ModelAnalyzer.Feasibility.ComplemetarityViolation, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.PrimalViolation, + MathOptAnalyzer.Feasibility.ComplemetarityViolation, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ] - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.PrimalViolation, + MathOptAnalyzer.Feasibility.PrimalViolation, ) - @test ret[] == ModelAnalyzer.Feasibility.PrimalViolation( + @test ret[] == MathOptAnalyzer.Feasibility.PrimalViolation( JuMP.index(LowerBoundRef(x)), 1.0, ) - @test ModelAnalyzer.constraint(ret[], model) == LowerBoundRef(x) - @test ModelAnalyzer.value(ret[]) == 1.0 - ret = ModelAnalyzer.list_of_issues( + @test MathOptAnalyzer.constraint(ret[], model) == LowerBoundRef(x) + @test MathOptAnalyzer.value(ret[]) == 1.0 + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.ComplemetarityViolation, + MathOptAnalyzer.Feasibility.ComplemetarityViolation, ) - @test ret[] == ModelAnalyzer.Feasibility.ComplemetarityViolation( + @test ret[] == MathOptAnalyzer.Feasibility.ComplemetarityViolation( JuMP.index(LowerBoundRef(x)), -1.0, ) - @test ModelAnalyzer.constraint(ret[], model) == LowerBoundRef(x) - @test ModelAnalyzer.value(ret[]) == -1.0 - ret = ModelAnalyzer.list_of_issues( + @test MathOptAnalyzer.constraint(ret[], model) == LowerBoundRef(x) + @test MathOptAnalyzer.value(ret[]) == -1.0 + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ) - @test ret[] == ModelAnalyzer.Feasibility.PrimalDualMismatch(-1.0, 0.0) - @test ModelAnalyzer.values(ret[]) == [-1.0, 0.0] + @test ret[] == MathOptAnalyzer.Feasibility.PrimalDualMismatch(-1.0, 0.0) + @test MathOptAnalyzer.values(ret[]) == [-1.0, 0.0] - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 1.0), dual_point = Dict(JuMP.index(LowerBoundRef(x)) => 1.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test list == [ - ModelAnalyzer.Feasibility.ComplemetarityViolation, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.ComplemetarityViolation, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ] - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.ComplemetarityViolation, + MathOptAnalyzer.Feasibility.ComplemetarityViolation, ) - @test ret[] == ModelAnalyzer.Feasibility.ComplemetarityViolation( + @test ret[] == MathOptAnalyzer.Feasibility.ComplemetarityViolation( JuMP.index(LowerBoundRef(x)), 1.0, ) - @test ModelAnalyzer.constraint(ret[], model) == LowerBoundRef(x) - @test ModelAnalyzer.value(ret[]) == 1.0 - ret = ModelAnalyzer.list_of_issues( + @test MathOptAnalyzer.constraint(ret[], model) == LowerBoundRef(x) + @test MathOptAnalyzer.value(ret[]) == 1.0 + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ) - @test ret[] == ModelAnalyzer.Feasibility.PrimalDualMismatch(1.0, 0.0) + @test ret[] == MathOptAnalyzer.Feasibility.PrimalDualMismatch(1.0, 0.0) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 1.0), dual_point = Dict(JuMP.index(LowerBoundRef(x)) => -1.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test list == [ - ModelAnalyzer.Feasibility.DualConstraintViolation, - ModelAnalyzer.Feasibility.DualConstrainedVariableViolation, - ModelAnalyzer.Feasibility.ComplemetarityViolation, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.DualConstraintViolation, + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation, + MathOptAnalyzer.Feasibility.ComplemetarityViolation, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ] - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstraintViolation, + MathOptAnalyzer.Feasibility.DualConstraintViolation, ) - @test ret[] == - ModelAnalyzer.Feasibility.DualConstraintViolation(JuMP.index(x), 2.0) - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.value(ret[]) == 2.0 - ret = ModelAnalyzer.list_of_issues( + @test ret[] == MathOptAnalyzer.Feasibility.DualConstraintViolation( + JuMP.index(x), + 2.0, + ) + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.value(ret[]) == 2.0 + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstrainedVariableViolation, + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation, ) - @test ret[] == ModelAnalyzer.Feasibility.DualConstrainedVariableViolation( + @test ret[] == MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation( JuMP.index(LowerBoundRef(x)), 1.0, ) - @test ModelAnalyzer.constraint(ret[], model) == LowerBoundRef(x) - @test ModelAnalyzer.value(ret[]) == 1.0 - ret = ModelAnalyzer.list_of_issues( + @test MathOptAnalyzer.constraint(ret[], model) == LowerBoundRef(x) + @test MathOptAnalyzer.value(ret[]) == 1.0 + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.ComplemetarityViolation, + MathOptAnalyzer.Feasibility.ComplemetarityViolation, ) - @test ret[] == ModelAnalyzer.Feasibility.ComplemetarityViolation( + @test ret[] == MathOptAnalyzer.Feasibility.ComplemetarityViolation( JuMP.index(LowerBoundRef(x)), -1.0, ) - @test ModelAnalyzer.constraint(ret[], model) == LowerBoundRef(x) - @test ModelAnalyzer.value(ret[]) == -1.0 - ret = ModelAnalyzer.list_of_issues( + @test MathOptAnalyzer.constraint(ret[], model) == LowerBoundRef(x) + @test MathOptAnalyzer.value(ret[]) == -1.0 + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ) - @test ret[] == ModelAnalyzer.Feasibility.PrimalDualMismatch(1.0, 0.0) + @test ret[] == MathOptAnalyzer.Feasibility.PrimalDualMismatch(1.0, 0.0) return end @@ -200,117 +202,126 @@ function test_no_lb() # mayber force fail here # @test_throws ErrorException - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.0), dual_point = Dict(JuMP.index(c) => 1.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test isempty(list) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => -1.0), dual_point = Dict(JuMP.index(c) => 1.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test list == Type[ - ModelAnalyzer.Feasibility.PrimalViolation, - ModelAnalyzer.Feasibility.ComplemetarityViolation, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.PrimalViolation, + MathOptAnalyzer.Feasibility.ComplemetarityViolation, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ] - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.PrimalViolation, + MathOptAnalyzer.Feasibility.PrimalViolation, ) - @test ret[] == ModelAnalyzer.Feasibility.PrimalViolation(JuMP.index(c), 1.0) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.value(ret[]) == 1.0 - ret = ModelAnalyzer.list_of_issues( + @test ret[] == + MathOptAnalyzer.Feasibility.PrimalViolation(JuMP.index(c), 1.0) + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.value(ret[]) == 1.0 + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.ComplemetarityViolation, + MathOptAnalyzer.Feasibility.ComplemetarityViolation, ) - @test ret[] == - ModelAnalyzer.Feasibility.ComplemetarityViolation(JuMP.index(c), -1.0) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.value(ret[]) == -1.0 - ret = ModelAnalyzer.list_of_issues( + @test ret[] == MathOptAnalyzer.Feasibility.ComplemetarityViolation( + JuMP.index(c), + -1.0, + ) + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.value(ret[]) == -1.0 + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ) - @test ret[] == ModelAnalyzer.Feasibility.PrimalDualMismatch(-1.0, 0.0) + @test ret[] == MathOptAnalyzer.Feasibility.PrimalDualMismatch(-1.0, 0.0) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 1.0), dual_point = Dict(JuMP.index(c) => 1.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test list == [ - ModelAnalyzer.Feasibility.ComplemetarityViolation, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.ComplemetarityViolation, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ] - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.ComplemetarityViolation, + MathOptAnalyzer.Feasibility.ComplemetarityViolation, ) - @test ret[] == - ModelAnalyzer.Feasibility.ComplemetarityViolation(JuMP.index(c), 1.0) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.value(ret[]) == 1.0 - ret = ModelAnalyzer.list_of_issues( + @test ret[] == MathOptAnalyzer.Feasibility.ComplemetarityViolation( + JuMP.index(c), + 1.0, + ) + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.value(ret[]) == 1.0 + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ) - @test ret[] == ModelAnalyzer.Feasibility.PrimalDualMismatch(1.0, 0.0) + @test ret[] == MathOptAnalyzer.Feasibility.PrimalDualMismatch(1.0, 0.0) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 1.0), dual_point = Dict(JuMP.index(c) => -1.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test list == [ - ModelAnalyzer.Feasibility.DualConstraintViolation, - ModelAnalyzer.Feasibility.DualConstrainedVariableViolation, - ModelAnalyzer.Feasibility.ComplemetarityViolation, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.DualConstraintViolation, + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation, + MathOptAnalyzer.Feasibility.ComplemetarityViolation, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ] - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstraintViolation, + MathOptAnalyzer.Feasibility.DualConstraintViolation, ) - @test ret[] == - ModelAnalyzer.Feasibility.DualConstraintViolation(JuMP.index(x), 2.0) - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.value(ret[]) == 2.0 - ret = ModelAnalyzer.list_of_issues( + @test ret[] == MathOptAnalyzer.Feasibility.DualConstraintViolation( + JuMP.index(x), + 2.0, + ) + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.value(ret[]) == 2.0 + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstrainedVariableViolation, + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation, ) - @test ret[] == ModelAnalyzer.Feasibility.DualConstrainedVariableViolation( + @test ret[] == MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation( JuMP.index(c), 1.0, ) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.value(ret[]) == 1.0 - ret = ModelAnalyzer.list_of_issues( + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.value(ret[]) == 1.0 + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.ComplemetarityViolation, + MathOptAnalyzer.Feasibility.ComplemetarityViolation, ) - @test ret[] == - ModelAnalyzer.Feasibility.ComplemetarityViolation(JuMP.index(c), -1.0) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.value(ret[]) == -1.0 - ret = ModelAnalyzer.list_of_issues( + @test ret[] == MathOptAnalyzer.Feasibility.ComplemetarityViolation( + JuMP.index(c), + -1.0, + ) + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.value(ret[]) == -1.0 + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ) - @test ret[] == ModelAnalyzer.Feasibility.PrimalDualMismatch(1.0, 0.0) + @test ret[] == MathOptAnalyzer.Feasibility.PrimalDualMismatch(1.0, 0.0) end function test_lb0() @@ -322,8 +333,8 @@ function test_lb0() # Max 0.5 * y # Subject to # ... - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.5), dual_point = Dict( @@ -331,11 +342,11 @@ function test_lb0() JuMP.index(LowerBoundRef(x)) => 0.0, ), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test isempty(list) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.5), dual_point = Dict( @@ -343,22 +354,24 @@ function test_lb0() JuMP.index(LowerBoundRef(x)) => 0.0, ), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test list == [ - ModelAnalyzer.Feasibility.DualConstraintViolation, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.DualConstraintViolation, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ] - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstraintViolation, + MathOptAnalyzer.Feasibility.DualConstraintViolation, ) - @test ret[] == - ModelAnalyzer.Feasibility.DualConstraintViolation(JuMP.index(x), 2.3) - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.value(ret[]) == 2.3 + @test ret[] == MathOptAnalyzer.Feasibility.DualConstraintViolation( + JuMP.index(x), + 2.3, + ) + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.value(ret[]) == 2.3 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.5), dual_point = Dict( @@ -366,30 +379,32 @@ function test_lb0() JuMP.index(LowerBoundRef(x)) => 0.0, ), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test list == [ - ModelAnalyzer.Feasibility.DualConstraintViolation, - ModelAnalyzer.Feasibility.DualConstrainedVariableViolation, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.DualConstraintViolation, + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ] - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstraintViolation, + MathOptAnalyzer.Feasibility.DualConstraintViolation, ) - @test ret[] == - ModelAnalyzer.Feasibility.DualConstraintViolation(JuMP.index(x), 4.3) - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.value(ret[]) == 4.3 - ret = ModelAnalyzer.list_of_issues( + @test ret[] == MathOptAnalyzer.Feasibility.DualConstraintViolation( + JuMP.index(x), + 4.3, + ) + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.value(ret[]) == 4.3 + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstrainedVariableViolation, + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation, ) - @test ret[] == ModelAnalyzer.Feasibility.DualConstrainedVariableViolation( + @test ret[] == MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation( JuMP.index(c), 3.3, ) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.value(ret[]) == 3.3 + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.value(ret[]) == 3.3 return end @@ -403,8 +418,8 @@ function test_lb2() # Subject to # ... - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 2.0), dual_point = Dict( @@ -412,11 +427,11 @@ function test_lb2() JuMP.index(LowerBoundRef(x)) => 1.0, ), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test isempty(list) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 2.0), dual_point = Dict( @@ -424,17 +439,19 @@ function test_lb2() JuMP.index(LowerBoundRef(x)) => 0.0, ), ) - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstraintViolation, + MathOptAnalyzer.Feasibility.DualConstraintViolation, ) - @test ret[] == - ModelAnalyzer.Feasibility.DualConstraintViolation(JuMP.index(x), 2.3) - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.value(ret[]) == 2.3 + @test ret[] == MathOptAnalyzer.Feasibility.DualConstraintViolation( + JuMP.index(x), + 2.3, + ) + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.value(ret[]) == 2.3 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 2.0), dual_point = Dict( @@ -442,25 +459,27 @@ function test_lb2() JuMP.index(LowerBoundRef(x)) => 0.0, ), ) - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstraintViolation, + MathOptAnalyzer.Feasibility.DualConstraintViolation, ) - @test ret[] == - ModelAnalyzer.Feasibility.DualConstraintViolation(JuMP.index(x), 4.3) - ret = ModelAnalyzer.list_of_issues( + @test ret[] == MathOptAnalyzer.Feasibility.DualConstraintViolation( + JuMP.index(x), + 4.3, + ) + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstrainedVariableViolation, + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation, ) - @test ret[] == ModelAnalyzer.Feasibility.DualConstrainedVariableViolation( + @test ret[] == MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation( JuMP.index(c), 3.3, ) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.value(ret[]) == 3.3 + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.value(ret[]) == 3.3 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 2.0), dual_point = Dict( @@ -468,31 +487,35 @@ function test_lb2() JuMP.index(LowerBoundRef(x)) => -1.0, ), ) - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstraintViolation, + MathOptAnalyzer.Feasibility.DualConstraintViolation, ) - @test ret[] == - ModelAnalyzer.Feasibility.DualConstraintViolation(JuMP.index(x), 5.3) - ret = ModelAnalyzer.list_of_issues( + @test ret[] == MathOptAnalyzer.Feasibility.DualConstraintViolation( + JuMP.index(x), + 5.3, + ) + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstrainedVariableViolation, + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation, ) - @test ret[1] == ModelAnalyzer.Feasibility.DualConstrainedVariableViolation( + @test ret[1] == + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation( JuMP.index(c), 3.3, ) - @test ModelAnalyzer.constraint(ret[1], model) == c - @test ModelAnalyzer.value(ret[1]) == 3.3 - @test ret[2] == ModelAnalyzer.Feasibility.DualConstrainedVariableViolation( + @test MathOptAnalyzer.constraint(ret[1], model) == c + @test MathOptAnalyzer.value(ret[1]) == 3.3 + @test ret[2] == + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation( JuMP.index(LowerBoundRef(x)), 1.0, ) - @test ModelAnalyzer.constraint(ret[2], model) == LowerBoundRef(x) - @test ModelAnalyzer.value(ret[2]) == 1.0 + @test MathOptAnalyzer.constraint(ret[2], model) == LowerBoundRef(x) + @test MathOptAnalyzer.value(ret[2]) == 1.0 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 2.0), dual_point = Dict( @@ -502,16 +525,16 @@ function test_lb2() skip_missing = true, ) - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstrainedVariableViolation, + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation, ) - @test ret[] == ModelAnalyzer.Feasibility.DualConstrainedVariableViolation( + @test ret[] == MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation( JuMP.index(c), 3.3, ) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.value(ret[]) == 3.3 + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.value(ret[]) == 3.3 return end @@ -524,9 +547,10 @@ function test_analyse_simple() optimize!(model) - data = ModelAnalyzer.analyze(ModelAnalyzer.Feasibility.Analyzer(), model) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Feasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 @@ -542,9 +566,10 @@ function test_analyse_simple_direct() optimize!(model) - data = ModelAnalyzer.analyze(ModelAnalyzer.Feasibility.Analyzer(), model) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Feasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 @@ -558,7 +583,7 @@ function test_with_interval() @constraint(model, c, 2 * x in MOI.Interval(0.0, 3.0)) @objective(model, Min, x) optimize!(model) - @test !ModelAnalyzer.Feasibility._can_dualize(JuMP.backend(model)) + @test !MathOptAnalyzer.Feasibility._can_dualize(JuMP.backend(model)) return end @@ -580,9 +605,10 @@ function test_analyse_many_constraint_types() optimize!(model) - data = ModelAnalyzer.analyze(ModelAnalyzer.Feasibility.Analyzer(), model) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Feasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 @@ -598,14 +624,15 @@ function test_analyse_mip() optimize!(model) - data = ModelAnalyzer.analyze(ModelAnalyzer.Feasibility.Analyzer(), model) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Feasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 buf = IOBuffer() - ModelAnalyzer.summarize(buf, data) + MathOptAnalyzer.summarize(buf, data) buf = IOBuffer() Base.show(buf, data) @@ -623,97 +650,104 @@ function test_analyse_no_opt() @objective(model, Min, x) # test no primal point - @test_throws ErrorException ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + @test_throws ErrorException MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, ) # test no dual point - @test_throws ErrorException ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + @test_throws ErrorException MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 1.0), dual_check = true, ) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 1.0), dual_check = false, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => -1.0), dual_check = false, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) - @test ret[] == ModelAnalyzer.Feasibility.PrimalViolation(JuMP.index(c), 1.0) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.value(ret[]) == 1.0 + ret = MathOptAnalyzer.list_of_issues(data, list[1]) + @test ret[] == + MathOptAnalyzer.Feasibility.PrimalViolation(JuMP.index(c), 1.0) + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.value(ret[]) == 1.0 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 1.0), dual_point = Dict(JuMP.index(c) => 1.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 2 - ret = ModelAnalyzer.list_of_issues(data, list[1]) - @test ret[1] == - ModelAnalyzer.Feasibility.ComplemetarityViolation(JuMP.index(c), 1.0) - @test ModelAnalyzer.constraint(ret[1], model) == c - @test ModelAnalyzer.value(ret[1]) == 1.0 - ret = ModelAnalyzer.list_of_issues(data, list[2]) - @test ret[1] == ModelAnalyzer.Feasibility.PrimalDualMismatch(1.0, 0.0) - - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + ret = MathOptAnalyzer.list_of_issues(data, list[1]) + @test ret[1] == MathOptAnalyzer.Feasibility.ComplemetarityViolation( + JuMP.index(c), + 1.0, + ) + @test MathOptAnalyzer.constraint(ret[1], model) == c + @test MathOptAnalyzer.value(ret[1]) == 1.0 + ret = MathOptAnalyzer.list_of_issues(data, list[2]) + @test ret[1] == MathOptAnalyzer.Feasibility.PrimalDualMismatch(1.0, 0.0) + + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.0), dual_point = Dict(JuMP.index(c) => 1.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => -1.0), dual_point = Dict(JuMP.index(c) => 2.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 4 - ret = ModelAnalyzer.list_of_issues(data, list[1]) - @test ret[1] == - ModelAnalyzer.Feasibility.PrimalViolation(JuMP.index(c), 1.0) - @test ModelAnalyzer.constraint(ret[1], model) == c - @test ModelAnalyzer.value(ret[1]) == 1.0 - ret = ModelAnalyzer.list_of_issues(data, list[2]) - @test ret[1] == - ModelAnalyzer.Feasibility.DualConstraintViolation(JuMP.index(x), 1.0) - @test ModelAnalyzer.variable(ret[1], model) == x - @test ModelAnalyzer.value(ret[1]) == 1.0 - ret = ModelAnalyzer.list_of_issues(data, list[3]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test ret[1] == - ModelAnalyzer.Feasibility.ComplemetarityViolation(JuMP.index(c), -2.0) - @test ModelAnalyzer.constraint(ret[1], model) == c - @test ModelAnalyzer.value(ret[1]) == -2.0 - ret = ModelAnalyzer.list_of_issues(data, list[4]) - @test ret[1] == ModelAnalyzer.Feasibility.PrimalDualMismatch(-1.0, 0.0) + MathOptAnalyzer.Feasibility.PrimalViolation(JuMP.index(c), 1.0) + @test MathOptAnalyzer.constraint(ret[1], model) == c + @test MathOptAnalyzer.value(ret[1]) == 1.0 + ret = MathOptAnalyzer.list_of_issues(data, list[2]) + @test ret[1] == MathOptAnalyzer.Feasibility.DualConstraintViolation( + JuMP.index(x), + 1.0, + ) + @test MathOptAnalyzer.variable(ret[1], model) == x + @test MathOptAnalyzer.value(ret[1]) == 1.0 + ret = MathOptAnalyzer.list_of_issues(data, list[3]) + @test ret[1] == MathOptAnalyzer.Feasibility.ComplemetarityViolation( + JuMP.index(c), + -2.0, + ) + @test MathOptAnalyzer.constraint(ret[1], model) == c + @test MathOptAnalyzer.value(ret[1]) == -2.0 + ret = MathOptAnalyzer.list_of_issues(data, list[4]) + @test ret[1] == MathOptAnalyzer.Feasibility.PrimalDualMismatch(-1.0, 0.0) buf = IOBuffer() - ModelAnalyzer.summarize(buf, data) + MathOptAnalyzer.summarize(buf, data) - ModelAnalyzer.summarize(buf, data, verbose = false) + MathOptAnalyzer.summarize(buf, data, verbose = false) return end @@ -723,43 +757,43 @@ function test_dual_constrained_variable() @variable(model, x >= 0) @objective(model, Min, x) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 1.0), dual_point = Dict(JuMP.index(LowerBoundRef(x)) => -1.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test list == [ - ModelAnalyzer.Feasibility.DualConstraintViolation, - ModelAnalyzer.Feasibility.DualConstrainedVariableViolation, - ModelAnalyzer.Feasibility.ComplemetarityViolation, - ModelAnalyzer.Feasibility.PrimalDualMismatch, + MathOptAnalyzer.Feasibility.DualConstraintViolation, + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation, + MathOptAnalyzer.Feasibility.ComplemetarityViolation, + MathOptAnalyzer.Feasibility.PrimalDualMismatch, ] - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualConstrainedVariableViolation, + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation, ) - @test ret[] == ModelAnalyzer.Feasibility.DualConstrainedVariableViolation( + @test ret[] == MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation( JuMP.index(LowerBoundRef(x)), 1.0, ) - @test ModelAnalyzer.constraint(ret[], model) == LowerBoundRef(x) - @test ModelAnalyzer.value(ret[]) == 1.0 + @test MathOptAnalyzer.constraint(ret[], model) == LowerBoundRef(x) + @test MathOptAnalyzer.value(ret[]) == 1.0 buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Feasibility.DualConstrainedVariableViolation, + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation, verbose = true, ) - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Feasibility.DualConstrainedVariableViolation, + MathOptAnalyzer.Feasibility.DualConstrainedVariableViolation, verbose = false, ) - ModelAnalyzer.summarize(buf, ret[], verbose = true) - ModelAnalyzer.summarize(buf, ret[], verbose = false) + MathOptAnalyzer.summarize(buf, ret[], verbose = true) + MathOptAnalyzer.summarize(buf, ret[], verbose = false) return end @@ -768,28 +802,31 @@ end function test_lowlevel_mismatch() buf = IOBuffer() issues = [] - push!(issues, ModelAnalyzer.Feasibility.PrimalObjectiveMismatch(0.0, 1.0)) - push!(issues, ModelAnalyzer.Feasibility.DualObjectiveMismatch(0.0, 1.0)) - push!(issues, ModelAnalyzer.Feasibility.PrimalDualSolverMismatch(0.0, 1.0)) + push!(issues, MathOptAnalyzer.Feasibility.PrimalObjectiveMismatch(0.0, 1.0)) + push!(issues, MathOptAnalyzer.Feasibility.DualObjectiveMismatch(0.0, 1.0)) + push!( + issues, + MathOptAnalyzer.Feasibility.PrimalDualSolverMismatch(0.0, 1.0), + ) for verbose in (true, false) - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Feasibility.PrimalObjectiveMismatch, + MathOptAnalyzer.Feasibility.PrimalObjectiveMismatch, verbose = verbose, ) - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Feasibility.DualObjectiveMismatch, + MathOptAnalyzer.Feasibility.DualObjectiveMismatch, verbose = verbose, ) - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Feasibility.PrimalDualSolverMismatch, + MathOptAnalyzer.Feasibility.PrimalDualSolverMismatch, verbose = verbose, ) for issue in issues # ensure we can summarize each issue type - ModelAnalyzer.summarize(buf, issue, verbose = verbose) + MathOptAnalyzer.summarize(buf, issue, verbose = verbose) end end @@ -804,33 +841,33 @@ function test_skip_missing_primal() @constraint(model, c, x + y >= 0) @objective(model, Min, x) - @test_throws ErrorException ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + @test_throws ErrorException MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 1.0), # dual_point = Dict(JuMP.index(c) => 1.0), skip_missing = false, dual_check = false, ) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 1.0), # dual_point = Dict(JuMP.index(c) => 1.0), skip_missing = true, dual_check = false, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(y) => 1.0), dual_point = Dict(JuMP.index(c) => 1.0), skip_missing = true, dual_check = true, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 return end @@ -843,23 +880,23 @@ function test_skip_missing_primal_var_not_in_con() @constraint(model, c, x >= 0) @objective(model, Min, x + y) - @test_throws ErrorException ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + @test_throws ErrorException MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.0), # dual_point = Dict(JuMP.index(c) => 1.0), skip_missing = false, dual_check = false, ) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.0), # dual_point = Dict(JuMP.index(c) => 1.0), skip_missing = true, dual_check = false, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 return end @@ -872,23 +909,23 @@ function test_skip_missing_primal_empty_con() @constraint(model, c2, x >= 0) @objective(model, Min, x) - @test_throws ErrorException ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + @test_throws ErrorException MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.0), dual_point = Dict(JuMP.index(c2) => 1.0), skip_missing = false, dual_check = true, ) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.0), dual_point = Dict(JuMP.index(c2) => 1.0), skip_missing = true, dual_check = true, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 return end @@ -901,23 +938,23 @@ function test_skip_missing_dual() @constraint(model, c2, x >= 2) @objective(model, Min, x) - @test_throws ErrorException ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + @test_throws ErrorException MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 2.0), dual_point = Dict(JuMP.index(c1) => 1.0), skip_missing = false, dual_check = true, ) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 2.0), dual_point = Dict(JuMP.index(c1) => 0.0), skip_missing = true, dual_check = true, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 return end @@ -929,8 +966,8 @@ function test_dual_bad_size() @constraint(model, c1, x >= 0) @objective(model, Min, x) - @test_throws ErrorException ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + @test_throws ErrorException MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 2.0), dual_point = Dict(JuMP.index(c1) => [1.0, 2.0]), @@ -945,13 +982,13 @@ function test_dual_vector() @constraint(model, c1, [x, 2x - 1] in Nonnegatives()) @objective(model, Min, x) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.5), dual_point = Dict(JuMP.index(c1) => [0.0, 0.5]), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 return end @@ -962,13 +999,13 @@ function test_feasibility_sense() @variable(model, x) @constraint(model, c1, x >= 0) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.0), # dual_point = Dict(JuMP.index(c1) => [0.0, 0.5]), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 return end @@ -980,53 +1017,53 @@ function test_objective() @constraint(model, c, x >= 0) @objective(model, Min, x) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.0), dual_point = Dict(JuMP.index(c) => 1.0), primal_objective = 0.0, dual_objective = 0.0, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.0), dual_point = Dict(JuMP.index(c) => 1.0), primal_objective = 1.0, dual_objective = 0.0, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 2 - @test ModelAnalyzer.list_of_issues( + @test MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.PrimalObjectiveMismatch, - )[] == ModelAnalyzer.Feasibility.PrimalObjectiveMismatch(0.0, 1.0) - @test ModelAnalyzer.list_of_issues( + MathOptAnalyzer.Feasibility.PrimalObjectiveMismatch, + )[] == MathOptAnalyzer.Feasibility.PrimalObjectiveMismatch(0.0, 1.0) + @test MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.PrimalDualSolverMismatch, - )[] == ModelAnalyzer.Feasibility.PrimalDualSolverMismatch(1.0, 0.0) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + MathOptAnalyzer.Feasibility.PrimalDualSolverMismatch, + )[] == MathOptAnalyzer.Feasibility.PrimalDualSolverMismatch(1.0, 0.0) + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.0), dual_point = Dict(JuMP.index(c) => 1.0), primal_objective = 0.0, dual_objective = 1.0, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 2 - @test ModelAnalyzer.list_of_issues( + @test MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.DualObjectiveMismatch, - )[] == ModelAnalyzer.Feasibility.DualObjectiveMismatch(0.0, 1.0) - @test ModelAnalyzer.list_of_issues( + MathOptAnalyzer.Feasibility.DualObjectiveMismatch, + )[] == MathOptAnalyzer.Feasibility.DualObjectiveMismatch(0.0, 1.0) + @test MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Feasibility.PrimalDualSolverMismatch, - )[] == ModelAnalyzer.Feasibility.PrimalDualSolverMismatch(0.0, 1.0) + MathOptAnalyzer.Feasibility.PrimalDualSolverMismatch, + )[] == MathOptAnalyzer.Feasibility.PrimalDualSolverMismatch(0.0, 1.0) return end @@ -1037,13 +1074,13 @@ function test_nl_con() @constraint(model, c1, x^3 == 0) @objective(model, Min, x) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.0), dual_point = Dict(JuMP.index(c1) => 0.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 return end @@ -1055,13 +1092,13 @@ function test_nl_obj() @constraint(model, c1, x == 0) @objective(model, Min, x^3) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Feasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Feasibility.Analyzer(), model, primal_point = Dict(JuMP.index(x) => 0.0), dual_point = Dict(JuMP.index(c1) => 0.0), ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 return end diff --git a/test/test_Infeasibility.jl b/test/test_Infeasibility.jl index e30ebba..815333e 100644 --- a/test/test_Infeasibility.jl +++ b/test/test_Infeasibility.jl @@ -8,7 +8,7 @@ module TestInfeasibility using JuMP using Test import HiGHS -import ModelAnalyzer +import MathOptAnalyzer function runtests() for name in names(@__MODULE__; all = true) @@ -27,45 +27,46 @@ function test_bounds() @variable(model, 2 <= y <= 1) @constraint(model, x + y <= 1) @objective(model, Max, x + y) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 - @test ret[] == ModelAnalyzer.Infeasibility.InfeasibleBounds{Float64}( + @test ret[] == MathOptAnalyzer.Infeasibility.InfeasibleBounds{Float64}( JuMP.index(y), 2.0, 1.0, ) - @test ModelAnalyzer.variable(ret[], model) == y - @test ModelAnalyzer.values(ret[]) == [2.0, 1.0] + @test MathOptAnalyzer.variable(ret[], model) == y + @test MathOptAnalyzer.values(ret[]) == [2.0, 1.0] # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Infeasibility.InfeasibleBounds{Float64}, + MathOptAnalyzer.Infeasibility.InfeasibleBounds{Float64}, ) str = String(take!(buf)) @test startswith(str, "# `InfeasibleBounds`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Infeasibility.InfeasibleBounds{Float64}, + MathOptAnalyzer.Infeasibility.InfeasibleBounds{Float64}, verbose = false, ) str = String(take!(buf)) @test str == "# InfeasibleBounds" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Variable: ") @test contains(str, " with lower bound ") @test contains(str, " and upper bound ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " : ") @test contains(str, " !<= ") - ModelAnalyzer.summarize(buf, data, verbose = false) - ModelAnalyzer.summarize(buf, data, verbose = true) + MathOptAnalyzer.summarize(buf, data, verbose = false) + MathOptAnalyzer.summarize(buf, data, verbose = true) return end @@ -75,49 +76,50 @@ function test_integrality() @variable(model, 2.2 <= y <= 2.9, Int) @constraint(model, x + y <= 1) @objective(model, Max, x + y) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 - @test ret[] == ModelAnalyzer.Infeasibility.InfeasibleIntegrality{Float64}( + @test ret[] == MathOptAnalyzer.Infeasibility.InfeasibleIntegrality{Float64}( JuMP.index(y), 2.2, 2.9, MOI.Integer(), ) - @test ModelAnalyzer.variable(ret[], model) == y - @test ModelAnalyzer.values(ret[]) == [2.2, 2.9] - @test ModelAnalyzer.set(ret[]) == MOI.Integer() + @test MathOptAnalyzer.variable(ret[], model) == y + @test MathOptAnalyzer.values(ret[]) == [2.2, 2.9] + @test MathOptAnalyzer.set(ret[]) == MOI.Integer() # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Infeasibility.InfeasibleIntegrality{Float64}, + MathOptAnalyzer.Infeasibility.InfeasibleIntegrality{Float64}, ) str = String(take!(buf)) @test startswith(str, "# `InfeasibleIntegrality`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Infeasibility.InfeasibleIntegrality{Float64}, + MathOptAnalyzer.Infeasibility.InfeasibleIntegrality{Float64}, verbose = false, ) str = String(take!(buf)) @test str == "# InfeasibleIntegrality" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Variable: ") @test contains(str, " with lower bound ") @test contains(str, " and upper bound ") @test contains(str, " and integrality constraint: ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " : [") @test contains(str, "; ") @test contains(str, "], ") - ModelAnalyzer.summarize(buf, data, verbose = false) - ModelAnalyzer.summarize(buf, data, verbose = true) + MathOptAnalyzer.summarize(buf, data, verbose = false) + MathOptAnalyzer.summarize(buf, data, verbose = true) return end @@ -127,23 +129,24 @@ function test_binary() @variable(model, 0 <= y <= 1, Bin) @constraint(model, x + y <= 1) @objective(model, Max, x + y) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 - @test ret[] == ModelAnalyzer.Infeasibility.InfeasibleIntegrality{Float64}( + @test ret[] == MathOptAnalyzer.Infeasibility.InfeasibleIntegrality{Float64}( JuMP.index(x), 0.5, 0.8, MOI.ZeroOne(), ) - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.values(ret[]) == [0.5, 0.8] - @test ModelAnalyzer.set(ret[]) == MOI.ZeroOne() + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.values(ret[]) == [0.5, 0.8] + @test MathOptAnalyzer.set(ret[]) == MOI.ZeroOne() buf = IOBuffer() - ModelAnalyzer.summarize(buf, data, verbose = false) - ModelAnalyzer.summarize(buf, data, verbose = true) + MathOptAnalyzer.summarize(buf, data, verbose = false) + MathOptAnalyzer.summarize(buf, data, verbose = true) return end @@ -153,50 +156,51 @@ function test_range() @variable(model, 1 <= y <= 11) @constraint(model, c, x + y <= 1) @objective(model, Max, x + y) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 @test ret[] == - ModelAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}( + MathOptAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}( JuMP.index(c), 11.0, 22.0, MOI.LessThan{Float64}(1.0), ) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.values(ret[]) == [11.0, 22.0] - @test ModelAnalyzer.set(ret[]) == MOI.LessThan{Float64}(1.0) + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.values(ret[]) == [11.0, 22.0] + @test MathOptAnalyzer.set(ret[]) == MOI.LessThan{Float64}(1.0) # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}, + MathOptAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}, ) str = String(take!(buf)) @test startswith(str, "# `InfeasibleConstraintRange`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}, + MathOptAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}, verbose = false, ) str = String(take!(buf)) @test str == "# InfeasibleConstraintRange" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Constraint: ") @test contains(str, " with computed lower bound ") @test contains(str, " and computed upper bound ") @test contains(str, " and set: ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " : [") @test contains(str, "; ") @test contains(str, "], !in ") - ModelAnalyzer.summarize(buf, data, verbose = false) - ModelAnalyzer.summarize(buf, data, verbose = true) + MathOptAnalyzer.summarize(buf, data, verbose = false) + MathOptAnalyzer.summarize(buf, data, verbose = true) return end @@ -206,21 +210,22 @@ function test_range_neg() @variable(model, -11 <= y <= -1) @constraint(model, c, x - y <= 1) @objective(model, Max, x + y) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 @test ret[] == - ModelAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}( + MathOptAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}( JuMP.index(c), 11.0, 22.0, MOI.LessThan{Float64}(1.0), ) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.values(ret[]) == [11.0, 22.0] - @test ModelAnalyzer.set(ret[]) == MOI.LessThan{Float64}(1.0) + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.values(ret[]) == [11.0, 22.0] + @test MathOptAnalyzer.set(ret[]) == MOI.LessThan{Float64}(1.0) return end @@ -230,21 +235,22 @@ function test_range_equalto() @variable(model, y == 2) @constraint(model, c, x + y == 1) @objective(model, Max, x + y) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 @test ret[] == - ModelAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}( + MathOptAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}( JuMP.index(c), 3.0, 3.0, MOI.EqualTo{Float64}(1.0), ) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.values(ret[]) == [3.0, 3.0] - @test ModelAnalyzer.set(ret[]) == MOI.EqualTo{Float64}(1.0) + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.values(ret[]) == [3.0, 3.0] + @test MathOptAnalyzer.set(ret[]) == MOI.EqualTo{Float64}(1.0) return end @@ -254,21 +260,22 @@ function test_range_equalto_2() @variable(model, y == 2) @constraint(model, c, 3x + 2y == 1) @objective(model, Max, x + y) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 @test ret[] == - ModelAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}( + MathOptAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}( JuMP.index(c), 7.0, 7.0, MOI.EqualTo{Float64}(1.0), ) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.values(ret[]) == [7.0, 7.0] - @test ModelAnalyzer.set(ret[]) == MOI.EqualTo{Float64}(1.0) + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.values(ret[]) == [7.0, 7.0] + @test MathOptAnalyzer.set(ret[]) == MOI.EqualTo{Float64}(1.0) return end @@ -278,21 +285,22 @@ function test_range_greaterthan() @variable(model, 1 <= y <= 11) @constraint(model, c, x + y >= 100) @objective(model, Max, x + y) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 @test ret[] == - ModelAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}( + MathOptAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}( JuMP.index(c), 11.0, 22.0, MOI.GreaterThan{Float64}(100.0), ) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.values(ret[]) == [11.0, 22.0] - @test ModelAnalyzer.set(ret[]) == MOI.GreaterThan{Float64}(100.0) + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.values(ret[]) == [11.0, 22.0] + @test MathOptAnalyzer.set(ret[]) == MOI.GreaterThan{Float64}(100.0) return end @@ -302,21 +310,22 @@ function test_range_equalto_3() @variable(model, 1 <= y <= 11) @constraint(model, c, x + y == 100) @objective(model, Max, x + y) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 @test ret[] == - ModelAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}( + MathOptAnalyzer.Infeasibility.InfeasibleConstraintRange{Float64}( JuMP.index(c), 11.0, 22.0, MOI.EqualTo{Float64}(100.0), ) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.values(ret[]) == [11.0, 22.0] - @test ModelAnalyzer.set(ret[]) == MOI.EqualTo{Float64}(100.0) + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.values(ret[]) == [11.0, 22.0] + @test MathOptAnalyzer.set(ret[]) == MOI.EqualTo{Float64}(100.0) return end @@ -328,12 +337,12 @@ function test_interval() @constraint(model, c1, x + y <= 1) @objective(model, Max, x + y) optimize!(model) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Infeasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Infeasibility.Analyzer(), model, optimizer = HiGHS.Optimizer, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 end @@ -345,12 +354,12 @@ function test_iis_feasible() @constraint(model, c1, x + y <= 1) @objective(model, Max, x + y) optimize!(model) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Infeasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Infeasibility.Analyzer(), model, optimizer = HiGHS.Optimizer, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 end @@ -363,45 +372,46 @@ function test_iis() @constraint(model, c2, x + y >= 2) @objective(model, Max, x + y) optimize!(model) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Infeasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Infeasibility.Analyzer(), model, optimizer = HiGHS.Optimizer, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 @test length(ret[].constraint) == 2 @test Set([ret[].constraint[1], ret[].constraint[2]]) == Set(JuMP.index.([c2, c1])) - iis = ModelAnalyzer.constraints(ret[], model) + iis = MathOptAnalyzer.constraints(ret[], model) @test length(iis) == 2 @test Set(iis) == Set([c2, c1]) # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Infeasibility.IrreducibleInfeasibleSubset, + MathOptAnalyzer.Infeasibility.IrreducibleInfeasibleSubset, ) str = String(take!(buf)) @test startswith(str, "# `IrreducibleInfeasibleSubset`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Infeasibility.IrreducibleInfeasibleSubset, + MathOptAnalyzer.Infeasibility.IrreducibleInfeasibleSubset, verbose = false, ) str = String(take!(buf)) @test str == "# IrreducibleInfeasibleSubset" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Irreducible Infeasible Subset: ") @test contains(str, ", ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test startswith(str, "IIS: ") @test contains(str, ", ") @@ -411,11 +421,11 @@ function test_iis() str = String(take!(buf)) @test startswith(str, "Infeasibility analysis found 1 issues") - ModelAnalyzer.summarize(buf, data, verbose = true) + MathOptAnalyzer.summarize(buf, data, verbose = true) str = String(take!(buf)) @test startswith(str, "## Infeasibility Analysis\n\n") - ModelAnalyzer.summarize(buf, data, verbose = false) - ModelAnalyzer.summarize(buf, data, verbose = true) + MathOptAnalyzer.summarize(buf, data, verbose = false) + MathOptAnalyzer.summarize(buf, data, verbose = true) return end @@ -428,19 +438,19 @@ function test_iis_free_var() @constraint(model, c2, x + y >= 2) @objective(model, Max, -2x + y) optimize!(model) - data = ModelAnalyzer.analyze( - ModelAnalyzer.Infeasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Infeasibility.Analyzer(), model, optimizer = HiGHS.Optimizer, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 @test length(ret[].constraint) == 2 @test Set([ret[].constraint[1], ret[].constraint[2]]) == Set(JuMP.index.([c2, c1])) - iis = ModelAnalyzer.constraints(ret[], model) + iis = MathOptAnalyzer.constraints(ret[], model) @test length(iis) == 2 @test Set(iis) == Set([c2, c1]) return @@ -456,23 +466,24 @@ function test_iis_multiple() @constraint(model, c2, x + y >= 2) @objective(model, Max, x + y) optimize!(model) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Infeasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Infeasibility.Analyzer(), model, optimizer = HiGHS.Optimizer, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 @test length(ret[].constraint) == 2 @test JuMP.index(c2) in Set([ret[].constraint[1], ret[].constraint[2]]) @test Set([ret[].constraint[1], ret[].constraint[2]]) ⊆ Set(JuMP.index.([c3, c2, c1])) - iis = ModelAnalyzer.constraints(ret[], model) + iis = MathOptAnalyzer.constraints(ret[], model) @test length(iis) == 2 @test Set(iis) ⊆ Set([c3, c2, c1]) @test c2 in iis @@ -488,22 +499,23 @@ function test_iis_interval_right() @constraint(model, c2, x + y >= 2) @objective(model, Max, x + y) optimize!(model) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Infeasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Infeasibility.Analyzer(), model, optimizer = HiGHS.Optimizer, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 @test length(ret[].constraint) == 2 @test Set([ret[].constraint[1], ret[].constraint[2]]) == Set(JuMP.index.([c2, c1])) - iis = ModelAnalyzer.constraints(ret[], model) + iis = MathOptAnalyzer.constraints(ret[], model) @test length(iis) == 2 @test Set(iis) == Set([c2, c1]) return @@ -518,25 +530,26 @@ function test_iis_interval_left() @constraint(model, c2, 2 <= x + y <= 5) @objective(model, Max, x + y) optimize!(model) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Infeasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Infeasibility.Analyzer(), model, optimizer = HiGHS.Optimizer, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 @test length(ret[].constraint) == 2 @test Set([ret[].constraint[1], ret[].constraint[2]]) == Set(JuMP.index.([c2, c1])) - iis = ModelAnalyzer.constraints(ret[], model) + iis = MathOptAnalyzer.constraints(ret[], model) @test length(iis) == 2 @test Set(iis) == Set([c2, c1]) - iis = ModelAnalyzer.constraints(ret[], JuMP.backend(model)) + iis = MathOptAnalyzer.constraints(ret[], JuMP.backend(model)) @test length(iis) == 2 @test Set(iis) == Set(JuMP.index.([c2, c1])) return @@ -554,26 +567,27 @@ function test_iis_spare() @constraint(model, c2, x + y >= 2) @objective(model, Max, x + y) optimize!(model) - data = ModelAnalyzer.analyze(ModelAnalyzer.Infeasibility.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = + MathOptAnalyzer.analyze(MathOptAnalyzer.Infeasibility.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 - data = ModelAnalyzer.analyze( - ModelAnalyzer.Infeasibility.Analyzer(), + data = MathOptAnalyzer.analyze( + MathOptAnalyzer.Infeasibility.Analyzer(), model, optimizer = HiGHS.Optimizer, ) - list = ModelAnalyzer.list_of_issue_types(data) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues(data, list[1]) + ret = MathOptAnalyzer.list_of_issues(data, list[1]) @test length(ret) == 1 @test length(ret[].constraint) == 2 @test Set([ret[].constraint[1], ret[].constraint[2]]) == Set(JuMP.index.([c2, c1])) - iis = ModelAnalyzer.constraints(ret[], model) + iis = MathOptAnalyzer.constraints(ret[], model) @test length(iis) == 2 @test Set(iis) == Set([c2, c1]) io = IOBuffer() - ModelAnalyzer.summarize(io, ret[1], verbose = true, model = model) + MathOptAnalyzer.summarize(io, ret[1], verbose = true, model = model) return end diff --git a/test/test_Numerical.jl b/test/test_Numerical.jl index 5ad2e2f..d7b650e 100644 --- a/test/test_Numerical.jl +++ b/test/test_Numerical.jl @@ -5,7 +5,7 @@ module TestNumerical -import ModelAnalyzer +import MathOptAnalyzer using Test using JuMP @@ -28,43 +28,49 @@ function test_variable_bounds() @variable(model, yg >= 3e+10) @variable(model, zs == 4e-11) @variable(model, zg == 4e+11) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 3 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.VariableNotInConstraints, + MathOptAnalyzer.Numerical.VariableNotInConstraints, ) @test length(ret) == 6 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.SmallBoundCoefficient, + MathOptAnalyzer.Numerical.SmallBoundCoefficient, ) @test length(ret) == 3 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeBoundCoefficient, + MathOptAnalyzer.Numerical.LargeBoundCoefficient, ) @test length(ret) == 3 buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.SmallBoundCoefficient) + MathOptAnalyzer.summarize( + buf, + MathOptAnalyzer.Numerical.SmallBoundCoefficient, + ) str = String(take!(buf)) @test startswith(str, "# `SmallBoundCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.SmallBoundCoefficient, + MathOptAnalyzer.Numerical.SmallBoundCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# SmallBoundCoefficient" buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.LargeBoundCoefficient) + MathOptAnalyzer.summarize( + buf, + MathOptAnalyzer.Numerical.LargeBoundCoefficient, + ) str = String(take!(buf)) @test startswith(str, "# `LargeBoundCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.LargeBoundCoefficient, + MathOptAnalyzer.Numerical.LargeBoundCoefficient, verbose = false, ) str = String(take!(buf)) @@ -85,48 +91,54 @@ function test_constraint_bounds() @constraint(model, [x] in MOI.Nonnegatives(1)) @constraint(model, [x - 1e-16] in MOI.Nonnegatives(1)) @constraint(model, [x - 1e+17] in MOI.Nonnegatives(1)) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 3 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.VariableBoundAsConstraint, + MathOptAnalyzer.Numerical.VariableBoundAsConstraint, ) @test length(ret) == 6 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.VariableNotInConstraints, + MathOptAnalyzer.Numerical.VariableNotInConstraints, ) @test length(ret) == 0 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.SmallRHSCoefficient, + MathOptAnalyzer.Numerical.SmallRHSCoefficient, ) @test length(ret) == 4 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeRHSCoefficient, + MathOptAnalyzer.Numerical.LargeRHSCoefficient, ) @test length(ret) == 4 buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.SmallRHSCoefficient) + MathOptAnalyzer.summarize( + buf, + MathOptAnalyzer.Numerical.SmallRHSCoefficient, + ) str = String(take!(buf)) @test startswith(str, "# `SmallRHSCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.SmallRHSCoefficient, + MathOptAnalyzer.Numerical.SmallRHSCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# SmallRHSCoefficient" buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.LargeRHSCoefficient) + MathOptAnalyzer.summarize( + buf, + MathOptAnalyzer.Numerical.LargeRHSCoefficient, + ) str = String(take!(buf)) @test startswith(str, "# `LargeRHSCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.LargeRHSCoefficient, + MathOptAnalyzer.Numerical.LargeRHSCoefficient, verbose = false, ) str = String(take!(buf)) @@ -142,48 +154,54 @@ function test_constraint_bounds_quad() @constraint(model, x^2 <= 1e+15) @constraint(model, [x^2 - 1e-16] in MOI.Nonpositives(1)) @constraint(model, [x^2 - 1e+17] in MOI.Nonpositives(1)) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 2 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.VariableBoundAsConstraint, + MathOptAnalyzer.Numerical.VariableBoundAsConstraint, ) @test length(ret) == 0 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.VariableNotInConstraints, + MathOptAnalyzer.Numerical.VariableNotInConstraints, ) @test length(ret) == 0 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.SmallRHSCoefficient, + MathOptAnalyzer.Numerical.SmallRHSCoefficient, ) @test length(ret) == 2 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeRHSCoefficient, + MathOptAnalyzer.Numerical.LargeRHSCoefficient, ) @test length(ret) == 2 buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.SmallRHSCoefficient) + MathOptAnalyzer.summarize( + buf, + MathOptAnalyzer.Numerical.SmallRHSCoefficient, + ) str = String(take!(buf)) @test startswith(str, "# `SmallRHSCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.SmallRHSCoefficient, + MathOptAnalyzer.Numerical.SmallRHSCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# SmallRHSCoefficient" buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.LargeRHSCoefficient) + MathOptAnalyzer.summarize( + buf, + MathOptAnalyzer.Numerical.LargeRHSCoefficient, + ) str = String(take!(buf)) @test startswith(str, "# `LargeRHSCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.LargeRHSCoefficient, + MathOptAnalyzer.Numerical.LargeRHSCoefficient, verbose = false, ) str = String(take!(buf)) @@ -192,19 +210,19 @@ function test_constraint_bounds_quad() return end -function test_constraint_bounds_quad() +function test_constraint_bounds_quad_vec() model = Model() @variable(model, x) @constraint(model, c, [-x^2 - 3] in MOI.Nonpositives(1)) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.NonconvexQuadraticConstraint, + MathOptAnalyzer.Numerical.NonconvexQuadraticConstraint, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[]) == JuMP.index(c) + @test MathOptAnalyzer.constraint(ret[]) == JuMP.index(c) return end @@ -215,26 +233,26 @@ function test_no_names() @variable(model, y) @constraint(model, 7y >= 3) @constraint(model, z, 0.0 * y == 3) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 2 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.VariableNotInConstraints, + MathOptAnalyzer.Numerical.VariableNotInConstraints, ) @test length(ret) == 1 # buf = IOBuffer() - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Variable: ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) # - ModelAnalyzer.summarize(buf, ret[1], verbose = true, model = model) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true, model = model) str = String(take!(buf)) @test startswith(str, "Variable: ") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, ret[1], verbose = true, @@ -242,26 +260,26 @@ function test_no_names() ) str = String(take!(buf)) @test startswith(str, "Variable: ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false, model = model) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false, model = model) str = String(take!(buf)) # # - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.EmptyConstraint, + MathOptAnalyzer.Numerical.EmptyConstraint, ) @test length(ret) == 1 # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Constraint: ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) # - ModelAnalyzer.summarize(buf, ret[1], verbose = true, model = model) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true, model = model) str = String(take!(buf)) @test startswith(str, "Constraint: ") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, ret[1], verbose = true, @@ -269,7 +287,7 @@ function test_no_names() ) str = String(take!(buf)) @test startswith(str, "Constraint: ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false, model = model) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false, model = model) str = String(take!(buf)) return end @@ -279,28 +297,28 @@ function test_variable_not_in_constraints() @variable(model, x) @variable(model, y) @constraint(model, 7y >= 3) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.VariableNotInConstraints, + MathOptAnalyzer.Numerical.VariableNotInConstraints, ) @test length(ret) == 1 - @test ModelAnalyzer.variable(ret[]) == JuMP.index(x) - @test ModelAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.variable(ret[]) == JuMP.index(x) + @test MathOptAnalyzer.variable(ret[], model) == x # buf = IOBuffer() - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Variable: ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) # - ModelAnalyzer.summarize(buf, ret[1], verbose = true, model = model) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true, model = model) str = String(take!(buf)) @test startswith(str, "Variable: ") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, ret[1], verbose = true, @@ -308,7 +326,7 @@ function test_variable_not_in_constraints() ) str = String(take!(buf)) @test startswith(str, "Variable: ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false, model = model) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false, model = model) str = String(take!(buf)) return end @@ -318,39 +336,39 @@ function test_empty_constraint_model() @variable(model, x) @constraint(model, c1, 2 * x == 5) @constraint(model, c2, 0.0 * x == 3) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.EmptyConstraint, + MathOptAnalyzer.Numerical.EmptyConstraint, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[]) == JuMP.index(c2) - @test ModelAnalyzer.constraint(ret[], model) == c2 + @test MathOptAnalyzer.constraint(ret[]) == JuMP.index(c2) + @test MathOptAnalyzer.constraint(ret[], model) == c2 # buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.EmptyConstraint) + MathOptAnalyzer.summarize(buf, MathOptAnalyzer.Numerical.EmptyConstraint) str = String(take!(buf)) @test startswith(str, "# `EmptyConstraint`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.EmptyConstraint, + MathOptAnalyzer.Numerical.EmptyConstraint, verbose = false, ) str = String(take!(buf)) @test str == "# EmptyConstraint" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Constraint: ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) # - ModelAnalyzer.summarize(buf, ret[1], verbose = true, model = model) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true, model = model) str = String(take!(buf)) @test startswith(str, "Constraint: ") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, ret[1], verbose = true, @@ -358,7 +376,7 @@ function test_empty_constraint_model() ) str = String(take!(buf)) @test startswith(str, "Constraint: ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false, model = model) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false, model = model) str = String(take!(buf)) return end @@ -368,36 +386,36 @@ function test_variable_bound_as_constraint() @variable(model, x) @constraint(model, c, x <= 2) @constraint(model, 3x <= 4) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.VariableBoundAsConstraint, + MathOptAnalyzer.Numerical.VariableBoundAsConstraint, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[]) == JuMP.index(c) - @test ModelAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.constraint(ret[]) == JuMP.index(c) + @test MathOptAnalyzer.constraint(ret[], model) == c # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.VariableBoundAsConstraint, + MathOptAnalyzer.Numerical.VariableBoundAsConstraint, ) str = String(take!(buf)) @test startswith(str, "# `VariableBoundAsConstraint`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.VariableBoundAsConstraint, + MathOptAnalyzer.Numerical.VariableBoundAsConstraint, verbose = false, ) str = String(take!(buf)) @test str == "# VariableBoundAsConstraint" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Constraint: ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) return end @@ -406,35 +424,36 @@ function test_dense_constraint() model = Model() @variable(model, x[1:10_000] <= 1) @constraint(model, c, sum(x) <= 4) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.DenseConstraint, + MathOptAnalyzer.Numerical.DenseConstraint, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[]) == JuMP.index(c) - @test ModelAnalyzer.constraint(ret[], JuMP.backend(model)) == JuMP.index(c) - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.value(ret[]) == 10_000 + @test MathOptAnalyzer.constraint(ret[]) == JuMP.index(c) + @test MathOptAnalyzer.constraint(ret[], JuMP.backend(model)) == + JuMP.index(c) + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.value(ret[]) == 10_000 # buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.DenseConstraint) + MathOptAnalyzer.summarize(buf, MathOptAnalyzer.Numerical.DenseConstraint) str = String(take!(buf)) @test startswith(str, "# `DenseConstraint`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.DenseConstraint, + MathOptAnalyzer.Numerical.DenseConstraint, verbose = false, ) str = String(take!(buf)) @test str == "# DenseConstraint" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Constraint: ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " : ") return @@ -444,36 +463,39 @@ function test_small_matrix_coef() model = Model() @variable(model, x <= 1) @constraint(model, c, 1e-9 * x <= 4) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.SmallMatrixCoefficient, + MathOptAnalyzer.Numerical.SmallMatrixCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.variable(ret[], JuMP.backend(model)) == JuMP.index(x) - @test ModelAnalyzer.value(ret[]) == 1e-9 + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.variable(ret[], JuMP.backend(model)) == JuMP.index(x) + @test MathOptAnalyzer.value(ret[]) == 1e-9 # buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.SmallMatrixCoefficient) + MathOptAnalyzer.summarize( + buf, + MathOptAnalyzer.Numerical.SmallMatrixCoefficient, + ) str = String(take!(buf)) @test startswith(str, "# `SmallMatrixCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.SmallMatrixCoefficient, + MathOptAnalyzer.Numerical.SmallMatrixCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# SmallMatrixCoefficient" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "(Constraint -- Variable): (") @test contains(str, ") with coefficient ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " -- ") @test contains(str, " : ") @@ -484,35 +506,38 @@ function test_large_matrix_coef() model = Model() @variable(model, x <= 1) @constraint(model, c, 1e+9 * x <= 4) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeMatrixCoefficient, + MathOptAnalyzer.Numerical.LargeMatrixCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.value(ret[]) == 1e+9 + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.value(ret[]) == 1e+9 # buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.LargeMatrixCoefficient) + MathOptAnalyzer.summarize( + buf, + MathOptAnalyzer.Numerical.LargeMatrixCoefficient, + ) str = String(take!(buf)) @test startswith(str, "# `LargeMatrixCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.LargeMatrixCoefficient, + MathOptAnalyzer.Numerical.LargeMatrixCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# LargeMatrixCoefficient" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "(Constraint -- Variable): (") @test contains(str, ") with coefficient ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " -- ") @test contains(str, " : ") @@ -523,34 +548,37 @@ function test_small_bound_coef() model = Model() @variable(model, x <= 1e-9) @constraint(model, 3 * x <= 4) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.SmallBoundCoefficient, + MathOptAnalyzer.Numerical.SmallBoundCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.value(ret[]) == 1e-9 + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.value(ret[]) == 1e-9 # buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.SmallBoundCoefficient) + MathOptAnalyzer.summarize( + buf, + MathOptAnalyzer.Numerical.SmallBoundCoefficient, + ) str = String(take!(buf)) @test startswith(str, "# `SmallBoundCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.SmallBoundCoefficient, + MathOptAnalyzer.Numerical.SmallBoundCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# SmallBoundCoefficient" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Variable: ") @test contains(str, " with bound ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " : ") return @@ -560,34 +588,37 @@ function test_large_bound_coef() model = Model() @variable(model, x <= 1e+9) @constraint(model, 3 * x <= 4) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeBoundCoefficient, + MathOptAnalyzer.Numerical.LargeBoundCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.value(ret[]) == 1e+9 + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.value(ret[]) == 1e+9 # buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.LargeBoundCoefficient) + MathOptAnalyzer.summarize( + buf, + MathOptAnalyzer.Numerical.LargeBoundCoefficient, + ) str = String(take!(buf)) @test startswith(str, "# `LargeBoundCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.LargeBoundCoefficient, + MathOptAnalyzer.Numerical.LargeBoundCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# LargeBoundCoefficient" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Variable: ") @test contains(str, " with bound ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " : ") return @@ -597,34 +628,37 @@ function test_small_rhs_coef() model = Model() @variable(model, x <= 1) @constraint(model, c, 3 * x <= 1e-9) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.SmallRHSCoefficient, + MathOptAnalyzer.Numerical.SmallRHSCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.value(ret[]) == 1e-9 + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.value(ret[]) == 1e-9 # buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.SmallRHSCoefficient) + MathOptAnalyzer.summarize( + buf, + MathOptAnalyzer.Numerical.SmallRHSCoefficient, + ) str = String(take!(buf)) @test startswith(str, "# `SmallRHSCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.SmallRHSCoefficient, + MathOptAnalyzer.Numerical.SmallRHSCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# SmallRHSCoefficient" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Constraint: ") @test contains(str, " with right-hand-side ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " : ") return @@ -634,34 +668,37 @@ function test_large_rhs_coef() model = Model() @variable(model, x <= 1) @constraint(model, c, 3 * x <= 1e+9) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeRHSCoefficient, + MathOptAnalyzer.Numerical.LargeRHSCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[], model) == c - @test ModelAnalyzer.value(ret[]) == 1e+9 + @test MathOptAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.value(ret[]) == 1e+9 # buf = IOBuffer() - ModelAnalyzer.summarize(buf, ModelAnalyzer.Numerical.LargeRHSCoefficient) + MathOptAnalyzer.summarize( + buf, + MathOptAnalyzer.Numerical.LargeRHSCoefficient, + ) str = String(take!(buf)) @test startswith(str, "# `LargeRHSCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.LargeRHSCoefficient, + MathOptAnalyzer.Numerical.LargeRHSCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# LargeRHSCoefficient" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Constraint: ") @test contains(str, " with right-hand-side ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " : ") return @@ -672,37 +709,37 @@ function test_small_objective_coef() @variable(model, x <= 1) @constraint(model, 3 * x <= 4) @objective(model, Min, 1e-9 * x) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.SmallObjectiveCoefficient, + MathOptAnalyzer.Numerical.SmallObjectiveCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.value(ret[]) == 1e-9 + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.value(ret[]) == 1e-9 # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.SmallObjectiveCoefficient, + MathOptAnalyzer.Numerical.SmallObjectiveCoefficient, ) str = String(take!(buf)) @test startswith(str, "# `SmallObjectiveCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.SmallObjectiveCoefficient, + MathOptAnalyzer.Numerical.SmallObjectiveCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# SmallObjectiveCoefficient" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Variable: ") @test contains(str, " with coefficient ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " : ") return @@ -713,37 +750,37 @@ function test_large_objective_coef() @variable(model, x <= 1) @constraint(model, 3 * x <= 4) @objective(model, Min, 1e+9 * x) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeObjectiveCoefficient, + MathOptAnalyzer.Numerical.LargeObjectiveCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.value(ret[]) == 1e+9 + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.value(ret[]) == 1e+9 # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.LargeObjectiveCoefficient, + MathOptAnalyzer.Numerical.LargeObjectiveCoefficient, ) str = String(take!(buf)) @test startswith(str, "# `LargeObjectiveCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.LargeObjectiveCoefficient, + MathOptAnalyzer.Numerical.LargeObjectiveCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# LargeObjectiveCoefficient" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Variable: ") @test contains(str, " with coefficient ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " : ") return @@ -754,39 +791,39 @@ function test_small_objective_coef_quad() @variable(model, x <= 1) @constraint(model, 3 * x <= 4) @objective(model, Min, 1e-9 * x^2) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.SmallObjectiveQuadraticCoefficient, + MathOptAnalyzer.Numerical.SmallObjectiveQuadraticCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.variables(ret[], model) == [x, x] - @test ModelAnalyzer.variables(ret[], JuMP.backend(model)) == + @test MathOptAnalyzer.variables(ret[], model) == [x, x] + @test MathOptAnalyzer.variables(ret[], JuMP.backend(model)) == JuMP.index.([x, x]) - @test_broken ModelAnalyzer.value(ret[]) == 1e-9 # 2e-9 TODO, what to return here + @test_broken MathOptAnalyzer.value(ret[]) == 1e-9 # 2e-9 TODO, what to return here # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.SmallObjectiveQuadraticCoefficient, + MathOptAnalyzer.Numerical.SmallObjectiveQuadraticCoefficient, ) str = String(take!(buf)) @test startswith(str, "# `SmallObjectiveQuadraticCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.SmallObjectiveQuadraticCoefficient, + MathOptAnalyzer.Numerical.SmallObjectiveQuadraticCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# SmallObjectiveQuadraticCoefficient" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "(Variable -- Variable): (") @test contains(str, " with coefficient ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " -- ") @test contains(str, " : ") @@ -798,37 +835,37 @@ function test_large_objective_coef_quad() @variable(model, x <= 1) @constraint(model, 3 * x <= 4) @objective(model, Min, 1e+9 * x^2) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeObjectiveQuadraticCoefficient, + MathOptAnalyzer.Numerical.LargeObjectiveQuadraticCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.variables(ret[], model) == [x, x] - @test_broken ModelAnalyzer.value(ret[]) == 1e+9 # 2e+9 TODO, what to return here + @test MathOptAnalyzer.variables(ret[], model) == [x, x] + @test_broken MathOptAnalyzer.value(ret[]) == 1e+9 # 2e+9 TODO, what to return here # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.LargeObjectiveQuadraticCoefficient, + MathOptAnalyzer.Numerical.LargeObjectiveQuadraticCoefficient, ) str = String(take!(buf)) @test startswith(str, "# `LargeObjectiveQuadraticCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.LargeObjectiveQuadraticCoefficient, + MathOptAnalyzer.Numerical.LargeObjectiveQuadraticCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# LargeObjectiveQuadraticCoefficient" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "(Variable -- Variable): (") @test contains(str, " with coefficient ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " -- ") @test contains(str, " : ") @@ -839,38 +876,38 @@ function test_small_matrix_coef_quad() model = Model() @variable(model, x <= 1) @constraint(model, c, 1e-9 * x^2 + x <= 4) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.SmallMatrixQuadraticCoefficient, + MathOptAnalyzer.Numerical.SmallMatrixQuadraticCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.variables(ret[], model) == [x, x] - @test ModelAnalyzer.constraint(ret[], model) == c - @test_broken ModelAnalyzer.value(ret[]) == 1e-9 # 2e-9 TODO, what to return here + @test MathOptAnalyzer.variables(ret[], model) == [x, x] + @test MathOptAnalyzer.constraint(ret[], model) == c + @test_broken MathOptAnalyzer.value(ret[]) == 1e-9 # 2e-9 TODO, what to return here # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.SmallMatrixQuadraticCoefficient, + MathOptAnalyzer.Numerical.SmallMatrixQuadraticCoefficient, ) str = String(take!(buf)) @test startswith(str, "# `SmallMatrixQuadraticCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.SmallMatrixQuadraticCoefficient, + MathOptAnalyzer.Numerical.SmallMatrixQuadraticCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# SmallMatrixQuadraticCoefficient" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "(Constraint -- Variable -- Variable): (") @test contains(str, ") with coefficient ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " -- ") @test contains(str, " : ") @@ -881,38 +918,38 @@ function test_large_matrix_coef_quad() model = Model() @variable(model, x <= 1) @constraint(model, c, 1e+9 * x^2 <= 4) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeMatrixQuadraticCoefficient, + MathOptAnalyzer.Numerical.LargeMatrixQuadraticCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.variables(ret[], model) == [x, x] - @test ModelAnalyzer.constraint(ret[], model) == c - @test_broken ModelAnalyzer.value(ret[]) == 1e+9 # 2e+9 TODO, what to return here + @test MathOptAnalyzer.variables(ret[], model) == [x, x] + @test MathOptAnalyzer.constraint(ret[], model) == c + @test_broken MathOptAnalyzer.value(ret[]) == 1e+9 # 2e+9 TODO, what to return here # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.LargeMatrixQuadraticCoefficient, + MathOptAnalyzer.Numerical.LargeMatrixQuadraticCoefficient, ) str = String(take!(buf)) @test startswith(str, "# `LargeMatrixQuadraticCoefficient`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.LargeMatrixQuadraticCoefficient, + MathOptAnalyzer.Numerical.LargeMatrixQuadraticCoefficient, verbose = false, ) str = String(take!(buf)) @test str == "# LargeMatrixQuadraticCoefficient" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "(Constraint -- Variable -- Variable): (") @test contains(str, ") with coefficient ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test contains(str, " -- ") @test contains(str, " : ") @@ -924,34 +961,34 @@ function test_objective_nonconvex() @variable(model, x <= 1) @constraint(model, 3 * x <= 4) @objective(model, Max, x^2) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.NonconvexQuadraticObjective, + MathOptAnalyzer.Numerical.NonconvexQuadraticObjective, ) @test length(ret) == 1 # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.NonconvexQuadraticObjective, + MathOptAnalyzer.Numerical.NonconvexQuadraticObjective, ) str = String(take!(buf)) @test startswith(str, "# `NonconvexQuadraticObjective`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.NonconvexQuadraticObjective, + MathOptAnalyzer.Numerical.NonconvexQuadraticObjective, verbose = false, ) str = String(take!(buf)) @test str == "# NonconvexQuadraticObjective" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Objective is Nonconvex quadratic") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test startswith(str, "Objective is Nonconvex quadratic") return @@ -962,34 +999,34 @@ function test_objective_nonconvex_2() @variable(model, x <= 1) @constraint(model, 3 * x <= 4) @objective(model, Min, -x^2) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.NonconvexQuadraticObjective, + MathOptAnalyzer.Numerical.NonconvexQuadraticObjective, ) @test length(ret) == 1 # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.NonconvexQuadraticObjective, + MathOptAnalyzer.Numerical.NonconvexQuadraticObjective, ) str = String(take!(buf)) @test startswith(str, "# `NonconvexQuadraticObjective`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.NonconvexQuadraticObjective, + MathOptAnalyzer.Numerical.NonconvexQuadraticObjective, verbose = false, ) str = String(take!(buf)) @test str == "# NonconvexQuadraticObjective" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Objective is Nonconvex quadratic") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) @test startswith(str, "Objective is Nonconvex quadratic") return @@ -999,43 +1036,43 @@ function test_constraint_nonconvex() model = Model() @variable(model, x <= 1) @constraint(model, c, x^2 >= 4) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.NonconvexQuadraticConstraint, + MathOptAnalyzer.Numerical.NonconvexQuadraticConstraint, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.constraint(ret[], model) == c # buf = IOBuffer() - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.NonconvexQuadraticConstraint, + MathOptAnalyzer.Numerical.NonconvexQuadraticConstraint, ) str = String(take!(buf)) @test startswith(str, "# `NonconvexQuadraticConstraint`") - ModelAnalyzer.summarize( + MathOptAnalyzer.summarize( buf, - ModelAnalyzer.Numerical.NonconvexQuadraticConstraint, + MathOptAnalyzer.Numerical.NonconvexQuadraticConstraint, verbose = false, ) str = String(take!(buf)) @test str == "# NonconvexQuadraticConstraint" # - ModelAnalyzer.summarize(buf, ret[1], verbose = true) + MathOptAnalyzer.summarize(buf, ret[1], verbose = true) str = String(take!(buf)) @test startswith(str, "Constraint: ") - ModelAnalyzer.summarize(buf, ret[1], verbose = false) + MathOptAnalyzer.summarize(buf, ret[1], verbose = false) str = String(take!(buf)) return end function test_empty_model() model = Model() - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 return end @@ -1044,15 +1081,15 @@ function test_nonconvex_zeros() model = Model() @variable(model, x[1:1]) @constraint(model, c, [x[1] * x[1]] in Zeros()) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.NonconvexQuadraticConstraint, + MathOptAnalyzer.Numerical.NonconvexQuadraticConstraint, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[], model) == c + @test MathOptAnalyzer.constraint(ret[], model) == c return end @@ -1063,24 +1100,24 @@ function test_vi_in_nonstandard_set() @constraint(model, c1, 3x[1] + 1e-9 in MOI.ZeroOne()) @constraint(model, c2, 4x[1] - 1e+9 in MOI.ZeroOne()) @constraint(model, c3, 2x[1] == 0) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 2 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.SmallRHSCoefficient, + MathOptAnalyzer.Numerical.SmallRHSCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[], model) == c1 - @test ModelAnalyzer.value(ret[]) == 1e-9 + @test MathOptAnalyzer.constraint(ret[], model) == c1 + @test MathOptAnalyzer.value(ret[]) == 1e-9 # - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeRHSCoefficient, + MathOptAnalyzer.Numerical.LargeRHSCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[], model) == c2 - @test ModelAnalyzer.value(ret[]) == -1e+9 + @test MathOptAnalyzer.constraint(ret[], model) == c2 + @test MathOptAnalyzer.value(ret[]) == -1e+9 return end @@ -1088,8 +1125,8 @@ function test_saf_in_nonstandard_set() model = Model() @variable(model, x[1:1]) @constraint(model, c, 2x[1] in MOI.ZeroOne()) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 return end @@ -1098,8 +1135,8 @@ function test_vaf_in_nonstandard_set() model = Model() @variable(model, x[1:1]) @constraint(model, c, [2x[1], x[1], x[1]] in SecondOrderCone()) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 0 return end @@ -1113,52 +1150,52 @@ function test_vector_functions() @constraint(model, c4, [-1e-9 * x[1] * x[1]] in Nonnegatives()) @constraint(model, c5, [1e+9 * x[1] * x[1]] in Nonnegatives()) @constraint(model, c6, [2 * x[1] * x[1]] in Zeros()) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 6 # - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.SmallMatrixCoefficient, + MathOptAnalyzer.Numerical.SmallMatrixCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[], model) == c1 - @test ModelAnalyzer.variable(ret[], model) == x[1] - @test ModelAnalyzer.value(ret[]) == 1e-9 + @test MathOptAnalyzer.constraint(ret[], model) == c1 + @test MathOptAnalyzer.variable(ret[], model) == x[1] + @test MathOptAnalyzer.value(ret[]) == 1e-9 # - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeMatrixCoefficient, + MathOptAnalyzer.Numerical.LargeMatrixCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[], model) == c2 - @test ModelAnalyzer.variable(ret[], model) == x[1] - @test ModelAnalyzer.value(ret[]) == 1e+9 + @test MathOptAnalyzer.constraint(ret[], model) == c2 + @test MathOptAnalyzer.variable(ret[], model) == x[1] + @test MathOptAnalyzer.value(ret[]) == 1e+9 # - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.SmallMatrixQuadraticCoefficient, + MathOptAnalyzer.Numerical.SmallMatrixQuadraticCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[], model) == c4 - @test ModelAnalyzer.variables(ret[], model) == [x[1], x[1]] - @test_broken ModelAnalyzer.value(ret[]) == 1e-9 + @test MathOptAnalyzer.constraint(ret[], model) == c4 + @test MathOptAnalyzer.variables(ret[], model) == [x[1], x[1]] + @test_broken MathOptAnalyzer.value(ret[]) == 1e-9 # - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeMatrixQuadraticCoefficient, + MathOptAnalyzer.Numerical.LargeMatrixQuadraticCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.constraint(ret[], model) == c5 - @test ModelAnalyzer.variables(ret[], model) == [x[1], x[1]] - @test_broken ModelAnalyzer.value(ret[]) == 1e+9 + @test MathOptAnalyzer.constraint(ret[], model) == c5 + @test MathOptAnalyzer.variables(ret[], model) == [x[1], x[1]] + @test_broken MathOptAnalyzer.value(ret[]) == 1e+9 # - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.VariableNotInConstraints, + MathOptAnalyzer.Numerical.VariableNotInConstraints, ) @test length(ret) == 1 - @test ModelAnalyzer.variable(ret[], model) == x[3] + @test MathOptAnalyzer.variable(ret[], model) == x[3] return end @@ -1166,31 +1203,31 @@ function test_variable_interval() model = Model() @variable(model, x in MOI.Interval(1e-9, 1e+9)) @objective(model, Min, x) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) == 3 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.SmallBoundCoefficient, + MathOptAnalyzer.Numerical.SmallBoundCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.value(ret[]) == 1e-9 + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.value(ret[]) == 1e-9 # - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeBoundCoefficient, + MathOptAnalyzer.Numerical.LargeBoundCoefficient, ) @test length(ret) == 1 - @test ModelAnalyzer.variable(ret[], model) == x - @test ModelAnalyzer.value(ret[]) == 1e+9 + @test MathOptAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.value(ret[]) == 1e+9 # - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.VariableNotInConstraints, + MathOptAnalyzer.Numerical.VariableNotInConstraints, ) @test length(ret) == 1 - @test ModelAnalyzer.variable(ret[], model) == x + @test MathOptAnalyzer.variable(ret[], model) == x return end @@ -1221,23 +1258,23 @@ function test_many() @objective(model, Max, 1e8 * x + 8e-11 * y) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) buf = IOBuffer() Base.show(buf, data) str = String(take!(buf)) buf = IOBuffer() - ModelAnalyzer.summarize(buf, data) - ModelAnalyzer.summarize(buf, data, verbose = false) + MathOptAnalyzer.summarize(buf, data) + MathOptAnalyzer.summarize(buf, data, verbose = false) redirect_stdout(devnull) do - ModelAnalyzer.summarize(data) - list = ModelAnalyzer.list_of_issue_types(data) - ModelAnalyzer.summarize(list[1]) - issues = ModelAnalyzer.list_of_issues(data, list[1]) - ModelAnalyzer.summarize(issues) - ModelAnalyzer.summarize(issues[1]) + MathOptAnalyzer.summarize(data) + list = MathOptAnalyzer.list_of_issue_types(data) + MathOptAnalyzer.summarize(list[1]) + issues = MathOptAnalyzer.list_of_issues(data, list[1]) + MathOptAnalyzer.summarize(issues) + MathOptAnalyzer.summarize(issues[1]) return end @@ -1259,15 +1296,15 @@ function test_nonconvex_qp() @constraint(model, x * y >= 4) # bad 7 @objective(model, Max, y * x) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) buf = IOBuffer() Base.show(buf, data) str = String(take!(buf)) buf = IOBuffer() - ModelAnalyzer.summarize(buf, data) - ModelAnalyzer.summarize(buf, data, verbose = false) + MathOptAnalyzer.summarize(buf, data) + MathOptAnalyzer.summarize(buf, data, verbose = false) return end @@ -1279,18 +1316,18 @@ function test_qp_range() @constraint(model, c, 1e-7 * x^2 + 7e8 * y * y <= 4) @objective(model, Min, 3e-7 * x * x + 2e12 * y * y) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) buf = IOBuffer() Base.show(buf, data) str = String(take!(buf)) buf = IOBuffer() - ModelAnalyzer.summarize(buf, data) - ModelAnalyzer.summarize(buf, data, verbose = false) + MathOptAnalyzer.summarize(buf, data) + MathOptAnalyzer.summarize(buf, data, verbose = false) open("my_report.txt", "w") do io - return ModelAnalyzer.summarize(io, data) + return MathOptAnalyzer.summarize(io, data) end file_data = read("my_report.txt", String) @@ -1302,17 +1339,17 @@ end function test_more_than_max_issues() model = Model() @variable(model, xg[1:20] <= 2e9) - data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) - list = ModelAnalyzer.list_of_issue_types(data) + data = MathOptAnalyzer.analyze(MathOptAnalyzer.Numerical.Analyzer(), model) + list = MathOptAnalyzer.list_of_issue_types(data) @test length(list) >= 1 - ret = ModelAnalyzer.list_of_issues( + ret = MathOptAnalyzer.list_of_issues( data, - ModelAnalyzer.Numerical.LargeBoundCoefficient, + MathOptAnalyzer.Numerical.LargeBoundCoefficient, ) @test length(ret) == 20 buf = IOBuffer() - ModelAnalyzer.summarize(buf, data) + MathOptAnalyzer.summarize(buf, data) str = String(take!(buf)) @test occursin("Showing first ", str) @test occursin(" issues ommitted)\n\n", str)