Skip to content

Commit 7eb2fd4

Browse files
committed
row prices and column bounds for cbc
Former-commit-id: 4d8e37c [formerly d1dea06] Former-commit-id: 524a1f5
1 parent a5696d4 commit 7eb2fd4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

mip/cbc.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@
332332
cbc_progress_callback prgcbc, void *appData);
333333
334334
void Cbc_clearCallBack(Cbc_Model *model);
335+
336+
const double *Cbc_getRowPrice(Cbc_Model *model);
337+
338+
const double *Osi_getRowPrice(void *osi);
335339
""")
336340

337341
CHAR_ONE = "{}".format(chr(1)).encode("utf-8")
@@ -680,12 +684,18 @@ def var_get_lb(self, var: "Var") -> float:
680684
raise Exception('Error while getting lower bound of variables')
681685
return float(lb[var.idx])
682686

687+
def var_set_lb(self, var: "Var", value: float):
688+
cbclib.Cbc_setColLower(self._model, var.idx, value)
689+
683690
def var_get_ub(self, var: "Var") -> float:
684691
ub = cbclib.Cbc_getColUpper(self._model)
685692
if ub == ffi.NULL:
686693
raise Exception('Error while getting upper bound of variables')
687694
return float(ub[var.idx])
688695

696+
def var_set_ub(self, var: "Var", value: float):
697+
cbclib.Cbc_setColUpper(self._model, var.idx, value)
698+
689699
def var_get_name(self, idx: int) -> str:
690700
namep = self.__name_space
691701
cbclib.Cbc_getColName(self._model, idx, namep, MAX_NAME_SIZE)
@@ -906,6 +916,12 @@ def get_pump_passes(self) -> int:
906916
def set_pump_passes(self, passes: int):
907917
self.__pumpp = passes
908918

919+
def constr_get_pi(self, constr: Constr) -> float:
920+
rp = cbclib.Cbc_getRowPrice(self._model)
921+
if rp == ffi.NULL:
922+
raise Exception('row prices not available')
923+
return float(rp[constr.idx])
924+
909925

910926
class ModelOsi(Model):
911927
def __init__(self, osi_ptr: CData):

0 commit comments

Comments
 (0)