Skip to content

Commit

Permalink
Merge pull request #62 from DimitriAlston/master
Browse files Browse the repository at this point in the history
v0.13.5 Update
  • Loading branch information
DimitriAlston committed Jul 14, 2023
2 parents 50bc327 + 6f25d4a commit 0fcbf69
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
4 changes: 2 additions & 2 deletions 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.4"
version = "0.13.5"

[deps]
DiffRules = "b552c78f-8df3-52c6-915a-8e097449b14b"
Expand All @@ -24,7 +24,7 @@ ForwardDiff = "~0.10"
IntervalArithmetic = "~0.20"
IntervalRootFinding = "~0.5"
NaNMath = "0.3.5, 1.0"
NNlib = "~0.7"
NNlib = "~0.8"
Reexport = "~0.2, ~1"
StaticArrays = "~1.2"
SpecialFunctions = "~1, ~2"
Expand Down
34 changes: 26 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

A Forward McCormick Operator Library

| **PSOR Lab** | **Build Status** | **Persistent DOI** |
|:------------:|:-----------------------------------------------------------------------:|:----------------------------------------:|
| [![](https://img.shields.io/badge/Developed_by-PSOR_Lab-342674)](https://psor.uconn.edu/) | [![Build Status](https://github.com/PSORLab/McCormick.jl/workflows/CI/badge.svg?branch=master)](https://github.com/PSORLab/McCormick.jl/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/PSORLab/McCormick.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/PSORLab/McCormick.jl) | [![DOI](https://zenodo.org/badge/245830962.svg)](https://zenodo.org/badge/latestdoi/245830962) |
| **PSOR Lab** | **Build Status** |
|:--------------:|:-----------------------------------------------------------------------:|
| [![](https://img.shields.io/badge/Developed_by-PSOR_Lab-342674)](https://psor.uconn.edu/) | [![Build Status](https://github.com/PSORLab/McCormick.jl/workflows/CI/badge.svg?branch=master)](https://github.com/PSORLab/McCormick.jl/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/PSORLab/McCormick.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/PSORLab/McCormick.jl) |

| **Documentation** | **Persistent DOI** |
|:------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------:|
| [![](https://img.shields.io/badge/docs-stable-blue.svg)](https://PSORLab.github.io/EAGO.jl/stable/mccormick/overview/) [![](https://img.shields.io/badge/docs-latest-blue.svg)](https://psorlab.github.io/EAGO.jl/dev/mccormick/overview/) | [![DOI](https://zenodo.org/badge/245830962.svg)](https://zenodo.org/badge/latestdoi/245830962) |

McCormick.jl is a component package in the EAGO ecosystem and is reexported by [EAGO.jl](https://github.com/PSORLab/EAGO.jl). It contains a library of forward McCormick operators (both nonsmooth and differentiable). Documentation for this is included in the [EAGO.jl](https://github.com/PSORLab/EAGO.jl) package and additional usage examples are included in [EAGO-notebooks](https://github.com/PSORLab/EAGO-notebooks) as Jupyter Notebooks.

Expand Down Expand Up @@ -43,7 +47,11 @@ Differentiable relaxations (`Diff <: RelaxTag`) are supported for the functions

In order to bound a function using a McCormick relaxation, you first construct a McCormick object (`x::MC`) that bounds the input variables, and then you pass these variables to the desired function.

In the example below, convex/concave relaxations of the function $f(x) = x (x - 5) \sin(x)$ are calculated at $x = 2$ on the interval $[1, 4]$.
In the example below, convex/concave relaxations of the function

$$f(x) = x (x - 5) \sin(x)$$

are calculated at $x = 2$ on the interval $X = [1, 4]$.

```julia
using McCormick
Expand Down Expand Up @@ -72,13 +80,21 @@ Iv = fMC.Intv # Retrieve interval bounds of f(x) on Intv

Plotting the results, we can easily visualize the convex and concave relaxations, interval bounds, and affine bounds constructed using the subgradient at the middle of $X$.

![Figure_1](Figure_1.png)
<p align="center">
<img src="https://github.com/PSORLab/McCormick.jl/blob/master/Figure_1.png">
</p>

## Bounding a Multivariate Function

This can readily be extended to multivariate functions, for example:

$$f(x, y) = \big(4 - 2.1 x^{2} + \frac{x^{4}}{6} \big) x^{2} + x y + (-4 + 4 y^{2}) y^{2}$$
$$
\begin{aligned}
& f(x, y) = \big(4 - 2.1 x^{2} + \frac{x^{4}}{6} \big) x^{2} + x y + (-4 + 4 y^{2}) y^{2}\\
& X = [-2, 0]\\
& Y = [-0.5, 0.5]
\end{aligned}
$$

```julia
using McCormick
Expand All @@ -88,7 +104,7 @@ f(x, y) = (4.0 - 2.1*x^2 + (x^4)/6.0)*x^2 + x*y + (-4.0 + 4.0*y^2)*y^2

# Define intervals for independent variables
n = 30
X = Interval{Float64}(-2,0)
X = Interval{Float64}(-2, 0)
Y = Interval{Float64}(-0.5, 0.5)
xrange = range(X.lo, stop=X.hi, length=n)
yrange = range(Y.lo, stop=Y.hi, length=n)
Expand All @@ -106,7 +122,9 @@ for (i,x) in enumerate(xrange)
end
```

![Figure_3](Figure_3.png)
<p align="center">
<img src="https://github.com/PSORLab/McCormick.jl/blob/master/Figure_3.png">
</p>

## Citing McCormick.jl

Expand Down

2 comments on commit 0fcbf69

@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/87517

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.5 -m "<description of version>" 0fcbf693b0fbe350335552cbcf9dd090a1dc89b3
git push origin v0.13.5

Please sign in to comment.