Skip to content
Snippets Groups Projects
Commit 1f41d7c7 authored by Falucho's avatar Falucho
Browse files

Retoques de Datos

parent 96c726a0
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ public final class AEControlador { ...@@ -26,7 +26,7 @@ public final class AEControlador {
private boolean forceStop = false; private boolean forceStop = false;
private int generacion = 0; private int generacion = 0;
private int generacionInvariante = 0; private int generacionInvariante = 0;
private Long startTime = null; private Long startTime = 0L;
private Long endTime = null; private Long endTime = null;
//Singleton //Singleton
......
...@@ -20,6 +20,7 @@ public final class ProblemaControlador { ...@@ -20,6 +20,7 @@ public final class ProblemaControlador {
private HashMap<Integer, Arista> aristasPair; private HashMap<Integer, Arista> aristasPair;
private HashMap<Integer, Parada> paradasOriginales; private HashMap<Integer, Parada> paradasOriginales;
private List<Parada> coordEspeciales;
private Matrix<Double> matrizOD; private Matrix<Double> matrizOD;
private Matrix<Integer> matrizDelaysPuntoAPunto; private Matrix<Integer> matrizDelaysPuntoAPunto;
...@@ -36,6 +37,17 @@ public final class ProblemaControlador { ...@@ -36,6 +37,17 @@ public final class ProblemaControlador {
System.out.println("OK"); System.out.println("OK");
} }
public List<Parada> getCoordEspeciales() {
if (coordEspeciales == null) {
coordEspeciales = new ArrayList<>();
coordEspeciales.add(new Parada("10000\t3502646\t5611050"));
coordEspeciales.add(new Parada("10003\t3453314\t5616550"));
coordEspeciales.add(new Parada("10001\t3445756\t5613413"));
coordEspeciales.add(new Parada("10002\t3451896\t5601352"));
}
return coordEspeciales;
}
public static ProblemaControlador getInstance() { public static ProblemaControlador getInstance() {
if (INSTANCIA == null) { if (INSTANCIA == null) {
INSTANCIA = new ProblemaControlador(); INSTANCIA = new ProblemaControlador();
......
...@@ -2,10 +2,7 @@ package uy.edu.fing.lrt.genetic; ...@@ -2,10 +2,7 @@ package uy.edu.fing.lrt.genetic;
import uy.edu.fing.lrt.controlador.ProblemaControlador; import uy.edu.fing.lrt.controlador.ProblemaControlador;
import uy.edu.fing.lrt.controlador.PropiedadesControlador; import uy.edu.fing.lrt.controlador.PropiedadesControlador;
import uy.edu.fing.lrt.modelo.Arista; import uy.edu.fing.lrt.modelo.*;
import uy.edu.fing.lrt.modelo.Concentrador;
import uy.edu.fing.lrt.modelo.Individuo;
import uy.edu.fing.lrt.modelo.Linea;
import uy.edu.fing.lrt.util.GlpkUtil; import uy.edu.fing.lrt.util.GlpkUtil;
import uy.edu.fing.lrt.util.ListUtil; import uy.edu.fing.lrt.util.ListUtil;
import uy.edu.fing.lrt.util.PropiedadesEnum; import uy.edu.fing.lrt.util.PropiedadesEnum;
...@@ -35,6 +32,8 @@ public final class Inicializador { ...@@ -35,6 +32,8 @@ public final class Inicializador {
default: default:
throw new RuntimeException("No se ha definido una acion " + algoritmo + " para la propiedad " + PropiedadesEnum.INICIALIZACION.getNombre()); throw new RuntimeException("No se ha definido una acion " + algoritmo + " para la propiedad " + PropiedadesEnum.INICIALIZACION.getNombre());
} }
result.add(Generador.sol1());
result.add(Generador.sol2());
result.parallelStream().forEach(e -> ProblemaControlador.getInstance().calculoDeFrecuencias(e)); result.parallelStream().forEach(e -> ProblemaControlador.getInstance().calculoDeFrecuencias(e));
return result; return result;
} }
......
...@@ -97,7 +97,7 @@ public final class GuiHelper { ...@@ -97,7 +97,7 @@ public final class GuiHelper {
lblEstado.setText(""); lblEstado.setText("");
Individuo best = AEControlador.getInstance().getBest(); Individuo best = AEControlador.getInstance().getBest();
if (best != null) { if (best != null) {
individuo = best.getAristas();
String tiempo = AEControlador.getInstance().getTime(); String tiempo = AEControlador.getInstance().getTime();
int gen = AEControlador.getInstance().getGeneracion(); int gen = AEControlador.getInstance().getGeneracion();
String frecs = best.getLineas().stream().map(l -> l.getFrecuencia() + "").collect(Collectors.joining("-")); String frecs = best.getLineas().stream().map(l -> l.getFrecuencia() + "").collect(Collectors.joining("-"));
...@@ -205,6 +205,18 @@ public final class GuiHelper { ...@@ -205,6 +205,18 @@ public final class GuiHelper {
g.fillOval(x - 1, y - 1, 1, 1); g.fillOval(x - 1, y - 1, 1, 1);
}); });
// java.util.List<Parada> coordEspeciales = ProblemaControlador.getInstance().getCoordEspeciales();
// g.setColor(Color.green);
// coordEspeciales.forEach((parada) -> {
//
// final int x = ((int) (parada.getCoordX().intValue() * propX)) + 10;
// final int y = (int) mapa.getSize().getHeight() - (((int) (parada.getCoordY().intValue() * propY))) - 10;
//
// g.drawOval(x - 3, y - 3, 7, 7);
// g.fillOval(x - 3, y - 3, 7, 7);
//
// });
return g; return g;
} }
......
...@@ -561,6 +561,10 @@ public final class Principal extends javax.swing.JFrame { ...@@ -561,6 +561,10 @@ public final class Principal extends javax.swing.JFrame {
Path path = Paths.get(pathPlace + "\\" + "individuo.txt"); Path path = Paths.get(pathPlace + "\\" + "individuo.txt");
try (BufferedWriter writer = Files.newBufferedWriter(path)) { try (BufferedWriter writer = Files.newBufferedWriter(path)) {
// for (Linea l : GuiHelper.sol1().getLineas()) {
// String line = l.getNodos().stream().map(e -> e + "").collect(Collectors.joining("\t", "", "\n"));
// writer.write(line);
// }
for (Arista arista : individuo) { for (Arista arista : individuo) {
writer.write(arista.getIdNodoA() + "\t"); writer.write(arista.getIdNodoA() + "\t");
writer.write(arista.getIdNodoB() + "\t"); writer.write(arista.getIdNodoB() + "\t");
......
package uy.edu.fing.lrt.modelo;
import uy.edu.fing.lrt.controlador.ProblemaControlador;
import uy.edu.fing.lrt.util.GlpkUtil;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public final class Generador {
//Metodos estaticos
private Generador() {
}
private void metodo() {
Individuo individuo = Generador.sol1();
Integer delay1 = (new Linea(GlpkUtil.SPP(individuo.getAristas(), 5, 4, Arista::getDelay))).getDelay() / 60;
Integer delay2 = (new Linea(GlpkUtil.SPP(individuo.getAristas(), 5, 3, Arista::getDelay))).getDelay() / 60;
Integer delay3 = (new Linea(GlpkUtil.SPP(individuo.getAristas(), 7, 3, Arista::getDelay))).getDelay() / 60;
Integer delay4 = (new Linea(GlpkUtil.SPP(individuo.getAristas(), 7, 6, Arista::getDelay))).getDelay() / 60;
Integer delay5 = (new Linea(GlpkUtil.SPP(individuo.getAristas(), 6, 2, Arista::getDelay))).getDelay() / 60;
System.out.println();
}
private static Arista find(int a, int b) {
return ProblemaControlador.getInstance().getArista(a, b);
}
private static Arista find(int a) {
return ProblemaControlador.getInstance().getArista(a);
}
private static Linea build(int[] idAristas) {
List<Arista> aristas = Arrays.stream(idAristas).mapToObj(Generador::find).collect(Collectors.toList());
return new Linea(aristas);
}
private static Concentrador build(int[]... idAristas) {
int size = idAristas.length;
List<Linea> lineas = Arrays.stream(idAristas).map(Generador::build).collect(Collectors.toList());
return new Concentrador(size, lineas);
}
private static Individuo buildI(int[] sizes, int[]... idAristas) {
int start = 0;
int end;
Concentrador[] c = new Concentrador[sizes.length];
for (int i = 0, sizesLength = sizes.length; i < sizesLength; i++) {
int size = sizes[i];
end = start + size;
c[i] = build(Arrays.copyOfRange(idAristas, start, end));
start = end;
}
return new Individuo(c);
}
public static Individuo sol1() {
return buildI(new int[]{2, 2, 3, 2},
new int[]{18, 32, 64, 6},
new int[]{16, 29, 65, 21, 22, 68, 70, 72, 83, 10},//ojo aca, no es 10, 12
new int[]{20, 46, 48, 50, 52, 79, 11},
new int[]{19, 45, 49, 51, 7},
new int[]{21, 65, 62, 64, 6},
new int[]{22, 68, 70, 72, 83, 10},
new int[]{23, 89, 86, 87, 13},
new int[]{27, 44, 45, 49, 52, 79, 11},
new int[]{26, 42, 50, 51, 7}
);
}
public static Individuo sol2() {
return buildI(new int[]{2, 2, 3, 2},
new int[]{18, 32, 64, 6},
new int[]{16, 29, 65, 21, 22, 68, 70, 72, 83, 12},//ojo aca, no es 10, 12
new int[]{20, 46, 48, 50, 52, 79, 11},
new int[]{19, 45, 49, 51, 7},
new int[]{21, 65, 62, 64, 6},
new int[]{22, 68, 70, 72, 83, 12},
new int[]{23, 89, 86, 87, 13},
new int[]{27, 44, 45, 49, 52, 79, 11},
new int[]{26, 42, 50, 51, 7}
);
}
}
...@@ -35,6 +35,12 @@ public final class Parada { ...@@ -35,6 +35,12 @@ public final class Parada {
return nombre; return nombre;
} }
public static String calcOriginalCoords(double coordX, double coordY) {
double x = (coordX + 36775.622427676) / 0.0648407565611663;
double y = (coordY + 397188.171216462) / 0.0647443036353733;
return x + "\t" + y;
}
@Override @Override
public String toString() { public String toString() {
return nombre + "(" + coordX + ", " + coordY + ")"; return nombre + "(" + coordX + ", " + coordY + ")";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment