@@ -1184,9 +1184,9 @@ cdef class DomainChanges:
11841184 list of BoundChange
11851185
11861186 """
1187+ cdef nboundchgs = SCIPdomchgGetNBoundchgs(self .scip_domchg)
11871188 cdef int i
11881189
1189- nboundchgs = SCIPdomchgGetNBoundchgs(self .scip_domchg)
11901190 return [BoundChange.create(SCIPdomchgGetBoundchg(self .scip_domchg, i))
11911191 for i in range (nboundchgs)]
11921192
@@ -1291,13 +1291,13 @@ cdef class Node:
12911291
12921292 """
12931293 cdef int addedconsssize = SCIPnodeGetNAddedConss(self .scip_node)
1294- cdef int i
12951294
12961295 if addedconsssize == 0 :
12971296 return []
12981297
12991298 cdef SCIP_CONS** addedconss = < SCIP_CONS** > malloc(addedconsssize * sizeof(SCIP_CONS* ))
13001299 cdef int nconss
1300+ cdef int i
13011301
13021302 SCIPnodeGetAddedConss(self .scip_node, addedconss, & nconss, addedconsssize)
13031303 assert nconss == addedconsssize
@@ -1372,14 +1372,14 @@ cdef class Node:
13721372
13731373 """
13741374 cdef int nbranchvars = self .getNParentBranchings()
1375- cdef int i
13761375
13771376 if nbranchvars == 0 :
13781377 return None
13791378
13801379 cdef SCIP_VAR** branchvars = < SCIP_VAR** > malloc(nbranchvars * sizeof(SCIP_VAR* ))
13811380 cdef SCIP_Real* branchbounds = < SCIP_Real* > malloc(nbranchvars * sizeof(SCIP_Real))
13821381 cdef SCIP_BOUNDTYPE* boundtypes = < SCIP_BOUNDTYPE* > malloc(nbranchvars * sizeof(SCIP_BOUNDTYPE))
1382+ cdef int i
13831383
13841384 SCIPnodeGetParentBranchings(self .scip_node, branchvars, branchbounds,
13851385 boundtypes, & nbranchvars, nbranchvars)
@@ -2736,7 +2736,7 @@ cdef class Model:
27362736 """
27372737
27382738 cdef SCIP_VAR** _vars
2739- cdef int _nvars
2739+ cdef int nvars
27402740 cdef SCIP_Real coef
27412741 cdef int i
27422742
@@ -2752,8 +2752,8 @@ cdef class Model:
27522752 # clear existing objective function
27532753 self .addObjoffset(- self .getObjoffset())
27542754 _vars = SCIPgetOrigVars(self ._scip)
2755- _nvars = SCIPgetNOrigVars(self ._scip)
2756- for i in range (_nvars ):
2755+ nvars = SCIPgetNOrigVars(self ._scip)
2756+ for i in range (nvars ):
27572757 PY_SCIP_CALL(SCIPchgVarObj(self ._scip, _vars[i], 0.0 ))
27582758
27592759 if expr[CONST] != 0.0 :
@@ -3429,18 +3429,18 @@ cdef class Model:
34293429 """
34303430 cdef SCIP_VAR** _vars
34313431 cdef SCIP_VAR* _var
3432- cdef int _nvars
3432+ cdef int nvars
34333433 cdef int i
34343434
34353435 vars = []
34363436 if transformed:
34373437 _vars = SCIPgetVars(self ._scip)
3438- _nvars = SCIPgetNVars(self ._scip)
3438+ nvars = SCIPgetNVars(self ._scip)
34393439 else :
34403440 _vars = SCIPgetOrigVars(self ._scip)
3441- _nvars = SCIPgetNOrigVars(self ._scip)
3441+ nvars = SCIPgetNOrigVars(self ._scip)
34423442
3443- for i in range (_nvars ):
3443+ for i in range (nvars ):
34443444 ptr = < size_t> (_vars[i])
34453445
34463446 # check whether the corresponding variable exists already
@@ -4373,15 +4373,14 @@ cdef class Model:
43734373 cdef SCIP_CONS* scip_cons
43744374 cdef int * idxs
43754375 cdef int i
4376- cdef int idx
43774376 cdef int j
43784377
43794378 terms = cons.expr.terms
43804379
43814380 # collect variables
43824381 variables = {var.ptr():var for term in terms for var in term}
43834382 variables = list (variables.values())
4384- varindex = {var.ptr():idx for (idx ,var) in enumerate (variables)}
4383+ varindex = {var.ptr():i for (i ,var) in enumerate (variables)}
43854384
43864385 # create monomials for terms
43874386 monomials = < SCIP_EXPR** > malloc(len (terms) * sizeof(SCIP_EXPR* ))
@@ -4740,7 +4739,6 @@ cdef class Model:
47404739 The created and added Constraint objects.
47414740
47424741 """
4743- cdef int idx
47444742 cdef int i
47454743
47464744 def ensure_iterable (elem , length ):
@@ -4756,9 +4754,10 @@ cdef class Model:
47564754
47574755 if isinstance (name, str ):
47584756 if name == " " :
4759- name = [" " for idx in range (n_conss)]
4757+ name = [" " for i in range (n_conss)]
47604758 else :
4761- name = [" %s _%s " % (name, idx) for idx in range (n_conss)]
4759+ name = [" %s _%s " % (name, i) for i in range (n_conss)]
4760+
47624761 initial = ensure_iterable(initial, n_conss)
47634762 separate = ensure_iterable(separate, n_conss)
47644763 enforce = ensure_iterable(enforce, n_conss)
@@ -4919,16 +4918,16 @@ cdef class Model:
49194918
49204919 """
49214920 cdef SCIP_Bool success
4922- cdef int _nvars
4921+ cdef int nvars
49234922 cdef int i
49244923
4925- SCIPgetConsNVars(self ._scip, constraint.scip_cons, & _nvars , & success)
4924+ SCIPgetConsNVars(self ._scip, constraint.scip_cons, & nvars , & success)
49264925
4927- cdef SCIP_VAR** _vars = < SCIP_VAR** > malloc(_nvars * sizeof(SCIP_VAR* ))
4928- SCIPgetConsVars(self ._scip, constraint.scip_cons, _vars, _nvars * sizeof(SCIP_VAR* ), & success)
4926+ cdef SCIP_VAR** _vars = < SCIP_VAR** > malloc(nvars * sizeof(SCIP_VAR* ))
4927+ SCIPgetConsVars(self ._scip, constraint.scip_cons, _vars, nvars * sizeof(SCIP_VAR* ), & success)
49294928
49304929 vars = []
4931- for i in range (_nvars ):
4930+ for i in range (nvars ):
49324931 ptr = < size_t> (_vars[i])
49334932 # check whether the corresponding variable exists already
49344933 if ptr in self ._modelvars:
@@ -5085,7 +5084,6 @@ cdef class Model:
50855084
50865085 """
50875086 cdef SCIP_CONS* scip_cons
5088- cdef int _nvars
50895087 cdef int nvars
50905088 cdef int i
50915089
@@ -5147,7 +5145,6 @@ cdef class Model:
51475145
51485146 """
51495147 cdef SCIP_CONS* scip_cons
5150- cdef int _nvars
51515148 cdef int nvars
51525149 cdef int i
51535150
@@ -5210,11 +5207,11 @@ cdef class Model:
52105207 """
52115208 cdef SCIP_CONS* scip_cons
52125209 cdef int nvars = len (vars )
5213- cdef int idx
5210+ cdef int i
52145211
52155212 _vars = < SCIP_VAR** > malloc(len (vars ) * sizeof(SCIP_VAR* ))
5216- for idx , var in enumerate (vars ):
5217- _vars[idx ] = (< Variable> var).scip_var
5213+ for i , var in enumerate (vars ):
5214+ _vars[i ] = (< Variable> var).scip_var
52185215 _resVar = (< Variable> resvar).scip_var
52195216
52205217 PY_SCIP_CALL(SCIPcreateConsAnd(self ._scip, & scip_cons, str_conversion(name), _resVar, nvars, _vars,
@@ -5271,12 +5268,11 @@ cdef class Model:
52715268 """
52725269 cdef SCIP_CONS* scip_cons
52735270 cdef int nvars = len (vars )
5274- cdef int idx
5275-
5271+ cdef int i
52765272
52775273 _vars = < SCIP_VAR** > malloc(len (vars ) * sizeof(SCIP_VAR* ))
5278- for idx , var in enumerate (vars ):
5279- _vars[idx ] = (< Variable> var).scip_var
5274+ for i , var in enumerate (vars ):
5275+ _vars[i ] = (< Variable> var).scip_var
52805276 _resVar = (< Variable> resvar).scip_var
52815277
52825278 PY_SCIP_CALL(SCIPcreateConsOr(self ._scip, & scip_cons, str_conversion(name), _resVar, nvars, _vars,
@@ -8583,12 +8579,12 @@ cdef class Model:
85838579
85848580 """
85858581 assert SCIPhasPrimalRay(self ._scip), " The problem does not have a primal ray."
8586- cdef int _nvars = SCIPgetNVars(self ._scip)
8582+ cdef int nvars = SCIPgetNVars(self ._scip)
85878583 cdef SCIP_VAR ** _vars = SCIPgetVars(self ._scip)
85888584 cdef int i
85898585
85908586 ray = []
8591- for i in range (_nvars ):
8587+ for i in range (nvars ):
85928588 ray.append(float (SCIPgetPrimalRayVal(self ._scip, _vars[i])))
85938589
85948590 return ray
@@ -9325,25 +9321,25 @@ cdef class Model:
93259321 raise ValueError (" Constant offsets in objective are not supported!" )
93269322
93279323 cdef SCIP_VAR** _vars
9328- cdef int _nvars
9324+ cdef int nvars
93299325
93309326 _vars = SCIPgetOrigVars(self ._scip)
9331- _nvars = SCIPgetNOrigVars(self ._scip)
9332- _coeffs = < SCIP_Real* > malloc(_nvars * sizeof(SCIP_Real))
9327+ nvars = SCIPgetNOrigVars(self ._scip)
9328+ _coeffs = < SCIP_Real* > malloc(nvars * sizeof(SCIP_Real))
93339329
9334- for i in range (_nvars ):
9330+ for i in range (nvars ):
93359331 _coeffs[i] = 0.0
93369332
93379333 for term, coef in coeffs.terms.items():
93389334 # avoid CONST term of Expr
93399335 if term != CONST:
93409336 assert len (term) == 1
93419337 var = < Variable> term[0 ]
9342- for i in range (_nvars ):
9338+ for i in range (nvars ):
93439339 if _vars[i] == var.scip_var:
93449340 _coeffs[i] = coef
93459341
9346- PY_SCIP_CALL(SCIPchgReoptObjective(self ._scip, objsense, _vars, & _coeffs[0 ], _nvars ))
9342+ PY_SCIP_CALL(SCIPchgReoptObjective(self ._scip, objsense, _vars, & _coeffs[0 ], nvars ))
93479343
93489344 free(_coeffs)
93499345
0 commit comments