Skip to content

Commit 70fc572

Browse files
Add support for knapsack constraints (#975)
* Add support for knapsack constraints * remove useless asserts * Standardize knapsack with other constypes * Remove handler name from default constraint name * Remove redeclaration * minor bugfixing * Fix stupid bug * Everything seems alright now * copilot * typo * all good now * remove knapsack getrhs * Add assert * remove get/setRhs
1 parent 0b78317 commit 70fc572

File tree

4 files changed

+333
-34
lines changed

4 files changed

+333
-34
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44
### Added
5+
- Added support for knapsack constraints
56
### Fixed
67
### Changed
78
### Removed

src/pyscipopt/scip.pxd

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,37 @@ cdef extern from "scip/cons_linear.h":
14741474
SCIP_Real* SCIPgetValsLinear(SCIP* scip, SCIP_CONS* cons)
14751475
SCIP_ROW* SCIPgetRowLinear(SCIP* scip, SCIP_CONS* cons)
14761476

1477+
cdef extern from "scip/cons_knapsack.h":
1478+
SCIP_RETCODE SCIPcreateConsKnapsack(SCIP* scip,
1479+
SCIP_CONS** cons,
1480+
char* name,
1481+
int nvars,
1482+
SCIP_VAR** vars,
1483+
SCIP_Longint* weights,
1484+
SCIP_Longint capacity,
1485+
SCIP_Bool initial,
1486+
SCIP_Bool separate,
1487+
SCIP_Bool enforce,
1488+
SCIP_Bool check,
1489+
SCIP_Bool propagate,
1490+
SCIP_Bool local,
1491+
SCIP_Bool modifiable,
1492+
SCIP_Bool dynamic,
1493+
SCIP_Bool removable,
1494+
SCIP_Bool stickingatnode)
1495+
SCIP_RETCODE SCIPaddCoefKnapsack(SCIP* scip,
1496+
SCIP_CONS* cons,
1497+
SCIP_VAR* var,
1498+
SCIP_Longint val)
1499+
1500+
SCIP_Real SCIPgetDualsolKnapsack(SCIP* scip, SCIP_CONS* cons)
1501+
SCIP_Real SCIPgetDualfarkasKnapsack(SCIP* scip, SCIP_CONS* cons)
1502+
SCIP_RETCODE SCIPchgCapacityKnapsack(SCIP* scip, SCIP_CONS* cons, SCIP_Real rhs)
1503+
SCIP_Longint SCIPgetCapacityKnapsack(SCIP* scip, SCIP_CONS* cons)
1504+
SCIP_VAR** SCIPgetVarsKnapsack(SCIP* scip, SCIP_CONS* cons)
1505+
int SCIPgetNVarsKnapsack(SCIP* scip, SCIP_CONS* cons)
1506+
SCIP_Longint* SCIPgetWeightsKnapsack(SCIP* scip, SCIP_CONS* cons)
1507+
14771508
cdef extern from "scip/cons_nonlinear.h":
14781509
SCIP_EXPR* SCIPgetExprNonlinear(SCIP_CONS* cons)
14791510
SCIP_RETCODE SCIPcreateConsNonlinear(SCIP* scip,

0 commit comments

Comments
 (0)