use of gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup in project n2a by frothga.
the class ParameterSpecGroupSet method consts.
private static void consts() {
ConstantParameterSpecGroup group = new ConstantParameterSpecGroup();
group.addConstParameter("A", 43.2);
group.addConstParameter("B", 32.4);
group.addConstParameter("C", 87.2);
group.addConstParameter("D", 111.2);
ParameterSpecGroup group2 = new ParameterSpecGroup(4);
group2.add("Z", new ListParameterSpecification(true, false, false, true));
ParameterSpecGroupSet groups = new ParameterSpecGroupSet();
groups.add(group);
groups.add(group2);
groups.printParameterSets();
}
use of gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup in project n2a by frothga.
the class ParameterSpecGroupSet method validate.
// ////////
// MISC //
// ////////
public void validate() throws ParameterSpecGroupSetValidationException {
Set<Object> paramKeys = new HashSet<Object>();
Set<Integer> specHashCodes = new HashSet<Integer>();
for (ParameterSpecGroup group : this) {
for (Object paramKey : group.keySet()) {
ParameterSpecification spec = group.get(paramKey);
// Validate
if (specHashCodes.contains(spec.objectHashCode())) {
throw new ParameterSpecGroupSetValidationException("Multiple parameter groups contain the same specification object '" + spec.getClass().getSimpleName() + "@" + spec.hashCode() + "'. A specification object should be added to only a single group because it is permitted to save state between calls.");
}
if (group != defaultValueGroup && paramKeys.contains(paramKey)) {
throw new ParameterSpecGroupSetValidationException("Multiple parameter groups contain a specification for the parameter '" + paramKey + "'.");
}
// Save
specHashCodes.add(spec.objectHashCode());
if (group != defaultValueGroup) {
// Default value parameters do not prevent
paramKeys.add(paramKey);
// other groups from having the same parameters.
}
// Max values
int max = spec.getMaxValues();
if (max != -1 && group.getRunCount() > max) {
throw new ParameterSpecGroupSetValidationException("Specification for parameter '" + paramKey + "' has a maximum run count less than the run count of its group.");
}
}
}
}
use of gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup in project n2a by frothga.
the class ParameterSpecGroupSet method add.
// Just short hand for a SINGLE-parameter spec group,
// but still returns the reference to the group for
// convenience.
public ParameterSpecGroup add(int iterations, String name, ParameterSpecification spec) {
ParameterSpecGroup group = new ParameterSpecGroup(iterations);
group.put(name, spec);
add(group);
return group;
}
use of gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup in project n2a by frothga.
the class ParameterSpecGroupSet method list.
public void list(boolean includeDVGroup) {
for (ParameterSpecGroup group : this) {
if (!includeDVGroup && group == defaultValueGroup) {
continue;
}
if (group == defaultValueGroup) {
System.out.print("<DV>");
}
System.out.println(group);
group.list(4);
}
}
use of gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup in project n2a by frothga.
the class ParameterSpecGroupSet method getRunCount.
public long getRunCount(boolean includeDVGroup) throws ParameterSpecGroupSetValidationException {
validate();
long product = 1;
boolean atLeastOne = false;
for (ParameterSpecGroup group : this) {
if (!includeDVGroup && group == defaultValueGroup) {
continue;
}
product *= group.getRunCount();
atLeastOne = true;
}
return atLeastOne ? product : 0;
}
Aggregations