diff --git a/src/main/scala/org/smastaplus/experiment/consumer/ConsumptionCampaign.scala b/src/main/scala/org/smastaplus/experiment/consumer/ConsumptionCampaign.scala index 78285369ca4f3b8816497f2348b83a3ee9f9f0d3..83ad412cc15a20db6ee9a3a6867ca44d483a835f 100644 --- a/src/main/scala/org/smastaplus/experiment/consumer/ConsumptionCampaign.scala +++ b/src/main/scala/org/smastaplus/experiment/consumer/ConsumptionCampaign.scala @@ -25,7 +25,7 @@ class ConsumptionCampaign(simulatedCost: SimulatedCost, fromStable: Boolean = fa val decentralizedDispatcherId = "akka.actor.default-dispatcher" val configurations : List[ConsumptionConfiguration] = { // The configurations - val numbersOfJobs = List.range(6, 9, 1) // l in [4,5[ + val numbersOfJobs = List.range(4, 5, 1) // l in [4,5[ val numbersOfTasks = List.range(40, 320, 40) if (byNodes) List.tabulate(9)(nbNodes => new ConsumptionConfiguration(8+ nbNodes, 4, 120, Uncorrelated)) @@ -47,7 +47,7 @@ class ConsumptionCampaign(simulatedCost: SimulatedCost, fromStable: Boolean = fa 5 } private val outcomeWithNegotiation = new DealConsumptionOutcome() - private var outcomeWithoutNegotiation = new NoDealConsumptionOutcome() + private var outcomeWithoutNegotiation = new DealConsumptionOutcome() var consumer : SynchronousDecentralizedConsumer = _ @@ -123,12 +123,11 @@ class ConsumptionCampaign(simulatedCost: SimulatedCost, fromStable: Boolean = fa val d = 3 // d instances per resource val stap = STAP.randomProblem(l, m, n, o, d, configuration.randomGenerationRule) for(_ <- 1 to nbAllocations) { // foreach initial allocation - val decentralizedSystem = ActorSystem("AgentBasedConsumer" + AgentBasedConsumer.id) - AgentBasedConsumer.id += 1 - val decentralizedConsumerSystem = ActorSystem("DecentralizedConsumer" + AgentBasedConsumer.id) - AgentBasedConsumer.id += 1 - val decentralizedBalancerSystem = ActorSystem("DecentralizedBalancer" + AgentBasedConsumer.id) - AgentBasedConsumer.id += 1 + val decentralizedSystem = ActorSystem("DecentralizedSystem1") + val decentralizedSystem2 = ActorSystem("DecentralizedSystem2") + val decentralizedSystem3 = ActorSystem("DecentralizedSystem3") + val decentralizedConsumerSystem = ActorSystem("DecentralizedConsumer") + val decentralizedBalancerSystem = ActorSystem("DecentralizedBalancer") var allocation = ExecutedAllocation.randomAllocation(stap) if (fromStable){ @@ -160,15 +159,22 @@ class ConsumptionCampaign(simulatedCost: SimulatedCost, fromStable: Boolean = fa new NoneSingleCounterProposalStrategy, decentralizedSystem, name = ConsumerType, dispatcherId = decentralizedDispatcherId, false, simulatedCost) - case "PSI" => //TODO - new AgentBasedConsumer(stap, - GlobalFlowtime, - //new NoneMultiProposalStrategy, - new ConcreteMultiProposalStrategy(1000.0), - None, - new NoneSingleCounterProposalStrategy, - decentralizedSystem, name = ConsumerType, dispatcherId = decentralizedDispatcherId, - false, simulatedCost) + case "PSI" => + new SynchronousDecentralizedConsumer(stap, + decentralizedSystem2, + name = "PSI", + dispatcherId = decentralizedDispatcherId, + monitor = false, + ssi = false, + psi = true) + case "SSI" => + new SynchronousDecentralizedConsumer(stap, + decentralizedSystem3, + name = "SSI", + dispatcherId = decentralizedDispatcherId, + monitor = false, + ssi = true, + psi = false) case s => throw new RuntimeException(s"ERROR ConsumptionCampaign is not able to manage consumer $s") } @@ -209,7 +215,7 @@ class ConsumptionCampaign(simulatedCost: SimulatedCost, fromStable: Boolean = fa val consumptionSetting = new ConsumptionSetting(allocation, consumer) val consumptionExperiments = new ConsumptionExperiment(consumptionSetting) if (debug) println(s"ConsumptionCampaign: configuration=$configuration consumer=${consumer.name} run $nbRuns") - outcomeWithoutNegotiation = consumptionExperiments.run().asInstanceOf[NoDealConsumptionOutcome] + outcomeWithoutNegotiation = consumptionExperiments.run().asInstanceOf[DealConsumptionOutcome] if (debug) println(s"ConsumptionCampaign: configuration=$configuration consumer=${consumer.name} run $nbRuns ends") consumptionOutcomes = consumptionOutcomes.updatedWith(consumer.name)({ case Some(list) => Some(outcomeWithoutNegotiation :: list) diff --git a/src/main/scala/org/smastaplus/experiment/consumer/ConsumptionExperiment.scala b/src/main/scala/org/smastaplus/experiment/consumer/ConsumptionExperiment.scala index d4cf01af4c56daa8eccf20be96a11c83b5e07375..a0ee037fd3b757a50e803ca04eb877cd2cd2cde2 100644 --- a/src/main/scala/org/smastaplus/experiment/consumer/ConsumptionExperiment.scala +++ b/src/main/scala/org/smastaplus/experiment/consumer/ConsumptionExperiment.scala @@ -45,14 +45,6 @@ class DealConsumptionOutcome(metrics: Map[String,Double] = Map( "11NbSecondStages" -> 0.0, "12MeanSimulatedFlowtime"-> 0.0)) extends ConsumptionOutcome(metrics) - /** - * Class representing the outcome of an experiment for a standard consumer - */ - class NoDealConsumptionOutcome(metrics: Map[String, Double] = Map( - "00MeanRealFlowtime" -> 0.0 - )) - extends ConsumptionOutcome(metrics) - /** * Class representing the outcome of an experiment for a standard consumer */ @@ -94,9 +86,22 @@ class ConsumptionExperiment(setting: ConsumptionSetting) extends Experiment[Cons )) case s: SynchronousDecentralizedConsumer => result = s.consume(setting.allocation) - outcome = new NoDealConsumptionOutcome( + val solvingTime = System.nanoTime() - startingTime + outcome = new DealConsumptionOutcome( Map( "00MeanRealFlowtime" -> result.realGlobalMeanFlowtime, + "01MeanGlobalFlowtime" -> result.consumptions2allocation.meanGlobalFlowtime, + "02SolvingTime" -> solvingTime.toDouble, + "03LocalRatio" -> result.consumptions2allocation.localAvailabilityRatio, + "04NbDeals" -> setting.consumer.nbDeals, + "05NbDelegations" -> setting.consumer.nbDelegations, + "06NbSwaps" -> setting.consumer.nbSwaps, + "07NbTimeouts" -> setting.consumer.nbTimeouts, + "08EndowmentSize" -> setting.consumer.avgEndowmentSize, + "09NbDelegatedTasks" -> setting.consumer.nbDelegatedTasks, + "10NbFirstStages" -> setting.consumer.nbFirstStages, + "11NbSecondStages" -> setting.consumer.nbSecondStages, + "12MeanSimulatedFlowtime" -> result.consumptions2allocation.realGlobalMeanFlowtime )) } if (result.isSound) outcome diff --git a/src/main/scala/org/smastaplus/experiment/consumer/WithVsWithoutNegotiationCampaign.scala b/src/main/scala/org/smastaplus/experiment/consumer/WithVsWithoutNegotiationCampaign.scala index 878d3a061241030500f48c957bb7efa663b45eb5..6ad02d9b3837de1019c666424bd6722bc7ae8736 100644 --- a/src/main/scala/org/smastaplus/experiment/consumer/WithVsWithoutNegotiationCampaign.scala +++ b/src/main/scala/org/smastaplus/experiment/consumer/WithVsWithoutNegotiationCampaign.scala @@ -9,7 +9,7 @@ import org.smastaplus.core.SimulatedCostE */ object WithVsWithoutNegotiationCampaign extends App { val fileName = "consumption4jobs8nodes5staps5allocations040-320tasks" - val balancerTypes : List[String] = List("DecentralizedConsumerMultiDelegationGlobalFlowtime") + val balancerTypes : List[String] = List("DecentralizedConsumerMultiDelegationGlobalFlowtime", "PSI", "SSI") private val campaign = new ConsumptionCampaign(simulatedCost = new SimulatedCostE, byNodes = false) campaign.run(balancerTypes, fileName) }