...
 
Commits (25)
......@@ -254,8 +254,7 @@ public class DSMLtoGATransformatorFuzzy implements DSMLtoGATransformator {
} else if(expr instanceof Or) {
return gt -> Math.max(left.apply(gt), right.apply(gt));
} else if(expr instanceof Implies) {
throw new RuntimeException("Unsupported");
// return gt -> !right.apply(gt) || left.apply(gt);
return gt -> Math.max(1 - right.apply(gt), left.apply(gt));
}
} else if(expr instanceof IUnaryOperator<?>) {
Function<Genotype<IntegerGene>, Double> right =
......
......@@ -200,7 +200,7 @@ public class GAExecutor {
.selector(UFTournamentSelector.ofVec()).populationSize(popSize)
// .offspringSelector(new TournamentSelector<IntegerGene, Vec<double[]>>())
// .survivorsSelector(UFTournamentSelector.ofVec()).populationSize(popSize)
.build().limit(() -> Limits.byGeneConvergence(0.9, 0.6))
.build().limit(() -> Limits.byGeneConvergence(0.9, 0.8))
/* .limit(() -> Limits.byFixedGeneration(800)) */.limit(
() -> (val -> !isAborted))
.limit(() -> Limits.byExecutionTime(Duration.ofMillis(timeout)));
......@@ -218,6 +218,14 @@ public class GAExecutor {
// System.out.println(statistics);
if(results.size() == 1) {
return isValid(results.get(0).genotype());
}
// If there are multiple results all have to be valid. At least one is valid as otherwise
// all solutions would have the same fitness across all dimensions. If there is at least one
// valid solution, all others have to be valid as well since they would be dominated by the
// valid one otherwise
return true;
}
......
......@@ -284,6 +284,7 @@ public class SolverILP implements ISolver {
} else {
System.out.println("No solution found");
expSolution.setSolutionState(UNSAT);
return true;
}
cplex.remove(maximize);
......
......@@ -15,35 +15,23 @@
+--------------------------------------------------------------------------*/
package test.org.fortiss.af3.exploration.smt.suite.base;
import static org.fortiss.af3.exploration.util.ExplorationModelElementFactory.createExplorationConstraint;
import static org.fortiss.af3.exploration.util.ExplorationModelElementFactory.createExplorationObjective;
import static org.fortiss.af3.exploration.util.ExplorationModelElementFactory.createResourceDimension;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createBusWeightOptimizationPatternExpression;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createRouteWeightConstraintPatternExpression;
import static org.junit.Assert.assertTrue;
import static test.org.fortiss.af3.exploration.smt.util.TestDSEUtils.initializeDSE;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Random;
import java.util.stream.Collectors;
import org.apache.commons.io.filefilter.RegexFileFilter;
import org.apache.commons.lang.StringUtils;
import org.eclipse.emf.common.util.EList;
import org.fortiss.af3.exploration.dseml.model.expression.IExpression;
import org.fortiss.af3.exploration.model.IExplorationConstraint;
import org.fortiss.af3.exploration.model.IExplorationObjective;
import org.fortiss.af3.exploration.model.IExplorationTarget;
import org.fortiss.af3.exploration.model.SuperSetMap;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.model.project.ProcessStep;
import org.fortiss.af3.exploration.model.project.TargetDefinitionStep;
import org.fortiss.af3.exploration.model.solutions.ExplorationSolution;
import org.fortiss.af3.platform.model.TransmissionUnit;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.tooling.base.annotation.AnnotationValueService;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
......@@ -159,7 +147,7 @@ public class PerformanceTest {
/** {@inheritDoc} */
@Override
protected void addAdditionalConstraints() throws Exception {
// empty
super.addAdditionalConstraints();
}
/** {@inheritDoc} */
......@@ -183,36 +171,7 @@ public class PerformanceTest {
/** {@inheritDoc} */
@Override
protected void addAdditionalConstraints() throws Exception {
EList<TransmissionUnit> busses = superSetMap.get(TransmissionUnit.class).getEntries();
if(!busses.isEmpty()) {
TransmissionUnit selectedBus = busses.get((new Random()).nextInt(busses.size()));
Collection<IExplorationConstraint<?>> constraints = new ArrayList<>();
IExpression routeWeightExpression =
createRouteWeightConstraintPatternExpression(dse);
constraints.add(createExplorationConstraint(Boolean.class,
createResourceDimension(), routeWeightExpression, "BandwidthWeight", true));
// for(TransmissionUnit bus : dse.getCurrentStep().getSuperSetMap()
// .get(TransmissionUnit.class).getEntries()) {
// for(Route route : dse.getCurrentStep().getSuperSetMap().get(Route.class)
// .getEntries()) {
// IExpression routeUsesBusExpression =
// createRouteUsesBusConstraintPatternExpression(dse, bus, route);
// constraints.add(createExplorationConstraint(Boolean.class,
// createResourceDimension(), routeUsesBusExpression, "RouteUsesBus",
// true));
// }
// }
IExpression expr =
createBusWeightOptimizationPatternExpression(dse, selectedBus, true);
IExplorationObjective<Double> objective = createExplorationObjective(Double.class,
createResourceDimension(), expr, "Bandwidth " + selectedBus.getName());
objective.getImplicitConstraints().addAll(constraints);
explorationTargets.add(objective);
}
super.addAdditionalConstraints();
}
/** {@inheritDoc} */
......@@ -232,36 +191,7 @@ public class PerformanceTest {
/** {@inheritDoc} */
@Override
protected void addAdditionalConstraints() throws Exception {
EList<TransmissionUnit> busses = superSetMap.get(TransmissionUnit.class).getEntries();
if(!busses.isEmpty()) {
TransmissionUnit selectedBus = busses.get((new Random()).nextInt(busses.size()));
Collection<IExplorationConstraint<?>> constraints = new ArrayList<>();
IExpression routeWeightExpression =
createRouteWeightConstraintPatternExpression(dse);
constraints.add(createExplorationConstraint(Boolean.class,
createResourceDimension(), routeWeightExpression, "BandwidthWeight", true));
// for(TransmissionUnit bus : dse.getCurrentStep().getSuperSetMap()
// .get(TransmissionUnit.class).getEntries()) {
// for(Route route : dse.getCurrentStep().getSuperSetMap().get(Route.class)
// .getEntries()) {
// IExpression routeUsesBusExpression =
// createRouteUsesBusConstraintPatternExpression(dse, bus, route);
// constraints.add(createExplorationConstraint(Boolean.class,
// createResourceDimension(), routeUsesBusExpression, "RouteUsesBus",
// true));
// }
// }
IExpression expr =
createBusWeightOptimizationPatternExpression(dse, selectedBus, true);
IExplorationObjective<Double> objective = createExplorationObjective(Double.class,
createResourceDimension(), expr, "Bandwidth " + selectedBus.getName());
objective.getImplicitConstraints().addAll(constraints);
explorationTargets.add(objective);
}
super.addAdditionalConstraints();
}
/** {@inheritDoc} */
......
......@@ -25,6 +25,7 @@ Export-Package: org.fortiss.af3.exploration.ui,
org.fortiss.af3.exploration.ui.menu,
org.fortiss.af3.exploration.ui.perspective,
org.fortiss.af3.exploration.ui.perspective.dashboard.projectwizard,
org.fortiss.af3.exploration.ui.perspective.extension,
org.fortiss.af3.exploration.ui.perspective.generic,
org.fortiss.af3.exploration.ui.perspective.navigator,
org.fortiss.af3.exploration.ui.perspective.process,
......
......@@ -3,6 +3,7 @@
<!-- (c) 2017 fortiss GmbH -->
<plugin>
<extension-point id="externalDSEExtensionProvider" name="External DSE Extension Provider" schema="schema/externalDSEExtensionProvider.exsd"/>
<!-- TODO(AD, #3669): Currently disabled in the UI. -->
<!--extension
point="org.fortiss.tooling.kernel.ui.contextMenuContribution">
......
......@@ -132,7 +132,7 @@
<Insets right="2.0" />
</GridPane.margin>
</Button>
<Button fx:id="importButton" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#onImportButton" text="Import external model" GridPane.columnIndex="1">
<Button fx:id="importButton" disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Import external model" GridPane.columnIndex="1">
<GridPane.margin>
<Insets left="2.0" />
</GridPane.margin>
......
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.fortiss.af3.exploration.ui" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.fortiss.af3.exploration.ui" id="externalDSEExtensionProvider" name="External DSE Extension Provider"/>
</appInfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence>
<element ref="externalDSEExtensionProvider" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="externalDSEExtensionProvider">
<complexType>
<attribute name="externalDSEExtensionProvider" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.fortiss.af3.exploration.ui.perspective.extension.IExternalDSEExtensionProvider"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiinfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>
DashboardFXController.java 10823c69ca83bb53bb8ca2b800ee6a148823182e GREEN
DashboardFXController.java 3f3908778140dc05c4d1b4c6faf3fd752589f1fb GREEN
DashboardFXViewPart.java 93e8ed38fb398aa5ababc85877a5fed8d5b88723 GREEN
......@@ -22,24 +22,17 @@ import static org.fortiss.af3.exploration.ui.perspective.service.IEventListener.
import static org.fortiss.af3.exploration.ui.perspective.service.IEventListener.DSE_EVENT.DSE_SELECTED_EVENT;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.showError;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Display;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.service.IDSEBackendService;
import org.fortiss.af3.exploration.ui.AF3ExplorationUIActivator;
import org.fortiss.af3.exploration.ui.perspective.dashboard.projectwizard.DashboardWizard;
import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager;
import org.fortiss.af3.exploration.ui.perspective.service.EventBroker;
import org.fortiss.af3.exploration.ui.perspective.service.IDSEPerspectiveManager;
import org.fortiss.af3.exploration.ui.perspective.service.IEventListener;
import org.fortiss.af3.exploration.ui.perspective.service.IExternalDSEExtensionService;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.tooling.common.ui.javafx.layout.CompositeFXControllerBase;
......@@ -143,28 +136,6 @@ public class DashboardFXController extends CompositeFXControllerBase<AnchorPane,
wizard.dispose();
}
/** Launches the import dialog for external models. */
public void onImportButton() {
if(!IExternalDSEExtensionService.INSTANCE.isImportWizardAvailable()) {
showError("No external import wizard available: None has been registered.");
return;
}
Class<? extends Wizard> importWizard =
IExternalDSEExtensionService.INSTANCE.getImportWizard();
try {
Constructor<? extends Wizard> constructor = importWizard.getConstructor();
Wizard newInstance = constructor.newInstance();
WizardDialog dialog =
new WizardDialog(Display.getDefault().getActiveShell(), newInstance);
dialog.open();
} catch(NoSuchMethodException | SecurityException | InstantiationException |
IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
showError("Failed to launch the import wirzard. Please refer to the log for details.");
error(AF3ExplorationUIActivator.getDefault(), "Failed to launch the import wirzard", e);
}
}
/** {@inheritDoc} */
@Override
public void propertyChanged(Object source, DSE_EVENT propId) {
......
IExternalDSEExtensionProvider.java 85871542b13d45760c58811ed1a830fc73176d55 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.ui.perspective.extension;
import java.util.List;
import org.fortiss.af3.exploration.ui.perspective.service.IExternalDSEExtensionService;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternFXControllerBase;
import org.fortiss.tooling.kernel.service.base.IObjectAware;
/**
* Interface for the providers of external DSE extensions.
* Instances are handled by the {@link IExternalDSEExtensionService}.
*
* @author munaro
*/
public interface IExternalDSEExtensionProvider extends IObjectAware<Object> {
/** Returns the constraint patterns to add. */
List<PatternFXControllerBase> getConstraintPatterns();
/** Returns the objective patterns to add. */
List<PatternFXControllerBase> getObjectivePatterns();
}
DSEPerspectiveManager.java ad2b28bf6bb8414eda0b1606c53befb8ef731a3a GREEN
EventBroker.java 5614a199ffe288807a29cf9c213787f52c3555e8 GREEN
ExternalDSEExtensionService.java 7290acc7b8f1735d43a23802f75509e2c441e0d2 GREEN
ExternalDSEExtensionService.java f402cb069178fdd12ab89f3244490f56bf3f37d1 GREEN
IDSEPerspectiveManager.java 2bc063e88352828ca0d3264730670694dbee76e4 GREEN
IEventListener.java 6d7eb240719a7d7ef0a2619c2fc72a22109c2786 GREEN
IExternalDSEExtensionService.java 32fe4caebc9ebe0660a53e093858b841b279cfe1 GREEN
IExternalDSEExtensionService.java f7a7b36329b112a1236752cf7f8f23ebf0f04818 GREEN
......@@ -15,95 +15,132 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.service;
import static java.util.Collections.emptyList;
import static org.fortiss.tooling.kernel.utils.ExtensionPointUtils.getBundle;
import static org.fortiss.tooling.kernel.utils.ExtensionPointUtils.getConfigurationElements;
import static org.fortiss.tooling.kernel.utils.ExtensionPointUtils.loadClass;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.eclipse.core.runtime.IConfigurationElement;
import org.fortiss.af3.exploration.ui.perspective.extension.IExternalDSEExtensionProvider;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternFXControllerBase;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
import org.fortiss.tooling.kernel.service.IKernelIntrospectionSystemService;
import org.osgi.framework.Bundle;
/**
* Singleton implementation of {@link IExternalDSEExtensionService}.
*
* @author eder
* @author munaro
*/
public class ExternalDSEExtensionService implements IExternalDSEExtensionService {
public class ExternalDSEExtensionService
implements IExternalDSEExtensionService, IIntrospectiveKernelService {
/** List storing all externally registered constraint patterns. */
private List<PatternFXControllerBase> registeredConstraintPatterns = new ArrayList<>();
/** List storing all externally registered objective patterns. */
private List<PatternFXControllerBase> registeredObjectivePatterns = new ArrayList<>();
/** The singleton instance. */
private static IExternalDSEExtensionService INSTANCE;
/** Constructor. */
private ExternalDSEExtensionService() {
// Prevent instantiation of this singleton.
}
/** Returns the singleton instance of {@code this} {@link ExternalDSEExtensionService}. */
public static synchronized IExternalDSEExtensionService getInstance() {
if(INSTANCE == null) {
INSTANCE = new ExternalDSEExtensionService();
}
return INSTANCE;
}
/** The connector extension point ID. */
private static final String EXTENSION_POINT_NAME =
"org.fortiss.af3.exploration.ui.externalDSEExtensionProvider";
/** The connector configuration element name. */
private static final String CONFIGURATION_ELEMENT_NAME = "externalDSEExtensionProvider";
/** List storing all externally registered constraints patterns. */
private List<PatternStruct> registeredPatterns = new ArrayList<>();
/** Class of external import wizard. */
private Class<? extends Wizard> importWizard = null;
/** Custom logo. */
private Image logo = null;
/** The connector attribute name. */
private static final String ATTRIBUTE_NAME = "externalDSEExtensionProvider";
/** {@inheritDoc} */
@Override
public void registerNewConstraintPattern(String name, Class<? extends Composite> composite) {
PatternStruct patternStruct = new PatternStruct();
patternStruct.isUtilizationPattern = false;
patternStruct.name = name;
patternStruct.composite = composite;
registeredPatterns.add(patternStruct);
public void startService() {
IKernelIntrospectionSystemService.getInstance().registerService(this);
}
/** {@inheritDoc} */
@Override
public void registerNewUtilizationConstraintPattern(String name,
Class<? extends Composite> composite, Class<? extends IAnnotatedSpecification> spec1,
Class<? extends IAnnotatedSpecification> spec2) {
PatternStruct patternStruct = new PatternStruct();
patternStruct.isUtilizationPattern = true;
patternStruct.name = name;
patternStruct.composite = composite;
patternStruct.spec1 = spec1;
patternStruct.spec2 = spec2;
registeredPatterns.add(patternStruct);
public void initializeService() {
for(IConfigurationElement ce : getConfigurationElements(EXTENSION_POINT_NAME,
CONFIGURATION_ELEMENT_NAME)) {
Bundle bundle = getBundle(ce);
try {
Class<?> handlerClass = loadClass(ce.getAttribute(ATTRIBUTE_NAME), bundle);
IExternalDSEExtensionProvider provider =
(IExternalDSEExtensionProvider)handlerClass.getConstructor().newInstance();
registeredConstraintPatterns.addAll(provider.getConstraintPatterns());
registeredObjectivePatterns.addAll(provider.getObjectivePatterns());
} catch(Exception ex) {
error(ToolingKernelActivator.getDefault(), ex.getMessage(), ex);
}
}
}
/** {@inheritDoc} */
@Override
public List<PatternStruct> getRegisteredPatterns() {
return registeredPatterns;
public List<PatternFXControllerBase> getConstraintPatterns() {
return registeredConstraintPatterns;
}
/** {@inheritDoc} */
@Override
public void registerImportWizard(Class<? extends Wizard> importWizard) {
this.importWizard = importWizard;
public List<PatternFXControllerBase> getObjectivePatterns() {
return registeredObjectivePatterns;
}
/** {@inheritDoc} */
@Override
public boolean isImportWizardAvailable() {
return importWizard == null ? false : true;
public String getIntrospectionLabel() {
return "External DSE Extension Service";
}
/** {@inheritDoc} */
@Override
public Class<? extends Wizard> getImportWizard() {
return importWizard;
public boolean showInIntrospectionNavigation() {
return true;
}
/** {@inheritDoc} */
@Override
public void registerCustomLogo(ImageDescriptor logoDescr) {
if(logo != null) {
logo.dispose();
}
logo = logoDescr.createImage();
public Collection<IIntrospectionItem> getIntrospectionItems() {
return emptyList();
}
/** {@inheritDoc} */
@Override
public boolean isCustomLogoAvailable() {
return logo == null ? false : true;
public IIntrospectionDetailsItem getDetailsItem() {
return null;
}
/** {@inheritDoc} */
@Override
public Image getCustomLogo() {
return logo;
public String getIntrospectionDescription() {
return getIntrospectionLabel() +
"\n\nThe service is used to add external Design Space Exploration (DSE) patterns.";
}
}
......@@ -17,84 +17,30 @@ package org.fortiss.af3.exploration.ui.perspective.service;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternFXControllerBase;
/**
* Service interface to adapt DSE perspective UI from outside this plugin.
* Service interface to add constraint and objective patterns from outside this plug-in.
*
* @author eder
* @author munaro
*/
public interface IExternalDSEExtensionService {
/** Singleton instance. */
public IExternalDSEExtensionService INSTANCE = new ExternalDSEExtensionService();
/**
* Adds a new section to the constraint view. The backend composite should be provided here.
*
* @param name
* the name of the pattern
* @param composite
* the SWT composite
*/
public void registerNewConstraintPattern(String name, Class<? extends Composite> composite);
/**
* Adds a new section to the constraint view. The utilization backend composite should be
* provided here. IMPORTANT: the order of spec1 and spec2 has to be equal to the order of the
* specifications in the constructor of the implemented utilization pattern class.
*
* @param name
* the name of the pattern
* @param composite
* the SWT composite
* @param spec1
* the logical component annotation specification
* @param spec2
* the technical ecu annotation specification
*/
public void registerNewUtilizationConstraintPattern(String name,
Class<? extends Composite> composite, Class<? extends IAnnotatedSpecification> spec1,
Class<? extends IAnnotatedSpecification> spec2);
/** Returns all registered patterns. */
public List<PatternStruct> getRegisteredPatterns();
/**
* Registers an import wizard. Only wizards with no arguments in the constructor may be
* registered. Note: Only one wizard maybe registered. will be handled like
* LiFo.
*/
public void registerImportWizard(Class<? extends Wizard> importWizard);
/** Returns the latest registered import wizard or null if there is none. */
public Class<? extends Wizard> getImportWizard();
/** Returns true if an import wizard has been registered else false. */
public boolean isImportWizardAvailable();
/** Returns the singleton instance of the {@link IExternalDSEExtensionService}. */
public static IExternalDSEExtensionService getInstance() {
return ExternalDSEExtensionService.getInstance();
}
/**
* Registers a custom logo. Note: Only one logo may be registered. Will be handled like LiFo.
*/
public void registerCustomLogo(ImageDescriptor logo);
/** Starts the service. */
public void startService();
/** Returns the latest registered custom logo {@link Image} or {@code null} if there is none. */
public Image getCustomLogo();
/** Initializes the service. */
public void initializeService();
/** Returns true if an a custom has been registered else false. */
public boolean isCustomLogoAvailable();
/** Returns all registered constraint patterns. */
public List<PatternFXControllerBase> getConstraintPatterns();
/** Struct for storing external pattern information. */
@SuppressWarnings("javadoc")
public class PatternStruct {
public boolean isUtilizationPattern;
public String name;
public Class<? extends Composite> composite;
public Class<? extends IAnnotatedSpecification> spec1;
public Class<? extends IAnnotatedSpecification> spec2;
}
/** Returns all registered objective patterns. */
public List<PatternFXControllerBase> getObjectivePatterns();
}
ConstraintsFXViewPart.java 51d0d643b74d13231e34248702c467949f93936a GREEN
ConstraintsFXViewPart.java 95cb8c21ca2efe514cc765fe4a19d98e4819499b GREEN
......@@ -15,12 +15,19 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.targetdef.constraint;
import static java.util.Arrays.asList;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.fx.ui.workbench3.FXViewPart;
import org.fortiss.af3.exploration.ui.perspective.generic.ExplorationUIFXController;
import org.fortiss.af3.exploration.ui.perspective.generic.ExplorationUIFXViewPart;
import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager;
import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager.EProcessStep;
import org.fortiss.af3.exploration.ui.perspective.service.IExternalDSEExtensionService;
import org.fortiss.af3.exploration.ui.perspective.targetdef.ConstraintObjectiveFXController;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternFXControllerBase;
import org.fortiss.af3.exploration.ui.perspective.targetdef.constraint.pattern.AllocationPatternFXController;
import org.fortiss.af3.exploration.ui.perspective.targetdef.constraint.pattern.CouplingPatternFXController;
import org.fortiss.af3.exploration.ui.perspective.targetdef.constraint.pattern.MemoryPatternFXController;
......@@ -36,16 +43,23 @@ public class ConstraintsFXViewPart extends ExplorationUIFXViewPart {
/** Constructor. */
public ConstraintsFXViewPart() throws Exception {
// @CodeFormatterOff
super(new ExplorationUIFXController(
new ConstraintObjectiveFXController(
new AllocationPatternFXController(),
new CouplingPatternFXController(),
new SafetyPatternFXController(),
new MemoryPatternFXController()),
"Constraints"),
"constraints_icon.png", null);
// @CodeFormatterOn
super(new ExplorationUIFXController(new ConstraintObjectiveFXController(getPatterns()),
"Constraints"), "constraints_icon.png", null);
}
/** Fetches internal and external constraint patterns to include in the view. */
private static PatternFXControllerBase[] getPatterns() {
List<PatternFXControllerBase> internalPatterns =
asList(new AllocationPatternFXController(), new CouplingPatternFXController(),
new SafetyPatternFXController(), new MemoryPatternFXController());
List<PatternFXControllerBase> externalPatterns =
IExternalDSEExtensionService.getInstance().getConstraintPatterns();
List<PatternFXControllerBase> patterns = new ArrayList<PatternFXControllerBase>();
patterns.addAll(internalPatterns);
patterns.addAll(externalPatterns);
return patterns.toArray(new PatternFXControllerBase[0]);
}
/** {@inheritDoc} */
......
AllocationPatternFXController.java 840bc404f6aefb8bc0e6f9b25f156d9db647178b GREEN
CouplingPatternFXController.java 937034aa2dd680abfcd815c32deb5f322663dc37 GREEN
AllocationPatternFXController.java 13cb6ad773ab746f167ee2f5684987b5be2e1424 GREEN
CouplingPatternFXController.java 4c6df087c82cdd5cee00936e73faf5cdf92f7a24 GREEN
MemoryPatternFXController.java b45b1eb1418d75cc4f4b2983b996b8ef4abab58d GREEN
SafetyPatternFXController.java 4d84c1bd15d1f8d15475849c5e2b9c24f094b76e GREEN
......@@ -28,6 +28,7 @@ import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeVie
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.RadioButton;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.TreeTableView;
import javafx.scene.control.TreeView;
......@@ -184,6 +185,10 @@ public class AllocationPatternFXController extends PatternFXControllerBase {
allocationButton.setToggleGroup(group);
dislocationButton.setToggleGroup(group);
allocationButton.setSelected(true);
// sets the selection mode of the viewer to allow at most one row selected
taskView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
ecuView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
/** {@inheritDoc} */
......
......@@ -42,6 +42,7 @@ import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeVie
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.RadioButton;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.TreeTableView;
import javafx.scene.control.TreeView;
......@@ -169,6 +170,9 @@ public class CouplingPatternFXController extends PatternFXControllerBase {
couplingButton.setToggleGroup(group);
decouplingButton.setToggleGroup(group);
couplingButton.setSelected(true);
// sets the selection mode of the viewer to allow multiple rows to be selected
view.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
/** {@inheritDoc} */
......
ObjectivesFXViewPart.java c41a2ea9b86c3f899a31fd960b188878a94c4113 GREEN
ObjectivesFXViewPart.java 0c28790e36d2eec4547e398988bc2e93863b5099 GREEN
......@@ -15,12 +15,19 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.ui.perspective.targetdef.objective;
import static java.util.Arrays.asList;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.fx.ui.workbench3.FXViewPart;
import org.fortiss.af3.exploration.ui.perspective.generic.ExplorationUIFXController;
import org.fortiss.af3.exploration.ui.perspective.generic.ExplorationUIFXViewPart;
import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager;
import org.fortiss.af3.exploration.ui.perspective.process.IProcessManager.EProcessStep;
import org.fortiss.af3.exploration.ui.perspective.service.IExternalDSEExtensionService;
import org.fortiss.af3.exploration.ui.perspective.targetdef.ConstraintObjectiveFXController;
import org.fortiss.af3.exploration.ui.perspective.targetdef.PatternFXControllerBase;
import org.fortiss.af3.exploration.ui.perspective.targetdef.objective.pattern.BusBandwidthOptimizationPatternFXController;
import org.fortiss.af3.exploration.ui.perspective.targetdef.objective.pattern.HardwareOptimizationPatternFXController;
......@@ -34,14 +41,23 @@ public class ObjectivesFXViewPart extends ExplorationUIFXViewPart {
/** Constructor. */
public ObjectivesFXViewPart() throws Exception {
// @CodeFormatterOff
super(new ExplorationUIFXController(
new ConstraintObjectiveFXController(
new HardwareOptimizationPatternFXController(),
new BusBandwidthOptimizationPatternFXController()),
"Objectives"),
"constraints_icon.png", null);
// @CodeFormatterOn
super(new ExplorationUIFXController(new ConstraintObjectiveFXController(getPatterns()),
"Objectives"), "constraints_icon.png", null);
}
/** Fetches internal and external constraint patterns to include in the view. */
private static PatternFXControllerBase[] getPatterns() {
List<PatternFXControllerBase> internalPatterns =
asList(new HardwareOptimizationPatternFXController(),
new BusBandwidthOptimizationPatternFXController());
List<PatternFXControllerBase> externalPatterns =
IExternalDSEExtensionService.getInstance().getObjectivePatterns();
List<PatternFXControllerBase> patterns = new ArrayList<PatternFXControllerBase>();
patterns.addAll(internalPatterns);
patterns.addAll(externalPatterns);
return patterns.toArray(new PatternFXControllerBase[0]);
}
/** {@inheritDoc} */
......
BusBandwidthOptimizationPatternFXController.java 51a11a64e1a94c8ce97e41cb2e9f0d81cdf691b8 GREEN
HardwareOptimizationPatternFXController.java 28d125e40b85e5054e40c046eb4a27e70589ebb4 GREEN
BusBandwidthOptimizationPatternFXController.java a8ca53c3dd130b80454f0272d4a6563465a7e8c2 GREEN
HardwareOptimizationPatternFXController.java d9bcf15caf37c784e80dbd9e5375c133217d8061 GREEN
......@@ -202,7 +202,7 @@ public class BusBandwidthOptimizationPatternFXController extends PatternFXContro
maxButton.setToggleGroup(group);
minButton.setSelected(true);
// sets the selection mode of the viewer to allow at most one row selected
// sets the selection mode of the viewer to allow only one row to be selected
view.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
}
......
......@@ -264,10 +264,12 @@ public class HardwareOptimizationPatternFXController extends PatternFXController
countButton.setToggleGroup(aggrGroup);
sumButton.setSelected(true);
// sets the selection mode of the viewer to allow at most one row selected
// sets the selection mode of the viewer to allow multiple rows to be selected
ecuView.getSelectionModel().selectAll();
propertyView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
taskView.getSelectionModel().selectAll();
ecuView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
propertyView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
taskView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
/** {@inheritDoc} */
......
SpiderChartVisualization.java a829db31b92435ba9b1f3508e246cc79a9c5dfd0 GREEN
SpiderChartVisualization.java f466f737829a8f626b136b2ddc988df8a42a2542 GREEN
......@@ -17,6 +17,7 @@ package org.fortiss.af3.exploration.ui.perspective.visualization.visualizations.
import static org.fortiss.af3.exploration.ui.util.SpiderChartUtils.transformIntoSpiderChart;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
......@@ -26,7 +27,10 @@ import org.fortiss.af3.exploration.ui.perspective.service.IDSEPerspectiveManager
import org.fortiss.af3.exploration.ui.perspective.service.IEventListener;
import org.fortiss.af3.exploration.ui.perspective.visualization.visualizations.IVisualizationView;
import org.fortiss.tooling.base.model.visualization.DataSetCollection;
import org.fortiss.tooling.spiderchart.widget.SpiderChartViewer;
import org.fortiss.tooling.spiderchart.control.SpiderChartViewer;
import javafx.embed.swt.FXCanvas;
import javafx.scene.Scene;
/**
* Spider Chart Visualization View.
......@@ -36,8 +40,10 @@ import org.fortiss.tooling.spiderchart.widget.SpiderChartViewer;
*/
public final class SpiderChartVisualization implements IVisualizationView, IEventListener {
// TODO (3450) The FXCanvas can be removed once the whole visualization view part is
// JavaFX-based
/** The spider chart viewer. */
private SpiderChartViewer viewer;
private FXCanvas viewer;
/** {@inheritDoc} */
@Override
......@@ -45,7 +51,10 @@ public final class SpiderChartVisualization implements IVisualizationView, IEven
DataSetCollection latestGeneratedDSEVisElements =
IDSEPerspectiveManager.INSTANCE.getLatestGeneratedDSEVisElements();
if(latestGeneratedDSEVisElements != null) {
viewer = transformIntoSpiderChart(latestGeneratedDSEVisElements, composite);
viewer = new FXCanvas(composite, SWT.NONE);
SpiderChartViewer chart = transformIntoSpiderChart(latestGeneratedDSEVisElements);
Scene scene = new Scene(chart.getViewerPane());
viewer.setScene(scene);
viewer.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
Rectangle clientArea = composite.getClientArea();
viewer.setBounds(clientArea.x, clientArea.y, clientArea.width, clientArea.height);
......
ExplorationSolutionVisualizationUtils.java 089540ba52f75b4a5024fa2ed7826d906e4ddde0 GREEN
ExplorationUiUtils.java aad4d16990fd642bcaa5d54b3ec0a575f3c5904f GREEN
SpiderChartUtils.java 885d37e537db3b6128c08a4c98247f3a9613d9bf GREEN
SpiderChartUtils.java 0fe92dbfbc71b16a000ab9b5bacb282456771d63 GREEN
......@@ -17,17 +17,15 @@ package org.fortiss.af3.exploration.ui.util;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static javafx.scene.paint.Color.BLUE;
import static javafx.scene.paint.Color.DARKGRAY;
import static javafx.scene.paint.Color.LIGHTGRAY;
import static org.fortiss.af3.schedule.ui.ganttchartview.ScheduleViewColors.getColor;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_14PT;
import static org.fortiss.tooling.spiderchart.style.FontStyle.BLACK_VERDANA_10PT;
import static org.fortiss.tooling.spiderchart.style.FontStyle.BLACK_VERDANA_12PT;
import static org.fortiss.tooling.spiderchart.style.FontStyle.BLACK_VERDANA_14PT;
import static org.fortiss.tooling.spiderchart.style.FontStyle.BLACK_VERDANA_8PT;
import static org.fortiss.tooling.spiderchart.style.LineStyle.SOLID_BLACK_1PT;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.BLUE;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.DARK_GRAY;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.LIGHT_GRAY;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.getDarkerColor;
import static org.fortiss.tooling.common.ui.javafx.style.FontStyle.BLACK_VERDANA_10PT;
import static org.fortiss.tooling.common.ui.javafx.style.FontStyle.BLACK_VERDANA_12PT;
import static org.fortiss.tooling.common.ui.javafx.style.FontStyle.BLACK_VERDANA_14PT;
import static org.fortiss.tooling.common.ui.javafx.style.FontStyle.BLACK_VERDANA_8PT;
import static org.fortiss.tooling.common.ui.javafx.style.LineStyle.SOLID_BLACK_1PT;
import java.text.DecimalFormat;
import java.util.ArrayList;
......@@ -35,22 +33,23 @@ import java.util.HashMap;
import java.util.List;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.base.model.visualization.Axis;
import org.fortiss.tooling.base.model.visualization.DataPoint;
import org.fortiss.tooling.base.model.visualization.DataSet;
import org.fortiss.tooling.base.model.visualization.DataSetCollection;
import org.fortiss.tooling.common.ui.javafx.style.FillStyle;
import org.fortiss.tooling.common.ui.javafx.style.FontStyle;
import org.fortiss.tooling.common.ui.javafx.style.LineStyle;
import org.fortiss.tooling.spiderchart.control.SpiderChartViewer;
import org.fortiss.tooling.spiderchart.model.DataSeries;
import org.fortiss.tooling.spiderchart.model.DoubleAxis;
import org.fortiss.tooling.spiderchart.model.SpiderChart;
import org.fortiss.tooling.spiderchart.style.AxisStyle;
import org.fortiss.tooling.spiderchart.style.ChartStyle;
import org.fortiss.tooling.spiderchart.style.DataSeriesStyle;
import org.fortiss.tooling.spiderchart.style.FillStyle;
import org.fortiss.tooling.spiderchart.style.FontStyle;
import org.fortiss.tooling.spiderchart.style.LegendStyle;
import org.fortiss.tooling.spiderchart.style.LineStyle;
import org.fortiss.tooling.spiderchart.widget.SpiderChartViewer;
import javafx.scene.paint.Color;
/**
* Utils for spider chart visualization.
......@@ -159,23 +158,20 @@ public class SpiderChartUtils {
*
* @param dataSetCollection
* {@link DataSetCollection} to visualize.
* @param parent
* {@link Composite} to add the viewer as a child.
* @return The corresponding {@link SpiderChartViewer}.
*/
public static SpiderChartViewer transformIntoSpiderChart(DataSetCollection dataSetCollection,
Composite parent) {
public static SpiderChartViewer transformIntoSpiderChart(DataSetCollection dataSetCollection) {
SpiderChart spiderChart = new SpiderChart();
spiderChart.setTitle(dataSetCollection.getName());
spiderChart.setLegendLabel("Legend");
ChartStyle chartStyle = new ChartStyle(true, true, false);
chartStyle.setTitleStyle(new FontStyle(VERDANA_14PT, getDarkerColor(BLUE)));
LegendStyle legendStyle = new LegendStyle(BLUE, false, 5, BLACK_VERDANA_12PT);
chartStyle.setTitleStyle(new FontStyle("Verdana", 14, BLUE.darker()));
LegendStyle legendStyle = new LegendStyle(false, 5, BLACK_VERDANA_12PT);
chartStyle.setLegendStyle(legendStyle);
chartStyle.setAxisSegments(4);
chartStyle.setBackgroundFillStyle(new FillStyle(LIGHT_GRAY));
chartStyle.setBackgroundLineStyle(new LineStyle(DARK_GRAY));
chartStyle.setBackgroundFillStyle(new FillStyle(LIGHTGRAY));
chartStyle.setBackgroundLineStyle(new LineStyle(DARKGRAY));
HashMap<Axis<Object>, DoubleAxis> modelToVisAxisMapping;
modelToVisAxisMapping = new HashMap<>();
......@@ -203,16 +199,19 @@ public class SpiderChartUtils {
}
dataSeries.setPoint(modelToVisAxisMapping.get(p.getAxis()), value);
}
RGB color = getColor(s.getId()).getRGB();
int alpha = 64;
LineStyle olive1pt = new LineStyle(color);
FillStyle oliveFill = new FillStyle(color, alpha);
DataSeriesStyle style = new DataSeriesStyle(olive1pt, oliveFill, true, true,
BLACK_VERDANA_10PT, 7, new DecimalFormat("#.#"));
// TODO (3450) The RGB-to-Color conversion can be removed once the Gantt-chart (and its
// utility methods) are JavaFX-based
RGB rgb = getColor(s.getId()).getRGB();
Color color = new Color(rgb.red / 255.0, rgb.green / 255.0, rgb.blue / 255.0, 1);
LineStyle line = new LineStyle(color.darker());
FillStyle fill = new FillStyle(color.brighter(), 0.5);
DataSeriesStyle style = new DataSeriesStyle(line, fill, true, true, BLACK_VERDANA_10PT,
7, new DecimalFormat("#.#"));
chartStyle.setDataSeriesStyle(dataSeries, style);
spiderChart.addData(dataSeries);
}
return new SpiderChartViewer(parent, spiderChart, chartStyle);
return new SpiderChartViewer(spiderChart, chartStyle);
}
}
......@@ -43,10 +43,10 @@ public class TestCaseGenerationCommandLineHandler implements ICommandLineSwitchH
private final int compArchNum = 1;
/** Minimal number of {@link Component}s per {@link ComponentArchitecture}. */
private final int minComponentNum = 8;
private final int minComponentNum = 16;
/** Maximum number of {@link Component}s per {@link ComponentArchitecture}. */
private final int maxComponentNum = 9;
private final int maxComponentNum = 17;
/** {@inheritDoc} */
@Override
......
......@@ -46,6 +46,7 @@ import org.fortiss.af3.exploration.AF3ExplorationActivator;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.task.model.TaskArchitecture;
import org.fortiss.tooling.kernel.utils.UniqueIDUtils;
/**
* Generator for DSE test case {@link FileProject}s. It creates deployment problems with generated
......@@ -89,6 +90,10 @@ public class ExplorationTestCaseGenerator {
createAF3Projects(genCompArchs, platformArchitectures, "DSE_Generated");
fileProjects = expandArchitecturesByAnnotations(fileProjects);
for(FileProject fp : fileProjects) {
UniqueIDUtils.generateAllIDs(fp);
}
fileProjects = expandByDseProblems(fileProjects);
info(AF3ExplorationActivator.getDefault(),
......
......@@ -26,13 +26,16 @@ import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.function.Consumer;
import java.util.function.Function;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.platform.model.annotation.FlashSize;
import org.fortiss.af3.platform.model.annotation.HardwareCost;
......@@ -162,7 +165,7 @@ public class AnnotationGenerationUtils {
SafetyIntegrityLevel.class)) {
// Levels range from 0 to Max, then there is an "undefined" enum that is also the
// exclusive upper bound here.
int lvlIdx = rand.nextInt(SIL.VALUES.size());
int lvlIdx = rand.nextInt(SIL.VALUES.size() - 2) + 1;
sil.setSilValue(SIL.get(lvlIdx));
}
......@@ -182,7 +185,7 @@ public class AnnotationGenerationUtils {
Collection<FileProject> expandedFileProjects = new ArrayList<>();
for(FileProject filePrj : fileProjects) {
for(double memoryUsage = 0.5; memoryUsage < 1; memoryUsage += 0.25) {
for(double memoryUsage = 0.25; memoryUsage < 0.75; memoryUsage += 0.25) {
FileProject expandedFP = EcoreUtils.copy(filePrj);
TaskArchitecture taskArch =
pickFirstInstanceOf(TaskArchitecture.class, expandedFP.getRootElements());
......@@ -190,11 +193,15 @@ public class AnnotationGenerationUtils {
expandedFP.getRootElements());
PlatformArchitecture platArch = pickFirstInstanceOf(PlatformArchitecture.class,
expandedFP.getRootElements());
int size = EcoreUtils
.pickInstanceOf(GenericExecutionUnit.class, platArch.getContainedElements())
.size();
defineTaskMemoryRequirements(taskArch, size * 200, memoryUsage);
// defineTaskSafetyRequirements(compArch);
int availableFlash = 0;
for(ExecutionUnit ex : EcoreUtils.pickInstanceOf(GenericExecutionUnit.class,
platArch.getContainedElements())) {
availableFlash += getAnnotation(ex, FlashSize.class).getBytes();
}
defineTaskMemoryRequirements(taskArch, availableFlash, memoryUsage);
defineTaskSafetyRequirements(compArch);
defineWCETs(expandedFP, taskArch);
expandedFileProjects.add(expandedFP);
}
......@@ -203,8 +210,8 @@ public class AnnotationGenerationUtils {
return expandedFileProjects;
}
private static void defineTaskSafetyRequirements(ComponentArchitecture compArch)
throws Exception {
/** Sets the safety level for all components in the passed architecture */
private static void defineTaskSafetyRequirements(ComponentArchitecture compArch) {
Random rand = new Random(System.currentTimeMillis());
setSafety(rand, compArch);
......@@ -215,6 +222,7 @@ public class AnnotationGenerationUtils {
compArch.addSpecification(createSafetyIntegrityLevel);
}
/** Recursively sets the safety of the component and all its children */
private static void setSafety(Random rand, IHierarchicElement comp) {
if(comp.getContainedElements() != null) {
for(IHierarchicElement comp2 : comp.getContainedElements()) {
......@@ -223,7 +231,7 @@ public class AnnotationGenerationUtils {
}
SafetyIntegrityLevel createSafetyIntegrityLevel =
SafetyAnnotationFactory.eINSTANCE.createSafetyIntegrityLevel();
createSafetyIntegrityLevel.setSilValue(SIL.get(rand.nextInt(SIL.VALUES.size())));
createSafetyIntegrityLevel.setSilValue(SIL.get(rand.nextInt(SIL.VALUES.size() - 2)));
createSafetyIntegrityLevel.setSafetyStandard(IEC61508);
comp.addSpecification(createSafetyIntegrityLevel);
}
......@@ -238,9 +246,10 @@ public class AnnotationGenerationUtils {
List<Long> memoryRequirements =
generateMemoryRequirements(availableMemory, childComponentNum, memoryUsageRatio);
Integer maxFlash = Collections.min(Arrays.asList(ANNOTATION_AMOUNT));
for(int index = 0; index < childComponentNum; index++) {
setAnnotationValue(tasks.get(index), FlashRequirement.class,
memoryRequirements.get(index));
long flash = Math.min(memoryRequirements.get(index), maxFlash);
setAnnotationValue(tasks.get(index), FlashRequirement.class, flash);
}
}
......
......@@ -20,11 +20,10 @@ import static java.lang.System.currentTimeMillis;
import static java.util.Arrays.asList;
import static java.util.Collections.shuffle;
import static java.util.stream.Collectors.toList;
import static org.eclipse.core.runtime.Assert.isTrue;
import static org.fortiss.af3.exploration.util.DSEProjectModelElementFactory.createDSE;
import static org.fortiss.af3.exploration.util.DSEProjectModelElementFactory.createRuleSet;
import static org.fortiss.af3.exploration.util.DSEProjectModelElementFactory.createTargetDefinitionStep;
import static org.fortiss.af3.exploration.util.DSMLModelElementFactory.createAnd;
import static org.fortiss.af3.exploration.util.DSMLModelElementFactory.createBooleanLiteral;
import static org.fortiss.af3.exploration.util.ExplorationModelElementFactory.createExplorationConstraint;
import static org.fortiss.af3.exploration.util.ExplorationModelElementFactory.createExplorationObjective;
import static org.fortiss.af3.exploration.util.ExplorationModelElementFactory.createReliabilityDimension;
......@@ -38,9 +37,10 @@ import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createAllocat
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createBusWeightOptimizationPatternExpression;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createRouteUsesBusConstraintPatternExpression;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createRouteWeightConstraintPatternExpression;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createSafetyPatternExpression;
import static org.fortiss.af3.exploration.util.PatternFactoryUtils.createUtilizationPatternExpression;
import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotationValue;
import static org.fortiss.tooling.common.util.LambdaUtils.filter;
import static org.fortiss.tooling.common.util.LambdaUtils.getFirst;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
......@@ -50,13 +50,14 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.Enumerator;
import org.fortiss.af3.allocation.model.AllocationTableCollection;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.exploration.dseml.model.booleanp.IBooleanExpression;
import org.fortiss.af3.exploration.dseml.model.expression.IExpression;
import org.fortiss.af3.exploration.dseml.model.expression.SuperSet;
import org.fortiss.af3.exploration.model.ExplorationConstraint;
......@@ -80,6 +81,7 @@ import org.fortiss.af3.platform.model.annotation.HardwareCost;
import org.fortiss.af3.platform.model.annotation.PowerConsumption;
import org.fortiss.af3.platform.model.annotation.RamSize;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.safety.model.annotation.SafetyIntegrityLevel;
import org.fortiss.af3.task.model.Task;
import org.fortiss.af3.task.model.TaskArchitecture;
import org.fortiss.af3.task.model.allocation.ComponentToTaskAllocationEntry;
......@@ -118,7 +120,7 @@ public class DseUtils {
{HardwareCost.class, PowerConsumption.class, RamSize.class, FlashSize.class};
/** Chance to add additional objectives in addition to the first one */
private static final int OPTIMIZATION_COUNT = 2;
private static final int OPTIMIZATION_COUNT = 1;
/** Probability that an objective will be a minimization objective */
private static final double OPTIMIZATION_MINIMIZE_CHANCE = 1.0;
......@@ -134,7 +136,7 @@ public class DseUtils {
fileProjects.forEach(fp -> createAddDse(fp));
fileProjects = addFlashConstraints(fileProjects);
// fileProjects = addSafetyConstraints(fileProjects);
fileProjects = addSafetyConstraints(fileProjects);
fileProjects = expandByAllocationConstraints(fileProjects);
fileProjects = expandByCouplingConstraints(fileProjects);
......@@ -288,8 +290,9 @@ public class DseUtils {
SuperSet<ExecutionUnit> execUnits =
dse.getCurrentStep().getSuperSetMap().get(ExecutionUnit.class);
for(ExecutionUnit execUnit : execUnits.getEntries()) {
IExpression expr = createUtilizationPatternExpression(dse, FLASH_MAX_UTIL_PERCENT,
execUnit, FlashRequirement.class, FlashSize.class);
IExpression expr =
createUtilizationPatternExpression(dse, FLASH_MAX_UTIL_PERCENT / 100.0,
execUnit, FlashRequirement.class, FlashSize.class);
IExplorationConstraint<Boolean> constr =
createExplorationConstraint(
Boolean.class, createResourceDimension(), expr, "Max Flash Util " +
......@@ -308,21 +311,22 @@ public class DseUtils {
return fileProjects;
}
/**
* Adds {@link IExplorationConstraint}s to respect {@link SafetyIntegrityLevel} of
* {@link ExecutionUnit}s.
*/
private static Collection<FileProject>
addSafetyConstraints(Collection<FileProject> fileProjects) {
for(FileProject fp : fileProjects) {
DSE dse = pickFirstInstanceOf(DSE.class, fp.getRootElements());
TargetDefinitionStep tgtDefStep = getTargetDefinitionStep(dse);
SuperSet<ExecutionUnit> execUnits =
tgtDefStep.getSuperSetMap().get(ExecutionUnit.class);
List<ExecutionUnit> execUnits =
tgtDefStep.getSuperSetMap().get(ExecutionUnit.class).getEntries();
IBooleanExpression expression = createBooleanLiteral(true);
for(ExecutionUnit executionUnit : execUnits.getEntries()) {
expression = createAnd(expression, (createSafetyPatternExpression(dse,
executionUnit,
tgtDefStep.getSuperSetMap().get(ComponentToTaskAllocationEntry.class))));
}
IExpression expression =
PatternFactoryUtils.createSafetyPatternExpressionGA(dse, execUnits,
tgtDefStep.getSuperSetMap().get(ComponentToTaskAllocationEntry.class));
ExplorationConstraint<Boolean> explorationConstraint =
createExplorationConstraint(Boolean.class, createResourceDimension(),
......@@ -391,11 +395,24 @@ public class DseUtils {
while((allocConstraints.size() < numTasksToAllocate) && !tasks.isEmpty()) {
Task task = tasks.poll();
SuperSet<ComponentToTaskAllocationEntry> ca2taSet = getTargetDefinitionStep(dse)
.getSuperSetMap().get(ComponentToTaskAllocationEntry.class);
long requiredFlash = getAnnotationValue(task, FlashRequirement.class, Long.class);
List<ExecutionUnit> tgtExecUnits =
freeFlash.entrySet().stream().filter(e -> e.getValue() >= requiredFlash)
.map(e -> e.getKey()).collect(toList());
Optional<ComponentToTaskAllocationEntry> alloc =
getFirst(filter(ca2taSet.getEntries(), e -> e.getTargetElement() == task));
isTrue(alloc.isPresent(),
"Could not determine the component(s) mapped to the task " + task.getName());
Integer maxSil = alloc.get().getComponents().stream()
.mapToInt(
c -> getAnnotationValue(c, SafetyIntegrityLevel.class, Enumerator.class)
.getValue())
.max().getAsInt();
List<ExecutionUnit> tgtExecUnits = freeFlash.entrySet().stream().filter(
e -> e.getValue() >= requiredFlash && maxSil <= getAnnotationValue(e.getKey(),
SafetyIntegrityLevel.class, Enumerator.class).getValue())
.map(e -> e.getKey()).collect(toList());
if(!tgtExecUnits.isEmpty()) {
shuffle(tgtExecUnits);
......
......@@ -28,7 +28,6 @@ import static org.fortiss.af3.timing.utils.TimingModelElementFactory.createEntit
import static org.fortiss.af3.timing.utils.TimingModelElementFactory.createPeriodicConstraint;
import static org.fortiss.af3.timing.utils.TimingModelElementFactory.createTimingSpecification;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.generateAllIDs;
import java.io.IOException;
import java.math.BigDecimal;
......@@ -47,6 +46,7 @@ import org.fortiss.af3.task.model.timing.TaskStartEvent;
import org.fortiss.af3.task.util.ComponentToTaskArchitectureTransformation;
import org.fortiss.af3.timing.model.PeriodicConstraint;
import org.fortiss.af3.timing.model.TimingSpecification;
import org.fortiss.tooling.kernel.utils.UniqueIDUtils;
/**
* Utility class for interacting with persistent AF3 projects.
......@@ -151,7 +151,7 @@ public class ProjectUtils {
int projectID = -1;
for(FileProject fp : fileProjects) {
generateAllIDs(fp);
UniqueIDUtils.generateMissingIDs(fp, UniqueIDUtils.getLargestID(fp));
fp.setName(fp.getName() + "_" + ++projectID);
URI prjURI = createURI(getDefaultGeneralProjectURI() + separator + fp.getName() + "." +
......
......@@ -383,7 +383,65 @@ public class PatternFactoryUtils {
Optional<ComponentToTaskAllocationEntry> alloc =
getFirst(filter(ca2taSet.getEntries(), e -> e.getTargetElement() == task));
isTrue(alloc.isPresent(),
"Could not determine the coomponent(s) mapped to the task " + task.getName());