-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
80 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
ConstraintDual(N) | ||
ConstraintDual() | ||
A constraint attribute for the vector of moments corresponding to the | ||
constraint that a polynomial is zero in the full space in result `N`. If the | ||
polynomial is constrained to be zero in an algebraic set, it is the moments | ||
for the constraint once it is rewritten into an constraint on the full space. | ||
If `N` is omitted, it is 1 by default. | ||
## Examples | ||
Consider the following program: | ||
```julia | ||
@variable(model, α) | ||
@variable(model, β ≤ 1) | ||
using DynamicPolynomials | ||
@polyvar x y | ||
cref = @constraint(model, α * x - β * y == 0, domain = @set x == y) | ||
``` | ||
The constraint is equivalent to | ||
```julia | ||
@constraint(model, (α - β) * y == 0) | ||
``` | ||
for which the dual is the 1-element vector with the moment of `y` of value `-1`. | ||
This is the result of `moments(cref)`. However, the dual of `cref` obtained by | ||
`dual(cref)` is the 2-elements vector with both the moments of `x` and `y` | ||
of value `-1`. | ||
""" | ||
struct MomentsAttribute <: MOI.AbstractConstraintAttribute | ||
N::Int | ||
end | ||
MomentsAttribute() = MomentsAttribute(1) | ||
|
||
function MOI.is_set_by_optimize(::MomentsAttribute) | ||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters