use of dr.app.beauti.components.hpm.HierarchicalModelComponentOptions in project beast-mcmc by beast-dev.
the class HierarchicalPriorDialog method addHPM.
public void addHPM(java.util.List<Parameter> parameterList) {
HierarchicalModelComponentOptions comp = (HierarchicalModelComponentOptions) options.getComponentOptions(HierarchicalModelComponentOptions.class);
HierarchicalPhylogeneticModel hpm = comp.addHPM(nameField.getText(), parameterList, parameterList.get(0).priorType);
hpm.getConditionalParameterList().get(0).mean = hpmMeanMean;
hpm.getConditionalParameterList().get(0).stdev = hpmMeanStDev;
hpm.getConditionalParameterList().get(0).setInitial(hpmMeanInitial);
hpm.getConditionalParameterList().get(1).shape = hpmPrecShape;
hpm.getConditionalParameterList().get(1).scale = hpmPrecScale;
hpm.getConditionalParameterList().get(1).setInitial(hpmPrecInitial);
}
use of dr.app.beauti.components.hpm.HierarchicalModelComponentOptions 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");
}
}
use of dr.app.beauti.components.hpm.HierarchicalModelComponentOptions 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);
}
}
use of dr.app.beauti.components.hpm.HierarchicalModelComponentOptions in project beast-mcmc by beast-dev.
the class PriorsPanel method hierarchicalButtonPressed.
private void hierarchicalButtonPressed(int[] rows) {
if (rows.length < 2) {
JOptionPane.showMessageDialog(frame, "Fewer than two parameters selected.", "Parameter linking error", JOptionPane.WARNING_MESSAGE);
return;
}
Double lowerBound = null;
Double upperBound = null;
List<Parameter> paramList = new ArrayList<Parameter>();
for (int i = 0; i < rows.length; ++i) {
Parameter parameter = parameters.get(rows[i]);
if (parameter.isStatistic) {
JOptionPane.showMessageDialog(frame, "Statistics cannot be used in a hierarchical model.", "HPM parameter linking error", JOptionPane.WARNING_MESSAGE);
return;
}
boolean sameBounds = true;
if (lowerBound == null) {
lowerBound = parameter.truncationLower;
} else {
if (lowerBound != parameter.truncationLower) {
sameBounds = false;
}
}
if (upperBound == null) {
upperBound = parameter.truncationUpper;
} else {
if (upperBound != parameter.truncationUpper) {
sameBounds = false;
}
}
if (!sameBounds) {
JOptionPane.showMessageDialog(frame, "Only parameters that share the same bounds\n" + "should be included in a HPM.", "HPM parameter link error", JOptionPane.WARNING_MESSAGE);
// Bail out
return;
}
paramList.add(parameter);
}
if (hierarchicalPriorDialog != null) {
// Already called
// Check to see if selected parameters are already in a HPM
HierarchicalModelComponentOptions comp = (HierarchicalModelComponentOptions) options.getComponentOptions(HierarchicalModelComponentOptions.class);
boolean anyConflicts = false;
for (Parameter parameter : paramList) {
if (comp.isHierarchicalParameter(parameter)) {
anyConflicts = true;
break;
}
}
if (anyConflicts) {
int option = JOptionPane.showConfirmDialog(this, "At one selected parameter already exists in a HPM.\n" + "Constructing a new prior will remove these parameter\n" + "from the original model. Continue?", "HPM warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (option == JOptionPane.NO_OPTION) {
return;
}
}
}
if (hierarchicalPriorDialog == null) {
hierarchicalPriorDialog = new HierarchicalPriorDialog(frame, options);
}
boolean done = false;
while (!done) {
int result = hierarchicalPriorDialog.showDialog(paramList);
if (result == JOptionPane.OK_OPTION && hierarchicalPriorDialog.validateModelName()) {
hierarchicalPriorDialog.getArguments();
done = true;
}
if (result == JOptionPane.CANCEL_OPTION) {
return;
}
}
// Remove parameters from old list
for (Parameter parameter : paramList) {
HierarchicalModelComponentOptions comp = (HierarchicalModelComponentOptions) options.getComponentOptions(HierarchicalModelComponentOptions.class);
if (comp.isHierarchicalParameter(parameter)) {
comp.removeParameter(this, parameter, false);
}
}
// Add HPM to component manager
hierarchicalPriorDialog.addHPM(paramList);
for (Parameter parameter : paramList) {
parameter.setPriorEdited(true);
}
priorTableModel.fireTableDataChanged();
}
Aggregations