Skip to content
Snippets Groups Projects
Commit 1ceff1e1 authored by Alex's avatar Alex
Browse files

fixed computeJointOffer to select only partner and own variable values!

parent 530571b3
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ import akka.actor.{FSM, Stash} ...@@ -14,7 +14,7 @@ import akka.actor.{FSM, Stash}
* In: Scerri P., Vincent R., Mailler R. (eds) * In: Scerri P., Vincent R., Mailler R. (eds)
* Coordination of Large-Scale Multiagent Systems. Springer, Boston, MA. * Coordination of Large-Scale Multiagent Systems. Springer, Boston, MA.
* @param variable which should be valuated * @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 * @param constraints which should be valuated
*/ */
class AgentBehaviour(variable: Variable, class AgentBehaviour(variable: Variable,
...@@ -157,7 +157,7 @@ class AgentBehaviour(variable: Variable, ...@@ -157,7 +157,7 @@ class AgentBehaviour(variable: Variable,
val potentialPartner: Variable = updatedMind.choosePartner(neighbours) val potentialPartner: Variable = updatedMind.choosePartner(neighbours)
updatedMind = updatedMind.setPartner(potentialPartner) updatedMind = updatedMind.setPartner(potentialPartner)
if (debug) println(s"$variable> context before computing the joint offer=${updatedMind.currentContext}") 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) val offer: Offer = new Offer(variable, moves)
directory.addressOf(potentialPartner) ! MakeOffer(offer) directory.addressOf(potentialPartner) ! MakeOffer(offer)
if (trace) println(s"$variable -> $potentialPartner : MakeOffer(${Some(offer)}") if (trace) println(s"$variable -> $potentialPartner : MakeOffer(${Some(offer)}")
......
...@@ -94,18 +94,16 @@ class MGM2Mind(val context : Context = new Context(), ...@@ -94,18 +94,16 @@ class MGM2Mind(val context : Context = new Context(),
* @param neighbours the variables which are linked to the variables * @param neighbours the variables which are linked to the variables
* @param constraints which should be valuated * @param constraints which should be valuated
*/ */
def computeJointOffer(variable: Variable, def computeJointOffer(variable: Variable, potentialPartner: Variable,
neighbours: Set[Variable],
constraints: Set[Constraint] constraints: Set[Constraint]
): List[BilateralMove] = { ): List[BilateralMove] = {
val currentCost: Double = currentContext.cost(constraints) val currentCost: Double = currentContext.cost(constraints)
var moves = List[BilateralMove]() var moves = List[BilateralMove]()
neighbours.foreach { neighbour => // foreach neighbour potentialPartner.domain.foreach { partnerValue => // for each value of the neighbour
neighbour.domain.foreach { neighbourValue => // for each value of the neighbour
variable.domain.foreach { myValue => // for each value of the local variable variable.domain.foreach { myValue => // for each value of the local variable
if (myValue != context.getValue(variable).get || if (myValue != context.getValue(variable).get ||
myValue != context.getValue(neighbour).get) { // If this is a move from the current context myValue != context.getValue(potentialPartner).get) { // If this is a move from the current context
val potentialContext: Context = context.fix(variable, myValue).fix(neighbour, neighbourValue) val potentialContext: Context = context.fix(variable, myValue).fix(potentialPartner, partnerValue)
val potentialCost: Double = potentialContext.cost(constraints) val potentialCost: Double = potentialContext.cost(constraints)
val gain = currentCost - potentialCost val gain = currentCost - potentialCost
val move = new BilateralMove(potentialContext, gain) val move = new BilateralMove(potentialContext, gain)
...@@ -113,7 +111,6 @@ class MGM2Mind(val context : Context = new Context(), ...@@ -113,7 +111,6 @@ class MGM2Mind(val context : Context = new Context(),
} }
} }
} }
}
moves moves
} }
...@@ -149,7 +146,6 @@ class MGM2Mind(val context : Context = new Context(), ...@@ -149,7 +146,6 @@ class MGM2Mind(val context : Context = new Context(),
} }
} }
} }
//neighbourDeltas = neighbourDeltas.updated(receiverVariable, bestDelta)
(bestOffer, bestDelta) (bestOffer, bestDelta)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment