/// <summary> /// Missing belief is guessed /// The worker possibly complete the task incorrectly /// and learn by doing /// </summary> /// <param name="task"></param> /// <param name="blocker"></param> /// <param name="murphy"></param> /// <param name="resolution"></param> public void RecoverBlockerIncompleteByGuessing(SymuTask task, Blocker blocker, MurphyIncomplete murphy, BlockerResolution resolution) { if (task is null) { throw new ArgumentNullException(nameof(task)); } if (murphy == null) { throw new ArgumentNullException(nameof(murphy)); } var impact = murphy.NextGuess(); if (impact > task.Incorrectness) { task.Incorrectness = impact; } if (task.Incorrectness == ImpactLevel.Blocked) { //Agent decide to cancel the task TaskProcessor.Cancel(task); } else { task.Weight *= murphy.NextImpactOnTimeSpent(); if (blocker != null) { task.Recover(blocker, resolution); } } }
/// <summary> /// Check a particular beliefId from Task.BeliefBits against Agent.Beliefs /// Prevent the agent from acting on a particular belief /// Task may be blocked if it is the case /// </summary> public void CheckRiskAversion(SymuTask task, IAgentId knowledgeId) { if (task is null) { throw new ArgumentNullException(nameof(task)); } if (!BeliefsModel.On) { return; } var taskBits = task.KnowledgesBits.GetBits(knowledgeId); float mandatoryScore = 0; byte mandatoryIndex = 0; var belief = BeliefsModel.GetBeliefFromKnowledgeId(knowledgeId); var actorBelief = BeliefsModel.GetActorBelief(knowledgeId); MurphyIncompleteBelief.CheckRiskAversion(belief, taskBits, actorBelief, ref mandatoryScore, ref mandatoryIndex, -Cognitive.InternalCharacteristics.RiskAversionValue()); if (!(mandatoryScore <= -Cognitive.InternalCharacteristics.RiskAversionValue())) { return; } var murphy = Environment.MainOrganization.Murphies.IncompleteBelief; // Prevent the agent from acting on a particular belief if (murphy.ShouldGuess((byte)task.HasBeenCancelledBy.Count)) { // to avoid complete blocking, we allow the agent, depending on the Murphies.IncompleteBelief parameters // to unblock the task var blocker = task.Add(Murphy.IncompleteBelief, Schedule.Step, knowledgeId, mandatoryIndex); RecoverBlockerIncompleteBeliefByGuessing(task, blocker); } else { // Agent can cancel the task a certain number of times TaskProcessor.Cancel(task); } }