Search in sources :

Example 6 with ParameterSpecGroup

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;
}
Also used : ParameterSpecGroup(gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup) ParameterSpecGroupSet(gov.sandia.umf.platform.ensemble.params.groupset.ParameterSpecGroupSet)

Example 7 with ParameterSpecGroup

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);
}
Also used : ListParameterSpecification(gov.sandia.umf.platform.ensemble.params.specs.ListParameterSpecification) EvenSpacingParameterSpecification(gov.sandia.umf.platform.ensemble.params.specs.EvenSpacingParameterSpecification) UniformParameterSpecification(gov.sandia.umf.platform.ensemble.params.specs.UniformParameterSpecification) ConstantParameterSpecGroup(gov.sandia.umf.platform.ensemble.params.groups.ConstantParameterSpecGroup) LatinHypercubeParameterSpecGroup(gov.sandia.umf.platform.ensemble.params.groups.LatinHypercubeParameterSpecGroup) MonteCarloParameterSpecGroup(gov.sandia.umf.platform.ensemble.params.groups.MonteCarloParameterSpecGroup) ParameterSpecGroup(gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup) ConstantParameterSpecGroup(gov.sandia.umf.platform.ensemble.params.groups.ConstantParameterSpecGroup)

Example 8 with ParameterSpecGroup

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;
}
Also used : ParameterSet(gov.sandia.n2a.parms.ParameterSet) ParameterSetList(gov.sandia.umf.platform.ensemble.params.ParameterSetList) ConstantParameterSpecGroup(gov.sandia.umf.platform.ensemble.params.groups.ConstantParameterSpecGroup) LatinHypercubeParameterSpecGroup(gov.sandia.umf.platform.ensemble.params.groups.LatinHypercubeParameterSpecGroup) MonteCarloParameterSpecGroup(gov.sandia.umf.platform.ensemble.params.groups.MonteCarloParameterSpecGroup) ParameterSpecGroup(gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup)

Example 9 with ParameterSpecGroup

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;
}
Also used : ConstantParameterSpecification(gov.sandia.umf.platform.ensemble.params.specs.ConstantParameterSpecification) ParameterSpecification(gov.sandia.n2a.parms.ParameterSpecification) UniformParameterSpecification(gov.sandia.umf.platform.ensemble.params.specs.UniformParameterSpecification) EvenSpacingParameterSpecification(gov.sandia.umf.platform.ensemble.params.specs.EvenSpacingParameterSpecification) ParameterKeyPath(gov.sandia.n2a.parms.ParameterKeyPath) ParameterDomain(gov.sandia.n2a.parms.ParameterDomain) ParameterSpecGroup(gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup)

Example 10 with ParameterSpecGroup

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;
}
Also used : ParameterSpecification(gov.sandia.n2a.parms.ParameterSpecification) ParameterSpecGroup(gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup) ParameterSpecGroupSet(gov.sandia.umf.platform.ensemble.params.groupset.ParameterSpecGroupSet) ExtensionPoint(gov.sandia.n2a.plugins.ExtensionPoint)

Aggregations

ParameterSpecGroup (gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup)10 ConstantParameterSpecGroup (gov.sandia.umf.platform.ensemble.params.groups.ConstantParameterSpecGroup)7 LatinHypercubeParameterSpecGroup (gov.sandia.umf.platform.ensemble.params.groups.LatinHypercubeParameterSpecGroup)7 MonteCarloParameterSpecGroup (gov.sandia.umf.platform.ensemble.params.groups.MonteCarloParameterSpecGroup)7 ParameterSpecification (gov.sandia.n2a.parms.ParameterSpecification)3 EvenSpacingParameterSpecification (gov.sandia.umf.platform.ensemble.params.specs.EvenSpacingParameterSpecification)3 ListParameterSpecification (gov.sandia.umf.platform.ensemble.params.specs.ListParameterSpecification)3 UniformParameterSpecification (gov.sandia.umf.platform.ensemble.params.specs.UniformParameterSpecification)3 ParameterSpecGroupSet (gov.sandia.umf.platform.ensemble.params.groupset.ParameterSpecGroupSet)2 ParameterDomain (gov.sandia.n2a.parms.ParameterDomain)1 ParameterKeyPath (gov.sandia.n2a.parms.ParameterKeyPath)1 ParameterSet (gov.sandia.n2a.parms.ParameterSet)1 ExtensionPoint (gov.sandia.n2a.plugins.ExtensionPoint)1 ParameterSetList (gov.sandia.umf.platform.ensemble.params.ParameterSetList)1 ConstantParameterSpecification (gov.sandia.umf.platform.ensemble.params.specs.ConstantParameterSpecification)1 HashSet (java.util.HashSet)1