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}
* 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)}")
......
......@@ -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)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment