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 51d958b303523978eeb39d03c70007970378a44b..9ca4f63eaabed6307389b4b5d8bafaecbc46ebc8 100644 --- a/src/main/scala/org/scadcop/solver/decentralized/mgm2/AgentBehaviour.scala +++ b/src/main/scala/org/scadcop/solver/decentralized/mgm2/AgentBehaviour.scala @@ -242,13 +242,13 @@ class AgentBehaviour(variable: Variable, when(ReceiverWaitingOffers) { // When offers are still missing - case Event(MakeOffer(eventualOffer), mind) if mind.nbReceivedOffers < neighbours.size => + case Event(MakeOffer(eventualOffer), mind) if mind.nbReceivedOffers < neighbours.size-1 => if (debug) println(s"$variable in $stateName has received MakeOffer and the context is partial.") val updatedMind: MGM2Mind = mind.addOffer(variable, eventualOffer) stay using updatedMind // When the last offer is received - case Event(MakeOffer(eventualOffer), mind) if mind.nbReceivedOffers == neighbours.size => + case Event(MakeOffer(eventualOffer), mind) if mind.nbReceivedOffers == neighbours.size-1 => if (debug) println(s"$variable in $stateName has received MakeOffer and the context is full.") var updatedMind: MGM2Mind = mind.addOffer(variable, eventualOffer) val (bestOffer, bestDelta) = updatedMind.chooseBestSingleOffer(variable, neighbours, constraints) @@ -312,14 +312,14 @@ class AgentBehaviour(variable: Variable, when(Committed) { //when it receives a neighbour's delta and the neighbourDeltas is partial case Event(InformDelta(delta), mind) if mind.deltas.size < neighbours.size => - if (debug) println(s"$variable in $stateName has received InformDelta and the contextis partial.") + if (debug) println(s"$variable in $stateName has received InformDelta (${mind.deltas.size}/${neighbours.size}) and the contextis partial.") val neighbour: Variable = directory.variableOf(sender) val updatedMind: MGM2Mind = mind.updateDeltas(neighbour: Variable, delta: Double) stay using updatedMind //when it receives a neighbour's delta and the context is full case Event(InformDelta(delta), mind) if mind.deltas.size == neighbours.size => - if (debug) println(s"$variable in $stateName has received InformDelta and the context is full.") + if (debug) println(s"$variable in $stateName has received InformDelta (${mind.deltas.size}/${neighbours.size}) and the context is full.") val neighbour: Variable = directory.variableOf(sender) val updatedMind: MGM2Mind = mind.updateDeltas(neighbour: Variable, delta: Double) val shouldIact: Boolean = updatedMind.amIBest(variable) @@ -340,14 +340,14 @@ class AgentBehaviour(variable: Variable, when(Uncommitted){ //when it receives a neighbour's delta and the neighbourDeltas is partial case Event(InformDelta(delta), mind) if mind.deltas.size < neighbours.size => - if (debug) println(s"$variable in $stateName has received InformDelta and the context is partial.") + if (debug) println(s"$variable in $stateName has received InformDelta (${mind.deltas.size}/${neighbours.size}) and the context is partial.") val neighbour: Variable = directory.variableOf(sender) val updatedMind: MGM2Mind = mind.updateDeltas(neighbour: Variable, delta: Double) stay using updatedMind //when it receves a neighbour's delta and the context is full case Event(InformDelta(delta), mind) if mind.deltas.size == neighbours.size => - if (debug) println(s"$variable in $stateName has received InformDelta and the context is full.") + if (debug) println(s"$variable in $stateName has received InformDelta (${mind.deltas.size}/${neighbours.size})and the context is full.") val neighbour: Variable = directory.variableOf(sender) val updatedMind: MGM2Mind = mind.updateDeltas(neighbour: Variable, delta: Double) val shouldIact: Boolean = updatedMind.amIBest(variable) diff --git a/src/main/scala/org/scadcop/solver/decentralized/mgm2/SupervisorBehaviour.Scala b/src/main/scala/org/scadcop/solver/decentralized/mgm2/SupervisorBehaviour.Scala deleted file mode 100644 index e7371d9beb5556ee42df70ae5b85bc4640d44ec9..0000000000000000000000000000000000000000 --- a/src/main/scala/org/scadcop/solver/decentralized/mgm2/SupervisorBehaviour.Scala +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) Maxime MORGE, Alex VIGNERON 2020 -package org.scadcop.solver.decentralized.mgm2 - -import org.scadcop.problem._ -import org.scadcop.solver.decentralized._ -import org.scadcop.solver.decentralized.agent._ - -import akka.actor.{FSM, Stash} - -/** - * Negotiation behaviour for an agent in the MGM2 algorithm - * See Maheswaran R.T., Pearce J.P., Tambe M. (2006) - * A Family of Graphical-Game-Based Algorithms for Distributed Constraint Optimization Problems. - * In: Scerri P., Vincent R., Mailler R. (eds) - * Coordination of Large-Scale Multiagent Systems. Springer, Boston, MA. - * @param variable which should be valuated - * @param neighbours the variables which are linked to the variables - * @param constraints which should be valuated - */ -class SupervisorBehaviour(variable: Variable, - neighbours : Set[Variable], - constraints: Set[Constraint]) - extends VariableAgent(variable, neighbours, constraints) - with FSM[MGM2State, MGM2Mind] - with Stash { - - debug = true - - - /** - * Initially the agent has no task in the bundle - */ - startWith(Init, new MGM2Mind()) - - when(Start){ - //when it receives a - case Event(Trigger, mind) => { - stay using mind - } - - } - - -} -