ModelAnalyzer main API
All the analysis modules in ModelAnalyzer
follow the same main API. The main function to perform an analysis is:
ModelAnalyzer.analyze
— Functionanalyze(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
.
Once the analysis is performed, the resulting data structure can be summarized using:
ModelAnalyzer.summarize
— Functionsummarize([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.
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_types
— Functionlist_of_issue_types(data::AbstractData)
Return a vector of DataType
containing the types of issues found in the analysis results contained in data
.
ModelAnalyzer.list_of_issues
— Functionlist_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.
It is possible to extract data from the issues with the methods:
ModelAnalyzer.variables
— Functionvariables(issue::AbstractIssue)
Return the variables associated to a particular issue.
variables(issue::ModelAnalyzer.AbstractIssue, model::JuMP.GenericModel)
Return the JuMP variable references associated to a particular issue.
ModelAnalyzer.variable
— Functionvariable(issue::AbstractIssue)
Return the variable associated to a particular issue.
variable(issue::ModelAnalyzer.AbstractIssue, model::JuMP.GenericModel)
Return the JuMP variable reference associated to a particular issue.
ModelAnalyzer.constraints
— Functionconstraints(issue::AbstractIssue)
Return the constraints associated to a particular issue.
constraintss(issue::ModelAnalyzer.AbstractIssue, model::JuMP.GenericModel)
Return the JuMP constraints reference associated to a particular issue.
ModelAnalyzer.constraint
— Functionconstraint(issue::AbstractIssue)
Return the constraint associated to a particular issue.
constraint(issue::ModelAnalyzer.AbstractIssue, model::JuMP.GenericModel)
Return the JuMP constraint reference associated to a particular issue.
ModelAnalyzer.set
— Functionset(issue::AbstractIssue)
Return the set associated to a particular issue.
ModelAnalyzer.values
— Functionvalues(issue::AbstractIssue)
Return the values associated to a particular issue.
ModelAnalyzer.value
— Functionvalue(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.