Skip to content

Commit

Permalink
fixing some more stuff
Browse files Browse the repository at this point in the history
Joao-Dionisio committed Jan 27, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 0aff74b commit 6111ed1
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/pyscipopt/conshdlr.pxi
Original file line number Diff line number Diff line change
@@ -168,9 +168,9 @@ cdef SCIP_RETCODE PyConsFree (SCIP* scip, SCIP_CONSHDLR* conshdlr) noexcept with
return SCIP_OKAY

cdef SCIP_RETCODE PyConsInit (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS** conss, int nconss) noexcept with gil:
PyConshdlr = getPyConshdlr(conshdlr)
cdef int i

PyConshdlr = getPyConshdlr(conshdlr)
cdef constraints = []
for i in range(nconss):
constraints.append(getPyCons(conss[i]))
10 changes: 5 additions & 5 deletions src/pyscipopt/lp.pxi
Original file line number Diff line number Diff line change
@@ -97,8 +97,8 @@ cdef class LP:
ubs -- upper bounds (default infinity)
"""

cdef ncols = len(entrieslist)
cdef nnonz = sum(len(entries) for entries in entrieslist)
cdef int ncols = len(entrieslist)
cdef int nnonz = sum(len(entries) for entries in entrieslist)
cdef int i

cdef SCIP_Real* c_objs = <SCIP_Real*> malloc(ncols * sizeof(SCIP_Real))
@@ -161,7 +161,7 @@ cdef class LP:
rhs -- right-hand side of the row (default infinity)
"""
beg = 0
nnonz = len(entries)
cdef int nnonz = len(entries)

cdef SCIP_Real* c_coefs = <SCIP_Real*> malloc(nnonz * sizeof(SCIP_Real))
cdef int* c_inds = <int*>malloc(nnonz * sizeof(int))
@@ -191,8 +191,8 @@ cdef class LP:
lhss -- left-hand side of the row (default 0.0)
rhss -- right-hand side of the row (default infinity)
"""
nrows = len(entrieslist)
nnonz = sum(len(entries) for entries in entrieslist)
cdef int nrows = len(entrieslist)
cdef int nnonz = sum(len(entries) for entries in entrieslist)

cdef SCIP_Real* c_lhss = <SCIP_Real*> malloc(nrows * sizeof(SCIP_Real))
cdef SCIP_Real* c_rhss = <SCIP_Real*> malloc(nrows * sizeof(SCIP_Real))
17 changes: 10 additions & 7 deletions src/pyscipopt/scip.pxi
Original file line number Diff line number Diff line change
@@ -4752,7 +4752,7 @@ cdef class Model:
assert isinstance(conss, Iterable), "Given constraint list is not iterable."

conss = list(conss)
n_conss = len(conss)
cdef int n_conss = len(conss)

if isinstance(name, str):
if name == "":
@@ -4825,7 +4825,7 @@ cdef class Model:
assert isinstance(conss, Iterable), "Given constraint list is not iterable"

conss = list(conss)
n_conss = len(conss)
cdef int n_conss = len(conss)

cdef SCIP_CONS* disj_cons

@@ -5086,6 +5086,7 @@ cdef class Model:
"""
cdef SCIP_CONS* scip_cons
cdef int _nvars
cdef int nvars
cdef int i

PY_SCIP_CALL(SCIPcreateConsSOS1(self._scip, &scip_cons, str_conversion(name), 0, NULL, NULL,
@@ -5147,6 +5148,7 @@ cdef class Model:
"""
cdef SCIP_CONS* scip_cons
cdef int _nvars
cdef int nvars
cdef int i

PY_SCIP_CALL(SCIPcreateConsSOS2(self._scip, &scip_cons, str_conversion(name), 0, NULL, NULL,
@@ -5207,10 +5209,9 @@ cdef class Model:
"""
cdef SCIP_CONS* scip_cons
cdef int nvars = len(vars)
cdef int idx

nvars = len(vars)

_vars = <SCIP_VAR**> malloc(len(vars) * sizeof(SCIP_VAR*))
for idx, var in enumerate(vars):
_vars[idx] = (<Variable>var).scip_var
@@ -5269,9 +5270,9 @@ cdef class Model:
"""
cdef SCIP_CONS* scip_cons
cdef int nvars = len(vars)
cdef int idx

nvars = len(vars)

_vars = <SCIP_VAR**> malloc(len(vars) * sizeof(SCIP_VAR*))
for idx, var in enumerate(vars):
@@ -5331,9 +5332,9 @@ cdef class Model:
"""
cdef SCIP_CONS* scip_cons
cdef int nvars = len(vars)
cdef int idx

nvars = len(vars)

assert type(rhsvar) is type(bool()), "Provide BOOLEAN value as rhsvar, you gave %s." % type(rhsvar)
_vars = <SCIP_VAR**> malloc(len(vars) * sizeof(SCIP_VAR*))
@@ -6399,6 +6400,7 @@ cdef class Model:
"""
cdef SCIP** subprobs
cdef SCIP_BENDERS* benders
cdef int nsubproblems
cdef int idx

# checking whether subproblems is a dictionary
@@ -9531,8 +9533,9 @@ cdef class Model:
"""
cdef int i

assert isinstance(gains, list)
nchildren = len(gains)
cdef int nchildren = len(gains)

cdef int _nchildren = nchildren
_gains = <SCIP_Real*> malloc(_nchildren * sizeof(SCIP_Real))

0 comments on commit 6111ed1

Please sign in to comment.