Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Servon committed Oct 27, 2020
1 parent 010e56c commit 1b7d88a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions zoopt/algos/opt_algorithms/racos/racos_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ def mixed_classification(self):
len_negative = len(self.__negative_solution)
index_set = list(range(self.__solution_space.get_size()))
remain_index_set = list(range(self.__solution_space.get_size()))
types = self.__solution_space.get_types()
types = self.__solution_space.get_types() # continuous, discrete, grid
order_or_precision = self.__solution_space.get_order_or_precision()
while len_negative > 0:
if len(remain_index_set) == 0:
ToolFunction.log('ERROR: sampled two same solutions, please raise issues on github')
k = remain_index_set[np.random.randint(0, len(remain_index_set))]
k = remain_index_set[np.random.randint(0, len(remain_index_set))] # randomly choose a index k
x_pos_k = self.__x_positive.get_x_index(k)

# continuous
Expand Down
4 changes: 2 additions & 2 deletions zoopt/algos/opt_algorithms/racos/sracos.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@ def sample_solution(self, ub=1):
:return: a solution containing trial
"""
sampled_data = self._positive_data + self._negative_data
if np.random.random() < self._parameter.get_probability():
if np.random.random() < self._parameter.get_probability(): # exploitation
classifier = RacosClassification(
self._objective.get_dim(), self._positive_data, self._negative_data, ub)
classifier.mixed_classification()
solution, distinct_flag = self.distinct_sample_classifier(
classifier, sampled_data, True, self._parameter.get_train_size())
else:
else: # exploration
solution, distinct_flag = self.distinct_sample(self._objective.get_dim(), sampled_data)

return solution, distinct_flag
Expand Down
3 changes: 2 additions & 1 deletion zoopt/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ def __init__(self, dim_list=[]):
self._size = len(dim_list)
self._regions = list(map(lambda x: x[1], dim_list))
self._types = list(map(lambda x: x[0], dim_list))
self._order_or_precision = list(map(lambda x: x[2] if len(x) == 3 else None, dim_list))
self._order_or_precision = list(map(lambda x: x[2] if len(x) == 3 else None,
dim_list)) # Note: for grid valuetype, len(x)=2

for _dim in dim_list:
if _dim[0] == ValueType.CONTINUOUS:
Expand Down

0 comments on commit 1b7d88a

Please sign in to comment.