@@ -38,46 +38,48 @@ solve!(p, SCS.Optimizer)
38
38
```
39
39
40
40
(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:
43
42
``` julia
44
43
using GLPK
45
44
solve! (p, GLPK. Optimizer)
46
45
```
47
46
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
50
53
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
+ ```
53
59
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:
54
62
``` 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 )
57
67
solve! (p, opt)
58
68
```
59
69
60
- or equivalently,
61
-
70
+ Another option is to use the solver-independent ` silent_solver `
71
+ keyword argument to ` solve! ` :
62
72
``` julia
63
- solve! (p, () -> SCS. Optimizer (verbose = false ) )
73
+ solve! (p, SCS. Optimizer; silent_solver = true )
64
74
```
65
75
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.
75
78
76
79
To turn off the problem status warning issued by Convex when a solver is
77
80
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:
80
82
81
83
``` julia
82
- solve! (p, () -> SCS. Optimizer (verbose = false ) , verbose= false )
84
+ solve! (p, SCS. Optimizer, verbose= false )
83
85
```
0 commit comments