File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,35 @@ model_2 = Model(() -> KNITRO.Optimizer(; license_manager = manager))
6767
6868To release the license manager, do ` KNITRO.KN_release_license(manager) ` .
6969
70+ ### Type stability
71+
72+ KNITRO.jl v0.14.7 moved the ` KNITRO.Optimizer ` object to a package extension. As
73+ a consequence, ` KNITRO.Optimizer ` is now type unstable, and it will be inferred
74+ as ` KNITRO.Optimizer()::Any ` .
75+
76+ In most cases, this should not impact performance. If it does, there are two
77+ work-arounds.
78+
79+ First, you can use a function barrier:
80+ ``` julia
81+ using JuMP, KNITRO
82+ function main (optimizer:: T ) where {T}
83+ model = Model (optimizer)
84+ return
85+ end
86+ main (KNITRO. Optimizer)
87+ ```
88+ Although the outer ` KNITRO.Optimizer ` is type unstable, the ` optimizer ` inside
89+ ` main ` will be properly inferred.
90+
91+ Second, you may explicitly get and use the extension module:
92+ ``` julia
93+ using JuMP, KNITRO
94+ const KNITROMathOptInterfaceExt =
95+ Base. get_extension (KNITRO, :KNITROMathOptInterfaceExt )
96+ model = Model (KNITROMathOptInterfaceExt. Optimizer)
97+ ```
98+
7099## Use with AMPL
71100
72101To use KNITRO with [ AmplNLWriter.jl] ( https://github.com/jump-dev/AmplNLWriter.jl ) ,
You can’t perform that action at this time.
0 commit comments