@@ -1536,8 +1536,6 @@ def fix_dual_bound(self, config, last_iter_cuts):
1536
1536
main_mip_results = self .mip_opt .solve (
1537
1537
self .mip , tee = config .mip_solver_tee , load_solutions = False , ** mip_args
1538
1538
)
1539
- if config .use_tabu_list :
1540
- self .update_attributes ()
1541
1539
if len (main_mip_results .solution ) > 0 :
1542
1540
self .mip .solutions .load_from (main_mip_results )
1543
1541
@@ -1570,12 +1568,10 @@ def set_up_tabulist_callback(self):
1570
1568
tabulist = self .mip_opt ._solver_model .register_callback (
1571
1569
tabu_list .IncumbentCallback_cplex
1572
1570
)
1573
- self .solve_data = MindtPySolveData ()
1574
- self .export_attributes ()
1575
- tabulist .solve_data = self .solve_data
1576
1571
tabulist .opt = self .mip_opt
1577
1572
tabulist .config = self .config
1578
- self .mip_opt ._solver_model .parameters .preprocessing .reduce .set (1 )
1573
+ tabulist .mindtpy_object = self
1574
+ self .mip_opt .options ['preprocessing_reduce' ] = 1
1579
1575
# If the callback is used to reject incumbents, the user must set the
1580
1576
# parameter c.parameters.preprocessing.reduce either to the value 1 (one)
1581
1577
# to restrict presolve to primal reductions only or to 0 (zero) to disable all presolve reductions
@@ -1597,19 +1593,15 @@ def set_up_lazy_OA_callback(self):
1597
1593
)
1598
1594
# pass necessary data and parameters to lazyoa
1599
1595
lazyoa .main_mip = self .mip
1600
- self .solve_data = MindtPySolveData ()
1601
- self .export_attributes ()
1602
- lazyoa .solve_data = self .solve_data
1603
1596
lazyoa .config = self .config
1604
1597
lazyoa .opt = self .mip_opt
1598
+ lazyoa .mindtpy_object = self
1605
1599
self .mip_opt ._solver_model .set_warning_stream (None )
1606
1600
self .mip_opt ._solver_model .set_log_stream (None )
1607
1601
self .mip_opt ._solver_model .set_error_stream (None )
1608
1602
if self .config .mip_solver == 'gurobi_persistent' :
1609
1603
self .mip_opt .set_callback (single_tree .LazyOACallback_gurobi )
1610
- self .solve_data = MindtPySolveData ()
1611
- self .export_attributes ()
1612
- self .mip_opt .solve_data = self .solve_data
1604
+ self .mip_opt .mindtpy_object = self
1613
1605
self .mip_opt .config = self .config
1614
1606
1615
1607
##########################################################################################################################################
@@ -1641,8 +1633,6 @@ def solve_main(self, config):
1641
1633
self .mip , tee = config .mip_solver_tee , load_solutions = False , ** mip_args
1642
1634
)
1643
1635
# update_attributes should be before load_from(main_mip_results), since load_from(main_mip_results) may fail.
1644
- if config .single_tree or config .use_tabu_list :
1645
- self .update_attributes ()
1646
1636
if len (main_mip_results .solution ) > 0 :
1647
1637
self .mip .solutions .load_from (main_mip_results )
1648
1638
except (ValueError , AttributeError , RuntimeError ):
@@ -1789,8 +1779,10 @@ def set_up_mip_solver(self, config, regularization_problem=False):
1789
1779
# determine if persistent solver is called.
1790
1780
if isinstance (self .mip_opt , PersistentSolver ):
1791
1781
self .mip_opt .set_instance (self .mip , symbolic_solver_labels = True )
1792
- if config .single_tree or config .use_tabu_list :
1793
- self .export_attributes ()
1782
+ if config .single_tree :
1783
+ self .set_up_lazy_OA_callback ()
1784
+ if config .use_tabu_list :
1785
+ self .set_up_tabulist_callback ()
1794
1786
mip_args = dict (config .mip_solver_args )
1795
1787
if config .mip_solver in {
1796
1788
'cplex' ,
@@ -2251,14 +2243,6 @@ def setup_regularization_main(self, config):
2251
2243
+ config .level_coef * self .dual_bound
2252
2244
)
2253
2245
2254
- def export_attributes (self ):
2255
- for name , val in self .__dict__ .items ():
2256
- setattr (self .solve_data , name , val )
2257
-
2258
- def update_attributes (self ):
2259
- for name , val in self .solve_data .__dict__ .items ():
2260
- self .__dict__ [name ] = val
2261
-
2262
2246
def update_result (self ):
2263
2247
if self .objective_sense == minimize :
2264
2248
self .results .problem .lower_bound = self .dual_bound
@@ -2699,14 +2683,6 @@ def initialize_subsolvers(self):
2699
2683
self .nlp_opt = SolverFactory (config .nlp_solver )
2700
2684
self .feasibility_nlp_opt = SolverFactory (config .nlp_solver )
2701
2685
2702
- # determine if persistent solver is called.
2703
- # if isinstance(mainopt, PersistentSolver):
2704
- # mainopt.set_instance(self.mip, symbolic_solver_labels=True)
2705
- if config .single_tree :
2706
- self .set_up_lazy_OA_callback ()
2707
- if config .use_tabu_list :
2708
- self .set_up_tabulist_callback ()
2709
-
2710
2686
set_solver_mipgap (self .mip_opt , config .mip_solver , config )
2711
2687
set_solver_mipgap (
2712
2688
self .regularization_mip_opt , config .mip_regularization_solver , config
@@ -2756,7 +2732,7 @@ def set_appsi_solver_update_config(self):
2756
2732
if config .mip_solver in {'appsi_cplex' , 'appsi_gurobi' , 'appsi_highs' }:
2757
2733
# mip main problem
2758
2734
self .mip_opt .update_config .check_for_new_or_removed_constraints = True
2759
- self .mip_opt .update_config .check_for_new_or_removed_vars = True # TODO
2735
+ self .mip_opt .update_config .check_for_new_or_removed_vars = True
2760
2736
self .mip_opt .update_config .check_for_new_or_removed_params = False
2761
2737
self .mip_opt .update_config .check_for_new_objective = True
2762
2738
self .mip_opt .update_config .update_constraints = True
0 commit comments