use of gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup in project n2a by frothga.
the class ParameterSpecGroupsPanel method getParameterSpecGroupSet.
// ////////////////////////
// ACCESSORS / MUTATORS //
// ////////////////////////
public ParameterSpecGroupSet getParameterSpecGroupSet() {
ParameterSpecGroupSet groupSet = new ParameterSpecGroupSet();
for (RoundedSpecPanel pnlRounded : groupPanels.keySet()) {
if (pnlRounded instanceof ParameterSpecGroupPanel) {
ParameterSpecGroupPanel pnlGroup = (ParameterSpecGroupPanel) pnlRounded;
ParameterSpecGroup group = pnlGroup.getParameterSpecGroup();
groupSet.add(group);
}
}
return groupSet;
}
use of gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup in project n2a by frothga.
the class ParameterSpecGroupSet method multiple.
private static void multiple() {
RandomManager.setRandomSeed("Ensemble/UniformParameterSpecification", 123);
ParameterSpecGroup knGrp = new ParameterSpecGroup(3);
knGrp.put("Knowledge", new ListParameterSpecification(new Object[] { 0.2, 0.5, 0.8 }));
ParameterSpecGroup gravGrp = new ParameterSpecGroup(6);
gravGrp.put("Gravity", new EvenSpacingParameterSpecification(10, 20));
ParameterSpecGroup uniGrp = new ParameterSpecGroup(3);
uniGrp.put("UNIFORM", new UniformParameterSpecification(0, 10.0), true);
ParameterSpecGroupSet groups = new ParameterSpecGroupSet();
groups.add(knGrp);
groups.add(gravGrp);
groups.add(uniGrp);
// ConstantParameterSpecGroup cgroup = new ConstantParameterSpecGroup();
// cgroup.addConstParameter("Gravity", 2222);
// cgroup.addConstParameter("Gravityx", 2222);
// groups.setDefaultValueGroup(cgroup);
groups.setDefaultValueGroup(new ConstantParameterSpecGroup("Gravity", 22, "xyz", "what", "pisquared", 10.237, "asdf"));
// groups.printParameterSets(false);
groups.printParameterSets(true);
}
use of gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup in project n2a by frothga.
the class ParameterSpecGroupSet method generateAllSetsFromSpecs.
public ParameterSetList generateAllSetsFromSpecs(boolean includeDVGroup) throws ParameterSpecGroupSetValidationException {
validate();
Set<Object> skipDVGroupParams = findSkipDVGroupParams();
ParameterSetList sets = new ParameterSetList();
// does return "zero" runs.
if (size() == 1 && get(0) == defaultValueGroup && !includeDVGroup) {
sets.add(new ParameterSet());
return sets;
}
// Make sure that the default value group is applied at the end for
// this process, just to have a nicely-sorted final parameter set,
// and use the sorted copy of this group set
// to access group information from this point forward in
// the method. Wouldn't need this sorted copy if code
// were refactored to not have the DV group as part of the
// actual group list.
ParameterSpecGroupSet sortedCopy = new ParameterSpecGroupSet(this);
sortedCopy.setDefaultValueGroup(defaultValueGroup, sortedCopy.size());
// Get the counts of each group.
Integer[] groupRunCounts = sortedCopy.getGroupRunCounts(includeDVGroup);
for (int[] idxs : new CombinationsIterator(groupRunCounts)) {
ParameterSet set = new ParameterSet();
for (int i = 0, g = 0; i < idxs.length; i++) {
ParameterSpecGroup group = sortedCopy.get(g++);
// Ignore the default values if desired.
if (!includeDVGroup && group == defaultValueGroup) {
// Just leap past this one, move to next.
group = sortedCopy.get(g++);
}
int idx = idxs[i];
addGroupParamsToParamSet(set, group, idx, skipDVGroupParams);
}
// if(includeDVGroup && defaultValueGroup != null) { // If refactored to have DV group separate reference.
// addGroupParamsToParamSet(skipDVGroupParams, set, idx, defaultValueGroup);
// }
sets.add(set);
}
return sets;
}
use of gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup in project n2a by frothga.
the class ParameterSpecGroupPanel method getParameterSpecGroup.
public ParameterSpecGroup getParameterSpecGroup() {
ParameterSpecGroup group = new ParameterSpecGroup(validCardinality);
for (ParameterSpecPanel pnlSpec : specPanels.keySet()) {
// TODO: hierarchical?
Object paramKey = pnlSpec.getParamBundle().getParameter().getKey();
List<ParameterDomain> domains = pnlSpec.getParamBundle().getDomains();
ParameterKeyPath keyPath = new ParameterKeyPath();
for (ParameterDomain domain : domains) {
keyPath.add(domain.getName());
}
keyPath.add(paramKey);
ParameterSpecification spec = pnlSpec.getSpecification();
group.add(keyPath, spec);
}
return group;
}
use of gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup in project n2a by frothga.
the class UIController method divideEnsembleParams.
// Any group in origSet for which the Simulator can handle parameterization
// is removed from origSet and added to the returned set
private ParameterSpecGroupSet divideEnsembleParams(MNode model, ParameterSpecGroupSet origSet, Backend sim) {
// Three cases:
// 1) framework handles all in group
// 2) simulator handles all in group
// 3) (changed) sim can only handle some of group; so have framework handle group instead
ParameterSpecGroupSet result = new ParameterSpecGroupSet();
for (ParameterSpecGroup group : origSet) {
if (group == origSet.getDefaultValueGroup()) {
// don't want to transfer default value group to simulator groups
continue;
}
int numHandled = 0;
ParameterSpecification spec = null;
Object errorKey = null;
for (Object key : group.keySet()) {
spec = group.get(key);
if (sim.canHandleRunEnsembleParameter(model, key, spec)) {
numHandled++;
} else if (numHandled != 0) {
errorKey = key;
break;
}
}
if (numHandled != group.size() && numHandled != 0) {
System.out.println("this simulator cannot handle '" + errorKey + "' with specification '" + spec.getShortName());
} else if (numHandled != 0) {
result.add(group);
}
}
for (ParameterSpecGroup group : result) {
origSet.remove(group);
}
return result;
}
Aggregations