Skip to content

Commit 4099286

Browse files
Apply suggestions from code review
Co-authored-by: DominikKamp <[email protected]>
1 parent 5056501 commit 4099286

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
### Added
55
- Added support for knapsack constraints
66
- Added isPositive(), isNegative(), isFeasLE(), isFeasLT(), isFeasGE(), isFeasGT(), isHugeValue(), and tests
7-
- Added SCIP_LOCKTYPE, addVarLocksType, getNLocksDown, getNLocksUp, getNLocksUpType, getNLocksDownType, and tests
7+
- Added SCIP_LOCKTYPE, addVarLocksType(), getNLocksDown(), getNLocksUp(), getNLocksDownType(), getNLocksUpType(), and tests
88
### Fixed
99
### Changed
1010
### Removed

src/pyscipopt/scip.pxd

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,8 @@ cdef extern from "scip/scip.h":
799799
SCIP_RETCODE SCIPaddVarLocksType(SCIP* scip, SCIP_VAR* var, SCIP_LOCKTYPE locktype, int nlocksdown, int nlocksup)
800800
int SCIPvarGetNLocksDown(SCIP_VAR* var)
801801
int SCIPvarGetNLocksUp(SCIP_VAR* var)
802-
int SCIPvarGetNLocksUpType(SCIP_VAR* var, SCIP_LOCKTYPE locktype)
803802
int SCIPvarGetNLocksDownType(SCIP_VAR* var, SCIP_LOCKTYPE locktype)
803+
int SCIPvarGetNLocksUpType(SCIP_VAR* var, SCIP_LOCKTYPE locktype)
804804
SCIP_VAR** SCIPgetVars(SCIP* scip)
805805
SCIP_VAR** SCIPgetOrigVars(SCIP* scip)
806806
const char* SCIPvarGetName(SCIP_VAR* var)
@@ -831,7 +831,7 @@ cdef extern from "scip/scip.h":
831831
SCIP_Real SCIPvarGetCutoffSum(SCIP_VAR* var, SCIP_BRANCHDIR dir)
832832
SCIP_Longint SCIPvarGetNBranchings(SCIP_VAR* var, SCIP_BRANCHDIR dir)
833833
SCIP_Bool SCIPvarMayRoundUp(SCIP_VAR* var)
834-
SCIP_Bool SCIPvarMayRoundDown(SCIP_VAR* var)
834+
SCIP_Bool SCIPvarMayRoundDown(SCIP_VAR* var)
835835

836836
# LP Methods
837837
SCIP_RETCODE SCIPgetLPColsData(SCIP* scip, SCIP_COL*** cols, int* ncols)
@@ -920,8 +920,8 @@ cdef extern from "scip/scip.h":
920920
SCIP_Real SCIPgetGap(SCIP* scip)
921921
int SCIPgetDepth(SCIP* scip)
922922
SCIP_RETCODE SCIPcutoffNode(SCIP* scip, SCIP_NODE* node)
923-
SCIP_Bool SCIPhasPrimalRay(SCIP* scip)
924-
SCIP_Real SCIPgetPrimalRayVal(SCIP* scip, SCIP_VAR* var)
923+
SCIP_Bool SCIPhasPrimalRay(SCIP* scip)
924+
SCIP_Real SCIPgetPrimalRayVal(SCIP* scip, SCIP_VAR* var)
925925
SCIP_RETCODE SCIPaddSolFree(SCIP* scip, SCIP_SOL** sol, SCIP_Bool* stored)
926926
SCIP_RETCODE SCIPaddSol(SCIP* scip, SCIP_SOL* sol, SCIP_Bool* stored)
927927
SCIP_RETCODE SCIPreadSol(SCIP* scip, const char* filename)
@@ -1065,7 +1065,7 @@ cdef extern from "scip/scip.h":
10651065
SCIP_RETCODE (*consgetnvars) (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, int* nvars, SCIP_Bool* success),
10661066
SCIP_RETCODE (*consgetdivebdchgs) (SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_DIVESET* diveset, SCIP_SOL* sol, SCIP_Bool* success, SCIP_Bool* infeasible),
10671067
SCIP_RETCODE (*consgetpermsymgraph)(SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SYM_GRAPH* graph, SCIP_Bool* success),
1068-
SCIP_RETCODE (*consgetsignedpermsymgraph)(SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SYM_GRAPH* graph, SCIP_Bool* success),
1068+
SCIP_RETCODE (*consgetsignedpermsymgraph)(SCIP* scip, SCIP_CONSHDLR* conshdlr, SCIP_CONS* cons, SYM_GRAPH* graph, SCIP_Bool* success),
10691069
SCIP_CONSHDLRDATA* conshdlrdata)
10701070
SCIP_CONSHDLRDATA* SCIPconshdlrGetData(SCIP_CONSHDLR* conshdlr)
10711071
SCIP_CONSHDLR* SCIPfindConshdlr(SCIP* scip, const char* name)
@@ -1634,7 +1634,7 @@ cdef extern from "scip/cons_disjunction.h":
16341634
const char* name,
16351635
int nconss,
16361636
SCIP_CONS** conss,
1637-
SCIP_CONS* relaxcons,
1637+
SCIP_CONS* relaxcons,
16381638
SCIP_Bool initial,
16391639
SCIP_Bool enforce,
16401640
SCIP_Bool check,
@@ -1643,7 +1643,7 @@ cdef extern from "scip/cons_disjunction.h":
16431643
SCIP_Bool dynamic)
16441644

16451645
SCIP_RETCODE SCIPaddConsElemDisjunction(SCIP* scip,
1646-
SCIP_CONS* cons,
1646+
SCIP_CONS* cons,
16471647
SCIP_CONS* addcons)
16481648

16491649
cdef extern from "scip/cons_and.h":

src/pyscipopt/scip.pxi

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,37 +1696,37 @@ cdef class Variable(Expr):
16961696
"""
16971697
return SCIPvarGetNLocksUp(self.scip_var)
16981698

1699-
def getNLocksUpType(self, locktype):
1699+
def getNLocksDownType(self, locktype):
17001700
"""
1701-
Returns the number of locks for rounding up of a certain type.
1701+
Returns the number of locks for rounding down of a certain type.
17021702
17031703
Parameters
17041704
----------
17051705
locktype: PY_SCIP_LOCKTYPE
1706-
types of variable locks
1706+
type of variable locks
17071707
17081708
Returns
17091709
-------
17101710
int
17111711
17121712
"""
1713-
return SCIPvarGetNLocksUpType(self.scip_var, locktype)
1714-
1715-
def getNLocksDownType(self, locktype):
1713+
return SCIPvarGetNLocksDownType(self.scip_var, locktype)
1714+
1715+
def getNLocksUpType(self, locktype):
17161716
"""
1717-
Returns the number of locks for rounding down of a certain type.
1717+
Returns the number of locks for rounding up of a certain type.
17181718
17191719
Parameters
17201720
----------
17211721
locktype: PY_SCIP_LOCKTYPE
1722-
types of variable locks
1722+
type of variable locks
17231723
17241724
Returns
17251725
-------
17261726
int
17271727
17281728
"""
1729-
return SCIPvarGetNLocksDownType(self.scip_var, locktype)
1729+
return SCIPvarGetNLocksUpType(self.scip_var, locktype)
17301730

17311731
def varMayRound(self, direction="down"):
17321732
"""
@@ -3159,7 +3159,7 @@ cdef class Model:
31593159

31603160
def isFeasLE(self, val1, val2):
31613161
"""
3162-
Returns whether relative difference between val1 and val2 is lower than feasibility tolerance.
3162+
Returns whether relative difference between val1 and val2 is not greater than feasibility tolerance.
31633163
31643164
Parameters
31653165
----------
@@ -3191,7 +3191,7 @@ cdef class Model:
31913191

31923192
def isFeasGE(self, val1, val2):
31933193
"""
3194-
Returns whether relative difference of val1 and val2 is greater than minus feasibility tolerance.
3194+
Returns whether relative difference of val1 and val2 is not lower than minus feasibility tolerance.
31953195
31963196
Parameters
31973197
----------
@@ -3937,12 +3937,12 @@ cdef class Model:
39373937
----------
39383938
var : Variable
39393939
variable to adjust the locks for
3940-
type : str
3941-
type of the variable locks
3940+
locktype : PY_SCIP_LOCKTYPE
3941+
type of variable locks
39423942
nlocksdown : int
3943-
modification in number of rounding down locks
3943+
modification in number of down locks
39443944
nlocksup : int
3945-
modification in number of rounding up locks
3945+
modification in number of up locks
39463946
39473947
"""
39483948
PY_SCIP_CALL(SCIPaddVarLocksType(self._scip, var.scip_var, locktype, nlocksdown, nlocksup))

tests/helpers/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def random_nlp_1():
6464
w = model.addVar(name="w")
6565
x = model.addVar(name="x")
6666
y = model.addVar(name="y", ub=1.4)
67-
z = model.addVar(name="z")
67+
z = model.addVar(name="z", ub=4)
6868

6969
model.addCons(exp(v) + log(w) + sqrt(x) + sin(y) + z ** 3 * y <= 5)
7070
model.setObjective(v + w + x + y + z, sense='maximize')
@@ -259,4 +259,5 @@ def gastrans_lp():
259259
model = gastrans_model()
260260
model.relax()
261261

262-
return model
262+
return model
263+

0 commit comments

Comments
 (0)