Skip to content

Commit c6a8e80

Browse files
committed
Add example and format
1 parent b19acda commit c6a8e80

File tree

3 files changed

+53
-18
lines changed

3 files changed

+53
-18
lines changed

docs/src/index.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ packages.
4141

4242
## Overview of the Optimizers
4343

44-
| Package | Local Gradient-Based | Local Hessian-Based | Local Derivative-Free | Box Constraints | Local Constrained | Global Unconstrained | Global Constrained |
45-
|:----------------------- |:--------------------:|:-------------------:|:---------------------:|:---------------:|:-----------------:|:--------------------:|:------------------:|
46-
| BlackBoxOptim | ❌ | ❌ | ❌ |✅ | ❌ | ✅ | ❌ |✅
47-
| CMAEvolutionaryStrategy |||| ||||
48-
| Evolutionary |||| ||| 🟡 |
49-
| Flux |||| ||||
50-
| GCMAES |||| ||||
51-
| MathOptInterface |||| ||| 🟡 |
52-
| MultistartOptimization |||| ||||
53-
| Metaheuristics |||| ||| 🟡 |
54-
| NOMAD |||| ||| 🟡 |
55-
| NLopt |||| | 🟡 || 🟡 |
56-
| Nonconvex |||| | 🟡 || 🟡 |
57-
| Optim |||| ||||
58-
| QuadDIRECT |||| ||||
44+
| Package | Local Gradient-Based | Local Hessian-Based | Local Derivative-Free | Box Constraints | Local Constrained | Global Unconstrained | Global Constrained |
45+
|:----------------------- |:--------------------:|:-------------------:|:---------------------:|:---------------:|:-----------------:|:--------------------:|:--------------------:|
46+
| BlackBoxOptim ||| | ||||
47+
| CMAEvolutionaryStrategy ||| | ||| |
48+
| Evolutionary ||| | ||| 🟡 |
49+
| Flux ||| | ||| |
50+
| GCMAES ||| | ||| |
51+
| MathOptInterface ||| | ||| 🟡 |
52+
| MultistartOptimization ||| | ||| |
53+
| Metaheuristics ||| | ||| 🟡 |
54+
| NOMAD ||| | ||| 🟡 |
55+
| NLopt ||| | | 🟡 || 🟡 |
56+
| Nonconvex ||| | | 🟡 || 🟡 |
57+
| Optim ||| | ||| |
58+
| QuadDIRECT ||| | ||| |
5959

6060
✅ = supported
6161

docs/src/optimization_packages/mathoptinterface.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,35 @@ opt = OptimizationMOI.MOI.OptimizerWithAttributes(Juniper.Optimizer,
7676
"print_level" => 0))
7777
sol = solve(prob, opt)
7878
```
79+
80+
#### Using Integer Constraints
81+
82+
The following shows how to use integer linear programming within `Optimization`. We will solve the classical Knapsack Problem using `Juniper.jl`.
83+
84+
- [`Juniper.Optimizer`](https://github.com/lanl-ansi/Juniper.jl)
85+
- Juniper requires a nonlinear optimizer to be set via the `nl_solver` option,
86+
which must be a MathOptInterface-based optimizer. See the
87+
[Juniper documentation](https://github.com/lanl-ansi/Juniper.jl) for more
88+
detail.
89+
- Allows only for binary decisions
90+
91+
```@example MOI
92+
v = [1.0, 2.0, 4.0, 3.0]
93+
w = [5.0, 4.0, 3.0, 2.0]
94+
W = 4.0
95+
u0 = [0.0, 0.0, 0.0, 1.0]
96+
97+
optfun = OptimizationFunction((u, p) -> -v'u, cons = (res, u, p) -> res .= w'u,
98+
Optimization.AutoForwardDiff())
99+
100+
optprob = OptimizationProblem(optfun, u0; lb = zero.(u0), ub = one.(u0),
101+
int = ones(Bool, length(u0)),
102+
lcons = [-Inf;], ucons = [W;])
103+
104+
nl_solver = OptimizationMOI.MOI.OptimizerWithAttributes(Ipopt.Optimizer,
105+
"print_level" => 0)
106+
minlp_solver = OptimizationMOI.MOI.OptimizerWithAttributes(Juniper.Optimizer,
107+
"nl_solver" => nl_solver)
108+
109+
res = solve(optprob, minlp_solver)
110+
```

docs/src/tutorials/intro.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ sol.original
4545
```
4646

4747
## Defining the objective function
48+
4849
Optimization.jl assumes that your objective function takes two arguments `objective(x, p)`
49-
1. The optimization variables `x`.
50-
2. Other parameters `p`, such as hyper parameters of the cost function.
51-
If you have no “other parameters”, you can safely disregard this argument. If your objective function is defined by someone else, you can create an anonymous function that just discards the extra parameters like this
50+
51+
1. The optimization variables `x`.
52+
2. Other parameters `p`, such as hyper parameters of the cost function.
53+
If you have no “other parameters”, you can safely disregard this argument. If your objective function is defined by someone else, you can create an anonymous function that just discards the extra parameters like this
54+
5255
```julia
5356
obj = (x, p) -> objective(x) # Pass this function into OptimizationFunction
5457
```

0 commit comments

Comments
 (0)