From a67d61f518f8411372903d8ffe2e23a08800d792 Mon Sep 17 00:00:00 2001 From: maroni Date: Mon, 2 Apr 2012 15:01:24 -0300 Subject: [PATCH] =?utf8?q?Implementa=C3=A7=C3=A3o=20dos=20registros=20de=20L?= =?utf8?q?og=20de=20eventos!?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/java/org/ufcspa/simdecs/test/Teste.java | 53 ++++++++++++---- web/login.xhtml | 2 +- web/redes/influencia.xml | 89 +++++++++++++++++++++++++++ web/simulador/endereco.txt | 2 +- 4 files changed, 132 insertions(+), 14 deletions(-) create mode 100644 web/redes/influencia.xml diff --git a/src/java/org/ufcspa/simdecs/test/Teste.java b/src/java/org/ufcspa/simdecs/test/Teste.java index 06428db..e454cc4 100644 --- a/src/java/org/ufcspa/simdecs/test/Teste.java +++ b/src/java/org/ufcspa/simdecs/test/Teste.java @@ -4,24 +4,53 @@ */ package org.ufcspa.simdecs.test; +import java.io.File; +import unbbayes.io.xmlbif.version6.XMLBIFIO; +import unbbayes.prs.bn.JunctionTreeAlgorithm; +import unbbayes.prs.bn.ProbabilisticNetwork; +import unbbayes.prs.bn.ProbabilisticNode; + /** * * @author maroni */ public class Teste { - private static long getIdFromUID(String pUID, String prefixo) { - String id = pUID.replaceAll(prefixo, ""); - id = id.substring(0, id.indexOf(":")); - return Long.parseLong(id); - } + public static void main(String[] args) { + final String caminhoRede = "/Users/maroni/NetBeansProjects/SimDeCS/web/redes/influencia.xml"; + ProbabilisticNetwork rede; - private static long getIdPacienteFromUID(String pUID) { - String id = pUID.substring(pUID.indexOf(":paciente-") + ":paciente-".length()); - return Long.parseLong(id); - } + try { + // required to run unbbayes gui classes on server + System.setProperty("java.awt.headless", "false"); + rede = new ProbabilisticNetwork(null); + XMLBIFIO.loadXML(new File(caminhoRede), rede); + JunctionTreeAlgorithm jt = new JunctionTreeAlgorithm(); + jt.setNet(rede); + jt.run(); - public static void main(String[] args) { - System.out.println(getIdFromUID("sintoma-np-12:paciente-1", "sintoma-np-")); - System.out.println(getIdPacienteFromUID("sintoma-np-12:paciente-15")); + + for (int j = 0; j < rede.getNodeCount(); j++) { + if (!(rede.getNodeAt(j) instanceof ProbabilisticNode)) { + System.out.println(rede.getNodeAt(j).getClass()); + continue; + } + + ProbabilisticNode nodoAtual = (ProbabilisticNode) rede.getNodeAt(j); + System.out.println(nodoAtual.getName()); + + // Verificando a tabela de probabilidades do nodo + for (int pb = 0; pb < nodoAtual.getStatesSize(); pb++) { + System.out.println(nodoAtual.getStateAt(pb)+":"+nodoAtual.getMarginalAt(pb)); + } + System.out.println(""); + } + + + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + + } } diff --git a/web/login.xhtml b/web/login.xhtml index 9f31a9e..8a34894 100644 --- a/web/login.xhtml +++ b/web/login.xhtml @@ -35,7 +35,7 @@ Acesso ao Simulador

- + diff --git a/web/redes/influencia.xml b/web/redes/influencia.xml new file mode 100644 index 0000000..31017ce --- /dev/null +++ b/web/redes/influencia.xml @@ -0,0 +1,89 @@ + + + + 1.0 + influencia + UnBBayes + + + 40 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 1.0 + 1.0 + 0.0 + + + + + + 0.5 + 0.5 + + + + + + 0.5 + 0.5 + + + + + \ No newline at end of file diff --git a/web/simulador/endereco.txt b/web/simulador/endereco.txt index 831425f..fbeea0d 100755 --- a/web/simulador/endereco.txt +++ b/web/simulador/endereco.txt @@ -1 +1 @@ -http://200.18.67.61/simdecs2/ +http://localhost:8080/SimDeCS/ \ No newline at end of file -- 1.7.6.4