Skip to content

Commit 85dd153

Browse files
committed
Merge branch 'mt/docs_sidebar'
2 parents d34755b + 65e5ac4 commit 85dd153

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/src/gradients/other_ad.md

+21
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
For more on how to construct a backend struct for each AD package, please refer to the README file of the [`AbstractDifferentiation`](https://github.com/JuliaDiff/AbstractDifferentiation.jl) repository.
1212

13+
## `abstractdiffy`ing a function
14+
1315
In order to use a specific `AbstractDifferentiation`-compatible AD package to differentiate a function `f(x...)` used in a `Nonconvex` objective/constraint, you can use the `abstractdiffy` function modifier from `Nonconvex`:
1416
```julia
1517
F = abstractdiffy(f, backend, x...)
@@ -42,3 +44,22 @@ which is short for:
4244
backend = AbstractDifferentiation.ForwardDiffBackend()
4345
F = abstractdiffy(f, backend, x...)
4446
```
47+
48+
## `abstractdiffy`ing a model
49+
50+
Instead of `abstractdiffy`ing or `forwarddiffy`ing one function at a time, the user can instead `abstractdiffy` or `forwarddiffy` an entire `Nonconvex` model including the objective, all the inequality constraint functions, all the equality constraint functions and all the semidefinite constraint functions.
51+
```julia
52+
ad_model = abstractdiffy(model, backend)
53+
```
54+
where `model` is of type `Model` or `DictModel`. `ad_model` can now be optimized using any of the `Nonconvex` algorithms compatible with the model. Similarly, `forwarddiffy` can be used on an entire model:
55+
```julia
56+
fd_model = forwarddiffy(model)
57+
```
58+
59+
By default, the objective and all the constraint functions will be modified with `abstractdiffy`/`forwarddiffy`. To prevent the modification of some component of the model, any of the following keyword arguments can be set to `false` (default is `true`):
60+
- `objective = false`
61+
- `ineq_constraints = false`
62+
- `eq_constraints = false`
63+
- `sd_constraints = false`
64+
65+
Setting the `objective`, `ineq_constraints`, `eq_constraints`, and/or `sd_constraints` keyword arguments to `false` (default is `true`) will prevent the modification of the objective, all the inequality constraint functions, all the equality constraint functions, and/or all the semidefinite constraint functions respectively.

0 commit comments

Comments
 (0)