Ejemplo n.º 1
0
        private static InitialStateConfiguration MakeInitialStateConfiguration(
            SheParameters sheParameters, SosielParameters sosielParameters)
        {
            var sameKeys = sosielParameters.AgentGoalAttributes.Select(ga => ga.Agent).Intersect(
                sosielParameters.AgentDecisionOptions.Select(d => d.Agent)).ToList();

            if (sosielParameters.AgentGoalAttributes.Count != sosielParameters.AgentDecisionOptions.Count ||
                sosielParameters.AgentGoalAttributes.Count != sameKeys.Count)
            {
                throw new ConfigurationException("AgentGoalAttributes is not suitable for AgentDecisionOptions");
            }

            var initialState = sosielParameters.AgentGoalAttributes
                               .Join(sosielParameters.AgentDecisionOptions, ga => ga.Agent, d => d.Agent, (goal, decision)
                                     => new { GoalAttribute = goal, DecisionAttribute = decision })
                               .ToList();

            var parsedStates = new List <AgentStateConfiguration>();

            foreach (var state in initialState)
            {
                var agentState          = ParseAgentState(sheParameters, state.GoalAttribute, state.DecisionAttribute);
                var variablesCollection = sosielParameters.AgentVariables.Cast <IVariable>().ToList();
                agentState.PrivateVariables = ParseAgentVariables(variablesCollection, state.GoalAttribute.Agent);
                parsedStates.Add(agentState);
            }

            return(new InitialStateConfiguration
            {
                AgentStates = parsedStates.ToArray()
            });
        }
Ejemplo n.º 2
0
        private static Dictionary <string, AgentArchetype> MakeAgentArchetypeConfiguration(SosielParameters parameters)
        {
            // Debugger.Launch();
            var agentArchetypes = new Dictionary <string, AgentArchetype>();
            var goals           = ParseGoals(parameters.GoalAttributes);
            var mentalModels    = ParseMentalModels(parameters.MentalModels);
            var decisionOptions = ParseDecisionOptions(
                parameters.DecisionOptionAttributes, parameters.DecisionOptionAntecedentAttributes);

            foreach (var archetype in parameters.AgentArchetypes)
            {
                var agentArchetype = new AgentArchetype(archetype.ArchetypeName);
                agentArchetype.NamePrefix             = archetype.ArchetypePrefix;
                agentArchetype.IsDataSetOriented      = archetype.DataSetOriented;
                agentArchetype.UseImportanceAdjusting = archetype.GoalImportanceAdjusting;
                agentArchetype.Goals        = goals[archetype.ArchetypeName];
                agentArchetype.MentalModels = mentalModels[archetype.ArchetypeName];

                var supportedMentalModels = agentArchetype.MentalModels.Values.Select(mm => mm.Name).ToList();

                agentArchetype.DecisionOptions = decisionOptions.Keys
                                                 .Where(d => supportedMentalModels.Contains(GetDecisionOptionMentalModelName(d)))
                                                 .Select(k => decisionOptions[k])
                                                 .ToList();

                var variablesCollection = parameters.AgentArchetypeVariables.Cast <IVariable>().ToList();
                foreach (var agentVariable in ParseAgentVariables(variablesCollection, agentArchetype.Name))
                {
                    agentArchetype.CommonVariables.Add(agentVariable.Key, agentVariable.Value);
                }

                // Debugger.Launch();
                agentArchetypes[agentArchetype.Name] = agentArchetype;
            }

            return(agentArchetypes);
        }
Ejemplo n.º 3
0
 public static ConfigurationModel MakeConfiguration(SheParameters sheParameters, SosielParameters sosielParameters)
 {
     return(new ConfigurationModel
     {
         AlgorithmConfiguration = MakeAlgorithmConfiguration(
             sosielParameters.CognitiveLevel, sosielParameters.Demographic, sosielParameters.Probabilities),
         AgentArchetypeConfiguration = MakeAgentArchetypeConfiguration(sosielParameters),
         InitialState = MakeInitialStateConfiguration(sheParameters, sosielParameters)
     });
 }