Skip to content
Snippets Groups Projects
Commit 7816b8f9 authored by Alex's avatar Alex
Browse files

added allunstashAll

parent 00f231fb
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ abstract class VariableAgent(val variable: Variable,
val constraints: Set[Constraint]) extends Actor {
var trace: Boolean = false
var debug: Boolean = false
var debugState: Boolean = false
var debugState: Boolean = true
var supervisor: ActorRef = context.parent
var directory: Directory = new Directory()
......
......@@ -180,6 +180,7 @@ class AgentBehaviour(variable: Variable,
directory.addressOf(potentialPartner) ! MakeOffer(offer)
if (trace) println(s"$variable -> $potentialPartner : MakeOffer(${Some(offer)}")
multicast(neighbours - potentialPartner, MakeOffer(new Offer(variable, List())))
unstashAll
goto(OffererMakingOff) using updatedMind
// When it receives an offer, the agent rejects it
......@@ -455,6 +456,7 @@ class AgentBehaviour(variable: Variable,
if (debug) println(s"$variable in $stateName has received Act(true) but has no move")
if (trace) println(s"$variable -> Supervisor : I kept my previous value = InformValue(${mind.context.getValue(variable).get})")
supervisor ! InformValue(mind.context.getValue(variable).get)
unstashAll
goto(Continue) using mind
// When it should not act because it does not have the highest delta in the neighbourhood
......@@ -462,6 +464,7 @@ class AgentBehaviour(variable: Variable,
if (debug) println(s"$variable in $stateName has received Act(false)")
if (trace) println(s"$variable -> Supervisor : I didn't change = InformValue(${mind.context.getValue(variable).get})")
supervisor ! InformValue(mind.context.getValue(variable).get)
unstashAll
goto(Continue) using mind
}
......@@ -475,6 +478,7 @@ class AgentBehaviour(variable: Variable,
if (debug) println(s"$variable in $stateName has received Act(false)")
if (trace) println(s"$variable -> Supervisor : I didn't change = InformValue(${mind.context.getValue(variable).get})")
supervisor ! InformValue(mind.context.getValue(variable).get)
unstashAll
goto(Continue) using mind
// When it receives its own acting decision and should act
......@@ -487,6 +491,7 @@ class AgentBehaviour(variable: Variable,
}
if (trace) println(s"$variable -> ${partner} : GiveGo($move)")
directory.addressOf(partner) ! GiveGo(move)
unstashAll
goto(HandlingPartnersGoNogo) using mind
// When its partner tells it to go
......@@ -509,7 +514,7 @@ class AgentBehaviour(variable: Variable,
// When it receives a Go from its partner
case Event(GiveGo(move), mind) =>
if (debug) println(s"$variable in $stateName has received Trigger")
if (debug) println(s"$variable in $stateName has received GiveGo")
val newVal: Value = mind.updateVal(variable, move)
val updatedMind: MGM2Mind = new MGM2Mind(context = mind.context.fix(variable, newVal),
mind.isCommitted, mind.partner,
......@@ -518,6 +523,7 @@ class AgentBehaviour(variable: Variable,
mind.metric)
if (trace) println(s"$variable -> Supervisor : I'm changing = InformValue(${updatedMind.context.getValue(variable).get})")
supervisor ! InformValue(updatedMind.context.getValue(variable).get)
unstashAll
goto(Continue) using updatedMind
// When it receives a NoGo from its partner
......@@ -525,6 +531,7 @@ class AgentBehaviour(variable: Variable,
if (debug) println(s"$variable in $stateName has received GiveNoGo")
if (trace) println(s"$variable -> Supervisor : I'm not changing = InformValue(${mind.context.getValue(variable).get})")
supervisor ! InformValue(mind.context.getValue(variable).get)
unstashAll
goto(Continue) using mind
}
......
......@@ -16,7 +16,7 @@ class Supervisor(val pb : DCOP, val algorithm: Algorithm, val initialContext: Co
with FSM[SupervisorState, SupervisorStatus] {
var debug = false
var debugState = false
var debugState = true
var trace = false
var solver: ActorRef = context.parent // Reference to the distributed solver
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment