Commit 771edfd8 authored by Simon Barner's avatar Simon Barner

Merge branch '3994' into 'master'

CLI: Launch DSE + Validate results

See merge request !332
parents 7f59418c 374dee05
CommandLineDSEProjectLoading.java 3baa51b26a31bcc4eaa19e4f6c17820d76ae1d92 GREEN
CommandLineDSEProjectLoading.java adef36989384bb984976d6bae70cd3739a27dbe1 GREEN
......@@ -15,12 +15,9 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.cli;
import static org.apache.commons.lang3.StringUtils.countMatches;
import static org.conqat.ide.commons.ui.logging.LoggingUtils.logAndShowError;
import static org.fortiss.af3.exploration.ui.util.ExplorationUiUtils.getFQNID;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import static org.fortiss.af3.exploration.util.ExplorationCLIUtils.findMatchingDSEProject;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.showError;
import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.IWorkbench;
......@@ -32,10 +29,7 @@ import org.fortiss.af3.exploration.ui.AF3ExplorationUIActivator;
import org.fortiss.af3.exploration.ui.perspective.DSEperspective;
import org.fortiss.af3.exploration.ui.perspective.dashboard.DashboardFXViewPart;
import org.fortiss.af3.exploration.ui.perspective.service.IDSEPerspectiveManager;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.tooling.kernel.extension.ICommandLineSwitchHandler;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
/**
* Handler to preload a DSE project and switch the initial perspective to the DSE perspective.
......@@ -44,18 +38,6 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
*/
public class CommandLineDSEProjectLoading implements ICommandLineSwitchHandler {
/** Name of the AF3 project to be searched for a matching DSE project. */
private String af3PrjName;
/** Name of the DSE project to be searched in the given AF3 project. */
private String dsePrjName;
/** The first AF3 project matching the given AF3 project name. */
private FileProject matchingAF3Project;
/** The first DSE project matching the given project name within the found AF3 project. */
private DSE matchingDSE;
/** {@inheritDoc} */
@Override
public boolean hasAdditionalArgument() {
......@@ -65,11 +47,8 @@ public class CommandLineDSEProjectLoading implements ICommandLineSwitchHandler {
/** {@inheritDoc} */
@Override
public void handleCLISwitch(String argument) {
if(!parseArgument(argument)) {
return;
}
if(!findReferencedDSEProject()) {
DSE matchingDSE = findMatchingDSEProject(argument);
if(matchingDSE == null) {
return;
}
......@@ -79,70 +58,6 @@ public class CommandLineDSEProjectLoading implements ICommandLineSwitchHandler {
IDSEPerspectiveManager.INSTANCE.setCurrentlySelectedDSE(matchingDSE);
}
/**
* Parses the argument for the required structure and extracts the AF3 and its DSE project name.
*
* @return {@code true} if the argument could be parsed, {@code false} otherwise.
*/
private boolean parseArgument(String argument) {
int slashCount = countMatches(argument, "/");
if(slashCount != 1) {
logAndShowError(AF3ExplorationUIActivator.getDefault(),
"The DSE to be loaded at startup must be provided in the format " +
"<AF3-Project>/<DSE-Name>",
null);
return false;
}
String[] argParts = argument.split("/");
af3PrjName = argParts[0];
dsePrjName = argParts[1];
return true;
}
/**
* Finds the AF3 project and a contained DSE project by the names given with the switch.
*
* @return {@code true} if the DSE project was found, {@code false} otherwise.
*/
private boolean findReferencedDSEProject() {
for(ITopLevelElement topElement : IPersistencyService.getInstance().getTopLevelElements()) {
if(topElement.getRootModelElement() instanceof FileProject) {
FileProject fp = (FileProject)topElement.getRootModelElement();
if(fp.getName().equals(af3PrjName)) {
matchingAF3Project = fp;
break;
}
}
}
if(matchingAF3Project == null) {
String errMsg = "Could not find a matching AF3 Project with the name " + af3PrjName +
" to load a DSE project.";
error(AF3ExplorationUIActivator.getDefault(), errMsg);
showError(errMsg);
return false;
}
for(DSE dse : pickInstanceOf(DSE.class, matchingAF3Project.getRootElements())) {
if(dse.getName().equals(dsePrjName)) {
matchingDSE = dse;
break;
}
}
if(matchingDSE == null) {
String errMsg = "Could not find a matching DSE project with the name " + dsePrjName +
" in the AF3 project " + af3PrjName + ".";
error(AF3ExplorationUIActivator.getDefault(), errMsg);
showError(errMsg);
return false;
}
return true;
}
/** Loads the DSE perspective. */
private void showDSEPerspective() {
IWorkbench wb = PlatformUI.getWorkbench();
......
DeploymentValidatorStartMenu.java 4ffbf77070f372459a9e79b39d0dc32343e762f1 GREEN
DeploymentValidatorStartMenu.java 7e3fe8187d99934f939cc99ba81392566b27e05d GREEN
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.menu;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static org.conqat.ide.commons.ui.dialog.MessageUtils.showInfo;
import static org.conqat.ide.commons.ui.dialog.MessageUtils.showWarning;
......@@ -108,7 +109,7 @@ public class DeploymentValidatorStartMenu implements IContextMenuContributor {
}
ExplorationExpressionDeploymentValidator validator =
new ExplorationExpressionDeploymentValidator(ta2hw, selRuleSet);
new ExplorationExpressionDeploymentValidator(ta2hw, asList(selRuleSet));
Boolean validationPassed = false;
try {
......
DashboardFXController.java e558a386fe11d56870329c5255429f6a93dd3d4e GREEN
DashboardFXController.java 10823c69ca83bb53bb8ca2b800ee6a148823182e GREEN
DashboardFXViewPart.java 93e8ed38fb398aa5ababc85877a5fed8d5b88723 GREEN
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.dashboard;
import static java.util.Arrays.asList;
import static javafx.application.Platform.runLater;
import static org.fortiss.af3.exploration.ui.AF3ExplorationUIActivator.getDefault;
import static org.fortiss.af3.exploration.ui.perspective.service.IEventListener.DSE_EVENT.DSE_REMOVED_EVENT;
......@@ -197,7 +198,8 @@ public class DashboardFXController extends CompositeFXControllerBase<AnchorPane,
EventBroker.getInstance().addListener(this);
updatePrjLabel(IDSEPerspectiveManager.INSTANCE.getCurrentlySelectedDSE());
if(IDSEBackendService.getInstance().getDSEBackends(PlatformArchitecture.class).isEmpty()) {
if(IDSEBackendService.getInstance().getDSEBackends(asList(PlatformArchitecture.class))
.isEmpty()) {
platformButton.setDisable(true);
}
}
......
......@@ -7,4 +7,4 @@ HelpComposite.java 72ad69a68860a4c645e2d6c3094be992a53c5d33 GREEN
HelpView.java 5cd89049b0373cacd8fc7e431870260bd81b93c1 GREEN
HierarchicElementContentProvider.java 8a393f0b867ce5616292910a5287b0e39c6d48b7 GREEN
SuperSetContentProvider.java 7e44e42675740b08582dfbc3e4b67ec9bdd73b93 GREEN
SynthesisViewBase.java 908f9ae2bb8cd570ac32861375f46343024f814c GREEN
SynthesisViewBase.java 8fe309bb06d37a1eb12ddc1a948e864fc6d0806f GREEN
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.generic;
import static java.util.Arrays.asList;
import static org.fortiss.af3.exploration.smt.modeltransformation.BasicDeploScheduleConstraint.initializeDeploSchedule;
import static org.fortiss.af3.exploration.smt.modeltransformation.ConstraintDefinitionUtils.createResourceAllocations;
import static org.fortiss.af3.exploration.smt.util.AllocationToSchedule.generateSchedule;
......@@ -203,10 +204,10 @@ public abstract class SynthesisViewBase extends DSEPerspectiveViewBase {
private Integer totalTimeout = DEFAULT_TIMEOUT * TIME_SECS_TO_MSECS;
/** References the artifact that will be produced by this synthesis view. */
protected Class<?> synthesizedArtifactType;
protected Class<? extends IModelElement> synthesizedArtifactType;
/** Constructor. */
protected SynthesisViewBase(Class<?> synthesizedArtifactType) {
protected SynthesisViewBase(Class<? extends IModelElement> synthesizedArtifactType) {
this.synthesizedArtifactType = synthesizedArtifactType;
EventBroker.getInstance().addListener(this);
}
......@@ -546,7 +547,7 @@ public abstract class SynthesisViewBase extends DSEPerspectiveViewBase {
/** Creates the ComboBox which allows to select a DSE backend for Exploration/Synthesis. */
private void createBackendCombo(Composite composite2) {
IDSEBackendService dbs = IDSEBackendService.getInstance();
Collection<IDSEBackend> backends = dbs.getDSEBackends(synthesizedArtifactType);
Collection<IDSEBackend> backends = dbs.getDSEBackends(asList(synthesizedArtifactType));
backendCombo = new ComboViewer(composite2, SWT.NONE);
backendCombo.setLabelProvider(new LabelProvider());
......@@ -571,9 +572,9 @@ public abstract class SynthesisViewBase extends DSEPerspectiveViewBase {
});
// Select the first found backend.
if(dbs.getDSEBackends(synthesizedArtifactType).size() > 0) {
if(dbs.getDSEBackends(asList(synthesizedArtifactType)).size() > 0) {
Collection<IDSEBackend> z3DefaultBackends =
dbs.findByName(synthesizedArtifactType, "Z3");
dbs.findByArtifactAndName(asList(synthesizedArtifactType), "Z3");
// If no Z3 backend is found (not the case in the std installation), use an arbitrary
// backend.
IDSEBackend defaultBackend = null;
......
DSEProcessNavigator.java a45e03d6080c637edb8b44070816a828838e47e9 GREEN
DSEProcessNavigator.java b0ed44175926555fe88206cc91a3440ab6ead73a GREEN
ExplorationNavigatorElementContentProvider.java 36626523f1e3eb45fc75c2104cac59505ad9daf0 GREEN
ExplorationNavigatorFXController.java 7f7c5fee19f5fe14c925dcfd97ef541a1ef354d1 GREEN
ExplorationNavigatorFXViewPart.java 8604b65d141c21690f90bc942a6bb29e35911295 GREEN
......
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.navigator;
import static java.util.Arrays.asList;
import static org.fortiss.af3.exploration.ui.perspective.process.IProcessManager.EProcessStep.CONSTRAINTS;
import static org.fortiss.af3.exploration.ui.perspective.process.IProcessManager.EProcessStep.DEPLOYMENT_SYNTHESIS;
import static org.fortiss.af3.exploration.ui.perspective.process.IProcessManager.EProcessStep.HOME;
......@@ -99,7 +100,8 @@ public class DSEProcessNavigator extends DseSaveableView {
MenuItem mntmPlatformSynthesis = new MenuItem(menu, SWT.NONE);
mntmPlatformSynthesis.setText("Platform Synthesis");
mntmPlatformSynthesis.addSelectionListener(new PlatformSynthSelectionAdapter());
if(IDSEBackendService.getInstance().getDSEBackends(PlatformArchitecture.class).isEmpty()) {
if(IDSEBackendService.getInstance().getDSEBackends(asList(PlatformArchitecture.class))
.isEmpty()) {
mntmPlatformSynthesis.setEnabled(false);
}
......
Exploration.java b0a5be69a42b39e9c6e6a8401f4340de3a87a93b GREEN
ExplorationActivator.java ac3a969f9999b629b83952926d67c2287c23d945 GREEN
ExplorationActivator.java c4a018273f54015cc1abf34a082fbf77c460dddf GREEN
......@@ -16,6 +16,8 @@
package org.fortiss.af3.exploration;
import org.eclipse.core.runtime.Plugin;
import org.fortiss.af3.exploration.cli.ExecuteDSECommandLineHandler;
import org.fortiss.af3.exploration.cli.ValidateDSESolutionCommandLineInterface;
import org.fortiss.af3.exploration.service.IDSESolutionExporterService;
import org.fortiss.af3.exploration.solutionconverter.RouteConverter;
import org.fortiss.af3.exploration.solutionconverter.ScheduleConverter;
......@@ -28,6 +30,7 @@ import org.fortiss.af3.exploration.solutionconverter.partition.TaskToPartitionCo
import org.fortiss.af3.exploration.solutionconverter.platform.PlatformConnectorInstanceConverter;
import org.fortiss.af3.exploration.solutionconverter.platform.PlatformExecUnitInstantiationConverter;
import org.fortiss.af3.exploration.solutionconverter.platform.PlatformTransmissionConnectionConverter;
import org.fortiss.tooling.kernel.service.ICommandLineInterfaceService;
import org.osgi.framework.BundleContext;
/**
......@@ -47,6 +50,12 @@ public class ExplorationActivator extends Plugin {
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
// Register the command line parser for executing a DSE.
ICommandLineInterfaceService cliService = ICommandLineInterfaceService.getInstance();
cliService.registerHandler("--execDSE", new ExecuteDSECommandLineHandler());
cliService.registerHandler("--validateDSE", new ValidateDSESolutionCommandLineInterface());
// We can lazily register converters since they are only used when the exploration was
// already loaded (--> DSE perspective).
registerDSESolutionConverters();
......
ExecuteDSECommandLineHandler.java 76f1d610761fc76f0cdf79a242e86efc25fcb208 GREEN
ValidateDSESolutionCommandLineInterface.java 848a6dcb1f3de889ba0107b041eef970ca396559 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2020 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.cli;
import static java.util.Collections.emptyList;
import static org.fortiss.af3.exploration.util.DSEProjectModelElementFactory.createExplorationStep;
import static org.fortiss.af3.exploration.util.DSEProjectModelElementFactory.createRuleSet;
import static org.fortiss.af3.exploration.util.ExplorationCLIUtils.findMatchingDSEProject;
import static org.fortiss.af3.exploration.util.ExplorationCLIUtils.getExplorationTypeByArgument;
import static org.fortiss.af3.exploration.util.ExplorationModelElementFactory.createExplorationSpecification;
import static org.fortiss.tooling.common.util.LambdaUtils.getFirst;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.getLargestID;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.prepareIDs;
import java.io.IOException;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.fortiss.af3.exploration.ExplorationActivator;
import org.fortiss.af3.exploration.model.ExplorationSpecification;
import org.fortiss.af3.exploration.model.ExplorationTarget;
import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.model.project.ExplorationStep;
import org.fortiss.af3.exploration.model.project.ProcessStep;
import org.fortiss.af3.exploration.model.project.RuleSet;
import org.fortiss.af3.exploration.model.solutions.ExplorationSolution;
import org.fortiss.af3.exploration.service.IDSEBackend;
import org.fortiss.af3.exploration.service.IDSEBackendService;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.kernel.extension.ICommandLineSwitchHandler;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
/**
* Handler to launch a {@link DSE} from a given {@link FileProject}. The synthesis to be performed
* also has to be specified.
*
* @author diewald
*/
public final class ExecuteDSECommandLineHandler implements ICommandLineSwitchHandler {
/** Static timeout (can be moved as defineable to the argument string if needed). */
private static final int timeoutMS = 10 * 1000; // 10 seconds
/** DSE service used for the exploration. */
private final IDSEBackendService dseService = IDSEBackendService.getInstance();
/** {@inheritDoc} */
@Override
public boolean hasAdditionalArgument() {
return true;
}
/** {@inheritDoc} */
@Override
public void handleCLISwitch(String argument) {
DSE matchingDSE = findMatchingDSEProject(argument);
if(matchingDSE == null) {
return;
}
Set<Class<? extends IModelElement>> solutionModels = getExplorationTypeByArgument(argument);
if(solutionModels.isEmpty()) {
return;
}
// Get & set the Z3 solver.
Optional<IDSEBackend> z3Backend =
getFirst(dseService.findByArtifactAndName(solutionModels, "Z3 (SMT)"));
if(!z3Backend.isPresent()) {
error(ExplorationActivator.getDefault(),
"Could not find the Z3 backend to perform the exploration.");
return;
}
ExplorationSpecification expSpec = constructExplorationSpecification(matchingDSE);
// Execute the DSE. The result is processed in the Job Adapter.
dseService.setSelectedDSEBackend(z3Backend.get());
dseService.setExplorationSpecification(expSpec);
dseService.setRequiredSolutions(solutionModels);
try {
dseService.explore(new DseCLISolutionAdapter(matchingDSE), timeoutMS);
} catch(Exception e) {
// The DSE produced an Exception --> Add log entry and do not store a solution.
error(ExplorationActivator.getDefault(),
"The exploration failed due to an exception in the DSE backend.", e);
}
}
/**
* Constructs an {@link ExplorationSpecification} using all {@link ExplorationTarget}s from the
* given {@link DSE}.
*/
private ExplorationSpecification constructExplorationSpecification(DSE matchingDSE) {
ExplorationSpecification expSpec = createExplorationSpecification();
ProcessStep dseStep = matchingDSE.getCurrentStep();
expSpec.getTargets().addAll(dseStep.getTargets());
expSpec.setSearchSpace(dseStep.getSuperSetMap());
return expSpec;
}
/** Adapter to store the result of the exploration. */
private class DseCLISolutionAdapter extends JobChangeAdapter {
/** DSE project of the exploration run. */
private final DSE dse;
/** Constructor. */
/* package */ DseCLISolutionAdapter(DSE selectedDSE) {
this.dse = selectedDSE;
}
/** {@inheritDoc} */
@Override
public void done(IJobChangeEvent event) {
ExplorationSolution result =
IDSEBackendService.getInstance().getAndClearExplorationSolution();
ExplorationStep expStep = createCLIExplorationStep(result);
// Save the result --> Save AF3 project.
ITopLevelElement modelCtx =
IPersistencyService.getInstance().getTopLevelElementFor(dse);
prepareIDs(expStep, dse, getLargestID(dse));
modelCtx.runAsCommand(() -> dse.addProcessStep(expStep));
try {
modelCtx.doSave(new NullProgressMonitor());
} catch(CoreException | IOException e) {
error(ExplorationActivator.getDefault(), "Could not store the result of the " +
"Exploration. An exception occured while saving.", e);
}
}
/** Creates an {@link ExplorationStep} to store the result. */
private ExplorationStep createCLIExplorationStep(ExplorationSolution result) {
ExplorationStep expStep = createExplorationStep("CLI solution", emptyList());
expStep.setSolution(result);
Collection<IExplorationTarget<?>> exploredTargets =
result.getExplorationSpec().getTargets();
RuleSet exploredRuleSet =
createRuleSet("CLI All Defined Targets", "No author", "No comment");
exploredRuleSet.getExplorationTargets().addAll(exploredTargets);
expStep.getRuleSets().add(exploredRuleSet);
return expStep;
}
}
}
/*-------------------------------------------------------------------------+
| Copyright 2020 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.cli;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import static org.fortiss.af3.exploration.util.ExplorationCLIUtils.findMatchingDSEProject;
import static org.fortiss.af3.exploration.util.ExplorationCLIUtils.getExplorationTypeByArgument;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.info;
import java.util.Collection;
import java.util.Set;
import org.fortiss.af3.allocation.model.AllocationTableCollection;
import org.fortiss.af3.exploration.ExplorationActivator;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.lang.ExplorationExpressionDeploymentValidator;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.model.project.ExplorationStep;
import org.fortiss.af3.exploration.model.project.ModelSnapshot;
import org.fortiss.af3.exploration.model.project.ProcessStep;
import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution;
import org.fortiss.af3.exploration.service.IDSESolutionExporterService;
import org.fortiss.af3.exploration.solutionconverter.DSESolutionArtifacts;
import org.fortiss.af3.task.model.allocation.TaskToExecutionUnitAllocationEntry;
import org.fortiss.af3.task.model.allocation.TaskToExecutionUnitAllocationTable;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.kernel.extension.ICommandLineSwitchHandler;
import org.fortiss.tooling.kernel.model.IProjectRootElement;
/**
* Enables the validation of solutions produced by a DSE execution and the corresponding solution
* conversion code for transferring these results to the modeling world.
*
* @author diewald
*/
public class ValidateDSESolutionCommandLineInterface implements ICommandLineSwitchHandler {
/**
* References the DSE solution exporter service used for transforming DSE solutions back to the
* modeling world.
*/
private final IDSESolutionExporterService dseExportService =
IDSESolutionExporterService.getInstance();
/** {@inheritDoc} */
@Override
public boolean hasAdditionalArgument() {
return true;
}
/** {@inheritDoc} */
@Override
public void handleCLISwitch(String argument) {
DSE matchingDSE = findMatchingDSEProject(argument);
if(matchingDSE == null) {
return;
}
ProcessStep currentStep = matchingDSE.getCurrentStep();
if(!(currentStep instanceof ExplorationStep)) {
error(ExplorationActivator.getDefault(), "The validator can only be executed if the " +
"current step of a DSE points to an ExplorationStep.");
return;
}
Set<Class<? extends IModelElement>> solutionModels = getExplorationTypeByArgument(argument);
if(solutionModels.isEmpty()) {
return;
}
ExplorationStep expStep = (ExplorationStep)currentStep;
for(SingleExplorationSolution singleSolution : expStep.getSolution().getSolutions()) {
boolean isSolutionValidated = false;
try {
isSolutionValidated = validateSingleSolution(expStep, singleSolution);
} catch(Exception e1) {
error(ExplorationActivator.getDefault(), "The validator for the solver model.");
} finally {
if(isSolutionValidated) {
info(ExplorationActivator.getDefault(),
"The solution " + singleSolution.getName() +
" passed the validation of the produced SuperSets.");
} else {
error(ExplorationActivator.getDefault(),
"The solution " + singleSolution.getName() +
" did not pass the validation of the produced SuperSets.");
}
}
try {
isSolutionValidated =
validateTransformedSolution(expStep, solutionModels, singleSolution);
} catch(Exception e) {
error(ExplorationActivator.getDefault(),
"The validator for the exported solution from the DSE failed.", e);
} finally {
if(isSolutionValidated) {
info(ExplorationActivator.getDefault(),
"The solution " + singleSolution.getName() +
" passed the validation of the produced model elements.");
} else {
error(ExplorationActivator.getDefault(),
"The solution " + singleSolution.getName() +
" did not pass the validation of the produced model elements.");
}
}
}
}
/**
* Validates the solution {@link SuperSet}s produced by a DSE backend. Thus, the optimizer and
* the back-transformation of its solution model is validated.
*
* @throws Exception
*/
private boolean validateSingleSolution(ExplorationStep expStep,
SingleExplorationSolution singleSolution) throws Exception {
SuperSet<TaskToExecutionUnitAllocationEntry> allocationSet =
singleSolution.getSolutionModel(TaskToExecutionUnitAllocationEntry.class);
if(allocationSet != null) {
ExplorationExpressionDeploymentValidator validator =
new ExplorationExpressionDeploymentValidator(allocationSet.getEntries(),
expStep.getRuleSets());
return validator.validate();
}
return false;
}
/**
* Validates the solution exported from the DSE. Thereby, the validation includes the operation
* of {@link IDSESolutionExporterService}.
*/
private boolean validateTransformedSolution(ExplorationStep expStep,
Set<Class<? extends IModelElement>> solutionModels,
SingleExplorationSolution singleSolution) throws Exception {
Collection<IProjectRootElement> rootInputElements = expStep.getInputArtifacts().stream()
.map(i -> ((ModelSnapshot)i).getRootElement()).collect(toList());