File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414- Added recipe for getting local constraints
1515- Added enableDebugSol() and disableDebugSol() for controlling the debug solution mechanism if DEBUGSOL=true
1616- Added getVarPseudocostScore() and getVarPseudocost()
17+ - Added getNBranchings() and getNBranchingsCurrentRun()
1718### Fixed
1819- Raised an error when an expression is used when a variable is required
1920- Fixed some compile warnings
Original file line number Diff line number Diff line change @@ -813,6 +813,7 @@ cdef extern from "scip/scip.h":
813813 SCIP_Real SCIPgetVarPseudocostScore(SCIP* scip, SCIP_VAR* var, SCIP_Real solval)
814814 SCIP_Real SCIPvarGetCutoffSum(SCIP_VAR* var, SCIP_BRANCHDIR dir )
815815 SCIP_Longint SCIPvarGetNBranchings(SCIP_VAR* var, SCIP_BRANCHDIR dir )
816+ SCIP_Longint SCIPvarGetNBranchingsCurrentRun(SCIP_VAR* var, SCIP_BRANCHDIR dir )
816817 SCIP_Bool SCIPvarMayRoundUp(SCIP_VAR* var)
817818 SCIP_Bool SCIPvarMayRoundDown(SCIP_VAR* var)
818819
Original file line number Diff line number Diff line change @@ -1804,6 +1804,37 @@ cdef class Variable(Expr):
18041804 mayround = SCIPvarMayRoundUp(self .scip_var)
18051805 return mayround
18061806
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+
18071838class MatrixVariable (MatrixExpr ):
18081839
18091840 def vtype (self ):
Original file line number Diff line number Diff line change @@ -80,3 +80,37 @@ def test_markRelaxationOnly():
8080 assert x .isDeletable ()
8181 assert not y .isRelaxationOnly ()
8282 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