diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/.ratings index 0a4a0ee4d3fad1c344a98633f614cd40e7d1ad6b..ce6480c448cf5ea2b513e9c3b03f36958879d222 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/.ratings @@ -1,2 +1,2 @@ -ExplorationAlg.java 9d5bf852819ef34f76d2390829c58b242e3ac06f RED +ExplorationAlg.java 23b771227aa82ddc80f010e14d1ef977e47fbdd5 RED ExplorationAlgActivator.java d51cc105f23cc84dee0130d36fbd5bbd840c0398 RED 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 a7ed7a452ec00dd9d7e37ea72cb3b28f1ccdd326..79e0269296450851936a9785c0822d67bddc1b84 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 aa46c8c39179a2b6f457cef98d294b222790ed5b RED +Opt4JDseBackend.java 02ad3770ed32b70bd97cd6e5407c5b5988d6347c 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 bec7188e1b8b25cb71238bcf5d90478207ee51ea..eb58def5a85611cd109024c3e52c78439cb2c6b8 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 @@ -28,7 +28,6 @@ import java.util.Optional; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; -import org.fortiss.af3.component.model.Component; import org.fortiss.af3.component.model.ComponentArchitecture; import org.fortiss.af3.exploration.alg.dse.CompositeExplorationSolution; import org.fortiss.af3.exploration.alg.dse.Explorer; @@ -54,6 +53,7 @@ import org.fortiss.af3.platform.model.PlatformArchitecture; import org.fortiss.af3.task.model.Signal; import org.fortiss.af3.task.model.Task; import org.fortiss.af3.task.model.TaskArchitecture; +import org.fortiss.af3.task.model.allocation.ComponentToTaskAllocationEntry; import org.fortiss.tooling.base.model.element.IModelElement; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; import org.fortiss.tooling.kernel.service.IPersistencyService; @@ -104,7 +104,8 @@ public class Opt4JDseBackend implements IDseBackend { // Input to DSE: {@link SystemModelAdapter} and {@link DesignSpaceExploration}. // SystemModelAdapter systemModelAdapter; - systemModelAdapter = new AF3SystemModelAdapter(superSets.get(Component.class), + systemModelAdapter = new AF3SystemModelAdapter(superSets.get(Task.class), + superSets.get(ComponentToTaskAllocationEntry.class), superSets.get(ExecutionUnit.class), superSets.get(Signal.class)); DseSpecification dseSpec = createDefaultDesignSpaceExploration(spec, context); diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/.ratings index 6908df7057d8bda882652ede2ba05d8553461be9..b2638f3c120aa09a2574fe13cad8594a5f122454 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/.ratings @@ -1,2 +1,2 @@ -TaskMappingEncoding.java ff2ea5d0f4f9273d97968167e8b4e7a20ae44fea RED +TaskMappingEncoding.java 4b7241a53286d947e29335afdf89b791d0b706f0 RED TaskMappingEntry.java 8872e14a5d29f267ce2be78e9a3f3f817f16edd2 RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/TaskMappingEncoding.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/TaskMappingEncoding.java index 3ec72a61f99e2fac4917b057b763b73c440e8753..97e0f04696f0ffa4a035052a3e64acd15b21655f 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/TaskMappingEncoding.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/TaskMappingEncoding.java @@ -28,7 +28,6 @@ import java.util.Map.Entry; import java.util.Optional; import java.util.stream.Collectors; -import org.eclipse.emf.ecore.EObject; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.ArchExpSubEncoding; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.MappingEncoding; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.comm.constraint.InternalIsolatedCommunicationSet; @@ -39,9 +38,9 @@ import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.co import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.constraint.InternalSeparationConstraint; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.encoding.ConstrainedEncoding; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; +import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.DefaultTaskGraph; import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; @@ -251,10 +250,8 @@ public abstract class TaskMappingEncoding<S extends ITaskAdapter<?>, T extends T * Creates a map which refers those {@link IExecutionUnitAdapter}s that are invalid allocation * targets of the given component. */ - private Multimap<ITaskAdapter<?>, IExecutionUnitAdapter<?>> - createDisallowedAllocationMap() { - Multimap<ITaskAdapter<?>, IExecutionUnitAdapter<?>> rval = - HashMultimap.create(); + private Multimap<ITaskAdapter<?>, IExecutionUnitAdapter<?>> createDisallowedAllocationMap() { + Multimap<ITaskAdapter<?>, IExecutionUnitAdapter<?>> rval = HashMultimap.create(); Collection<ComponentMultiDislocationConstraint> forbiddenDeploymentConstraints = getChildrenWithType(dse, ComponentMultiDislocationConstraint.class); @@ -284,10 +281,8 @@ public abstract class TaskMappingEncoding<S extends ITaskAdapter<?>, T extends T * Creates a lookup map that holds the collection of all disallowed mapping targets of * {@link ITaskAdapter}s. */ - private Multimap<ITaskAdapter<?>, IExecutionUnitAdapter<?>> - createAllowedAllocationMap() { - Multimap<ITaskAdapter<?>, IExecutionUnitAdapter<?>> rval = - HashMultimap.create(); + private Multimap<ITaskAdapter<?>, IExecutionUnitAdapter<?>> createAllowedAllocationMap() { + Multimap<ITaskAdapter<?>, IExecutionUnitAdapter<?>> rval = HashMultimap.create(); Collection<ComponentMultiAllocationConstraint> allowedDeploymentConstraints = getChildrenWithType(dse, ComponentMultiAllocationConstraint.class); @@ -327,22 +322,26 @@ public abstract class TaskMappingEncoding<S extends ITaskAdapter<?>, T extends T * Returns the collection of allowed mapping targets if a * {@link ComponentMultiAllocationConstraint} is defined, otherwise {@code null} is returned. */ + // TODO(#2960): Must be based on the DSML expressions. public Collection<IExecutionUnitAdapter<?>> getAllowedAllocations(ITaskAdapter<?> deployableComponent) { - ITaskAdapter<?> origComponent = systemModelAdapter - .getDeployableComponentOf((EObject)deployableComponent.getObject()); - return allowedAllocations.get(origComponent); + // ITaskAdapter<?> origComponent = systemModelAdapter + // .getDeployableComponentOf((EObject)deployableComponent.getObject()); + // return allowedAllocations.get(origComponent); + return Collections.emptySet(); } /** * Returns the collection of disallowed mapping targets if a * {@link ComponentMultiDislocationConstraint} is defined, otherwise null is returned. */ + // TODO(#2960): Must be based on the DSML expressions. public Collection<IExecutionUnitAdapter<?>> getDisAllowedAllocations(ITaskAdapter<?> deployableComponent) { - ITaskAdapter<?> origComponent = systemModelAdapter - .getDeployableComponentOf((EObject)deployableComponent.getObject()); - return disallowedAllocations.get(origComponent); + // ITaskAdapter<?> origComponent = systemModelAdapter + // .getDeployableComponentOf((EObject)deployableComponent.getObject()); + // return disallowedAllocations.get(origComponent); + return Collections.emptySet(); } /** {@inheritDoc} */ diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/.ratings index fee32671e26239ea727e424b709a21694225a3be..bd7cf90886c2fbaf8ba621c9e8d010340d4f6828 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/.ratings @@ -5,4 +5,4 @@ DseProblemModuleBase.java 67ea368a0824fb500f85bf49868754455049b9c9 RED EvaluatorWrapper.java 47ff0b2df7f75e232fa269b55750f0e2c408b08c RED ExplorationGoalPriorityMultiEvaluator.java 0f900f86c8adc14b69d95bb8eb3a34ea1ed2d41e RED ProblemModuleBase.java fb1401b846d001dfc78bbd8b8881929788b10d41 RED -StrictTTDecoder.java 0553585f0cd521b0d5012aeec5508785fc305529 RED +StrictTTDecoder.java 433d1f8cd1cacda8b6fed6e6c3d10b7edfe3ee8e RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/StrictTTDecoder.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/StrictTTDecoder.java index 03916df25d10ce6940002dab8ca4c00da844a098..d6d929cc870f91765f83f7ef3c1a43f69327e745 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/StrictTTDecoder.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/StrictTTDecoder.java @@ -21,6 +21,7 @@ import java.util.Collections; import org.fortiss.af3.exploration.alg.dse.TaskMappingFactory; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.comm.MessageEncoding; +import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.partitionmapping.PartitionMappingEncoding; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.platform.PlatformCommunicationGraphEncoding; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.InstantiatedAcyclicTaskGraphEncoding; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.InstantiatedTaskGraphEncoding; @@ -87,11 +88,14 @@ public class StrictTTDecoder<S extends InstantiatedTaskMappingEntry, T extends I assert (acycItgEnc != null) : "The required acyclic and instantiated task graph encoding could not be found in the map of already decoded phenotypes."; PlatformCommunicationGraphEncoding pcgEncoding = phenotypeTypeMap.getEncoding(PlatformCommunicationGraphEncoding.class); + PartitionMappingEncoding partEnc = + phenotypeTypeMap.getEncoding(PartitionMappingEncoding.class); + assert (partEnc != null) : "The required partition mapping encoding could not be found in the map of already decoded phenotypes."; // TODO: Externalize the validation such that the encoding is not required to be passed to // the constructor (is there for validation purposes) StrictTTSchedule<S, T> schedule = new StrictTTSchedule<S, T>(systemModelAdapter, genotype); - simpleEDFScheduler.schedule(acycItgEnc, genotype, schedule); + simpleEDFScheduler.schedule(acycItgEnc, partEnc, genotype, schedule); assert (schedule.validateSchedule(true)); @@ -124,6 +128,7 @@ public class StrictTTDecoder<S extends InstantiatedTaskMappingEntry, T extends I reqTypes.add(InstantiatedTaskMappingEncoding.class); reqTypes.add(MessageEncoding.class); reqTypes.add(PlatformCommunicationGraphEncoding.class); + reqTypes.add(PartitionMappingEncoding.class); reqTypes.add(InstantiatedAcyclicTaskGraphEncoding.class); // FIXME: Remove as soon as the evaluators can declare their required Phenotypes!!! (Needed // for the period evaluator) diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/.ratings index 2d052905d49b319419c14766228dffc17f2e6582..b91d9f9e6d62db01b5d7e4f6bdd0c7b45823dd43 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/.ratings @@ -2,5 +2,5 @@ ArchExpSubSolution.java 3bb56206fe70f19f7cb6aee575eba552ce9bbc4e RED ArchitectureSolution.java 8ba40ce339c4195641ed1b67c79718e297d66e4c RED IExplorationSolution.java a6153937197358907ceec46606a7f28620c26f2b RED IScheduleSolution.java 8a2959147bdca874fd43b1591bc5471b68c04333 RED -StrictTTSchedule.java 2a272e7f146d8aa2a105c23302782ee291e55dea RED +StrictTTSchedule.java d6ca9625a09d36f29d2b8db1cc5d64095d84ca18 RED TimeSlot.java 499ba8b40aca05351c4baf03d104dd20e5eb19d1 RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/StrictTTSchedule.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/StrictTTSchedule.java index bf7ccd9c3f00412c715977ec74f5fbff5eb05c3e..d87bf12d5f0b205a149b7fa15956c1c6fe487c03 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/StrictTTSchedule.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/StrictTTSchedule.java @@ -27,11 +27,11 @@ import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.Ta import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ICommunicationResourceAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IGatewayUnitAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IRequestAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; +import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITransmissionUnitAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.comm.Message; @@ -357,8 +357,7 @@ public class StrictTTSchedule<S extends TaskMappingEntry<ITaskAdapter<?>, Partit private String getResourceName(IResourceAdapter<?> resource) { String str = resource.getName(); if(!(resource instanceof ITransmissionUnitAdapter || - resource instanceof IGatewayUnitAdapter) && - resource != systemModelAdapter.getHardwareResource(resource)) { + resource instanceof IGatewayUnitAdapter)) { // FIXME: Use the name of the partition. str += "@" + resource .toString();/* systemModelAdapter.getHardwareResource(resource).getName(); */ diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/.ratings index 796dd04fa1fb71616f129cba192adc1eadfd875b..ac519bada43aa29247fe811d5e24ba066f0701c7 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/.ratings @@ -1,8 +1,8 @@ ComponentMultiAllocationConstraintEvaluator.java 7742b1ca3553eb066830cae7e42e57502317ab02 RED ComponentMultiDislocationConstraintEvaluator.java 27140484b86611f07080e59de1ff54313c6c7ade RED ConstraintEvaluatorBase.java f42f71e64d32201b232c24542a2c0367a6293942 RED -DeadlineConstraintEvaluator.java f2681056772afc4dc3c95ddab49f3800d893c2e8 RED +DeadlineConstraintEvaluator.java 7cafe322514b562da0475cf0ed21cc0103ff5354 RED IConstraintEvaluator.java bca49bbdea5e089b0d045fc356ceedcb466df55e RED MappingEvaluatorConstraint.java 9ffa75d8a7ffe974b2ac547fefd16a95e7423ae7 RED -PeriodConstraintEvaluator.java d4f1997659766f0958eebfe89aa3447d4d98469f RED +PeriodConstraintEvaluator.java fa430e00be92b210a633ef2661d54f2d742b37eb RED SafetyIntegrityLevelConstraintEvaluator.java b9b6594e9b8065b27a4cc28f8cfe5b2eb5b4e3d1 RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/PeriodConstraintEvaluator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/PeriodConstraintEvaluator.java index e6960990d86045a825a7d8b62cffc2dbffdbe0c3..1a9c9ee958ced9b7f64b99fa4645be30801e4bb5 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/PeriodConstraintEvaluator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/PeriodConstraintEvaluator.java @@ -106,7 +106,7 @@ public class PeriodConstraintEvaluator<S extends InstantiatedTaskMappingEntry, T // Each deployable component has a period. for(ITaskAdapter<?> component : systemModelAdapter .getDeployableComponents()) { - if(component.getTimingRequirementPeriod() == null) { + if(component.getPeriod() == null) { throw new Exception("The component " + component.getName() + " has no period specified. Each component that shall be considered" + " by the DSE must be associated with a period: either defined for" + diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/.ratings index f1c8043bcbef90a3c25d7e839aff421f6b3513f9..aba3765fc559f0ac0df9a2cb0afcd0030a3bad0c 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/.ratings @@ -1,4 +1,4 @@ -DeprecatedSystemModelAdapter.java 58ad7df1f616cf16e27548a5c8e8076978b6468c RED +DeprecatedSystemModelAdapter.java fdee2a13cb08c3bcde6c38ef74b16fb2f768ab96 RED ICommunicationResourceAdapter.java 54dd128bfa04c5cfd16551eec8983e712636f86a RED IComponentAdapter.java c8425150287be21b48d686469b88ea7fb77793e4 RED IExecutionUnitAdapter.java a93c835d5dce6a6054eea7b0abb9663c04a335b8 RED @@ -12,8 +12,8 @@ IResourceAdapter.java 634866895c9d1aa427f3c8d47e69acd807d0b582 RED IResourceConnectionAdapter.java 7e20a8c3e60a9892597301556c891ba2dd43387f RED ISafetyFunctionAdapter.java 02c3777272abddd5f60d2c840cf3739827e8287a RED ISignalAdapter.java a158c54dc238fa5c8891f4355ffa2833f6984f81 RED -ITaskAdapter.java 94fa22a6afe51b29dd67fd81188174e22e96f026 RED +ITaskAdapter.java 97ad40c0ca14be2fb4fd070214a3d6ebe5be914a RED ITransmissionUnitAdapter.java 8965b73bfe9ef232a2a6d5427f7001761716d583 RED InternalComponentParameters.java 2b19f4eeddee84e4c6e558ed9a1613cba33b7665 RED -SystemModelAdapter.java 5d1d02fc1653b9528cdb7acc697350325a58f641 RED +SystemModelAdapter.java 318c8b657c703f6b928bd7974363c2d9db7bc247 RED SystemParameterContainer.java eddfc430acd8661dfe8ffbf191ef71a83157eff5 RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/DeprecatedSystemModelAdapter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/DeprecatedSystemModelAdapter.java index 103b685782a7af246a983faa34ef08318d7b2e4d..e9956883879313253a10f995dcdb895b63bc7a9d 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/DeprecatedSystemModelAdapter.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/DeprecatedSystemModelAdapter.java @@ -274,7 +274,7 @@ public class DeprecatedSystemModelAdapter<C, E, S, G, TR, M> { */ protected void setupScheduleableComponents() { for(ITaskAdapter<C> comp : deployableComponents) { - if(comp.getTimingRequirementPeriod() != null) { + if(comp.getPeriod() != null) { schedulableComponents.add(comp); } } @@ -351,7 +351,7 @@ public class DeprecatedSystemModelAdapter<C, E, S, G, TR, M> { // Compute vertex sets of maximum connected components of temporary task graph ConnectivityInspector<ITaskAdapter<?>, ChannelAdapterWeightedEdge> ci = new ConnectivityInspector<ITaskAdapter<?>, ChannelAdapterWeightedEdge>( - monolithicTaskGraph.getGraph()); + monolithicTaskGraph.getDelegateGraph()); List<Set<ITaskAdapter<?>>> connectedSets = ci.connectedSets(); // Reconstruct TaskGraphs from vertex sets of connected components for(Set<ITaskAdapter<?>> connectedSet : connectedSets) { @@ -360,7 +360,8 @@ public class DeprecatedSystemModelAdapter<C, E, S, G, TR, M> { for(ISignalAdapter<?> message : messages) { if(connectedSet.contains(message.getSource()) && !message.getTargets().isEmpty()) { - taskGraph.addDataDependency(message.getSource(), message.getTargets(), message); + // taskGraph.addDataDependency(message.getSource(), message.getTargets(), + // message); } } @@ -509,8 +510,9 @@ public class DeprecatedSystemModelAdapter<C, E, S, G, TR, M> { Collection<ITaskAdapter<?>> targetDeployableComponents = channelAdapter.getTargets(); if(sourceDeployableComponent != null && !(targetDeployableComponents.isEmpty())) { - taskGraph.addDataDependency(sourceDeployableComponent, targetDeployableComponents, - channelAdapter); + // taskGraph.addDataDependency(sourceDeployableComponent, + // targetDeployableComponents, + // channelAdapter); } } } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ITaskAdapter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ITaskAdapter.java index aff94917698319ce720112ff7f0fda76bdab305f..fb19cef020f27d7440351dd95d8049a44c461b90 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ITaskAdapter.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ITaskAdapter.java @@ -44,10 +44,10 @@ public interface ITaskAdapter<T> extends IRequestAdapter<T>, Cloneable { public Enumerator getRequiredSafetyIntegrityLevel(); /** Returns the period of the deployable component. */ - public Double getTimingRequirementPeriod(); + public Double getPeriod(); /** Sets the period of the deployable component. */ - public void setTimingRequirementPeriod(double period); + public void setPeriod(double period); /** * Predicates whether this {@link ITaskAdapter} must be instantiated by another @@ -81,8 +81,7 @@ public interface ITaskAdapter<T> extends IRequestAdapter<T>, Cloneable { * {@link ITaskAdapter}s. */ // TODO: If possible, find a way to eliminate this suppresswarning. - public void setReplacedComponent( - @SuppressWarnings("rawtypes") ITaskAdapter abstractComponent); + public void setReplacedComponent(@SuppressWarnings("rawtypes") ITaskAdapter abstractComponent); /** * Whenever an {@link ITaskAdapter} is copied/cloned its references wrt. the task @@ -103,13 +102,6 @@ public interface ITaskAdapter<T> extends IRequestAdapter<T>, Cloneable { */ public int getMaxReplication(); - /** - * Predicate if this {@link ITaskAdapter} is strongly causal. This implies that - * its outputs to non-strongly causal {@link ITaskAdapter}s only become available - * during the next hyperperiod. - */ - public boolean isStronglyCausal(); - /** * Clones the {@link ITaskAdapter} on which this method is called. If * {@link Component}s are instantiated during the exploration, this is needed. The initially diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/SystemModelAdapter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/SystemModelAdapter.java index ddffc2567c50dd1f82eae190a615089e7982e27b..1c878ff45a84484d98725d3dec77cb48604ba6d7 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/SystemModelAdapter.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/SystemModelAdapter.java @@ -17,7 +17,6 @@ package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; import static org.fortiss.af3.exploration.util.ExplorationUtils.isDebugVerboseEnabled; import static org.fortiss.af3.schedule.utils.MathUtils.lcmDoubleCollection; -import static org.fortiss.af3.task.util.TaskAllocationUtils.getAllocatedComponentsTo; import java.util.ArrayList; import java.util.Collection; @@ -52,8 +51,6 @@ import org.fortiss.af3.platform.model.IPlatformCommunicationResource; import org.fortiss.af3.platform.model.IPlatformExport; import org.fortiss.af3.platform.model.IPlatformResource; import org.fortiss.af3.platform.model.PlatformArchitecture; -import org.fortiss.af3.task.model.Task; -import org.fortiss.af3.task.model.TaskArchitecture; import org.fortiss.tooling.base.model.element.IConnection; import org.fortiss.tooling.base.model.element.IConnector; import org.fortiss.tooling.base.model.element.IHierarchicElement; @@ -90,16 +87,20 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { protected SubClassToInstanceMap<EObject> inputModels = MutableSubClassToInstanceMap.create(); /** Deployable software components, to be mapped to deployment targets provided by platform. */ - protected Collection<ITaskAdapter<C>> deployableComponents; + protected Collection<ITaskAdapter<C>> tasks; /** Collection of deployable components from the base model. */ - protected Collection<C> deployableComponentObjects; + protected Collection<C> taskObjects; + + /** Collection of signals exchanged between tasks. */ + protected Collection<ISignalAdapter<S>> signals; /** * Look up table to determine the input/output directions of {@link IConnector} types of the * target {@link PlatformArchitecture}. */ - protected Map<Class<? extends IConnector>, ConnectionType> connectionTypeLUT; + protected Map<Class<? extends IConnector>, ConnectionType> connectionTypeLUT = + Collections.emptyMap(); /** * Deployable software components that may be replicated (per default: all @{code @@ -123,9 +124,6 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { */ protected Collection<IExecutionUnitAdapter<E>> deploymentTargets; - /** Channels that define the (allowed) data exchange between logical components. */ - protected Collection<ISignalAdapter<S>> messages; - /** All {@link ExecutionUnit}s that are present in the target platform. */ protected Collection<IExecutionUnitAdapter<E>> allPresentExecutionUnits; @@ -185,7 +183,7 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { * Map: deployable component (= task) -> corresponding (independent, connected) * {@link DefaultTaskGraph}. */ - protected Map<ITaskAdapter<C>, TaskGraph> componentInGraph; + protected Map<ITaskAdapter<C>, TaskGraph> tasksInGraph; /** * Map: deployable component (= task) -> corresponding (independent, connected) @@ -267,8 +265,8 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { * time-triggered scheduler. */ protected void setupScheduleableComponents() { - for(ITaskAdapter<C> comp : deployableComponents) { - if(comp.getTimingRequirementPeriod() != null) { + for(ITaskAdapter<C> comp : tasks) { + if(comp.getPeriod() != null) { schedulableComponents.add(comp); } } @@ -294,29 +292,23 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { // Temporary task graph: add vertices (= software components / tasks that need to be mapped // to processing elements, and that potentially require data from other software components) DefaultTaskGraph<?> temporaryTaskGraph = new DefaultTaskGraph<>(); - // createTaskForrest(); - for(ITaskAdapter<?> deployableComponent : deployableComponents) { - temporaryTaskGraph.addTask(deployableComponent); - } - // Temporary task graph: add edges - addDataDependenciesToTaskGraph(temporaryTaskGraph); + // TODO: Use generics in the task graph + temporaryTaskGraph.addAllTask((Collection<ITaskAdapter<?>>)(Collection<?>)tasks); + temporaryTaskGraph.addAllSignals((Collection<ISignalAdapter<?>>)(Collection<?>)signals); + + temporaryTaskGraph.display(); // Separate temporary task graph into multiple TaskGraphs that consist of exactly one // connected graph component. I.e., there are no data dependencies between the resulting new // TaskGraphs. - // TODO: handle the removal of taskgraphs in another way. Throw an exception / display an - // error for inconsistent period specifications? - // Create a generic TaskGraph of the logical architecture (can contain cycles) taskGraphs = createDefaultTaskGraphs(temporaryTaskGraph); - // removeInvalidTaskGraphs(taskGraphs); - componentInGraph = registerTaskGraphsForComponents(taskGraphs); + tasksInGraph = registerTaskGraphsForTasks(taskGraphs); // Construct an Directed Acyclic TaskGraph (e.g., utilized in scheduling). acyclicTaskGraphs = taskGraphs.stream().map(tg -> new AcyclicTaskGraph(tg)) .collect(Collectors.toList()); - removeInvalidTaskGraphs(acyclicTaskGraphs); - componentInAcyclicGraph = registerTaskGraphsForComponents(acyclicTaskGraphs); + componentInAcyclicGraph = registerTaskGraphsForTasks(acyclicTaskGraphs); // Print some debugging output: print the taskgraphs and display them in a dialog. if(isDebugVerboseEnabled()) { @@ -341,23 +333,20 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { private Collection<TaskGraph> createDefaultTaskGraphs(TaskGraph monolithicTaskGraph) throws InvalidTimingModelException { Collection<TaskGraph> independentTaskGraphs = new ArrayList<>(); - // Compute vertex sets of maximum connected components of temporary task graph ConnectivityInspector<ITaskAdapter<?>, ChannelAdapterWeightedEdge> ci = new ConnectivityInspector<ITaskAdapter<?>, ChannelAdapterWeightedEdge>( - monolithicTaskGraph.getGraph()); + monolithicTaskGraph.getDelegateGraph()); List<Set<ITaskAdapter<?>>> connectedSets = ci.connectedSets(); // Reconstruct TaskGraphs from vertex sets of connected components for(Set<ITaskAdapter<?>> connectedSet : connectedSets) { TaskGraph taskGraph = new DefaultTaskGraph<>(); Graphs.addAllVertices(taskGraph.getGraph(), connectedSet); - - for(ISignalAdapter<?> message : messages) { - if(connectedSet.contains(message.getSource()) && !message.getTargets().isEmpty()) { - taskGraph.addDataDependency(message.getSource(), message.getTargets(), message); + for(ISignalAdapter<?> signal : signals) { + if(connectedSet.contains(signal.getSource())) { + taskGraph.addSignal(signal); } } - // Check if tasks within current sub TaskGraph share the same common period taskGraph.updatePeriod(); independentTaskGraphs.add(taskGraph); @@ -402,7 +391,7 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { // However, we should try to avoid the "SuppressWarnings". @SuppressWarnings("unchecked") private <T extends TaskGraph> Map<ITaskAdapter<C>, T> - registerTaskGraphsForComponents(Collection<T> graphs) { + registerTaskGraphsForTasks(Collection<T> graphs) { Map<ITaskAdapter<C>, T> componentToGraphMap = new HashMap<ITaskAdapter<C>, T>(); for(T taskGraph : graphs) { @@ -414,44 +403,6 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { return componentToGraphMap; } - /** - * For a given collection of {@link TaskGraph}s this method removes all the {@link TaskGraph}s - * from the given collection and the contained {@link ITaskAdapter}s from the set - * of deployable components if the corresponding {@link TaskGraph} has a non-strictly positive - * hyperperiod. - */ - private <T extends TaskGraph> void removeInvalidTaskGraphs(Collection<T> taskGraphs) { - Set<ITaskAdapter<?>> tasksToBeRemoved = new HashSet<ITaskAdapter<?>>(); - Collection<T> graphsToBeRemoved = new HashSet<T>(); - // for(T currentGraph : taskGraphs) { - // if(currentGraph.getPeriod() <= 0) { - // // No valid period specification: TaskGraph cannot be mapped. - // tasksToBeRemoved.addAll((currentGraph).getTasks()); - // graphsToBeRemoved.add(currentGraph); - // System.out.println("No valid period specification: TaskGraph cannot be mapped."); - // System.out.println(currentGraph); - // } - // } - - // TODO: Move these checks to a model validation framework - // Remove tasks with invalid specification - if(!tasksToBeRemoved.isEmpty()) { - System.out.println( - "The following deployable components are ignored during design exploration due to lack of timing annotations."); - System.out.println( - "Each deployable component must be annotated with delay (execution time) and the source commpoent must be annotated with a period!"); - for(ITaskAdapter<?> deployableComponent : tasksToBeRemoved) { - System.out.print(deployableComponent.getName() + " , "); - deployableComponents.remove(deployableComponent); - } - for(T currentGraph : graphsToBeRemoved) { - taskGraphs.remove(currentGraph); - } - System.out.print("\n"); - } - - } - /** * Calculates and returns the hyperperiod of the set of all given {@link TaskGraph}s by * calculating the least common multiple from the hyperperiods of the {@link TaskGraph}s. @@ -487,27 +438,6 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { } } - /** - * Add edges to a {@link TaskGraph} that describe the data dependencies between the software - * components of the logical {@link ComponentArchitecture}. - * - * @throws Exception - */ - private void addDataDependenciesToTaskGraph(DefaultTaskGraph<?> taskGraph) throws Exception { - - // TODO: Currently, top-level components are considered as deployable components (=tasks) - for(ISignalAdapter<?> channelAdapter : messages) { - - ITaskAdapter<?> sourceDeployableComponent = channelAdapter.getSource(); - Collection<ITaskAdapter<?>> targetDeployableComponents = channelAdapter.getTargets(); - - if(sourceDeployableComponent != null && !(targetDeployableComponents.isEmpty())) { - taskGraph.addDataDependency(sourceDeployableComponent, targetDeployableComponents, - channelAdapter); - } - } - } - /** * Creates the {@link PlatformCommunicationGraphEncoding} that is used to determine the routing * of @@ -581,9 +511,9 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { protected void setupEmittedMessages() { emittedMessagesBySender = new HashMap<ITaskAdapter<C>, Collection<ISignalAdapter<S>>>(); - for(ITaskAdapter<C> currentSender : deployableComponents) { + for(ITaskAdapter<C> currentSender : tasks) { Collection<ISignalAdapter<S>> emittedMessages = new ArrayList<ISignalAdapter<S>>(); - for(ISignalAdapter<S> currentMessage : messages) { + for(ISignalAdapter<S> currentMessage : signals) { if(currentSender == currentMessage.getSource()) { emittedMessages.add(currentMessage); } @@ -610,7 +540,7 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { * contain "abstract" {@link Component}s. */ public Collection<ITaskAdapter<C>> getDeployableComponents() { - return deployableComponents; + return tasks; } /** @@ -648,14 +578,7 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { * identified. */ public synchronized ITaskAdapter<C> getDeployableComponentOf(EObject originalEObject) { - // FIXME: HACK to work around the missing consideration of the Task Architecture ATM. - if(originalEObject instanceof Task) { - TaskArchitecture ta = (TaskArchitecture)((Task)originalEObject).getContainer(); - Collection<Component> cCol = getAllocatedComponentsTo(ta, (Task)originalEObject); - originalEObject = cCol.iterator().next(); - } - - for(ITaskAdapter<C> deployableComponentAdapter : deployableComponents) { + for(ITaskAdapter<C> deployableComponentAdapter : tasks) { if(deployableComponentAdapter.getObject() == originalEObject) { return deployableComponentAdapter; } @@ -685,7 +608,7 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { public synchronized ISignalAdapter<S> getChannelAdapter(ITaskAdapter<C> source, ITaskAdapter<C> target) { // TODO: Currently, top-level components are considered as deployable components (=tasks) - for(ISignalAdapter<S> currentChannel : messages) { + for(ISignalAdapter<S> currentChannel : signals) { if(currentChannel.getSource() == source && currentChannel.getTargets().contains(target)) { return currentChannel; @@ -786,7 +709,7 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { * contained. */ public TaskGraph getTaskGraph(ITaskAdapter<?> deployableComponent) { - return componentInGraph.get(deployableComponent); + return tasksInGraph.get(deployableComponent); } /** @@ -822,7 +745,7 @@ public class SystemModelAdapter<C, E, S, G, TR, M> { /** Returns whether the given {@link Component} is a deployable {@link Component}. */ public boolean isDeployableComponent(Component component) { - return deployableComponentObjects.contains(component); + return taskObjects.contains(component); } /** Returns the input output behavior of the given platform connector. */ diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/.ratings index 6a822c2c59c2dbd848eab66c787617b31316601c..9db5d44071f2d9c8b287fddf0c161ef0a1d559d2 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/.ratings @@ -8,6 +8,6 @@ AF3RequestAdapter.java 8b551cf83401d93705d0527184a961ea8244daa3 RED AF3ResourceAdapter.java f20b7da41445acadc3d3cc5b662a993ecbaed47a RED AF3ResourceConnectionAdapter.java b0804eb7d4a2b36065d45bfd90ad548ca7e6c0f8 RED AF3SignalAdapter.java c636c07318ba0f166b35cbf3d45f3b5ec2868e0e RED -AF3SystemModelAdapter.java af16ad00e14b64075a14d1c51c1723f4606c482c RED -AF3TaskAdapter.java a696f76d2ef31f3ae15f013067be9f667f7e6a0d RED -AF3TransmissionUnitAdapter.java 9221b239d1d54cc0b2f01b3c385faa660ed1d3e0 RED +AF3SystemModelAdapter.java 8ddfaa7c415a231ad7bff6194c7f075baecaab34 RED +AF3TaskAdapter.java 5b1a6389970bad5feee7ace642d550ec208e1602 RED +AF3TransmissionUnitAdapter.java f50b20ebf32bed0a7c28d317ef300317ad1198cc RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SystemModelAdapter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SystemModelAdapter.java index da6f0b860e465f3977b5caf3099cf7bb4b704647..a9166087660fef903c43e5a0d70b071f9a9a12c8 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SystemModelAdapter.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SystemModelAdapter.java @@ -35,6 +35,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import java.util.Set; import org.conqat.lib.commons.collections.Pair; @@ -69,8 +70,10 @@ import org.fortiss.af3.task.model.Signal; import org.fortiss.af3.task.model.Task; import org.fortiss.af3.task.model.TaskInputPort; import org.fortiss.af3.task.model.TaskOutputPort; +import org.fortiss.af3.task.model.allocation.ComponentToTaskAllocationEntry; import org.fortiss.tooling.base.model.element.IConnector; import org.fortiss.tooling.base.model.element.IHierarchicElement; +import org.fortiss.tooling.base.model.element.IModelElement; import org.fortiss.tooling.kernel.model.IProjectRootElement; import org.fortiss.tooling.kernel.utils.EcoreUtils; @@ -83,7 +86,7 @@ import com.google.common.collect.Multimap; * @author diewald */ public class AF3SystemModelAdapter extends - SystemModelAdapter<Component, ExecutionUnit, TaskOutputPort, GatewayUnit, TransmissionUnit, MemoryUnit> { + SystemModelAdapter<Task, ExecutionUnit, TaskOutputPort, GatewayUnit, TransmissionUnit, MemoryUnit> { /** * References the {@link AF3DeploymentParameterMapAdapter} providing access to the deployment @@ -109,18 +112,30 @@ public class AF3SystemModelAdapter extends } }); - public AF3SystemModelAdapter(SuperSet<Component> components, SuperSet<ExecutionUnit> execUnits, - SuperSet<Signal> signals) throws Exception { + public AF3SystemModelAdapter(SuperSet<Task> tasks, + SuperSet<ComponentToTaskAllocationEntry> componentTaskAllocs, + SuperSet<ExecutionUnit> execUnits, SuperSet<Signal> signals) throws Exception { // FIXME: Porting Code. - ComponentArchitecture compArch = getFirstParentWithType( - getFirst(components.getEntries()).orElse(null), ComponentArchitecture.class); + Optional<ComponentToTaskAllocationEntry> anyEntry = + getFirst(componentTaskAllocs.getEntries()); + if(!anyEntry.isPresent()) { + throw new Exception("The set of component to task allocations is empty." + + " It is needed by the DSE. Exiting."); + } + Optional<IModelElement> anyComponent = getFirst(anyEntry.get().getSourceElements()); + if(!anyComponent.isPresent()) { + throw new Exception("At least one task is not associated with a Component." + + " It is needed by the DSE. Exiting."); + } + ComponentArchitecture compArch = + getFirstParentWithType(anyComponent.get(), ComponentArchitecture.class); this.logicalArchitecture = new AF3LogicalArchitectureAdapter(compArch); PlatformArchitecture platArch = getFirstParentWithType( - getFirst(components.getEntries()).orElse(null), PlatformArchitecture.class); + getFirst(execUnits.getEntries()).orElse(null), PlatformArchitecture.class); this.platformArchitecture = new AF3PlatformArchitectureAdapter(platArch); // End: Porting code. - this.deployableComponentObjects = components.getEntries(); + this.taskObjects = tasks.getEntries(); this.faultContainmentRegion = Tile.class; // TODO(#3254): Use SuperSets here for querying the required input types. putInputModel(ComponentArchitecture.class, compArch); @@ -143,13 +158,14 @@ public class AF3SystemModelAdapter extends // TODO(#3264): Reintegrate the support for Component Design Libraries. // Multimap<Component, ITaskAdapter<Component>> componentToReplacementAdapter = // createComponentReplacementAdapters(systemParameters.getReplacementComponents()); - Multimap<Component, ITaskAdapter<Component>> componentToReplacementAdapter = - HashMultimap.create(); - deployableComponents = createDeployableComponents(componentToReplacementAdapter); - componentReplacementAdapters = componentToReplacementAdapter.values(); - replicableComponents = new HashSet<>(deployableComponents); - realizableDeployableComponents = createRealizableDeployableComponents(deployableComponents); - messages = createSignalAdapters(signals); + Multimap<Task, ITaskAdapter<Task>> componentToReplacementAdapter = HashMultimap.create(); + this.tasks = createTaskAdapters(componentToReplacementAdapter); + + // TODO(#3264): The three lines below belong to this issue. + // componentReplacementAdapters = componentToReplacementAdapter.values(); + replicableComponents = Collections.emptySet();// new HashSet<>(tasks); + realizableDeployableComponents = Collections.emptySet(); // createRealizableDeployableComponents(tasks); + this.signals = createSignalAdapters(signals); setupScheduleableComponents(); setupTaskGraphs(); @@ -168,22 +184,23 @@ public class AF3SystemModelAdapter extends * {@link ITaskAdapter}s which are referenced by {@link Component}s of the input * {@link ComponentArchitecture} are included in the collection. */ - private Multimap<Component, ITaskAdapter<Component>> createComponentReplacementAdapters( - Multimap<Component, Component> replacementComponents) throws Exception { - Multimap<Component, ITaskAdapter<Component>> rval = HashMultimap.create(); - Collection<Component> allReplacementComponents = replacementComponents.values(); - Map<Component, InternalComponentParameters> internalParameterMap = - createInternalParameterMaps(allReplacementComponents); - - for(Component curComponent : replacementComponents.keySet()) { - for(Component curReplacementComponent : replacementComponents.get(curComponent)) { - rval.put(curComponent, - new AF3TaskAdapter(curReplacementComponent, internalParameterMap)); - } - } - - return rval; - } + // TODO(#3264) + // private Multimap<Component, ITaskAdapter<Component>> createComponentReplacementAdapters( + // Multimap<Component, Component> replacementComponents) throws Exception { + // Multimap<Component, ITaskAdapter<Component>> rval = HashMultimap.create(); + // Collection<Component> allReplacementComponents = replacementComponents.values(); + // Map<Component, InternalComponentParameters> internalParameterMap = + // createInternalParameterMaps(allReplacementComponents); + // + // for(Component curComponent : replacementComponents.keySet()) { + // for(Component curReplacementComponent : replacementComponents.get(curComponent)) { + // rval.put(curComponent, + // new AF3TaskAdapter(curReplacementComponent, internalParameterMap)); + // } + // } + // + // return rval; + // } /** * Determines the deployable components from an AF3 {@link ComponentArchitecture}. @@ -191,28 +208,26 @@ public class AF3SystemModelAdapter extends * @throws Exception */ // TODO(#3262): Periods, Replication bounds. - private Collection<ITaskAdapter<Component>> createDeployableComponents( - Multimap<Component, ITaskAdapter<Component>> componentReplacementAdapters) - throws Exception { - Collection<ITaskAdapter<Component>> rval = new HashSet<>(); + private Collection<ITaskAdapter<Task>> createTaskAdapters( + Multimap<Task, ITaskAdapter<Task>> componentReplacementAdapters) throws Exception { + Collection<ITaskAdapter<Task>> rval = new HashSet<>(); - Map<Component, InternalComponentParameters> internalParameterMap = - createInternalParameterMaps(deployableComponentObjects); + Map<Task, InternalComponentParameters> internalParameterMap = + createInternalParameterMaps(taskObjects); - for(Component currentComponent : deployableComponentObjects) { + for(Task currentTask : taskObjects) { Double period = 10.0; // No replication for the porting time. Pair<Integer, Integer> replicationBounds = new Pair<>(1, 1); // componentReplicationBounds.get(currentComponent); if(replicationBounds == null || replicationBounds.getFirst() == null || replicationBounds.getSecond() == null) { - throw new Exception("The replication bounds for the deployable component " + - currentComponent + " have not been defined properly."); + throw new Exception("The replication bounds for the task " + currentTask + + " have not been defined properly."); } - rval.add(new AF3TaskAdapter(currentComponent, internalParameterMap, - replicationBounds.getFirst(), replicationBounds.getSecond(), period, - componentReplacementAdapters.get(currentComponent))); + rval.add(new AF3TaskAdapter(currentTask, internalParameterMap, + replicationBounds.getFirst(), replicationBounds.getSecond(), period)); } return rval; @@ -274,26 +289,25 @@ public class AF3SystemModelAdapter extends * of each given component using the {@link AF3DeploymentParameterMapAdapter} and transforms * them into a {@link InternalComponentParameters} representation. */ - private Map<Component, InternalComponentParameters> - createInternalParameterMaps(Collection<Component> deployableComponents) { + private Map<Task, InternalComponentParameters> + createInternalParameterMaps(Collection<Task> tasks) { if(parameterAdapter == null) { return Collections.emptyMap(); } - Map<Component, InternalComponentParameters> internalParameterMap = - new HashMap<Component, InternalComponentParameters>(); - - for(Component currentComponent : deployableComponents) { + Map<Task, InternalComponentParameters> internalParameterMap = new HashMap<>(); + for(Task currentComponent : tasks) { Map<IExecutionUnitAdapter<?>, Double> wcetMap = new HashMap<IExecutionUnitAdapter<?>, Double>(); Map<IExecutionUnitAdapter<?>, Double> energyConsumptionMap = new HashMap<IExecutionUnitAdapter<?>, Double>(); for(IExecutionUnitAdapter<?> execUnit : deploymentTargets) { - wcetMap.put(execUnit, parameterAdapter.getWcet(currentComponent, execUnit)); + // TODO(#3262): Also reinclude the WCets. + wcetMap.put(execUnit, + 1.0/* parameterAdapter.getWcet(currentComponent, execUnit) */); // energyConsumptionMap.put(execUnit, // parameterAdapter.getEnergyConsumption(currentComponent, execUnit)); } - InternalComponentParameters parameterMap = new InternalComponentParameters(); parameterMap.setWcetMap(wcetMap); parameterMap.setEnergyConsumptionMap(energyConsumptionMap); @@ -386,118 +400,6 @@ public class AF3SystemModelAdapter extends } } - /** - * Propagates periods defined in periodic constraints to successor components as defined in the - * corresponding {@link ComponentArchitecture}. The successor {@link Component}s are associated - * with a list of periods that are propagated to them. - * - * @throws Exception - * if the timing specification of any traversed element is inconsistent. - */ - // private void propagatePeriodsToPredecessors(Map<Component, Double> componentPeriodMap, - // Map<Component, Collection<Double>> possibleComponentPeriods) throws Exception { - // Set<Component> workingQueue = new HashSet<Component>(); - // Set<InputPort> traversedInputPorts = new HashSet<InputPort>(); - // workingQueue.addAll(componentPeriodMap.keySet()); - // while(!workingQueue.isEmpty()) { - // Component currentComponent = (Component)workingQueue.toArray()[0]; - // workingQueue.remove(currentComponent); - // for(InputPort portToPredeccessor : currentComponent.getInputPorts()) { - // if(!traversedInputPorts.contains(portToPredeccessor)) { - // traversedInputPorts.add(portToPredeccessor); - // for(OutputPort predecessorPort : findSourcePorts(portToPredeccessor)) { - // Component predecessorComponent = predecessorPort.getComponent(); - // // Predecessor is not referenced by a periodic constraint - // if(!componentPeriodMap.containsKey(predecessorComponent)) { - // Collection<Double> possiblePeriods = - // possibleComponentPeriods.get(predecessorComponent); - // // If the predecessor component has not been considered yet, a list for - // // the possible periods must be created. - // if(possiblePeriods == null) { - // possiblePeriods = new ArrayList<Double>(); - // } - // possiblePeriods.addAll(possibleComponentPeriods.get(currentComponent)); - // possibleComponentPeriods.put(predecessorComponent, possiblePeriods); - // workingQueue.add(predecessorComponent); - // } - // } - // } - // } - // } - // } - - /** - * Determines the allowed data exchange (channels) from an AF3 {@link ComponentArchitecture}. - * - * @throws Exception - */ - // private Collection<ISignalAdapter<OutputPort>> - // createSignalAdapters(Map<OutputPort, Long> messageSizes) throws Exception { - // Collection<ISignalAdapter<OutputPort>> rval = new ArrayList<ISignalAdapter<OutputPort>>(); - // - // Collection<Component> af3DeployableComponents = new ArrayList<>(); - // deployableComponents.forEach(d -> af3DeployableComponents.add(d.getObject())); - // - // for(OutputPort currentSenderPort : getDeployableOutputPorts(af3DeployableComponents)) { - // ITaskAdapter<?> currentSenderComponentAdapter = - // getDeployableComponentAdapter(currentSenderPort.getComponent()); - // if(currentSenderComponentAdapter != null) { - // Collection<ITaskAdapter<?>> receiverComponentAdapters = - // new ArrayList<ITaskAdapter<?>>(); - // Collection<Port> targetPorts = - // findTargetPorts(currentSenderPort, af3DeployableComponents); - // for(Port currentReceiverPort : targetPorts) { - // ITaskAdapter<?> receiverComponentAdapter = - // getDeployableComponentAdapter(currentReceiverPort.getComponent()); - // receiverComponentAdapters.add(receiverComponentAdapter); - // } - // if(!receiverComponentAdapters.isEmpty()) { - // // Do not consider unconnected Ports - // Collection<InputPort> filteredRecvPorts = - // pickInstanceOf(InputPort.class, new ArrayList<>(targetPorts)); - // AF3SignalAdapter sigAdp = new AF3SignalAdapter(currentSenderPort, - // currentSenderComponentAdapter, filteredRecvPorts, - // receiverComponentAdapters, messageSizes.get(currentSenderPort)); - // sigAdp.setSignalType(portSignalTypes.get(currentSenderPort)); - // rval.add(sigAdp); - // } - // } - // } - // - // return rval; - // } - - /** - * Pre-sort the {@link ISignalAdapter}s such that the {@link ITaskAdapter}s - * referenced by periodic constraints are located at the top of the {@link ISignalAdapter} list. - * <p> - * <b>NOTE:</b> This method is just for user convenience, do not expect the ordering to be kept - * by other algorithms! - * - * @throws Exception - * if the period cannot be determined for one component, possibly due to an - * inconsistent timing specification. - */ - // TODO: cleanup or get rid of this method. - // private Collection<ISignalAdapter<OutputPort>> sortMessagesByExpectedOrder( - // Collection<ISignalAdapter<OutputPort>> unsortedMessages, - // Map<Component, Double> componentPeriodMap) throws Exception { - // Collection<ISignalAdapter<OutputPort>> rval = new ArrayList<ISignalAdapter<OutputPort>>(); - // for(ISignalAdapter<OutputPort> currentMessage : unsortedMessages) { - // Double periodValue = componentPeriodMap.get(currentMessage.getSource().getObject()); - // if(periodValue != null && periodValue > 0) { - // rval.add(currentMessage); - // } - // } - // for(ISignalAdapter<OutputPort> currentMessage : unsortedMessages) { - // Double periodValue = componentPeriodMap.get(currentMessage.getSource().getObject()); - // if(periodValue == null || periodValue <= 0) { - // rval.add(currentMessage); - // } - // } - // return rval; - // } - /** * Creates {@link IMemoryUnitAdapter}s from AF3-{@link MemoryUnit}s. * @@ -763,19 +665,16 @@ public class AF3SystemModelAdapter extends */ public ITaskAdapter<?> getTaskAdapter(Task af3Task) { if(af3Task == null) { - throw new IllegalArgumentException( - "Cannot identify IDeployableComponentAdapters for 'null' Components"); + throw new IllegalArgumentException("Cannot identify ITaskAdapter for 'null' Tasks"); } - - ITaskAdapter<?> deployableComponentAdapter = null; - for(ITaskAdapter<Component> deployableComponent : deployableComponents) { - if(deployableComponent.getObject() == af3Task) { - deployableComponentAdapter = deployableComponent; + ITaskAdapter<?> taskAdapter = null; + for(ITaskAdapter<Task> task : tasks) { + if(task.getObject() == af3Task) { + taskAdapter = task; break; } } - - return deployableComponentAdapter; + return taskAdapter; } /** @@ -869,7 +768,7 @@ public class AF3SystemModelAdapter extends // would be rather required to define the source and sink components as // IDeployableComponents in the ecore model. The transformation from AF3 components to the // IDeployableCompontes should be done when the data from the GUI is written to the model. - ITaskAdapter<?> deployableComponent = getTaskAdapter(task); - return getTaskGraph(deployableComponent); + ITaskAdapter<?> taskAdapter = getTaskAdapter(task); + return getTaskGraph(taskAdapter); } } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3TaskAdapter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3TaskAdapter.java index 6ec5dd10c1d7baae52bf7d75c0c421a333e19534..6bb4ded97c607b99a20321ef28552060d894775c 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3TaskAdapter.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3TaskAdapter.java @@ -18,23 +18,24 @@ package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.Map; import org.eclipse.emf.common.util.Enumerator; import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; +import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.InternalComponentParameters; import org.fortiss.af3.safety.model.annotation.SafetyIntegrityLevel; +import org.fortiss.af3.task.model.Task; /** * Adapter between the AF3 deployable {@link Component} (=tasks) and the DSE. * * @author barner */ -public class AF3TaskAdapter extends AF3RequestAdapter<Component> - implements ITaskAdapter<Component> { +public class AF3TaskAdapter extends AF3RequestAdapter<Task> implements ITaskAdapter<Task> { /** Map of possible Wcets defined by the deployment target. */ @SuppressWarnings("unused") private Map<IExecutionUnitAdapter<?>, Double> wcetMap; @@ -68,8 +69,8 @@ public class AF3TaskAdapter extends AF3RequestAdapter<Component> * * @throws Exception */ - public AF3TaskAdapter(Component deployableComponent, - Map<Component, InternalComponentParameters> internalParameters) throws Exception { + public AF3TaskAdapter(Task deployableComponent, + Map<Task, InternalComponentParameters> internalParameters) throws Exception { super(deployableComponent); // TODO: possible NPE @@ -92,10 +93,9 @@ public class AF3TaskAdapter extends AF3RequestAdapter<Component> * * @throws Exception */ - public AF3TaskAdapter(Component deployableComponent, - Map<Component, InternalComponentParameters> internalParameters, Integer minReplication, - Integer maxReplication, Double period) throws Exception { - this(deployableComponent, internalParameters); + public AF3TaskAdapter(Task task, Map<Task, InternalComponentParameters> internalParameters, + Integer minReplication, Integer maxReplication, Double period) throws Exception { + this(task, internalParameters); this.minReplication = minReplication; this.maxReplication = maxReplication; @@ -108,12 +108,10 @@ public class AF3TaskAdapter extends AF3RequestAdapter<Component> * * @throws Exception */ - public AF3TaskAdapter(Component deployableComponent, - Map<Component, InternalComponentParameters> internalParameters, Integer minReplication, - Integer maxReplication, Double period, - Collection<ITaskAdapter<Component>> componentReplacementAdapters) - throws Exception { - this(deployableComponent, internalParameters, minReplication, maxReplication, period); + public AF3TaskAdapter(Task task, Map<Task, InternalComponentParameters> internalParameters, + Integer minReplication, Integer maxReplication, Double period, + Collection<ITaskAdapter<Component>> componentReplacementAdapters) throws Exception { + this(task, internalParameters, minReplication, maxReplication, period); this.period = period; replacementComponents = componentReplacementAdapters; @@ -123,14 +121,12 @@ public class AF3TaskAdapter extends AF3RequestAdapter<Component> * Creates an "concrete" {@link ITaskAdapter} for an {@link Component} with the * given period. */ - public AF3TaskAdapter(Component deployableComponent, - Map<Component, InternalComponentParameters> internalParameters, - ITaskAdapter<Component> replacedComponent) throws Exception { - this(deployableComponent, internalParameters, replacedComponent.getMinReplication(), - replacedComponent.getMaxReplication(), - replacedComponent.getTimingRequirementPeriod()); + public AF3TaskAdapter(Task task, Map<Task, InternalComponentParameters> internalParameters, + ITaskAdapter<Task> replacedComponent) throws Exception { + this(task, internalParameters, replacedComponent.getMinReplication(), + replacedComponent.getMaxReplication(), replacedComponent.getPeriod()); - this.replacedComponent = replacedComponent; + // this.replacedComponent = replacedComponent; } /** {@inheritDoc} */ @@ -156,13 +152,13 @@ public class AF3TaskAdapter extends AF3RequestAdapter<Component> /** {@inheritDoc} */ @Override - public Double getTimingRequirementPeriod() { + public Double getPeriod() { return period; } /** {@inheritDoc} */ @Override - public void setTimingRequirementPeriod(double period) { + public void setPeriod(double period) { this.period = period; } @@ -180,22 +176,25 @@ public class AF3TaskAdapter extends AF3RequestAdapter<Component> /** {@inheritDoc} */ @Override - public Collection<ITaskAdapter<Component>> getReplacementComponents() { - return replacementComponents; + public Collection<ITaskAdapter<Task>> getReplacementComponents() { + // TODO(#3264) + // return replacementComponents; + return Collections.emptySet(); } /** {@inheritDoc} */ @Override - public ITaskAdapter<Component> getReplacedComponent() { - return replacedComponent; + public ITaskAdapter<Task> getReplacedComponent() { + // TODO(#3264) + // return replacedComponent; + return null; } /** {@inheritDoc} */ // TODO: If possible, find a way to avoid these suppresswarnings. @SuppressWarnings("unchecked") @Override - public void setReplacedComponent( - @SuppressWarnings("rawtypes") ITaskAdapter abstractComponent) { + public void setReplacedComponent(@SuppressWarnings("rawtypes") ITaskAdapter abstractComponent) { replacedComponent = abstractComponent; } @@ -217,15 +216,6 @@ public class AF3TaskAdapter extends AF3RequestAdapter<Component> return maxReplication; } - /** {@inheritDoc} */ - @Override - public boolean isStronglyCausal() { - if(modelElement.isStronglyCausal()) { - return true; - } - return false; - } - /** {@inheritDoc} */ @Override public AF3TaskAdapter clone() { diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3TransmissionUnitAdapter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3TransmissionUnitAdapter.java index 34548ec06355d236cc811cbcf6412178058b9830..15672d946519a061aa086ab041aa31d142dc1f56 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3TransmissionUnitAdapter.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3TransmissionUnitAdapter.java @@ -30,12 +30,17 @@ import org.fortiss.af3.timing.model.annotation.TransmissionUnitBandwidth; * * @author barner */ -public class AF3TransmissionUnitAdapter extends AF3ResourceAdapter<TransmissionUnit> implements - ITransmissionUnitAdapter<TransmissionUnit> { +public class AF3TransmissionUnitAdapter extends AF3ResourceAdapter<TransmissionUnit> + implements ITransmissionUnitAdapter<TransmissionUnit> { /** Conversion constant for the message size. */ private static final long MBYTES_TO_BYTES = 1000 * 1000; - /** {@link IResourceAdapter}s that are connected with this {@link AF3TransmissionUnitAdapter}. */ + /** Conversion bytes -> bits. */ + private static final long BYTES_TO_BITS = 8; + + /** + * {@link IResourceAdapter}s that are connected with this {@link AF3TransmissionUnitAdapter}. + */ Collection<IResourceAdapter<?>> connectedResources; /** {@link TransmissionUnit} bandwidth annotation */ @@ -63,13 +68,12 @@ public class AF3TransmissionUnitAdapter extends AF3ResourceAdapter<TransmissionU this.transmissionUnitPower = power; // Extract annotations - transmissionUnitBandwidth = - pickFirstInstanceOf(TransmissionUnitBandwidth.class, - transmissionUnit.getSpecifications()); + transmissionUnitBandwidth = pickFirstInstanceOf(TransmissionUnitBandwidth.class, + transmissionUnit.getSpecifications()); if(transmissionUnitBandwidth == null) { throw new Exception("Transmission unit " + transmissionUnit + " does not have a bandwidth annotation."); - } else if(transmissionUnitBandwidth.getBandwidth_MBytesPerSecond() == 0.0) { + } else if(transmissionUnitBandwidth.getBandwidth_MBitS() == 0.0) { throw new Exception("The transmission unit " + transmissionUnit + " has a bandwidth of 0 MB/s. This is not a valid attribute."); } @@ -79,13 +83,13 @@ public class AF3TransmissionUnitAdapter extends AF3ResourceAdapter<TransmissionU @Override public double getPower(long messageSizeInBits) { return messageSizeInBits / - (MBYTES_TO_BYTES * transmissionUnitBandwidth.getBandwidth_MBytesPerSecond()) * + (MBYTES_TO_BYTES * transmissionUnitBandwidth.getBandwidth_MBitS()) * transmissionUnitPower; } /** {@inheritDoc} */ @Override public double getTransmissionDuration(double messageSizeMB) { - return messageSizeMB / transmissionUnitBandwidth.getBandwidth_MBytesPerSecond(); + return (messageSizeMB * BYTES_TO_BITS) / transmissionUnitBandwidth.getBandwidth_MBitS(); } } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/.ratings index a84a6cb91be3d06e177f9cc2460474e868fa1a1c..be0192144a5f5d9458f26ef3677c7f0636421eda 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/.ratings @@ -1,5 +1,5 @@ -AcyclicTaskGraph.java 7cca0f0902960c20a4acfae7fe2f84432592da20 RED +AcyclicTaskGraph.java c448c1ca9f53ebb2aae627c9ea0ee603912f377f RED ChannelAdapterWeightedEdge.java ef160bea5d74f09617388767313657dd76283f61 RED -DefaultTaskGraph.java 4d155038b8a2b112dd83e96f09fb70483bc7e5aa RED -TaskGraph.java da0b771d32cd41947767ffb0d5a5a5d90c1c206f RED -TaskGraphInstantiator.java 227babf2903b30077cf9ba6d0b9857f91d61ef0d RED +DefaultTaskGraph.java c4c33dfbf26a364761ad4e15b5884305bd910f0e RED +TaskGraph.java 4368f1710b40760d4653e61f693bb1aeabe5cafb RED +TaskGraphInstantiator.java 63c5159b692665cca407bd254982d0976be5a4ff RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/AcyclicTaskGraph.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/AcyclicTaskGraph.java index 4ba1a5dd34f0c52077a2662de9807e4fdbe0bd19..da6df476375778265a4b45d032c7e085e8493beb 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/AcyclicTaskGraph.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/AcyclicTaskGraph.java @@ -21,14 +21,14 @@ import java.util.HashMap; import java.util.SortedSet; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.TaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ILogicalArchitectureAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISignalAdapter; +import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.faultmodel.FaultDetector; -import org.jgrapht.DirectedGraph; import org.jgrapht.Graphs; import org.jgrapht.alg.PrimMinimumSpanningTree; import org.jgrapht.alg.interfaces.MinimumSpanningTree; +import org.jgrapht.graph.DefaultListenableGraph; import org.jgrapht.graph.ListenableDirectedWeightedGraph; /** @@ -71,7 +71,7 @@ public class AcyclicTaskGraph extends DefaultTaskGraph<AcyclicTaskGraph> { * {@link ChannelAdapterWeightedEdge}s. */ private void createMinSpanAcycTaskGraph(TaskGraph taskGraph) { - DirectedGraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge> tg = + DefaultListenableGraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge> tg = taskGraph.getGraph(); Graphs.addAllVertices(graph, tg.vertexSet()); @@ -101,8 +101,7 @@ public class AcyclicTaskGraph extends DefaultTaskGraph<AcyclicTaskGraph> { ChannelAdapterWeightedEdge.class); Graphs.addGraph(clonedTaskGraph.graph, graph); clonedTaskGraph.taskFaultDetectorsMap = - new HashMap<ITaskAdapter<?>, SortedSet<FaultDetector>>( - taskFaultDetectorsMap); + new HashMap<ITaskAdapter<?>, SortedSet<FaultDetector>>(taskFaultDetectorsMap); return clonedTaskGraph; } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/DefaultTaskGraph.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/DefaultTaskGraph.java index 922da178f0c75636fa8ac518b553d0baf34290ba..970d344596a0b49d4ea0f56d791cffec9a6df713 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/DefaultTaskGraph.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/DefaultTaskGraph.java @@ -15,6 +15,7 @@ +--------------------------------------------------------------------------*/ package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; @@ -23,14 +24,16 @@ import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISignalAdapter; +import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.faultmodel.FaultDetector; import org.fortiss.af3.exploration.alg.dse.sysmodel.random.RandomExploration; -import org.fortiss.af3.exploration.alg.exception.InvalidTimingModelException; import org.fortiss.af3.exploration.alg.graph.display.JGraphTVisualizer; +import org.fortiss.af3.schedule.utils.MathUtils; import org.jgrapht.Graphs; +import org.jgrapht.graph.DefaultListenableGraph; +import org.jgrapht.graph.DirectedWeightedMultigraph; import org.jgrapht.graph.ListenableDirectedWeightedGraph; import org.jgrapht.traverse.DepthFirstIterator; @@ -57,7 +60,10 @@ import com.google.common.collect.Multimap; public class DefaultTaskGraph<T extends DefaultTaskGraph<?>> implements TaskGraph, Cloneable { /** Underlying graph implementation */ // TODO: Add a weight w.r.t. transmission time, when deployed - protected ListenableDirectedWeightedGraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge> graph; + protected DefaultListenableGraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge> graph; + + /** The actual Graph holding the data. It does not provide any listener interface. */ + protected DirectedWeightedMultigraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge> delegateGraph; // TODO: Currently, all tasks in a {@link TaskGraph} must have the same period /** The period time of this {@link DefaultTaskGraph}. */ @@ -76,14 +82,16 @@ public class DefaultTaskGraph<T extends DefaultTaskGraph<?>> implements TaskGrap */ private Multimap<ITaskAdapter<?>, ITaskAdapter<?>> abstractToInstanceTaskMap; + /** TEMPORAL PRECISION. */ + public static int TEMP_PRECISION_EXP = 9; + /** Creates an empty {@link DefaultTaskGraph}. */ public DefaultTaskGraph() { + delegateGraph = new DirectedWeightedMultigraph<>(ChannelAdapterWeightedEdge.class); + graph = new DefaultListenableGraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge>( + delegateGraph); - graph = new ListenableDirectedWeightedGraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge>( - ChannelAdapterWeightedEdge.class); - - taskFaultDetectorsMap = - new HashMap<ITaskAdapter<?>, SortedSet<FaultDetector>>(); + taskFaultDetectorsMap = new HashMap<ITaskAdapter<?>, SortedSet<FaultDetector>>(); abstractToInstanceTaskMap = HashMultimap.create(); } @@ -91,23 +99,29 @@ public class DefaultTaskGraph<T extends DefaultTaskGraph<?>> implements TaskGrap /** Registers a deployable component (=task) with the {@link DefaultTaskGraph}. */ @Override public boolean addTask(ITaskAdapter<?> task) { - if(task.isInstantiation()) { - abstractToInstanceTaskMap.put(task.getReplacedComponent(), task); - } - // FIXME: Hack, remove the map. - abstractToInstanceTaskMap.put(task, task); + // TODO(#3264) + // if(task.isInstantiation()) { + // abstractToInstanceTaskMap.put(task.getReplacedComponent(), task); + // } + // // FIXME: Hack, remove the map. + // abstractToInstanceTaskMap.put(task, task); return graph.addVertex(task); } /** {@inheritDoc} */ @Override - public boolean addTask(ITaskAdapter<?> task, - ITaskAdapter<?> refTask) { + public boolean addTask(ITaskAdapter<?> task, ITaskAdapter<?> refTask) { // FIXME: Hack, remove the map. abstractToInstanceTaskMap.put(refTask, task); return graph.addVertex(task); } + /** Registers a deployable component (=task) with the {@link DefaultTaskGraph}. */ + @Override + public boolean addAllTask(Collection<ITaskAdapter<?>> tasks) { + return Graphs.addAllVertices(graph, tasks); + } + /** {@inheritDoc} */ @Override public void removeTask(ITaskAdapter<?> task) { @@ -126,36 +140,25 @@ public class DefaultTaskGraph<T extends DefaultTaskGraph<?>> implements TaskGrap /** {@inheritDoc} */ @Override - public boolean addDataDependency(ITaskAdapter<?> sourceComponent, - Collection<ITaskAdapter<?>> destinationComponents, - ISignalAdapter<?> channelAdapter) { - - boolean addingAllEdgesSuccessful = true; - - // Add edges from the source component to each receiver. - for(ITaskAdapter<?> currentDestinationComponent : destinationComponents) { - // Only add Dependencies which are present in this TaskGraph - if(graph.containsVertex(sourceComponent) && - graph.containsVertex(currentDestinationComponent)) { - // Generate an edge in the task graph for each receiver. A single failure will cause - // the whole function to be return 'failed'. - if(!graph.addEdge(sourceComponent, currentDestinationComponent, - new ChannelAdapterWeightedEdge(channelAdapter))) { - addingAllEdgesSuccessful = false; - } + public boolean addSignal(ISignalAdapter<?> signalAdapter) { + for(ITaskAdapter<?> recvTask : signalAdapter.getTargets()) { + if(!graph.addEdge(signalAdapter.getSource(), recvTask, + new ChannelAdapterWeightedEdge(signalAdapter))) { + return false; } } - - return addingAllEdgesSuccessful; + return true; } - /** Registers a data dependencies between a source and its destination component. */ - public boolean addDataDependency(ITaskAdapter<?> sourceComponent, - ITaskAdapter<?> destinationComponent, ISignalAdapter<?> channelAdapter) { - graph.addVertex(sourceComponent); - graph.addVertex(destinationComponent); - return graph.addEdge(sourceComponent, destinationComponent, - new ChannelAdapterWeightedEdge(channelAdapter)); + /** {@inheritDoc} */ + @Override + public boolean addAllSignals(Collection<ISignalAdapter<?>> signalAdapters) { + for(ISignalAdapter<?> signal : signalAdapters) { + if(!addSignal(signal)) { + return false; + } + } + return false; } /** {@inheritDoc} */ @@ -167,42 +170,30 @@ public class DefaultTaskGraph<T extends DefaultTaskGraph<?>> implements TaskGrap // TODO: Get rid of this method! /** {@inheritDoc} */ @Override - public ListenableDirectedWeightedGraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge> - getGraph() { + public DefaultListenableGraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge> getGraph() { return graph; } + // TODO: Get rid of this method! + /** {@inheritDoc} */ + @Override + public DirectedWeightedMultigraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge> + getDelegateGraph() { + return delegateGraph; + } + /** {@inheritDoc} */ @Override public Double getPeriod() { return period; } - /** - * {@inheritDoc} - * - * @throws InvalidTimingModelException - * see {@link TaskGraph#updatePeriod()}. - */ + /** {@inheritDoc} */ @Override - public void updatePeriod() throws InvalidTimingModelException { - boolean isFirstSet = false; - // TODO: Move these consistency check to model validation framework - for(ITaskAdapter<?> deployableComponent : getTasks()) { - Double deployableComponentPeriod = deployableComponent.getTimingRequirementPeriod(); - - if(!isFirstSet) { - period = deployableComponentPeriod; - isFirstSet = true; - } - - // TODO: readd the period consistency check for task graphs. - // if(period != null && !period.equals(deployableComponentPeriod)) { - // throw new InvalidTimingModelException( - // "The periods of the task graph could not be identified. Currently, only tasks with - // the same period or non-periodic task graphs are allowed."); - // } - } + public void updatePeriod() { + Collection<Double> periodList = new ArrayList<>(); + getTasks().forEach(t -> periodList.add(t.getPeriod())); + period = MathUtils.gcdDoubleCollection(periodList, TEMP_PRECISION_EXP); } /** Returns the fault detector with a given index / ID for a given task. */ @@ -238,8 +229,7 @@ public class DefaultTaskGraph<T extends DefaultTaskGraph<?>> implements TaskGrap @Override public void display() { JGraphTVisualizer<ITaskAdapter<?>, ChannelAdapterWeightedEdge> taskViz = - new JGraphTVisualizer<ITaskAdapter<?>, ChannelAdapterWeightedEdge>( - this.getGraph()); + new JGraphTVisualizer<ITaskAdapter<?>, ChannelAdapterWeightedEdge>(this.getGraph()); taskViz.displayGraph("Task graph"); } @@ -249,8 +239,7 @@ public class DefaultTaskGraph<T extends DefaultTaskGraph<?>> implements TaskGrap String rval = ""; Iterator<ITaskAdapter<?>> iter = - new DepthFirstIterator<ITaskAdapter<?>, ChannelAdapterWeightedEdge>( - graph); + new DepthFirstIterator<ITaskAdapter<?>, ChannelAdapterWeightedEdge>(graph); while(iter.hasNext()) { ITaskAdapter<?> deployableComponent = iter.next(); rval = rval.concat("Task " + deployableComponent.getName() + ": "); @@ -278,8 +267,7 @@ public class DefaultTaskGraph<T extends DefaultTaskGraph<?>> implements TaskGrap ChannelAdapterWeightedEdge.class); Graphs.addGraph(clonedTaskGraph.graph, graph); clonedTaskGraph.taskFaultDetectorsMap = - new HashMap<ITaskAdapter<?>, SortedSet<FaultDetector>>( - taskFaultDetectorsMap); + new HashMap<ITaskAdapter<?>, SortedSet<FaultDetector>>(taskFaultDetectorsMap); return clonedTaskGraph; } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraph.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraph.java index c3325e1fd203cd91a92bae2b625126154ebd990a..b8e507cd2a33edd6388ccfb76aec9fe57ea4b477 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraph.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraph.java @@ -18,12 +18,13 @@ package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph; import java.util.Collection; import java.util.Set; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISignalAdapter; +import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.faultmodel.FaultDetector; import org.fortiss.af3.exploration.alg.exception.InvalidTimingModelException; import org.jgrapht.DirectedGraph; -import org.jgrapht.graph.ListenableDirectedWeightedGraph; +import org.jgrapht.graph.DefaultListenableGraph; +import org.jgrapht.graph.DirectedWeightedMultigraph; /** * Interface for {@link TaskGraph}s which are the (flattened) DSE-internal representations of a @@ -32,16 +33,16 @@ import org.jgrapht.graph.ListenableDirectedWeightedGraph; * @author diewald */ public interface TaskGraph { - - /** Registers a data dependencies between a source and its destination components. */ - public boolean addDataDependency(ITaskAdapter<?> sourceComponent, - Collection<ITaskAdapter<?>> destinationComponents, - ISignalAdapter<?> channelAdapter); + // TODO: Get rid of this method! + /** Returns the underlying {@link DefaultListenableGraph}. */ + DefaultListenableGraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge> getGraph(); // TODO: Get rid of this method! - /** Returns the underlying {@link ListenableDirectedWeightedGraph}. */ - public ListenableDirectedWeightedGraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge> - getGraph(); + /** + * Returns the underlying {@link DirectedWeightedMultigraph} that holds the data of the + * corresponding {@link DefaultListenableGraph}. + */ + DirectedWeightedMultigraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge> getDelegateGraph(); /** * Updates the period of this {@link TaskGraph}: Determine the common period of the tasks @@ -51,53 +52,66 @@ public interface TaskGraph { * @throws InvalidTimingModelException * if the periods of the {@link TaskGraph}'s task are inconsistent. */ - public void updatePeriod() throws InvalidTimingModelException; + void updatePeriod() throws InvalidTimingModelException; /** Returns the {@link TaskGraph}s period. */ - public Double getPeriod(); + Double getPeriod(); /** Returns the set of deployable components (=tasks) of this {@link TaskGraph}. */ - public Set<ITaskAdapter<?>> getTasks(); + Set<ITaskAdapter<?>> getTasks(); /** * Checks whether {@code this} {@link TaskGraph} contains the given * {@link ITaskAdapter} or an instance of it. */ - public boolean containsTask(ITaskAdapter<?> task); + boolean containsTask(ITaskAdapter<?> task); /** * Checks whether {@code this} {@link TaskGraph} contains any of the given * {@link ITaskAdapter}s. */ - public boolean containsAnyTaskOf(Collection<ITaskAdapter<?>> taskSet); + boolean containsAnyTaskOf(Collection<ITaskAdapter<?>> taskSet); /** * Adds the given {@link ITaskAdapter} to the {@link TaskGraph}, i.e. as a vertex * to the corresponding {@link DirectedGraph}. */ - public boolean addTask(ITaskAdapter<?> task); + boolean addTask(ITaskAdapter<?> task); /** * Adds the given {@code task} to the {@link TaskGraph}, i.e. as a vertex * to the corresponding {@link DirectedGraph}, and further makes it accessible if the given * {@code refTask} is queried. */ - public boolean addTask(ITaskAdapter<?> task, - ITaskAdapter<?> refTask); + boolean addTask(ITaskAdapter<?> task, ITaskAdapter<?> refTask); + + /** + * Adds all given tasks to the task graph. + * + * @param tasks + * collection of tasks to add to the graph. + * @return whether the tasks were successfully added. + */ + boolean addAllTask(Collection<ITaskAdapter<?>> tasks); + + /** Adds a signal to the task graph that defines a data exchange between two tasks. */ + boolean addSignal(ISignalAdapter<?> signalAdapter); + + /** Adds signals to the task graph that are used to exchange data between tasks. */ + boolean addAllSignals(Collection<ISignalAdapter<?>> signalAdapters); /** Removes the given {@code task} and its data dependencies from the {@link TaskGraph}. */ - public void removeTask(ITaskAdapter<?> task); + void removeTask(ITaskAdapter<?> task); /** Creates a Dialog that illustrates this {@link TaskGraph}. */ - public void display(); + void display(); /** Creates and returns a copy of {@code this} {@link TaskGraph}. */ - public <T extends TaskGraph> T copy(); + <T extends TaskGraph> T copy(); /** Registers a fault detector for a given task. */ - public void addFaultDetector(ITaskAdapter<?> deployableComponent, - FaultDetector faultDetector); + void addFaultDetector(ITaskAdapter<?> deployableComponent, FaultDetector faultDetector); /** Returns a random fault detector index / ID for the given task. */ - public int getRandomFaultDetectorId(ITaskAdapter<?> deployableComponent); + int getRandomFaultDetectorId(ITaskAdapter<?> deployableComponent); } diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraphInstantiator.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraphInstantiator.java index 6f1d9f48a143fa8f16b7cbd5e8bcbb23b30d8f0e..cfe3dd239a2073db119302ad782852d0eac67650 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraphInstantiator.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraphInstantiator.java @@ -26,7 +26,7 @@ import java.util.Set; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEntry; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; -import org.jgrapht.graph.ListenableDirectedWeightedGraph; +import org.jgrapht.graph.DefaultListenableGraph; /** * Manages the construction of {@link TaskGraph}s whose vertices are exclusively instances of @@ -50,8 +50,7 @@ public class TaskGraphInstantiator<T extends TaskGraph> { */ public TaskGraphInstantiator(T abstractGraph, InstantiatedTaskMappingEncoding<? extends InstantiatedTaskMappingEntry> encoding) { - instanceToAbstractNodeMap = - new HashMap<T, Map<ITaskAdapter<?>, ITaskAdapter<?>>>(); + instanceToAbstractNodeMap = new HashMap<T, Map<ITaskAdapter<?>, ITaskAdapter<?>>>(); instanceToAbstractNodeMap.put(abstractGraph, createAbstractInstantiatedNodeAssociations(encoding)); } @@ -63,8 +62,7 @@ public class TaskGraphInstantiator<T extends TaskGraph> { */ public TaskGraphInstantiator(Collection<T> abstractGraphs, InstantiatedTaskMappingEncoding<? extends InstantiatedTaskMappingEntry> encoding) { - instanceToAbstractNodeMap = - new HashMap<T, Map<ITaskAdapter<?>, ITaskAdapter<?>>>(); + instanceToAbstractNodeMap = new HashMap<T, Map<ITaskAdapter<?>, ITaskAdapter<?>>>(); for(T taskGraph : abstractGraphs) { instanceToAbstractNodeMap.put(taskGraph, createAbstractInstantiatedNodeAssociations(encoding)); @@ -94,8 +92,7 @@ public class TaskGraphInstantiator<T extends TaskGraph> { instanceToAbstractNodeMap.get(abstractGraph); assert (nodeCorrespondenceMap != null); - Set<ITaskAdapter<?>> removeableVertices = - new HashSet<ITaskAdapter<?>>(); + Set<ITaskAdapter<?>> removeableVertices = new HashSet<ITaskAdapter<?>>(); for(Entry<ITaskAdapter<?>, ITaskAdapter<?>> instancePair : nodeCorrespondenceMap .entrySet()) { ITaskAdapter<?> instComp = instancePair.getKey(); @@ -119,10 +116,9 @@ public class TaskGraphInstantiator<T extends TaskGraph> { * Replaces the given {#link abstractNode} with the given {#link instanceNode} in the {#link * instanceTaskGraph}. */ - public void insertInstanceComponent(T instanceTaskGraph, - ITaskAdapter<?> abstractNode, + public void insertInstanceComponent(T instanceTaskGraph, ITaskAdapter<?> abstractNode, ITaskAdapter<?> instanceNode) { - ListenableDirectedWeightedGraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge> graph = + DefaultListenableGraph<ITaskAdapter<?>, ChannelAdapterWeightedEdge> graph = instanceTaskGraph.getGraph(); instanceTaskGraph.addTask(instanceNode, abstractNode); @@ -149,9 +145,8 @@ public class TaskGraphInstantiator<T extends TaskGraph> { * {@link ITaskAdapter} instantiating the "abstract" * {@link ITaskAdapter}. */ - private Map<ITaskAdapter<?>, ITaskAdapter<?>> - createAbstractInstantiatedNodeAssociations( - InstantiatedTaskMappingEncoding<? extends InstantiatedTaskMappingEntry> encoding) { + private Map<ITaskAdapter<?>, ITaskAdapter<?>> createAbstractInstantiatedNodeAssociations( + InstantiatedTaskMappingEncoding<? extends InstantiatedTaskMappingEntry> encoding) { Map<ITaskAdapter<?>, ITaskAdapter<?>> instanceToAbstractNodeMap = new HashMap<ITaskAdapter<?>, ITaskAdapter<?>>(); for(ITaskAdapter<?> instantiatedComponent : encoding.getRequesters()) { diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/.ratings b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/.ratings index 671bc5a5da9a26dfe662cb0bd0b8b63eb7c542ef..dd0d79534f91439185dbc9fadf2d1be1235dae5b 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/.ratings +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/.ratings @@ -1,3 +1,3 @@ -EDFSchedulerBase.java fdb939558fd2175e37da5d48c8a9e639bb68655a RED +EDFSchedulerBase.java 1efa9a6b03345476ee6187431e88b90b8abf19f8 RED FailSilentEDFScheduler.java 288d361bd44dc5fc6c88c7e0c9cf224da976a665 RED FaultDetectionVotingEDFScheduler.java 4cb56434b52ca84bf574e668ee4c67760495fa7e RED diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/EDFSchedulerBase.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/EDFSchedulerBase.java index d5bc75597544027eeafed02218232439d662b814..4b69319a0c52ceb22749567672cf3c059e4d2024 100644 --- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/EDFSchedulerBase.java +++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/EDFSchedulerBase.java @@ -29,6 +29,8 @@ import java.util.TreeSet; import org.apfloat.Apcomplex; import org.apfloat.Apfloat; +import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.partitionmapping.Partition; +import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.partitionmapping.PartitionMappingEncoding; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.InstantiatedAcyclicTaskGraphEncoding; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; @@ -36,8 +38,8 @@ import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.in import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEntry; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule; import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.TimeSlot; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; +import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.AcyclicTaskGraph; import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.ChannelAdapterWeightedEdge; @@ -97,8 +99,7 @@ public abstract class EDFSchedulerBase<S extends InstantiatedTaskMappingEntry, T * deadline. */ public SchedulingObject(SchedulingObjectComparator comparator, - ITaskAdapter<?> deployableComponent, double release, - double deadline) { + ITaskAdapter<?> deployableComponent, double release, double deadline) { this.comparator = comparator; this.deployableComponent = deployableComponent; this.release = release; @@ -273,7 +274,7 @@ public abstract class EDFSchedulerBase<S extends InstantiatedTaskMappingEntry, T int index = 0; TopologicalOrderIterator<ITaskAdapter<?>, ChannelAdapterWeightedEdge> iter = new TopologicalOrderIterator<ITaskAdapter<?>, ChannelAdapterWeightedEdge>( - taskGraph.getGraph()); + taskGraph.getDelegateGraph()); while(iter.hasNext()) { ITaskAdapter<?> deployableComponent = iter.next(); // create the instance of each hyper-period @@ -289,8 +290,7 @@ public abstract class EDFSchedulerBase<S extends InstantiatedTaskMappingEntry, T // add the predecessor list for(ChannelAdapterWeightedEdge edge : taskGraph.getGraph() .incomingEdgesOf(deployableComponent)) { - ITaskAdapter<?> sourceComponent = - taskGraph.getGraph().getEdgeSource(edge); + ITaskAdapter<?> sourceComponent = taskGraph.getGraph().getEdgeSource(edge); // look into the previous allocated scheduling objects for(SchedulingObject pred : localReleaseQueue) { if(pred.deployableComponent == sourceComponent) { @@ -327,8 +327,8 @@ public abstract class EDFSchedulerBase<S extends InstantiatedTaskMappingEntry, T * <li>the tasks within the task graph are scheduled according to topological order</li> * </ul> */ - public void schedule(InstantiatedAcyclicTaskGraphEncoding<S, ?> acycItgEnc, T taskMapping, - StrictTTSchedule<S, T> schedule) { + public void schedule(InstantiatedAcyclicTaskGraphEncoding<S, ?> acycItgEnc, + PartitionMappingEncoding partEnc, T taskMapping, StrictTTSchedule<S, T> schedule) { SortedSet<SchedulingObject> releaseQueue = createReleaseQueue(systemModelAdapter, acycItgEnc); // Create copy of release queue @@ -388,7 +388,7 @@ public abstract class EDFSchedulerBase<S extends InstantiatedTaskMappingEntry, T TaskGraph tgOfDeadlineTarget = systemModelAdapter.getAcyclicTaskGraph(targetDeployableComponent); Collection<ITaskAdapter<?>> deadlineTargetPredescessors = - Graphs.predecessorListOf(tgOfDeadlineTarget.getGraph(), + Graphs.predecessorListOf(tgOfDeadlineTarget.getDelegateGraph(), targetDeployableComponent); // TODO: Separate method to adjust readyQueue. @@ -409,8 +409,8 @@ public abstract class EDFSchedulerBase<S extends InstantiatedTaskMappingEntry, T // Pick first task in the ready queue... SchedulingObject schedulingObject = readyQueue.first(); // ...and schedule it - Apfloat finishTime = scheduleObject(schedulingObject, acycItgEnc, taskMapping, schedule, - currenttimes, mappingEntryToTimeSlot, generatedTimeSlots); + Apfloat finishTime = scheduleObject(schedulingObject, acycItgEnc, partEnc, taskMapping, + schedule, currenttimes, mappingEntryToTimeSlot, generatedTimeSlots); // Check if any successor becomes ready List<SchedulingObject> toBeRemoved = new ArrayList<SchedulingObject>(); @@ -432,7 +432,7 @@ public abstract class EDFSchedulerBase<S extends InstantiatedTaskMappingEntry, T } if(!releaseQueueLocal.isEmpty()) { for(SchedulingObject schObj : releaseQueueLocal) { - Double compPeriod = schObj.deployableComponent.getTimingRequirementPeriod(); + Double compPeriod = schObj.deployableComponent.getPeriod(); if(compPeriod != null) { throw new RuntimeException( "The Components " + releaseQueueLocal + " were not scheduled..."); @@ -446,8 +446,9 @@ public abstract class EDFSchedulerBase<S extends InstantiatedTaskMappingEntry, T /** Inserts a single {@link SchedulingObject} into the {@link StrictTTSchedule} */ private Apfloat scheduleObject(SchedulingObject schedulingObject, - InstantiatedAcyclicTaskGraphEncoding<S, ?> acycItgEnc, T encoding, - StrictTTSchedule<S, T> schedule, Map<IExecutionUnitAdapter<?>, Apfloat> currentTimeMap, + InstantiatedAcyclicTaskGraphEncoding<S, ?> acycItgEnc, PartitionMappingEncoding partEnc, + T encoding, StrictTTSchedule<S, T> schedule, + Map<IExecutionUnitAdapter<?>, Apfloat> currentTimeMap, Map<S, TimeSlot> mappingEntryToTimeSlot, Multimap<SchedulingObject, TimeSlot> generatedTimeSlots) { Collection<S> entries = encoding.getMappingEntriesOf(schedulingObject.deployableComponent); @@ -458,19 +459,22 @@ public abstract class EDFSchedulerBase<S extends InstantiatedTaskMappingEntry, T for(S entry : entries) { // TODO: Deprecate the use of the mapping entries together with the removal of the time // map. - IExecutionUnitAdapter<?> deploymentTarget = entry.getTarget(); - IExecutionUnitAdapter<?> hardwareDeploymentTarget = - (IExecutionUnitAdapter<?>)systemModelAdapter - .getHardwareResource(deploymentTarget); + Partition partition = entry.getTarget(); + // TODO: For now, we assume that partitions are allocated to single execution Units, + // e.g., cores. + // IExecutionUnitAdapter<?> hardwareTarget = + // (IExecutionUnitAdapter<?>)getFirst(partEnc.getAllocatedResourcesFor(partition)) + // .get(); // TODO: remove this obscure time map... - if(currentTimeMap.get(hardwareDeploymentTarget) == null) { - // First slot, set the time to 0 - currentTimeMap.put(hardwareDeploymentTarget, new Apfloat(0, DOUBLE_PRECISION)); + if(currentTimeMap.get(partition) == null) { + // // First slot, set the time to 0 + currentTimeMap.put(partition, new Apfloat(0, DOUBLE_PRECISION)); startTime = new Apfloat(0, DOUBLE_PRECISION); - } else { - startTime = currentTimeMap.get(hardwareDeploymentTarget); } + // } else { + startTime = currentTimeMap.get(partition); + // } // The start time should be no less than the ready time Apfloat readyTime = new Apfloat(schedulingObject.ready, DOUBLE_PRECISION); @@ -501,7 +505,7 @@ public abstract class EDFSchedulerBase<S extends InstantiatedTaskMappingEntry, T // Build time slot long iteration = java.lang.Math.round(schedulingObject.release / taskGraph.getPeriod()); iteration = iteration >= 0 ? iteration : 0; - TimeSlot deployableComponentSlot = schedule.createTimeSlot(entry, deploymentTarget, + TimeSlot deployableComponentSlot = schedule.createTimeSlot(entry, partition, predecessorSlots, startTime.floatValue(), deployableComponentEndTime.floatValue(), iteration); @@ -531,7 +535,7 @@ public abstract class EDFSchedulerBase<S extends InstantiatedTaskMappingEntry, T new Apfloat(deployableComponentSlot.getEndTime(), DOUBLE_PRECISION); // Book keeping - currentTimeMap.put(hardwareDeploymentTarget, deployableComponentEndTime); + currentTimeMap.put(partition, deployableComponentEndTime); generatedTimeSlots.put(schedulingObject, deployableComponentSlot); // Overall finish time of all replicas @@ -563,7 +567,7 @@ public abstract class EDFSchedulerBase<S extends InstantiatedTaskMappingEntry, T */ protected abstract Apfloat registerIncomingMessagesWithSchedule(T encoding, InstantiatedAcyclicTaskGraphEncoding<S, ?> acycItgEnc, StrictTTSchedule<S, T> schedule, - Map<S, TimeSlot> mappingEntryToTimeSlot, - ITaskAdapter<?> deployableComponent, Apfloat starttime, - IExecutionUnitAdapter<?> deploymentTarget, long iteration, TimeSlot slot); + Map<S, TimeSlot> mappingEntryToTimeSlot, ITaskAdapter<?> deployableComponent, + Apfloat starttime, IExecutionUnitAdapter<?> deploymentTarget, long iteration, + TimeSlot slot); }