Skip to content
Snippets Groups Projects
Commit 3c95dec5 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Exploration(.*): Introduce typeParameter fields for Sets and ExplorationTargets.

* Change the MM accordingly.
* Introduce static helper methods to implement the getters/setters of the affected maps: Runtime exceptions are thrown on mismatching types.
* Add a migrator to set the DSESuperSet types of old models.
* Adjust the factory methods.
refs 3289
parent fbefcaea
No related branches found
No related tags found
No related merge requests found
Showing
with 61 additions and 22 deletions
......@@ -170,8 +170,8 @@ public class CompositeExplorationSolution<P extends Phenotype> {
singleSolution.getSubSolution(InstantiatedTaskMappingEncoding.class);
PartitionMappingEncoding pmEncoding =
singleSolution.getSubSolution(PartitionMappingEncoding.class);
SuperSet<ComponentToExecutionUnitAllocationEntry> compExecUnitAllocs =
createSuperSet("Optimized_Allocations");
SuperSet<ComponentToExecutionUnitAllocationEntry> compExecUnitAllocs = createSuperSet(
"Optimized_Allocations", ComponentToExecutionUnitAllocationEntry.class);
for(Partition resource : tm.getResources()) {
for(ITaskAdapter<?> task : tm.getRequesters(resource)) {
Component af3Component = task.getAssignedComponent();
......
......@@ -15,8 +15,6 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.alg.dse.backend.opt4j;
import static org.fortiss.af3.exploration.util.ExplorationUtils.getReturnTypeOf;
import java.util.Map;
import java.util.Map.Entry;
......@@ -51,7 +49,7 @@ public class Opt4JSingleExplorationSolution extends SolutionQuantification {
// Determine the ExplorationTarget class to identify the correct return value type.
Objective objective = problemModule.getObjectiveOf(targetAssoc.getValue());
ExplorationTarget<?> concreteExpTarget = targetAssoc.getKey();
Class<?> expectedResultType = getReturnTypeOf(concreteExpTarget);
Class<?> expectedResultType = concreteExpTarget.getResultType();
// FIXME: throw an exception here.
assert (expectedResultType != null) : "Could not determine the result type of the exploration target " +
concreteExpTarget.getName() +
......@@ -67,6 +65,12 @@ public class Opt4JSingleExplorationSolution extends SolutionQuantification {
if(expectedResultType.equals(Boolean.class) ||
IModelElement.class.isAssignableFrom(expectedResultType)) {
result = Boolean.valueOf(objectives.get(objective).getDouble() <= 10E-9);
} else if(expectedResultType.equals(Double.class) &&
result.getClass().equals(Integer.class)) {
// FIXME: Remove this special case: It shall not be needed anymore, once we got rid
// of the static type definition in EMF meta-models and derive them from the
// referenced annotations.
result = Double.valueOf((Integer)result);
} else if(result != null && !result.getClass().equals(expectedResultType)) {
// Note: if the result is null, a serious constraint violation is indicated. Its
// corresponding solution will be filtered out in a later stage.
......
InternalIsolatedCommunicationSet.java 250ff5f0ee41829b051b4c597810ae80dc73a0cc RED
InternalIsolatedCommunicationSet.java 46aa91e7690c31e46c6e852d8eed54b246fa4654 RED
......@@ -182,4 +182,18 @@ public class InternalIsolatedCommunicationSet extends EObjectImpl
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public Class<Boolean> getResultType() {
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public void setResultType(Class<Boolean> type) {
// TODO Auto-generated method stub
}
}
......@@ -17,8 +17,8 @@ package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.c
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IRequestAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter;
import org.fortiss.af3.exploration.dsl_v2.model.expression.IExpression;
import org.fortiss.af3.exploration.model.ExplorationConstraint;
import org.fortiss.af3.exploration.model.ExplorationTarget;
......@@ -173,4 +173,18 @@ public class InternalReplicationConstraint extends EObjectImpl
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public Class<Boolean> getResultType() {
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public void setResultType(Class<Boolean> type) {
// TODO Auto-generated method stub
}
}
......@@ -19,8 +19,8 @@ import java.util.Collection;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IRequestAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry;
import org.fortiss.af3.exploration.dsl_v2.model.expression.IExpression;
import org.fortiss.af3.exploration.model.ExplorationConstraint;
......@@ -166,4 +166,18 @@ public class InternalSeparationConstraint extends EObjectImpl
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public Class<Boolean> getResultType() {
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public void setResultType(Class<Boolean> type) {
// TODO Auto-generated method stub
}
}
EnergyObjectiveEvaluator.java ad2b868aa3dce2c7708ee6cc90f357b79a4cf799 RED
FailSilentReliabilityEvaluator.java 83211c8e2b69579c424a486cd6845bb8d1bb69fa RED
FaultDetectionVotingReliabilityEvaluator.java 189fdfd0daed3348c510a6aeac0bd391e835c524 RED
MappingEvaluatorObjective.java 5a1e083a5f18be458b73c6fc4fd9d37b9f69d213 RED
MappingEvaluatorObjective.java 6ca3fa4dcbaeb61b38ad1d36a318dbb9ead58831 RED
ReliabilityEvaluatorBase.java 98fa54270cba25137112fe55f3551fbd8064ac28 RED
......@@ -88,7 +88,7 @@ public class MappingEvaluatorObjective extends TaskMappingEvaluator {
// The minMax Term is always non-zero.
// FIXME: Using "BigInteger" as a type is a hack: It is a workaround to comply with the
// construction of objectives in the UI.
@SuppressWarnings("null") Number retVal = minMaxTerm.accept(this, BigInteger.class);
@SuppressWarnings("null") Number retVal = minMaxTerm.accept(this, Number.class);
return retVal instanceof BigInteger ? new IntegerValue(retVal.intValue())
: new DoubleValue(retVal.doubleValue());
......
......@@ -4,4 +4,4 @@ ScheduleLabelGenerator.java 0ceecedfec9802bbcaa33525d61e1a60a70d3841 RED
SchedulePlotter.java 29b1156c9419d4ff3314c4b2c932aeb46f4749f8 RED
ScheduleToolTipGenerator.java cedfa0dd7ebc7b48d7cc70e966eebaeee9636caf RED
TaskSeriesCollectionFromSchedule.java b53b7af649c48980520ad572da8c7bbdbae0aed5 RED
XYPlotter.java 4fd144980d0d55bccbe8840c8e049b9bf3d41118 RED
XYPlotter.java 4ab3c02351dab5e78cea843dc6665ddee46a636c RED
......@@ -459,15 +459,11 @@ public class XYPlotter extends JFrame implements ChartMouseListener, ActionListe
coordinateToSolution.clear();
for(SingleExplorationSolution solution : explorationResult.getSolutions()) {
/* Retrieve the solution values of the selected objectives. */
Map<ExplorationTarget<?>, ExplorationResult<?>> objValues =
solution.getSolutionMap().map();
Object xResultVal = null;
Object yResultVal = null;
if(Xaxis != null && Yaxis != null) {
ExplorationResult<?> xExpResult = objValues.get(Xaxis.getTarget());
ExplorationResult<?> yExpResult = objValues.get(Yaxis.getTarget());
ExplorationResult<?> xExpResult = solution.get(Xaxis.getTarget());
ExplorationResult<?> yExpResult = solution.get(Yaxis.getTarget());
if(xExpResult != null && yExpResult != null) {
xResultVal = xExpResult.getResult();
yResultVal = yExpResult.getResult();
......@@ -503,17 +499,14 @@ public class XYPlotter extends JFrame implements ChartMouseListener, ActionListe
.stream().filter(r -> r == currentSolution).findAny();
if(singleExpSol.isPresent()) {
SingleExplorationSolution currentSolMap = singleExpSol.get();
Map<ExplorationTarget<?>, ExplorationResult<?>> objectiveValues =
currentSolMap.getSolutionMap().map();
// TODO: identifying the elements by their names is not good style, the map is not
// required.
/* Update the list of exact objective values */
if(objectiveValues != null) {
if(currentSolMap != null) {
// display the objective values
for(int i = 0; i < goalList.size(); i++) {
ExplorationTarget<?> target = goalList.get(i);
ExplorationResult<?> expResult = objectiveValues.get(target);
ExplorationResult<?> expResult = currentSolMap.get(target);
if(objectiveToGuiItems.get(target) != null &&
(expResult != null && expResult.getResult() instanceof Double)) {
objectiveToGuiItems.get(target).objTextField
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment