Skip to content

Commit

Permalink
Merge pull request #64 from DimitriAlston/master
Browse files Browse the repository at this point in the history
Additional MC constructor
  • Loading branch information
DimitriAlston committed Sep 15, 2023
2 parents 0fcbf69 + 5261c5b commit b4a568f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "McCormick"
uuid = "53c679d3-6890-5091-8386-c291e8c8aaa1"
authors = ["Matthew Wilhelm <matthew.wilhelm@uconn.edu>"]
version = "0.13.5"
version = "0.13.6"

[deps]
DiffRules = "b552c78f-8df3-52c6-915a-8e097449b14b"
Expand Down
23 changes: 17 additions & 6 deletions src/McCormick.jl
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ end
"""
MC{N,T}(y::Interval{Float64})
Constructs McCormick relaxation with convex relaxation equal to `y.lo` and
Constructs a McCormick relaxation with the convex relaxation equal to `y.lo` and
concave relaxation equal to `y.hi`.
"""
function MC{N,T}(y::Interval{Float64}) where {N, T <: RelaxTag}
Expand All @@ -344,7 +344,7 @@ end
"""
MC{N,T}(y::Float64)
Constructs McCormick relaxation with convex relaxation equal to `y` and
Constructs a McCormick relaxation with the convex relaxation equal to `y` and
concave relaxation equal to `y`.
"""
MC{N,T}(y::Float64) where {N, T <: RelaxTag} = MC{N,T}(Interval{Float64}(y))
Expand All @@ -356,20 +356,31 @@ MC{N,T}(y::Q) where {N, T <: RelaxTag, Q <: NumberNotRelax} = MC{N,T}(Interval{F
"""
MC{N,T}(cv::Float64, cc::Float64)
Constructs McCormick relaxation with convex relaxation equal to `cv` and
Constructs a McCormick relaxation with the convex relaxation equal to `cv` and
concave relaxation equal to `cc`.
"""
function MC{N,T}(cv::Float64, cc::Float64) where {N, T <: RelaxTag}
MC{N,T}(cv, cc, Interval{Float64}(cv, cc), zero(SVector{N,Float64}),
zero(SVector{N,Float64}), true)
zero(SVector{N,Float64}), true)
end

"""
MC{N,T}(cv::Float64, cc::Float64, Intv::Interval{Float64})
Constructs a McCormick relaxation with the convex relaxation equal to `cv`,
concave relaxation equal to `cc`, and interval bounds of `Intv`.
"""
function MC{N,T}(cv::Float64, cc::Float64, Intv::Interval{Float64}) where {N, T <: RelaxTag}
MC{N,T}(cv, cc, Intv, zero(SVector{N,Float64}),
zero(SVector{N,Float64}), true)
end

"""
MC{N,T}(val::Float64, Intv::Interval{Float64}, i::Int64)
Constructs McCormick relaxation with convex relaxation equal to `val`,
Constructs a McCormick relaxation with the convex relaxation equal to `val`,
concave relaxation equal to `val`, interval bounds of `Intv`, and a unit subgradient
with nonzero's ith dimension of length N.
with a nonzero ith dimension of length N.
"""
function MC{N,T}(val::Float64, Intv::Interval{Float64}, i::Int64) where {N, T <: RelaxTag}
MC{N,T}(val, val, Intv, seed_gradient(i, Val{N}()), seed_gradient(i, Val{N}()), false)
Expand Down

2 comments on commit b4a568f

@DimitriAlston
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/91510

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.13.6 -m "<description of version>" b4a568f21f262c1848170ddf4e3182a8a5153af9
git push origin v0.13.6

Please sign in to comment.