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