Skip to content

Commit

Permalink
C interface: add Cbc_setRowRHS
Browse files Browse the repository at this point in the history
  • Loading branch information
h-g-s committed Nov 27, 2019
1 parent 8a44fa4 commit 531d71d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Cbc/src/Cbc_C_Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2358,6 +2358,31 @@ Cbc_setRowUpper(Cbc_Model *model, int index, double value)
solver->setRowUpper(index, value);
}

COINLIBAPI void COINLINKAGE
Cbc_setRowRHS(Cbc_Model *model, int row, double rhs)
{
char sense = Cbc_getRowSense(model, row);
switch (sense)
{
case 'L':
Cbc_setRowUpper(model, row, rhs);
break;
case 'G':
Cbc_setRowLower(model, row, rhs);
break;
case 'E':
Cbc_setRowLower(model, row, rhs);
Cbc_setRowUpper(model, row, rhs);
break;
default:
fprintf(stderr, "Could not change RHS in row %d to %g in row with sense: %c\n",
row, rhs, sense);
exit(1);
}
}



/** @brief Constraint lower bounds
*
* @param model problem object
Expand Down
9 changes: 9 additions & 0 deletions Cbc/src/Cbc_C_Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@ Cbc_setRowLower(Cbc_Model *model, int index, double value);
COINLIBAPI void COINLINKAGE
Cbc_setRowUpper(Cbc_Model *model, int index, double value);

/** @brief Sets the RHS of a constraint
*
* @param model problem object
* @param row row index
* @param rhs value of the new RHS
**/
COINLIBAPI void COINLINKAGE
Cbc_setRowRHS(Cbc_Model *model, int row, double rhs);

/** @brief Set the objective coefficient of a single variable
*
* @param model problem object
Expand Down

0 comments on commit 531d71d

Please sign in to comment.