Questions about MindtPy rewrite
Summary
Following GDPOpt rewrite #2406 , we are going to rewrite MindtPy in a similar way. A main change in GDPOpt rewrite is
Stores algorithm state (bounds, timing info, etc) on the GDPoptSolver class in lieu of the former `GDPoptSolveData' object.
We encountered a problem when removing solve_data in MindtPy. MindtPy uses the LazyConstraintCallback function to implement the LP/NLP based Branch and Bound algorithm(single-tree implementation). To use the LazyConstraintCallback function in Cplex, we need to define the LazyOACallback_cplex class.
https://github.com/Pyomo/pyomo/blob/main/pyomo/contrib/mindtpy/single_tree.py#L33
Currently, we pass all the algorithm status to LazyOACallback_cplex using solve_data.
LazyOACallback_cplex will obtain the status and update it in the B&B process. If we define all the algorithm status as the attributes of the MindtPySolver class. How can LazyOACallback_cplex access and update the attributes of MindtPySolver?
- Both
LazyOACallback_cplexandMindtPySolverare class. -
LazyOACallback_cplexis a subclass ofcplex.callbacks.LazyConstraintCallback.
https://github.com/Pyomo/pyomo/blob/main/pyomo/contrib/mindtpy/single_tree.py#L584
Any thoughts? @jsiirola @emma58 @bernalde @michaelbynum Thanks.
@ZedongPeng, I'm not entirely sure all of the things that the LazyOACallback_cplex class needs to know, but there's nothing to stop you (I don't think) from storing those things on the MindtPySolver class and then passing that object in instead of the solve_data object. Alternatively, if you think the single-tree implementation of the B&B algorithm has very different requirements for what it needs to store than any of the other algorithm then maybe you want to design it with a different or modified base class that does that book-keeping. You can use a MixIn class if you just want to add some common functionality--that's what the this class is for the OA algorithms in GDPopt.