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

de.learnlib.algorithm.observationpack.vpa.hypothesis.AbstractHypTrans Maven / Gradle / Ivy

Go to download

This artifact provides the implementation of the VPA adaption of the Observation-Pack learning algorithm as discussed in the PhD thesis "Foundations of Active Automata Learning: An Algorithmic Perspective" (https://dx.doi.org/10.17877/DE290R-16359) by Malte Isberner.

The newest version!
/* Copyright (C) 2013-2023 TU Dortmund
 * This file is part of LearnLib, http://www.learnlib.de/.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.learnlib.algorithm.observationpack.vpa.hypothesis;

import de.learnlib.AccessSequenceProvider;
import de.learnlib.datastructure.list.IntrusiveListElemImpl;
import net.automatalib.word.Word;

/**
 * @param 
 *         input symbol type
 */
public abstract class AbstractHypTrans extends IntrusiveListElemImpl>
        implements AccessSequenceProvider {

    private final Word aseq;
    protected IntrusiveListElemImpl> prev;
    private HypLoc treeTarget;
    private DTNode nonTreeTarget;

    public AbstractHypTrans(Word aseq) {
        this.aseq = aseq;
    }

    public HypLoc getTreeTarget() {
        assert isTree();
        return treeTarget;
    }

    public boolean isTree() {
        return treeTarget != null;
    }

    public HypLoc getTargetLocation() {
        if (treeTarget != null) {
            return treeTarget;
        }
        assert nonTreeTarget.isLeaf() : "transition does not point to a leaf";
        assert nonTreeTarget.getData() != null;
        return nonTreeTarget.getData();
    }

    public DTNode getNonTreeTarget() {
        assert !isTree();
        return nonTreeTarget;
    }

    public void setNonTreeTarget(DTNode nonTreeTarget) {
        assert !isTree();
        this.nonTreeTarget = nonTreeTarget;
    }

    public DTNode getTargetNode() {
        if (treeTarget != null) {
            return treeTarget.getLeaf();
        }
        return nonTreeTarget;
    }

    @Override
    public Word getAccessSequence() {
        return aseq;
    }

    public void makeTree(HypLoc tgtLoc) {
        assert !isTree();
        this.treeTarget = tgtLoc;
        this.nonTreeTarget = null;
        removeFromList();
    }

    public void removeFromList() {
        if (next != null) {
            next.prev = prev;
        }
        if (prev != null) {
            prev.setNextElement(next);
        }
        prev = null;
        next = null;
    }
}