summaryrefslogtreecommitdiffstats
path: root/examples/examples-adaptive/src
diff options
context:
space:
mode:
Diffstat (limited to 'examples/examples-adaptive/src')
-rw-r--r--examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AnomalyDetection.java88
-rw-r--r--examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AutoLearn.java41
-rw-r--r--examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelSaver.java11
-rw-r--r--examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AnomalyDetectionPolicyDecideTaskSelectionLogic.java5
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java5
5 files changed, 22 insertions, 128 deletions
diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AnomalyDetection.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AnomalyDetection.java
index b0cff91d0..10c3610ba 100644
--- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AnomalyDetection.java
+++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AnomalyDetection.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (c) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,11 +27,17 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
/**
* The Class AnomalyDetection is used as a Java context for Adaptive anomaly detection in the adaptive domain.
*/
+@Getter
+@Setter
@EqualsAndHashCode
+@ToString
public class AnomalyDetection implements Serializable {
private static final long serialVersionUID = -823013127095523727L;
@@ -70,60 +77,6 @@ public class AnomalyDetection implements Serializable {
}
/**
- * Indicates if this is the first round of the algorithm.
- *
- * @return true if this is the first round of the algorithm
- */
- public boolean getFirstRound() {
- return firstRound;
- }
-
- /**
- * Sets the first round indicator of the algorithm.
- *
- * @param firstRound the first round indicator of the algorithm
- */
- public void setFirstRound(final boolean firstRound) {
- this.firstRound = firstRound;
- }
-
- /**
- * Gets the frequency value of the algorithm.
- *
- * @return the frequency value of the algorithm
- */
- public int getFrequency() {
- return frequency;
- }
-
- /**
- * Sets the frequency value of the algorithm.
- *
- * @param frequency the frequency value of the algorithm
- */
- public void setFrequency(final int frequency) {
- this.frequency = frequency;
- }
-
- /**
- * Gets the anomaly score values of the algorithm.
- *
- * @return the anomaly score values of the algorithm
- */
- public List<Double> getAnomalyScores() {
- return anomalyScores;
- }
-
- /**
- * Sets the anomaly score values of the algorithm.
- *
- * @param anomalyScores the anomaly score values of the algorithm
- */
- public void setAnomalyScores(final List<Double> anomalyScores) {
- this.anomalyScores = anomalyScores;
- }
-
- /**
* Check if the anomaly score values of the algorithm are set.
*
* @return true, if the anomaly score values of the algorithm are set
@@ -140,24 +93,6 @@ public class AnomalyDetection implements Serializable {
}
/**
- * Gets the frequency forecasted by the algorithm.
- *
- * @return the frequency forecasted by the algorithm
- */
- public List<Double> getFrequencyForecasted() {
- return frequencyForecasted;
- }
-
- /**
- * Sets the frequency forecasted by the algorithm.
- *
- * @param frequencyForecasted the frequency forecasted by the algorithm
- */
- public void setFrequencyForecasted(final List<Double> frequencyForecasted) {
- this.frequencyForecasted = frequencyForecasted;
- }
-
- /**
* Check if the frequency forecasted by the algorithm is set.
*
* @return true, if the frequency forecasted by the algorithm is set
@@ -172,13 +107,4 @@ public class AnomalyDetection implements Serializable {
public void unsetFrequencyForecasted() {
frequencyForecasted = null;
}
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- return "AnomalyDetection [firstRound=" + firstRound + ", frequency=" + frequency + ", anomalyScores="
- + anomalyScores + ", frequencyForecasted=" + frequencyForecasted + "]";
- }
}
diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AutoLearn.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AutoLearn.java
index 60c4d96d9..1760f910d 100644
--- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AutoLearn.java
+++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AutoLearn.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (c) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,12 +26,16 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
import lombok.ToString;
/**
* The Class AutoLearn is used as a Java context for Adaptive auto-learning of trends towards a fixed value in the
* adaptive domain.
*/
+@Getter
+@Setter
@EqualsAndHashCode
@ToString
public class AutoLearn implements Serializable {
@@ -71,24 +76,6 @@ public class AutoLearn implements Serializable {
}
/**
- * Gets the average difference values of the algorithm.
- *
- * @return the average difference values of the algorithm
- */
- public List<Double> getAvDiffs() {
- return avDiffs;
- }
-
- /**
- * Sets the average difference values of the algorithm.
- *
- * @param avDiffs the average difference values of the algorithm
- */
- public void setAvDiffs(final List<Double> avDiffs) {
- this.avDiffs = avDiffs;
- }
-
- /**
* Check if the average difference values of the algorithm are set.
*
* @return true, if check set av diffs
@@ -105,24 +92,6 @@ public class AutoLearn implements Serializable {
}
/**
- * Gets the count values of the algorithm.
- *
- * @return the count values of the algorithm
- */
- public List<Long> getCounts() {
- return counts;
- }
-
- /**
- * Sets the count values of the algorithm.
- *
- * @param counts the count values of the algorithm
- */
- public void setCounts(final List<Long> counts) {
- this.counts = counts;
- }
-
- /**
* Check if the count values of the algorithm are set.
*
* @return true, if the count values of the algorithm are set
diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelSaver.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelSaver.java
index 83a42ac8d..0ebff497c 100644
--- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelSaver.java
+++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelSaver.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,8 @@
package org.onap.policy.apex.examples.adaptive.model;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelSaver;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
@@ -32,18 +35,12 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class AdaptiveDomainModelSaver {
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(AdaptiveDomainModelSaver.class);
/**
- * Private default constructor to prevent subclassing.
- */
- private AdaptiveDomainModelSaver() {
- // Prevent subclassing
- }
-
- /**
* Write the AADM model to args[0].
*
* @param args Not used
diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AnomalyDetectionPolicyDecideTaskSelectionLogic.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AnomalyDetectionPolicyDecideTaskSelectionLogic.java
index 6b61e822b..e059c9810 100644
--- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AnomalyDetectionPolicyDecideTaskSelectionLogic.java
+++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AnomalyDetectionPolicyDecideTaskSelectionLogic.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -144,7 +145,7 @@ public class AnomalyDetectionPolicyDecideTaskSelectionLogic {
}
anomalyDetection.setFrequency(frequency);
- if (unsetfirstround && anomalyDetection.getFirstRound()) {
+ if (unsetfirstround && anomalyDetection.isFirstRound()) {
anomalyDetection.setFirstRound(false);
}
@@ -160,7 +161,7 @@ public class AnomalyDetectionPolicyDecideTaskSelectionLogic {
anomalyDetection.getFrequencyForecasted().set(frequency, forecastedValue);
// anomaly score is ignored in the first frequency period
- if (!anomalyDetection.getFirstRound()) {
+ if (!anomalyDetection.isFirstRound()) {
((LinkedList<Double>) anomalyDetection.getAnomalyScores()).addLast(anomalyScore);
}
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java
index d24733224..1237537fd 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (c) 2020 Nordix Foundation.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +45,8 @@ public class AnomalyDetectionConceptTest {
assertEquals(newAnomalyScores, anomalyDetection.getAnomalyScores());
assertTrue(anomalyDetection.checkSetAnomalyScores());
assertEquals(55, anomalyDetection.getFrequency());
- assertEquals(true, anomalyDetection.getFirstRound());
- assertEquals("AnomalyDetection [firstRound=true, frequency=55, anomalyScores=[55.0], frequencyForecasted=null]",
+ assertEquals(true, anomalyDetection.isFirstRound());
+ assertEquals("AnomalyDetection(firstRound=true, frequency=55, anomalyScores=[55.0], frequencyForecasted=null)",
anomalyDetection.toString());
}