From 0eae67a2eecadc480eb068f45e8499ddd1a0cf5e Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Fri, 28 Dec 2018 09:14:13 +0100 Subject: [PATCH] fix display of objective --- examples/dotnet/ShiftSchedulingSat.cs | 2 +- ortools/sat/python/cp_model.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/dotnet/ShiftSchedulingSat.cs b/examples/dotnet/ShiftSchedulingSat.cs index 5068baf3ad..edf0926e6b 100644 --- a/examples/dotnet/ShiftSchedulingSat.cs +++ b/examples/dotnet/ShiftSchedulingSat.cs @@ -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++; } diff --git a/ortools/sat/python/cp_model.py b/ortools/sat/python/cp_model.py index fec3396d72..7fa39455a2 100644 --- a/ortools/sat/python/cp_model.py +++ b/ortools/sat/python/cp_model.py @@ -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