Skip to content

Commit

Permalink
Mock externalized params for Maslowian studies
Browse files Browse the repository at this point in the history
  • Loading branch information
IDoCodingStuffs committed Jul 7, 2019
1 parent 741b7d1 commit 5a0a4bd
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.codingstuffs.abilene.intake

object ParamRequisitionActor {

}

class ParamRequisitionActor {

}
Original file line number Diff line number Diff line change
@@ -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)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 15 additions & 9 deletions src/main/scala/net/codingstuffs/abilene/simulation/Member.scala
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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 {

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ abstract class DecisionMakingModel
abstract class AgentBehaviorModel

case object MaslowianAgent extends AgentBehaviorModel
case object StochasticAgent extends AgentBehaviorModel
case object SimpleAgent extends AgentBehaviorModel

0 comments on commit 5a0a4bd

Please sign in to comment.