Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 10 commits
  • 5 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jan 16, 2013
@westerholz westerholz Implementierung get Expected Values ecd1101
Commits on Jan 17, 2013
@westerholz westerholz Zeitreihenbreinigung angepassst faa2abe
Commits on Jan 18, 2013
@westerholz westerholz Pre Test Erwartungswerte c173524
@westerholz westerholz Merged with Master#2 f978f95
@westerholz westerholz merged with master too often.... 95faf16
@westerholz westerholz Callback ocomplete eingefügt. 295c2c6
@westerholz westerholz Master merged 6615147
@westerholz westerholz Merge remote-tracking branch 'origin/master' into
ErwartungswerteCashFlow

Conflicts:
	.settings/com.vaadin.integration.eclipse.prefs
	src/main/java/dhbw/ka/mwi/businesshorizon2/methods/random/RandomWalk.java
	src/main/java/dhbw/ka/mwi/businesshorizon2/ui/process/method/MethodPresenter.java
43737c2
@westerholz westerholz Deletion prefs Datei 0e7af70
@extr3m0 extr3m0 Merge pull request #31 from DHBW-Karlsruhe/ErwartungswerteCashFlow
Erwartungswerte cash flow
4383a19
View
5 .settings/com.vaadin.integration.eclipse.prefs
@@ -1,5 +0,0 @@
-com.vaadin.integration.eclipse.useLatestNightly=false
-com.vaadin.integration.eclipse.widgetsetBuildsSuspended=true
-com.vaadin.integration.eclipse.widgetsetCompilationEta=417131
-com.vaadin.integration.eclipse.widgetsetDirty=false
-eclipse.preferences.version=1
View
1  src/main/java/dhbw/ka/mwi/businesshorizon2/methods/random/RandomWalk.java
@@ -107,6 +107,7 @@ public StochasticResultContainer calculate(Project project,
callback.onComplete(src);
}
return src;
+
}
}
View
50 src/main/java/dhbw/ka/mwi/businesshorizon2/methods/timeseries/AnalysisTimeseries.java
@@ -153,9 +153,12 @@ private double calculateMatrixVariance(double[] timeseries) {
* @return geglaetteter Prognosewert
*/
private double calculateARModel(int consideredPeriodsOfPast, int forecast,
- DoubleMatrix2D valuations, double[] previousValues) {
+ DoubleMatrix2D valuations, double[] previousValues)
+ throws StochasticMethodException {
if (this.equalizedValues[forecast - 1] == 0) {
-
+ if (valuations == null) {
+ valuations = calculateValuations(consideredPeriodsOfPast);
+ }
double equalizedValuePerPeriod = 0;
for (int past = 1; past <= consideredPeriodsOfPast; past++) {
double previousValue;
@@ -267,4 +270,47 @@ private double calculateARModel(int consideredPeriodsOfPast, int forecast,
return returnValues;
}
+ public double[] getExpectedValues(double[] previousValues,
+ int consideredPeriodsOfPast, int periodsToForecast)
+ throws StochasticMethodException {
+
+ double[] expectedValues = new double[periodsToForecast];
+ CalculateTide tide = new CalculateTide();
+ boolean isStationary = StationaryTest.isStationary(previousValues);
+ if (!isStationary) {
+ previousValues = tide.reduceTide(previousValues);
+ }
+ /**
+ * Uebertragung der Werte der Zeitreihe in eine DoubleArrayList. Diese
+ * wird von der COLT Bibliothek verwendet zur Loesung der Matrix.
+ */
+
+ this.DoubleArrayListTimeseries = new DoubleArrayList();
+ for (int i = 0; i < previousValues.length; i++) {
+ this.DoubleArrayListTimeseries.add(previousValues[i]);
+ }
+
+ // Start der zur Prognose benoetigten Berechnungen
+ this.mean = Descriptive.mean(DoubleArrayListTimeseries);
+ this.variance = this.calculateVariance(this.DoubleArrayListTimeseries);
+
+ this.yuleWalkerVariance = this.calculateMatrixVariance(previousValues);
+
+ this.equalizedValues = new double[periodsToForecast];
+
+ for (int forecast = 0; forecast < expectedValues.length; forecast++) {
+ if (!isStationary) {
+ double newTide = tide.getTideValue(forecast
+ + previousValues.length - 1);
+ expectedValues[forecast] = (double) ((newTide - calculateARModel(
+ consideredPeriodsOfPast, forecast, matrixValutaions,
+ previousValues)));
+ } else {
+ expectedValues[forecast] = (double) (calculateARModel(
+ consideredPeriodsOfPast, forecast, matrixValutaions,
+ previousValues));
+ }
+ }
+ return expectedValues;
+ }
}
View
55 src/main/java/dhbw/ka/mwi/businesshorizon2/methods/timeseries/TimeseriesCalculator.java
@@ -45,6 +45,57 @@ public int getOrderKey() {
return 1;
}
+ public StochasticResultContainer calculateExpectedValues(Project project)
+ throws StochasticMethodException {
+
+ TreeSet<AbstractPeriodContainer> resultPeriods = new TreeSet<AbstractPeriodContainer>();
+ StochasticResultContainer resultContainer = null;
+
+ /**
+ * Die Zeitreihenanalyse kann nur durchgefuehrt werden, wenn die Anzahl
+ * der beruecksichtigten Vergangenheitsperioden kleiner ist als die
+ * Anzahl der eingegebenen Vergangenheitsperioden
+ */
+ if (project.getRelevantPastPeriods() > project.getPeriods().size() - 1) {
+ logger.debug("Anzahl der betrachteten Perioden der Vergangenheit ist zu groß!");
+ throw new ConsideredPeriodsOfPastException(
+ "Die Anzahl der betrachteten Perioden der Vergangenheit muss kleiner sein als die Azahl der beobachteten Perioden.");
+ }
+
+ if (project.getPeriods().first() instanceof CashFlowPeriod) {
+ // Nachfolgend wird die Zeitreihenanalyse fuer CashFlowPerioden
+ // ausgefuehrt
+ TreeSet<? super CashFlowPeriodContainer> cFResultContainer = resultPeriods;
+
+ double[] previousValues = new double[project.getPeriods().size()];
+ AnalysisTimeseries timeseries = new AnalysisTimeseries();
+ int counter = 0;
+
+ // Umwandlung der Perioden in ein Double-Arrays
+ for (CashFlowPeriod cFPeriod : (TreeSet<CashFlowPeriod>) project
+ .getPeriods()) {
+ previousValues[counter] = cFPeriod.getFreeCashFlow();
+ counter++;
+ }
+
+ double[] expectedValues = timeseries.getExpectedValues(
+ previousValues, project.getRelevantPastPeriods(),
+ project.getPeriodsToForecast());
+ CashFlowPeriodContainer cFContainer = new CashFlowPeriodContainer();
+ for (int i = 0; i < expectedValues.length; i++) {
+ CashFlowPeriod cfPeriod = new CashFlowPeriod(
+ project.getBasisYear() + (i + 1));
+ cfPeriod.setFreeCashFlow(expectedValues[i]);
+ cFContainer.getPeriods().add(cfPeriod);
+ }
+ TreeSet<CashFlowPeriodContainer> periodContainer = new TreeSet<CashFlowPeriodContainer>();
+ periodContainer.add(cFContainer);
+ resultContainer = new StochasticResultContainer(periodContainer);
+ }
+ return resultContainer;
+
+ }
+
/**
* @author Kai Westerholz
*/
@@ -492,7 +543,9 @@ public StochasticResultContainer calculate(Project project,
resultContainer = new StochasticResultContainer(resultPeriods);
}
-
+ if (callback != null) {
+ callback.onComplete(resultContainer);
+ }
return resultContainer;
}
View
191 src/main/java/dhbw/ka/mwi/businesshorizon2/ui/process/method/MethodPresenter.java
@@ -11,213 +11,204 @@
import com.mvplite.event.EventBus;
import com.mvplite.event.EventHandler;
-
-import dhbw.ka.mwi.businesshorizon2.models.Project;
-import dhbw.ka.mwi.businesshorizon2.ui.process.ScreenPresenter;
-import dhbw.ka.mwi.businesshorizon2.ui.process.ScreenSelectableEvent;
-import dhbw.ka.mwi.businesshorizon2.ui.process.ShowErrorsOnScreenEvent;
-import dhbw.ka.mwi.businesshorizon2.ui.process.ValidStateEvent;
-import dhbw.ka.mwi.businesshorizon2.ui.process.ValidateContentStateEvent;
-import dhbw.ka.mwi.businesshorizon2.services.proxies.ProjectProxy;
-import dhbw.ka.mwi.businesshorizon2.ui.process.method.CheckMethodTypeEvent;
-import dhbw.ka.mwi.businesshorizon2.ui.process.navigation.NavigationSteps;
import dhbw.ka.mwi.businesshorizon2.methods.AbstractStochasticMethod;
import dhbw.ka.mwi.businesshorizon2.methods.random.RandomWalk;
import dhbw.ka.mwi.businesshorizon2.methods.timeseries.TimeseriesCalculator;
import dhbw.ka.mwi.businesshorizon2.methods.wiener.Wiener;
import dhbw.ka.mwi.businesshorizon2.models.InputType;
-
+import dhbw.ka.mwi.businesshorizon2.models.Project;
import dhbw.ka.mwi.businesshorizon2.models.ProjectInputType;
+import dhbw.ka.mwi.businesshorizon2.services.proxies.ProjectProxy;
import dhbw.ka.mwi.businesshorizon2.ui.process.InvalidStateEvent;
+import dhbw.ka.mwi.businesshorizon2.ui.process.ScreenPresenter;
+import dhbw.ka.mwi.businesshorizon2.ui.process.ScreenSelectableEvent;
+import dhbw.ka.mwi.businesshorizon2.ui.process.ShowErrorsOnScreenEvent;
+import dhbw.ka.mwi.businesshorizon2.ui.process.ValidStateEvent;
+import dhbw.ka.mwi.businesshorizon2.ui.process.ValidateContentStateEvent;
+import dhbw.ka.mwi.businesshorizon2.ui.process.navigation.NavigationSteps;
/**
- * Der Presenter fuer die Maske des Prozessschrittes zur Auswahl der Berechnungsmethoden.
+ * Der Presenter fuer die Maske des Prozessschrittes zur Auswahl der
+ * Berechnungsmethoden.
*
* @author Julius Hacker
- *
+ *
*/
-
+
public class MethodPresenter extends ScreenPresenter<MethodViewInterface> {
-
+
private static final long serialVersionUID = 1L;
-
private Logger logger = Logger.getLogger(MethodPresenter.class);
- private Boolean showError = false;
+ private Boolean showError = false;
@Autowired
private EventBus eventBus;
@Autowired
private ProjectProxy projectProxy;
-
+
private Project project;
-
+
private SortedSet<AbstractStochasticMethod> methods;
private ProjectInputType projectInputType;
-
-
/**
- * Dies ist der Konstruktor, der von Spring nach der Initialierung der Dependencies
- * aufgerufen wird. Er registriert lediglich sich selbst als einen EventHandler.
+ * Dies ist der Konstruktor, der von Spring nach der Initialierung der
+ * Dependencies aufgerufen wird. Er registriert lediglich sich selbst als
+ * einen EventHandler.
*
* @author Julius Hacker
*/
@PostConstruct
public void init() {
eventBus.addHandler(this);
+
logger.debug("test");
methods = new TreeSet<AbstractStochasticMethod>();
-
+
}
@Override
- public boolean isValid() {
+ public boolean isValid() {
boolean valid = false;
if (projectInputType.getStochastic()) {
-
- for (AbstractStochasticMethod m: methods){
+
+ for (AbstractStochasticMethod m : methods) {
if (m.getSelected()) {
valid = true;
}
-
+
}
-
- if (showError){
+
+ if (showError) {
getView().showErrorNoMethodSelected(valid);
}
-
- } else if (projectInputType.getDeterministic()){
-
- valid = true;
-
- if (showError){
+
+ } else if (projectInputType.getDeterministic()) {
+
+ valid = true;
+
+ if (showError) {
getView().showErrorNothingSelected(valid);
}
}
-
+
return valid;
}
-
- public void toggleMethodType(Boolean stochastic,Boolean checked){
- eventBus.fireEvent(new CheckMethodTypeEvent(stochastic,checked));
-
-
+ public void toggleMethodType(Boolean stochastic, Boolean checked) {
+ eventBus.fireEvent(new CheckMethodTypeEvent(stochastic, checked));
+
getView().showInputMethodSelection(stochastic, checked);
-
- if (stochastic){
+
+ if (stochastic) {
projectInputType.setStochastic(checked);
getView().enableMethodSelection(checked);
-
- }
- else if (!stochastic){
+
+ } else if (!stochastic) {
projectInputType.setDeterministic(checked);
}
-
+
this.validate(new ValidateContentStateEvent());
}
-
- public void toggleMethod(Set<AbstractStochasticMethod> checkedMethods){
+
+ public void toggleMethod(Set<AbstractStochasticMethod> checkedMethods) {
eventBus.fireEvent(new CheckMethodEvent(checkedMethods));
-
- for (AbstractStochasticMethod m : methods){
+
+ for (AbstractStochasticMethod m : methods) {
m.setSelected(false);
- if (checkedMethods.contains(m)){
+ if (checkedMethods.contains(m)) {
m.setSelected(true);
}
-
+
}
this.validate(new ValidateContentStateEvent());
}
-
- public void toggleMethodTypeInput(Boolean stochastic, InputType newSelected){
+
+ public void toggleMethodTypeInput(Boolean stochastic, InputType newSelected) {
eventBus.fireEvent(new InputTypeChangedEvent());
- if (stochastic){
+ if (stochastic) {
projectInputType.setStochasticInput(newSelected);
- }
- else{
+ } else {
projectInputType.setDeterministicInput(newSelected);
- }
+ }
}
-
+
@EventHandler
- public void onShowMethod(ShowMethodViewEvent event){
-
+ public void onShowMethod(ShowMethodViewEvent event) {
+
project = projectProxy.getSelectedProject();
-
+
if (project.getMethods() == null) {
-
+
methods.add(new RandomWalk());
methods.add(new TimeseriesCalculator());
methods.add(new Wiener());
-
- project.setMethods(methods);
- }
- else{
+
+ project.setMethods(methods);
+ } else {
methods = project.getMethods();
}
-
- if (project.getProjectInputType() == null){
+
+ if (project.getProjectInputType() == null) {
projectInputType = new ProjectInputType();
project.setProjectInputType(projectInputType);
- }
- else{
+ } else {
projectInputType = project.getProjectInputType();
}
-
+
for (AbstractStochasticMethod m : methods) {
getView().showMethod(m);
}
-
+
Boolean state = projectInputType.getStochastic();
-
- if (state != null){
+
+ if (state != null) {
getView().enableMethodSelection(state);
- }
- else{
+ } else {
projectInputType.setStochastic(false);
getView().enableMethodSelection(false);
}
-
- getView().showInputMethodSelection(true, projectInputType.getStochastic());
- getView().showInputMethodSelection(false, projectInputType.getDeterministic());
- getView().selectInput(true, projectInputType.getStochasticInput().getCaption());
- getView().selectInput(false, projectInputType.getDeterministicInput().getCaption());
-
- eventBus.fireEvent(new ScreenSelectableEvent(NavigationSteps.METHOD,true));
-
+
+ getView().showInputMethodSelection(true,
+ projectInputType.getStochastic());
+ getView().showInputMethodSelection(false,
+ projectInputType.getDeterministic());
+ getView().selectInput(true,
+ projectInputType.getStochasticInput().getCaption());
+ getView().selectInput(false,
+ projectInputType.getDeterministicInput().getCaption());
+
+ eventBus.fireEvent(new ScreenSelectableEvent(NavigationSteps.METHOD,
+ true));
+
}
-
-
-
@Override
- @EventHandler
+ @EventHandler
public void validate(ValidateContentStateEvent event) {
- if (!this.isValid()){
- eventBus.fireEvent(new InvalidStateEvent(NavigationSteps.METHOD,showError));
- }
- else {
+ if (!this.isValid()) {
+ eventBus.fireEvent(new InvalidStateEvent(NavigationSteps.METHOD,
+ showError));
+ } else {
eventBus.fireEvent(new ValidStateEvent(NavigationSteps.METHOD));
}
-
+
}
-
@EventHandler
@Override
public void handleShowErrors(ShowErrorsOnScreenEvent event) {
- if (event.getStep()==NavigationSteps.METHOD){
+ if (event.getStep() == NavigationSteps.METHOD) {
showError = true;
}
-
+
}
-
+
}

No commit comments for this range

Something went wrong with that request. Please try again.