From 6111ed1b0b3b2d6ca1885d71543291e8946bbefe Mon Sep 17 00:00:00 2001 From: Joao-Dionisio Date: Mon, 27 Jan 2025 13:13:34 +0100 Subject: [PATCH] fixing some more stuff --- src/pyscipopt/conshdlr.pxi | 2 +- src/pyscipopt/lp.pxi | 10 +++++----- src/pyscipopt/scip.pxi | 17 ++++++++++------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/pyscipopt/conshdlr.pxi b/src/pyscipopt/conshdlr.pxi index 91cb0c40a..9b9bd8acc 100644 --- a/src/pyscipopt/conshdlr.pxi +++ b/src/pyscipopt/conshdlr.pxi @@ -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])) diff --git a/src/pyscipopt/lp.pxi b/src/pyscipopt/lp.pxi index 2532da7f6..f6645db54 100644 --- a/src/pyscipopt/lp.pxi +++ b/src/pyscipopt/lp.pxi @@ -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 = 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 = malloc(nnonz * sizeof(SCIP_Real)) cdef int* c_inds = 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 = malloc(nrows * sizeof(SCIP_Real)) cdef SCIP_Real* c_rhss = malloc(nrows * sizeof(SCIP_Real)) diff --git a/src/pyscipopt/scip.pxi b/src/pyscipopt/scip.pxi index adcad2657..2fd4fd9ea 100644 --- a/src/pyscipopt/scip.pxi +++ b/src/pyscipopt/scip.pxi @@ -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 = malloc(len(vars) * sizeof(SCIP_VAR*)) for idx, var in enumerate(vars): _vars[idx] = (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 = 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 = 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 = malloc(_nchildren * sizeof(SCIP_Real))