Exemplo n.º 1
0
        public void GerarTeste(Teste teste, Materia materia, Questao questao)
        {
            try
            {
                IList <Questao> questaoList = questaoDAO.GetAllRandom(teste, materia, questao);

                if (teste.QuantidadeQuestoes > questaoList.Count)
                {
                    throw new Exception("A quantidade de questões do " + questao.Bimestre + " e na Matéria " + materia.Nome + " é de " + questaoList.Count);
                }
                else
                {
                    if (questaoList.Count < 1)
                    {
                        throw new Exception("Não há nenhuma questão cadastrada nesse Bimestre e nessa matéria");
                    }
                    else
                    {
                        int testeID = testeDAO.AdicionarTBTestes(teste);
                        teste.ID = testeID;

                        foreach (var item in questaoList)
                        {
                            testeDAO.AdicionarTBTestes_Questoes(Convert.ToInt32(item.ID), testeID);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 2
0
 public async Task <IEnumerable <Order> > GetOrders(
     Teste teste,
     CancellationToken cancellationToken)
 {
     return(await Task.FromResult(new List <Order>
     {
         new Order
         {
             Total = 50m,
             Date = DateTime.Now,
             Items = new List <Item>
             {
                 new Item
                 {
                     Product = new Product
                     {
                         Name = "Produto Teste"
                     },
                     Quantity = 1,
                     UnitCost = 43
                 }
             }
         }
     }.AsEnumerable()));
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            ValidateEchipa       validateEchipa       = new ValidateEchipa();
            ValidateElev         validateElev         = new ValidateElev();
            ValidateJucator      validateJucator      = new ValidateJucator();
            ValidateMeci         validateMeci         = new ValidateMeci();
            ValidateJucatorActiv validateJucatorActiv = new ValidateJucatorActiv();

            EchipaRepository       echipaRepository       = new EchipaRepository(validateEchipa, "C:\\Users\\pc\\source\\repos\\Lab9\\Lab9\\files\\echipe.txt", new InFileRepository <int, Echipa> .CreateEntityFromString(CreateEchipaFromString));
            ElevRepository         elevRepository         = new ElevRepository(validateElev, "C:\\Users\\pc\\source\\repos\\Lab9\\Lab9\\files\\elevi.txt", new InFileRepository <int, Elev> .CreateEntityFromString(CreateElevFromString));
            JucatorRepository      jucatorRepository      = new JucatorRepository(validateJucator, "C:\\Users\\pc\\source\\repos\\Lab9\\Lab9\\files\\jucatori.txt", new InFileRepository <int, Jucator> .CreateEntityFromString(CreateJucatorFromString));
            MeciRepository         meciRepository         = new MeciRepository(validateMeci, "C:\\Users\\pc\\source\\repos\\Lab9\\Lab9\\files\\meciuri.txt", new InFileRepository <int, Meci> .CreateEntityFromString(CreateMeciFromString));
            JucatorActivRepository jucatorActivRepository = new JucatorActivRepository(validateJucatorActiv, "C:\\Users\\pc\\source\\repos\\Lab9\\Lab9\\files\\jucatoriActivi.txt", new InFileRepository <int, JucatorActiv> .CreateEntityFromString(CreateJucatorActivFromString));

            EchipaService       echipaService       = new EchipaService(echipaRepository);
            ElevService         elevService         = new ElevService(elevRepository);
            JucatorService      jucatorService      = new JucatorService(jucatorRepository);
            MeciService         meciService         = new MeciService(meciRepository);
            JucatorActivService jucatorActivService = new JucatorActivService(jucatorActivRepository);


            Teste.RunTests(echipaService, elevService, jucatorActivService, jucatorService, meciService);

            Consola consola = new Consola(echipaService, elevService, jucatorService, meciService, jucatorActivService);

            consola.run();
        }
Exemplo n.º 4
0
    protected void btnSalvar_Click(object sender, EventArgs e)
    {
        var Teste = new Teste();

        try
        {
            if (txtId.Text != "")
            {
                Teste.IDTeste = int.Parse(txtId.Text);
                Teste.Get();
            }

            Teste.Descricao = txtDescricao.Text;
            Teste.Oliveira  = txtOliveira.Text;
            Teste.Assi      = int.Parse(txtAssi.Text);

            Teste.Save();
            GetTeste((int)Teste.IDTeste);

            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('Registro salvo.')</script>");
        }
        catch (Exception err)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>");
        }
    }
Exemplo n.º 5
0
        public IHttpActionResult PutTeste(int id, Teste teste)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != teste.Id)
            {
                return(BadRequest("O Id informado na URL é diferente do código do teste"));
            }

            if (db.Testes.Count(t => t.Id == teste.Id) == 0)
            {
                return(NotFound());
            }

            //db.Entry(teste).State = System.Data.Entity.EntityState.Modified;

            Teste testeOriginal = db.Testes.Find(id);

            db.Entry(testeOriginal).CurrentValues.SetValues(teste);

            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 6
0
        public List <Teste> GetAllData()
        {
            List <Teste> testeList = new List <Teste>();

            try
            {
                querry = new SqlCommand("select * from teste", con.getConection());
                SqlDataReader dr = querry.ExecuteReader();
                while (dr.Read())
                {
                    Teste testModel = new Teste();
                    for (int i = 0; i < dr.FieldCount; i++)
                    {
                        testModel.Id   = (int)dr.GetValue(0);
                        testModel.Nome = dr.GetValue(1).ToString();
                    }
                    testeList.Add(testModel);
                }

                dr.Close();
                dr.Dispose();
                querry.Dispose();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            finally
            {
                con.closeConnection();
            }

            return(testeList);
        }
Exemplo n.º 7
0
    public static void Main()
    {
        var teste = new Teste(1, "abc");

        WriteLine(teste.Numero);
        WriteLine(teste.Texto);
    }
Exemplo n.º 8
0
        public ActionResult Create(FormCollection dadosTeste)
        {
            //Verifica cada dado introduzido pelo utilizador por inconsistências (se os campos estão preenchidos, se os campos são válidos, etc.)
            if (string.IsNullOrEmpty(dadosTeste["nome"]) == true)
            {
                ModelState.AddModelError("nome", "Tem de introduzir o nome para o teste!");
            }

            //Se os dados introduzidos estiverem válidos, cria e insere um novo teste na base de dados
            if (ModelState.IsValid == true)
            {
                Teste newTeste = new Teste();

                newTeste.nome      = dadosTeste["nome"];
                newTeste.idTecnica = 1;

                newTeste.idUtilizador   = Convert.ToInt32(Session["idUtilizadorAutenticado"]);
                newTeste.dataRealizacao = DateTime.Now;

                db.Testes.InsertOnSubmit(newTeste);

                db.SubmitChanges();

                return(RedirectToAction("PerformTeste", new { id = newTeste.idTeste }));
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 9
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            //int idT;
            int    id   = Convert.ToInt32(etId.Text);
            string desc = descricaoet.Text;

            DataService dataService = new DataService();

            if (!string.IsNullOrEmpty(etId.Text) && !string.IsNullOrEmpty(desc))
            {
                try
                {
                    Teste teste;
                    teste = new Teste(id, desc);

                    // await dataService.PostAsync(teste);

                    // idVerifica.Text = etId.Text + " - " + desc;
                }
                catch (Exception ex)
                {
                    if (ex.Source != null)
                    {
                        await DisplayAlert("Erro", ex.Message, "OK");

                        // Console.WriteLine("Exception source: {0}", ex.Source);
                    }
                    throw;
                }
            }
            else
            {
                await DisplayAlert("Erro", "Dados inválidos...", "OK");
            }
        }
Exemplo n.º 10
0
        public override void Adicionar()
        {
            CadastroTeste dialogTeste = new CadastroTeste();

            DialogResult resultado = dialogTeste.ShowDialog();

            if (resultado == DialogResult.OK)
            {
                try
                {
                    SaveFileDialog saveFileDialog1 = new SaveFileDialog();

                    saveFileDialog1.Filter           = "PDF File |*.pdf";
                    saveFileDialog1.FilterIndex      = 2;
                    saveFileDialog1.RestoreDirectory = true;

                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        string path = saveFileDialog1.FileName;

                        Teste testeAdicionado = dialogTeste.Teste;
                        IOCService.TesteService.Adicionar(testeAdicionado);
                        IOCService.TesteService.ExportarPDF(testeAdicionado, path);
                        MessageBox.Show("Teste gerado com sucesso");
                        System.Diagnostics.Process.Start(path);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            }

            AtualizarListagem();
        }
Exemplo n.º 11
0
        public override void Excluir()
        {
            Teste testeSelecionadaNoListBox = IOCuserControl.TesteControl.retornaTesteSelecionadaNoListBox();

            try
            {
                DialogResult resultado = MessageBox.Show("Deseja excluir o teste: " + Convert.ToString(testeSelecionadaNoListBox.Nome) + "?", "Atenção", MessageBoxButtons.YesNo);

                if (DialogResult.Yes == resultado)
                {
                    IOCService.TesteService.Excluir(testeSelecionadaNoListBox);
                    MessageBox.Show("Teste excluído com sucesso");
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }

            ControleDeReferencia.ReferenciaFormularioPrincipal.btnExcluir.Enabled       = _buttonsEnable.btnExcluir;
            ControleDeReferencia.ReferenciaFormularioPrincipal.btnExportarTeste.Enabled = _buttonsEnable.btnExportar;
            ControleDeReferencia.ReferenciaFormularioPrincipal.btnGerarGabarito.Enabled = _buttonsEnable.btnGerarGabarito;

            AtualizarListagem();
        }
Exemplo n.º 12
0
        private void btnGerarTeste_Click(object sender, EventArgs e)
        {
            var materia = new Materia();
            var questao = new Questao();
            var teste   = new Teste();

            try
            {
                VerificaCampos();
                materia.Nome             = cmbMateria.SelectedItem.ToString();
                questao.Bimestre         = cmbBimestre.SelectedItem.ToString();
                teste.QuantidadeQuestoes = Convert.ToInt32(quantidadeQuestoes.Value);
                teste.dataGeracao        = DateTime.Now;
                teste.Descricao          = "Descrição";
                teste.listaQuestao       = _questoesServico.GetAllRandom(teste, materia, questao);

                _testeServico.GerarTeste(teste, materia, questao);

                MessageBox.Show("Adicionado com sucesso", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                DialogResult = DialogResult.None;

                MessageBox.Show(ex.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 13
0
        public void GerarGabarito()
        {
            Teste testeSelecionadaNoListBox = IOCuserControl.TesteControl.retornaTesteSelecionadaNoListBox();

            try
            {
                SaveFileDialog saveFileDialog1 = new SaveFileDialog();

                saveFileDialog1.Filter           = "PDF File |*.pdf";
                saveFileDialog1.FilterIndex      = 2;
                saveFileDialog1.RestoreDirectory = true;

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string path = saveFileDialog1.FileName;
                    IOCService.TesteService.GerarPDFGabarito(testeSelecionadaNoListBox, path);
                    MessageBox.Show("Gabarito do teste: " + testeSelecionadaNoListBox.Nome + " gerado!");
                    System.Diagnostics.Process.Start(path);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            DefinirEnableButtons(ObtemEnableButtons());
            AtualizarListagem();
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Idade,Apelido")] Teste teste)
        {
            if (id != teste.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teste);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TesteExists(teste.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(teste));
        }
Exemplo n.º 15
0
        private void conferir_teste(string url)
        {
            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(url);
                client.DefaultRequestHeaders
                .Accept
                .Add(new MediaTypeWithQualityHeaderValue("application/json"));      //ACCEPT header

                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "");
                request.Headers.Authorization =
                    new AuthenticationHeaderValue(
                        "Basic",
                        Convert.ToBase64String(
                            System.Text.ASCIIEncoding.ASCII.GetBytes(
                                string.Format("{0}:{1}", configuracao.Usuario, configuracao.Senha))));

                client.SendAsync(request)
                .ContinueWith(responseTask =>
                {
                    HttpResponseMessage resposta = responseTask.Result;
                    string json = resposta.Content.ReadAsStringAsync().Result;
                    Teste teste = JsonConvert.DeserializeObject <Teste>(json);
                    BeginInvoke(new MyDelegate2(DelegateMethod2), teste);
                });
            }
            catch
            {
            }
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            Teste t = new Teste();

            t.teste();
            Console.ReadKey();
        }
Exemplo n.º 17
0
 public IList <Questao> ObterQuestoesTeste(Teste teste)
 {
     return(base.ConsultarLista(sqlGetAllQuestoesPorTesteId, TuplaParaEntidade, new Dictionary <String, Object>()
     {
         { "Id", teste.Id }
     }));
 }
Exemplo n.º 18
0
        public void Postar(int idUsuario, string descricao, String inicio, string termino, int acertos, int erros)
        {
            Context.Response.Clear();
            using (var context = new Context())
            {
                var usuario = context.DbUsuarios.Where(u => u.IdUsuario.Equals(idUsuario)).FirstOrDefault();
                if (usuario != null)
                {
                    var testeNew = new Teste
                    {
                        IdUsuario = idUsuario,
                        Descricao = descricao,
                        Inicio    = Convert.ToDateTime(inicio),
                        Termino   = Convert.ToDateTime(termino),
                        Acertos   = acertos,
                        Erros     = erros,
                    };
                    context.Set <Teste>().Add(testeNew);
                    context.SaveChanges();

                    Context.Response.Write(testeNew.IdTeste);
                }
                else
                {
                    throw new Exception("Usuario não encontrado na base de dados!");
                }
            };
        }
Exemplo n.º 19
0
        public async Task <PadraoResponse <Teste> > PutTeste(Teste model)
        {
            PadraoResponse <Teste> response = new PadraoResponse <Teste>();

            if (model.Id == Guid.Empty)
            {
                throw new Exception("O CAMPO Id é obrigatório!");
            }

            Teste modelCadastrado = await _unitOfWork.TesteRepository.GetUm(e => e.Id == model.Id);

            if (modelCadastrado is null)
            {
                throw new Exception("Manda o Id certo bobão!");
            }

            modelCadastrado.Nome = model.Nome;

            modelCadastrado.AtualizarRegistro();
            _unitOfWork.TesteRepository.Atualizar(modelCadastrado);

            await _unitOfWork.CommitAsync();

            response.Data = modelCadastrado;
            return(response);
        }
Exemplo n.º 20
0
        public IHttpActionResult PutTeste(int id, Teste teste)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != teste.Id)
            {
                return(BadRequest());
            }

            db.Entry(teste).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TesteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 21
0
    protected void btnSalvar_Click(object sender, EventArgs e)
    {
        var Teste = new Teste();
        try
        {
            if (txtId.Text != "")
            {
                Teste.IDTeste = int.Parse(txtId.Text);
                Teste.Get();
            }

            Teste.Descricao = txtDescricao.Text;
        Teste.Oliveira = txtOliveira.Text;
        Teste.Assi = int.Parse(txtAssi.Text);

            Teste.Save();
            GetTeste((int)Teste.IDTeste);

            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('Registro salvo.')</script>");
        }
        catch (Exception err)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>");
        }
    }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            var ctx = new Model();

            Teste t1 = new Teste()
            {
                Nome = "Everaldo", Idade = 31
            };
            Teste t2 = new Teste()
            {
                Nome = "Ana", Idade = 27
            };


            ctx.Teste.Add(t1);
            ctx.Teste.Add(t2);

            ctx.SaveChanges();

            var dados = from t in ctx.Teste
                        select t;

            foreach (var l in dados)
            {
                Console.WriteLine("{0} - {1}", l.Nome, l.Idade);
            }
            Console.ReadKey();
        }
Exemplo n.º 23
0
 public static bool RegistrarTesteEscopoEstaValido(this Teste teste)
 {
     return(AssertionConcern.IsSatisfiedBy
            (
                AssertionConcern.AssertNotEmpty(teste.Tester, "O tester é obrigatório"),
                AssertionConcern.AssertNotEmpty(teste.Role, "O perfil é obrigatório")
            ));
 }
Exemplo n.º 24
0
        private static Teste ConverterId(IDataReader _reader)
        {
            Teste teste = new Teste();

            teste.Id = Convert.ToInt32(_reader["Id"]);

            return(teste);
        }
Exemplo n.º 25
0
        public IList <Questao> GetAllRandom(Teste teste, Materia materia, Questao questao)
        {
            Dictionary <string, object> parms = new Dictionary <string, object> {
                { "Quantidade", teste.QuantidadeQuestoes }, { "MateriaNome", materia.Nome }, { "Bimestre", questao.Bimestre }
            };

            return(Db.GetAll(_sqlSelectAllRandom, Make, parms));
        }
Exemplo n.º 26
0
 public UtilsTest()
 {
     teste = new Teste()
     {
         id        = 1,
         descricao = "teste"
     };
 }
Exemplo n.º 27
0
    public static void TesteChave()
    {
        Teste.inicializaTeste();
        String chave = Dao.gerarChaveUsuario();

        Teste.respostaTeste();
        Teste.debug += "|Chave: " + chave;
    }
        public ActionResult DeleteConfirmed(int id)
        {
            Teste teste = db.Teste.Find(id);

            db.Teste.Remove(teste);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 29
0
        public IList <Teste> GetTestes(Teste teste)
        {
            Dictionary <string, object> parms = new Dictionary <string, object> {
                { "Bimestre", teste.listaQuestao[0].Bimestre }, { "MateriaID", teste.listaQuestao[0].materia.ID }
            };

            return(Db.GetAll(_sqlGetAllQuestoes, MakeTesteQuestoes, parms));
        }
Exemplo n.º 30
0
        public IList <Questao> GetQuestoes(Teste teste)
        {
            Dictionary <string, object> parms = new Dictionary <string, object> {
                { "TesteID", teste.ID }
            };

            return(Db.GetAll <Questao>(_sqlSelectQuestoes, MakeQuestoes, parms));
        }
Exemplo n.º 31
0
    public override void OnInspectorGUI()
    {
        Teste myTeste = (Teste)this.target;

        this.enableGroup = EditorGUILayout.BeginToggleGroup("ints", this.enableGroup);
        myTeste.b        = EditorGUILayout.Slider(myTeste.b, 0f, 10f);
        EditorGUILayout.EndToggleGroup();
    }
Exemplo n.º 32
0
 protected void DeleteTeste(int idTeste)
 {
     try
     {
         var Teste = new Teste();
         Teste.IDTeste = idTeste;
         Teste.Delete();
         GetTestes();
     }
     catch (Exception err)
     {
         Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>");
     }
 }
Exemplo n.º 33
0
        public static List<Resultado> BateriaDeTestes(List<Dados> nDados, Teste t, int repetições)
        {
            List<Resultado> resultFinal = new List<Resultado>();

            while(repetições > 0)
            {
                foreach(Dados d in nDados){
                    d.ReSeedDados(t.seed, t.folds);
                }

                 Console.WriteLine("Faltam " + repetições.ToString() + "repetições");
                //realiza o teste para cada 'fold'
                resultFinal.Add(ExecutaTeste(nDados,t));

                t.seed++;
                repetições--;
            }
            return resultFinal;
        }
Exemplo n.º 34
0
    void Main()
    {
        if (a == b) {
            a++;
        } else if (a == 1) {
            a = a * b;
        } else {
            b--;
        }

        while (a < b) {
            b = a + 1;
        }

        for (int i = 0; i < 5; i++) {
            boolean entrou = true;
        }

        foreach (int i in lista) {
            do {
                a = new Teste();
            } while (i != b);
        }
    }
Exemplo n.º 35
0
        public static Resultado ExecutaTeste(List<Dados> grupos, Teste nTeste)
        {
            Resultado resultado = new Resultado(nTeste);

            for (int fold = 0; fold < nTeste.folds; fold++)
            {
                List<List<Vector>> dadosTreino = new List<List<Vector>>();
                List<List<Vector>> dadosTeste = new List<List<Vector>>();

                //DEBUG Console.WriteLine(" - Iniciando fold " + fold.ToString());
                for (int i = 0; i < grupos.Count; i++)
                {
                    dadosTreino.Add(grupos[i].GetKFoldTreino(nTeste.folds, fold));
                    dadosTeste.Add(grupos[i].GetKFoldTeste(nTeste.folds, fold));
                }

                List<BoundingVolume> caixas = new List<BoundingVolume>();

                //Aqui Seleciona o tipo de bounding volume
                for (int i = 0; i < grupos.Count; i++)
                {
                    if (nTeste.BV == 2){
                        caixas.Add(new OBB(dadosTreino[i], Convert.ToInt32 (Math.Pow (2,i)),0));
                    }
                    if (nTeste.BV == 1){
                        //caixas.Add(new AABB(dadosTreino[i], "-" + i.ToString() + "-",0));
                    }
                    if (nTeste.BV == 0){
                        caixas.Add(new Sphere(dadosTreino[i], Convert.ToInt32 (Math.Pow (2,i)),0));
                    }

                }

                TesteColisao teste = new TesteColisao(nTeste);

                teste.RealizaTeste(caixas);

                 Console.WriteLine(" - Iniciando testes");

                result result = new result();
                foreach (BoundingVolume c in caixas)
                {
                    result.profundidadeMaxima = Math.Max(result.profundidadeMaxima, c.MaxProfundidade());
                }

                foreach (PreRedeNeural p in teste.PRN)
                {
                    result.planos += p.planos.Count;
                    result.padroes += p.padDentro.RowCount;
                    result.padroes += p.padFora.RowCount;
                }

                 Console.WriteLine(" - Gerando Redes " + fold.ToString());
                List<Rede> redes = GeraRedesNeurais(teste.PRN, nTeste);

                 Console.WriteLine(" - Pontos de treino " + fold.ToString());
                TestaPontos(caixas, redes, nTeste, out result.treinoCertos, out result.treinoErrados);

                 Console.WriteLine(" - Pontos de teste " + fold.ToString());

                if (dadosTeste.Count == dadosTreino.Count)
                {
                    caixas.Clear();
                    for (int i = 0; i < grupos.Count; i++)
                    {
                        caixas.Add(new BoundingVolume(dadosTeste[i], Convert.ToInt32 (Math.Pow (2,i)),0));
                    }
                    TestaPontos(caixas, redes,nTeste, out result.testeCertos, out result.testeErrados);
                }
                resultado.resultados.Add (result);
            }
            return resultado;
        }
Exemplo n.º 36
0
    private void GetTeste(int idTeste)
    {
        dvSalvarTeste.Visible = true;
        dvListarTestes.Visible = false;

        var Teste = new Teste();
        Teste.IDTeste = idTeste;
        Teste.Get();

        txtId.Text = Teste.IDTeste.ToString();
        txtDescricao.Text = Teste.Descricao.ToString();
        txtOliveira.Text = Teste.Oliveira.ToString();
        txtAssi.Text = Teste.Assi.ToString();
    }
Exemplo n.º 37
0
        public static List<Rede> GeraRedesNeurais(List<PreRedeNeural> preRede,Teste nTeste)
        {
            Rede.FAtivação[] fs;
            if (nTeste.Bounds)
            {
             	fs = new Rede.FAtivação[2] { F1Bounds, F2 };
            }
            else
            {
                fs = new Rede.FAtivação[2] { F1, F2 };
            }
            List<Rede> r = new List<Rede>();

            foreach (PreRedeNeural prn in preRede)
            {
                r.Add(prn.GerarRedeNeural(fs));
            }
            return r;
        }
Exemplo n.º 38
0
        public static void TestaPontos(List<BoundingVolume> caixas, List<Rede> redes, Teste tipo, out int correto, out int errado)
        {
            correto=0;
            errado=0;
            if (!tipo.Voto)
            {
                //teste para a caixa "ncaixa"
                for (int nCaixa = 0; nCaixa < caixas.Count; nCaixa++)
                {
                    //teste para o ponto "i"
                    for (int i = 0; i < caixas[nCaixa].QntdDados; i++)
                    {

                        double[] ponto = caixas[nCaixa].Pontos[i].CopyToArray();

                        double max = double.NegativeInfinity;
                        int maxNeuronio = -1;
                        int maxRede = -1;
                        int voto = 0;

                        //Acha valor maximo entre os neurônios de saída
                        for (int nRede = 0; nRede < redes.Count; nRede++)
                        {
                            double[] respostas = redes[nRede].CalculaSaída(ponto);
                            //achar o neuronio com maior valor para cada rede
                            for (int nResp = 0; nResp < respostas.Length; nResp++)
                            {
                                if (max < respostas[nResp])
                                {
                                    max = respostas[nResp];
                                    maxNeuronio = nResp;
                                    maxRede = nRede;
                                }
                            }
                        }

                        //decide o voto
                        voto = redes[maxRede].Camadas[1][maxNeuronio].desc;

                        if (voto == caixas[nCaixa].Nome)
                        {
                            correto++;
                        }
                        else
                        {
                            errado++;
                        }
                    }
                }
            }
            else
            {
                //teste para a caixa "ncaixa"
                for (int nCaixa = 0; nCaixa < caixas.Count; nCaixa++)
                {
                    //teste para o ponto "i"
                    for (int i = 0; i < caixas[nCaixa].QntdDados; i++)
                    {

                        double[] ponto = caixas[nCaixa].Pontos[i].CopyToArray();

                        //inicializa o vetor de votos cheio de zeros
                        double[] votos = new double[caixas.Count];

                        //Acha valor maximo entre os neurônios de saída
                        for (int nRede = 0; nRede < redes.Count; nRede++)
                        {
                            double max = double.NegativeInfinity;
                            int maxIndex =  -1;
                            int voto = -1;
                            double[] respostas = redes[nRede].CalculaSaída(ponto);

                            //achar o neuronio com maior valor para cada rede
                            for (int nResp = 0; nResp < respostas.Length; nResp++)
                            {
                                if (max <respostas[nResp])
                                {
                                    max = respostas[nResp];
                                    maxIndex = nResp;
                                }
                            }
                            //decide o voto
                            //as vezes nao acha o index por problemas de contas nos neurônios
                            if (maxIndex == -1)
                            {
                                voto = -1;
                            }
                            else
                            {
                                voto = redes[nRede].Camadas[1][maxIndex].desc;
                            }
                            //contabiliza
                            for (int dc = 0; dc < caixas.Count; dc++)
                            {
                                if (voto == caixas[dc].Nome)
                                {
                                  	//votos[dc] += max;
                                    //soma 1 voto, mesmo que pequeno
                                    votos[dc]++;
                                    break;
                                }
                            }
                        }

                        //correr vetor de votos e achar maior
                        double Nmax = double.NegativeInfinity;
                        int NmaxIndex =  -1;
                        for (int v = 0; v<caixas.Count ;v++ )
                        {
                            if (Nmax < votos[v])
                            {
                                Nmax = votos[v];
                                NmaxIndex = v;
                            }
                        }
                        if (NmaxIndex == nCaixa)
                        {
                            correto++;
                        }
                        else
                        {
                            errado++;
                        }
                    }
                }
            }
        }
Exemplo n.º 39
0
        static void Main(string[] args)
        {
            //teste padrão

            Teste t = new Teste();
            t.seed = 10;
            t.folds = 10;
            t.profundidade = 20;
            t.desc = "generico";

            t.Bounds = true;
            t.MBC = true;
            t.MPD  = false;
            t.TODOS  = false;

            t.AaA = true;
            t.OaA = !t.AaA;
            t.Voto = true;

            t.BV = 0;

            //tenta ler o tipoTeste do arquivo.
            TextReader textreader;
            try {
                textreader = new StreamReader("tipoTeste.xml");
                XmlSerializer serializer = new XmlSerializer(typeof(Teste));
                t = (Teste)serializer.Deserialize( textreader);
            } finally {
                textreader.Close();
            }

            int repet = 1;

            List<Dados> data;
            System.Diagnostics.Stopwatch tempo = new System.Diagnostics.Stopwatch();

            //Iris
            data = Flor();
            t.desc = "Iris";
            tempo.Start();
            imprimeMelhorResultado(BateriaDeTestes(data, t, repet*50));
            Console.WriteLine();
            Console.WriteLine("Tempo: " + tempo.ElapsedMilliseconds.ToString ());

            //Wine
            data = Vinho();
            t.desc = "Wine";
            tempo.Start();
            imprimeMelhorResultado(BateriaDeTestes(data, t, repet*20));
            Console.WriteLine();
            Console.WriteLine("Tempo: " + tempo.ElapsedMilliseconds.ToString ());

            //Glass
            data = Vidro();
            t.desc = "Glass";
            tempo.Start();
            imprimeMelhorResultado(BateriaDeTestes(data, t, repet*10));
            Console.WriteLine();
            Console.WriteLine("Tempo: " + tempo.ElapsedMilliseconds.ToString ());

            //Vowel
            data = Vogal();
            t.desc = "Vowel";
            tempo.Start();
            imprimeMelhorResultado(BateriaDeTestes(data, t, repet*10));
            Console.WriteLine();
            Console.WriteLine("Tempo: " + tempo.ElapsedMilliseconds.ToString ());

            //Car
            data = Carro();
            t.desc = "Car";
            tempo.Start();
            imprimeMelhorResultado(BateriaDeTestes(data, t, repet*5));
            Console.WriteLine();
            Console.WriteLine("Tempo: " + tempo.ElapsedMilliseconds.ToString ());

            //Segmentation
            data = Segmentacao();
            t.desc = "Segmentation";
            tempo.Start();
            imprimeMelhorResultado(BateriaDeTestes(data, t, repet*2));
            Console.WriteLine();
            Console.WriteLine("Tempo: " + tempo.ElapsedMilliseconds.ToString ());
        }
Exemplo n.º 40
0
 public TesteColisao(Teste nTipo)
 {
     tipo = nTipo;
 }