Skip to content

Add support for knapsack constraints #975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
### Added
- Added support for knapsack constraints
### Fixed
### Changed
### Removed
Expand Down
31 changes: 31 additions & 0 deletions src/pyscipopt/scip.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,37 @@ cdef extern from "scip/cons_linear.h":
SCIP_Real* SCIPgetValsLinear(SCIP* scip, SCIP_CONS* cons)
SCIP_ROW* SCIPgetRowLinear(SCIP* scip, SCIP_CONS* cons)

cdef extern from "scip/cons_knapsack.h":
SCIP_RETCODE SCIPcreateConsKnapsack(SCIP* scip,
SCIP_CONS** cons,
char* name,
int nvars,
SCIP_VAR** vars,
SCIP_Longint* weights,
SCIP_Longint capacity,
SCIP_Bool initial,
SCIP_Bool separate,
SCIP_Bool enforce,
SCIP_Bool check,
SCIP_Bool propagate,
SCIP_Bool local,
SCIP_Bool modifiable,
SCIP_Bool dynamic,
SCIP_Bool removable,
SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPaddCoefKnapsack(SCIP* scip,
SCIP_CONS* cons,
SCIP_VAR* var,
SCIP_Longint val)

SCIP_Real SCIPgetDualsolKnapsack(SCIP* scip, SCIP_CONS* cons)
SCIP_Real SCIPgetDualfarkasKnapsack(SCIP* scip, SCIP_CONS* cons)
SCIP_RETCODE SCIPchgCapacityKnapsack(SCIP* scip, SCIP_CONS* cons, SCIP_Real rhs)
SCIP_Longint SCIPgetCapacityKnapsack(SCIP* scip, SCIP_CONS* cons)
SCIP_VAR** SCIPgetVarsKnapsack(SCIP* scip, SCIP_CONS* cons)
int SCIPgetNVarsKnapsack(SCIP* scip, SCIP_CONS* cons)
SCIP_Longint* SCIPgetWeightsKnapsack(SCIP* scip, SCIP_CONS* cons)

cdef extern from "scip/cons_nonlinear.h":
SCIP_EXPR* SCIPgetExprNonlinear(SCIP_CONS* cons)
SCIP_RETCODE SCIPcreateConsNonlinear(SCIP* scip,
Expand Down
Loading