Skip to content

Commit f5365b8

Browse files
committed
Fix best individual description bug
* The problem was fixed changing the query to gather the best individual of the last population * Hide convergence button until it is implemented
1 parent 94f590f commit f5365b8

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

MLC/GUI/Experiment/ExperimentWindow.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ def __init__(self, mlc_local,
133133
if self._autogenerated_object.disable_board_check.checkState() == Qt.Checked:
134134
self.on_disable_arduino_toggle(True)
135135

136+
# FIXME: The code of show_convergence button is not implemented yet. Hide the button
137+
self._autogenerated_object.convergence_button.setVisible(False)
138+
136139
def closeEvent(self, event):
137140
logger.debug('[EXPERIMENT {0}] [CLOSE_DIALOG] - Executing overriden closeEvent function'
138141
.format(self._experiment_name))

MLC/api/MLCLocal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def get_experiment_info(self, experiment_name):
299299

300300
if simulation.number_of_generations() != 0:
301301
# Get the best indiv description
302-
min_indiv_id = MLCRepository.get_instance().get_individual_with_min_cost()
302+
min_indiv_id = MLCRepository.get_instance().get_individual_with_min_cost_in_last_pop()
303303
min_indiv_data = MLCRepository.get_instance().get_individual_data(min_indiv_id)
304304
experiment_info["best_indiv_id"] = min_indiv_id
305305
experiment_info["best_indiv_value"] = min_indiv_data.get_value()

MLC/db/mlc_repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def update_individual(self, individual_id, individual):
108108
def remove_individual(self, individual_id):
109109
raise NotImplementedError("This method must be implemented")
110110

111-
def get_individual_with_min_cost(self):
111+
def get_individual_with_min_cost_in_last_pop(self):
112112
raise NotImplementedError("This method must be implemented")
113113

114114
def get_individual(self, individual_id):

MLC/db/sqlite/sql_statements.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,17 @@ def stmt_update_cost(individual_id, cost, evaluation_time, generation):
139139
evaluation_time,
140140
individual_id,
141141
generation)
142-
143-
144-
def stmt_get_individual_with_min_cost():
145-
return '''SELECT indiv_id
146-
FROM population
147-
ORDER BY cost ASC
148-
LIMIT 1'''
142+
"""
143+
The individual with the least cost in the last population
144+
is considered to be the best individual
145+
"""
146+
def stmt_get_individual_with_min_cost_in_last_pop():
147+
return '''SELECT indiv_id,
148+
cost
149+
FROM population
150+
ORDER BY gen DESC,
151+
cost ASC
152+
LIMIT 1'''
149153

150154
def stmt_enable_foreign_key():
151155
return '''PRAGMA foreign_keys = ON'''

MLC/db/sqlite/sqlite_repository.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ def update_individual(self, individual_id, individual):
208208
def remove_individual(self, individual_id):
209209
raise NotImplementedError("This method must be implemented")
210210

211-
def get_individual_with_min_cost(self):
211+
def get_individual_with_min_cost_in_last_pop(self):
212212
conn = self.__get_db_connection()
213-
cursor = conn.execute(stmt_get_individual_with_min_cost())
213+
cursor = conn.execute(stmt_get_individual_with_min_cost_in_last_pop())
214214

215215
# We are expecting just one resultte
216216
min_indiv_id = cursor.fetchone()[0]

0 commit comments

Comments
 (0)