Skip to content

Commit

Permalink
adding more bots + fixing readme formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
dfridovi committed Nov 27, 2024
1 parent 38e2601 commit 2e05e3a
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 12 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Set update schedule for GitHub Actions
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
22 changes: 22 additions & 0 deletions .github/workflows/compat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CompatHelper
on:
schedule:
- cron: '00 00 * * *'
push:
branches: [ main ]
pull_request:
branches: [ main ]
issues:
types: [opened, reopened]

jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.GHACTION_PRIV }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
20 changes: 20 additions & 0 deletions .github/workflows/tagbot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: 3
permissions:
contents: write
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.GHACTION_PRIV }}
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ As discussed below, this package replicates functionality already available in [

Suppose we have the following quadratic program:
```displaymath
&\min_x~ &\frac{1}{2} x^\top M x - θ^\top x\\
&s.t. &Ax - b \ge 0.
min_x 0.5 xᵀ M x - θᵀ x
s.t. Ax - b 0.
```

The KKT conditions for this problem can be expressed as follows:
```displaymath
G(x, y; θ) = M x - θ - A^\top y &= 0\\
H(x, y; θ) = A x - b &\ge 0\\
y &\ge 0\\
y^\top H(x, y; θ) = 0,
G(x, y; θ) = Mx - Aᵀ y - θ = 0
H(x, y; θ) = Ax - b ≥ 0
y ≥ 0
yᵀ H(x, y; θ) = 0,
```
where $y$ is the Lagrange multiplier associated to the constraint $Ax - b \ge 0$ in the original problem.
where `y` is the Lagrange multiplier associated to the constraint `Ax - b ≥ 0` in the original problem.

This is precisely a MCP, whose standard form is:
```displaymath
G(x, y; θ) &= 0\\
0 \le y \perp H(x, y; θ) &\ge 0.
G(x, y; θ) = 0
0 y H(x, y; θ) ≥ 0 0.
```

Now, we can encode this problem and solve it using `MCPSolver` as follows:
Expand Down Expand Up @@ -73,10 +73,11 @@ sol = MCPSolver.solve(
Note that the initial guess for the $y$ variable must be elementwise positive. This is because we are using an interior point method; for further details, refer to `src/solver.jl`.

Finally, `MCPSolver` integrates with `ChainRulesCore` and `ForwardDiff` so you can differentiate through the solver itself! For example, suppose we wanted to find the value of $\theta$ in the problem above which solves
```math
&\min_{\theta, x, y}~ &\overbrace{\|x\|_2^2 + \|y\|_2^2}^{f(x, y)}\\
&s.t. &(x, y) solves \text{MCP}(\theta).
```displaymath
min_{θ, x, y} f(x, y)
s.t. (x, y) solves MCP).
```

We could do so by initializing with a particular value of $\theta$ and then iteratively descending the gradient $\nabla_\theta f$, which we can easily compute via:
```julia
mcp = MCPSolver.PrimalDualMCP(
Expand All @@ -90,6 +91,8 @@ mcp = MCPSolver.PrimalDualMCP(

function f(θ)
sol = MCPSolver.solve(MCPSolver.InteriorPoint(), mcp, θ)

# Some example objective function that depends on `x` and `y`.
sum(sol.x .^ 2) + sum(sol.y .^ 2)
end

Expand Down

0 comments on commit 2e05e3a

Please sign in to comment.