Skip to content

Commit

Permalink
add _ for private method
Browse files Browse the repository at this point in the history
  • Loading branch information
ZedongPeng committed Feb 5, 2024
1 parent 6cf2e6b commit c4721b5
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pyomo/contrib/gdpopt/ldsda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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
)
Expand All @@ -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
Expand Down

0 comments on commit c4721b5

Please sign in to comment.