Search in sources :

Example 1 with ParameterSpecGroupSet

use of gov.sandia.umf.platform.ensemble.params.groupset.ParameterSpecGroupSet 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 2 with ParameterSpecGroupSet

use of gov.sandia.umf.platform.ensemble.params.groupset.ParameterSpecGroupSet in project n2a by frothga.

the class UIController method prepareAndSubmitRunEnsemble.

public boolean prepareAndSubmitRunEnsemble(Component parentComponent, MNode model) throws Exception {
    // Set up simulators.
    List<ExtensionPoint> simEP = PluginManager.getExtensionsForPoint(Backend.class);
    Backend[] simulators = new Backend[simEP.size()];
    int s = 0;
    for (ExtensionPoint ep : simEP) {
        simulators[s++] = (Backend) ep;
    }
    // Set up execution environments.
    // Hack to suppress errors in this outdated code.
    HostSystem[] envs = new HostSystem[0];
    // TODO: Fix this with appropriate interfaces.
    String name = (String) ReflectionUtil.invoke("getName", model);
    String owner = (String) ReflectionUtil.invoke("getOwner", model);
    CreateRunEnsembleDialog dlg = new CreateRunEnsembleDialog((JFrame) SwingUtilities.getRoot(parentComponent), // TODO change from -1
    -1, /*TEMP*/
    name, owner, 12342347483L, /*TEMP until appropriate interfaces*/
    model, simulators, simulators[0], envs, HostSystem.get("localhost"), false);
    dlg.setVisible(true);
    if (dlg.getResult() == CreateRunEnsembleDialog.CREATE) {
        String label = dlg.getLabel();
        HostSystem env = dlg.getEnvironment();
        Backend simulator = dlg.getSimulator();
        ParameterSpecGroupSet groups = dlg.getParameterSpecGroupSet();
        ParameterSpecGroupSet simHandledGroups;
        try {
            // next line modifies groups to remove any that the Simulator will handle
            simHandledGroups = divideEnsembleParams(model, groups, simulator);
        } catch (RuntimeException e) {
            Dialogs.showDetails(MainFrame.instance, "could not create run ensemble", e);
            return false;
        }
        List<String> outputExpressions = dlg.getSelectedOutputExpressions();
        /*            
            int runNum = 0;
            for(ParameterSet set : groups.generateAllSetsFromSpecs(false)) {
                ParameterSet modelParamSet = set.subset("Model");
                ParameterSet simParamSet = set.subset("Simulator");
                modelParamSet.sliceKeyPathKeys();
                simParamSet.sliceKeyPathKeys();

                Run run = model.addRun(modelParamSet, re);
                re.addRun(run);

                Simulation simulation = simulator.createSimulation();
                ParameterDomain domain = new ParameterDomain(simParamSet);
                simulation.setSelectedParameters(domain);
                try {
                    RunState runState;
                    logger.debug(System.currentTimeMillis() + " before execute for run " +
                            runNum++);
                    // quick and dirty attempt at batch script version of doing ensemble
                    runState = simulation.prepare(run, simHandledGroups, env);
//                    runState = simulation.execute(run, simHandledGroups, env);
                    run.setState(XStreamWrapper.writeToString(runState));
                    run.save();
                } catch(Exception e1) {
                    UMF.handleUnexpectedError(null, e1, "Could not create the run.  An error occurred.");
                    return false;
                }
            }
            env.submitBatch(re);
 */
        return true;
    }
    return false;
}
Also used : Backend(gov.sandia.n2a.plugins.extpoints.Backend) ExtensionPoint(gov.sandia.n2a.plugins.ExtensionPoint) CreateRunEnsembleDialog(gov.sandia.umf.platform.ui.ensemble.run.CreateRunEnsembleDialog) HostSystem(gov.sandia.n2a.execenvs.HostSystem) ParameterSpecGroupSet(gov.sandia.umf.platform.ensemble.params.groupset.ParameterSpecGroupSet) ExtensionPoint(gov.sandia.n2a.plugins.ExtensionPoint)

Example 3 with ParameterSpecGroupSet

use of gov.sandia.umf.platform.ensemble.params.groupset.ParameterSpecGroupSet in project n2a by frothga.

the class FixedParameterSpacePanel method updateFromGroups.

protected void updateFromGroups() {
    ParameterSpecGroupSet newGroups = pnlGroups.getParameterSpecGroupSet();
    newGroups.setDefaultValueGroup(defaultValueGroup);
    try {
        newGroups.validate();
        setError(null);
    } catch (Exception e) {
        setError(new RuntimeException("There is a problem with your parameterization.", e));
        return;
    }
    groups = newGroups;
    ParameterSetList sets = groups.generateAllSetsFromSpecs(chkDV.isSelected());
    mdlParamSets.setParameterSetList(sets);
    pnlParamDetails.updateRun(sets.getNumSets(), estDuration);
}
Also used : ParameterSetList(gov.sandia.umf.platform.ensemble.params.ParameterSetList) ParameterSpecGroupSet(gov.sandia.umf.platform.ensemble.params.groupset.ParameterSpecGroupSet)

Example 4 with ParameterSpecGroupSet

use of gov.sandia.umf.platform.ensemble.params.groupset.ParameterSpecGroupSet 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

ParameterSpecGroupSet (gov.sandia.umf.platform.ensemble.params.groupset.ParameterSpecGroupSet)4 ExtensionPoint (gov.sandia.n2a.plugins.ExtensionPoint)2 ParameterSpecGroup (gov.sandia.umf.platform.ensemble.params.groups.ParameterSpecGroup)2 HostSystem (gov.sandia.n2a.execenvs.HostSystem)1 ParameterSpecification (gov.sandia.n2a.parms.ParameterSpecification)1 Backend (gov.sandia.n2a.plugins.extpoints.Backend)1 ParameterSetList (gov.sandia.umf.platform.ensemble.params.ParameterSetList)1 CreateRunEnsembleDialog (gov.sandia.umf.platform.ui.ensemble.run.CreateRunEnsembleDialog)1