Skip to content
Snippets Groups Projects
Commit ee8036cd authored by Jean-Christophe Routier's avatar Jean-Christophe Routier
Browse files

update isTerminated with increasing objective

parent bfcdc118
No related branches found
No related tags found
No related merge requests found
...@@ -21,9 +21,9 @@ import scala.language.postfixOps ...@@ -21,9 +21,9 @@ import scala.language.postfixOps
abstract class VariableAgent(val variable: Variable, abstract class VariableAgent(val variable: Variable,
val neighbours : Set[Variable], val neighbours : Set[Variable],
val constraints: Set[Constraint]) extends Actor { val constraints: Set[Constraint]) extends Actor {
var trace: Boolean = true var trace: Boolean = false
var debug: Boolean = true var debug: Boolean = false
var debugState: Boolean = true var debugState: Boolean = false
var supervisor: ActorRef = context.parent var supervisor: ActorRef = context.parent
var directory: Directory = new Directory() var directory: Directory = new Directory()
......
...@@ -15,9 +15,9 @@ import akka.actor.{Actor, ActorRef, FSM, Props, Stash, PoisonPill} ...@@ -15,9 +15,9 @@ import akka.actor.{Actor, ActorRef, FSM, Props, Stash, PoisonPill}
class Supervisor(val pb : DCOP, val algorithm: Algorithm, val initialContext: Context) extends Actor with Stash class Supervisor(val pb : DCOP, val algorithm: Algorithm, val initialContext: Context) extends Actor with Stash
with FSM[SupervisorState, SupervisorStatus] { with FSM[SupervisorState, SupervisorStatus] {
var debug = true var debug = false
var debugState = true var debugState = false
var trace = true var trace = false
var solver: ActorRef = context.parent // Reference to the distributed solver var solver: ActorRef = context.parent // Reference to the distributed solver
var directory = new Directory() // White page for the peers var directory = new Directory() // White page for the peers
...@@ -141,6 +141,7 @@ class Supervisor(val pb : DCOP, val algorithm: Algorithm, val initialContext: Co ...@@ -141,6 +141,7 @@ class Supervisor(val pb : DCOP, val algorithm: Algorithm, val initialContext: Co
if (trace) println(s"Supervisor -> $anyVariable : ContinueAlgo") if (trace) println(s"Supervisor -> $anyVariable : ContinueAlgo")
directory.addressOf(anyVariable) ! ContinueAlgo directory.addressOf(anyVariable) ! ContinueAlgo
} }
updatedStatus = updatedStatus.updateObjectiveValue(newObjectiveValue)
if (trace) println(s"Supervisor -> self : ContinueAlgo") if (trace) println(s"Supervisor -> self : ContinueAlgo")
self ! ContinueAlgo self ! ContinueAlgo
} }
...@@ -151,7 +152,6 @@ class Supervisor(val pb : DCOP, val algorithm: Algorithm, val initialContext: Co ...@@ -151,7 +152,6 @@ class Supervisor(val pb : DCOP, val algorithm: Algorithm, val initialContext: Co
directory.addressOf(anyVariable) ! Query directory.addressOf(anyVariable) ! Query
} }
if (trace) println(s"Supervisor -> self : StopAlgo") if (trace) println(s"Supervisor -> self : StopAlgo")
updatedStatus = updatedStatus.updateObjectiveValue(newObjectiveValue)
self ! StopAlgo self ! StopAlgo
} }
goto(Deciding) using updatedStatus goto(Deciding) using updatedStatus
......
...@@ -41,7 +41,7 @@ class SupervisorStatus(val readyVariables: Set[Variable] = Set(), ...@@ -41,7 +41,7 @@ class SupervisorStatus(val readyVariables: Set[Variable] = Set(),
* Returns true if the algorithm ends * Returns true if the algorithm ends
* @todo modify it * @todo modify it
*/ */
def isTerminated(newObjectiveValue : Double) : Boolean = newObjectiveValue > previousObj def isTerminated(newObjectiveValue : Double) : Boolean = newObjectiveValue <= previousObj
/*Returns the updated supervisor's status when resetting the context*/ /*Returns the updated supervisor's status when resetting the context*/
def resetContext(): SupervisorStatus = { def resetContext(): SupervisorStatus = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment