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

minor changes

parent 92cc39fa
Branches
No related tags found
No related merge requests found
......@@ -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)
......
// 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
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment