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 44368fdd714eca567b6d0ecfb0656a111fe75c93..2fb2e0fd27a9ce9637c16fbbb4fd1e2e60c17eb0 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 bba85f19d896b98fd559383155a1a99d3694ec44..0e03fef4c3ebc8bfdb04a3a3a55aaebc01da1f1d 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 = {