1

I feel like I am missing something very simple and very straightforward. I am trying to add a constraint after the LP has been solved (using the optimal LP solution as a mechanism to devise this constraint). And I am adding it by this piece of code

432 SCIP_CONS * cons = nullptr;
433 namebuf.str("");
434 namebuf<<"cut_3_OR1";
435  SCIP_CALL(SCIPcreateConsLinear(scip, &cons, namebuf.str().c_str(), 0, nullptr, nullptr, -SCIPinfinity(scip), 1.0,   /* <= 1.0 constraint */
436                                    true,  /* initial  <= 0 */
437                                    false, /* separate */
438                                    true,  /* enforce */
439                                    true,  /* check */
440                                    true,  /* propagate */
441                                    false, /* local */
442                                    true,  /* modifiable */
443                                    false, /* dynamic */
444                                    false, /* removable */
445                                    false  /* stickingatnode */));

The code compiles fine but upon running the code, I get this error message

[src/scip/scip_cons.c:991] ERROR: invalid SCIP stage <10>
[src/scip/cons_linear.c:17695] ERROR: Error <-8> in function call
[src/Solver.h:445] ERROR: Error <-8> in function call
make: *** [run] Error 1

The code compiles and runs when I remove this constraint addition.

Could someone tell me what is wrong?

1 Answer 1

1

Stage 10 is SCIP_STAGE_SOLVED. You try to add a constraint after your problem is solved to optimality. Is the constraint that you want to add necessary? Then you might have to implement a constraint handler and add your constraint in the sepalp-callback of your handler. As an example, you could look at the TSP example in the SCIP documentation (it has a subtour-elimination constraint handler)

Sign up to request clarification or add additional context in comments.

5 Comments

Yes. It is necessary as it will increase the value of the lower bound. So I assume I have to add it how you have suggested. Are there any tutorials on how to do it? Thanks for your help.
There is also a section in the documentation about this: scip.zib.de/doc/html/CONS.php (and I edited my original post with an example)
I am not sure if I should ask this a separate question but I think I have a slightly related question. I want to add the aforementioned cut at my root node but I arrive at the root node after adding certain columns. I don't want to add any cuts during this column generation process. should I change anything significantly?
I assume you add your columns in a pricer plugin? You definitely should not add the cuts there. As I wrote, you should add the cuts in a constraint handler (or a separation routine if they are not model constraints)
Yes! I add columns using a pricer and I did implement the constraint handler (currently it does nothing as in i had not implemented it to add the cut but it does do some checks). I will ask it as a question so that it’s easier. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.