gurobipy 12.0.3__cp313-cp313-win_amd64.whl → 13.0.0b1__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,169 @@
1
+ from gurobipy._grb import GRB
2
+ from gurobipy._lowlevel import _load_model_memoryview, _add_qp_terms_memoryview
3
+ from gurobipy._util import _isscalar
4
+
5
+
6
+ def _double_array_argument(arg, size):
7
+ """If arg is a single value, build a repeating array. Otherwise,
8
+ let numpy handle conversion from an arbitrary iterator."""
9
+ import numpy as np
10
+
11
+ if _isscalar(arg):
12
+ arg = float(arg)
13
+ repeat = np.empty(size, dtype="float64")
14
+ repeat.fill(arg)
15
+ return repeat
16
+
17
+ else:
18
+ return np.require(arg, dtype="float64", requirements=["C"])
19
+
20
+
21
+ def _char_array_argument(arg, size):
22
+ """Convert str or bytearray to bytes. If a single value is given and
23
+ size is not None, build a repeating byte array. Otherwise, let numpy
24
+ handle conversion from an arbitrary iterator."""
25
+
26
+ import numpy as np
27
+
28
+ # Convert to bytes first if possible. Single character case still
29
+ # needs to be handled after conversion.
30
+ if isinstance(arg, str):
31
+ arg = arg.encode()
32
+
33
+ if isinstance(arg, (bytes, bytearray)):
34
+ if size is not None and len(arg) == 1:
35
+ return arg * size
36
+ else:
37
+ return arg
38
+ else:
39
+ return np.require(arg, dtype="S1", requirements=["C"]).tobytes()
40
+
41
+
42
+ def loadModel(
43
+ *,
44
+ env,
45
+ numvars,
46
+ numconstrs,
47
+ modelsense=GRB.MINIMIZE,
48
+ objcon=0.0,
49
+ obj=None,
50
+ lb=None,
51
+ ub=None,
52
+ vtype=None,
53
+ constr_csc=None,
54
+ sense=None,
55
+ rhs=None,
56
+ qobj_coo=None,
57
+ name=None,
58
+ ):
59
+ """
60
+ ROUTINE:
61
+ loadModel(...)
62
+
63
+ PURPOSE:
64
+ Load an optimization model from input data. You’ll need numpy
65
+ installed to use this function.
66
+
67
+ ARGUMENTS:
68
+ env – Environment to use to create the model.
69
+ numvars – Number of variables in the model.
70
+ numconstrs – Number of constraints in the model.
71
+ modelsense – Objective function sense (defaults to GRB.MINIMIZE).
72
+ objcon – Objective function constrant (defaults to 0.0).
73
+ obj – (optional) List or 1-D array of linear objective coefficients.
74
+ lb – (optional) List or 1-D array of variable lower bounds.
75
+ ub – (optional) List or 1-D array of variable upper bounds.
76
+ vtype – (optional) List or 1-D array of variable types.
77
+ constr_csc – (optional) CSC format linear constraint data.
78
+ sense – (optional) List or 1-D array of constraint senses.
79
+ rhs – (optional) List or 1-D array of constraint RHS values.
80
+ qobj_coo – (optional) COO format Q objective data.
81
+ name – (optional) Model name.
82
+
83
+ RETURN VALUE:
84
+ A Model object.
85
+ """
86
+
87
+ import numpy as np
88
+
89
+ if name is None:
90
+ modelname = b""
91
+ elif isinstance(name, str):
92
+ modelname = name.encode()
93
+ else:
94
+ raise TypeError("'name' must be a string or None")
95
+
96
+ # Prepare variable attribute arrays, repeating scalars if needed
97
+ if obj is not None:
98
+ obj = _double_array_argument(obj, size=numvars)
99
+ if lb is not None:
100
+ lb = _double_array_argument(lb, size=numvars)
101
+ if ub is not None:
102
+ ub = _double_array_argument(ub, size=numvars)
103
+ if vtype is not None:
104
+ vtype = _char_array_argument(vtype, size=numvars)
105
+
106
+ if constr_csc is None:
107
+ # No linear constraint matrix was given; construct an empty one
108
+ rhs = np.array([], dtype="float64")
109
+ sense = b""
110
+ vbeg = np.zeros((numvars,), dtype="uint64")
111
+ vlen = np.zeros((numvars,), dtype="int32")
112
+ vind = np.array([], dtype="int32")
113
+ vval = np.array([], dtype="float64")
114
+
115
+ else:
116
+ # To avoid ambiguity, a string for 'sense' must have length numconstrs.
117
+ # no '<=' or '<' allowed to set the same sense for all constraints.
118
+ sense = _char_array_argument(sense, size=None)
119
+
120
+ rhs = np.require(rhs, dtype="float64", requirements=["C"])
121
+
122
+ data, indices, indptr = constr_csc
123
+ vind = np.require(indices, dtype="int32", requirements=["C"])
124
+ vval = np.require(data, dtype="float64", requirements=["C"])
125
+
126
+ indptr = np.require(indptr, dtype="uint64", requirements=["C"])
127
+ vlen = np.empty(numvars, dtype="int32")
128
+ np.subtract(indptr[1:], indptr[:-1], out=vlen)
129
+ vbeg = indptr[:-1]
130
+
131
+ model = _load_model_memoryview(
132
+ env=env,
133
+ numvars=numvars,
134
+ numconstrs=numconstrs,
135
+ modelname=modelname,
136
+ objsense=modelsense,
137
+ objcon=objcon,
138
+ obj=obj,
139
+ sense=sense,
140
+ rhs=rhs,
141
+ vbeg=vbeg,
142
+ vlen=vlen,
143
+ vind=vind,
144
+ vval=vval,
145
+ lb=lb,
146
+ ub=ub,
147
+ vtype=vtype,
148
+ )
149
+
150
+ # Any further operations must be followed by an update() call. The model
151
+ # must be cleaned up if an exception is raised after this point.
152
+
153
+ if qobj_coo is not None:
154
+ qval, (qrow, qcol) = qobj_coo
155
+ try:
156
+ numqnz = len(qrow)
157
+ _add_qp_terms_memoryview(
158
+ model=model,
159
+ numqnz=numqnz,
160
+ qrow=np.require(qrow, dtype="int32", requirements=["C"]),
161
+ qcol=np.require(qcol, dtype="int32", requirements=["C"]),
162
+ qval=np.require(qval, dtype="float64", requirements=["C"]),
163
+ )
164
+ model.update()
165
+ except Exception:
166
+ model.close()
167
+ raise
168
+
169
+ return model
Binary file
Binary file
Binary file
Binary file
gurobipy/_paramconst.py CHANGED
@@ -16,7 +16,9 @@ class ParamConstClass(object):
16
16
  Cutoff: sets a target objective value
17
17
  IterationLimit: limits the number of simplex iterations performed
18
18
  MemLimit: returns an error if the total amount of memory used by Gurobi exceeds this limit (in GB)
19
+ NLBarIterLimit: limits the number of NL barrier iterations performed
19
20
  NodeLimit: limits the number of MIP nodes explored
21
+ PDHGIterLimit: limits the number of PDHG iterations performed
20
22
  SoftMemLimit: limits the total amount of memory that Gurobi can use (in GB)
21
23
  SolutionLimit: sets a target for the number of feasible solutions found
22
24
  TimeLimit: limits the total time expended (in seconds)
@@ -30,7 +32,13 @@ class ParamConstClass(object):
30
32
  MarkowitzTol: threshold pivoting tolerance
31
33
  MIPGap: target relative MIP optimality gap
32
34
  MIPGapAbs: target absolute MIP optimality gap
35
+ NLBarCFeasTol: NL barrier complementarity feasibility tolerance
36
+ NLBarDFeasTol: NL barrier dual feasibility tolerance
37
+ NLBarPFeasTol: NL barrier primal feasibility tolerance
33
38
  OptimalityTol: dual feasibility tolerance
39
+ PDHGRelTol: PDHG relative termination tolerance
40
+ PDHGAbsTol: PDHG absolute termination tolerance
41
+ PDHGConvTol: PDHG relative objective gap tolerance
34
42
  PSDTol: QP positive semidefinite tolerance
35
43
 
36
44
  Simplex: affect the simplex algorithms
@@ -63,10 +71,12 @@ class ParamConstClass(object):
63
71
  ConcurrentMIP: enables concurrent MIP optimization
64
72
  ConcurrentJobs: enables distributed concurrent optimization
65
73
  DegenMoves: limit degenerate simplex moves
74
+ FixVarsInIndicators: controls whether variables in indicators should be fixed in a fixed model
66
75
  Heuristics: controls the amount of time spent in MIP heuristics
67
76
  ImproveStartGap: gap at which to switch MIP search strategies
68
77
  ImproveStartNodes: node count at which to switch MIP search strategies
69
78
  ImproveStartTime: time at which to switch MIP search strategies
79
+ ImproveStartWork: work at which to switch MIP search strategies
70
80
  IntegralityFocus: controls integrality focus
71
81
  MinRelNodes: controls the minimum relaxation heuristic
72
82
  MIPFocus: affects the high-level MIP search strategy
@@ -76,6 +86,7 @@ class ParamConstClass(object):
76
86
  NodefileStart: memory nodes may use (in GB) before being written to disk
77
87
  NodeMethod: determines the algorithm used to solve MIP node relaxations
78
88
  NonConvex: controls how to deal with non-convex quadratic programs
89
+ NoRelHeurSolutions: limits the number of solutions found by the NoRel heuristic
79
90
  NoRelHeurTime: controls the time spent in the NoRel heuristic
80
91
  NoRelHeurWork: controls the work spent in the NoRel heuristic
81
92
  OBBT: controls the aggressiveness of optimality-based bound tightening
@@ -86,6 +97,8 @@ class ParamConstClass(object):
86
97
  SolutionNumber: controls access to alternate MIP solutions
87
98
  StartNodeLimit: limits nodes in MIP start sub-MIP
88
99
  StartNumber: selects the MIP start index
100
+ StartTimeLimit: limits time (in seconds) in MIP start sub-MIP
101
+ StartWorkLimit: limits work (in work units) in MIP start sub-MIP
89
102
  SubMIPNodes: limits the numbers of nodes explored in a RINS sub-MIP
90
103
  Symmetry: controls access to alternate MIP solutions
91
104
  VarBranch: controls the branch variable selection strategy
@@ -148,6 +161,7 @@ class ParamConstClass(object):
148
161
  ProjImpliedCuts: controls projected implied bound cut generation
149
162
  PSDCuts: controls PSD cut generation
150
163
  LiftProjectCuts: controls lift-and-project cut generation
164
+ MasterKnapsackCuts: controls master knapsack cut generation
151
165
  MixingCuts: controls mixing cut generation
152
166
  RelaxLiftCuts: controls relax-and-lift cut generation
153
167
  RLTCuts: controls RLT cut generation
@@ -155,6 +169,9 @@ class ParamConstClass(object):
155
169
  SubMIPCuts: controls sub-MIP cut generation
156
170
  ZeroHalfCuts: controls zero-half cut generation
157
171
 
172
+ NL barrier: affect the NL barrier algorithm
173
+ OptimalityTarget: selects search for global or local optimum
174
+
158
175
  Distributed algorithms: used for distributed optimization
159
176
  WorkerPassword: cluster client password
160
177
  WorkerPool: server URL to access the cluster
@@ -217,6 +234,7 @@ class ParamConstClass(object):
217
234
  length, to limit error or to limit the total number of pieces
218
235
  IgnoreNames: indicates whether to ignore names provided by users
219
236
  IISMethod: method used to find an IIS
237
+ InheritParams: control how a supporting environment is applied
220
238
  JSONSolDetail: controls amount of information in a JSON solution string
221
239
  LazyConstraints: programs that use lazy constraints must set this to 1
222
240
  LogFile: sets the name of the Gurobi log file
@@ -231,6 +249,7 @@ class ParamConstClass(object):
231
249
  MultiObjPre: controls initial presolve level on multi-objective models
232
250
  ObjNumber: selects the objective index of multi-objectives
233
251
  OutputFlag: turn logging on or off
252
+ PDHGGPU: Enable GPU for PDHG
234
253
  Record: enables replay
235
254
  ResultFile: result file to write when optimization completes
236
255
  ScenarioNumber: selects the scenario index of multi-scenario models
@@ -257,6 +276,7 @@ class ParamConstClass(object):
257
276
  Cutoff = "Cutoff"
258
277
  IterationLimit = "IterationLimit"
259
278
  MemLimit = "MemLimit"
279
+ NLBarIterLimit = "NLBarIterLimit"
260
280
  NodeLimit = "NodeLimit"
261
281
  SoftMemLimit = "SoftMemLimit"
262
282
  SolutionLimit = "SolutionLimit"
@@ -272,6 +292,9 @@ class ParamConstClass(object):
272
292
  MarkowitzTol = "MarkowitzTol"
273
293
  MIPGap = "MIPGap"
274
294
  MIPGapAbs = "MIPGapAbs"
295
+ NLBarCFeasTol = "NLBarCFeasTol"
296
+ NLBarDFeasTol = "NLBarDFeasTol"
297
+ NLBarPFeasTol = "NLBarPFeasTol"
275
298
  OptimalityTol = "OptimalityTol"
276
299
  PSDTol = "PSDTol"
277
300
 
@@ -295,36 +318,45 @@ class ParamConstClass(object):
295
318
  CrossoverBasis = "CrossoverBasis"
296
319
  QCPDual = "QCPDual"
297
320
 
298
- BranchDir = "BranchDir"
299
- DegenMoves = "DegenMoves"
300
- ConcurrentJobs = "ConcurrentJobs"
301
- ConcurrentMIP = "ConcurrentMIP"
302
- Disconnected = "Disconnected"
303
- DistributedMIPJobs = "DistributedMIPJobs"
304
- Heuristics = "Heuristics"
305
- ImproveStartGap = "ImproveStartGap"
306
- ImproveStartNodes = "ImproveStartNodes"
307
- ImproveStartTime = "ImproveStartTime"
308
- MinRelNodes = "MinRelNodes"
309
- MIPFocus = "MIPFocus"
310
- MIQCPMethod = "MIQCPMethod"
311
- NLPHeur = "NLPHeur"
312
- NodefileDir = "NodefileDir"
313
- NodefileStart = "NodefileStart"
314
- NodeMethod = "NodeMethod"
315
- NonConvex = "NonConvex"
316
- NoRelHeurTime = "NoRelHeurTime"
317
- NoRelHeurWork = "NoRelHeurWork"
318
- OBBT = "OBBT"
319
- PartitionPlace = "PartitionPlace"
320
- PumpPasses = "PumpPasses"
321
- RINS = "RINS"
322
- SolFiles = "SolFiles"
323
- SolutionNumber = "SolutionNumber"
324
- SubMIPNodes = "SubMIPNodes"
325
- Symmetry = "Symmetry"
326
- VarBranch = "VarBranch"
327
- ZeroObjNodes = "ZeroObjNodes"
321
+ PDHGIterLimit = "PDHGIterLimit"
322
+ PDHGRelTol = "PDHGRelTol"
323
+ PDHGAbsTol = "PDHGAbsTol"
324
+ PDHGConvTol = "PDHGConvTol"
325
+ PDHGGPU = "PDHGGPU"
326
+
327
+ BranchDir = "BranchDir"
328
+ DegenMoves = "DegenMoves"
329
+ ConcurrentJobs = "ConcurrentJobs"
330
+ ConcurrentMIP = "ConcurrentMIP"
331
+ Disconnected = "Disconnected"
332
+ DistributedMIPJobs = "DistributedMIPJobs"
333
+ FixVarsInIndicators = "FixVarsInIndicators"
334
+ Heuristics = "Heuristics"
335
+ ImproveStartGap = "ImproveStartGap"
336
+ ImproveStartNodes = "ImproveStartNodes"
337
+ ImproveStartTime = "ImproveStartTime"
338
+ ImproveStartWork = "ImproveStartWork"
339
+ MinRelNodes = "MinRelNodes"
340
+ MIPFocus = "MIPFocus"
341
+ MIQCPMethod = "MIQCPMethod"
342
+ NLPHeur = "NLPHeur"
343
+ NodefileDir = "NodefileDir"
344
+ NodefileStart = "NodefileStart"
345
+ NodeMethod = "NodeMethod"
346
+ NonConvex = "NonConvex"
347
+ NoRelHeurSolutions = "NoRelHeurSolutions"
348
+ NoRelHeurTime = "NoRelHeurTime"
349
+ NoRelHeurWork = "NoRelHeurWork"
350
+ OBBT = "OBBT"
351
+ PartitionPlace = "PartitionPlace"
352
+ PumpPasses = "PumpPasses"
353
+ RINS = "RINS"
354
+ SolFiles = "SolFiles"
355
+ SolutionNumber = "SolutionNumber"
356
+ SubMIPNodes = "SubMIPNodes"
357
+ Symmetry = "Symmetry"
358
+ VarBranch = "VarBranch"
359
+ ZeroObjNodes = "ZeroObjNodes"
328
360
 
329
361
  TuneCriterion = "TuneCriterion"
330
362
  TuneJobs = "TuneJobs"
@@ -360,6 +392,7 @@ class ParamConstClass(object):
360
392
  ProjImpliedCuts = "ProjImpliedCuts"
361
393
  PSDCuts = "PSDCuts"
362
394
  LiftProjectCuts = "LiftProjectCuts"
395
+ MasterKnapsackCuts = "MasterKnapsackCuts"
363
396
  MixingCuts = "MixingCuts"
364
397
  RelaxLiftCuts = "RelaxLiftCuts"
365
398
  RLTCuts = "RLTCuts"
@@ -370,6 +403,8 @@ class ParamConstClass(object):
370
403
  CutPasses = "CutPasses"
371
404
  GomoryPasses = "GomoryPasses"
372
405
 
406
+ OptimalityTarget = "OptimalityTarget"
407
+
373
408
  WorkerPassword = "WorkerPassword"
374
409
  WorkerPool = "WorkerPool"
375
410
  ComputeServer = "ComputeServer"
@@ -418,6 +453,7 @@ class ParamConstClass(object):
418
453
  FuncPieces = "FuncPieces"
419
454
  IISMethod = "IISMethod"
420
455
  IntegralityFocus = "IntegralityFocus"
456
+ InheritParams = "InheritParams"
421
457
  JSONSolDetail = "JSONSolDetail"
422
458
  LazyConstraints = "LazyConstraints"
423
459
  LogFile = "LogFile"
@@ -448,6 +484,8 @@ class ParamConstClass(object):
448
484
  Seed = "Seed"
449
485
  StartNodeLimit = "StartNodeLimit"
450
486
  StartNumber = "StartNumber"
487
+ StartTimeLimit = "StartTimeLimit"
488
+ StartWorkLimit = "StartWorkLimit"
451
489
  ThreadLimit = "ThreadLimit"
452
490
  Threads = "Threads"
453
491
  UpdateMode = "UpdateMode"