diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/.ratings index c013b02fd1db17e9f39a3ca091f01a8d4863069e..ac94feeb8a446738fd564b93c2334190db780ac7 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/.ratings @@ -1 +1 @@ -Opt4JDseBackend.java 4f9559ae2dce6b0378ef936843f521d4b5993dde RED +Opt4JDseBackend.java f0485dc7fbc69c31f2f7fd15a7dad582ee5d7636 RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/Opt4JDseBackend.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/Opt4JDseBackend.java index 0360eb468e60f3b8f9491f1a1c53de7b554a932a..91928dee43716df571dc3a6a5f4031401ed3ae61 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/Opt4JDseBackend.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/backend/Opt4JDseBackend.java @@ -27,6 +27,7 @@ import java.util.Optional; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.swt.widgets.Display; import org.fortiss.af3.component.model.ComponentArchitecture; import org.fortiss.af3.exploration.alg.dse.CompositeExplorationSolution; @@ -66,7 +67,7 @@ public class Opt4JDseBackend implements IDseBackend { private final Collection<Class<?>> requiredInputModels = Arrays.asList( ComponentArchitecture.class, TaskArchitecture.class, PlatformArchitecture.class); - // TODO: Remove after migration to AF3 visiualization + // TODO: Remove after migration to AF3 visualization /** Last {@link XYPlotter} (in order to close it before creating a new one. */ protected XYPlotter lastPlotter; @@ -94,10 +95,12 @@ public class Opt4JDseBackend implements IDseBackend { // Input to DSE: {@link SystemModelAdapter} and {@link DesignSpaceExploration}. // SystemModelAdapter systemModelAdapter; - systemModelAdapter = new AF3SystemModelAdapter(superSets.get(Task.class), - superSets.get(ComponentToTaskAllocationEntry.class), - superSets.get(ExecutionUnit.class), superSets.get(Signal.class)); - DseSpecification dseSpec = createDefaultDesignSpaceExploration(expSpec, context); + systemModelAdapter = + new AF3SystemModelAdapter(superSets.get(Task.class), + superSets.get(ComponentToTaskAllocationEntry.class), + superSets.get(ExecutionUnit.class), superSets.get(Signal.class)); + DseSpecification dseSpec = + createDefaultDesignSpaceExploration(EcoreUtil.copy(expSpec), context); // Set the requested solutions. Set<Class<?>> solutionTypes = new HashSet<>(); @@ -145,8 +148,8 @@ public class Opt4JDseBackend implements IDseBackend { * Temporary helper method to extract the architecture model from a {@link SuperSet} provided in * the {@link SuperSetMap} to the DSE. */ - private <T extends IModelElement, S extends IModelElement> T getArchModel(SuperSetMap superSets, - Class<T> archModelType, Class<S> elementType) throws Exception { + private <T extends IModelElement, S extends IModelElement> T getArchModel( + SuperSetMap superSets, Class<T> archModelType, Class<S> elementType) throws Exception { Optional<S> anyElem = getFirst(superSets.get(elementType).getEntries()); if(!anyElem.isPresent()) { throw new Exception("No " + elementType.getSimpleName() + @@ -170,8 +173,9 @@ public class Opt4JDseBackend implements IDseBackend { // draw figure // FIXME: Unchecked cast to ExplorationSolutionSet - XYPlotter plotter = new XYPlotter(solutionSet.getExplorationSpec(), solutionSet, - "Design Space Exploration Result (generations: " + "N/A" + ")"); + XYPlotter plotter = + new XYPlotter(solutionSet.getExplorationSpec(), solutionSet, + "Design Space Exploration Result (generations: " + "N/A" + ")"); plotter.createPlot(); plotter.pack(); RefineryUtilities.centerFrameOnScreen(plotter); diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/.ratings index 08035aab4f6d654cecb53e128dbd550023890788..09629640790fc796517b65d2b55d14b69dd82bf9 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/.ratings @@ -1,4 +1,4 @@ -CompositeExplorationSolution.java c35b0b0cf5658300b5e8c4f2cc9e217c29ae37a3 RED +CompositeExplorationSolution.java 88849af9f8a52684cc523f89e235599e16dd9ac3 RED DSEFactory.java 0a2f2cc6a197e760c1f8223339ffa5f16856b184 RED Explorer.java 2194a74cbe51ca9e7dafb008dcefb51a54064dc8 RED ImplicitExplorationTargetFactory.java 6c16c6712886b549dda0a73aef4a4c3fe18c1850 RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/CompositeExplorationSolution.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/CompositeExplorationSolution.java index 6616895151cbc20232e223e65a20067ab5726e51..1910fcd1d1e4a1b003b7a4e1bb52460eec5362dd 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/CompositeExplorationSolution.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/CompositeExplorationSolution.java @@ -25,7 +25,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import org.eclipse.emf.ecore.EObject; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.IExplorationSolution; @@ -179,10 +178,13 @@ public class CompositeExplorationSolution<P extends Phenotype> { outputTypes.add(SuperSetMap.class); ExplorationTransformationInputs inputs = new ExplorationTransformationInputs(null, internalSolutions); - Map<Class<EObject>, ?> solutionModels = + Map<Class<IModelElement>, IModelElement> solutionModels = getService(IExplorationTransformationService.class).getTransformedModels( DSE_INTERNAL, null, inputs, outputTypes, ""); - singleExpSolution.setSolutionSets((SuperSetMap)solutionModels.get(SuperSetMap.class)); + SuperSetMap transformedSuperSets = (SuperSetMap)solutionModels.get(SuperSetMap.class); + transformedSuperSets.keySet().forEach( + k -> singleExpSolution.putSolutionModel((Class<IModelElement>)k, + transformedSuperSets.get((Class<IModelElement>)k))); // Invalid solutions are filtered before. singleExpSolution.setSolutionState(SolutionState.OPTIMIZED); diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/.ratings index 3d0c634caaac904168a84a330a3e2c29c8f9db39..cf90b997a025d6a54ed09d7db99ba84c61eecfb0 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/.ratings @@ -4,4 +4,4 @@ ScheduleLabelGenerator.java 0ceecedfec9802bbcaa33525d61e1a60a70d3841 RED SchedulePlotter.java 29b1156c9419d4ff3314c4b2c932aeb46f4749f8 RED ScheduleToolTipGenerator.java cedfa0dd7ebc7b48d7cc70e966eebaeee9636caf RED TaskSeriesCollectionFromSchedule.java b53b7af649c48980520ad572da8c7bbdbae0aed5 RED -XYPlotter.java b8abd061e80509c7c8af83baf584e9549c98a4d9 RED +XYPlotter.java a70c65b6138805d91ad1db551bcc4e7cfc1dc200 RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/XYPlotter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/XYPlotter.java index 8374540a3f1d363d08bcec701a73f833c97df638..a572858c9b5a3f2cf62bc0860b19499925f30a64 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/XYPlotter.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/plot/XYPlotter.java @@ -22,7 +22,6 @@ import static org.fortiss.af3.exploration.alg.service.IExplorationTransformation import static org.fortiss.af3.exploration.util.DesignSpaceExplorationModelElementFactory.createSuperSetMap; import static org.fortiss.af3.exploration.util.ExplorationUtils.createExceptionStatus; import static org.fortiss.af3.project.utils.ProjectUtils.getFileProject; -import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElements; import java.awt.Color; import java.awt.GridBagConstraints; @@ -66,6 +65,7 @@ import org.fortiss.af3.exploration.model.solutions.ExplorationSolution; import org.fortiss.af3.exploration.model.solutions.SingleExplorationSolution; import org.fortiss.af3.partition.model.allocation.PartitionToExecutionUnitAllocationEntry; import org.fortiss.af3.project.model.FileProject; +import org.fortiss.tooling.base.model.element.IModelElement; import org.fortiss.tooling.common.util.LambdaUtils; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; import org.fortiss.tooling.kernel.service.IPersistencyService; @@ -613,9 +613,9 @@ public class XYPlotter extends JFrame implements ChartMouseListener, ActionListe * * @throws Exception */ - private AllocationTableCollection transformSingleDeployment( - SingleExplorationSolution solutionMap, String deploymentName, boolean generateSCSpec) - throws Exception { + @SuppressWarnings("unchecked") + private AllocationTableCollection transformSingleDeployment(SingleExplorationSolution solution, + String deploymentName, boolean generateSCSpec) throws Exception { // Deployment generation has NOT been cancelled. if(deploymentName.isEmpty()) { deploymentName = "_Deployment"; @@ -641,7 +641,7 @@ public class XYPlotter extends JFrame implements ChartMouseListener, ActionListe // TODO: The context must be an export here. In a future version, it must be // possible to specify, how the transformed model can be injected / exported. SuperSet<PartitionToExecutionUnitAllocationEntry> partToExU = - solutionMap.getSolutionSets().get(PartitionToExecutionUnitAllocationEntry.class); + solution.getSolutionModel(PartitionToExecutionUnitAllocationEntry.class); PartitionToExecutionUnitAllocationEntry entry = LambdaUtils.getFirst(partToExU.getEntries()).get(); ITopLevelElement modelContext = @@ -657,13 +657,16 @@ public class XYPlotter extends JFrame implements ChartMouseListener, ActionListe // TODO: clearer separation between In- and output models. // Create a new SuperSet Map that combines in and outputs. - SuperSetMap solutionSuperSets = solutionMap.getSolutionSets(); + Collection<Class<? extends IModelElement>> solutionSuperSetTypes = + solution.getAvailableSolutionModels(); SuperSetMap superSetMap = createSuperSetMap(); - for(Class<?> setType : solutionSuperSets.keySet()) { - superSetMap.put((Class)setType, solutionSuperSets.get((Class)setType)); + for(Class<? extends IModelElement> setType : solutionSuperSetTypes) { + superSetMap.put((Class<IModelElement>)setType, + solution.getSolutionModel((Class<IModelElement>)setType)); } for(Class<?> setType : expSpec.getSearchSpace().keySet()) { - superSetMap.put((Class)setType, expSpec.getSearchSpace().get((Class)setType)); + superSetMap.put((Class<IModelElement>)setType, + expSpec.getSearchSpace().get((Class<IModelElement>)setType)); } ExplorationTransformationInputs inputs = new ExplorationTransformationInputs(superSetMap, null); @@ -747,21 +750,4 @@ public class XYPlotter extends JFrame implements ChartMouseListener, ActionListe fp.getRootElements().add(deployment); fp.getRootElements().add(deployment); } - - /** - * Actually generates the an AF3 deployment model from a given solution in the provided model - * context and registers the resulting deployment (and a possibly generated - * {@link ComponentArchitecture}) in the {@link FileProject} of the DSE. - */ - private <S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - void addDeploymentToProject(Deployment deployment) { - ComponentArchitecture deployedArchitecture = - (ComponentArchitecture)deployment.getComponentArchitectureReference() - .getReference(); - FileProject fp = getFileProject(expSpec); - if(!getRootElements(expSpec, ComponentArchitecture.class).contains(deployedArchitecture)) { - fp.getRootElements().add(deployedArchitecture); - } - fp.getRootElements().add(deployment); - } }