コード例 #1
0
        public void init()
        {
            //Cria 12 estados
            newState("S0-Origem");
            newState("S1-Producao");
            newState("S2-Entrega");
            newState("S3-Transacion");

            //Define as transicoes
            ArrayList cond;

            //transicao S0 com S1
            cond = new ArrayList {
                Sensor.hu, Sensor.perto
            };
            addTransition(0, 1, cond, 0.5f);

            //transicao S1 com S1
            cond = new ArrayList {
                Sensor.hu, Sensor.perto
            };
            addTransition(1, 1, cond, 0.5f);

            //transicao S1 com S2
            cond = new ArrayList {
                Sensor.perto
            };
            addTransition(1, 2, cond, 0.5f);

            //transicao S2 com S2
            cond = new ArrayList {
                Sensor.longe
            };
            addTransition(0, 4, cond, 0.5f);

            //transicao S2 com S3
            cond = new ArrayList {
                Sensor.perto
            };
            addTransition(0, 8, cond, 0.5f);

            //transicao S3 com S0
            cond = new ArrayList {
                Sensor.ht, Sensor.longe
            };
            addTransition(1, 1, cond, 0.5f);

            distribuiProbabilidades();
            MarkovTemplate.showInternalMarkov();
        }
コード例 #2
0
        public void init()
        {
            //Cria 12 estados
            newState("S0-Repouso");
            newState("S1-MoveMate");
            newState("S2-MovePrey");
            newState("S3-Wander");
            newState("S4-Quer Mate");
            newState("S5-InteractM");
            newState("S6-InteractM");
            newState("S7-Mate");
            newState("S8-Quer Atacar");
            newState("S9-InteractA");
            newState("S10-InteractA");
            newState("S11-Ataca");
            newState("S12-Emergency");

            //Define as transicoes
            ArrayList cond;

            //transicao S0 com S1
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.longe
            };
            addTransition(0, 1, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.longe
            };
            addTransition(0, 1, cond, 0.5f);
            //transicao S0 com S2
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.longe
            };
            addTransition(0, 2, cond, 0.5f);
            cond = new ArrayList {
                Sensor.hu, Sensor.longe
            };
            addTransition(0, 2, cond, 0.5f);
            //transicao S0 com S3
            cond = new ArrayList {
                Sensor.ht, Sensor.longe
            };
            addTransition(0, 3, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.longe
            };
            addTransition(0, 3, cond, 0.5f);
            cond = new ArrayList {
                Sensor.hu, Sensor.longe
            };
            addTransition(0, 3, cond, 0.5f);
            cond = new ArrayList {
                Sensor.longe
            };
            addTransition(0, 3, cond, 0.5f);
            cond = new ArrayList {
                Sensor.perto
            };
            addTransition(0, 3, cond, 0.5f);
            //transicao S0 com S4
            cond = new ArrayList {
                Sensor.ht, Sensor.perto
            };
            addTransition(0, 4, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.perto
            };
            addTransition(0, 4, cond, 0.5f);
            //transicao S0 com S8
            cond = new ArrayList {
                Sensor.hu, Sensor.perto
            };
            addTransition(0, 8, cond, 0.5f);
            cond = new ArrayList {
                Sensor.hu, Sensor.ht, Sensor.perto
            };
            addTransition(0, 8, cond, 0.5f);
            //transicao S0 com S12
            cond = new ArrayList {
                Sensor.emergency
            };
            addTransition(0, 12, cond, 2);

            //transicao S1 com S1
            cond = new ArrayList {
                Sensor.ht, Sensor.longe
            };
            addTransition(1, 1, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.longe
            };
            addTransition(1, 1, cond, 0.5f);
            //transicao S1 com S2
            cond = new ArrayList {
                Sensor.hu, Sensor.longe
            };
            addTransition(1, 2, cond, 0.5f);
            //transicao S1 com S4
            cond = new ArrayList {
                Sensor.ht, Sensor.perto
            };
            addTransition(1, 4, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.perto
            };
            addTransition(1, 4, cond, 0.5f);
            //transicao S1 com S8
            cond = new ArrayList {
                Sensor.hu, Sensor.perto
            };
            addTransition(1, 8, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.perto
            };
            addTransition(1, 8, cond, 0.5f);
            //transicao S1 com S12
            cond = new ArrayList {
                Sensor.emergency
            };
            addTransition(3, 12, cond, 2);

            //transicao S2 com S1
            cond = new ArrayList {
                Sensor.ht, Sensor.longe
            };
            addTransition(2, 1, cond, 0.5f);
            //transicao S2 com S2
            cond = new ArrayList {
                Sensor.hu, Sensor.longe
            };
            addTransition(2, 2, cond, 0.5f);
            cond = new ArrayList {
                Sensor.hu, Sensor.ht, Sensor.longe
            };
            addTransition(2, 2, cond, 0.5f);
            //transicao S2 com S8
            cond = new ArrayList {
                Sensor.hu, Sensor.perto
            };
            addTransition(2, 8, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.perto
            };
            addTransition(2, 8, cond, 0.5f);
            //transicao S2 com S4
            cond = new ArrayList {
                Sensor.ht, Sensor.perto
            };
            addTransition(2, 4, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.perto
            };
            addTransition(2, 4, cond, 0.5f);


            //transicao S3 com S1
            cond = new ArrayList {
                Sensor.hu, Sensor.longe
            };
            addTransition(3, 1, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.longe
            };
            addTransition(3, 1, cond, 0.5f);
            //transicao S3 com S2
            cond = new ArrayList {
                Sensor.ht, Sensor.longe
            };
            addTransition(3, 2, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.longe
            };
            addTransition(3, 2, cond, 0.5f);
            //transicao S3 com S3
            cond = new ArrayList {
                Sensor.ht, Sensor.longe
            };
            addTransition(3, 3, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.longe
            };
            addTransition(3, 3, cond, 0.5f);
            cond = new ArrayList {
                Sensor.hu, Sensor.longe
            };
            addTransition(3, 3, cond, 0.5f);
            cond = new ArrayList {
                Sensor.longe
            };
            addTransition(3, 3, cond, 0.5f);
            cond = new ArrayList {
                Sensor.perto
            };
            addTransition(3, 3, cond, 0.5f);
            //transicao S3 com S4
            cond = new ArrayList {
                Sensor.ht, Sensor.perto
            };
            addTransition(3, 4, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.perto
            };
            addTransition(3, 4, cond, 0.5f);
            //transicao S3 com S8
            cond = new ArrayList {
                Sensor.hu, Sensor.perto
            };
            addTransition(3, 8, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.perto
            };
            addTransition(3, 8, cond, 0.5f);
            //transicao S3 com S12
            cond = new ArrayList {
                Sensor.emergency
            };
            addTransition(3, 12, cond, 2);

            //transicao S4 com S1
            cond = new ArrayList {
                Sensor.ht, Sensor.longe
            };
            addTransition(4, 1, cond, 0.5f);
            //transicao S4 com S2
            cond = new ArrayList {
                Sensor.hu, Sensor.longe
            };
            addTransition(4, 2, cond, 0.5f);
            //transicao S4 com S5
            cond = new ArrayList {
                Sensor.ht, Sensor.perto, Sensor.conhecido
            };
            addTransition(4, 5, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.perto, Sensor.conhecido
            };
            addTransition(4, 5, cond, 0.5f);
            //transicao S4 com S6
            cond = new ArrayList {
                Sensor.ht, Sensor.perto, Sensor.desconhecido
            };
            addTransition(4, 6, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.perto, Sensor.conhecido
            };
            addTransition(4, 5, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.perto, Sensor.desconhecido
            };
            addTransition(4, 6, cond, 0.5f);
            cond = new ArrayList {
                Sensor.ht, Sensor.hu, Sensor.perto, Sensor.conhecido
            };
            addTransition(4, 5, cond, 0.5f);
            cond = new ArrayList {
                Sensor.hu, Sensor.perto
            };
            addTransition(4, 8, cond, 0.5f);
            cond = new ArrayList {
                Sensor.hu, Sensor.ht, Sensor.perto
            };
            addTransition(4, 8, cond, 0.5f);
            //transicao S4 com S12
            cond = new ArrayList {
                Sensor.emergency
            };
            addTransition(4, 12, cond, 2);

            //transicao S5 com S3
            cond = new ArrayList {
                Sensor.n_interact
            };
            addTransition(5, 3, cond, 0.5f);
            cond = new ArrayList {
                Sensor.emergency
            };
            addTransition(5, 12, cond, 2);
            //transicao S5 com S7
            cond = new ArrayList {
                Sensor.interact
            };
            addTransition(5, 7, cond, 0.5f);

            //transicao S6 com S3
            cond = new ArrayList {
                Sensor.n_interact
            };
            addTransition(6, 3, cond, 0.5f);
            cond = new ArrayList {
                Sensor.emergency
            };
            addTransition(6, 12, cond, 2);
            cond = new ArrayList {
                Sensor.interact
            };
            addTransition(6, 7, cond, 0.5f);

            //transicao S7 com S3
            cond = new ArrayList {
                Sensor.n_interact
            };
            addTransition(7, 3, cond, 0.5f);//transicao S6 com S7


            //transicao S8 com S2
            cond = new ArrayList {
                Sensor.hu, Sensor.longe
            };
            addTransition(8, 2, cond, 0.5f);
            cond = new ArrayList {
                Sensor.emergency
            };
            addTransition(8, 12, cond, 2);
            //transicao S8 com S9
            cond = new ArrayList {
                Sensor.hu, Sensor.conhecido
            };
            addTransition(8, 9, cond, 0.5f);
            //transicao S8 com S10
            cond = new ArrayList {
                Sensor.hu, Sensor.desconhecido
            };
            addTransition(8, 10, cond, 0.5f);
            //transicao S8 com S4
            cond = new ArrayList {
                Sensor.ht, Sensor.perto
            };
            addTransition(8, 4, cond, 0.5f);

            //transicao S9 com S3
            cond = new ArrayList {
                Sensor.n_interact
            };
            addTransition(9, 3, cond, 0.5f);
            //transicao S9 com S11
            cond = new ArrayList {
                Sensor.interact
            };
            addTransition(9, 11, cond, 0.5f);
            cond = new ArrayList {
                Sensor.emergency
            };
            addTransition(9, 12, cond, 2);

            //transicao S10 com S3
            cond = new ArrayList {
                Sensor.n_interact
            };
            addTransition(10, 3, cond, 0.5f);
            //transicao S10 com S11
            cond = new ArrayList {
                Sensor.interact
            };
            addTransition(10, 11, cond, 0.5f);
            cond = new ArrayList {
                Sensor.emergency
            };
            addTransition(10, 12, cond, 2);

            //transicao S11 com S3
            cond = new ArrayList {
                Sensor.n_interact
            };
            addTransition(11, 3, cond, 0.5f);
            cond = new ArrayList {
                Sensor.emergency
            };
            addTransition(12, 12, cond, 2);

            distribuiProbabilidades();
#if ShowInternalMarkov
            MarkovTemplate.showInternalMarkov();
#endif
        }