public DiscernibilityMatrix(DecisionSystem ds,IEnumerable<int> reduct, double ruleValue)
 {
     var sa = new StandardApproximationSpace(ds, reduct);
     RuleValue = ruleValue;
     var columns = sa.LowerApproximation(RuleValue);
     //so sánh với các phần tử không thuộc lower approximation
     var rows =
         ds.Universe.Where(p => columns.All(p2 => p2[0] != p[0])).Where(p => p[ds.DecisionAttributes[0]] != RuleValue);
     Matrix = new List<List<List<pairID>>>();
     foreach (var column in columns)
     {
         var dataRow = new List<List<pairID>>();
         foreach (var row in rows)
         {
             var dataInstances = new List<pairID>();
             foreach (var header in reduct)
             {
                 if (row[header] != column[header])
                 {
                     dataInstances.Add(new pairID(header, int.Parse(column[header].ToString())));
                 }
             }
             if(dataInstances.Count!=0)
                 dataRow.Add(dataInstances);
         }
         if(dataRow.Count!=0)
         Matrix.Add(dataRow);
     }
 }
Exemplo n.º 2
0
 public ReductProcessor(DecisionSystem _deciSystem)
 {
     DS = _deciSystem;
     Results = new List<HashSet<int>>();
     Process();
     MinimalReducts = GetMinimalReducts();
     CoreAttrs = GetCoreAttrs();
 }
Exemplo n.º 3
0
 public void ResetDecisions()
 {
     if (decisionName != null)
     {
         DecisionSystem decisionOff = GameObject.Find(decisionName).GetComponent <DecisionSystem>();
         decisionOff.ResetDecision();
         decisionOff = null;
     }
 }
Exemplo n.º 4
0
 public Rules(DecisionSystem ds,IEnumerable<int> reduct)
 {
     var data = new List<double>(ds.AttributesDomain[ds.DecisionAttribute]);
     DiscernMatrix = new List<DiscernibilityMatrix>();
     foreach (var m in data.Select(d => reduct != null ? new DiscernibilityMatrix(ds, reduct, d) : new DiscernibilityMatrix(ds, ds.ConditionAttributes, d)))
     {
         m.GenerateRules();
         DiscernMatrix.Add(m);
     }
 }
Exemplo n.º 5
0
 public void SendVote()
 {
     if (localPlayer.decisionName != null)
     {
         Debug.Log("Sending my Vote");
         DecisionSystem actualDecision = GameObject.Find(localPlayer.decisionName).GetComponent <DecisionSystem>();
         actualDecision.Vote(actualDecision.choices[currentChoice[localPlayer.playerId].Value]);
         currentChoice = null;
     }
     else
     {
         ActivateNPCFeedback("Debes elegir una opción antes de votar...");
     }
 }
Exemplo n.º 6
0
    //The function that handles the initialization-step of the Learning system.
    void InitializeAgent()
    {
        //Initialize the objects needed in the system's loop and put reference to this class where necessary.
        perception = gameObject.GetComponentInChildren<Perception>();
        perception.agentController = this;
        perception.InitializePerception();
        learn = new Learn();
        learn.agentController = this;
        decisionSystem = new DecisionSystem();
        decisionSystem.agentController = this;

        //Find the actions defined in the Actions child of the agent and put them in a list for referencing.
        actions = transform.FindChild("Actions").gameObject.GetComponents<BasicAction>().ToList();
        // initializes the agentcontroller in each action
        actions.ForEach(a => a.agentController = this);
    }
    private void HandlePlayerVote(string[] msg)
    {
        if (NotInClientScene())
        {
            int playerId = Int32.Parse(msg[1]);
            DecisionSystem.Choice choice = (DecisionSystem.Choice)Enum.Parse(typeof(DecisionSystem.Choice), msg[2]);

            LevelManager levelManager = GameObject.FindObjectOfType <LevelManager>();
            string       decisionName = levelManager.localPlayer.decisionName;
            if (decisionName != null)
            {
                DecisionSystem currentDecision = GameObject.Find(decisionName).GetComponent <DecisionSystem>();
                currentDecision.ReceiveVote(playerId, choice);
            }
        }
    }
Exemplo n.º 8
0
    public void SendPreVote()
    {
        DecisionSystem actualDecision = GameObject.Find(localPlayer.decisionName).GetComponent <DecisionSystem>();

        actualDecision.SendPreVote(currentChoice[localPlayer.playerId].Value);
    }
 public QuickReductProcessor(DecisionSystem _deciSystem)
     : base(_deciSystem)
 {
 }
Exemplo n.º 10
0
 public Pair(double?[] dtr1, double?[] dtr2, DecisionSystem ds,int idIndex,List<Discretization> DisList)
 {
     dataList = new List<bool>();
     data = new List<List<bool>>();
     rawdata = "";
     for (var i = 0; i < dtr1.Count(); i++)
     {
         var tempData = new List<bool>();
         if (i == idIndex)
         {
             id1 = dtr1[i].ToString();
             id2 = dtr2[i].ToString();
             continue;
         }
         if (i == ds.DecisionAttributes.ElementAt(0)) continue;
         var location = -1;
         int min, max;
         var bmin = int.TryParse(dtr1[i].ToString(), out min);
         if (!bmin) min = 0;
         var bmax = int.TryParse(dtr2[i].ToString(), out max);
         if (!bmax) max = 0;
         if (min > max)
         {
             var temp = min;
             min = max;
             max = temp;
         }
         for (var j = 0; j < DisList.Count(); j++)
         {
             if (j == i - 1) //current attribute
             {
                 rawdata += new string('0', DisList[j].MappedTable.Count);
                 for (var k = 0; k < DisList[j].MappedTable.Count; k++)
                 {
                     location++;
                     if (DisList[j].IsDiscreted)
                     {
                         if (dtr1[i].ToString() == dtr2[i].ToString())
                         {
                             tempData.Add(false);
                             dataList.Add(false);
                             continue;
                         }
                         var sb = new StringBuilder(rawdata);
                         sb[location] = '1';
                         rawdata = sb.ToString();
                         tempData.Add(true);
                         dataList.Add(true);
                         continue;
                     }
                     if (min <= k)
                     {
                         if (k >= max)
                         {
                             tempData.Add(false);
                             dataList.Add(false);
                             continue;
                         }
                         var sb = new StringBuilder(rawdata);
                         sb[location] = '1';
                         rawdata = sb.ToString();
                         tempData.Add(true);
                         dataList.Add(true);
                     }
                     else
                     {
                         tempData.Add(false);
                         dataList.Add(false);
                     }
                 }
             }
             if (j < i - 1)
             {
                 location += DisList[j].MappedTable.Count;
                 //skip
             }
             else
             {
                 break;
             }
         }
         data.Add(tempData);
     }
 }
Exemplo n.º 11
0
        private void Numericalization(object[][] originalUniverse, int idIndex, int[] conditionAttributes,int[] decisionAttributes)
        {
            ds=new DecisionSystem {ConditionAttributes = new int[conditionAttributes.Count()]};
            Array.Copy(conditionAttributes,ds.ConditionAttributes,conditionAttributes.Count());
            ds.DecisionAttributes = new int[decisionAttributes.Count()]; Array.Copy(decisionAttributes, ds.DecisionAttributes, decisionAttributes.Count());
            ds.Universe=new double?[originalUniverse.Count()][];
            ConditionList = new List<Discretization>();
            DecisionList = new List<Discretization>();
            var nCondition = 0;
            for (var i = 0; i < originalUniverse.Count(); i++)
            {
                ds.Universe[i] = new double?[originalUniverse[0].Count()];
                ds.Universe[i][idIndex] = double.Parse(originalUniverse[i][idIndex].ToString());
            }
            for (var i = 0; i < originalUniverse[0].Count(); i++)
            {

                if (i == idIndex)
                {
                    continue;
                }
                var column = (from row in originalUniverse.AsEnumerable()
                              select row[i]).ToList();
                Discretization dis;
                if (i == decisionAttributes[0])
                {
                    dis = new Discretization(column, ds.DecisionAttributes[0], true);
                    DecisionList.Add(dis);
                }
                else
                {
                    dis = new Discretization(column, ds.ConditionAttributes[nCondition]);
                    ConditionList.Add(dis);
                    nCondition++;
                }
                for (var j = 0; j < originalUniverse.Count(); j++)
                {

                    //ds.Universe[j][i] = double.Parse(OriginalUniverse[j][i]);
                    ds.Universe[j][i] = dis.Data[j];
                }
            }
            UpdateAttributeDomain(idIndex);
        }
Exemplo n.º 12
0
 private IEnumerable<double> GetDecisionValues(DecisionSystem des)
 {
     return (from row in des.Universe.AsEnumerable()
        select double.Parse(row[des.DecisionAttributes[0]].ToString())).Distinct().ToList();
 }