Beispiel #1
0
 public void CheckTest()
 {
     Assert.IsFalse(_knowledgeModel.Check(_actorKnowledge0, _taskKnowledge0, out var index, Threshold, 0));
     Assert.AreEqual(0, index);
     Assert.IsFalse(_knowledgeModel.Check(_actorKnowledge0, _taskKnowledge1, out index, Threshold, 0));
     Assert.AreEqual(1, index);
     Assert.IsTrue(_knowledgeModel.Check(_actorKnowledge1, _taskKnowledge0, out _, Threshold, 0));
     Assert.IsTrue(_knowledgeModel.Check(_actorKnowledge1, _taskKnowledge1, out _, Threshold, 0));
     Assert.IsFalse(_knowledgeModel.Check(_actorKnowledge01, _taskKnowledge0, out index, Threshold, 0));
     Assert.AreEqual(0, index);
     Assert.IsTrue(_knowledgeModel.Check(_actorKnowledge01, _taskKnowledge1, out _, Threshold, 0));
     Assert.IsTrue(_knowledgeModel.Check(_actorKnowledgeFloat, _taskKnowledge0, out _, Threshold, 0));
     Assert.IsTrue(_knowledgeModel.Check(_actorKnowledgeFloat, _taskKnowledge1, out _, Threshold, 0));
 }
        /// <summary>
        ///     Check Knowledge required by a task against the worker expertise
        /// </summary>
        /// <param name="knowledgeId"></param>
        /// <param name="taskBitIndexes">KnowledgeBits indexes of the task that must be checked against worker Knowledge</param>
        /// <param name="knowledgeModel"></param>
        /// <param name="mandatoryCheck"></param>
        /// <param name="requiredCheck"></param>
        /// <param name="mandatoryIndex"></param>
        /// <param name="requiredIndex"></param>
        /// <param name="step"></param>
        public void CheckKnowledge(IAgentId knowledgeId, TaskKnowledgeBits taskBitIndexes,
                                   KnowledgeModel knowledgeModel,
                                   ref bool mandatoryCheck,
                                   ref bool requiredCheck, ref byte mandatoryIndex, ref byte requiredIndex, ushort step)
        {
            if (taskBitIndexes is null)
            {
                throw new ArgumentNullException(nameof(taskBitIndexes));
            }

            if (knowledgeModel == null)
            {
                throw new ArgumentNullException(nameof(knowledgeModel));
            }

            // model is off
            if (!IsAgentOn())
            {
                mandatoryCheck = true;
                requiredCheck  = true;
                return;
            }

            // agent may don't have the knowledge at all
            var actorKnowledge = knowledgeModel.GetActorKnowledge(knowledgeId);

            if (actorKnowledge == null)
            {
                return;
            }

            mandatoryCheck = knowledgeModel.Check(actorKnowledge, taskBitIndexes.GetMandatory(), out mandatoryIndex,
                                                  ThresholdForReacting, step);
            requiredCheck = knowledgeModel.Check(actorKnowledge, taskBitIndexes.GetRequired(), out requiredIndex,
                                                 ThresholdForReacting, step);
        }