File Formats
Functions to help read and write MOI models to/from various file formats. See The FileFormats submodule for more details.
MathOptInterface.FileFormats.Model
— FunctionModel(
;
format::FileFormat = FORMAT_AUTOMATIC,
filename::Union{Nothing, String} = nothing,
kwargs...
)
Return model corresponding to the FileFormat
format
, or, if format == FORMAT_AUTOMATIC
, guess the format from filename
.
The filename
argument is only needed if format == FORMAT_AUTOMATIC
.
kwargs
are passed to the underlying model constructor.
MathOptInterface.FileFormats.FileFormat
— TypeFileFormat
List of accepted export formats.
FORMAT_AUTOMATIC
: try to detect the file format based on the file nameFORMAT_CBF
: the Conic Benchmark formatFORMAT_LP
: the LP file formatFORMAT_MOF
: the MathOptFormat file formatFORMAT_MPS
: the MPS file formatFORMAT_NL
: the AMPL .nl file formatFORMAT_REW
: the .rew file format, which is MPS with generic namesFORMAT_SDPA
: the SemiDefinite Programming Algorithm format
MathOptInterface.FileFormats.CBF.Model
— TypeModel()
Create an empty instance of FileFormats.CBF.Model
.
MathOptInterface.FileFormats.LP.Model
— TypeModel(; kwargs...)
Create an empty instance of FileFormats.LP.Model.
Keyword arguments are:
maximum_length::Int=255
: the maximum length for the name of a variable. lp_solve 5.0 allows only 16 characters, while CPLEX 12.5+ allow 255.warn::Bool=false
: print a warning when variables or constraints are renamed.
MathOptInterface.FileFormats.MOF.Model
— TypeModel(; kwargs...)
Create an empty instance of FileFormats.MOF.Model.
Keyword arguments are:
print_compact::Bool=false
: print the JSON file in a compact format without spaces or newlines.warn::Bool=false
: print a warning when variables or constraints are renameddifferentiation_backend::MOI.Nonlinear.AbstractAutomaticDifferentiation = MOI.Nonlinear.SparseReverseMode()
: automatic differentiation backend to use when reading models with nonlinear constraints and objectives.use_nlp_block::Bool=true
: iftrue
parse"ScalarNonlinearFunction"
into anMOI.NLPBlock
. Iffalse
,"ScalarNonlinearFunction"
are parsed asMOI.ScalarNonlinearFunction
functions.
MathOptInterface.FileFormats.MPS.Model
— TypeModel(; kwargs...)
Create an empty instance of FileFormats.MPS.Model.
Keyword arguments are:
warn::Bool=false
: print a warning when variables or constraints are renamed.print_objsense::Bool=false
: print the OBJSENSE section when writinggeneric_names::Bool=false
: strip all names in the model and replace them with the generic namesC$i
andR$i
for the i'th column and row respectively.quadratic_format::QuadraticFormat = kQuadraticFormatGurobi
: specify the solver-specific extension used when writing the quadratic components of the model. Options arekQuadraticFormatGurobi
,kQuadraticFormatCPLEX
, andkQuadraticFormatMosek
.
MathOptInterface.FileFormats.NL.Model
— TypeModel(; use_nlp_block::Bool = true)
Create a new Optimizer object.
MathOptInterface.FileFormats.SDPA.Model
— TypeModel(; number_type::Type = Float64)
Create an empty instance of FileFormats.SDPA.Model{number_type}
.
It is important to be aware that the SDPA file format is interpreted in geometric form and not standard conic form. The standard conic form and geometric conic form are two dual standard forms for semidefinite programs (SDPs). The geometric conic form of an SDP is as follows:
\[\begin{align} & \min_{y \in \mathbb{R}^m} & b^T y \\ & \;\;\text{s.t.} & \sum_{i=1}^m A_i y_i - C & \in \mathbb{K} \end{align}\]
where $\mathcal{K}$ is a cartesian product of nonnegative orthant and positive semidefinite matrices that align with a block diagonal structure shared with the matrices A_i
and C
.
In other words, the geometric conic form contains free variables and affine constraints in either the nonnegative orthant or the positive semidefinite cone. That is, in the MathOptInterface's terminology, MOI.VectorAffineFunction
-in-MOI.Nonnegatives
and MOI.VectorAffineFunction
-in-MOI.PositiveSemidefiniteConeTriangle
constraints.
The corresponding standard conic form of the dual SDP is as follows:
\[\begin{align} & \max_{X \in \mathbb{K}} & \text{tr}(CX) \\ & \;\;\text{s.t.} & \text{tr}(A_iX) & = b_i & i = 1, \ldots, m. \end{align}\]
In other words, the standard conic form contains nonnegative and positive semidefinite variables with equality constraints. That is, in the MathOptInterface's terminology, MOI.VectorOfVariables
-in-MOI.Nonnegatives
, MOI.VectorOfVariables
-in-MOI.PositiveSemidefiniteConeTriangle
and MOI.ScalarAffineFunction
-in-MOI.EqualTo
constraints.
If a model is in standard conic form, use Dualization.jl
to transform it into the geometric conic form before writting it. Otherwise, the nonnegative (resp. positive semidefinite) variables will be bridged into free variables with affine constraints constraining them to belong to the nonnegative orthant (resp. positive semidefinite cone) by the MOI.Bridges.Constraint.VectorFunctionizeBridge
. Moreover, equality constraints will be bridged into pairs of affine constraints in the nonnegative orthant by the MOI.Bridges.Constraint.SplitIntervalBridge
and then the MOI.Bridges.Constraint.VectorizeBridge
.
If a solver is in standard conic form, use Dualization.jl
to transform the model read into standard conic form before copying it to the solver. Otherwise, the free variables will be bridged into pairs of variables in the nonnegative orthant by the MOI.Bridges.Variable.FreeBridge
and affine constraints will be bridged into equality constraints by creating a slack variable by the MOI.Bridges.Constraint.VectorSlackBridge
.
Other helpers
MathOptInterface.FileFormats.NL.SolFileResults
— TypeSolFileResults(
filename::String,
model::Model;
suffix_lower_bound_duals::Vector{String} =
["ipopt_zL_out", "lower_bound_duals"],
suffix_uuper_bound_duals::Vector{String} =
["ipopt_zU_out", "upper_bound_duals"],
)
Parse the .sol
file filename
created by solving model
and return a SolFileResults
struct.
The returned struct supports the MOI.get
API for querying result attributes such as MOI.TerminationStatus
, MOI.VariablePrimal
, and MOI.ConstraintDual
.
SolFileResults(
raw_status::String,
termination_status::MOI.TerminationStatusCode,
)
Return a SolFileResults
struct with MOI.RawStatusString
set to raw_status
, MOI.TerminationStatus
set to termination_status
, and MOI.PrimalStatus
and MOI.DualStatus
set to NO_SOLUTION
.
All other attributes are un-set.