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

renaming in choosebestsingleoffer

parent 1ceff1e1
Branches
No related tags found
No related merge requests found
......@@ -277,7 +277,7 @@ class AgentBehaviour(variable: Variable,
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(eventualOffer)
val (bestOffer, bestDelta) = updatedMind.chooseBestSingleOffer(variable, neighbours, constraints)
val (bestOffer, bestDelta) = updatedMind.chooseBestSingleOffer(variable, constraints)
updatedMind = updatedMind.updateDeltas(variable, bestDelta)
val partner : Option[Variable]= bestOffer match {
case Some(o) => Some(o.offererVariable)
......
......@@ -122,7 +122,6 @@ class MGM2Mind(val context : Context = new Context(),
* @param constraints which should be valuated
*/
def chooseBestSingleOffer(receiverVariable: Variable,
neighbours: Set[Variable],
constraints: Set[Constraint]): (Option[Offer], Double) = {
val currentCost = currentContext.cost(constraints)
var bestOffer: Option[Offer] = None // The best offer which will be selected, eventually none
......@@ -133,13 +132,13 @@ class MGM2Mind(val context : Context = new Context(),
val receiverValue: Value = move.context.getValue(receiverVariable).get
val offererValue: Value = move.context.getValue(offererVariable).get
val constraint: Constraint = relevantConstraint(constraints, receiverVariable, offererVariable)
val costConstraint = constraint.cost(context)
val commonUtilityBeforeChange = constraint.cost(context)
val potentialContext = context.fix(offererVariable, offererValue).fix(receiverVariable, receiverValue)
val commonUtilityAfterChange = constraint.cost(potentialContext)
val potentialCost = potentialContext.cost(constraints)
val potentialCostConstraint = constraint.cost(potentialContext)
val gainConstraint = costConstraint - potentialCostConstraint
val sharedUtilityGain = commonUtilityAfterChange - commonUtilityBeforeChange
//Subtract the difference in the link between the two agent so it is not counted twice
val delta: Double = currentCost - potentialCost + move.payoff - gainConstraint
val delta: Double = potentialCost - currentCost + move.payoff - sharedUtilityGain
if (delta ~> bestDelta) {
bestDelta = delta
bestOffer = Some(new Offer(offererVariable, List(move)))
......
......@@ -249,7 +249,7 @@ class Supervisor(val pb : DCOP, val algorithm: Algorithm) extends Actor with Sta
object Supervisor {
var counter = 0
val NB_ROUNDS = 2
val NB_ROUNDS = 5
def incrementCounter() : Int = {
counter = counter + 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment