File tree Expand file tree Collapse file tree 4 files changed +67
-0
lines changed Expand file tree Collapse file tree 4 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 14
14
- Added recipe for getting local constraints
15
15
- Added enableDebugSol() and disableDebugSol() for controlling the debug solution mechanism if DEBUGSOL=true
16
16
- Added getVarPseudocostScore() and getVarPseudocost()
17
+ - Added getNBranchings() and getNBranchingsCurrentRun()
17
18
### Fixed
18
19
- Raised an error when an expression is used when a variable is required
19
20
- Fixed some compile warnings
Original file line number Diff line number Diff line change @@ -813,6 +813,7 @@ cdef extern from "scip/scip.h":
813
813
SCIP_Real SCIPgetVarPseudocostScore(SCIP* scip, SCIP_VAR* var, SCIP_Real solval)
814
814
SCIP_Real SCIPvarGetCutoffSum(SCIP_VAR* var, SCIP_BRANCHDIR dir )
815
815
SCIP_Longint SCIPvarGetNBranchings(SCIP_VAR* var, SCIP_BRANCHDIR dir )
816
+ SCIP_Longint SCIPvarGetNBranchingsCurrentRun(SCIP_VAR* var, SCIP_BRANCHDIR dir )
816
817
SCIP_Bool SCIPvarMayRoundUp(SCIP_VAR* var)
817
818
SCIP_Bool SCIPvarMayRoundDown(SCIP_VAR* var)
818
819
Original file line number Diff line number Diff line change @@ -1804,6 +1804,37 @@ cdef class Variable(Expr):
1804
1804
mayround = SCIPvarMayRoundUp(self .scip_var)
1805
1805
return mayround
1806
1806
1807
+ def getNBranchings (self , branchdir ):
1808
+ """
1809
+ returns the number of times, a bound of the variable was changed in given direction due to branching
1810
+
1811
+ Parameters
1812
+ ----------
1813
+ branchdir : PY_SCIP_BRANCHDIR
1814
+ branching direction (downwards, or upwards)
1815
+
1816
+ Returns
1817
+ -------
1818
+ int
1819
+ """
1820
+ return SCIPvarGetNBranchings(self .scip_var, branchdir)
1821
+
1822
+ def getNBranchingsCurrentRun (self , branchdir ):
1823
+ """
1824
+ returns the number of times, a bound of the variable was changed in given direction due to branching in the
1825
+ current run
1826
+
1827
+ Parameters
1828
+ ----------
1829
+ branchdir : PY_SCIP_BRANCHDIR
1830
+ branching direction (downwards, or upwards)
1831
+
1832
+ Returns
1833
+ -------
1834
+ int
1835
+ """
1836
+ return SCIPvarGetNBranchingsCurrentRun(self .scip_var, branchdir)
1837
+
1807
1838
class MatrixVariable (MatrixExpr ):
1808
1839
1809
1840
def vtype (self ):
Original file line number Diff line number Diff line change @@ -80,3 +80,37 @@ def test_markRelaxationOnly():
80
80
assert x .isDeletable ()
81
81
assert not y .isRelaxationOnly ()
82
82
assert not y .isDeletable ()
83
+
84
+ def test_getNBranchings ():
85
+ m = Model ()
86
+
87
+ x = m .addVar ("x" , vtype = 'I' , obj = - 1.0 )
88
+ y = m .addVar ("y" , vtype = 'I' , obj = - 2.0 )
89
+
90
+ m .addCons (2 * x + 1 * y <= 3.5 )
91
+ m .addCons (x + 2 * y <= 3.5 )
92
+
93
+ m .setPresolve (SCIP_PARAMSETTING .OFF )
94
+ m .setHeuristics (SCIP_PARAMSETTING .OFF )
95
+ m .disablePropagation ()
96
+ m .presolve ()
97
+
98
+ assert x .getNBranchings (SCIP_BRANCHDIR .UPWARDS ) == 0
99
+ assert x .getNBranchings (SCIP_BRANCHDIR .DOWNWARDS ) == 0
100
+
101
+ def test_getNBranchingsCurrentRun ():
102
+ m = Model ()
103
+
104
+ x = m .addVar ("x" , vtype = 'I' , obj = - 1.0 )
105
+ y = m .addVar ("y" , vtype = 'I' , obj = - 2.0 )
106
+
107
+ m .addCons (2 * x + 1 * y <= 3.5 )
108
+ m .addCons (x + 2 * y <= 3.5 )
109
+
110
+ m .setPresolve (SCIP_PARAMSETTING .OFF )
111
+ m .setHeuristics (SCIP_PARAMSETTING .OFF )
112
+ m .disablePropagation ()
113
+ m .presolve ()
114
+
115
+ assert x .getNBranchingsCurrentRun (SCIP_BRANCHDIR .UPWARDS ) == 0
116
+ assert x .getNBranchingsCurrentRun (SCIP_BRANCHDIR .DOWNWARDS ) == 0
You can’t perform that action at this time.
0 commit comments