From 5a0a4bdfbb6fa2e3f0ebaf786e2be2efef3a3622 Mon Sep 17 00:00:00 2001 From: IDoCodingStuffs Date: Sun, 7 Jul 2019 16:58:39 -0400 Subject: [PATCH] Mock externalized params for Maslowian studies --- .../intake/ParamRequisitionActor.scala | 9 +++++++ .../abilene/intake/mock/SocialBehavior.scala | 12 ++++++++++ .../abilene/simulation/Abilene.scala | 2 +- .../abilene/simulation/Member.scala | 24 ++++++++++++------- .../generators/random/FoldedGaussian.scala | 7 +++--- .../models/DecisionMakingModel.scala | 2 +- 6 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 src/main/scala/net/codingstuffs/abilene/intake/ParamRequisitionActor.scala create mode 100644 src/main/scala/net/codingstuffs/abilene/intake/mock/SocialBehavior.scala diff --git a/src/main/scala/net/codingstuffs/abilene/intake/ParamRequisitionActor.scala b/src/main/scala/net/codingstuffs/abilene/intake/ParamRequisitionActor.scala new file mode 100644 index 0000000..b0ff6f3 --- /dev/null +++ b/src/main/scala/net/codingstuffs/abilene/intake/ParamRequisitionActor.scala @@ -0,0 +1,9 @@ +package net.codingstuffs.abilene.intake + +object ParamRequisitionActor { + +} + +class ParamRequisitionActor { + +} \ No newline at end of file diff --git a/src/main/scala/net/codingstuffs/abilene/intake/mock/SocialBehavior.scala b/src/main/scala/net/codingstuffs/abilene/intake/mock/SocialBehavior.scala new file mode 100644 index 0000000..aa76a3a --- /dev/null +++ b/src/main/scala/net/codingstuffs/abilene/intake/mock/SocialBehavior.scala @@ -0,0 +1,12 @@ +package net.codingstuffs.abilene.intake.mock + +object SocialBehavior { + val index_means_sd: Map[String, (Double, Double)] = Map( + "physio" -> (0, 0.2), + "safety" -> (0, 0.2), + "affiliation" -> (0, 0.2), + "mate_acquisition" -> (0, 0.2), + "mate_retention" -> (0, 0.2), + "parenting" -> (0, 0.2) + ) +} diff --git a/src/main/scala/net/codingstuffs/abilene/simulation/Abilene.scala b/src/main/scala/net/codingstuffs/abilene/simulation/Abilene.scala index 5cf3cb1..30c4a60 100644 --- a/src/main/scala/net/codingstuffs/abilene/simulation/Abilene.scala +++ b/src/main/scala/net/codingstuffs/abilene/simulation/Abilene.scala @@ -10,7 +10,7 @@ import akka.pattern.ask import akka.util.Timeout import com.typesafe.config.ConfigFactory import net.codingstuffs.abilene.simulation.decision_making.generators.random.{Beta, Discrete, FoldedGaussian, Uniform} -import net.codingstuffs.abilene.simulation.decision_making.models.{DecisionMakingModel, MaslowianAgent, StochasticAgent} +import net.codingstuffs.abilene.simulation.decision_making.models.{DecisionMakingModel, MaslowianAgent, SimpleAgent} import net.codingstuffs.abilene.simulation.decision_making.models.simplified.ArithmeticRoundup.{EgalitarianRoundup, SelfishRoundup, WeightedRoundup} import scala.concurrent.duration.FiniteDuration diff --git a/src/main/scala/net/codingstuffs/abilene/simulation/Member.scala b/src/main/scala/net/codingstuffs/abilene/simulation/Member.scala index 27831b1..dbf8e6d 100644 --- a/src/main/scala/net/codingstuffs/abilene/simulation/Member.scala +++ b/src/main/scala/net/codingstuffs/abilene/simulation/Member.scala @@ -1,13 +1,15 @@ package net.codingstuffs.abilene.simulation import akka.actor.{Actor, ActorLogging, ActorRef, Props} +import net.codingstuffs.abilene.intake.mock.SocialBehavior import net.codingstuffs.abilene.simulation.Group.DataPoint import net.codingstuffs.abilene.simulation.decision_making.calculators.DecisionCalculator import net.codingstuffs.abilene.simulation.decision_making.generators.GroupParamGenerator +import net.codingstuffs.abilene.simulation.decision_making.generators.random.FoldedGaussian import net.codingstuffs.abilene.simulation.decision_making.models.AgentParamGenerator.DecisionParams import net.codingstuffs.abilene.simulation.decision_making.models.{ AgentBehaviorModel, - AgentParamGenerator, DecisionMakingModel, MaslowianAgent, StochasticAgent + AgentParamGenerator, DecisionMakingModel, MaslowianAgent, SimpleAgent } import net.codingstuffs.abilene.simulation.decision_making.models.maslowian.MaslowianParamGenerator @@ -27,8 +29,8 @@ object Member { } class Member(group: ActorRef, - behaviorModel : AgentBehaviorModel, - decisionModel : DecisionMakingModel, + behaviorModel: AgentBehaviorModel, + decisionModel: DecisionMakingModel, randomGenerators: (Random, Random)) extends Actor with ActorLogging { @@ -45,19 +47,23 @@ class Member(group: ActorRef, implicit var params: DecisionParams = behaviorModel match { - case StochasticAgent => initialParams + case SimpleAgent => initialParams + + case MaslowianAgent => + val maslowianParams = new MaslowianParamGenerator(SocialBehavior.index_means_sd.map( + mapping => FoldedGaussian.GENERATOR(mapping._2._1, mapping._2._2).nextDouble + ).toList) - case MaslowianAgent => { - val maslowianParams = MaslowianParamGenerator.instance DecisionParams( (initialParams.selfParams._1, + //Homeostatic entropy calculated as inverse of a Maslowian sum initialParams.selfParams._2, (1 / maslowianParams.getMaslowianSum(name)) * initialParams.selfParams._3), - initialParams.groupPreferences, - initialParams.groupWeights) - } + + initialParams.groupPreferences, initialParams.groupWeights) } + private val knownPreferences = params.groupPreferences override def receive: Receive = onMessage(knownPreferences) diff --git a/src/main/scala/net/codingstuffs/abilene/simulation/decision_making/generators/random/FoldedGaussian.scala b/src/main/scala/net/codingstuffs/abilene/simulation/decision_making/generators/random/FoldedGaussian.scala index 3308fa3..3d909d3 100644 --- a/src/main/scala/net/codingstuffs/abilene/simulation/decision_making/generators/random/FoldedGaussian.scala +++ b/src/main/scala/net/codingstuffs/abilene/simulation/decision_making/generators/random/FoldedGaussian.scala @@ -3,9 +3,10 @@ package net.codingstuffs.abilene.simulation.decision_making.generators.random import scala.util.Random object FoldedGaussian { - final def GENERATOR(mean: Double) = new FoldedGaussian(mean) + final def GENERATOR(mean: Double) = new FoldedGaussian(mean, 1) + final def GENERATOR(mean: Double, sd: Double) = new FoldedGaussian(mean, sd) } -class FoldedGaussian(mean: Double) extends Random { - override def nextDouble: Double = math.abs(super.nextGaussian) + mean +class FoldedGaussian(mean: Double, sd: Double) extends Random { + override def nextDouble: Double = math.abs(super.nextGaussian * sd) + mean } diff --git a/src/main/scala/net/codingstuffs/abilene/simulation/decision_making/models/DecisionMakingModel.scala b/src/main/scala/net/codingstuffs/abilene/simulation/decision_making/models/DecisionMakingModel.scala index 5f3560c..b7c3731 100644 --- a/src/main/scala/net/codingstuffs/abilene/simulation/decision_making/models/DecisionMakingModel.scala +++ b/src/main/scala/net/codingstuffs/abilene/simulation/decision_making/models/DecisionMakingModel.scala @@ -6,4 +6,4 @@ abstract class DecisionMakingModel abstract class AgentBehaviorModel case object MaslowianAgent extends AgentBehaviorModel -case object StochasticAgent extends AgentBehaviorModel \ No newline at end of file +case object SimpleAgent extends AgentBehaviorModel \ No newline at end of file