Skip to content

Commit

Permalink
qrg
Browse files Browse the repository at this point in the history
  • Loading branch information
miguerubsk committed Nov 10, 2020
1 parent a444d51 commit 5b1deb2
Show file tree
Hide file tree
Showing 6 changed files with 251 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
nbproject/private/private.xml
nbproject/private/private.properties
/log/
*0.txt
30 changes: 16 additions & 14 deletions nbproject/build-impl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,6 @@ is divided into following sections:
<istrue value="${not.archive.disabled}"/>
</or>
</condition>
<condition property="do.mkdist">
<and>
<isset property="do.archive"/>
<isset property="libs.CopyLibs.classpath"/>
<not>
<istrue value="${mkdist.disabled}"/>
</not>
<not>
<istrue value="${modules.supported.internal}"/>
</not>
</and>
</condition>
<condition property="do.archive+manifest.available">
<and>
<isset property="manifest.available"/>
Expand Down Expand Up @@ -1193,13 +1181,27 @@ is divided into following sections:
<attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
</manifest>
</target>
<target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen" if="do.mkdist" name="-do-jar-copylibs">
<target depends="init,compile" name="-check-do-mkdist">
<condition property="do.mkdist">
<and>
<isset property="do.archive"/>
<isset property="libs.CopyLibs.classpath"/>
<not>
<istrue value="${mkdist.disabled}"/>
</not>
<not>
<available file="${build.classes.dir}/module-info.class"/>
</not>
</and>
</condition>
</target>
<target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen,-check-do-mkdist" if="do.mkdist" name="-do-jar-copylibs">
<j2seproject3:copylibs manifest="${tmp.manifest.file}"/>
<echo level="info">To run this application from the command line without Ant, try:</echo>
<property location="${dist.jar}" name="dist.jar.resolved"/>
<echo level="info">java -jar "${dist.jar.resolved}"</echo>
</target>
<target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen" if="do.archive" name="-do-jar-jar" unless="do.mkdist">
<target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen,-check-do-mkdist" if="do.archive" name="-do-jar-jar" unless="do.mkdist">
<j2seproject1:jar manifest="${tmp.manifest.file}"/>
<property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
<property location="${dist.jar}" name="dist.jar.resolved"/>
Expand Down
4 changes: 2 additions & 2 deletions nbproject/genfiles.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ [email protected]
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=29d45fb8
nbproject/build-impl.xml.script.CRC32=405e9818
nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.92.0.48
nbproject/build-impl.xml.script.CRC32=8fe6f3b0
nbproject/build-impl.xml.stylesheet.CRC32=f89f7d21@1.96.0.48
70 changes: 70 additions & 0 deletions src/util/CargaDatos.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tools;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
*
* @author Miguerubsk
*/
public class CargaDatos {
private int TamMatriz, TamSolucion;
private double Matriz[][];
private String NombreFichero;

public CargaDatos(String fichero){
NombreFichero = fichero;
FileReader f = null;
String linea;
try {
f = new FileReader(fichero);
BufferedReader b = new BufferedReader(f);

if((linea = b.readLine()) != null){
String[] split = linea.split(" ");
TamMatriz = Integer.parseInt(split[0]);
TamSolucion = Integer.parseInt(split[1]);
Matriz = new double[TamMatriz][TamMatriz];
}

for (int i = 0; i < TamMatriz; i++) {
for (int j = 0; j < TamMatriz; j++) {
Matriz[i][j] = 0;
}
}

while((linea = b.readLine()) != null){
String[] split = linea.split(" ");
Matriz[Integer.parseInt(split[0])][Integer.parseInt(split[1])] = Double.parseDouble(split[2]);
Matriz[Integer.parseInt(split[1])][Integer.parseInt(split[0])] = Double.parseDouble(split[2]);
}

} catch (IOException e) {
System.out.println(e);
}

}

public int getTamMatriz() {
return TamMatriz;
}

public int getTamSolucion() {
return TamSolucion;
}

public double[][] getMatriz() {
return Matriz;
}

public String getNombreFichero() {
return NombreFichero;
}

}
90 changes: 90 additions & 0 deletions src/util/Configurador.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package util;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

/**
*
* @author Miguerubsk
*/
public class Configurador {

private ArrayList<String> Ficheros, Algoritmos;
private ArrayList<Long> Semillas;
private Integer Evaluaciones;
private Integer Tenencia;

public Configurador(String ruta) {
Ficheros = new ArrayList<>();
Algoritmos = new ArrayList<>();
Semillas = new ArrayList<>();

String linea;
FileReader f = null;
try {
f = new FileReader(ruta);
BufferedReader b = new BufferedReader(f);

while ((linea = b.readLine()) != null) {
String[] split = linea.split("=");
switch (split[0]) {
case "Archivos":
String[] vF = split[1].split(" ");
for (int i = 0; i < vF.length; i++) {
Ficheros.add(vF[i]);
}
break;
case "Semillas":
String[] vS = split[1].split(" ");
for (int i = 0; i < vS.length; i++) {
Semillas.add(Long.parseLong(vS[i]));
}
break;
case "Algoritmos":
String[] vA = split[1].split(" ");
for (int i = 0; i < vA.length; i++) {
Algoritmos.add(vA[i]);
}
break;
case "Evaluaciones":
Evaluaciones = Integer.parseInt(split[1]);
break;
case "Tenencia_Tabu":
Tenencia = Integer.parseInt(split[1]);
break;
}
}

} catch (IOException e) {
System.out.println(e);
}
}

public ArrayList<String> getFicheros() {
return Ficheros;
}

public ArrayList<String> getAlgoritmos() {
return Algoritmos;
}

public ArrayList<Long> getSemillas() {
return Semillas;
}

public Integer getEvaluaciones() {
return Evaluaciones;
}

public int getTenencia() {
return Tenencia;
}

}
72 changes: 72 additions & 0 deletions src/util/GuardarLog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tools;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/**
*
* @author Miguerubsk
*/
public class GuardarLog {

private FileWriter fichero = null;
private PrintWriter pw = null;
private String separador = "\n-------------------------------------";

public GuardarLog(String nombreArchivo, String texto, String algoritmo) {
try {
String carpeta = "log/" + algoritmo + "/";
File directorio = new File(carpeta);
if (!directorio.exists()) {
directorio.mkdirs();
}

File file = new File(carpeta + nombreArchivo + ".txt");
if (!file.exists()) {
file.createNewFile();
} else {
file.delete();
file.createNewFile();
}
fichero = new FileWriter(carpeta + nombreArchivo + ".txt");
pw = new PrintWriter(fichero);

pw.write(texto + separador);

} catch (IOException e) {
System.err.println(e.toString());
}
}

public void escribir(String texto) {
try {
fichero.write("\n[INFORMACION]\n" + texto + "\n");
} catch (Exception e) {
System.out.println("tools.GuardarLog.escribir()" + e.toString());
}
}

public void escribirNoInfo(String texto) {
try {
fichero.write("\n" + texto + "\n");
} catch (Exception e) {
System.out.println("tools.GuardarLog.escribir()" + e.toString());
}
}

public void escribirFinal(String texto) {
try {
fichero.write(separador + "\n" + texto + "\n");
fichero.close();
} catch (Exception e) {
System.out.println("tools.GuardarLog.escribir()" + e.toString());
}
}
}

0 comments on commit 5b1deb2

Please sign in to comment.