Skip to content
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

Cgl012cut.cpp is not threadsafe #63

Open
tosttost opened this issue May 13, 2021 · 3 comments
Open

Cgl012cut.cpp is not threadsafe #63

tosttost opened this issue May 13, 2021 · 3 comments

Comments

@tosttost
Copy link
Contributor

In Cgl012cut.cpp line 3289:

static double max_score_ever = ZERO; /* maximum score of a violated cut during
					the whole cutting plane procedure */

this global variable is used and updated during separation, so multiple instances of Cgl012cut running in parallel (or probably sequential within the same process) will influence each other.

Note that I have no idea if

  • what effects this might have on Cbc
  • it is algorithmically valid to turn that global variable into a field of Cgl012cut (which would be easy to do)

Is there anyone around that knows about the internals of Cgl012cut?

@tkralphs
Copy link
Member

tkralphs commented May 13, 2021

Looks to me like it is intentional that the variable is global. I guess it would be algorithmically valid to make it a field in the sense that the value it gets will be valid, just maybe not "as good" as the value it would get it if it were global. One of the limitations of the modular design of Cgl is that it's not easy to maintain this kind of global information, but I'm not sure how best to modify this. Interestingly, there is a commit back in 2014 to "make zerohalf threadsafe" 2b40662. Maybe @jjforrest can comment.

@jjhforrest
Copy link
Contributor

jjhforrest commented May 13, 2021 via email

@tosttost
Copy link
Contributor Author

Thanks for the explanation. If only less cuts but no invalid cuts are separated, the severity of this issue is reduced significantly.

It might be an exotic use case but there are definitely people who use cbc as a library to solve multiple MIP within the same process. Writing problems into files and calling the cbc executable is not always viable:

  • if the problem is easy, overhead for starting the process and disk IO can be an issue
  • writing fractional numbers to text files can cause precision issues

Therefore thread safety is not only relevant in terms of "./cbc foobar.mps -threads 42 -solve".

Mutable global variables are not reset. Therefore even if the problems are solved sequentially within the same process they will influence each other.

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

No branches or pull requests

3 participants