/*
 * AutoCorrelatedBranchRatesDistribution.java
 *
 * Copyright (c) 2002-2019 Alexei Drummond, Andrew Rambaut and Marc Suchard
 *
 * This file is part of BEAST.
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership and licensing.
 *
 * BEAST is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 *  BEAST is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with BEAST; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA  02110-1301  USA
 */

package dr.evomodel.branchratemodel;

import dr.inference.distribution.shrinkage.BayesianBridgeDistributionModel;
import dr.inference.distribution.shrinkage.BayesianBridgeStatisticsProvider;
import dr.inference.model.*;

/**
 * @author Marc A. Suchard
 * @author Alexander Fisher
 */
public class BayesianBridgeAutoCorrelatedBranchRates extends AutoCorrelatedBranchRatesDistribution
        implements BayesianBridgeStatisticsProvider {

    private final BayesianBridgeDistributionModel distribution;

    public BayesianBridgeAutoCorrelatedBranchRates(String name,
                                                   DifferentiableBranchRates branchRateModel,
                                                   BayesianBridgeDistributionModel distribution,
                                                   BranchVarianceScaling scaling,
                                                   boolean takeLogBeforeIncrement, boolean operateOnIncrements) {
        super(name, branchRateModel, distribution, scaling, takeLogBeforeIncrement, operateOnIncrements);
        this.distribution = distribution;
    }

    @Override
    public double getCoefficient(int i) {
        return getIncrement(i);
    }

    @Override
    public Parameter getGlobalScale() {
        return distribution.getGlobalScale();
    }

    @Override
    public Parameter getLocalScale() {
        return distribution.getLocalScale();
    }

    @Override
    public Parameter getExponent() {
        return distribution.getExponent();
    }

    @Override
    public Parameter getSlabWidth() {
        return distribution.getSlabWidth();
    }
}

@@ -1047,16 +1047,139 @@
 model;%0A%0A
+import dr.evolution.tree.MutableTreeModel;%0Aimport dr.evolution.tree.TreeTrait;%0Aimport dr.evomodel.tree.TreeParameterModel;%0A
 import d
@@ -1242,24 +1242,24 @@
 utionModel;%0A
-
 import dr.in
@@ -1633,16 +1633,73 @@
 ibution;
+%0A    private final TreeParameterModel treeParameterModel;
 %0A%0A    pu
@@ -2249,16 +2249,16 @@
 ments);%0A
-
         
@@ -2287,24 +2287,245 @@
 stribution;%0A
+        this.treeParameterModel = new TreeParameterModel(%0A                (MutableTreeModel)branchRateModel.getTree(), getLocalScale(),%0A                false, TreeTrait.Intent.NODE);%0A        addModel(treeParameterModel);%0A
     %7D%0A%0A    @

fix checkpointing for tree-based shrinkage models