Skip to content

Commit

Permalink
documentation page added
Browse files Browse the repository at this point in the history
  • Loading branch information
sshin23 committed Jul 30, 2023
1 parent 3852dcb commit 18c3b60
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 304 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Documentation

on:
push:
branches:
- master # update to match your development branch (master, main, dev, trunk, ...)
tags: '*'
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: '1.9'
- name: Install dependencies
run: julia --project=docs/ docs/install.jl
- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
run: julia --project=docs/ docs/make.jl
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

| **License** | **Documentation** | **Build Status** | **Coverage** | **Citation** |
|:-----------------:|:----------------:|:----------------:|:----------------:|:----------------:|
| [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | [![doc](https://img.shields.io/badge/docs-dev-blue.svg)](https://sshin23.github.io/SIMDiff.jl/dev) | [![build](https://github.com/sshin23/SIMDiff.jl/actions/workflows/test.yml/badge.svg)](https://github.com/sshin23/SIMDiff.jl/actions/workflows/test.yml) | [![codecov](https://codecov.io/gh/sshin23/SIMDiff.jl/branch/main/graph/badge.svg?token=8ViJWBWnZt)](https://codecov.io/gh/sshin23/SIMDiff.jl) |
| [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | [![doc](https://img.shields.io/badge/docs-dev-blue.svg)](https://github.com/sshin23/SIMDiff.jl/dev) | [![build](https://github.com/sshin23/SIMDiff.jl/actions/workflows/test.yml/badge.svg)](https://github.com/sshin23/SIMDiff.jl/actions/workflows/test.yml) | [![codecov](https://codecov.io/gh/sshin23/SIMDiff.jl/branch/main/graph/badge.svg?token=8ViJWBWnZt)](https://codecov.io/gh/sshin23/SIMDiff.jl) |

## Introduction
SIMDiff.jl employs what we call **SIMD abstraction for nonlinear programs** (NLPs), which allows for the **preservation of the parallelizable structure** within the model equations, facilitating **efficient, parallel derivative evaluations** on the **GPU**.
Expand Down
20 changes: 7 additions & 13 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
using Documenter, MadDiff, Literate
using Documenter, SIMDiff, Literate

const _PAGES = [
"Introduction" => "index.md",
"Quick Start"=>"guide.md",
"How it Works" => "tutorial.md",
"API Manual" => [
"MadDiffCore" => "core.md",
"MadDiffSpecialFunctions" => "special.md",
"MadDiffModels" => "models.md",
"MadDiffMOI" => "moi.md",
]
"API Manual" => "core.md",
]

const _JL_FILENAMES = [
"guide.jl",
"tutorial.jl"
# "tutorial.jl"
]

for jl_filename in _JL_FILENAMES
Expand All @@ -30,15 +24,15 @@ end


makedocs(
sitename = "MadDiff",
sitename = "SIMDiff.jl",
authors = "Sungho Shin",
format = Documenter.LaTeX(platform="docker"),
pages = _PAGES
)

makedocs(
sitename = "MadDiff",
modules = [MadDiff],
sitename = "SIMDiff.jl",
modules = [SIMDiff],
authors = "Sungho Shin",
format = Documenter.HTML(
prettyurls = get(ENV, "CI", nothing) == "true",
Expand All @@ -51,6 +45,6 @@ makedocs(


deploydocs(
repo = "github.com/sshin23/MadDiff.jl.git"
repo = "github.com/sshin23/SIMDiff.jl.git"
)

Empty file removed docs/src/algorithms.md
Empty file.
4 changes: 2 additions & 2 deletions docs/src/core.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MadDiffCore
# SIMDiff
```@autodocs
Modules = [MadDiffCore]
Modules = [SIMDiff]
```
41 changes: 18 additions & 23 deletions docs/src/guide.jl
Original file line number Diff line number Diff line change
@@ -1,46 +1,41 @@
# # Getting Started
# SIMDiff provides a built-in API for creating nonlinear prgogramming models and allows solving the created models using NLP solvers (in particular, those that are interfaced with `NLPModels`, such as [NLPModelsIpopt](https://github.com/JuliaSmoothOptimizers/NLPModelsIpopt.jl). We now use `SIMDiff`'s bulit-in API to model the following nonlinear program:
# SIMDiff can create nonlinear prgogramming models and allows solving the created models using NLP solvers (in particular, those that are interfaced with `NLPModels`, such as [NLPModelsIpopt](https://github.com/JuliaSmoothOptimizers/NLPModelsIpopt.jl). We now use `SIMDiff` to model the following nonlinear program:
# ```math
# \begin{aligned}
# \min_{\{x_i\}_{i=0}^N} &\sum_{i=2}^N 100(x_{i-1}^2-x_i)^2+(x_{i-1}-1)^2\\
# \text{s.t.} & 3x_{i+1}^3+2x_{i+2}-5+\sin(x_{i+1}-x_{i+2})\sin(x_{i+1}+x_{i+2})+4x_{i+1}-x_i e^{x_i-x_{i+1}}-3 = 0
# \end{aligned}
# ```
# We model the problem with:
using SIMDiff

# We set
N = 10000

# First, we create a `SIMDiffModel`.
m = SIMDiffModel()
# First, we create a `SIMDiff.Core`.
c = SIMDiff.Core()

# The variables can be created as follows:
x = [variable(m; start = mod(i,2)==1 ? -1.2 : 1.) for i=1:N];

x = SIMDiff.variable(
c, N;
start = (mod(i,2)==1 ? -1.2 : 1. for i=1:N)
)

# The objective can be set as follows:
objective(m, sum(100(x[i-1]^2-x[i])^2+(x[i-1]-1)^2 for i=2:N));
SIMDiff.objective(c, 100*(x[i-1]^2-x[i])^2+(x[i-1]-1)^2 for i in 2:N)

# The constraints can be set as follows:
for i=1:N-2
constraint(m, 3x[i+1]^3+2*x[i+2]-5+sin(x[i+1]-x[i+2])sin(x[i+1]+x[i+2])+4x[i+1]-x[i]exp(x[i]-x[i+1])-3 == 0);
end
SIMDiff.constraint(
c,
3x[i+1]^3+2*x[i+2]-5+sin(x[i+1]-x[i+2])sin(x[i+1]+x[i+2])+4x[i+1]-x[i]exp(x[i]-x[i+1])-3
for i in 1:N-2)

# The important last step is instantiating the model. This step must be taken before calling optimizers.
instantiate!(m)
# Finally, we create an NLPModel.
m = SIMDiff.Model(c)

# To solve the problem with `Ipopt`,
using NLPModelsIpopt
sol = ipopt(m);

# The solution `sol` contains the field `sol.solution` holding the optimized parameters.

# ### SIMDiff as an AD backend of JuMP
# SIMDiff can be used as an automatic differentiation backend of JuMP. The problem above can be modeled in `JuMP` and solved with `Ipopt` along with `SIMDiff`

using JuMP, Ipopt

m = JuMP.Model(Ipopt.Optimizer)

@variable(m, x[i=1:N], start=mod(i,2)==1 ? -1.2 : 1.)
@NLobjective(m, Min, sum(100(x[i-1]^2-x[i])^2+(x[i-1]-1)^2 for i=2:N))
@NLconstraint(m, [i=1:N-2], 3x[i+1]^3+2*x[i+2]-5+sin(x[i+1]-x[i+2])sin(x[i+1]+x[i+2])+4x[i+1]-x[i]exp(x[i]-x[i+1])-3 == 0)

optimize!(m; differentiation_backend = SIMDiffAD())
288 changes: 47 additions & 241 deletions docs/src/guide.md

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions docs/src/models.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/src/moi.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/src/special.md

This file was deleted.

2 changes: 0 additions & 2 deletions docs/src/tutorial.jl

This file was deleted.

10 changes: 0 additions & 10 deletions docs/src/tutorial.md

This file was deleted.

0 comments on commit 18c3b60

Please sign in to comment.