public void Initialize() { var agentId = new AgentId(1, 1); _belief0 = new Belief(Network, 0, Model, BeliefWeightLevel.RandomWeight); _belief1 = new Belief(Network, 1, Model, BeliefWeightLevel.RandomWeight); _belief2 = new Belief(Network, 2, Model, BeliefWeightLevel.RandomWeight); _actorBelief0 = new ActorBelief(agentId, _belief0.EntityId, BeliefLevel.NeitherAgreeNorDisagree); _actorBelief1 = new ActorBelief(agentId, _belief1.EntityId, BeliefLevel.NeitherAgreeNorDisagree); _actorBelief2 = new ActorBelief(agentId, _belief2.EntityId, BeliefLevel.NeitherAgreeNorDisagree); }
public void Initialize() { MainOrganization.Models.Generator = RandomGenerator.RandomUniform; _cognitiveArchitecture = new CognitiveArchitecture { KnowledgeAndBeliefs = { HasBelief = true, HasKnowledge = true }, MessageContent = { CanReceiveBeliefs = true, CanReceiveKnowledge = true }, InternalCharacteristics = { CanLearn = true, CanForget = true, CanInfluenceOrBeInfluence = true } }; var modelEntity = new BeliefModelEntity { On = true }; _beliefsModel = new BeliefsModel(_agentId, modelEntity, _cognitiveArchitecture, Network, MainOrganization.Models.Generator); _belief = new Belief(Network, 1, MainOrganization.Models.Generator, BeliefWeightLevel.RandomWeight); _actorBelief = new ActorBelief(Network.ActorBelief, _agentId, _belief.EntityId, BeliefLevel.NeitherAgreeNorDisagree); _taskBits.SetMandatory(new byte[] { 0 }); _taskBits.SetRequired(new byte[] { 0 }); }
/// <summary> /// Check belief required by a task against the worker expertise /// </summary> /// <param name="belief"></param> /// <param name="taskBitIndexes">KnowledgeBit indexes of the task that must be checked against agent's beliefs</param> /// <param name="actorBelief"></param> /// <param name="mandatoryCheck"> /// The normalized score of the agent belief [-1; 1] at the first mandatoryIndex that is above /// beliefThreshHoldForReacting /// </param> /// <param name="requiredCheck"></param> /// <param name="mandatoryIndex"></param> /// <param name="requiredIndex"></param> /// <returns>0 if agent has no beliefs</returns> public void CheckBelief(Belief belief, TaskKnowledgeBits taskBitIndexes, ActorBelief actorBelief, ref float mandatoryCheck, ref float requiredCheck, ref byte mandatoryIndex, ref byte requiredIndex) { if (taskBitIndexes is null) { throw new ArgumentNullException(nameof(taskBitIndexes)); } if (belief is null) { throw new ArgumentNullException(nameof(belief)); } // model is off if (!IsAgentOn()) { mandatoryCheck = 0; requiredCheck = 0; return; } // agent may don't have the belief at all //var actorBelief = actorBeliefs?.GetActorBelief<ActorBelief>(belief.EntityId); if (actorBelief == null) { mandatoryCheck = 0; requiredCheck = 0; return; } mandatoryCheck = actorBelief.Check(taskBitIndexes.GetMandatory(), out mandatoryIndex, belief, ThresholdForReacting, true); requiredCheck = actorBelief.Check(taskBitIndexes.GetRequired(), out requiredIndex, belief, ThresholdForReacting, true); }
public static void CheckRiskAversion(Belief belief, TaskKnowledgeBits taskBitIndexes, ActorBelief actorBelief, ref float mandatoryCheck, ref byte mandatoryIndex, float threshold) { if (taskBitIndexes is null) { throw new ArgumentNullException(nameof(taskBitIndexes)); } if (belief is null) { throw new NullReferenceException(nameof(belief)); } // agent may don't have the belief at all //var agentBelief = actorBeliefs?.GetActorBelief<ActorBelief>(belief.EntityId); if (actorBelief == null) { mandatoryCheck = 0; return; } mandatoryCheck = actorBelief.Check(taskBitIndexes.GetMandatory(), out mandatoryIndex, belief, threshold, false); }