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 1f2c255ed5a2cf6654a8c66a2403e5e8d32fc7eb..17919942caeb97b6b20d39402cfa3734316030f1 100644 --- a/src/main/scala/org/scadcop/solver/decentralized/mgm2/AgentBehaviour.scala +++ b/src/main/scala/org/scadcop/solver/decentralized/mgm2/AgentBehaviour.scala @@ -14,7 +14,7 @@ import akka.actor.{FSM, Stash} * 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 variablesAlex which are linked to the variables + * @param neighbours the variables which are linked to the variables * @param constraints which should be valuated */ class AgentBehaviour(variable: Variable, @@ -157,7 +157,7 @@ class AgentBehaviour(variable: Variable, val potentialPartner: Variable = updatedMind.choosePartner(neighbours) updatedMind = updatedMind.setPartner(potentialPartner) if (debug) println(s"$variable> context before computing the joint offer=${updatedMind.currentContext}") - val moves: List[BilateralMove] = updatedMind.computeJointOffer(potentialPartner, neighbours, constraints) + val moves: List[BilateralMove] = updatedMind.computeJointOffer(variable, potentialPartner, constraints) val offer: Offer = new Offer(variable, moves) directory.addressOf(potentialPartner) ! MakeOffer(offer) if (trace) println(s"$variable -> $potentialPartner : MakeOffer(${Some(offer)}") diff --git a/src/main/scala/org/scadcop/solver/decentralized/mgm2/MGM2Mind.scala b/src/main/scala/org/scadcop/solver/decentralized/mgm2/MGM2Mind.scala index 0d4bab944b6de47f10c397b7f3980b348a265e66..68210d3e1f0a5b185a65b676df2c6a212319c6da 100644 --- a/src/main/scala/org/scadcop/solver/decentralized/mgm2/MGM2Mind.scala +++ b/src/main/scala/org/scadcop/solver/decentralized/mgm2/MGM2Mind.scala @@ -94,18 +94,16 @@ class MGM2Mind(val context : Context = new Context(), * @param neighbours the variables which are linked to the variables * @param constraints which should be valuated */ - def computeJointOffer(variable: Variable, - neighbours: Set[Variable], + def computeJointOffer(variable: Variable, potentialPartner: Variable, constraints: Set[Constraint] ): List[BilateralMove] = { val currentCost: Double = currentContext.cost(constraints) var moves = List[BilateralMove]() - neighbours.foreach { neighbour => // foreach neighbour - neighbour.domain.foreach { neighbourValue => // for each value of the neighbour + potentialPartner.domain.foreach { partnerValue => // for each value of the neighbour variable.domain.foreach { myValue => // for each value of the local variable if (myValue != context.getValue(variable).get || - myValue != context.getValue(neighbour).get) { // If this is a move from the current context - val potentialContext: Context = context.fix(variable, myValue).fix(neighbour, neighbourValue) + myValue != context.getValue(potentialPartner).get) { // If this is a move from the current context + val potentialContext: Context = context.fix(variable, myValue).fix(potentialPartner, partnerValue) val potentialCost: Double = potentialContext.cost(constraints) val gain = currentCost - potentialCost val move = new BilateralMove(potentialContext, gain) @@ -113,7 +111,6 @@ class MGM2Mind(val context : Context = new Context(), } } } - } moves } @@ -149,7 +146,6 @@ class MGM2Mind(val context : Context = new Context(), } } } - //neighbourDeltas = neighbourDeltas.updated(receiverVariable, bestDelta) (bestOffer, bestDelta) }