|
@@ -14,25 +14,24 @@ class Algorithm():
|
|
self.validator = _validator
|
|
self.validator = _validator
|
|
self.policy = _policy
|
|
self.policy = _policy
|
|
|
|
|
|
- self.currentSolution = self.initializer()
|
|
|
|
-
|
|
|
|
- # evaluate current solution
|
|
|
|
- self.currentSolution.evaluate(self.evaluator)
|
|
|
|
-
|
|
|
|
- # keep in memory best known solution (current solution)
|
|
|
|
- self.bestSolution = self.currentSolution
|
|
|
|
-
|
|
|
|
# other parameters
|
|
# other parameters
|
|
self.maxEvalutations = 0 # by default
|
|
self.maxEvalutations = 0 # by default
|
|
- self.numberOfEvaluations = 0
|
|
|
|
self.maximise = _maximise
|
|
self.maximise = _maximise
|
|
|
|
|
|
|
|
+ self.initRun()
|
|
|
|
+
|
|
|
|
|
|
- def reinit(self):
|
|
|
|
|
|
+ def initRun(self):
|
|
"""
|
|
"""
|
|
- Reinit the whole variable
|
|
|
|
|
|
+ Reinit the whole variables
|
|
"""
|
|
"""
|
|
- self.currentSolution = self.initializer
|
|
|
|
|
|
+
|
|
|
|
+ self.currentSolution = self.initializer()
|
|
|
|
+
|
|
|
|
+ # evaluate current solution
|
|
|
|
+ self.currentSolution.evaluate(self.evaluator)
|
|
|
|
+
|
|
|
|
+ # keep in memory best known solution (current solution)
|
|
self.bestSolution = self.currentSolution
|
|
self.bestSolution = self.currentSolution
|
|
|
|
|
|
self.numberOfEvaluations = 0
|
|
self.numberOfEvaluations = 0
|
|
@@ -92,9 +91,10 @@ class Algorithm():
|
|
Run the specific algorithm following number of evaluations to find optima
|
|
Run the specific algorithm following number of evaluations to find optima
|
|
"""
|
|
"""
|
|
self.maxEvalutations = _evaluations
|
|
self.maxEvalutations = _evaluations
|
|
|
|
+ self.initRun()
|
|
|
|
|
|
logging.info("Run %s with %s evaluations" % (self.__str__(), _evaluations))
|
|
logging.info("Run %s with %s evaluations" % (self.__str__(), _evaluations))
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
def progress(self):
|
|
def progress(self):
|
|
logging.info("-- Evaluation n°%s of %s, %s%%" % (self.numberOfEvaluations, self.maxEvalutations, "{0:.2f}".format((self.numberOfEvaluations) / self.maxEvalutations * 100.)))
|
|
logging.info("-- Evaluation n°%s of %s, %s%%" % (self.numberOfEvaluations, self.maxEvalutations, "{0:.2f}".format((self.numberOfEvaluations) / self.maxEvalutations * 100.)))
|