From 7816b8f90084bb3cb03aae2a2b1872f06f3d661e Mon Sep 17 00:00:00 2001 From: Alex <alexandravigneron1@gmail.com> Date: Wed, 8 Jul 2020 10:35:02 +0200 Subject: [PATCH] added allunstashAll --- .../solver/decentralized/agent/VariableAgent.scala | 2 +- .../solver/decentralized/mgm2/AgentBehaviour.scala | 9 ++++++++- .../solver/decentralized/supervisor/Supervisor.scala | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/scala/org/scadcop/solver/decentralized/agent/VariableAgent.scala b/src/main/scala/org/scadcop/solver/decentralized/agent/VariableAgent.scala index fb92fb1..d6a308b 100755 --- a/src/main/scala/org/scadcop/solver/decentralized/agent/VariableAgent.scala +++ b/src/main/scala/org/scadcop/solver/decentralized/agent/VariableAgent.scala @@ -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() diff --git a/src/main/scala/org/scadcop/solver/decentralized/mgm2/AgentBehaviour.scala b/src/main/scala/org/scadcop/solver/decentralized/mgm2/AgentBehaviour.scala index 3e17241..d88b44c 100755 --- a/src/main/scala/org/scadcop/solver/decentralized/mgm2/AgentBehaviour.scala +++ b/src/main/scala/org/scadcop/solver/decentralized/mgm2/AgentBehaviour.scala @@ -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 } 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 c8181c6..c58beaf 100755 --- a/src/main/scala/org/scadcop/solver/decentralized/supervisor/Supervisor.scala +++ b/src/main/scala/org/scadcop/solver/decentralized/supervisor/Supervisor.scala @@ -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 -- GitLab