@@ -271,9 +271,10 @@ optimize!(model)
271
271
272
272
## Reusing the same Gurobi environment for multiple solves
273
273
274
- When using this package via other packages such as [ JuMP.jl] ( https://github.com/jump-dev/JuMP.jl ) ,
275
- the default behavior is to obtain a new Gurobi license token every time a model
276
- is created. If you are using Gurobi in a setting where the number of concurrent
274
+ The default behavior of ` Gurobi.Optimizer() ` is to create a new Gurobi
275
+ environment (and license token) for each model.
276
+
277
+ If you are using Gurobi in a setting where the number of concurrent
277
278
Gurobi uses is limited (for example, [ "Single-Use" or "Floating-Use" licenses] ( http://www.gurobi.com/products/licensing-pricing/licensing-overview ) ),
278
279
you might instead prefer to obtain a single license token that is shared by all
279
280
models that your program solves.
@@ -292,6 +293,13 @@ model_2 = direct_model(Gurobi.Optimizer(GRB_ENV))
292
293
set_attribute (model_2, " OutputFlag" , 0 )
293
294
```
294
295
296
+ ### Environments are not thread-safe
297
+
298
+ ` Gurobi.Env ` are NOT thread-safe. If two models both use the same environment
299
+ you must not solve them simultaneously on different threads.
300
+
301
+ ### Environments inside a module
302
+
295
303
If you create a module with a ` Gurobi.Env ` as a module-level constant, use an
296
304
` __init__ ` function to ensure that a new environment is created each time the
297
305
module is loaded:
@@ -315,7 +323,7 @@ create_optimizer() = Gurobi.Optimizer(GRB_ENV_REF[])
315
323
end # MyModule
316
324
```
317
325
318
- ## Pass parameters to an Environment
326
+ ### Pass parameters to an Environment
319
327
320
328
To set parameters in an environment before the environment is started, pass a
321
329
` Dict{String,Any} ` that maps parameter names to values:
0 commit comments