From d950627e426db85ddb455b9831b439aa06fd04ce Mon Sep 17 00:00:00 2001 From: Antonio Gomez Date: Fri, 1 Nov 2024 16:01:40 -0700 Subject: [PATCH] Now sending and receiving proper data --- src/ProblemCristina.py | 3 ++- src/SolverDAB.py | 7 ++++--- src/Worker.py | 5 ++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ProblemCristina.py b/src/ProblemCristina.py index 5138796..9655147 100755 --- a/src/ProblemCristina.py +++ b/src/ProblemCristina.py @@ -36,7 +36,8 @@ def __init__(self): def solve(self, solution): val = random.randint(0, 1000000) - print("ProblemCristina. Solution found with value: " + str(val)) + solution.setValue(val) +# print("ProblemCristina. Solution found with value: " + str(val)) return val def extractSolution(self): diff --git a/src/SolverDAB.py b/src/SolverDAB.py index 81a40fa..dd04e2d 100644 --- a/src/SolverDAB.py +++ b/src/SolverDAB.py @@ -297,7 +297,7 @@ def createNewCandidate(self, probMatrix, totalSumGoodSolutions, topSolutions=Non else: if minVal > maxVal: minVal, maxVal = maxVal, minVal - newVal = random.randint(minVal, maxVal) + newVal = random.randint(int(minVal), int(maxVal)) currentVal = parameters[i].get_value() if newVal != currentVal: @@ -405,9 +405,9 @@ def createNewCandidate(self, probMatrix, totalSumGoodSolutions, topSolutions): minVal = maxVal - 1 if minVal > maxVal: minVal, maxVal = maxVal, minVal - newVal = random.randint(minVal, maxVal) + newVal = random.randint(int(minVal), int(maxVal)) while newVal == currentVal: - newVal = random.randint(minVal, maxVal) + newVal = random.randint(int(minVal), int(maxVal)) p.set_value(newVal) #Here: go through the parameters of the solution and change those #parameters considering the min and max values of each parameter, @@ -758,6 +758,7 @@ def receiveSolutions(self): u.logger.error("DRIVER (comm). " + str(e) + " line: " + str(sys.exc_info()[2].tb_lineno)) try: + u.logger.info("SOLVERDAB. Received solution with value " + str(solVal[0]) + " from bee " + str(beeIdx[0])) if (float(solVal[0]) > 0.0 and float(solVal[0]) < u.infinity / 100): #Add the solution to the list of best solutions (the method will implement the #priority list) diff --git a/src/Worker.py b/src/Worker.py index 0fe8cc4..676431f 100755 --- a/src/Worker.py +++ b/src/Worker.py @@ -122,7 +122,7 @@ def run(self, infile, cfile): req.wait(status) u.logger.info("WORKER (" + str(self.__rank) + - ") has received a solution from bee " + + ") has received a solution to evaluate from bee " + str(agent_idx[0])) solution.setParametersValues(buff) @@ -139,6 +139,9 @@ def run(self, infile, cfile): u.logger.debug("WORKER (" + str(self.__rank) + "). Buffer size: " + str(len(buff))) + u.logger.debug("WORKER (" + str(self.__rank) + + "- " + str(agent_idx) + ") found solution with value " + + str(solution_value[0])) self.__comm.Send(buff, 0, u.tags.COMMSOLUTION) self.__comm.Send(solution_value, 0, u.tags.COMMSOLUTION)