All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dmg.pmml.time_series.StateSpaceModel Maven / Gradle / Ivy

There is a newer version: 1.6.6
Show newest version

package org.dmg.pmml.time_series;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
import org.dmg.pmml.Extension;
import org.dmg.pmml.HasExtensions;
import org.dmg.pmml.PMMLObject;
import org.dmg.pmml.Visitor;
import org.dmg.pmml.VisitorAction;
import org.dmg.pmml.adapters.ObjectAdapter;
import org.dmg.pmml.adapters.RealNumberAdapter;
import org.jpmml.model.annotations.Added;
import org.jpmml.model.annotations.Property;

@XmlRootElement(name = "StateSpaceModel", namespace = "http://www.dmg.org/PMML-4_4")
@XmlType(name = "", propOrder = {
    "extensions",
    "stateVector",
    "transitionMatrix",
    "measurementMatrix",
    "psiVector",
    "dynamicRegressors"
})
@Added((org.dmg.pmml.Version.PMML_4_4))
@JsonRootName("StateSpaceModel")
@JsonPropertyOrder({
    "variance",
    "period",
    "intercept",
    "extensions",
    "stateVector",
    "transitionMatrix",
    "measurementMatrix",
    "psiVector",
    "dynamicRegressors"
})
public class StateSpaceModel
    extends TimeSeriesAlgorithm
    implements HasExtensions
{

    @XmlAttribute(name = "variance")
    @XmlJavaTypeAdapter(RealNumberAdapter.class)
    @JsonProperty("variance")
    private Number variance;
    @XmlAttribute(name = "period")
    @XmlJavaTypeAdapter(ObjectAdapter.class)
    @XmlSchemaType(name = "anySimpleType")
    @JsonProperty("period")
    private Object period;
    @XmlAttribute(name = "intercept")
    @XmlJavaTypeAdapter(RealNumberAdapter.class)
    @JsonProperty("intercept")
    private Number intercept;
    @XmlElement(name = "Extension", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("Extension")
    private List extensions;
    @XmlElement(name = "StateVector", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("StateVector")
    private StateVector stateVector;
    @XmlElement(name = "TransitionMatrix", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("TransitionMatrix")
    private TransitionMatrix transitionMatrix;
    @XmlElement(name = "MeasurementMatrix", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("MeasurementMatrix")
    private MeasurementMatrix measurementMatrix;
    @XmlElement(name = "PsiVector", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("PsiVector")
    private PsiVector psiVector;
    @XmlElement(name = "DynamicRegressor", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("DynamicRegressor")
    private List dynamicRegressors;
    private final static Object DEFAULT_PERIOD = new ObjectAdapter().unmarshal("none");
    private final static Number DEFAULT_INTERCEPT = new RealNumberAdapter().unmarshal("0");
    private final static long serialVersionUID = 67371010L;

    public Number getVariance() {
        return variance;
    }

    public StateSpaceModel setVariance(
        @Property("variance")
        Number variance) {
        this.variance = variance;
        return this;
    }

    public Object getPeriod() {
        if (period == null) {
            return DEFAULT_PERIOD;
        } else {
            return period;
        }
    }

    public StateSpaceModel setPeriod(
        @Property("period")
        Object period) {
        this.period = period;
        return this;
    }

    public Number getIntercept() {
        if (intercept == null) {
            return DEFAULT_INTERCEPT;
        } else {
            return intercept;
        }
    }

    public StateSpaceModel setIntercept(
        @Property("intercept")
        Number intercept) {
        this.intercept = intercept;
        return this;
    }

    @Override
    public boolean hasExtensions() {
        return ((this.extensions!= null)&&(this.extensions.size()> 0));
    }

    @Override
    public List getExtensions() {
        if (extensions == null) {
            extensions = new ArrayList();
        }
        return this.extensions;
    }

    @Override
    public StateSpaceModel addExtensions(Extension... extensions) {
        getExtensions().addAll(Arrays.asList(extensions));
        return this;
    }

    public StateVector getStateVector() {
        return stateVector;
    }

    public StateSpaceModel setStateVector(
        @Property("stateVector")
        StateVector stateVector) {
        this.stateVector = stateVector;
        return this;
    }

    public TransitionMatrix getTransitionMatrix() {
        return transitionMatrix;
    }

    public StateSpaceModel setTransitionMatrix(
        @Property("transitionMatrix")
        TransitionMatrix transitionMatrix) {
        this.transitionMatrix = transitionMatrix;
        return this;
    }

    public MeasurementMatrix getMeasurementMatrix() {
        return measurementMatrix;
    }

    public StateSpaceModel setMeasurementMatrix(
        @Property("measurementMatrix")
        MeasurementMatrix measurementMatrix) {
        this.measurementMatrix = measurementMatrix;
        return this;
    }

    public PsiVector getPsiVector() {
        return psiVector;
    }

    public StateSpaceModel setPsiVector(
        @Property("psiVector")
        PsiVector psiVector) {
        this.psiVector = psiVector;
        return this;
    }

    public boolean hasDynamicRegressors() {
        return ((this.dynamicRegressors!= null)&&(this.dynamicRegressors.size()> 0));
    }

    public List getDynamicRegressors() {
        if (dynamicRegressors == null) {
            dynamicRegressors = new ArrayList();
        }
        return this.dynamicRegressors;
    }

    public StateSpaceModel addDynamicRegressors(DynamicRegressor... dynamicRegressors) {
        getDynamicRegressors().addAll(Arrays.asList(dynamicRegressors));
        return this;
    }

    @Override
    public VisitorAction accept(Visitor visitor) {
        VisitorAction status = visitor.visit(this);
        if (status == VisitorAction.CONTINUE) {
            visitor.pushParent(this);
            if ((status == VisitorAction.CONTINUE)&&hasExtensions()) {
                status = PMMLObject.traverse(visitor, getExtensions());
            }
            if (status == VisitorAction.CONTINUE) {
                status = PMMLObject.traverse(visitor, getStateVector(), getTransitionMatrix(), getMeasurementMatrix(), getPsiVector());
            }
            if ((status == VisitorAction.CONTINUE)&&hasDynamicRegressors()) {
                status = PMMLObject.traverse(visitor, getDynamicRegressors());
            }
            visitor.popParent();
        }
        if (status == VisitorAction.TERMINATE) {
            return VisitorAction.TERMINATE;
        }
        return VisitorAction.CONTINUE;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy