From c4721b5a90b1f13e78fd36f4e4b5fb7534ceb495 Mon Sep 17 00:00:00 2001 From: ZedongPeng Date: Mon, 5 Feb 2024 12:41:24 -0500 Subject: [PATCH] add _ for private method --- pyomo/contrib/gdpopt/ldsda.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pyomo/contrib/gdpopt/ldsda.py b/pyomo/contrib/gdpopt/ldsda.py index 340c46dae2e..e4904c4e2b8 100644 --- a/pyomo/contrib/gdpopt/ldsda.py +++ b/pyomo/contrib/gdpopt/ldsda.py @@ -123,8 +123,10 @@ def _solve_gdp(self, model, config): add_transformed_boolean_variable_list(self.working_model_util_block) self._log_header(logger) - self.get_external_information(self.working_model_util_block, config) - self.directions = self.get_directions(self.number_of_external_variables, config) + self._get_external_information(self.working_model_util_block, config) + self.directions = self._get_directions( + self.number_of_external_variables, config + ) self.best_direction = None self.current_point = config.starting_point self.explored_point_set = set() @@ -183,7 +185,7 @@ def _solve_GDP_subproblem(self, model, config, search_type): result = SolverFactory(config.minlp_solver).solve( subproblem, **minlp_args ) - primal_improved = self.handle_subproblem_result( + primal_improved = self._handle_subproblem_result( result, subproblem, config, search_type ) return primal_improved @@ -194,7 +196,7 @@ def _solve_GDP_subproblem(self, model, config, search_type): ) return False - def get_external_information(self, util_block, config): + def _get_external_information(self, util_block, config): """Function that obtains information from the model to perform the reformulation with external variables. Parameters @@ -271,7 +273,7 @@ def fix_disjunctions_with_external_var(self, util_block, external_var_values_lis disjunct.deactivate() self.explored_point_set.add(tuple(external_var_values_list)) - def get_directions(self, dimension, config): + def _get_directions(self, dimension, config): """Function creates the search directions of the given dimension. Parameters @@ -297,7 +299,7 @@ def get_directions(self, dimension, config): directions.remove((0,) * dimension) return directions - def check_valid_neighbor(self, neighbor): + def _check_valid_neighbor(self, neighbor): """Function that checks if a given neighbor is valid. Parameters @@ -339,7 +341,7 @@ def neighbor_search(self, model, config): self.best_direction = None for direction in self.directions: neighbor = tuple(map(sum, zip(self.current_point, direction))) - if self.check_valid_neighbor(neighbor): + if self._check_valid_neighbor(neighbor): self.fix_disjunctions_with_external_var( self.working_model_util_block, neighbor ) @@ -367,7 +369,7 @@ def line_search(self, model, config): primal_improved = True while primal_improved: next_point = tuple(map(sum, zip(self.current_point, self.best_direction))) - if self.check_valid_neighbor(next_point): + if self._check_valid_neighbor(next_point): self.fix_disjunctions_with_external_var( self.working_model_util_block, next_point ) @@ -380,7 +382,7 @@ def line_search(self, model, config): break print("Line search finished.") - def handle_subproblem_result( + def _handle_subproblem_result( self, subproblem_result, subproblem, config, search_type ): """Function that handles the result of the subproblem