ModelAnalyzer main API

All the analysis modules in ModelAnalyzer follow the same main API. The main function to perform an analysis is:

ModelAnalyzer.analyzeFunction
analyze(analyzer::AbstractAnalyzer, model::JuMP.GenericModel; kwargs...)

Analyze a JuMP model using the specified analyzer. Depending on the analyzer, this keyword arguments might vary. This function will return an instance of AbstractData which contains the results of the analysis that can be further summarized or queried for issues.

See summarize, list_of_issues, and list_of_issue_types.

source

Once the analysis is performed, the resulting data structure can be summarized using:

ModelAnalyzer.summarizeFunction
summarize([io::IO,] AbstractData; model = nothing, verbose = true, max_issues = 10, kwargs...)

Print a summary of the analysis results contained in AbstractData to the specified IO stream. If no IO stream is provided, it defaults to stdout. The model that led to the issue can be provided to model, it will be used to generate the name of variables and constraints in the issue summary. The verbose flag controls whether to print detailed information about each issue (if true) or a concise summary (if false). The max_issues argument controls the maximum number of issues to display in the summary. If there are more issues than max_issues, only the first max_issues will be displayed.

summarize([io::IO,] ::Type{T}; verbose = true) where {T<:AbstractIssue}

This variant allows summarizing information of a specific type T (which must be a subtype of AbstractIssue). In the verbose case it will provide a text explaning the issue. In the non-verbose case it will provide just the issue name.

summarize([io::IO,] issue::AbstractIssue; model = nothing, verbose = true)

This variant allows summarizing a single issue instance of type AbstractIssue. The model that led to the issue can be provided to model, it will be used to generate the name of variables and constraints in the issue summary.

source

Alternatively, you can also query the types of issues found in the analysis and summarize them individually. The following functions are useful for this:

ModelAnalyzer.list_of_issue_typesFunction
list_of_issue_types(data::AbstractData)

Return a vector of DataType containing the types of issues found in the analysis results contained in data.

source
ModelAnalyzer.list_of_issuesFunction
list_of_issues(data::AbstractData, issue_type::Type{T}) where {T<:AbstractIssue}

Return a vector of instances of T (which must be a subtype of AbstractIssue) found in the analysis results contained in data. This allows you to retrieve all instances of a specific issue type from the analysis results.

source

It is possible to extract data from the issues with the methods:

ModelAnalyzer.variablesFunction
variables(issue::AbstractIssue)

Return the variables associated to a particular issue.

source
variables(issue::ModelAnalyzer.AbstractIssue, model::JuMP.GenericModel)

Return the JuMP variable references associated to a particular issue.

source
ModelAnalyzer.variableFunction
variable(issue::AbstractIssue)

Return the variable associated to a particular issue.

source
variable(issue::ModelAnalyzer.AbstractIssue, model::JuMP.GenericModel)

Return the JuMP variable reference associated to a particular issue.

source
ModelAnalyzer.constraintsFunction
constraints(issue::AbstractIssue)

Return the constraints associated to a particular issue.

source
constraintss(issue::ModelAnalyzer.AbstractIssue, model::JuMP.GenericModel)

Return the JuMP constraints reference associated to a particular issue.

source
ModelAnalyzer.constraintFunction
constraint(issue::AbstractIssue)

Return the constraint associated to a particular issue.

source
constraint(issue::ModelAnalyzer.AbstractIssue, model::JuMP.GenericModel)

Return the JuMP constraint reference associated to a particular issue.

source
ModelAnalyzer.valueFunction
value(issue::AbstractIssue)

Return the value associated to a particular issue. The value is a number with a different meaning depending on the type of issue. For example, for some numerical issues, it can be the coefficient value.

source