From 75fcd947b41ccba84c0d856191f61c58dedddf25 Mon Sep 17 00:00:00 2001 From: zeptodoctor <44736852+zeptodoctor@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:56:03 +0000 Subject: [PATCH] build based on 0583508 --- previews/PR168/index.html | 2 +- previews/PR168/manual/index.html | 4 ++-- previews/PR168/reference/index.html | 2 +- previews/PR168/search/index.html | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/previews/PR168/index.html b/previews/PR168/index.html index 20aa26f..88662b2 100644 --- a/previews/PR168/index.html +++ b/previews/PR168/index.html @@ -1,2 +1,2 @@ -Home · Dualization.jl

Dualization.jl Documentation

Dualization.jl is a package written on top of MathOptInterface that allows users to write the dual of a JuMP model automatically. This package has two main features: the dualize function, which enables users to get a dualized JuMP model, and the DualOptimizer, which enables users to solve a problem by providing the solver the dual of the problem.

Installation

To install the package you can use Pkg.add as follows:

pkg> add Dualization

Contributing

Contributions to this package are more than welcome, if you find a bug or have any suggestions for the documentation please post it on the github issue tracker.

When contributing please note that the package follows the JuMP style guide.

+Home · Dualization.jl

Dualization.jl Documentation

Dualization.jl is a package written on top of MathOptInterface that allows users to write the dual of a JuMP model automatically. This package has two main features: the dualize function, which enables users to get a dualized JuMP model, and the DualOptimizer, which enables users to solve a problem by providing the solver the dual of the problem.

Installation

To install the package you can use Pkg.add as follows:

pkg> add Dualization

Contributing

Contributions to this package are more than welcome, if you find a bug or have any suggestions for the documentation please post it on the github issue tracker.

When contributing please note that the package follows the JuMP style guide.

diff --git a/previews/PR168/manual/index.html b/previews/PR168/manual/index.html index 79cdb87..6695c2b 100644 --- a/previews/PR168/manual/index.html +++ b/previews/PR168/manual/index.html @@ -107,7 +107,7 @@ && -A_{1,III}^T y_1 - A_{2,III}^T y_2 - A_{3,III}^T y_3 & = a_{III}\\ && y_1 & \ge 0\\ && y_2 & \le 0 -\end{align}\]

Supported constraints

This is the list of supported Function-in-Set constraints of the package. If you try to dualize a constraint not listed here, it will return an unsupported error.

MOI FunctionMOI Set
VariableIndexGreaterThan
VariableIndexLessThan
VariableIndexEqualTo
ScalarAffineFunctionGreaterThan
ScalarAffineFunctionLessThan
ScalarAffineFunctionEqualTo
VectorOfVariablesNonnegatives
VectorOfVariablesNonpositives
VectorOfVariablesZeros
VectorOfVariablesSecondOrderCone
VectorOfVariablesRotatedSecondOrderCone
VectorOfVariablesPositiveSemidefiniteConeTriangle
VectorOfVariablesExponentialCone
VectorOfVariablesDualExponentialCone
VectorOfVariablesPowerCone
VectorOfVariablesDualPowerCone
VectorAffineFunctionNonnegatives
VectorAffineFunctionNonpositives
VectorAffineFunctionZeros
VectorAffineFunctionSecondOrderCone
VectorAffineFunctionRotatedSecondOrderCone
VectorAffineFunctionPositiveSemidefiniteConeTriangle
VectorAffineFunctionExponentialCone
VectorAffineFunctionDualExponentialCone
VectorAffineFunctionPowerCone
VectorAffineFunctionDualPowerCone

Note that some of MOI constraints can be bridged, see Bridges, to constraints in this list.

Supported objective functions

MOI Function
VariableIndex
ScalarAffineFunction
ScalarQuadraticFunction

Dualize a model

Dualization.dualizeFunction
dualize(args...; kwargs...)

The dualize function works in three different ways. The user can provide:

  • A MathOptInterface.ModelLike

    The function will return a DualProblem struct that has the dualized model and PrimalDualMap{Float64} for users to identify the links between primal and dual model. The PrimalDualMap{Float64} maps variables and constraints from the original primal model into the respective objects of the dual model.

  • A MathOptInterface.ModelLike and a DualProblem{T}

  • A JuMP.Model

    The function will return a JuMP model with the dual representation of the problem.

  • A JuMP.Model and an optimizer constructor

    The function will return a JuMP model with the dual representation of the problem with the optimizer constructor attached.

On each of these methods, the user can provide the following keyword arguments:

  • dual_names: of type DualNames struct. It allows users to set more intuitive names for the dual variables and dual constraints created.

  • variable_parameters: A vector of MOI.VariableIndex containing the variables that should not be considered model variables during dualization. These variables will behave like constants during dualization. This is especially useful for the case of bi-level modelling, where the second level depends on some decisions from the upper level.

  • ignore_objective: a boolean indicating if the objective function should be added to the dual model. This is also useful for bi-level modelling, where the second level model is represented as a KKT in the upper level model.

source

DualOptimizer

You can solve a primal problem by using its dual formulation using the DualOptimizer.

Dualization.DualOptimizerType
DualOptimizer(dual_optimizer::OT) where {OT <: MOI.ModelLike}

The DualOptimizer finds the solution for a problem by solving its dual representation. It builds the dual model internally and solve it using the dual_optimizer as the solver.

Primal results are obtained by querying dual results of the internal problem solved by dual_optimizer. Analogously, dual results are obtained by querying primal results of the internal problem.

The user can define the model providing the DualOptimizer and the solver of its choice.

Example

julia> using Dualization, JuMP, HiGHS
+\end{align}\]

Supported constraints

This is the list of supported Function-in-Set constraints of the package. If you try to dualize a constraint not listed here, it will return an unsupported error.

MOI FunctionMOI Set
VariableIndexGreaterThan
VariableIndexLessThan
VariableIndexEqualTo
ScalarAffineFunctionGreaterThan
ScalarAffineFunctionLessThan
ScalarAffineFunctionEqualTo
VectorOfVariablesNonnegatives
VectorOfVariablesNonpositives
VectorOfVariablesZeros
VectorOfVariablesSecondOrderCone
VectorOfVariablesRotatedSecondOrderCone
VectorOfVariablesPositiveSemidefiniteConeTriangle
VectorOfVariablesExponentialCone
VectorOfVariablesDualExponentialCone
VectorOfVariablesPowerCone
VectorOfVariablesDualPowerCone
VectorAffineFunctionNonnegatives
VectorAffineFunctionNonpositives
VectorAffineFunctionZeros
VectorAffineFunctionSecondOrderCone
VectorAffineFunctionRotatedSecondOrderCone
VectorAffineFunctionPositiveSemidefiniteConeTriangle
VectorAffineFunctionExponentialCone
VectorAffineFunctionDualExponentialCone
VectorAffineFunctionPowerCone
VectorAffineFunctionDualPowerCone

Note that some of MOI constraints can be bridged, see Bridges, to constraints in this list.

Supported objective functions

MOI Function
VariableIndex
ScalarAffineFunction
ScalarQuadraticFunction

Dualize a model

Dualization.dualizeFunction
dualize(args...; kwargs...)

The dualize function works in three different ways. The user can provide:

  • A MathOptInterface.ModelLike

    The function will return a DualProblem struct that has the dualized model and PrimalDualMap{Float64} for users to identify the links between primal and dual model. The PrimalDualMap{Float64} maps variables and constraints from the original primal model into the respective objects of the dual model.

  • A MathOptInterface.ModelLike and a DualProblem{T}

  • A JuMP.Model

    The function will return a JuMP model with the dual representation of the problem.

  • A JuMP.Model and an optimizer constructor

    The function will return a JuMP model with the dual representation of the problem with the optimizer constructor attached.

On each of these methods, the user can provide the following keyword arguments:

  • dual_names: of type DualNames struct. It allows users to set more intuitive names for the dual variables and dual constraints created.

  • variable_parameters: A vector of MOI.VariableIndex containing the variables that should not be considered model variables during dualization. These variables will behave like constants during dualization. This is especially useful for the case of bi-level modelling, where the second level depends on some decisions from the upper level.

  • ignore_objective: a boolean indicating if the objective function should be added to the dual model. This is also useful for bi-level modelling, where the second level model is represented as a KKT in the upper level model.

source

DualOptimizer

You can solve a primal problem by using its dual formulation using the DualOptimizer.

Dualization.DualOptimizerType
DualOptimizer(dual_optimizer::OT) where {OT <: MOI.ModelLike}

The DualOptimizer finds the solution for a problem by solving its dual representation. It builds the dual model internally and solve it using the dual_optimizer as the solver.

Primal results are obtained by querying dual results of the internal problem solved by dual_optimizer. Analogously, dual results are obtained by querying primal results of the internal problem.

The user can define the model providing the DualOptimizer and the solver of its choice.

Example

julia> using Dualization, JuMP, HiGHS
 
 julia> model = Model(dual_optimizer(HiGHS.Optimizer))
 A JuMP Model
@@ -115,7 +115,7 @@
 Variables: 0
 Model mode: AUTOMATIC
 CachingOptimizer state: EMPTY_OPTIMIZER
-Solver name: Dual model with HiGHS attached
source

Solving an optimization problem via its dual representation can be useful because some conic solvers assume the model is in the standard form and others use the geometric form.

Geometric form has affine expressions in cones

\[\begin{align} +Solver name: Dual model with HiGHS attached
source

Solving an optimization problem via its dual representation can be useful because some conic solvers assume the model is in the standard form and others use the geometric form.

Geometric form has affine expressions in cones

\[\begin{align} & \min_{x \in \mathbb{R}^n} & c^T x \\ & \;\;\text{s.t.} & A_i x + b_i & \in \mathcal{C}_i & i = 1 \ldots m diff --git a/previews/PR168/reference/index.html b/previews/PR168/reference/index.html index cf5711b..94bb15d 100644 --- a/previews/PR168/reference/index.html +++ b/previews/PR168/reference/index.html @@ -1,2 +1,2 @@ -Reference · Dualization.jl

Reference

Dualization.supported_constraintsFunction
supported_constraints(con_types::Vector{Tuple{Type, Type}})

Returns true if Function-in-Set is supported for Dualization and throws an error if it is not.

source
Dualization.supported_objectiveFunction
supported_objective(primal_model::MOI.ModelLike)

Returns true if MOI.ObjectiveFunctionType() is supported for Dualization and throws an error if it is not.

source
Dualization.DualNamesType
DualNames

DualNames is a struct to pass the prefix of dual variables and dual constraints names.

See more on naming the variables.

source
+Reference · Dualization.jl

Reference

Dualization.supported_constraintsFunction
supported_constraints(con_types::Vector{Tuple{Type, Type}})

Returns true if Function-in-Set is supported for Dualization and throws an error if it is not.

source
Dualization.supported_objectiveFunction
supported_objective(primal_model::MOI.ModelLike)

Returns true if MOI.ObjectiveFunctionType() is supported for Dualization and throws an error if it is not.

source
Dualization.DualNamesType
DualNames

DualNames is a struct to pass the prefix of dual variables and dual constraints names.

See more on naming the variables.

source
diff --git a/previews/PR168/search/index.html b/previews/PR168/search/index.html index 1f9c902..9bd71a8 100644 --- a/previews/PR168/search/index.html +++ b/previews/PR168/search/index.html @@ -1,2 +1,2 @@ -Search · Dualization.jl

Loading search...

    +Search · Dualization.jl

    Loading search...