fix display of objective

This commit is contained in:
Laurent Perron
2018-12-28 09:14:13 +01:00
parent 65d633665e
commit 0eae67a2ee
2 changed files with 5 additions and 2 deletions

View File

@@ -563,7 +563,7 @@ public class ObjectiveSolutionPrinter : CpSolverSolutionCallback
var objectiveBound = BestObjectiveBound();
var time = currentTime - _startTime;
Console.WriteLine($"Solution {_solutionCount}, time = {time.TotalSeconds} s, objective = [{objective}, {objectiveBound}]");
Console.WriteLine($"Solution {_solutionCount}, time = {time.TotalSeconds} s, objective = [{objectiveBound}, {objective}]");
_solutionCount++;
}

View File

@@ -1556,7 +1556,10 @@ class ObjectiveSolutionPrinter(CpSolverSolutionCallback):
"""Called on each new solution."""
current_time = time.time()
objective = self.ObjectiveValue()
best_bound = self.BestObjectiveBound()
obj_lb = min(objective, best_bound)
obj_ub = max(objective, best_bound)
print('Solution %i, time = %f s, objective = [%i, %i]' %
(self.__solution_count, current_time - self.__start_time,
objective, self.BestObjectiveBound()))
obj_lb, obj_ub))
self.__solution_count += 1