-
Notifications
You must be signed in to change notification settings - Fork 37
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
Interaction between AbstractMaster and Master may lead to subtle bugs #6
Comments
I looked into the issue you raised and I think you've a valid point. The easiest way to fix this is to specify in the documentation that the constructor of the master class will invoke the buildModel() function. |
Thank you for looking into the issue. I would personally say that the least destructive way would be to move the building of the master object to the actual algorithm (
However, clearly, this option would require somewhat more changes than the addition to the Javadoc. And I am not sure if this would lead to other unwanted side-effects? |
I am using the library for column generation and branch and price procedures by the way (for example to solve a train unit shunting problem), but I haven't used any of the other functionality so far. What I like regarding the column generation framework is that it provides a basic framework, that allows to structure the classes needed to implement such involved algorithms. What would probably be nice for further additions to the column generation framework would be to allow the user more freedom in implementing more advanced strategies. For example regarding the use of columns in column generation (which pool of columns is currently in use, should a certain column be deleted if the current pool of columns becomes too large). The same goes for more advanced branching strategies (e.g. strong branching) and control of the branch and price tree (depth-first, breadth-first). However, these are quite clearly more advanced features. |
Thanks! Wrt the technical stuff: I'll get back to that later, it's a bit too busy at work at the moment. |
Currently, the implementation is such that the Master class (or in general the class extending AbstractMaster) uses
super(...)
to call the AbstractMaster constructor, which in turn callsbuildModel()
. However, this may lead to very subtle bugs in cases where fields are used that are also used in the buildModel() class. Consider a Master model with contents:This code will throw a rather unexpected NPE at the addition to the list, as the call in the super constructor to buildModel() precedes the construction of the ArrayList. Moreover, this behaviour breaks the convention to call overridable methods in constructors (see e.g. Effective Java 2nd Edition, Item 17).
It would be good if this behaviour would at least be documented somewhere. Otherwise, there should also be multiple ways out to get rid of the behaviour altogether, by for example deferring the construction of the container class AbstractMaster to the ColGen class or by moving the responsibility for building the Master problem to the user.
The text was updated successfully, but these errors were encountered: