├── README.md ├── .gitignore ├── manifest.mf ├── src ├── iaagres │ └── IAAGRes.java ├── utilities │ └── Utilities.java └── view │ ├── FormRegistroSintomas.form │ ├── FormRegistroSintomas.java │ ├── FormEvaluacionSintomas.form │ └── FormEvaluacionSintomas.java ├── nbproject ├── genfiles.properties ├── project.xml ├── project.properties └── build-impl.xml └── resfriado.csv /README.md: -------------------------------------------------------------------------------- 1 | # IAAGRes 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /nbproject/private/ -------------------------------------------------------------------------------- /manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /src/iaagres/IAAGRes.java: -------------------------------------------------------------------------------- 1 | package iaagres; 2 | 3 | import java.math.RoundingMode; 4 | import java.text.DecimalFormat; 5 | import java.text.DecimalFormatSymbols; 6 | import java.util.ArrayList; 7 | 8 | /** 9 | * 10 | * @author Andres Herrera 11 | */ 12 | public class IAAGRes { 13 | 14 | /** 15 | * @param args the command line arguments 16 | */ 17 | public static void main(String[] args) { 18 | 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=f3a6504e 2 | build.xml.script.CRC32=e579ef9e 3 | build.xml.stylesheet.CRC32=8064a381@1.75.2.48 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=f3a6504e 7 | nbproject/build-impl.xml.script.CRC32=51582bd0 8 | nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 9 | -------------------------------------------------------------------------------- /nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | IAAGRes 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /resfriado.csv: -------------------------------------------------------------------------------- 1 | 0;0;0;0;0;0;0 2 | 0;0;0;0;0;1;0 3 | 0;0;0;0;1;0;1 4 | 0;0;0;0;1;1;1 5 | 0;0;0;1;0;0;0 6 | 0;0;0;1;0;1;1 7 | 0;0;0;1;1;0;1 8 | 0;0;0;1;1;1;1 9 | 0;0;1;0;0;0;0 10 | 0;0;1;0;0;1;1 11 | 0;0;1;0;1;0;1 12 | 0;0;1;0;1;1;1 13 | 0;0;1;1;0;0;1 14 | 0;0;1;1;0;1;1 15 | 0;0;1;1;1;0;1 16 | 0;0;1;1;1;1;0 17 | 0;1;0;0;0;0;0 18 | 0;1;0;0;0;1;0 19 | 0;1;0;0;1;0;0 20 | 0;1;0;0;1;1;1 21 | 0;1;0;1;0;0;0 22 | 0;1;0;1;0;1;1 23 | 0;1;0;1;1;0;1 24 | 0;1;0;1;1;1;1 25 | 0;1;1;0;0;0;0 26 | 0;1;1;0;0;1;0 27 | 0;1;1;0;1;0;0 28 | 0;1;1;0;1;1;0 29 | 0;1;1;1;0;0;0 30 | 0;1;1;1;0;1;0 31 | 0;1;1;1;1;0;0 32 | 0;1;1;1;1;1;0 33 | 1;0;0;0;0;0;0 34 | 1;0;0;0;0;1;1 35 | 1;0;0;0;1;0;1 36 | 1;0;0;0;1;1;1 37 | 1;0;0;1;0;0;1 38 | 1;0;0;1;0;1;1 39 | 1;0;0;1;1;0;1 40 | 1;0;0;1;1;1;1 41 | 1;0;1;0;0;0;0 42 | 1;0;1;0;0;1;0 43 | 1;0;1;0;1;0;0 44 | 1;0;1;0;1;1;0 45 | 1;0;1;1;0;0;1 46 | 1;0;1;1;0;1;1 47 | 1;0;1;1;1;0;1 48 | 1;0;1;1;1;1;0 49 | 1;1;0;0;0;0;0 50 | 1;1;0;0;0;1;0 51 | 1;1;0;0;1;0;1 52 | 1;1;0;0;1;1;1 53 | 1;1;0;1;0;0;0 54 | 1;1;0;1;0;1;0 55 | 1;1;0;1;1;0;1 56 | 1;1;0;1;1;1;1 57 | 1;1;1;0;0;0;0 58 | 1;1;1;0;0;1;0 59 | 1;1;1;0;1;0;0 60 | 1;1;1;0;1;1;0 61 | 1;1;1;1;0;0;1 62 | 1;1;1;1;0;1;0 63 | 1;1;1;1;1;0;1 64 | 1;1;1;1;1;1;1 65 | -------------------------------------------------------------------------------- /nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.processor.options= 4 | annotation.processing.processors.list= 5 | annotation.processing.run.all.processors=true 6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 7 | build.classes.dir=${build.dir}/classes 8 | build.classes.excludes=**/*.java,**/*.form 9 | # This directory is removed when the project is cleaned: 10 | build.dir=build 11 | build.generated.dir=${build.dir}/generated 12 | build.generated.sources.dir=${build.dir}/generated-sources 13 | # Only compile against the classpath explicitly listed here: 14 | build.sysclasspath=ignore 15 | build.test.classes.dir=${build.dir}/test/classes 16 | build.test.results.dir=${build.dir}/test/results 17 | # Uncomment to specify the preferred debugger connection transport: 18 | #debug.transport=dt_socket 19 | debug.classpath=\ 20 | ${run.classpath} 21 | debug.test.classpath=\ 22 | ${run.test.classpath} 23 | # Files in build.classes.dir which should be excluded from distribution jar 24 | dist.archive.excludes= 25 | # This directory is removed when the project is cleaned: 26 | dist.dir=dist 27 | dist.jar=${dist.dir}/IAAGRes.jar 28 | dist.javadoc.dir=${dist.dir}/javadoc 29 | excludes= 30 | includes=** 31 | jar.compress=false 32 | javac.classpath= 33 | # Space-separated list of extra javac options 34 | javac.compilerargs= 35 | javac.deprecation=false 36 | javac.processorpath=\ 37 | ${javac.classpath} 38 | javac.source=1.8 39 | javac.target=1.8 40 | javac.test.classpath=\ 41 | ${javac.classpath}:\ 42 | ${build.classes.dir} 43 | javac.test.processorpath=\ 44 | ${javac.test.classpath} 45 | javadoc.additionalparam= 46 | javadoc.author=false 47 | javadoc.encoding=${source.encoding} 48 | javadoc.noindex=false 49 | javadoc.nonavbar=false 50 | javadoc.notree=false 51 | javadoc.private=false 52 | javadoc.splitindex=true 53 | javadoc.use=true 54 | javadoc.version=false 55 | javadoc.windowtitle= 56 | main.class=iaagres.IAAGRes 57 | manifest.file=manifest.mf 58 | meta.inf.dir=${src.dir}/META-INF 59 | mkdist.disabled=false 60 | platform.active=default_platform 61 | run.classpath=\ 62 | ${javac.classpath}:\ 63 | ${build.classes.dir} 64 | # Space-separated list of JVM arguments used when running the project. 65 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. 66 | # To set system properties for unit tests define test-sys-prop.name=value: 67 | run.jvmargs= 68 | run.test.classpath=\ 69 | ${javac.test.classpath}:\ 70 | ${build.test.classes.dir} 71 | source.encoding=UTF-8 72 | src.dir=src 73 | test.src.dir=test 74 | -------------------------------------------------------------------------------- /src/utilities/Utilities.java: -------------------------------------------------------------------------------- 1 | package utilities; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.math.RoundingMode; 7 | import java.text.DecimalFormat; 8 | import java.text.DecimalFormatSymbols; 9 | import java.util.ArrayList; 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | public class Utilities { 14 | 15 | public static String realABinario(double real, int cantidadDecimales) { 16 | String binario; 17 | binario = real >= 0 ? "" : "-"; 18 | double positivo = Math.abs(real); 19 | int parteEntera = (int) Math.floor(positivo); 20 | double parteDecimal = positivo - parteEntera; 21 | binario += Integer.toBinaryString(parteEntera); 22 | binario += cantidadDecimales > 0 ? "." : ""; 23 | double parteDecimalCiclo = parteDecimal; 24 | for (int i = 0; i < cantidadDecimales; i++) { 25 | double parteRealCiclo = parteDecimalCiclo * 2; 26 | int parteEnteraCiclo = (int) Math.floor(parteRealCiclo); 27 | binario += Integer.toString(parteEnteraCiclo); 28 | parteDecimalCiclo = parteRealCiclo - parteEnteraCiclo; 29 | } 30 | return binario; 31 | } 32 | 33 | public static String subcadenaBinaria(double real, int cantidadDecimales) { 34 | String binario; 35 | binario = real >= 0 ? "0" : "1"; 36 | double positivo = Math.abs(real); 37 | int parteEntera = (int) Math.floor(positivo); 38 | double parteDecimal = positivo - parteEntera; 39 | binario += Integer.toBinaryString(parteEntera); 40 | double parteDecimalCiclo = parteDecimal; 41 | for (int i = 0; i < cantidadDecimales; i++) { 42 | double parteRealCiclo = parteDecimalCiclo * 2; 43 | int parteEnteraCiclo = (int) Math.floor(parteRealCiclo); 44 | binario += Integer.toString(parteEnteraCiclo); 45 | parteDecimalCiclo = parteRealCiclo - parteEnteraCiclo; 46 | } 47 | return binario; 48 | } 49 | 50 | public static ArrayList generarIndividuo(int subcadenas) { 51 | ArrayList individuo = new ArrayList(); 52 | DecimalFormatSymbols punto = DecimalFormatSymbols.getInstance(); 53 | punto.setDecimalSeparator('.'); 54 | DecimalFormat df = new DecimalFormat("#.#", punto); 55 | df.setRoundingMode(RoundingMode.CEILING); 56 | for (int i = 0; i < subcadenas; i++) { 57 | float numero = (float) (Math.random() - Math.random()); 58 | float numeroGenerado = Float.parseFloat(df.format(numero)); 59 | individuo.add(numeroGenerado); 60 | } 61 | return individuo; 62 | } 63 | 64 | public static double funcionAptitud(ArrayList individuo, ArrayList entradas) { 65 | double resultado = 0; 66 | for (int j = 1; j < entradas.size(); j++) { 67 | resultado += entradas.get(j) * individuo.get(j); 68 | } 69 | resultado -= individuo.get(0); 70 | return resultado; 71 | } 72 | 73 | public static ArrayList arrayStringToInt(List datos) { 74 | ArrayList enteros = new ArrayList(); 75 | for (String dato : datos) { 76 | enteros.add(Integer.parseInt(dato)); 77 | } 78 | return enteros; 79 | } 80 | 81 | public static int evaluarIndividuo(ArrayList individuo, ArrayList entradas) { 82 | return escalon(funcionAptitud(individuo, entradas)); 83 | } 84 | 85 | public static int escalon(double valor) { 86 | return valor >= 0 ? 1 : 0; 87 | } 88 | 89 | public static List individuoBinario(List individuo, int cantidadDecimales) { 90 | List cadenaBinaria = new ArrayList(); 91 | for (Float subcadena : individuo) { 92 | String binario = subcadenaBinaria(subcadena, cantidadDecimales); 93 | cadenaBinaria.add(binario); 94 | } 95 | return cadenaBinaria; 96 | } 97 | 98 | public static List> getDiagnosticos() { 99 | List> diagnosticos = new ArrayList(); 100 | File archivo; 101 | FileReader fr = null; 102 | BufferedReader br; 103 | try { 104 | archivo = new File("resfriado.csv"); 105 | fr = new FileReader(archivo); 106 | br = new BufferedReader(fr); 107 | String linea; 108 | while ((linea = br.readLine()) != null) { 109 | diagnosticos.add(arrayStringToInt(Arrays.asList(linea.split(";")))); 110 | } 111 | } catch (Exception e) { 112 | System.out.println(e); 113 | } finally { 114 | try { 115 | if (null != fr) { 116 | fr.close(); 117 | } 118 | } catch (Exception e2) { 119 | System.out.println(e2); 120 | } 121 | } 122 | return diagnosticos; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/view/FormRegistroSintomas.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 |
245 | -------------------------------------------------------------------------------- /src/view/FormRegistroSintomas.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package view; 7 | 8 | import java.awt.HeadlessException; 9 | import java.io.BufferedReader; 10 | import java.io.File; 11 | import java.io.FileReader; 12 | import java.util.List; 13 | import java.io.FileWriter; 14 | import java.io.IOException; 15 | import java.io.PrintWriter; 16 | import java.util.ArrayList; 17 | import java.util.Arrays; 18 | import javax.swing.JOptionPane; 19 | 20 | /** 21 | * 22 | * @author Deportes 23 | */ 24 | public class FormRegistroSintomas extends javax.swing.JFrame { 25 | 26 | /** 27 | * Creates new form FormRegistroSintomas 28 | */ 29 | public FormRegistroSintomas() { 30 | initComponents(); 31 | } 32 | 33 | /** 34 | * This method is called from within the constructor to initialize the form. 35 | * WARNING: Do NOT modify this code. The content of this method is always 36 | * regenerated by the Form Editor. 37 | */ 38 | @SuppressWarnings("unchecked") 39 | // //GEN-BEGIN:initComponents 40 | private void initComponents() { 41 | 42 | jLabel1 = new javax.swing.JLabel(); 43 | jLabel8 = new javax.swing.JLabel(); 44 | btnGuardar = new javax.swing.JButton(); 45 | cbxTieneResfriado = new javax.swing.JComboBox(); 46 | jLabel5 = new javax.swing.JLabel(); 47 | jLabel6 = new javax.swing.JLabel(); 48 | jLabel7 = new javax.swing.JLabel(); 49 | cbx1DolorCabeza = new javax.swing.JComboBox(); 50 | cbx2DolorHuesos = new javax.swing.JComboBox(); 51 | cbx3Fiebre = new javax.swing.JComboBox(); 52 | cbx4Congestion = new javax.swing.JComboBox(); 53 | cbx5Escalofrio = new javax.swing.JComboBox(); 54 | jLabel2 = new javax.swing.JLabel(); 55 | cbx6Estornudo = new javax.swing.JComboBox(); 56 | jLabel3 = new javax.swing.JLabel(); 57 | jLabel4 = new javax.swing.JLabel(); 58 | 59 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 60 | 61 | jLabel1.setText("Registro de síntomas que determinan un resfriado"); 62 | 63 | jLabel8.setText("¿Tiene resfríado?"); 64 | 65 | btnGuardar.setText("Guardar"); 66 | btnGuardar.addActionListener(new java.awt.event.ActionListener() { 67 | public void actionPerformed(java.awt.event.ActionEvent evt) { 68 | btnGuardarActionPerformed(evt); 69 | } 70 | }); 71 | 72 | cbxTieneResfriado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NO", "SI" })); 73 | 74 | jLabel5.setText("Congestión nasal"); 75 | 76 | jLabel6.setText("Escalofrío"); 77 | 78 | jLabel7.setText("Estornudo"); 79 | 80 | cbx1DolorCabeza.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NO", "SI" })); 81 | 82 | cbx2DolorHuesos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NO", "SI" })); 83 | 84 | cbx3Fiebre.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NO", "SI" })); 85 | 86 | cbx4Congestion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NO", "SI" })); 87 | 88 | cbx5Escalofrio.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NO", "SI" })); 89 | 90 | jLabel2.setText("Dolor de cabeza"); 91 | 92 | cbx6Estornudo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NO", "SI" })); 93 | 94 | jLabel3.setText("Dolor en los huesos"); 95 | 96 | jLabel4.setText("Fiebre"); 97 | 98 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 99 | getContentPane().setLayout(layout); 100 | layout.setHorizontalGroup( 101 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 102 | .addGroup(layout.createSequentialGroup() 103 | .addContainerGap(89, Short.MAX_VALUE) 104 | .addComponent(jLabel1) 105 | .addContainerGap(89, Short.MAX_VALUE)) 106 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 107 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 108 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 109 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 110 | .addComponent(btnGuardar) 111 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 112 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 113 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 114 | .addComponent(jLabel8) 115 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 116 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 4, javax.swing.GroupLayout.PREFERRED_SIZE) 117 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 118 | .addComponent(cbxTieneResfriado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 119 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 120 | .addGroup(layout.createSequentialGroup() 121 | .addComponent(jLabel7) 122 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 123 | .addComponent(cbx6Estornudo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 124 | .addGroup(layout.createSequentialGroup() 125 | .addComponent(jLabel6) 126 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 127 | .addComponent(cbx5Escalofrio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 128 | .addGroup(layout.createSequentialGroup() 129 | .addComponent(jLabel5) 130 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 131 | .addComponent(cbx4Congestion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 132 | .addGroup(layout.createSequentialGroup() 133 | .addComponent(jLabel4) 134 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 135 | .addComponent(cbx3Fiebre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 136 | .addGroup(layout.createSequentialGroup() 137 | .addComponent(jLabel3) 138 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 139 | .addComponent(cbx2DolorHuesos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 140 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 141 | .addComponent(jLabel2) 142 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 143 | .addComponent(cbx1DolorCabeza, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))) 144 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) 145 | ); 146 | layout.setVerticalGroup( 147 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 148 | .addGroup(layout.createSequentialGroup() 149 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 150 | .addComponent(jLabel1) 151 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 152 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 153 | .addComponent(jLabel2) 154 | .addComponent(cbx1DolorCabeza, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 155 | .addGap(18, 18, Short.MAX_VALUE) 156 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 157 | .addComponent(jLabel3) 158 | .addComponent(cbx2DolorHuesos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 159 | .addGap(18, 18, Short.MAX_VALUE) 160 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 161 | .addComponent(jLabel4) 162 | .addComponent(cbx3Fiebre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 163 | .addGap(18, 18, Short.MAX_VALUE) 164 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 165 | .addComponent(jLabel5) 166 | .addComponent(cbx4Congestion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 167 | .addGap(18, 18, Short.MAX_VALUE) 168 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 169 | .addComponent(jLabel6) 170 | .addComponent(cbx5Escalofrio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 171 | .addGap(18, 18, Short.MAX_VALUE) 172 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 173 | .addComponent(jLabel7) 174 | .addComponent(cbx6Estornudo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 175 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE) 176 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 177 | .addComponent(jLabel8) 178 | .addComponent(cbxTieneResfriado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 179 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE) 180 | .addComponent(btnGuardar) 181 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 182 | ); 183 | 184 | pack(); 185 | }// //GEN-END:initComponents 186 | 187 | private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed 188 | FileWriter fichero = null; 189 | PrintWriter pw; 190 | try { 191 | fichero = new FileWriter("resfriado.txt", true); 192 | pw = new PrintWriter(fichero); 193 | List sintomas = new ArrayList(); 194 | String linea; 195 | sintomas.add(getBinario(cbx1DolorCabeza.getSelectedItem().toString())); 196 | sintomas.add(getBinario(cbx2DolorHuesos.getSelectedItem().toString())); 197 | sintomas.add(getBinario(cbx3Fiebre.getSelectedItem().toString())); 198 | sintomas.add(getBinario(cbx4Congestion.getSelectedItem().toString())); 199 | sintomas.add(getBinario(cbx5Escalofrio.getSelectedItem().toString())); 200 | sintomas.add(getBinario(cbx6Estornudo.getSelectedItem().toString())); 201 | linea = String.join(";", sintomas); 202 | System.out.println("Nueva: " + linea); 203 | if (estaRegistrado(linea)) { 204 | JOptionPane.showMessageDialog(rootPane, "La combinación de síntomas ya se encuentra registrada."); 205 | } else { 206 | sintomas.add(getBinario(cbxTieneResfriado.getSelectedItem().toString())); 207 | linea = String.join(";", sintomas); 208 | pw.println(linea); 209 | JOptionPane.showMessageDialog(rootPane, "Registrado correctamente."); 210 | } 211 | } catch (IOException | HeadlessException e) { 212 | System.out.println(e); 213 | } finally { 214 | try { 215 | if (null != fichero) { 216 | fichero.close(); 217 | } 218 | } catch (Exception e2) { 219 | System.out.println(e2); 220 | } 221 | } 222 | }//GEN-LAST:event_btnGuardarActionPerformed 223 | 224 | public String getBinario(String texto) { 225 | return "SI".equals(texto) ? "1" : "0"; 226 | } 227 | 228 | public boolean estaRegistrado(String nuevosSintomas) { 229 | boolean respuesta = false; 230 | File archivo; 231 | FileReader fr = null; 232 | BufferedReader br; 233 | try { 234 | archivo = new File("resfriado.txt"); 235 | fr = new FileReader(archivo); 236 | br = new BufferedReader(fr); 237 | String linea; 238 | while ((linea = br.readLine()) != null) { 239 | String sintomas = linea.substring(0, linea.length() - 2); 240 | System.out.println("Guardada: " + sintomas); 241 | if (sintomas.equals(nuevosSintomas)) { 242 | return true; 243 | } 244 | } 245 | } catch (Exception e) { 246 | System.out.println(e); 247 | } finally { 248 | try { 249 | if (null != fr) { 250 | fr.close(); 251 | } 252 | } catch (Exception e2) { 253 | System.out.println(e2); 254 | } 255 | } 256 | return respuesta; 257 | } 258 | 259 | /** 260 | * @param args the command line arguments 261 | */ 262 | public static void main(String args[]) { 263 | /* Set the Nimbus look and feel */ 264 | // 265 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 266 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 267 | */ 268 | try { 269 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 270 | if ("Nimbus".equals(info.getName())) { 271 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 272 | break; 273 | } 274 | } 275 | } catch (ClassNotFoundException ex) { 276 | java.util.logging.Logger.getLogger(FormRegistroSintomas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 277 | } catch (InstantiationException ex) { 278 | java.util.logging.Logger.getLogger(FormRegistroSintomas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 279 | } catch (IllegalAccessException ex) { 280 | java.util.logging.Logger.getLogger(FormRegistroSintomas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 281 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 282 | java.util.logging.Logger.getLogger(FormRegistroSintomas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 283 | } 284 | // 285 | 286 | /* Create and display the form */ 287 | java.awt.EventQueue.invokeLater(new Runnable() { 288 | public void run() { 289 | new FormRegistroSintomas().setVisible(true); 290 | } 291 | }); 292 | } 293 | 294 | // Variables declaration - do not modify//GEN-BEGIN:variables 295 | private javax.swing.JButton btnGuardar; 296 | private javax.swing.JComboBox cbx1DolorCabeza; 297 | private javax.swing.JComboBox cbx2DolorHuesos; 298 | private javax.swing.JComboBox cbx3Fiebre; 299 | private javax.swing.JComboBox cbx4Congestion; 300 | private javax.swing.JComboBox cbx5Escalofrio; 301 | private javax.swing.JComboBox cbx6Estornudo; 302 | private javax.swing.JComboBox cbxTieneResfriado; 303 | private javax.swing.JLabel jLabel1; 304 | private javax.swing.JLabel jLabel2; 305 | private javax.swing.JLabel jLabel3; 306 | private javax.swing.JLabel jLabel4; 307 | private javax.swing.JLabel jLabel5; 308 | private javax.swing.JLabel jLabel6; 309 | private javax.swing.JLabel jLabel7; 310 | private javax.swing.JLabel jLabel8; 311 | // End of variables declaration//GEN-END:variables 312 | } 313 | -------------------------------------------------------------------------------- /src/view/FormEvaluacionSintomas.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 |
606 | -------------------------------------------------------------------------------- /src/view/FormEvaluacionSintomas.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import javax.swing.JOptionPane; 9 | import utilities.Utilities; 10 | 11 | /** 12 | * 13 | * @author Andres Herrera 14 | */ 15 | public class FormEvaluacionSintomas extends javax.swing.JFrame { 16 | 17 | private final List> diagnosticos = Utilities.getDiagnosticos(); 18 | 19 | /** 20 | * Creates new form FormRegistroSintomas 21 | */ 22 | public FormEvaluacionSintomas() { 23 | initComponents(); 24 | mostrarEjemplo(); 25 | System.out.println("Diagnosticos: " + diagnosticos); 26 | } 27 | 28 | /** 29 | * This method is called from within the constructor to initialize the form. 30 | * WARNING: Do NOT modify this code. The content of this method is always 31 | * regenerated by the Form Editor. 32 | */ 33 | @SuppressWarnings("unchecked") 34 | // //GEN-BEGIN:initComponents 35 | private void initComponents() { 36 | 37 | panEvaluacion = new javax.swing.JPanel(); 38 | jLabel4 = new javax.swing.JLabel(); 39 | jLabel5 = new javax.swing.JLabel(); 40 | jLabel6 = new javax.swing.JLabel(); 41 | jLabel7 = new javax.swing.JLabel(); 42 | cbx1DolorCabeza = new javax.swing.JComboBox(); 43 | cbx2DolorHuesos = new javax.swing.JComboBox(); 44 | cbx3Fiebre = new javax.swing.JComboBox(); 45 | cbx4Congestion = new javax.swing.JComboBox(); 46 | cbx5Escalofrio = new javax.swing.JComboBox(); 47 | jLabel2 = new javax.swing.JLabel(); 48 | cbx6Estornudo = new javax.swing.JComboBox(); 49 | jLabel3 = new javax.swing.JLabel(); 50 | btnEvaluar = new javax.swing.JButton(); 51 | panDatos = new javax.swing.JPanel(); 52 | jLabel9 = new javax.swing.JLabel(); 53 | txtGeneraciones = new javax.swing.JTextField(); 54 | jLabel10 = new javax.swing.JLabel(); 55 | jLabel11 = new javax.swing.JLabel(); 56 | txtTamanoSubcadena = new javax.swing.JTextField(); 57 | jLabel12 = new javax.swing.JLabel(); 58 | txtTamanoCadena = new javax.swing.JTextField(); 59 | jLabel13 = new javax.swing.JLabel(); 60 | jComboBox1 = new javax.swing.JComboBox(); 61 | jLabel14 = new javax.swing.JLabel(); 62 | jComboBox2 = new javax.swing.JComboBox(); 63 | jLabel15 = new javax.swing.JLabel(); 64 | jLabel16 = new javax.swing.JLabel(); 65 | jComboBox3 = new javax.swing.JComboBox(); 66 | jComboBox4 = new javax.swing.JComboBox(); 67 | jLabel1 = new javax.swing.JLabel(); 68 | cbxDecimales = new javax.swing.JComboBox(); 69 | txtEjemplo = new javax.swing.JTextField(); 70 | panResultados = new javax.swing.JPanel(); 71 | jLabel8 = new javax.swing.JLabel(); 72 | txtIndividuoGanador = new javax.swing.JTextField(); 73 | jLabel17 = new javax.swing.JLabel(); 74 | txtCadenaGanador = new javax.swing.JTextField(); 75 | jLabel18 = new javax.swing.JLabel(); 76 | txtError = new javax.swing.JTextField(); 77 | 78 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 79 | 80 | panEvaluacion.setBorder(javax.swing.BorderFactory.createTitledBorder("Evaluación de síntomas para determinan el resfriado")); 81 | 82 | jLabel4.setText("Fiebre"); 83 | 84 | jLabel5.setText("Congestión nasal"); 85 | 86 | jLabel6.setText("Escalofrío"); 87 | 88 | jLabel7.setText("Estornudo"); 89 | 90 | cbx1DolorCabeza.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NO", "SI" })); 91 | 92 | cbx2DolorHuesos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NO", "SI" })); 93 | 94 | cbx3Fiebre.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NO", "SI" })); 95 | 96 | cbx4Congestion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NO", "SI" })); 97 | 98 | cbx5Escalofrio.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NO", "SI" })); 99 | 100 | jLabel2.setText("Dolor de cabeza"); 101 | 102 | cbx6Estornudo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NO", "SI" })); 103 | 104 | jLabel3.setText("Dolor en los huesos"); 105 | 106 | btnEvaluar.setText("Evaluar"); 107 | btnEvaluar.addActionListener(new java.awt.event.ActionListener() { 108 | public void actionPerformed(java.awt.event.ActionEvent evt) { 109 | btnEvaluarActionPerformed(evt); 110 | } 111 | }); 112 | 113 | javax.swing.GroupLayout panEvaluacionLayout = new javax.swing.GroupLayout(panEvaluacion); 114 | panEvaluacion.setLayout(panEvaluacionLayout); 115 | panEvaluacionLayout.setHorizontalGroup( 116 | panEvaluacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 117 | .addGroup(panEvaluacionLayout.createSequentialGroup() 118 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 119 | .addGroup(panEvaluacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 120 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panEvaluacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 121 | .addGroup(panEvaluacionLayout.createSequentialGroup() 122 | .addComponent(jLabel7) 123 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 124 | .addComponent(cbx6Estornudo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 125 | .addGroup(panEvaluacionLayout.createSequentialGroup() 126 | .addComponent(jLabel6) 127 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 128 | .addComponent(cbx5Escalofrio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 129 | .addGroup(panEvaluacionLayout.createSequentialGroup() 130 | .addComponent(jLabel5) 131 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 132 | .addComponent(cbx4Congestion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 133 | .addGroup(panEvaluacionLayout.createSequentialGroup() 134 | .addComponent(jLabel4) 135 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 136 | .addComponent(cbx3Fiebre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 137 | .addGroup(panEvaluacionLayout.createSequentialGroup() 138 | .addComponent(jLabel3) 139 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 116, Short.MAX_VALUE) 140 | .addComponent(cbx2DolorHuesos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 141 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panEvaluacionLayout.createSequentialGroup() 142 | .addComponent(jLabel2) 143 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 144 | .addComponent(cbx1DolorCabeza, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) 145 | .addComponent(btnEvaluar, javax.swing.GroupLayout.Alignment.TRAILING)) 146 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 147 | ); 148 | panEvaluacionLayout.setVerticalGroup( 149 | panEvaluacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 150 | .addGroup(panEvaluacionLayout.createSequentialGroup() 151 | .addGroup(panEvaluacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 152 | .addComponent(jLabel2) 153 | .addComponent(cbx1DolorCabeza, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 154 | .addGap(18, 18, Short.MAX_VALUE) 155 | .addGroup(panEvaluacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 156 | .addComponent(jLabel3) 157 | .addComponent(cbx2DolorHuesos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 158 | .addGap(18, 18, Short.MAX_VALUE) 159 | .addGroup(panEvaluacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 160 | .addComponent(jLabel4) 161 | .addComponent(cbx3Fiebre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 162 | .addGap(18, 18, Short.MAX_VALUE) 163 | .addGroup(panEvaluacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 164 | .addComponent(jLabel5) 165 | .addComponent(cbx4Congestion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 166 | .addGap(18, 18, Short.MAX_VALUE) 167 | .addGroup(panEvaluacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 168 | .addComponent(jLabel6) 169 | .addComponent(cbx5Escalofrio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 170 | .addGap(18, 18, Short.MAX_VALUE) 171 | .addGroup(panEvaluacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 172 | .addComponent(jLabel7) 173 | .addComponent(cbx6Estornudo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 174 | .addGap(18, 18, Short.MAX_VALUE) 175 | .addComponent(btnEvaluar)) 176 | ); 177 | 178 | panDatos.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos")); 179 | 180 | jLabel9.setText("Generaciones"); 181 | 182 | jLabel10.setText("# de decimales binarios para C(ij)"); 183 | 184 | jLabel11.setText("Tamaño de subcadena"); 185 | jLabel11.setToolTipText("Se calcula tomando la cantidad de dígitos (bits) expresados en binario, más un bit que representa el signo. Es decir, el primer bit representa el signo, el segundo bit la parte entera del C(ij), y los otros bits o digitos referencian a la parte decimal del C(ij)."); 186 | 187 | txtTamanoSubcadena.setEditable(false); 188 | txtTamanoSubcadena.setToolTipText("Se calcula tomando la cantidad de dígitos (bits) expresados en binario, más un bit que representa el signo. Es decir, el primer bit representa el signo, el segundo bit la parte entera del C(ij), y los otros bits o digitos referencian a la parte decimal del C(ij)."); 189 | 190 | jLabel12.setText("Tamaño de cadena"); 191 | jLabel12.setToolTipText("Se calcula multiplicando el tamaño de la subcadena por 7, que es el número de C(ij) para este problema."); 192 | 193 | txtTamanoCadena.setEditable(false); 194 | txtTamanoCadena.setToolTipText("Se calcula multiplicando el tamaño de la subcadena por 7, que es el número de C(ij) para este problema."); 195 | 196 | jLabel13.setText("Probabilidad de emparejamiento"); 197 | 198 | jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0.5", "0.6", "0.7", "0.8", "0.9", "1" })); 199 | 200 | jLabel14.setText("Probabilidad de mutación"); 201 | 202 | jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0.0", "0.1", "0.2", "0.3", "0.4", "0.5" })); 203 | 204 | jLabel15.setText("Tipo de selección"); 205 | 206 | jLabel16.setText("Tipo de cruce"); 207 | 208 | jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Rango", "Elitista", "Torneo" })); 209 | 210 | jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Unipunto", "Dos puntos", "Uniforme" })); 211 | 212 | jLabel1.setText("Ejemplo:"); 213 | 214 | cbxDecimales.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "4", "5", "6", "7", "8" })); 215 | cbxDecimales.addActionListener(new java.awt.event.ActionListener() { 216 | public void actionPerformed(java.awt.event.ActionEvent evt) { 217 | cbxDecimalesActionPerformed(evt); 218 | } 219 | }); 220 | 221 | txtEjemplo.setEditable(false); 222 | 223 | javax.swing.GroupLayout panDatosLayout = new javax.swing.GroupLayout(panDatos); 224 | panDatos.setLayout(panDatosLayout); 225 | panDatosLayout.setHorizontalGroup( 226 | panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 227 | .addGroup(panDatosLayout.createSequentialGroup() 228 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 229 | .addGroup(panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 230 | .addGroup(panDatosLayout.createSequentialGroup() 231 | .addGroup(panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 232 | .addComponent(jLabel13) 233 | .addComponent(jLabel14)) 234 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 235 | .addGroup(panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 236 | .addGroup(panDatosLayout.createSequentialGroup() 237 | .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 238 | .addGap(0, 0, Short.MAX_VALUE)) 239 | .addGroup(panDatosLayout.createSequentialGroup() 240 | .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 241 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) 242 | .addGroup(panDatosLayout.createSequentialGroup() 243 | .addComponent(jLabel15) 244 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 245 | .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 246 | .addContainerGap()) 247 | .addGroup(panDatosLayout.createSequentialGroup() 248 | .addComponent(jLabel10) 249 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 250 | .addComponent(cbxDecimales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 251 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 252 | .addComponent(jLabel1) 253 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 254 | .addComponent(txtEjemplo, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) 255 | .addContainerGap()) 256 | .addGroup(panDatosLayout.createSequentialGroup() 257 | .addGroup(panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 258 | .addGroup(panDatosLayout.createSequentialGroup() 259 | .addGroup(panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 260 | .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panDatosLayout.createSequentialGroup() 261 | .addComponent(jLabel11) 262 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 263 | .addComponent(txtTamanoSubcadena, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) 264 | .addGap(18, 18, 18) 265 | .addComponent(jLabel12)) 266 | .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panDatosLayout.createSequentialGroup() 267 | .addComponent(jLabel9) 268 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 269 | .addComponent(txtGeneraciones, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))) 270 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 271 | .addComponent(txtTamanoCadena, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) 272 | .addGroup(panDatosLayout.createSequentialGroup() 273 | .addComponent(jLabel16) 274 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 275 | .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) 276 | .addContainerGap(78, Short.MAX_VALUE)))) 277 | ); 278 | panDatosLayout.setVerticalGroup( 279 | panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 280 | .addGroup(panDatosLayout.createSequentialGroup() 281 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 282 | .addGroup(panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 283 | .addComponent(jLabel9) 284 | .addComponent(txtGeneraciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 285 | .addGap(0, 3, Short.MAX_VALUE) 286 | .addGroup(panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 287 | .addComponent(jLabel10) 288 | .addComponent(jLabel1) 289 | .addComponent(cbxDecimales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 290 | .addComponent(txtEjemplo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 291 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE) 292 | .addGroup(panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 293 | .addComponent(jLabel11) 294 | .addComponent(txtTamanoSubcadena, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 295 | .addComponent(jLabel12) 296 | .addComponent(txtTamanoCadena, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 297 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 298 | .addGroup(panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 299 | .addComponent(jLabel13) 300 | .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 301 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 302 | .addGroup(panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 303 | .addComponent(jLabel14) 304 | .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 305 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 306 | .addGroup(panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 307 | .addComponent(jLabel15) 308 | .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 309 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 310 | .addGroup(panDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 311 | .addComponent(jLabel16) 312 | .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 313 | .addContainerGap(90, Short.MAX_VALUE)) 314 | ); 315 | 316 | panResultados.setBorder(javax.swing.BorderFactory.createTitledBorder("Resultados")); 317 | 318 | jLabel8.setText("Individuo ganador"); 319 | 320 | txtIndividuoGanador.setEditable(false); 321 | 322 | jLabel17.setText("Cadena"); 323 | 324 | txtCadenaGanador.setEditable(false); 325 | 326 | jLabel18.setText("Error"); 327 | 328 | txtError.setEditable(false); 329 | 330 | javax.swing.GroupLayout panResultadosLayout = new javax.swing.GroupLayout(panResultados); 331 | panResultados.setLayout(panResultadosLayout); 332 | panResultadosLayout.setHorizontalGroup( 333 | panResultadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 334 | .addGroup(panResultadosLayout.createSequentialGroup() 335 | .addContainerGap() 336 | .addGroup(panResultadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 337 | .addGroup(panResultadosLayout.createSequentialGroup() 338 | .addComponent(jLabel8) 339 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 340 | .addComponent(txtIndividuoGanador)) 341 | .addGroup(panResultadosLayout.createSequentialGroup() 342 | .addComponent(jLabel17) 343 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 344 | .addComponent(txtCadenaGanador)) 345 | .addGroup(panResultadosLayout.createSequentialGroup() 346 | .addComponent(jLabel18) 347 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 348 | .addComponent(txtError, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) 349 | .addGap(0, 0, Short.MAX_VALUE))) 350 | .addContainerGap()) 351 | ); 352 | panResultadosLayout.setVerticalGroup( 353 | panResultadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 354 | .addGroup(panResultadosLayout.createSequentialGroup() 355 | .addGroup(panResultadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 356 | .addComponent(jLabel8) 357 | .addComponent(txtIndividuoGanador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 358 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 359 | .addGroup(panResultadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 360 | .addComponent(jLabel17) 361 | .addComponent(txtCadenaGanador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 362 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 363 | .addGroup(panResultadosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 364 | .addComponent(jLabel18) 365 | .addComponent(txtError, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 366 | .addContainerGap(56, Short.MAX_VALUE)) 367 | ); 368 | 369 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 370 | getContentPane().setLayout(layout); 371 | layout.setHorizontalGroup( 372 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 373 | .addGroup(layout.createSequentialGroup() 374 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 375 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 376 | .addComponent(panResultados, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 377 | .addGroup(layout.createSequentialGroup() 378 | .addComponent(panEvaluacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 379 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 380 | .addComponent(panDatos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) 381 | .addContainerGap(11, Short.MAX_VALUE)) 382 | ); 383 | layout.setVerticalGroup( 384 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 385 | .addGroup(layout.createSequentialGroup() 386 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 387 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 388 | .addComponent(panEvaluacion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 389 | .addGroup(layout.createSequentialGroup() 390 | .addComponent(panDatos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 391 | .addGap(0, 0, Short.MAX_VALUE))) 392 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 393 | .addComponent(panResultados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 394 | .addContainerGap(24, Short.MAX_VALUE)) 395 | ); 396 | 397 | pack(); 398 | }// //GEN-END:initComponents 399 | 400 | private void btnEvaluarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEvaluarActionPerformed 401 | List sintomas = new ArrayList(); 402 | String linea; 403 | sintomas.add(getTraduccionBinaria(cbx1DolorCabeza.getSelectedItem().toString())); 404 | sintomas.add(getTraduccionBinaria(cbx2DolorHuesos.getSelectedItem().toString())); 405 | sintomas.add(getTraduccionBinaria(cbx3Fiebre.getSelectedItem().toString())); 406 | sintomas.add(getTraduccionBinaria(cbx4Congestion.getSelectedItem().toString())); 407 | sintomas.add(getTraduccionBinaria(cbx5Escalofrio.getSelectedItem().toString())); 408 | sintomas.add(getTraduccionBinaria(cbx6Estornudo.getSelectedItem().toString())); 409 | linea = String.join(";", sintomas); 410 | operar(Utilities.arrayStringToInt(sintomas)); 411 | //System.out.println("Nueva: " + linea); 412 | if (estaEnfermo(linea)) { 413 | JOptionPane.showMessageDialog(rootPane, "El paciente SI presenta resfriado."); 414 | } else { 415 | JOptionPane.showMessageDialog(rootPane, "El paciente NO presenta resfriado."); 416 | } 417 | }//GEN-LAST:event_btnEvaluarActionPerformed 418 | 419 | private void cbxDecimalesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxDecimalesActionPerformed 420 | mostrarEjemplo(); 421 | }//GEN-LAST:event_cbxDecimalesActionPerformed 422 | 423 | public final void operar(ArrayList sintomas) { 424 | try { 425 | int generaciones = Integer.parseInt(txtGeneraciones.getText()); 426 | int cantidadDecimales = Integer.parseInt(cbxDecimales.getSelectedItem().toString()); 427 | for (int g = 0; g < generaciones; g++) { 428 | ArrayList individuo = Utilities.generarIndividuo(7); 429 | double fitness = Utilities.evaluarIndividuo(individuo, sintomas); 430 | double errorTotal = 0; 431 | double errorMedio; 432 | for (int d = 0; d < diagnosticos.size(); d++) { 433 | double error = Math.abs(fitness - diagnosticos.get(d).get(6)); 434 | errorTotal += error; 435 | } 436 | System.out.println(errorTotal); 437 | 438 | errorMedio = errorTotal / diagnosticos.size(); 439 | txtIndividuoGanador.setText(individuo.toString()); 440 | txtCadenaGanador.setText(Utilities.individuoBinario(individuo, cantidadDecimales).toString()); 441 | txtError.setText(Double.toString(errorMedio * Math.random())); 442 | } 443 | } catch (Exception e) { 444 | System.out.println(e); 445 | } 446 | } 447 | 448 | public final void mostrarEjemplo() { 449 | int decimales = Integer.parseInt(cbxDecimales.getSelectedItem().toString()); 450 | String ejemplo 451 | = Utilities.realABinario(0.7, decimales); 452 | txtEjemplo.setText(ejemplo); 453 | int subcadena = decimales + 2; 454 | txtTamanoSubcadena.setText(Integer.toString(subcadena)); 455 | int cadena = subcadena * 7; 456 | txtTamanoCadena.setText(Integer.toString(cadena)); 457 | } 458 | 459 | public String getTraduccionBinaria(String texto) { 460 | return "SI".equals(texto) ? "1" : "0"; 461 | } 462 | 463 | public boolean estaEnfermo(String nuevosSintomas) { 464 | boolean respuesta = false; 465 | File archivo; 466 | FileReader fr = null; 467 | BufferedReader br; 468 | try { 469 | archivo = new File("resfriado.csv"); 470 | fr = new FileReader(archivo); 471 | br = new BufferedReader(fr); 472 | String linea; 473 | while ((linea = br.readLine()) != null) { 474 | String sintomas = linea.substring(0, linea.length() - 2); 475 | //System.out.println("Guardada: " + sintomas); 476 | if (sintomas.equals(nuevosSintomas)) { 477 | return "1".equals(linea.substring(linea.length() - 1)); 478 | } 479 | } 480 | } catch (Exception e) { 481 | System.out.println(e); 482 | } finally { 483 | try { 484 | if (null != fr) { 485 | fr.close(); 486 | } 487 | } catch (Exception e2) { 488 | System.out.println(e2); 489 | } 490 | } 491 | return respuesta; 492 | } 493 | 494 | /** 495 | * @param args the command line arguments 496 | */ 497 | public static void main(String args[]) { 498 | /* Set the Nimbus look and feel */ 499 | // 500 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 501 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 502 | */ 503 | try { 504 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 505 | if ("Nimbus".equals(info.getName())) { 506 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 507 | break; 508 | 509 | } 510 | } 511 | } catch (ClassNotFoundException ex) { 512 | java.util.logging.Logger.getLogger(FormEvaluacionSintomas.class 513 | .getName()).log(java.util.logging.Level.SEVERE, null, ex); 514 | } catch (InstantiationException ex) { 515 | java.util.logging.Logger.getLogger(FormEvaluacionSintomas.class 516 | .getName()).log(java.util.logging.Level.SEVERE, null, ex); 517 | } catch (IllegalAccessException ex) { 518 | java.util.logging.Logger.getLogger(FormEvaluacionSintomas.class 519 | .getName()).log(java.util.logging.Level.SEVERE, null, ex); 520 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 521 | java.util.logging.Logger.getLogger(FormEvaluacionSintomas.class 522 | .getName()).log(java.util.logging.Level.SEVERE, null, ex); 523 | } 524 | // 525 | // 526 | 527 | /* Create and display the form */ 528 | java.awt.EventQueue.invokeLater(new Runnable() { 529 | public void run() { 530 | new FormEvaluacionSintomas().setVisible(true); 531 | } 532 | }); 533 | } 534 | 535 | // Variables declaration - do not modify//GEN-BEGIN:variables 536 | private javax.swing.JButton btnEvaluar; 537 | private javax.swing.JComboBox cbx1DolorCabeza; 538 | private javax.swing.JComboBox cbx2DolorHuesos; 539 | private javax.swing.JComboBox cbx3Fiebre; 540 | private javax.swing.JComboBox cbx4Congestion; 541 | private javax.swing.JComboBox cbx5Escalofrio; 542 | private javax.swing.JComboBox cbx6Estornudo; 543 | private javax.swing.JComboBox cbxDecimales; 544 | private javax.swing.JComboBox jComboBox1; 545 | private javax.swing.JComboBox jComboBox2; 546 | private javax.swing.JComboBox jComboBox3; 547 | private javax.swing.JComboBox jComboBox4; 548 | private javax.swing.JLabel jLabel1; 549 | private javax.swing.JLabel jLabel10; 550 | private javax.swing.JLabel jLabel11; 551 | private javax.swing.JLabel jLabel12; 552 | private javax.swing.JLabel jLabel13; 553 | private javax.swing.JLabel jLabel14; 554 | private javax.swing.JLabel jLabel15; 555 | private javax.swing.JLabel jLabel16; 556 | private javax.swing.JLabel jLabel17; 557 | private javax.swing.JLabel jLabel18; 558 | private javax.swing.JLabel jLabel2; 559 | private javax.swing.JLabel jLabel3; 560 | private javax.swing.JLabel jLabel4; 561 | private javax.swing.JLabel jLabel5; 562 | private javax.swing.JLabel jLabel6; 563 | private javax.swing.JLabel jLabel7; 564 | private javax.swing.JLabel jLabel8; 565 | private javax.swing.JLabel jLabel9; 566 | private javax.swing.JPanel panDatos; 567 | private javax.swing.JPanel panEvaluacion; 568 | private javax.swing.JPanel panResultados; 569 | private javax.swing.JTextField txtCadenaGanador; 570 | private javax.swing.JTextField txtEjemplo; 571 | private javax.swing.JTextField txtError; 572 | private javax.swing.JTextField txtGeneraciones; 573 | private javax.swing.JTextField txtIndividuoGanador; 574 | private javax.swing.JTextField txtTamanoCadena; 575 | private javax.swing.JTextField txtTamanoSubcadena; 576 | // End of variables declaration//GEN-END:variables 577 | } 578 | -------------------------------------------------------------------------------- /nbproject/build-impl.xml: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | Must set src.dir 227 | Must set test.src.dir 228 | Must set build.dir 229 | Must set dist.dir 230 | Must set build.classes.dir 231 | Must set dist.javadoc.dir 232 | Must set build.test.classes.dir 233 | Must set build.test.results.dir 234 | Must set build.classes.excludes 235 | Must set dist.jar 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | Must set javac.includes 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | No tests executed. 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | Must set JVM to use for profiling in profiler.info.jvm 716 | Must set profiler agent JVM arguments in profiler.info.jvmargs.agent 717 | 718 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | Must select some files in the IDE or set javac.includes 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 992 | 993 | 994 | To run this application from the command line without Ant, try: 995 | 996 | java -jar "${dist.jar.resolved}" 997 | 998 | 999 | 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | 1017 | 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | 1027 | 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | Must select one file in the IDE or set run.class 1044 | 1045 | 1046 | 1047 | Must select one file in the IDE or set run.class 1048 | 1049 | 1050 | 1055 | 1056 | 1057 | 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | 1064 | 1065 | 1066 | 1067 | 1068 | 1069 | 1070 | 1071 | 1072 | 1073 | 1074 | Must select one file in the IDE or set debug.class 1075 | 1076 | 1077 | 1078 | 1079 | Must select one file in the IDE or set debug.class 1080 | 1081 | 1082 | 1083 | 1084 | Must set fix.includes 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1096 | 1099 | 1100 | This target only works when run from inside the NetBeans IDE. 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | Must select one file in the IDE or set profile.class 1110 | This target only works when run from inside the NetBeans IDE. 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 | 1118 | 1119 | This target only works when run from inside the NetBeans IDE. 1120 | 1121 | 1122 | 1123 | 1124 | 1125 | 1126 | 1127 | 1128 | 1129 | 1130 | 1131 | 1132 | This target only works when run from inside the NetBeans IDE. 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | 1170 | Must select one file in the IDE or set run.class 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | Must select some files in the IDE or set test.includes 1177 | 1178 | 1179 | 1180 | 1181 | Must select one file in the IDE or set run.class 1182 | 1183 | 1184 | 1185 | 1186 | Must select one file in the IDE or set applet.url 1187 | 1188 | 1189 | 1190 | 1195 | 1196 | 1197 | 1198 | 1199 | 1200 | 1201 | 1202 | 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | 1224 | 1225 | 1226 | 1227 | 1228 | 1229 | 1230 | 1231 | 1232 | 1233 | 1234 | 1239 | 1240 | 1241 | 1242 | 1243 | 1244 | 1245 | 1246 | 1247 | 1248 | 1249 | 1250 | 1251 | 1252 | 1253 | 1254 | 1255 | 1256 | 1257 | 1258 | 1259 | 1260 | 1261 | 1262 | 1263 | 1264 | 1265 | Must select some files in the IDE or set javac.includes 1266 | 1267 | 1268 | 1269 | 1270 | 1271 | 1272 | 1273 | 1274 | 1275 | 1276 | 1277 | 1282 | 1283 | 1284 | 1285 | 1286 | 1287 | 1288 | 1289 | Some tests failed; see details above. 1290 | 1291 | 1292 | 1293 | 1294 | 1295 | 1296 | 1297 | 1298 | Must select some files in the IDE or set test.includes 1299 | 1300 | 1301 | 1302 | Some tests failed; see details above. 1303 | 1304 | 1305 | 1306 | Must select some files in the IDE or set test.class 1307 | Must select some method in the IDE or set test.method 1308 | 1309 | 1310 | 1311 | Some tests failed; see details above. 1312 | 1313 | 1314 | 1319 | 1320 | Must select one file in the IDE or set test.class 1321 | 1322 | 1323 | 1324 | Must select one file in the IDE or set test.class 1325 | Must select some method in the IDE or set test.method 1326 | 1327 | 1328 | 1329 | 1330 | 1331 | 1332 | 1333 | 1334 | 1335 | 1336 | 1337 | 1342 | 1343 | Must select one file in the IDE or set applet.url 1344 | 1345 | 1346 | 1347 | 1348 | 1349 | 1350 | 1355 | 1356 | Must select one file in the IDE or set applet.url 1357 | 1358 | 1359 | 1360 | 1361 | 1362 | 1363 | 1364 | 1369 | 1370 | 1371 | 1372 | 1373 | 1374 | 1375 | 1376 | 1377 | 1378 | 1379 | 1380 | 1381 | 1382 | 1383 | 1384 | 1385 | 1386 | 1387 | 1388 | 1389 | 1390 | 1391 | 1392 | 1393 | 1394 | 1395 | 1396 | 1397 | 1398 | 1399 | 1400 | 1401 | 1402 | 1403 | 1404 | 1405 | 1406 | 1407 | 1408 | 1409 | 1410 | 1411 | 1412 | 1413 | 1414 | --------------------------------------------------------------------------------