/// <summary>
        /// Assigns new decision option to mental model of current agent. If empty rooms ended, old decision options will be removed.
        /// </summary>
        /// <param name="newDecisionOption"></param>
        public void AssignNewDecisionOption(DecisionOption newDecisionOption)
        {
            DecisionOptionLayer layer = newDecisionOption.Layer;

            DecisionOption[] layerDecisionOptions = AssignedDecisionOptions.GroupBy(r => r.Layer).Where(g => g.Key == layer).SelectMany(g => g).ToArray();

            if (layerDecisionOptions.Length < layer.LayerConfiguration.MaxNumberOfDecisionOptions)
            {
                AssignedDecisionOptions.Add(newDecisionOption);
                AnticipationInfluence.Add(newDecisionOption, new Dictionary <Goal, double>());

                DecisionOptionActivationFreshness[newDecisionOption] = 0;
            }
            else
            {
                DecisionOption decisionOptionForRemoving = DecisionOptionActivationFreshness.Where(kvp => kvp.Key.Layer == layer).GroupBy(kvp => kvp.Value).OrderByDescending(g => g.Key)
                                                           .Take(1).SelectMany(g => g.Select(kvp => kvp.Key)).RandomizeOne();

                AssignedDecisionOptions.Remove(decisionOptionForRemoving);
                AnticipationInfluence.Remove(decisionOptionForRemoving);

                DecisionOptionActivationFreshness.Remove(decisionOptionForRemoving);

                AssignNewDecisionOption(newDecisionOption);
            }
        }
        /// <summary>
        /// Adds decision option to the decision option set layer.
        /// </summary>
        /// <param name="decisionOption"></param>
        public void Add(DecisionOption decisionOption)
        {
            indexer++;
            decisionOption.PositionNumber = indexer;
            decisionOption.Layer          = this;

            DecisionOptions.Add(decisionOption);
        }
        /// <summary>
        /// Assigns new decision option with defined anticipated influence to mental model of current agent. If empty rooms ended, old decision options will be removed.
        /// Anticipated influence is copied to the agent.
        /// </summary>
        /// <param name="newDecisionOption"></param>
        /// <param name="anticipatedInfluence"></param>
        public void AssignNewDecisionOption(DecisionOption newDecisionOption, Dictionary <Goal, double> anticipatedInfluence)
        {
            AssignNewDecisionOption(newDecisionOption);

            //copy ai to personal ai for assigned goals only

            Dictionary <Goal, double> ai = anticipatedInfluence.Where(kvp => AssignedGoals.Contains(kvp.Key)).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

            AnticipationInfluence[newDecisionOption] = new Dictionary <Goal, double>(ai);
        }
示例#4
0
        /// <summary>
        /// Adds decision option to mental model of current prototype if it isn't exists in the scope.
        /// </summary>
        /// <param name="newDecisionOption"></param>
        /// <param name="layer"></param>
        public void AddNewDecisionOption(DecisionOption newDecisionOption, DecisionOptionLayer layer)
        {
            if (mentalProto == null)
            {
                TransformDOToMentalModel();
            }

            layer.Add(newDecisionOption);

            DecisionOptions.Add(newDecisionOption);
        }
        /// <summary>
        /// Removes decision option from decision option set layer.
        /// </summary>
        /// <param name="decisionOption"></param>
        public void Remove(DecisionOption decisionOption)
        {
            decisionOption.Layer = null;

            DecisionOptions.Remove(decisionOption);
        }
示例#6
0
 /// <summary>
 /// Checks for similar decision options
 /// </summary>
 /// <param name="decisionOption"></param>
 /// <returns></returns>
 public bool IsSimilarDecisionOptionExists(DecisionOption decisionOption)
 {
     return(DecisionOptions.Any(kh => kh == decisionOption));
 }
        /// <summary>
        /// Adds decision option to agent prototype and then assign one to the decision option list of current agent.
        /// Also copies anticipated influence to the agent.
        /// </summary>
        /// <param name="newDecisionOption"></param>
        /// <param name="layer"></param>
        /// <param name="anticipatedInfluence"></param>
        public void AddDecisionOption(DecisionOption newDecisionOption, DecisionOptionLayer layer, Dictionary <Goal, double> anticipatedInfluence)
        {
            Prototype.AddNewDecisionOption(newDecisionOption, layer);

            AssignNewDecisionOption(newDecisionOption, anticipatedInfluence);
        }
        /// <summary>
        /// Adds decision option to agent prototype and then assign one to the decision option list of current agent.
        /// </summary>
        /// <param name="newDecisionOption"></param>
        /// <param name="layer"></param>
        public void AddDecisionOption(DecisionOption newDecisionOption, DecisionOptionLayer layer)
        {
            Prototype.AddNewDecisionOption(newDecisionOption, layer);

            AssignNewDecisionOption(newDecisionOption);
        }