|
98 | 98 |
|
99 | 99 | _function_map = {} |
100 | 100 |
|
101 | | -gurobipy, gurobipy_available = attempt_import('gurobipy', minimum_version='12.0.0') |
102 | | -if gurobipy_available: |
103 | | - from gurobipy import GRB, nlfunc |
104 | 101 |
|
| 102 | +def _finalize_gurobipy(gurobipy, available): |
| 103 | + if not available: |
| 104 | + return |
105 | 105 | _function_map.update( |
106 | 106 | { |
107 | | - 'exp': (_GENERAL, nlfunc.exp), |
108 | | - 'log': (_GENERAL, nlfunc.log), |
109 | | - 'log10': (_GENERAL, nlfunc.log10), |
110 | | - 'sin': (_GENERAL, nlfunc.sin), |
111 | | - 'cos': (_GENERAL, nlfunc.cos), |
112 | | - 'tan': (_GENERAL, nlfunc.tan), |
113 | | - 'sqrt': (_GENERAL, nlfunc.sqrt), |
| 107 | + 'exp': (_GENERAL, gurobipy.nlfunc.exp), |
| 108 | + 'log': (_GENERAL, gurobipy.nlfunc.log), |
| 109 | + 'log10': (_GENERAL, gurobipy.nlfunc.log10), |
| 110 | + 'sin': (_GENERAL, gurobipy.nlfunc.sin), |
| 111 | + 'cos': (_GENERAL, gurobipy.nlfunc.cos), |
| 112 | + 'tan': (_GENERAL, gurobipy.nlfunc.tan), |
| 113 | + 'sqrt': (_GENERAL, gurobipy.nlfunc.sqrt), |
114 | 114 | # Not supporting any of these right now--we'd have to build them from the |
115 | 115 | # above: |
116 | 116 | # 'asin': None, |
|
128 | 128 | ) |
129 | 129 |
|
130 | 130 |
|
| 131 | +gurobipy, gurobipy_available = attempt_import( |
| 132 | + 'gurobipy', |
| 133 | + deferred_submodules=['GRB'], |
| 134 | + callback=_finalize_gurobipy, |
| 135 | + minimum_version='12.0.0', |
| 136 | +) |
| 137 | +GRB = gurobipy.GRB |
| 138 | + |
| 139 | + |
131 | 140 | """ |
132 | 141 | In Gurobi 12: |
133 | 142 |
|
|
0 commit comments