Search in sources :

Example 1 with LinkedParameter

use of dr.app.beauti.components.linkedparameters.LinkedParameter in project beast-mcmc by beast-dev.

the class PriorsPanel method editLinkedParameter.

private void editLinkedParameter(LinkedParameter linkedParameter, List<Parameter> selectedParameters) {
    Parameter sourceParameter = linkedParameter.getArgumentParameter();
    Operator sourceOperator = linkedParameter.getArgumentOperator();
    List<Parameter> compatibleParameters = new ArrayList<Parameter>();
    for (Parameter parameter : parameters) {
        boolean isCompatible = true;
        if (parameter.isStatistic) {
            isCompatible = false;
        }
        if (parameter.truncationLower != sourceParameter.truncationLower) {
            isCompatible = false;
        }
        Operator operator = options.getOperator(parameter);
        if (operator == null || operator.getOperatorType() != sourceOperator.getOperatorType()) {
            isCompatible = false;
        }
        if (isCompatible) {
            compatibleParameters.add(parameter);
        }
    }
    if (linkParameterDialog == null) {
        linkParameterDialog = new JointPriorDialog(frame, options);
    }
    linkParameterDialog.setLinkedParameter(linkedParameter);
    linkParameterDialog.setCompatibleParameterList(compatibleParameters);
    linkParameterDialog.setDependentParameterList(selectedParameters);
    boolean done = false;
    while (!done) {
        int result = linkParameterDialog.showDialog();
        if (result == JOptionPane.OK_OPTION && linkParameterDialog.validateModelName()) {
            done = true;
        }
        if (result == JOptionPane.CANCEL_OPTION) {
            return;
        }
    }
    linkedParameter.setName(linkParameterDialog.getName());
    linkedParameter.linkDependentParameters(linkParameterDialog.getDependentParameterList());
    linkParameterDialog.getArguments(linkedParameter.getArgumentParameter());
    for (Parameter parameter : linkParameterDialog.getDependentParameterList()) {
        parameter.setPriorEdited(true);
    }
    priorTableModel.fireTableDataChanged();
    frame.setAllOptions();
}
Also used : ArrayList(java.util.ArrayList) LinkedParameter(dr.app.beauti.components.linkedparameters.LinkedParameter)

Example 2 with LinkedParameter

use of dr.app.beauti.components.linkedparameters.LinkedParameter in project beast-mcmc by beast-dev.

the class PriorsPanel method removeFromJointPrior.

private void removeFromJointPrior(Parameter parameter) {
    LinkedParameterComponentOptions comp = (LinkedParameterComponentOptions) options.getComponentOptions(LinkedParameterComponentOptions.class);
    LinkedParameter linkedParameter = comp.getLinkedParameter(parameter);
    if (linkedParameter != null) {
        comp.removeDependentParameter(parameter);
    }
    // Possibly remove parameter from its HPM
    HierarchicalModelComponentOptions hmco = (HierarchicalModelComponentOptions) options.getComponentOptions(HierarchicalModelComponentOptions.class);
    if (hmco.isHierarchicalParameter(parameter)) {
        if (hmco.removeParameter(this, parameter, true) == JOptionPane.NO_OPTION) {
            // Bail out
            System.err.println("Bailing out of modification");
            return;
        }
        System.err.println("Parameter removed from an HPM");
    }
}
Also used : LinkedParameter(dr.app.beauti.components.linkedparameters.LinkedParameter) LinkedParameterComponentOptions(dr.app.beauti.components.linkedparameters.LinkedParameterComponentOptions) HierarchicalModelComponentOptions(dr.app.beauti.components.hpm.HierarchicalModelComponentOptions)

Example 3 with LinkedParameter

use of dr.app.beauti.components.linkedparameters.LinkedParameter in project beast-mcmc by beast-dev.

the class PriorsPanel method priorButtonPressed.

private void priorButtonPressed(int row) {
    Parameter parameter = parameters.get(row);
    LinkedParameterComponentOptions lpco = (LinkedParameterComponentOptions) options.getComponentOptions(LinkedParameterComponentOptions.class);
    HierarchicalModelComponentOptions hmco = (HierarchicalModelComponentOptions) options.getComponentOptions(HierarchicalModelComponentOptions.class);
    if (lpco.isArgumentParameter(parameter)) {
        LinkedParameter linkedParameter = lpco.getLinkedParameterForArgument(parameter);
        editLinkedParameter(linkedParameter, linkedParameter.getDependentParameterList());
    } else {
        if (hmco.isHierarchicalParameter(parameter)) {
            int option = JOptionPane.showConfirmDialog(this, "This parameter forms part of an Hierarchical Model.\n" + "Selecting a new prior will remove the parameter from\n" + "this HPM.\nContinue?", "Hierarchical parameter warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
            if (option == JOptionPane.NO_OPTION) {
                return;
            }
        }
        if (parameter.isLinked) {
            int option = JOptionPane.showConfirmDialog(this, "Parameter linked to other parameter. Selecting a\n" + "new prior will remove the link.\nContinue?", "Linked parameter warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
            if (option == JOptionPane.NO_OPTION) {
                return;
            }
        }
        editPrior(parameter);
    }
}
Also used : LinkedParameter(dr.app.beauti.components.linkedparameters.LinkedParameter) LinkedParameter(dr.app.beauti.components.linkedparameters.LinkedParameter) LinkedParameterComponentOptions(dr.app.beauti.components.linkedparameters.LinkedParameterComponentOptions) HierarchicalModelComponentOptions(dr.app.beauti.components.hpm.HierarchicalModelComponentOptions)

Example 4 with LinkedParameter

use of dr.app.beauti.components.linkedparameters.LinkedParameter in project beast-mcmc by beast-dev.

the class PriorsPanel method linkButtonPressed.

private void linkButtonPressed(int[] rows) {
    Parameter firstParameter = parameters.get(rows[0]);
    // gather the selected parameters...
    List<Parameter> selectedParameters = new ArrayList<Parameter>();
    boolean isLinked = false;
    for (int i = 0; i < rows.length; ++i) {
        Parameter parameter = parameters.get(rows[i]);
        if (parameter.isStatistic) {
            JOptionPane.showMessageDialog(frame, "Statistics cannot be linked together or\n" + "linked with parameter.", "Parameter linking error", JOptionPane.WARNING_MESSAGE);
            // Bail out
            return;
        }
        if (parameter.truncationLower != firstParameter.truncationLower || parameter.truncationUpper != firstParameter.truncationUpper || options.getOperator(parameter).getOperatorType() != options.getOperator(firstParameter).getOperatorType()) {
            JOptionPane.showMessageDialog(frame, "Only parameters that share the same bounds\n" + "and have the same operator types can be linked.", "Parameter linking error", JOptionPane.WARNING_MESSAGE);
            // Bail out
            return;
        }
        if (parameter.isLinked) {
            isLinked = true;
        }
        selectedParameters.add(parameters.get(rows[i]));
    }
    if (isLinked) {
        int option = JOptionPane.showConfirmDialog(this, "One or more selected parameters are already linked or\n" + "part of a hierarchical model.\n\n" + "Constructing a new prior will remove these parameter\n" + "from the original model. Continue?", "Link warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
        if (option == JOptionPane.NO_OPTION) {
            return;
        }
    }
    LinkedParameterComponentOptions comp = (LinkedParameterComponentOptions) options.getComponentOptions(LinkedParameterComponentOptions.class);
    LinkedParameter linkedParameter = comp.createLinkedParameter(null, selectedParameters);
    editLinkedParameter(linkedParameter, selectedParameters);
}
Also used : LinkedParameter(dr.app.beauti.components.linkedparameters.LinkedParameter) ArrayList(java.util.ArrayList) LinkedParameter(dr.app.beauti.components.linkedparameters.LinkedParameter) LinkedParameterComponentOptions(dr.app.beauti.components.linkedparameters.LinkedParameterComponentOptions)

Aggregations

LinkedParameter (dr.app.beauti.components.linkedparameters.LinkedParameter)4 LinkedParameterComponentOptions (dr.app.beauti.components.linkedparameters.LinkedParameterComponentOptions)3 HierarchicalModelComponentOptions (dr.app.beauti.components.hpm.HierarchicalModelComponentOptions)2 ArrayList (java.util.ArrayList)2