From bfcdc11817759260ba955d22632e7597f797c9de Mon Sep 17 00:00:00 2001
From: Jean-Christophe <jean-christophe.routier@univ-lille.fr>
Date: Wed, 8 Jul 2020 12:27:19 +0200
Subject: [PATCH] update isTerminated with increasing objective

---
 .../solver/decentralized/supervisor/Supervisor.scala        | 6 ++++--
 .../solver/decentralized/supervisor/SupervisorStatus.scala  | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/main/scala/org/scadcop/solver/decentralized/supervisor/Supervisor.scala b/src/main/scala/org/scadcop/solver/decentralized/supervisor/Supervisor.scala
index 44368fd..2fb2e0f 100755
--- a/src/main/scala/org/scadcop/solver/decentralized/supervisor/Supervisor.scala
+++ b/src/main/scala/org/scadcop/solver/decentralized/supervisor/Supervisor.scala
@@ -134,7 +134,9 @@ class Supervisor(val pb : DCOP, val algorithm: Algorithm, val initialContext: Co
         previousObj = status.previousObj,
         isFirstRound = false)
 
-      if (! updatedStatus.isTerminated){// If the solving must be restart for another round
+      val newObjectiveValue = pb.objective(updatedStatus.assignment)
+
+      if (! updatedStatus.isTerminated(newObjectiveValue)){// If the solving must be restart for another round
         pb.variables.foreach { anyVariable: Variable =>
           if (trace) println(s"Supervisor -> $anyVariable : ContinueAlgo")
           directory.addressOf(anyVariable) ! ContinueAlgo
@@ -149,7 +151,7 @@ class Supervisor(val pb : DCOP, val algorithm: Algorithm, val initialContext: Co
           directory.addressOf(anyVariable) ! Query
         }
         if (trace) println(s"Supervisor -> self : StopAlgo")
-        updatedStatus = updatedStatus.updateObjectiveValue(pb.objective(status.assignment))
+        updatedStatus = updatedStatus.updateObjectiveValue(newObjectiveValue)
         self ! StopAlgo
         }
         goto(Deciding) using updatedStatus
diff --git a/src/main/scala/org/scadcop/solver/decentralized/supervisor/SupervisorStatus.scala b/src/main/scala/org/scadcop/solver/decentralized/supervisor/SupervisorStatus.scala
index bba85f1..0e03fef 100755
--- a/src/main/scala/org/scadcop/solver/decentralized/supervisor/SupervisorStatus.scala
+++ b/src/main/scala/org/scadcop/solver/decentralized/supervisor/SupervisorStatus.scala
@@ -41,7 +41,7 @@ class SupervisorStatus(val readyVariables: Set[Variable] = Set(),
     * Returns true if the algorithm ends
     * @todo modify it
     */
-  def isTerminated : Boolean = Supervisor.incrementCounter() > Supervisor.NB_ROUNDS
+  def isTerminated(newObjectiveValue : Double) : Boolean = newObjectiveValue > previousObj
 
   /*Returns the updated supervisor's status when resetting the context*/
   def resetContext(): SupervisorStatus = {
-- 
GitLab