scipopt / PySCIPOpt

Python interface for the SCIP Optimization Suite
https://scipopt.github.io/PySCIPOpt
MIT License
786 stars 252 forks source link

How to define a constraint as a lazy one? #707

Closed abb-omidi closed 1 year ago

abb-omidi commented 1 year ago

Dear support team,

I am working on the problem and am willing to add some of its constraints as lazy mode. I took a look at the lot-size example that seems to be a good starting point. In the lot-size model, it tried to generate a cut based on some of the problem information and then separating this cut into the model, but in my case, I actually need to define some of the constraints as the lazy ones. I am working on a modifiable MRE that seems to run without throwing any error, but I am not sure how can I find out the solver adds these constraints as lazy. I was wondering if, how can I fix that if something goes wrong.

Best regards Abbas

Joao-Dionisio commented 1 year ago

Good morning, @abb-omidi! I'm not sure if SCIP has the same distinction as Gurobi regarding user and ~dual~ lazy constraints, I think they are all treated the same. To add cuts during solving, you would need to add a constraint handler that adds cuts whenever a particular event is triggered.

abb-omidi commented 1 year ago

@Joao-Dionisio,

Many thanks for your comments. I am not sure I understand your first comment.

I'm not sure if SCIP has the same distinction as Gurobi regarding user and dual constraints

*) Is it referred to as a user cut and lazy cut respectively, and still has not been implemented in PySCIPopt?

*) However, in the addCons method, there are two parameters, namely removable and dynamic which get either True or False values. Based on the documents, they define as:

1) Is the constraint subject to aging? 2) should the relaxation be removed from the LP due to aging or cleanup?

As per I cannot find out more explanation regard to that, would you please, what exactly they mean?

*) I implemented a constraint handler to add cuts, but it seems to need some additional methods like conscheck and conslock as well. I am not sure if it may or may not be a lazy cut. Also, as long as the problem is solved in the log file the issue python error in conscheck: this method needs to be implemented is shown. Could you please, have a look at that? (I should note the result is incorrect and the cuts are not added to the model).

*) Finally, is it possible to call more than one include method in an optimization run simultaneously? (E.g. includeConshdlr callback and event callback).

Best regards Abbas

Joao-Dionisio commented 1 year ago

Hey, @abb-omidi!

I meant that I believe that you need to implement these things yourself, such as in the lot-sizing example, unlike Gurobi, which allows the user to specify if it's a user cut or a lazy constraint. What you would need to do, I think, is add an appropriate constraint handler.

  1. No, I don't think PySCIPOpt does automatically what you want it to do.
  2. Regarding the age of the constraints, check out this answer from Marco Lübecke, it should explain your doubts.
  3. For more information on constraint handlers, check the corresponding SCIP page.
  4. Yes, you can add multiple include methods.
abb-omidi commented 1 year ago

Dear @Joao-Dionisio,

Many thanks for your answer as well as the provided link. I think, first, I have to understand what exactly the constraint handlers are and how they work on an optimization model. Then go to the next step.

Best regards Abbas

abb-omidi commented 1 year ago

Dear @Joao-Dionisio,

Would you please, does the material presented in this video (I mean the presented notebook FROM SCIP Online Workshop 2020) exist yet? If so, how can I see that?

Best regards Abbas

Joao-Dionisio commented 1 year ago

Hey @fserra, do you still have your jupyter presentation for 2020's SCIP online workshop?

Joao-Dionisio commented 1 year ago

Hello, @abb-omidi. This is the file you're looking for, right? I changed the format to pdf so that I can upload to github, you need to change it back to ipynb to use it.

tsp-example.pdf

abb-omidi commented 1 year ago

Dear @Joao-Dionisio,

Many thanks for sharing this. It seems to be somewhat dense . Let me read that and will back to you if I have any questions.

All the best Abbas