Skip to content

Commit 77541e5

Browse files
authored
[docs] mention MOI.OptimizerWithAttributess (#433)
* [docs] mention MOI.OptimizerWithAttributess * Update solvers.md
1 parent 422f4fc commit 77541e5

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

docs/src/solvers.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,46 +38,48 @@ solve!(p, SCS.Optimizer)
3838
```
3939

4040
(Of course, the solver must be installed first.) For example, we can use
41-
GLPK to solve a MILP
42-
41+
GLPK to solve a MILP:
4342
```julia
4443
using GLPK
4544
solve!(p, GLPK.Optimizer)
4645
```
4746

48-
Many of the solvers also allow options to be passed in. More details can
49-
be found in each solver's documentation.
47+
Many of the solvers also allow options to be passed using
48+
`MOI.OptimizerWithAttributes`. For example, to set a time limit (in
49+
milliseconds) with GLPK, use:
50+
```julia
51+
using Convex, GLPK
52+
const MOI = Convex.MOI
5053

51-
For example, if we wish to turn off printing for the SCS solver (ie, run
52-
in quiet mode), we can do so by
54+
solve!(
55+
p,
56+
MOI.OptimizerWithAttributes(GLPK.Optimizer, "tm_lim" => 60_000.0)
57+
)
58+
```
5359

60+
As another example, if we wish to turn off printing for the SCS solver
61+
(i.e., run in quiet mode), we can do so as follows:
5462
```julia
55-
using SCS
56-
opt = () -> SCS.Optimizer(verbose=false)
63+
using Convex, SCS
64+
const MOI = Convex.MOI
65+
66+
opt = MOI.OptimizerWithAttributes(SCS.Optimizer, MOI.Silent() => false)
5767
solve!(p, opt)
5868
```
5969

60-
or equivalently,
61-
70+
Another option is to use the solver-independent `silent_solver`
71+
keyword argument to `solve!`:
6272
```julia
63-
solve!(p, () -> SCS.Optimizer(verbose=false))
73+
solve!(p, SCS.Optimizer; silent_solver=true)
6474
```
6575

66-
If we wish to increase the maximum number of iterations for ECOS or SCS,
67-
we can do so by
68-
69-
```julia
70-
using ECOS
71-
solve!(p, () -> ECOS.Optimizer(maxit=10000))
72-
using SCS
73-
solve!(p, () -> SCS.Optimizer(max_iters=10000))
74-
```
76+
See each solver's documentation for more information on solver-dependent
77+
options.
7578

7679
To turn off the problem status warning issued by Convex when a solver is
7780
not able to solve a problem to optimality, use the keyword argument
78-
`verbose=false` of the solve method, along with any desired
79-
solver parameters:
81+
`verbose=false` of the solve method:
8082

8183
```julia
82-
solve!(p, () -> SCS.Optimizer(verbose=false), verbose=false)
84+
solve!(p, SCS.Optimizer, verbose=false)
8385
```

0 commit comments

Comments
 (0)