further refactoring, renaming. Added dynamic parameter visualization to GUI.
This commit is contained in:
parent
100f26e983
commit
ce4c5c97d5
|
@ -1,9 +1,9 @@
|
|||
package de.wwwu.awolf.model.communication;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
|
||||
public class AlgorithmData implements Data {
|
||||
public class AlgorithmMessage implements Message {
|
||||
|
||||
private SubscriberType type;
|
||||
private Algorithm.Type algorithmType;
|
|
@ -1,12 +1,12 @@
|
|||
package de.wwwu.awolf.model.communication;
|
||||
|
||||
public class TypeData implements Data {
|
||||
public class DataProviderMessage implements Message {
|
||||
|
||||
private SubscriberType type;
|
||||
|
||||
@Override
|
||||
public SubscriberType getType() {
|
||||
return type;
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Override
|
|
@ -5,7 +5,7 @@ import java.io.Serializable;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class EvaluationData implements Data {
|
||||
public class EvaluationMessage implements Message {
|
||||
|
||||
private SubscriberType type;
|
||||
private List<Algorithm.Type> algorithmtypes;
|
|
@ -1,43 +0,0 @@
|
|||
package de.wwwu.awolf.model.communication;
|
||||
|
||||
public class GeneratorData implements Data {
|
||||
|
||||
private SubscriberType type;
|
||||
private String message;
|
||||
private double m;
|
||||
private double b;
|
||||
|
||||
public double getM() {
|
||||
return m;
|
||||
}
|
||||
|
||||
public void setM(double m) {
|
||||
this.m = m;
|
||||
}
|
||||
|
||||
public double getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public void setB(double b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubscriberType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(SubscriberType type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package de.wwwu.awolf.model.communication;
|
||||
|
||||
public class ImportData implements Data {
|
||||
|
||||
private SubscriberType type;
|
||||
private int numberOfLines;
|
||||
private int current;
|
||||
|
||||
@Override
|
||||
public SubscriberType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(SubscriberType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getNumberOfLines() {
|
||||
return numberOfLines;
|
||||
}
|
||||
|
||||
public void setNumberOfLines(int numberOfLines) {
|
||||
this.numberOfLines = numberOfLines;
|
||||
}
|
||||
|
||||
public int getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
public void setCurrent(int current) {
|
||||
this.current = current;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.model.communication;
|
||||
|
||||
public interface Data {
|
||||
public interface Message {
|
||||
|
||||
SubscriberType getType();
|
||||
|
|
@ -2,12 +2,7 @@ package de.wwwu.awolf.model.communication;
|
|||
|
||||
public enum SubscriberType {
|
||||
|
||||
EVAL_D,
|
||||
EVALUATION_TABLE_DATA,
|
||||
EVAL_T,
|
||||
LINES_RES,
|
||||
LINES_RES_MULT,
|
||||
EVALUATION,
|
||||
ALGORITHM,
|
||||
PICTURE,
|
||||
GENERATOR
|
||||
DATA_PROVIDER
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package de.wwwu.awolf.model;
|
||||
package de.wwwu.awolf.model.dao;
|
||||
|
||||
/**
|
||||
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
@ -1,4 +1,4 @@
|
|||
package de.wwwu.awolf.model;
|
||||
package de.wwwu.awolf.model.dao;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.apache.commons.math3.util.Precision;
|
|
@ -1,4 +1,4 @@
|
|||
package de.wwwu.awolf.model;
|
||||
package de.wwwu.awolf.model.dao;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
|
@ -1,4 +1,4 @@
|
|||
package de.wwwu.awolf.model;
|
||||
package de.wwwu.awolf.model.dao;
|
||||
|
||||
/**
|
||||
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
@ -1,4 +1,4 @@
|
|||
package de.wwwu.awolf.model;
|
||||
package de.wwwu.awolf.model.dao;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.apache.commons.math3.util.Precision;
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.model.evaluation;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package de.wwwu.awolf.presenter;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.LineModel;
|
||||
import de.wwwu.awolf.model.communication.Data;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.model.dao.LineModel;
|
||||
import de.wwwu.awolf.model.communication.Message;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
import de.wwwu.awolf.presenter.algorithms.AlgorithmHandler;
|
||||
import de.wwwu.awolf.presenter.data.DataHandler;
|
||||
|
@ -24,7 +24,7 @@ import javafx.beans.property.BooleanProperty;
|
|||
* @Email: a_wolf28@uni-muenster.de
|
||||
* @Date: 10.09.2017.
|
||||
*/
|
||||
public abstract class AbstractPresenter implements Flow.Subscriber<Data> {
|
||||
public abstract class AbstractPresenter implements Flow.Subscriber<Message> {
|
||||
|
||||
private final ExecutorService executor;
|
||||
private LineModel model;
|
||||
|
@ -56,25 +56,23 @@ public abstract class AbstractPresenter implements Flow.Subscriber<Data> {
|
|||
|
||||
|
||||
@Override
|
||||
public void onNext(Data data) {
|
||||
Logging.logDebug("Presenter received message. Type: " + data.getType());
|
||||
switch (data.getType()) {
|
||||
case EVALUATION_TABLE_DATA:
|
||||
evaluatedDatas(data);
|
||||
public void onNext(Message message) {
|
||||
Logging.logDebug("Presenter received message. Type: " + message.getType());
|
||||
switch (message.getType()) {
|
||||
case EVALUATION:
|
||||
evaluatedDatas(message);
|
||||
break;
|
||||
case ALGORITHM:
|
||||
visualizeAlgorithm(data);
|
||||
visualizeAlgorithm(message);
|
||||
break;
|
||||
case DATA_PROVIDER:
|
||||
enableStartAlgorithmButton();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void visualizeAlgorithm(Data data);
|
||||
|
||||
protected abstract void evaluatedDatas(Data data);
|
||||
|
||||
|
||||
@Override
|
||||
public void onError(Throwable throwable) {
|
||||
|
||||
|
@ -121,23 +119,14 @@ public abstract class AbstractPresenter implements Flow.Subscriber<Data> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return das zu grunde legende Modell
|
||||
*/
|
||||
public LineModel getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return die zu grunde legende View
|
||||
*/
|
||||
public ViewController getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param view die zu grunde legende View
|
||||
*/
|
||||
public void registerView(ViewController view) {
|
||||
this.view = view;
|
||||
Logging.logDebug("View has been set.");
|
||||
|
@ -146,9 +135,6 @@ public abstract class AbstractPresenter implements Flow.Subscriber<Data> {
|
|||
Platform.runLater(() -> this.view.initGui());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Evaluation
|
||||
*/
|
||||
EvaluatationHandler getEvaluatationHandler() {
|
||||
return evaluatationHandler;
|
||||
}
|
||||
|
@ -157,12 +143,17 @@ public abstract class AbstractPresenter implements Flow.Subscriber<Data> {
|
|||
return dataHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the instance of the ExecutorService
|
||||
*
|
||||
* @return ExecutorService instance
|
||||
*/
|
||||
public ExecutorService getExecutor() {
|
||||
return Objects.requireNonNullElseGet(executor, Executors::newCachedThreadPool);
|
||||
}
|
||||
|
||||
public AlgorithmHandler getAlgorithmHandler() {
|
||||
return algorithmHandler;
|
||||
}
|
||||
|
||||
protected abstract void enableStartAlgorithmButton();
|
||||
|
||||
protected abstract void visualizeAlgorithm(Message message);
|
||||
|
||||
protected abstract void evaluatedDatas(Message message);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
package de.wwwu.awolf.presenter;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
||||
import de.wwwu.awolf.model.communication.Data;
|
||||
import de.wwwu.awolf.model.communication.EvaluationData;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||
import de.wwwu.awolf.model.communication.Message;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.data.DataHandler;
|
||||
import de.wwwu.awolf.presenter.evaluation.EvaluatationHandler;
|
||||
import de.wwwu.awolf.presenter.util.Logging;
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import javafx.application.Platform;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -28,6 +26,11 @@ public class Presenter extends AbstractPresenter {
|
|||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton access method
|
||||
*
|
||||
* @return instance
|
||||
*/
|
||||
public static Presenter getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new Presenter();
|
||||
|
@ -37,26 +40,25 @@ public class Presenter extends AbstractPresenter {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void visualizeAlgorithm(Data data) {
|
||||
AlgorithmData algorithmData = (AlgorithmData) data;
|
||||
|
||||
Platform.runLater(() -> getView().getAlgorithmTabControllers().get(algorithmData.getAlgorithmType()).updatePlot(getModel(), algorithmData.getLineData())
|
||||
);
|
||||
Logging.logInfo("Type: " + algorithmData.getType() + ". Result: " + algorithmData.getLineData().toString());
|
||||
protected void enableStartAlgorithmButton() {
|
||||
Platform.runLater(() -> getView().getAlgorithmTabControllers().values().forEach(tab -> tab.getStartButton().setDisable(false)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void evaluatedDatas(Data data) {
|
||||
EvaluationData evaluationData = (EvaluationData) data;
|
||||
SwingUtilities
|
||||
.invokeLater(
|
||||
() -> getView().appendEvalResults(evaluationData.getMultipleColumnResult()));
|
||||
protected void visualizeAlgorithm(Message message) {
|
||||
AlgorithmMessage algorithmMessage = (AlgorithmMessage) message;
|
||||
Platform.runLater(() -> getView().getAlgorithmTabControllers().get(algorithmMessage.getAlgorithmType()).updatePlot(getModel(), algorithmMessage.getLineData()));
|
||||
Logging.logInfo("Type: " + algorithmMessage.getType() + ". Result: " + algorithmMessage.getLineData().toString());
|
||||
}
|
||||
|
||||
/***************************************************************************************************************************
|
||||
* Hilfsmethoden
|
||||
***************************************************************************************************************************/
|
||||
|
||||
@Override
|
||||
protected void evaluatedDatas(Message message) {
|
||||
//TODO
|
||||
// EvaluationData evaluationData = (EvaluationData) data;
|
||||
// SwingUtilities
|
||||
// .invokeLater(
|
||||
// () -> getView().appendEvalResults(evaluationData.getMultipleColumnResult()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Startet den Export des akteullen Datensatzes (nur der Geraden)
|
||||
|
@ -87,8 +89,7 @@ public class Presenter extends AbstractPresenter {
|
|||
getModel().setLines(data);
|
||||
//Berechnung der Schnittpunkte und vis. der Ergebnisse (anz. Geraden, anz. Schnittpunkte)
|
||||
Logging.logInfo("Import was successful! ");
|
||||
Platform.runLater(() -> getView().getAlgorithmTabControllers().values().forEach(e -> e.updatePlot(getModel(), null))
|
||||
);
|
||||
Platform.runLater(() -> getView().getAlgorithmTabControllers().values().forEach(e -> e.updatePlot(getModel(), null)));
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -102,8 +103,7 @@ public class Presenter extends AbstractPresenter {
|
|||
Set<Line> data = getDataHandler().getData(type, n);
|
||||
getModel().setLines(data);
|
||||
Logging.logInfo("Generate was successful!");
|
||||
Platform.runLater(() -> getView().getAlgorithmTabControllers().values().forEach(e -> e.updatePlot(getModel(), null))
|
||||
);
|
||||
Platform.runLater(() -> getView().getAlgorithmTabControllers().values().forEach(e -> e.updatePlot(getModel(), null)));
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package de.wwwu.awolf.presenter.algorithms;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.communication.Data;
|
||||
import de.wwwu.awolf.model.communication.Message;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Flow;
|
||||
|
@ -14,7 +15,7 @@ import java.util.concurrent.Flow;
|
|||
* @Email: a_wolf28@uni-muenster.de
|
||||
* @Date: 28.05.2017.
|
||||
*/
|
||||
public interface Algorithm extends Callable<Line>, Flow.Publisher<Data> {
|
||||
public interface Algorithm extends Callable<Line>, Flow.Publisher<Message> {
|
||||
|
||||
/**
|
||||
* Startet die Berechnung des jeweiligen Algorithmus.
|
||||
|
@ -28,6 +29,10 @@ public interface Algorithm extends Callable<Line>, Flow.Publisher<Data> {
|
|||
|
||||
void setPresenter(AbstractPresenter presenter);
|
||||
|
||||
Map<String, Object> getParameter();
|
||||
|
||||
void setParameter(Map<String, Object> parameter);
|
||||
|
||||
enum Type {
|
||||
LMS("Least Median of Squares"),
|
||||
RM("Repeated Median"),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.presenter.algorithms;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.Presenter;
|
||||
import de.wwwu.awolf.presenter.util.Logging;
|
||||
import java.util.EnumMap;
|
||||
|
@ -17,6 +17,7 @@ public class AlgorithmHandler {
|
|||
|
||||
private static AlgorithmHandler instance;
|
||||
private Map<Algorithm.Type, Algorithm> algorithmMapping;
|
||||
private Map<Algorithm.Type, Map<String, Object>> algorithmParameters;
|
||||
|
||||
|
||||
private AlgorithmHandler() {
|
||||
|
@ -88,10 +89,15 @@ public class AlgorithmHandler {
|
|||
ServiceLoader<Algorithm> load = ServiceLoader.load(Algorithm.class);
|
||||
load.reload();
|
||||
algorithmMapping = new EnumMap<>(Algorithm.Type.class);
|
||||
algorithmParameters = new EnumMap<>(Algorithm.Type.class);
|
||||
load.forEach(algorithm -> {
|
||||
algorithmMapping.put(algorithm.getType(), algorithm);
|
||||
algorithmParameters.put(algorithm.getType(), algorithm.getParameter());
|
||||
Logging.logDebug("Found: " + algorithm.getClass().getSimpleName());
|
||||
});
|
||||
}
|
||||
|
||||
public Map<String, Object> getAlgorithmParametersByType(Algorithm.Type type) {
|
||||
return algorithmParameters.get(type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.wwwu.awolf.presenter.algorithms.advanced;
|
||||
|
||||
import de.wwwu.awolf.model.Interval;
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.Point;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
||||
import de.wwwu.awolf.model.communication.Data;
|
||||
import de.wwwu.awolf.model.dao.Interval;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.model.dao.Point;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||
import de.wwwu.awolf.model.communication.Message;
|
||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
|
@ -14,8 +14,10 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
|
@ -43,11 +45,21 @@ public class LeastMedianOfSquaresEstimator implements Algorithm {
|
|||
private Line sigmaMin;
|
||||
private double heightsigmaMin;
|
||||
private double intersectionsPoint;
|
||||
private double constant = 0.5;
|
||||
private double constant;
|
||||
|
||||
private double slope;
|
||||
private double yInterception;
|
||||
private Flow.Subscriber<? super AlgorithmData> subscriber;
|
||||
private Flow.Subscriber<? super AlgorithmMessage> subscriber;
|
||||
private Map<String, Object> parameter;
|
||||
|
||||
public LeastMedianOfSquaresEstimator() {
|
||||
quantileError = 0.1;
|
||||
constant = 0.5;
|
||||
|
||||
parameter = new HashMap<>();
|
||||
parameter.put("Quantile Error", quantileError);
|
||||
parameter.put("Constant", constant);
|
||||
}
|
||||
|
||||
/**
|
||||
* Algorithmus zum berechnen des LMS-Schätzers
|
||||
|
@ -57,9 +69,9 @@ public class LeastMedianOfSquaresEstimator implements Algorithm {
|
|||
*/
|
||||
@Override
|
||||
public Line call() {
|
||||
|
||||
this.n = setOfLines.size();
|
||||
double qPlus = 0.5;
|
||||
quantileError = 0.1;
|
||||
double qMinus = qPlus * (1 - quantileError);
|
||||
kMinus = (int) Math.ceil(n * qMinus);
|
||||
kPlus = (int) Math.ceil(n * qPlus);
|
||||
|
@ -155,6 +167,16 @@ public class LeastMedianOfSquaresEstimator implements Algorithm {
|
|||
subscribe(presenter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getParameter() {
|
||||
return this.parameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(Map<String, Object> parameter) {
|
||||
this.parameter = parameter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Liefert die Anzahl der Schnittpunkte in einem Intervall
|
||||
|
@ -373,7 +395,7 @@ public class LeastMedianOfSquaresEstimator implements Algorithm {
|
|||
slope = m;
|
||||
yInterception = b;
|
||||
|
||||
AlgorithmData data = new AlgorithmData();
|
||||
AlgorithmMessage data = new AlgorithmMessage();
|
||||
data.setAlgorithmType(getType());
|
||||
data.setType(SubscriberType.ALGORITHM);
|
||||
data.setLineData(new Line(m, b));
|
||||
|
@ -460,7 +482,7 @@ public class LeastMedianOfSquaresEstimator implements Algorithm {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
||||
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||
this.subscriber = subscriber;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.wwwu.awolf.presenter.algorithms.advanced;
|
||||
|
||||
import de.wwwu.awolf.model.Interval;
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.Point;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
||||
import de.wwwu.awolf.model.communication.Data;
|
||||
import de.wwwu.awolf.model.dao.Interval;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.model.dao.Point;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||
import de.wwwu.awolf.model.communication.Message;
|
||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
|
@ -14,9 +14,11 @@ import de.wwwu.awolf.presenter.util.Logging;
|
|||
import de.wwwu.awolf.presenter.util.RandomSampler;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Flow;
|
||||
|
||||
|
@ -57,8 +59,15 @@ public class RepeatedMedianEstimator implements Algorithm {
|
|||
|
||||
private double slope;
|
||||
private double yInterception;
|
||||
private Flow.Subscriber<? super AlgorithmData> subscriber;
|
||||
private Flow.Subscriber<? super AlgorithmMessage> subscriber;
|
||||
private Map<String, Object> parameter;
|
||||
|
||||
public RepeatedMedianEstimator() {
|
||||
beta = 0.5;
|
||||
|
||||
parameter = new HashMap<>();
|
||||
parameter.put("Beta", beta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Führt den Algortihmus zur Berechnung des RM-Schätzers durch.
|
||||
|
@ -70,7 +79,7 @@ public class RepeatedMedianEstimator implements Algorithm {
|
|||
n = setOfLines.size();
|
||||
interval = new Interval(-10000, 10000);
|
||||
original = new Interval(-10000, 10000);
|
||||
beta = 0.5;
|
||||
|
||||
|
||||
intersectionsInLeftSlab = new HashSet<>();
|
||||
intersectionsInCenterSlab = new HashSet<>();
|
||||
|
@ -253,7 +262,7 @@ public class RepeatedMedianEstimator implements Algorithm {
|
|||
Math.floor(potentialYInterceptions.size() * 0.5));
|
||||
|
||||
if (this.subscriber != null) {
|
||||
AlgorithmData data = new AlgorithmData();
|
||||
AlgorithmMessage data = new AlgorithmMessage();
|
||||
data.setAlgorithmType(getType());
|
||||
data.setType(SubscriberType.ALGORITHM);
|
||||
data.setLineData(new Line(getSlope(), getyInterception()));
|
||||
|
@ -348,9 +357,19 @@ public class RepeatedMedianEstimator implements Algorithm {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
||||
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||
this.subscriber = subscriber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getParameter() {
|
||||
return this.parameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(Map<String, Object> parameter) {
|
||||
this.parameter = parameter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.wwwu.awolf.presenter.algorithms.advanced;
|
||||
|
||||
import de.wwwu.awolf.model.Interval;
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.Point;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
||||
import de.wwwu.awolf.model.communication.Data;
|
||||
import de.wwwu.awolf.model.dao.Interval;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.model.dao.Point;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||
import de.wwwu.awolf.model.communication.Message;
|
||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
|
@ -17,6 +17,7 @@ import java.util.Collection;
|
|||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Flow;
|
||||
|
||||
|
@ -50,8 +51,9 @@ public class TheilSenEstimator implements Algorithm {
|
|||
private double bVariant;
|
||||
private double slope;
|
||||
private double yInterception;
|
||||
private Flow.Subscriber<? super AlgorithmData> subscriber;
|
||||
private Flow.Subscriber<? super AlgorithmMessage> subscriber;
|
||||
private AbstractPresenter presenter;
|
||||
private Map<String, Object> parameter;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -217,7 +219,7 @@ public class TheilSenEstimator implements Algorithm {
|
|||
yInterception = b;
|
||||
|
||||
if (this.subscriber != null) {
|
||||
AlgorithmData data = new AlgorithmData();
|
||||
AlgorithmMessage data = new AlgorithmMessage();
|
||||
data.setAlgorithmType(getType());
|
||||
data.setType(SubscriberType.ALGORITHM);
|
||||
data.setLineData(new Line(m, b));
|
||||
|
@ -242,7 +244,17 @@ public class TheilSenEstimator implements Algorithm {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
||||
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||
this.subscriber = subscriber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getParameter() {
|
||||
return this.parameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(Map<String, Object> parameter) {
|
||||
this.parameter = parameter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package de.wwwu.awolf.presenter.algorithms.naiv;
|
||||
package de.wwwu.awolf.presenter.algorithms.naive;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
||||
import de.wwwu.awolf.model.communication.Data;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||
import de.wwwu.awolf.model.communication.Message;
|
||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
|
@ -10,8 +10,10 @@ import de.wwwu.awolf.presenter.util.FastElementSelector;
|
|||
import de.wwwu.awolf.presenter.util.Logging;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Flow;
|
||||
|
||||
|
@ -22,16 +24,20 @@ import java.util.concurrent.Flow;
|
|||
* @Email: a_wolf28@uni-muenster.de
|
||||
* @Date: 15.09.2017.
|
||||
*/
|
||||
public class NaivLeastMedianOfSquaresEstimator implements Algorithm {
|
||||
public class NaiveLeastMedianOfSquaresEstimator implements Algorithm {
|
||||
|
||||
private static final Algorithm.Type type = Type.NAIVE_LMS;
|
||||
private List<Line> setOfLines = new ArrayList<>();
|
||||
|
||||
private int n;
|
||||
private double ds, b, m;
|
||||
private Flow.Subscriber<? super Data> subscriber;
|
||||
private Flow.Subscriber<? super Message> subscriber;
|
||||
private AbstractPresenter presenter;
|
||||
private Map<String, Object> parameter;
|
||||
|
||||
public NaiveLeastMedianOfSquaresEstimator() {
|
||||
parameter = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Crude Algorithmus zum berechnen des LSM-Schätzers.
|
||||
|
@ -77,7 +83,7 @@ public class NaivLeastMedianOfSquaresEstimator implements Algorithm {
|
|||
Logging.logInfo("=== E N D - naiv L M S ===");
|
||||
Logging.logInfo("Slope: " + getSlope() + ", y-Interception: " + getYInterception());
|
||||
|
||||
AlgorithmData data = new AlgorithmData();
|
||||
AlgorithmMessage data = new AlgorithmMessage();
|
||||
data.setAlgorithmType(getType());
|
||||
data.setType(SubscriberType.ALGORITHM);
|
||||
data.setLineData(new Line(getSlope(), getYInterception()));
|
||||
|
@ -137,7 +143,17 @@ public class NaivLeastMedianOfSquaresEstimator implements Algorithm {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
||||
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||
this.subscriber = subscriber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getParameter() {
|
||||
return this.parameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(Map<String, Object> parameter) {
|
||||
this.parameter = parameter;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package de.wwwu.awolf.presenter.algorithms.naiv;
|
||||
package de.wwwu.awolf.presenter.algorithms.naive;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.Point;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
||||
import de.wwwu.awolf.model.communication.Data;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.model.dao.Point;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||
import de.wwwu.awolf.model.communication.Message;
|
||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
|
@ -23,7 +23,7 @@ import java.util.concurrent.Flow;
|
|||
* @Email: a_wolf28@uni-muenster.de
|
||||
* @Date: 15.09.2017.
|
||||
*/
|
||||
public class NaivRepeatedMedianEstimator implements Algorithm {
|
||||
public class NaiveRepeatedMedianEstimator implements Algorithm {
|
||||
|
||||
private static final Algorithm.Type type = Type.NAIVE_RM;
|
||||
|
||||
|
@ -34,8 +34,13 @@ public class NaivRepeatedMedianEstimator implements Algorithm {
|
|||
private List<Double> yMedians;
|
||||
private double medianX;
|
||||
private double medianY;
|
||||
private Flow.Subscriber<? super Data> subscriber;
|
||||
private Flow.Subscriber<? super Message> subscriber;
|
||||
private AbstractPresenter presenter;
|
||||
private Map<String, Object> parameter;
|
||||
|
||||
public NaiveRepeatedMedianEstimator() {
|
||||
parameter = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Line call() {
|
||||
|
@ -90,7 +95,7 @@ public class NaivRepeatedMedianEstimator implements Algorithm {
|
|||
end = System.currentTimeMillis();
|
||||
Logging.logInfo("=== E N D - naiv R M ===");
|
||||
Logging.logInfo("Slope: " + getSlope() + ", y-Interception: " + getYInterception());
|
||||
AlgorithmData data = new AlgorithmData();
|
||||
AlgorithmMessage data = new AlgorithmMessage();
|
||||
data.setAlgorithmType(getType());
|
||||
data.setType(SubscriberType.ALGORITHM);
|
||||
data.setLineData(new Line(getSlope(), getYInterception()));
|
||||
|
@ -144,6 +149,16 @@ public class NaivRepeatedMedianEstimator implements Algorithm {
|
|||
return new Point(m, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getParameter() {
|
||||
return this.parameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(Map<String, Object> parameter) {
|
||||
this.parameter = parameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Steigung
|
||||
*/
|
||||
|
@ -159,7 +174,7 @@ public class NaivRepeatedMedianEstimator implements Algorithm {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
||||
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||
this.subscriber = subscriber;
|
||||
}
|
||||
}
|
|
@ -1,15 +1,17 @@
|
|||
package de.wwwu.awolf.presenter.algorithms.naiv;
|
||||
package de.wwwu.awolf.presenter.algorithms.naive;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmData;
|
||||
import de.wwwu.awolf.model.communication.Data;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.model.communication.AlgorithmMessage;
|
||||
import de.wwwu.awolf.model.communication.Message;
|
||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
import de.wwwu.awolf.presenter.util.FastElementSelector;
|
||||
import de.wwwu.awolf.presenter.util.Logging;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Flow;
|
||||
|
||||
|
@ -20,15 +22,20 @@ import java.util.concurrent.Flow;
|
|||
* @Email: a_wolf28@uni-muenster.de
|
||||
* @Date: 15.09.2017.
|
||||
*/
|
||||
public class NaivTheilSenEstimator implements Algorithm {
|
||||
public class NaiveTheilSenEstimator implements Algorithm {
|
||||
|
||||
private static final Algorithm.Type type = Type.NAIVE_TS;
|
||||
|
||||
private List<Line> setOfLines;
|
||||
private double slope;
|
||||
private double yInterception;
|
||||
private Flow.Subscriber<? super Data> subscriber;
|
||||
private Flow.Subscriber<? super Message> subscriber;
|
||||
private AbstractPresenter presenter;
|
||||
private Map<String, Object> parameter;
|
||||
|
||||
public NaiveTheilSenEstimator() {
|
||||
parameter = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Line call() {
|
||||
|
@ -68,7 +75,7 @@ public class NaivTheilSenEstimator implements Algorithm {
|
|||
end = System.currentTimeMillis();
|
||||
Logging.logInfo("=== E N D - naiv T S ===");
|
||||
Logging.logInfo("Slope: " + getSlope() + ", y-Interception: " + getYInterception());
|
||||
AlgorithmData data = new AlgorithmData();
|
||||
AlgorithmMessage data = new AlgorithmMessage();
|
||||
data.setAlgorithmType(getType());
|
||||
data.setType(SubscriberType.ALGORITHM);
|
||||
data.setLineData(new Line(getSlope(), getYInterception()));
|
||||
|
@ -92,6 +99,16 @@ public class NaivTheilSenEstimator implements Algorithm {
|
|||
subscribe(presenter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getParameter() {
|
||||
return this.parameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(Map<String, Object> parameter) {
|
||||
this.parameter = parameter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Steigung
|
||||
|
@ -108,7 +125,7 @@ public class NaivTheilSenEstimator implements Algorithm {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
||||
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||
this.subscriber = subscriber;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package de.wwwu.awolf.presenter.data;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.communication.DataProviderMessage;
|
||||
import de.wwwu.awolf.model.communication.Message;
|
||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.AbstractPresenter;
|
||||
import de.wwwu.awolf.presenter.data.generator.CircleDatasetGenerator;
|
||||
import de.wwwu.awolf.presenter.data.generator.CloudDatasetGenerator;
|
||||
|
@ -13,19 +16,22 @@ import java.util.Collections;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorCompletionService;
|
||||
import java.util.concurrent.Flow;
|
||||
import java.util.concurrent.Flow.Subscriber;
|
||||
|
||||
public class DataHandler {
|
||||
public class DataHandler implements Flow.Publisher<Message> {
|
||||
|
||||
private final AbstractPresenter presenter;
|
||||
private Subscriber<? super Message> subscriber;
|
||||
|
||||
public DataHandler(AbstractPresenter presenter) {
|
||||
this.presenter = presenter;
|
||||
subscribe(presenter);
|
||||
}
|
||||
|
||||
public Set<Line> getData(final File file) {
|
||||
//Presenter soll die Klasse überwachen
|
||||
ExecutorCompletionService<Set<Line>> completionService = new ExecutorCompletionService<>(
|
||||
this.presenter.getExecutor());
|
||||
ExecutorCompletionService<Set<Line>> completionService = new ExecutorCompletionService<>(this.presenter.getExecutor());
|
||||
Logging.logDebug("Importing Data: " + file.getAbsolutePath());
|
||||
completionService.submit(new DataImporter(file));
|
||||
//wait until future is ready
|
||||
|
@ -35,14 +41,17 @@ public class DataHandler {
|
|||
Logging.logError("Interrupted while importing... ", e);
|
||||
Thread.currentThread().interrupt();
|
||||
return Collections.emptySet();
|
||||
} finally {
|
||||
DataProviderMessage message = new DataProviderMessage();
|
||||
message.setType(SubscriberType.DATA_PROVIDER);
|
||||
this.subscriber.onNext(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Set<Line> getData(final DataType type, final int dataSize) {
|
||||
//Presenter soll die Klasse überwachen
|
||||
ExecutorCompletionService<Set<Line>> completionService = new ExecutorCompletionService<>(
|
||||
this.presenter.getExecutor());
|
||||
ExecutorCompletionService<Set<Line>> completionService = new ExecutorCompletionService<>(this.presenter.getExecutor());
|
||||
Logging.logDebug("Generating Data: Size: " + dataSize + ", dataType: " + type.name());
|
||||
|
||||
switch (type) {
|
||||
|
@ -65,6 +74,10 @@ public class DataHandler {
|
|||
Logging.logError("Interrupted while generating... ", e);
|
||||
Thread.currentThread().interrupt();
|
||||
return Collections.emptySet();
|
||||
} finally {
|
||||
DataProviderMessage message = new DataProviderMessage();
|
||||
message.setType(SubscriberType.DATA_PROVIDER);
|
||||
this.subscriber.onNext(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +85,11 @@ public class DataHandler {
|
|||
this.presenter.getExecutor().submit(new DataExporter(lines, file));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(Subscriber<? super Message> subscriber) {
|
||||
this.subscriber = subscriber;
|
||||
}
|
||||
|
||||
|
||||
public enum DataType {
|
||||
CLOUD,
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.wwwu.awolf.presenter.data.generator;
|
|||
|
||||
import static de.wwwu.awolf.presenter.data.generator.DatasetGenerator.generateDataLines;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.presenter.data.generator;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.presenter.data.generator;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.presenter.data.generator;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.wwwu.awolf.presenter.data.io;
|
||||
|
||||
import com.opencsv.CSVWriter;
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.util.Logging;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.wwwu.awolf.presenter.data.io;
|
||||
|
||||
import com.opencsv.CSVReader;
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.util.Logging;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.presenter.evaluation;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.model.evaluation.ComparisonResult;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
import de.wwwu.awolf.presenter.algorithms.AlgorithmHandler;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package de.wwwu.awolf.presenter.evaluation;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.LineModel;
|
||||
import de.wwwu.awolf.model.communication.Data;
|
||||
import de.wwwu.awolf.model.communication.EvaluationData;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.model.dao.LineModel;
|
||||
import de.wwwu.awolf.model.communication.Message;
|
||||
import de.wwwu.awolf.model.communication.EvaluationMessage;
|
||||
import de.wwwu.awolf.model.communication.SubscriberType;
|
||||
import de.wwwu.awolf.model.evaluation.ComparisonResult;
|
||||
import de.wwwu.awolf.presenter.Presenter;
|
||||
|
@ -31,7 +31,7 @@ import java.util.concurrent.Flow;
|
|||
* @Email: a_wolf28@uni-muenster.de
|
||||
* @Date: 01.08.2017.
|
||||
*/
|
||||
public class EvaluatationHandler implements Runnable, Flow.Publisher<Data> {
|
||||
public class EvaluatationHandler implements Runnable, Flow.Publisher<Message> {
|
||||
|
||||
private LineModel arrangement;
|
||||
private DatasetGenerator generator;
|
||||
|
@ -40,7 +40,7 @@ public class EvaluatationHandler implements Runnable, Flow.Publisher<Data> {
|
|||
private int type;
|
||||
private int iterations;
|
||||
private int alg;
|
||||
private Flow.Subscriber<? super Data> subscriber;
|
||||
private Flow.Subscriber<? super Message> subscriber;
|
||||
private Map<Algorithm.Type, Map<String, String>> resultMapping;
|
||||
|
||||
/**
|
||||
|
@ -173,8 +173,8 @@ public class EvaluatationHandler implements Runnable, Flow.Publisher<Data> {
|
|||
*/
|
||||
private void sendTableApproximationData(Map<Algorithm.Type, Map<String, String>> result) {
|
||||
|
||||
EvaluationData data = new EvaluationData();
|
||||
data.setType(SubscriberType.EVALUATION_TABLE_DATA);
|
||||
EvaluationMessage data = new EvaluationMessage();
|
||||
data.setType(SubscriberType.EVALUATION);
|
||||
data.setMultipleColumnResult(result);
|
||||
data.setRowsPerColumn(result.keySet().size());
|
||||
this.subscriber.onNext(data);
|
||||
|
@ -276,7 +276,7 @@ public class EvaluatationHandler implements Runnable, Flow.Publisher<Data> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(Flow.Subscriber<? super Data> subscriber) {
|
||||
public void subscribe(Flow.Subscriber<? super Message> subscriber) {
|
||||
this.subscriber = subscriber;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.presenter.evaluation.measures;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.util.FastElementSelector;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.presenter.evaluation.measures;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.util.FastElementSelector;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.presenter.evaluation.measures;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.util.FastElementSelector;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.presenter.util.Comparators;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.presenter.util.Comparators;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package de.wwwu.awolf.presenter.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.Point;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.model.dao.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package de.wwwu.awolf.view;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.Presenter;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
import de.wwwu.awolf.presenter.algorithms.AlgorithmHandler;
|
||||
import de.wwwu.awolf.presenter.data.DataHandler;
|
||||
import de.wwwu.awolf.presenter.util.Logging;
|
||||
import de.wwwu.awolf.view.controller.AlgorithmTabController;
|
||||
|
@ -10,7 +11,6 @@ import de.wwwu.awolf.view.services.DataService;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
|
@ -56,22 +56,15 @@ public class ViewController {
|
|||
}
|
||||
|
||||
private void initTabbedPane() {
|
||||
//TODO
|
||||
Map<String, String> props = new HashMap<>();
|
||||
props.put("sfsdf", "dsadasd");
|
||||
props.put("dfd", "dsadasd");
|
||||
props.put("sdfdsfg", "dsadasd");
|
||||
props.put("dsfsdfsdf", "dsadasd");
|
||||
|
||||
AlgorithmHandler algorithmHandler = Presenter.getInstance().getAlgorithmHandler();
|
||||
try {
|
||||
for (Algorithm.Type value : Algorithm.Type.values()) {
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
loader.setLocation(
|
||||
AlgorithmTabController.class.getResource("/views/AlgorithmTab.fxml"));
|
||||
loader.setLocation(AlgorithmTabController.class.getResource("/views/AlgorithmTab.fxml"));
|
||||
Parent parent = loader.load();
|
||||
AlgorithmTabController controller = loader.getController();
|
||||
controller.setAlgorithmType(value);
|
||||
controller.setProperties(props);
|
||||
controller.setProperties(algorithmHandler.getAlgorithmParametersByType(value));
|
||||
controller.setModel(Presenter.getInstance().getModel());
|
||||
controller.init();
|
||||
this.algorithmTabControllers.put(value, controller);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.wwwu.awolf.view.controller;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.LineModel;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.model.dao.LineModel;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
import de.wwwu.awolf.view.services.ButtonClickService;
|
||||
import java.util.Map;
|
||||
|
@ -22,13 +22,14 @@ public class AlgorithmTabController {
|
|||
private final XYChart.Series<Double, Double> dataSerie;
|
||||
private final XYChart.Series<Double, Double> lineSerie;
|
||||
@FXML
|
||||
public LineChart<Double, Double> chart;
|
||||
private LineChart<Double, Double> chart;
|
||||
@FXML
|
||||
public VBox vBox;
|
||||
private VBox vBox;
|
||||
@FXML
|
||||
public Button startButton;
|
||||
private Button startButton;
|
||||
|
||||
private Algorithm.Type algorithmType;
|
||||
private Map<String, String> properties;
|
||||
private Map<String, Object> properties;
|
||||
private LineModel model;
|
||||
|
||||
public AlgorithmTabController() {
|
||||
|
@ -48,25 +49,27 @@ public class AlgorithmTabController {
|
|||
|
||||
public void init() {
|
||||
// add GUI elements to maintain the parameters
|
||||
properties.forEach((key, value) -> {
|
||||
//Pane component for the layout
|
||||
BorderPane borderPane = new BorderPane();
|
||||
borderPane.setPadding(new Insets(10, 0, 10, 0));
|
||||
if (properties != null) {
|
||||
properties.forEach((key, value) -> {
|
||||
//Pane component for the layout
|
||||
BorderPane borderPane = new BorderPane();
|
||||
borderPane.setPadding(new Insets(10, 0, 10, 0));
|
||||
|
||||
//text field for the input
|
||||
TextField textField = new TextField(value);
|
||||
//text field for the input
|
||||
TextField textField = new TextField(String.valueOf(value));
|
||||
|
||||
//label
|
||||
Label label = new Label(key);
|
||||
label.setAlignment(Pos.BASELINE_LEFT);
|
||||
label.setLabelFor(textField);
|
||||
label.setPadding(new Insets(2, 10, 0, 0));
|
||||
//label
|
||||
Label label = new Label(key);
|
||||
label.setAlignment(Pos.BASELINE_LEFT);
|
||||
label.setLabelFor(textField);
|
||||
label.setPadding(new Insets(2, 10, 0, 0));
|
||||
|
||||
//add components
|
||||
borderPane.setLeft(label);
|
||||
borderPane.setRight(textField);
|
||||
vBox.getChildren().add(borderPane);
|
||||
});
|
||||
//add components
|
||||
borderPane.setLeft(label);
|
||||
borderPane.setRight(textField);
|
||||
vBox.getChildren().add(borderPane);
|
||||
});
|
||||
}
|
||||
|
||||
BooleanProperty booleanProperty = startButton.disableProperty();
|
||||
startButton.setOnAction(event -> {
|
||||
|
@ -107,13 +110,15 @@ public class AlgorithmTabController {
|
|||
this.algorithmType = algorithmType;
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
public Map<String, Object> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, String> properties) {
|
||||
public void setProperties(Map<String, Object> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
|
||||
public Button getStartButton() {
|
||||
return startButton;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.view.services;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.Presenter;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
|
@ -12,7 +12,7 @@ public class ButtonClickService extends Service<Boolean> {
|
|||
private final BooleanProperty startButtonDisabled;
|
||||
private Algorithm.Type type;
|
||||
|
||||
public ButtonClickService(Algorithm.Type algorithmType, BooleanProperty startButtonDisabled) {
|
||||
public ButtonClickService(final Algorithm.Type algorithmType, final BooleanProperty startButtonDisabled) {
|
||||
this.startButtonDisabled = startButtonDisabled;
|
||||
this.type = algorithmType;
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@ public class DataService extends Service<Boolean> {
|
|||
private DataHandler.ActionType actionType;
|
||||
private int n;
|
||||
|
||||
public DataService(final DataHandler.ActionType actionType, final DataHandler.DataType type,
|
||||
final int n) {
|
||||
public DataService(final DataHandler.ActionType actionType, final DataHandler.DataType type, final int n) {
|
||||
this.type = type;
|
||||
this.actionType = actionType;
|
||||
this.n = n;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
de.wwwu.awolf.presenter.algorithms.advanced.LeastMedianOfSquaresEstimator
|
||||
de.wwwu.awolf.presenter.algorithms.advanced.RepeatedMedianEstimator
|
||||
de.wwwu.awolf.presenter.algorithms.advanced.TheilSenEstimator
|
||||
de.wwwu.awolf.presenter.algorithms.naiv.NaivLeastMedianOfSquaresEstimator
|
||||
de.wwwu.awolf.presenter.algorithms.naiv.NaivRepeatedMedianEstimator
|
||||
de.wwwu.awolf.presenter.algorithms.naiv.NaivTheilSenEstimator
|
||||
de.wwwu.awolf.presenter.algorithms.naive.NaiveLeastMedianOfSquaresEstimator
|
||||
de.wwwu.awolf.presenter.algorithms.naive.NaiveRepeatedMedianEstimator
|
||||
de.wwwu.awolf.presenter.algorithms.naive.NaiveTheilSenEstimator
|
|
@ -1,61 +1,54 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.chart.LineChart?>
|
||||
<?import javafx.scene.chart.NumberAxis?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.Cursor?>
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import javafx.scene.layout.FlowPane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<BorderPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="400.0" prefWidth="600.0"
|
||||
styleClass="algoPane" xmlns="http://javafx.com/javafx/10.0.2-internal"
|
||||
fx:controller="de.wwwu.awolf.view.controller.AlgorithmTabController">
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.chart.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<BorderPane prefHeight="400.0" prefWidth="600.0" styleClass="algoPane" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.wwwu.awolf.view.controller.AlgorithmTabController">
|
||||
<center>
|
||||
<LineChart BorderPane.alignment="CENTER" prefHeight="398.0" prefWidth="390.0" title="Plot"
|
||||
fx:id="chart">
|
||||
<LineChart fx:id="chart" prefHeight="398.0" prefWidth="390.0" title="Plot" BorderPane.alignment="CENTER">
|
||||
<xAxis>
|
||||
<NumberAxis label="X" side="BOTTOM">
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</padding>
|
||||
</NumberAxis>
|
||||
</xAxis>
|
||||
<yAxis>
|
||||
<NumberAxis label="Y" side="LEFT">
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</padding>
|
||||
</NumberAxis>
|
||||
</yAxis>
|
||||
</LineChart>
|
||||
</center>
|
||||
<left>
|
||||
<VBox BorderPane.alignment="CENTER" alignment="TOP_CENTER" prefHeight="200.0" prefWidth="200.0"
|
||||
fx:id="vBox">
|
||||
<VBox fx:id="vBox" alignment="TOP_CENTER" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<BorderPane.margin>
|
||||
<Insets left="10.0"/>
|
||||
<Insets left="10.0" />
|
||||
</BorderPane.margin>
|
||||
<children>
|
||||
</children>
|
||||
<cursor>
|
||||
<Cursor fx:constant="HAND"/>
|
||||
<Cursor fx:constant="HAND" />
|
||||
</cursor>
|
||||
<padding>
|
||||
<Insets top="10.0"/>
|
||||
<Insets top="10.0" />
|
||||
</padding>
|
||||
</VBox>
|
||||
</left>
|
||||
<top>
|
||||
<FlowPane BorderPane.alignment="CENTER" hgap="5.0" prefHeight="25.0" prefWidth="200.0">
|
||||
<FlowPane hgap="5.0" prefHeight="25.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<BorderPane.margin>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</BorderPane.margin>
|
||||
<children>
|
||||
<Button alignment="CENTER" contentDisplay="CENTER" defaultButton="true" pickOnBounds="false"
|
||||
text="Start" fx:id="startButton">
|
||||
<Button fx:id="startButton" alignment="CENTER" contentDisplay="CENTER" defaultButton="true" disable="true" pickOnBounds="false" text="Start">
|
||||
<cursor>
|
||||
<Cursor fx:constant="HAND"/>
|
||||
<Cursor fx:constant="HAND" />
|
||||
</cursor>
|
||||
</Button>
|
||||
</children>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.presenter.algorithms.advanced;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.presenter.algorithms.Algorithm;
|
||||
import de.wwwu.awolf.presenter.algorithms.AlgorithmHandler;
|
||||
import java.util.HashSet;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.wwwu.awolf.presenter.algorithms.advanced;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -2,8 +2,8 @@ package de.wwwu.awolf.presenter.util;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import de.wwwu.awolf.model.Line;
|
||||
import de.wwwu.awolf.model.LineModel;
|
||||
import de.wwwu.awolf.model.dao.Line;
|
||||
import de.wwwu.awolf.model.dao.LineModel;
|
||||
import java.util.ArrayList;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
Loading…
Reference in New Issue