public void NullCheckTest() { byte[] taskKnowledge = { }; Assert.ThrowsException <ArgumentNullException>(() => _actorBelief1.Check(null, out _, _belief1, 1, true)); Assert.ThrowsException <ArgumentNullException>( () => _actorBelief1.Check(taskKnowledge, out _, null, 1, true)); }
/// <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); }
public void ZeroLengthCheckTest() { byte[] taskKnowledge = { }; _actorBelief0.SetBeliefBits(_bits0); Assert.AreEqual(0, _actorBelief0.Check(taskKnowledge, out _, _belief0, 1, true)); }