示例#1
0
        public override double CalculateTrust(Agent trustor, Trustee trustee, TrustAction action)
        {
            var            actionFeatures = action.WeightedFeatures;
            List <Feature> looseFeatures  = new List <Feature>();

            double result = 0;

            foreach (Feature feature in trustee.Features)
            {
                if (actionFeatures.Any(x => x.Key.Resource.Equals(feature.FeatureID.Resource)))
                {
                    var weight = actionFeatures.First(x => x.Key.Resource.Equals(feature.FeatureID.Resource)).Value;
                    result += weight * feature.BeliefValue;
                }
                else
                {
                    looseFeatures.Add(feature);
                }
            }

            result *= 0.9d;

            foreach (Feature looseFeature in looseFeatures)
            {
                result += (looseFeature.BeliefValue / looseFeatures.Count) * 0.1;
            }

            return(result);
        }
示例#2
0
        static void Main(string[] args)
        {
            TrustModelManager model = new TrustModelManager();

            /*var ana = new Agent("Ana");
             * Singleton<AgentsManager>.Instance.Agents.Add(ana);
             * var bob = new Agent("Bob");
             * Singleton<AgentsManager>.Instance.Agents.Add(bob);
             *
             * var cat = new Category("Ability");
             * Singleton<CategoriesManager>.Instance.Categories.Add(cat);
             *
             * var feature = new FeatureModel("Cooking", cat);
             * Singleton<FeaturesManager>.Instance.Features.Add(feature);
             *
             * var perceptionModel = new PerceptionModel("Saw Cooking");
             * perceptionModel.AffectedAgents.List.Add(ana);
             * perceptionModel.TargetTrustees.List.Add(bob);
             * perceptionModel.FeaturesToSpawn.List.Add(feature);
             *
             * var perception = perceptionModel.SpawnFeature(10, 1);
             * perception.UpdateModel();
             *
             */
            Agent ana = Singleton <AgentsManager> .Instance.Agents["Ana"];
            Agent bob = Singleton <AgentsManager> .Instance.Agents["Bob"];

            var         feature = Singleton <FeaturesManager> .Instance.Features["Cooking"];
            TrustAction action  = new TrustAction("Cooking");

            action.AddFeature(feature, 1);

            var a = ana.TrusteeTrustValues(bob, action, new[] { new SimpleLinear() });
        }
示例#3
0
        public Dictionary <string, double> TrusteeTrustValues(Agent targetAgent, TrustAction action, TrustFunction[] trustFunctions)
        {
            Dictionary <string, double> result = new Dictionary <string, double>();

            Trustee targetTrustee = Trustees[targetAgent.Name];

            foreach (TrustFunction trustFunction in trustFunctions)
            {
                result.Add(trustFunction.ToString(), trustFunction.CalculateTrust(this, targetTrustee, action));
            }

            return(result);
        }
示例#4
0
 public abstract double CalculateTrust(Agent trustor, Trustee trustee, TrustAction action);