Skip to content

Interface SCIP methods missing from PySCIPOpt#1236

Open
adamj34 wants to merge 6 commits into
scipopt:masterfrom
adamj34:extend-interface
Open

Interface SCIP methods missing from PySCIPOpt#1236
adamj34 wants to merge 6 commits into
scipopt:masterfrom
adamj34:extend-interface

Conversation

@adamj34

@adamj34 adamj34 commented Jul 19, 2026

Copy link
Copy Markdown

Wrap SCIPgetNNodesLeft and append a check to an existing test

@Joao-Dionisio

Copy link
Copy Markdown
Member

Thank you @adamj34 , this looks good! How many other methods did you interface? It may be good to add a bunch at a time, to avoid merging too many PRs and spamming our followers.

@adamj34

adamj34 commented Jul 19, 2026

Copy link
Copy Markdown
Author

@Joao-Dionisio I could interface a few more. I wanted to keep it simple for the first PR but I can add the rest in bulk, as you suggested.

I see that there's an error in the CI pipeline:
error: pyscipopt.scip.Model.getNNodesLeft is not present in stub

Should new methods be added there by hand, or it's supposed to be automated in some way (by the .pre-commit-config.yaml hook, possibly)?

@Joao-Dionisio

Copy link
Copy Markdown
Member

I wanted to keep it simple for the first PR

That's fair, we can merge this one and do the bulk one later.

Should new methods be added there by hand, or it's supposed to be automated in some way (by the .pre-commit-config.yaml hook, possibly)?

We've started working on adding stubs this year, so for now this is still something that needs to be done manually, but hopefuly not for much longer. There is a stub generator, but it's not working yet.

@adamj34

adamj34 commented Jul 19, 2026

Copy link
Copy Markdown
Author

ok, I've added it manually

@adamj34 adamj34 changed the title Add getNNodesLeft method Interface SCIP methods missing from PySCIPOpt Jul 20, 2026
Comment thread src/pyscipopt/scip.pxd Outdated
SCIP_Longint SCIPgetNNodeLPIterations(SCIP* scip)
SCIP_Longint SCIPgetNStrongbranchLPIterations(SCIP* scip)
SCIP_Real SCIPgetPrimalDualIntegral(SCIP* scip)
int SCIPgetNRuns(SCIP* scip)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please order this roughly in the order in which they appear in the SCIP documentation?

Comment thread src/pyscipopt/scip.pxd Outdated
SCIP_Real SCIPgetPrimalDualIntegral(SCIP* scip)
int SCIPgetNRuns(SCIP* scip)
int SCIPgetNReoptRuns(SCIP* scip)
void SCIPaddNNodes(SCIP* scip, SCIP_Longint nnodes)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you let me know what's the use of this method? Is it to let SCIP know that there were more nodes that were hidden from it somehow?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I'm guessing it's because of sub-SCIPs, etc. In any case, perhaps adding a line to the PySCIPOpt docstring explaining this would be nice.

@adamj34 adamj34 Jul 21, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the functional standpoint, it increments scip->stat->nnodes and scip->stat->ntotalnodes

as far as concrete use cases are concerned, I'm not sure about them but your guess looks reasonable

Comment thread src/pyscipopt/scip.pxd Outdated
SCIP_RETCODE SCIPgetNSiblings(SCIP* scip)
SCIP_RETCODE SCIPgetLeaves(SCIP* scip, SCIP_NODE*** leaves, int* nleaves)
SCIP_Longint SCIPgetNLeaves(SCIP* scip)
SCIP_Longint SCIPgetNNodesLeft(SCIP* scip)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SCIP_Longint SCIPgetNNodesLeft(SCIP* scip)
int SCIPgetNNodesLeft(SCIP* scip)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants