diff --git a/org.fortiss.af3.exploration.alg/master/.classpath b/org.fortiss.af3.exploration.alg/master/.classpath deleted file mode 100644 index c8152f8c0ae977f4c1f78eb0a3cbcc2984442c64..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/.classpath +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="generated-src"/> - <classpathentry kind="lib" path="lib/jgrapht-core-0.9.0.jar" sourcepath="lib/jgrapht-0.9.0-src.jar"/> - <classpathentry kind="lib" path="lib/opt4j-operators-3.1.3.jar" sourcepath="lib/opt4j-source-3.1.3.jar"/> - <classpathentry exported="true" kind="lib" path="lib/aopalliance-1.0.jar"/> - <classpathentry exported="true" kind="lib" path="lib/apfloat.jar"/> - <classpathentry exported="true" kind="lib" path="lib/jgrapht-ext-0.9.0.jar"/> - <classpathentry exported="true" kind="lib" path="lib/jgraphx-2.0.0.1.jar"/> - <classpathentry kind="lib" path="lib/guice-assistedinject-4.0.jar" sourcepath="lib/guice-assistedinject-4.0-sources.jar"/> - <classpathentry kind="lib" path="lib/guice-4.0.jar" sourcepath="lib/guice-4.0-sources.jar"/> - <classpathentry kind="lib" path="lib/guice-multibindings-4.0.jar" sourcepath="lib/guice-multibindings-4.0-sources.jar"/> - <classpathentry exported="true" kind="lib" path="lib/commons-collections4-4.1.jar"/> - <classpathentry exported="true" kind="lib" path="lib/opt4j-optimizers-SNAPSHOT-20161110.jar" sourcepath="lib/opt4j-optimizers-SNAPSHOT-20161110-sources.jar"/> - <classpathentry exported="true" kind="lib" path="lib/guava-19.0.jar" sourcepath="lib/guava-19.0-sources.jar"/> - <classpathentry exported="true" kind="lib" path="lib/opt4j-core-3.1.3.jar"/> - <classpathentry kind="output" path="build"/> -</classpath> diff --git a/org.fortiss.af3.exploration.alg/master/.project b/org.fortiss.af3.exploration.alg/master/.project deleted file mode 100644 index ebe3b9ac2f9e362c58df3ac780ac453e2873e277..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/.project +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.fortiss.af3.exploration.alg</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.fortiss.ide.dev_tools.emf.builder.EcoreBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.fortiss.ide.dev_tools.warnings.RemoveWarningsBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - <nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature> - </natures> -</projectDescription> diff --git a/org.fortiss.af3.exploration.alg/master/.settings/edu.umd.cs.findbugs.core.prefs b/org.fortiss.af3.exploration.alg/master/.settings/edu.umd.cs.findbugs.core.prefs deleted file mode 100644 index a8e8fa5d205d5716edc958b2502058e02d9f87e5..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/.settings/edu.umd.cs.findbugs.core.prefs +++ /dev/null @@ -1,143 +0,0 @@ -#FindBugs User Preferences -#Tue Dec 13 13:57:04 CET 2016 -cloud_id=edu.umd.cs.findbugs.cloud.doNothingCloud -detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true -detectorAtomicityProblem=AtomicityProblem|true -detectorBadAppletConstructor=BadAppletConstructor|false -detectorBadResultSetAccess=BadResultSetAccess|true -detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true -detectorBadUseOfReturnValue=BadUseOfReturnValue|true -detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true -detectorBooleanReturnNull=BooleanReturnNull|true -detectorCallToUnsupportedMethod=CallToUnsupportedMethod|false -detectorCheckExpectedWarnings=CheckExpectedWarnings|false -detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true -detectorCheckRelaxingNullnessAnnotation=CheckRelaxingNullnessAnnotation|true -detectorCheckTypeQualifiers=CheckTypeQualifiers|true -detectorCloneIdiom=CloneIdiom|true -detectorComparatorIdiom=ComparatorIdiom|true -detectorConfusedInheritance=ConfusedInheritance|true -detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true -detectorCovariantArrayAssignment=CovariantArrayAssignment|false -detectorCrossSiteScripting=CrossSiteScripting|true -detectorDefaultEncodingDetector=DefaultEncodingDetector|true -detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true -detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true -detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true -detectorDontUseEnum=DontUseEnum|true -detectorDroppedException=DroppedException|true -detectorDumbMethodInvocations=DumbMethodInvocations|true -detectorDumbMethods=DumbMethods|true -detectorDuplicateBranches=DuplicateBranches|true -detectorEmptyZipFileEntry=EmptyZipFileEntry|false -detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true -detectorExplicitSerialization=ExplicitSerialization|true -detectorFinalizerNullsFields=FinalizerNullsFields|true -detectorFindBadCast2=FindBadCast2|true -detectorFindBadForLoop=FindBadForLoop|true -detectorFindCircularDependencies=FindCircularDependencies|false -detectorFindComparatorProblems=FindComparatorProblems|true -detectorFindDeadLocalStores=FindDeadLocalStores|true -detectorFindDoubleCheck=FindDoubleCheck|true -detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true -detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true -detectorFindFinalizeInvocations=FindFinalizeInvocations|true -detectorFindFloatEquality=FindFloatEquality|true -detectorFindHEmismatch=FindHEmismatch|true -detectorFindInconsistentSync2=FindInconsistentSync2|true -detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true -detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true -detectorFindMaskedFields=FindMaskedFields|true -detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true -detectorFindNakedNotify=FindNakedNotify|true -detectorFindNonShortCircuit=FindNonShortCircuit|true -detectorFindNullDeref=FindNullDeref|true -detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true -detectorFindOpenStream=FindOpenStream|true -detectorFindPuzzlers=FindPuzzlers|true -detectorFindRefComparison=FindRefComparison|true -detectorFindReturnRef=FindReturnRef|true -detectorFindRoughConstants=FindRoughConstants|true -detectorFindRunInvocations=FindRunInvocations|true -detectorFindSelfComparison=FindSelfComparison|true -detectorFindSelfComparison2=FindSelfComparison2|true -detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true -detectorFindSpinLoop=FindSpinLoop|true -detectorFindSqlInjection=FindSqlInjection|true -detectorFindTwoLockWait=FindTwoLockWait|true -detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true -detectorFindUnconditionalWait=FindUnconditionalWait|true -detectorFindUninitializedGet=FindUninitializedGet|true -detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true -detectorFindUnreleasedLock=FindUnreleasedLock|true -detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true -detectorFindUnsyncGet=FindUnsyncGet|true -detectorFindUseOfNonSerializableValue=FindUseOfNonSerializableValue|true -detectorFindUselessControlFlow=FindUselessControlFlow|true -detectorFindUselessObjects=FindUselessObjects|true -detectorFormatStringChecker=FormatStringChecker|true -detectorHugeSharedStringConstants=HugeSharedStringConstants|true -detectorIDivResultCastToDouble=IDivResultCastToDouble|true -detectorIncompatMask=IncompatMask|true -detectorInconsistentAnnotations=InconsistentAnnotations|true -detectorInefficientIndexOf=InefficientIndexOf|false -detectorInefficientInitializationInsideLoop=InefficientInitializationInsideLoop|false -detectorInefficientMemberAccess=InefficientMemberAccess|false -detectorInefficientToArray=InefficientToArray|false -detectorInfiniteLoop=InfiniteLoop|true -detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true -detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true -detectorInitializationChain=InitializationChain|true -detectorInitializeNonnullFieldsInConstructor=InitializeNonnullFieldsInConstructor|true -detectorInstantiateStaticClass=InstantiateStaticClass|true -detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true -detectorInvalidJUnitTest=InvalidJUnitTest|true -detectorIteratorIdioms=IteratorIdioms|true -detectorLazyInit=LazyInit|true -detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true -detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true -detectorMethodReturnCheck=MethodReturnCheck|true -detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true -detectorMutableEnum=MutableEnum|true -detectorMutableLock=MutableLock|true -detectorMutableStaticFields=MutableStaticFields|true -detectorNaming=Naming|true -detectorNoteUnconditionalParamDerefs=NoteUnconditionalParamDerefs|true -detectorNumberConstructor=NumberConstructor|true -detectorOptionalReturnNull=OptionalReturnNull|true -detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true -detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true -detectorPublicSemaphores=PublicSemaphores|false -detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true -detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true -detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true -detectorRedundantConditions=RedundantConditions|true -detectorRedundantInterfaces=RedundantInterfaces|true -detectorRepeatedConditionals=RepeatedConditionals|true -detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true -detectorSerializableIdiom=SerializableIdiom|true -detectorStartInConstructor=StartInConstructor|true -detectorStaticCalendarDetector=StaticCalendarDetector|true -detectorStringConcatenation=StringConcatenation|true -detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true -detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true -detectorSwitchFallthrough=SwitchFallthrough|true -detectorSynchronizationOnSharedBuiltinConstant=SynchronizationOnSharedBuiltinConstant|true -detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true -detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true -detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true -detectorURLProblems=URLProblems|true -detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true -detectorUnnecessaryMath=UnnecessaryMath|true -detectorUnreadFields=UnreadFields|true -detectorUselessSubclassMethod=UselessSubclassMethod|false -detectorVarArgsProblems=VarArgsProblems|true -detectorVolatileUsage=VolatileUsage|true -detectorWaitInLoop=WaitInLoop|true -detectorWrongMapIterator=WrongMapIterator|true -detectorXMLFactoryBypass=XMLFactoryBypass|true -detector_threshold=2 -effort=default -filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,MT_CORRECTNESS,PERFORMANCE,STYLE|false|15 -filter_settings_neg=MALICIOUS_CODE,SECURITY,EXPERIMENTAL,NOISE,I18N| -run_at_full_build=false diff --git a/org.fortiss.af3.exploration.alg/master/META-INF/MANIFEST.MF b/org.fortiss.af3.exploration.alg/master/META-INF/MANIFEST.MF deleted file mode 100644 index ee717b8d5db96743b79782935808114107f75ab1..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/META-INF/MANIFEST.MF +++ /dev/null @@ -1,186 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Exploration Algorithms -Bundle-SymbolicName: org.fortiss.af3.exploration.alg;singleton:=true -Bundle-Version: 2.11.0.qualifier -Bundle-ClassPath: ., - lib/jgrapht-core-0.9.0.jar, - lib/opt4j-operators-3.1.3.jar, - lib/aopalliance-1.0.jar, - lib/apfloat.jar, - lib/jgrapht-ext-0.9.0.jar, - lib/jgraphx-2.0.0.1.jar, - lib/guice-assistedinject-4.0.jar, - lib/guice-4.0.jar, - lib/guice-multibindings-4.0.jar, - lib/commons-collections4-4.1.jar, - lib/opt4j-optimizers-SNAPSHOT-20161110.jar, - lib/guava-19.0.jar, - lib/opt4j-core-3.1.3.jar -Bundle-Vendor: fortiss GmbH -Bundle-Localization: plugin -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Bundle-ActivationPolicy: lazy -Bundle-Activator: org.fortiss.af3.exploration.alg.ExplorationAlgActivator -Require-Bundle: org.fortiss.tooling.base.ui;visibility:=reexport, - org.fortiss.af3.safety;bundle-version="2.9.0";visibility:=reexport, - org.fortiss.tooling.kernel;visibility:=reexport, - org.fortiss.af3.schedule;visibility:=reexport, - org.eclipse.core.runtime, - org.eclipse.emf.ecore;visibility:=reexport, - org.fortiss.tooling.base;visibility:=reexport, - org.fortiss.af3.component;visibility:=reexport, - org.fortiss.af3.exploration;bundle-version="2.11.0";visibility:=reexport, - org.fortiss.af3.expression;visibility:=reexport, - org.fortiss.af3.platform;visibility:=reexport, - org.fortiss.af3.project;visibility:=reexport, - org.opt4j.core;resolution:=optional;visibility:=reexport, - org.opt4j.operators;resolution:=optional;visibility:=reexport, - org.opt4j.optimizers;resolution:=optional;visibility:=reexport -Export-Package: com.google.common.annotations, - com.google.common.base, - com.google.common.base.internal, - com.google.common.cache, - com.google.common.collect, - com.google.common.escape, - com.google.common.eventbus, - com.google.common.hash, - com.google.common.html, - com.google.common.io, - com.google.common.math, - com.google.common.net, - com.google.common.primitives, - com.google.common.reflect, - com.google.common.util.concurrent, - com.google.common.xml, - com.google.thirdparty.publicsuffix, - org.fortiss.af3.exploration.alg, - org.fortiss.af3.exploration.alg.contribution, - org.fortiss.af3.exploration.alg.dse, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.comm, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.repair, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution, - org.fortiss.af3.exploration.alg.dse.evaluator; - uses:="org.fortiss.af3.exploration.alg.dse.sysmodel.arch, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype, - org.fortiss.af3.exploration.model, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate, - org.opt4j.core", - org.fortiss.af3.exploration.alg.dse.evaluator.constraint; - uses:="org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution, - org.fortiss.af3.exploration.alg.dse.modeltransformation, - org.fortiss.af3.exploration.alg.dse.sysmodel.arch, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype, - eu.dreamsproject.ikerlan.safetystandards.SafetyCompliance, - org.fortiss.af3.exploration.model, - org.fortiss.af3.exploration.alg.dse.evaluator", - org.fortiss.af3.exploration.alg.dse.evaluator.objective; - uses:="org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution, - org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph, - org.apfloat, - org.fortiss.af3.exploration.alg.dse.sysmodel.arch, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype, - org.fortiss.af3.exploration.model, - org.fortiss.af3.exploration.alg.dse.evaluator", - org.fortiss.af3.exploration.alg.dse.modeltransformation, - org.fortiss.af3.exploration.alg.dse.modeltransformation.base, - org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch, - org.fortiss.af3.exploration.alg.dse.modeltransformation.deployment, - org.fortiss.af3.exploration.alg.dse.modeltransformation.element, - org.fortiss.af3.exploration.alg.dse.sysmodel, - org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - uses:="org.eclipse.emf.ecore, - org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph, - org.eclipse.emf.common.util, - org.jgrapht", - org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - uses:="org.fortiss.tooling.base.model.element, - eu.dreamsproject.application.model.annotation, - org.fortiss.af3.component.model, - org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph, - org.eclipse.emf.common.util, - org.fortiss.af3.timing.model.annotation, - org.fortiss.af3.exploration.alg.dse.sysmodel.arch, - org.fortiss.af3.platform.model, - eu.dreamsproject.platform.model.annotation", - org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3.helper, - org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph, - org.fortiss.af3.exploration.alg.dse.sysmodel.comm; - uses:="org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping, - org.fortiss.af3.exploration.alg.dse.sysmodel.arch, - org.fortiss.af3.exploration.alg.dse.sysmodel.mapping, - org.jgrapht", - org.fortiss.af3.exploration.alg.dse.sysmodel.faultmodel, - org.fortiss.af3.exploration.alg.dse.sysmodel.mapping;uses:="org.fortiss.af3.exploration.alg.dse.sysmodel.arch", - org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.comm, - org.fortiss.af3.exploration.alg.dse.sysmodel.random, - org.fortiss.af3.exploration.alg.dse.sysmodel.sched;uses:="org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution,org.fortiss.af3.exploration.alg.dse.sysmodel.arch,org.fortiss.af3.exploration.model", - org.fortiss.af3.exploration.alg.dse.sysmodel.sched.comm; - uses:="org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution, - org.fortiss.af3.exploration.alg.dse.sysmodel.sched, - org.fortiss.af3.exploration.alg.dse.sysmodel.arch, - org.fortiss.af3.exploration.model, - org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.comm", - org.fortiss.af3.exploration.alg.dse.sysmodel.sched.proc; - uses:="org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping, - org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping, - org.apfloat, - org.fortiss.af3.exploration.alg.dse.sysmodel.sched, - org.fortiss.af3.exploration.alg.dse.sysmodel.arch, - org.fortiss.af3.exploration.model", - org.fortiss.af3.exploration.alg.exception, - org.fortiss.af3.exploration.alg.guava, - org.fortiss.af3.exploration.alg.service, - org.fortiss.af3.exploration.alg.util, - org.fortiss.af3.exploration.dsl.model, - org.fortiss.af3.exploration.dsl.model.expressions, - org.fortiss.af3.exploration.dsl.model.expressions.impl, - org.fortiss.af3.exploration.dsl.model.expressions.util, - org.fortiss.af3.exploration.dsl.model.impl, - org.fortiss.af3.exploration.dsl.model.operators, - org.fortiss.af3.exploration.dsl.model.operators.impl, - org.fortiss.af3.exploration.dsl.model.operators.util, - org.fortiss.af3.exploration.dsl.model.patterns, - org.fortiss.af3.exploration.dsl.model.patterns.impl, - org.fortiss.af3.exploration.dsl.model.patterns.util, - org.fortiss.af3.exploration.dsl.model.types, - org.fortiss.af3.exploration.dsl.model.types.impl, - org.fortiss.af3.exploration.dsl.model.types.util, - org.fortiss.af3.exploration.dsl.model.util, - org.fortiss.af3.exploration.model, - org.fortiss.af3.exploration.model.impl, - org.fortiss.af3.exploration.model.location, - org.fortiss.af3.exploration.model.location.impl, - org.fortiss.af3.exploration.model.location.util, - org.fortiss.af3.exploration.model.time, - org.fortiss.af3.exploration.model.time.impl, - org.fortiss.af3.exploration.model.time.util, - org.fortiss.af3.exploration.model.util, - org.fortiss.af3.exploration.moea.model, - org.fortiss.af3.exploration.moea.model.annotation, - org.fortiss.af3.exploration.moea.model.annotation.impl, - org.fortiss.af3.exploration.moea.model.annotation.util, - org.fortiss.af3.exploration.moea.model.feature, - org.fortiss.af3.exploration.moea.model.feature.impl, - org.fortiss.af3.exploration.moea.model.feature.util, - org.fortiss.af3.exploration.moea.model.impl, - org.fortiss.af3.exploration.moea.model.parameters, - org.fortiss.af3.exploration.moea.model.parameters.impl, - org.fortiss.af3.exploration.moea.model.parameters.util, - org.fortiss.af3.exploration.moea.model.predefined, - org.fortiss.af3.exploration.moea.model.predefined.impl, - org.fortiss.af3.exploration.moea.model.predefined.util, - org.fortiss.af3.exploration.moea.model.solutions, - org.fortiss.af3.exploration.moea.model.solutions.impl, - org.fortiss.af3.exploration.moea.model.solutions.util, - org.fortiss.af3.exploration.moea.model.util, - org.fortiss.af3.exploration.port, - org.fortiss.af3.exploration.util diff --git a/org.fortiss.af3.exploration.alg/master/build.properties b/org.fortiss.af3.exploration.alg/master/build.properties deleted file mode 100644 index d52b576df69084c35b14057b6b580329d0823789..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/build.properties +++ /dev/null @@ -1,28 +0,0 @@ -# <copyright> -# </copyright> -# -# $Id: build.properties 3885 2016-11-11 09:41:01Z diewald $ - -bin.includes = .,\ - META-INF/,\ - plugin.xml,\ - plugin.properties,\ - lib/aopalliance-1.0.jar,\ - lib/apfloat.jar,\ - lib/jgrapht-core-0.9.0.jar,\ - lib/licenses/,\ - lib/opt4j-operators-3.1.3.jar,\ - lib/opt4j-satdecoding-3.1.3.jar,\ - lib/opt4j-viewer-3.1.3.jar,\ - lib/jgrapht-ext-0.9.0.jar,\ - lib/jgraphx-2.0.0.1.jar,\ - lib/guice-assistedinject-4.0.jar,\ - lib/guice-4.0.jar,\ - lib/guice-multibindings-4.0.jar,\ - lib/commons-collections4-4.1.jar,\ - lib/opt4j-optimizers-SNAPSHOT-20161110.jar,\ - lib/guava-19.0.jar,\ - lib/opt4j-core-3.1.3.jar -source.. = src/, \ - generated-src -output.. = build/ diff --git a/org.fortiss.af3.exploration.alg/master/changelog_exploration-alg_old.txt b/org.fortiss.af3.exploration.alg/master/changelog_exploration-alg_old.txt deleted file mode 100644 index d2a57f5e262a84dadb7337ef625e239bd6e00e19..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/changelog_exploration-alg_old.txt +++ /dev/null @@ -1,1928 +0,0 @@ -r3970 | barner | 2017-01-16 10:18:28 MEZ - -- DreamsPlatformUtils:seekInterPlatformConnectors(): Throw InvalidPlatformModelException instead of generic java.lang.Exception ----------------------------------------------------------------------------- -r3966 | diewald | 2016-12-20 17:04:54 MEZ - -Remove the dynamic name calculation from the VirtualLinks. - -For DREAMS, use the existing mechanism to calculate the names when generating the Virtual Links. ----------------------------------------------------------------------------- -r3964 | diewald | 2016-12-12 13:55:09 MEZ - -Move LambdaUtils from org.fortiss.af3.exploration.alg to org.fortiss.tooling common. -refs 2779 - ----------------------------------------------------------------------------- -r3945 | diewald | 2016-11-24 14:24:33 MEZ - -Improve the safety constraint transformation. - -- Create allocation constraints for safety relevant components to all safety relevant partitions. -- Existing direct allocation constraints defined for safety-relevant components superseed these constraints. ----------------------------------------------------------------------------- -r3927 | diewald | 2016-11-15 18:07:15 MEZ - -More reliable DSE: increase population size & fix sf penalty function. ----------------------------------------------------------------------------- -r3895 | diewald | 2016-11-11 18:03:50 MEZ - -Fix VL generation from the DSE: null logical Partition ports fixed. ----------------------------------------------------------------------------- -r3888 | diewald | 2016-11-11 12:56:13 MEZ - -Optimize the fix to random allocation ratio. ----------------------------------------------------------------------------- -r3885 | diewald | 2016-11-11 10:41:01 MEZ - -(More) Reliably generate solutions for each run of the DSE. - -- Fix operators not being called for non-repaired genotypes. -- Fix the copy operation in Opt4J for CompositeGenotypes. -- Increase the Population and offspring size. -- Ensure consistency between the InternalIsolatedCommunicationSet constraints and the AbstractTaskMappingEncodings. -- Several fixes in operators. -- Make the call to the SafetyConstraintChecker more robust. -- Add a static debug routing to check consistency between InternalIsolatedCommunicationSet constraints and the AbstractTaskMappingEncodings' allocation map. ----------------------------------------------------------------------------- -r3881 | barner | 2016-11-10 14:20:43 MEZ - -- Set fix to random ratio to 0.5 ----------------------------------------------------------------------------- -r3879 | diewald | 2016-11-10 11:33:35 MEZ - -Fixup the period constraint handling. ----------------------------------------------------------------------------- -r3878 | diewald | 2016-11-10 10:53:30 MEZ - -Robustness improvements. ----------------------------------------------------------------------------- -r3877 | diewald | 2016-11-10 10:35:28 MEZ - -Fix & re-enable the repair operation. ----------------------------------------------------------------------------- -r3875 | diewald | 2016-11-09 17:18:09 MEZ - -Clean implementation of the constraint transformation interface. - -- Provide a real eclipse extension point for constraint transformation modules. -- Add the IExplorationConstraintTransformationService. -- Add a new utility method that provides easy to use type-based filtering of collections of elements that are generics (returned collection). -- Cleanup. ----------------------------------------------------------------------------- -r3869 | diewald | 2016-11-09 13:45:29 MEZ - -Fixup subsequent model exports from the DSE. ----------------------------------------------------------------------------- -r3867 | diewald | 2016-11-09 13:18:17 MEZ - -VL Generation: Re-add allocation to prevent overwriting of existing transceiver port allocations. ----------------------------------------------------------------------------- -r3857 | diewald | 2016-11-08 09:21:57 MEZ - -Fix the execution order calculation of IElementTransformationMudules. - -- Eliminate the use of the dependency graph for the execution order calculation. -- Correctly implement the order Comparator. ----------------------------------------------------------------------------- -r3856 | diewald | 2016-11-07 16:42:57 MEZ - -Fix timing model generation: ensure correct ordering of transformation modules. ----------------------------------------------------------------------------- -r3852 | diewald | 2016-11-07 13:22:38 MEZ - -Fix VL generation: Too many messages were removed in the MessageDecoder. ----------------------------------------------------------------------------- -r3851 | diewald | 2016-11-07 11:08:11 MEZ - -Use the compositor service to add transformed models from the DSE. ----------------------------------------------------------------------------- -r3850 | diewald | 2016-11-07 10:56:50 MEZ - -Fix VL generation from the DSE. - -- Allow messages from non-isolated communication participants to all isolated components. ----------------------------------------------------------------------------- -r3841 | diewald | 2016-11-04 15:51:29 MEZ - -Fix messages/VLs to avoid unneeded messages & respect safety channels (part2 of 2). - -- Introduce the DSE-internal InternalIsolatedCommunicationSet constraint to denote sets of IMappingEntries that may only communicate with entries from the same set or entries not contained in any other InternalIsolatedCommunicationSet. -- Adjust the relevant decoders to respect InternalIsolatedCommunicationSet constraints (especially the message relevant ones). -- Adjust the ComponentArchitecture Transformation Modules to respect InternalIsolatedCommunicationSet constraints for the channels between components. -- Correct the VirtualLink Transformation Module to select the correct logical receiver ports for replicated components. -- Do not save the generated SafetyCompliance model directly after exporting. ----------------------------------------------------------------------------- -r3837 | diewald | 2016-11-03 13:11:54 MEZ - -Cleanup & refactoring. ----------------------------------------------------------------------------- -r3826 | diewald | 2016-11-03 12:06:37 MEZ - -Fix messages/VLs to avoid unneeded messages & respect safety channels (part1). - -- MessageDecoder: Remove unneeded receiver resources after the message generation. -- MessageDecoder: Remove unneeded messages if no more receiver resources exist. -- MessageDecoder: Execute the MessageRouting on the possibly reduced set of generated Messages. -- Add some not yet used code that will become relevant after reworking the message scheduler. -- Add a utility method to ease and shorten mapping operations. ----------------------------------------------------------------------------- -r3823 | diewald | 2016-11-03 09:18:47 MEZ - -Fix NPE: Partial revert: Add more component -> generated component associations to the genToGentAssocMap. ----------------------------------------------------------------------------- -r3821 | diewald | 2016-11-02 17:59:28 MEZ - -Correct the replication of EventChains. - -- Add a mechanism to detect the top-most EventChain that requires replication -> Do not replicate Sub-EventChains separately. -- Use a path walk algorithm to identify the required Event references for sub chains. ----------------------------------------------------------------------------- -r3810 | diewald | 2016-11-02 10:32:55 MEZ - -Style: replace with static import. ----------------------------------------------------------------------------- -r3809 | diewald | 2016-11-02 10:31:02 MEZ - -Fix missing references of timing constraints to their corresponding Events. - -Replicated timing constraints were not registered at the association maps such that timing constraints of replicated and instantiated Events were set to NULL during the instantiation. ----------------------------------------------------------------------------- -r3808 | diewald | 2016-11-02 09:51:03 MEZ - -Reuse the replication number suffix for instantiated components. ----------------------------------------------------------------------------- -r3807 | diewald | 2016-11-01 19:56:50 MEZ - -Fix the replication of ports for connect non-safety component ports. ----------------------------------------------------------------------------- -r3804 | diewald | 2016-10-28 17:30:35 MESZ - -WIP: Add the safety port replication module. ----------------------------------------------------------------------------- -r3801 | barner | 2016-10-28 15:45:32 MESZ - -- Fix build -- TODO: org.tooling.base.ui is needed to disable annotation view ----------------------------------------------------------------------------- -r3800 | diewald | 2016-10-28 15:30:33 MESZ - -Readd the safety channel separation in the instantiated acyclic task graph generation. ----------------------------------------------------------------------------- -r3797 | diewald | 2016-10-28 13:14:06 MESZ - -- Encodings: Extend the ComposableGentoype and ComposablePhentoype interface such that implementing classes declare their registration type for the containing CompositeGenotype/-Phenotype. -- Extend the IAssociatedElement interface: Add required operations. -- Introduce a reference Map in the TaskMappingEncoding to track associations between mapping entries. -- Proxy interactions with the allocation table of the TaskMappingEncoding to consider associations between mapping entries. -- Remove the creation of additional lists when returning values from the allocation table of the TaskMappingEncoding. -- Correctly implement the update mechanism for InstantiatedTaskMappingDecoders: - - Update the existing mapping, instead of creating a new one: entry objects are now correctly preserved. - - TaskMappingEntry: allow resetting the allocation target reference. -- Creators: Improve the consideration of hybrid genotypes. -- Correct the setting of encoding entry -> Component association during the ComponentArchitecture Generation. - ----------------------------------------------------------------------------- -r3788 | barner | 2016-10-27 10:23:59 MESZ - -- Move eu.dreamsproject.deployment.ui.util.VirtualLinkUtils to org.fortiss.af3.exploration.alg.util.VirtualLinkUtils -- Adjust to retirement of org.fortiss.af3.exploration.ui.util.ExplorationUiUtils - (methods that are still relevant have been moved to org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils) ----------------------------------------------------------------------------- -r3786 | diewald | 2016-10-27 09:18:45 MESZ - -Disable the automatic VL generation for now. ----------------------------------------------------------------------------- -r3785 | diewald | 2016-10-27 09:06:35 MESZ - -Fix NPE: Disable repair module for now. ----------------------------------------------------------------------------- -r3783 | diewald | 2016-10-26 18:42:45 MESZ - -Fix bug in message scheduling / message generation. - -- Correctly generate messages for instantiated components: Search for the correct components in the instantiated task mapping encoding. -- Some more util classes. -- Debug Code. -- Base the InstantitedAcyclicTaskGraphDecoder on the InstantiatedTaskGraph instead of the AbstractAcyclicTaskGraphEncoding. ----------------------------------------------------------------------------- -r3770 | diewald | 2016-10-25 15:50:28 MESZ - -Improve the implementation of the repair interface by providing a service. - -- Create an extension point that allows to register IRepairModules for Genotypes. -- Add a mechanism to automatically call the registered IRepairModules for Genotypes. -- Modify the repair operation for violated safety constraints to use the new mechanism. ----------------------------------------------------------------------------- -r3753 | diewald | 2016-10-24 11:16:46 MESZ - -Fix the VirtualLink Generation when exporting Deployments from the DSE. - -- Correctly update the association maps in the ComponentArchitectureInstatiator module. -- Fix the model retrieval for the generated Deployment: prefer the transformed Deployment. -- Fix the port retrieval in the VL generation. ----------------------------------------------------------------------------- -r3747 | diewald | 2016-10-21 16:10:16 MESZ - -Improve the implementation of internal constraints. - -- Introduce a mechanism in the exploration process that allows to generate constraints on encodings during the exploration. -- (Temporally) introduce "internal" constraints: Replication and separation constraints. -- Correct the dependency graph implementation to allow multiple decoders that use the same in- and outputs. -- Add Apache commons library v4. ----------------------------------------------------------------------------- -r3730 | diewald | 2016-10-19 17:43:43 MESZ - -Automatic model transformation for evaluators. - -- The CompositeEvaluatorBase queries the IExplorationTransformationService to provide the models demanded by the registered evaluators. -- Extend the IExplorationEvaluationService to allow querying the required models for a given set of evaluators. -- Introduce the SubClassToInstanceMultimap that is a multimap and has types as keys. Keys are searched up to a defined bound it the map does not directly contain the demanded key. -- Add a mechanism to the system model adapter that allows to register and retrieve the original input models. -- Test case: Use the IExplorationEvaluationService for the SafetyComplianceConstraint: - - Eliminate the model transformations implemented directly in the evaluator. - - Remove the create methods for the energy objective and the safety compliance constraint from the factories. - ----------------------------------------------------------------------------- -r3715 | diewald | 2016-10-17 16:19:07 MESZ - -Fix the file extension of generated timing models. ----------------------------------------------------------------------------- -r3714 | diewald | 2016-10-17 15:51:34 MESZ - -Increase DSE efficiency: During creation phase, only use actually allowed safety architectures --> Previously, some invalid architectures were generated that were sorted out during the optimization. ----------------------------------------------------------------------------- -r3713 | diewald | 2016-10-17 10:51:50 MESZ - -Replicate the TimingProject instead of the TimingDescription and store it in a separate Resource to avoid breaking the assumption to have one TimingDescription per TimingProject. ----------------------------------------------------------------------------- -r3702 | barner | 2016-10-14 14:30:04 MESZ - -- Sort messages by sending OutputPort before generating virtual links -- Remove VirtualLinkTreeComparator that is no longer required, since passing a sorted input set to the VL generator now ensures that VLs are always generated in the same order on subsequent runs. -- Note that the recently introduced naming of PartitionsPorts (VL_x_...) canceled the effect the sorting of VLs in the editor (i.e., without sorting the messages before assigning a VLID the display order would again depend on the (random) order of the initial message set). ----------------------------------------------------------------------------- -r3687 | barner | 2016-10-13 10:28:33 MESZ - -- Remove unused createVirtualLink* methods from DreamsPsmModelElementFactory -- Move currently used set of create* methods from MessagesToVirtualLinks to DreamsPsmModelElementFactory ----------------------------------------------------------------------------- -r3685 | diewald | 2016-10-12 17:50:39 MESZ - -Instantiate components in the 100% safety compliance model. - -- Add helper methods to the SafetyCompliance model transformator to: - - instantiate abstract safety components, - - and reference the instantiated components by the safety functions. -- Allow passing multiple model types to the Transformation service such multiple transformed models can be requested at the same time. -- Remove inter-safety channel signals (first prototype) from the instantiated task graph to ensure separation. ----------------------------------------------------------------------------- -r3676 | diewald | 2016-10-10 15:26:57 MESZ - -Code cleanup & comment out debug windows for the dependency graph. ----------------------------------------------------------------------------- -r3671 | diewald | 2016-10-06 17:08:34 MESZ - -Correct the cleaning of the genToGenAssocMap in the TransformationStrategy. - -The genToGenAssocMap contains associations between model elements on the input side of a transformation stage and the model elements of the output side. Thereby, the processing stage is not considered a stage. Previously, this map was cleared in one of the submodules. This change correctly implements the clearing mechanism on every relevant stage change in a TransformationStrategy module. ----------------------------------------------------------------------------- -r3670 | diewald | 2016-10-06 16:49:26 MESZ - -Remove outdated TODO and FIXME. ----------------------------------------------------------------------------- -r3669 | diewald | 2016-10-06 16:47:36 MESZ - -Remove the BiTable as it is conceptually broken. - -The inverse mapping overrides existing row entries. Use the TypedBiMap instead. ----------------------------------------------------------------------------- -r3668 | diewald | 2016-10-06 16:16:16 MESZ - -Fix the crossover operation & wrong associations between mapping entries. - -- Each crossover operation performed by opt4j now operates on copies of the parent's genotypes instead of the parent's genotypes (as it is expected): Fixed Opt4J & updated lib. -- Replace the association HashSet of TaskMappingEntries with a ClassToInstanceMap such that only associated Element per type is allowed. -- Change the clone method of TaskMappingEntrys such that the association between mapping entries is not cloned (which was erroneous in prev. revisions). ----------------------------------------------------------------------------- -r3664 | barner | 2016-10-06 14:13:07 MESZ - -- Fix typo: platfrom -> platform ----------------------------------------------------------------------------- -r3660 | barner | 2016-10-06 12:54:00 MESZ - -- Add context menu entry to virtual link tree viewer that allows to update transceiver ports (currently: partition and onchip NI ports) ----------------------------------------------------------------------------- -r3657 | diewald | 2016-10-06 12:08:54 MESZ - -Fix inconsistent allocation if temporal replication occurs. - -Due to the use of HashMultimap as the allocation map, the collection for values is backed by a set. If one component is allocated twice or more to the same execution unit, only one entry would be allocated. This is solved by using ListMultimap backed by a ArrayListMultimap. ----------------------------------------------------------------------------- -r3654 | barner | 2016-10-05 17:47:05 MESZ - -- VL generator: assign names to OnChipNetworkInterfacePorts assigned to onchip network interfaces (copies name of corresponding partition port) ----------------------------------------------------------------------------- -r3651 | diewald | 2016-10-05 17:27:30 MESZ - -Fix the instantiation of (Timing)Events. - -- Add more logic to the TimingEvent*Modules (esp. TimingEventReplicationModule) to handle different types of model elements more consistently. -- Improve the usage of the association maps. ----------------------------------------------------------------------------- -r3650 | barner | 2016-10-05 16:43:24 MESZ - -- Remove debug code ----------------------------------------------------------------------------- -r3649 | diewald | 2016-10-05 14:15:45 MESZ - -Add the transformation code for the timing constraint replication. - -- The implementation is almost identical to the replication of event chains (see TimingChainReplicationModule). ----------------------------------------------------------------------------- -r3647 | diewald | 2016-10-05 11:27:57 MESZ - -Correct the addition of replicated event chains to their containers. - -- Dynamically determine the container by its type. -- The container can be either a TimingChainFolder or another EventChain. ----------------------------------------------------------------------------- -r3642 | diewald | 2016-10-05 09:34:14 MESZ - -- Introduce the TypedBiMap and HashTypedBiMap: - - Both keys and values are Pairs of objects and its type. - - It allows to reference the same value from multiple keys iff they have different types: - The BiMap property of broviding an equivalent inverse view is thereby preserved. - - The backend uses a Bimap that correlates the types. -- ITransformationModule(s): Introduce the genToGenAssocMap that associates associates in- and output generated elements within one transformationstate. -- Replace the uses of the StandardBiTable with the TypedBiMap since the StandardBiTable did provide a correct inverse view (as expected). -- For IElementTransformationStrategies: Order the sub modules not only by their activation state, but also by their required in- and output elements (element-wise). -- Update the dependency graph such that one DependencyEdge may represent multiple decoders. Needed for the element-wise transformators. -- Add a utility method to allow a redirection of EventAnnotations. ----------------------------------------------------------------------------- -r3601 | diewald | 2016-09-28 10:01:16 MESZ - -Extract the getReplicatedElements method to a static utility method that allows to identify replicated Events. ----------------------------------------------------------------------------- -r3600 | diewald | 2016-09-28 09:49:49 MESZ - -Add nop transformation modules for the replication of EventChains and TimingConstraints. ----------------------------------------------------------------------------- -r3596 | diewald | 2016-09-27 17:57:30 MESZ - -- Reflect the removal of model elements in event chains: - - Remove non-needed event chains. - - Reconnect event chains such that the complete chain is connected althouh event chains in between are removed. -- Only update model element <-> encoding entry associations if for events that actually correspond to an encoding entry. - ----------------------------------------------------------------------------- -r3561 | diewald | 2016-09-23 16:22:56 MESZ - -Use the SubClassToInstanceMap also for the transformed models in the modular transformation framework. ----------------------------------------------------------------------------- -r3560 | diewald | 2016-09-23 16:13:46 MESZ - -Generalize the associations between entries of encodings in the DSE process. - -- Introduce an IAssociativeElement interface to encapsulate the association operations. -- Introduce a StandardAssociativeBitable that update associated elements if it is changed (i.e., put/remove operations). -- Introduce a HashTable-based AssociativeBiTable. ----------------------------------------------------------------------------- -r3554 | diewald | 2016-09-23 15:06:05 MESZ - -Fix the automatic generation of Virtual Links in the modular transformation: Also consider the already transformed models when optional modules search for its inputs. ----------------------------------------------------------------------------- -r3551 | diewald | 2016-09-23 14:28:32 MESZ ----------------------------------------------------------------------------- -r3549 | diewald | 2016-09-23 13:25:12 MESZ - -Correct the implementation of the BiTable. - -- The StandardBiTable is now a wrapper class around the StandardTable, since guava does not allow subclassing. -- Moved the BiTable classes into org.fortiss.exploration.alg.guava. -- Adjusted the transformator modules to use the BiTable. ----------------------------------------------------------------------------- -r3547 | diewald | 2016-09-22 18:14:03 MESZ - -Add several support classes for the DSE process and the modular transformation framework. - -The basic idea is to better encapsulate the data structures that are used in the DSE process and the modular transformation framework to avoid inconsistent data structure. Since the used data structures are based on Guava, the implementation of the support classes is oriented at this library. ----------------------------------------------------------------------------- -r3546 | diewald | 2016-09-22 14:07:47 MESZ - -Fix the export of the deployment parameter table for exported deployments. ----------------------------------------------------------------------------- -r3543 | diewald | 2016-09-22 13:23:13 MESZ - -Add an export mechanism for 100% safety compliance models. - -- Add a mechanism to the SafetyComplianceModelTransformator to save the generated 100% model as a resource. -- Add a dialog & support code that allows to trigger the export of a generated safety compliance model when a deployment model is exported. ----------------------------------------------------------------------------- -r3541 | diewald | 2016-09-22 10:14:54 MESZ - -Move the 125% --> 100% safety compliance specification transformation from the safety compliance evaluator into a transformation strategy module. ----------------------------------------------------------------------------- -r3539 | diewald | 2016-09-21 16:49:40 MESZ - -Fix the transformation of TimingDescriptions. - -- Use a Table (guava) implementation for the encoding entry <-> model element associations in the transformation to allow referencing multiple model elements of different types. -- Correct the dependencies of some Transformation Modules. -- Initialize the encoding entry <-> model element associations already in the corresponding transformation modules. -- Spelling & minor bug fixes. ----------------------------------------------------------------------------- -r3530 | diewald | 2016-09-20 14:09:36 MESZ - -Bug Fix: Partially missing separation of safety components. - -- Inject the generated ComponentArchitecture of a generated Deployment to the generated SafetyCompoliance model which is passed to the checker. -- Associate mapping entries denoting replicas with the replicated components in the model transformation such that the generated deployment is complete. ----------------------------------------------------------------------------- -r3507 | barner | 2016-09-15 13:56:56 MESZ ----------------------------------------------------------------------------- -r3491 | diewald | 2016-09-13 15:18:06 MESZ - -Add documentation for the parameters of two functions. ----------------------------------------------------------------------------- -r3490 | diewald | 2016-09-13 13:39:58 MESZ - -Fix the element-wise transformation. - -- Do not iterate over all states in ITRansformationStrategies, only in ElememtTransformationStrategyBase sub-modules. -- Correct the placement of the transformed models in the transformed model map. ----------------------------------------------------------------------------- -r3487 | diewald | 2016-09-12 15:36:31 MESZ - -Bug Fix: The FileProject to inject models sometimes failed if a "base model" passed to the transformation service was not injected to the file project. ----------------------------------------------------------------------------- -r3486 | diewald | 2016-09-12 14:56:24 MESZ - -- Use the new utility method in org.fortiss.exploration.ui to create the error message if the VL generation fails: stack traces are now shown. -- Erroneous catching of Exceptions fixed during model transformation. ----------------------------------------------------------------------------- -r3483 | diewald | 2016-09-09 18:41:40 MESZ - -[WIP] Operational element-wise transformation framework. - -- Remove deprecated Dreamstiming transformation module and its interface classes. -- Specify the output type via of element wise transformation via a generic. -- Element modules directly inject their generated objects into the transformed model. -- Also launch "normal" transformation modules which are sub modules of IElementTransformationStrategy(s). -- Cleanup. - -TODO: -- Only few references are actually set in the generated TimingDescription. This behaviour must be corrected. Currently, the resulting TimingDescription is not valid. ----------------------------------------------------------------------------- -r3480 | diewald | 2016-09-09 15:31:04 MESZ - -Introduce the ExplorationException as the super class of all Exception thrown by the DSE. - -- Create the class ExplorationException and let others inherit from it. -- Extend the DecodingException constructors to take an additional exception. ----------------------------------------------------------------------------- -r3479 | diewald | 2016-09-09 12:00:05 MESZ - -Switch the default behaviour of the random number generator to provide more randomness. ----------------------------------------------------------------------------- -r3478 | diewald | 2016-09-09 11:54:32 MESZ - -Bug-Fix inconsistency in allocation entries of the taskmapping w.r.t. the number of safety channels of a safety function. - -- The Composite create phase has a much improved decoding handling to generate correct encodings from the beginning: - - Consistency is between encodings is now ensured instead of requiring the decoding phase. - - All registered decoders of all subdecoders are now launched after each generated genotype to handle previously missing dependencies. - - Identity decoders are directly launched after the creation of the correps. genotype. -- The CrossoverAllocation operation now only swaps as many allocation entries as the smaller entry set has. This avoids swapping the number of replicas between Component entries causing an inconsistency between the SafetyArchitectureEncoding and the TaskMappongEncoding. -- Added some markers where to implement consistency checks. -- Fixed several bugs in the Timing Event model transformation. -- Introduction of the debug utility class. -- Misc. other bug fixes. ----------------------------------------------------------------------------- -r3462 | barner | 2016-09-06 10:33:17 MESZ - -- Use assert() to guarantee that random generator wrapper has been initialized before use, i.e. avoid to return default value in that case ----------------------------------------------------------------------------- -r3461 | diewald | 2016-09-06 09:53:19 MESZ - -Reintegrate the DREAMS timing initializer that creates a copy of an existing timing description that is further processed in the model transformation. ----------------------------------------------------------------------------- -r3460 | diewald | 2016-09-06 09:39:58 MESZ - -Re-integrate the event replication transformation module. ----------------------------------------------------------------------------- -r3459 | diewald | 2016-09-06 09:17:50 MESZ - -Only launch the TimingEventInstantiationModule if instantiation is indicated by the IDeployableComponentAdapters. ----------------------------------------------------------------------------- -r3458 | diewald | 2016-09-05 19:11:42 MESZ - -Fix undesired model navigator updates. ----------------------------------------------------------------------------- -r3457 | diewald | 2016-09-05 19:03:10 MESZ - -Fix an undesired cancellation of the DSE process by Opt4J. - -The Opt4J framework removes two aims to remove two lames if both have the same distance value, but the code expects one lame to remain. Hence, use a self-compiled version providing a fix for this case. ----------------------------------------------------------------------------- -r3456 | diewald | 2016-09-05 16:53:35 MESZ - -Re-integrate the model naming capability in the modular transformation framework. ----------------------------------------------------------------------------- -r3455 | diewald | 2016-09-05 16:05:21 MESZ - -[WIP] Re-integration of the element-wise model transformation into the modular transformation framework. - -- WIP: Adaption and separation of the element-wise transformation modules. -- Integration of the dependency graph to determine the execution order of the element-wise transformation modules. -- TODO: registration of the element-wise modules. - ----------------------------------------------------------------------------- -r3454 | barner | 2016-09-05 15:08:56 MESZ - -- Reset temporary Deployment's references to Component/PlatformArchitectures in all exit paths of evaluateGoal(). -- This fixes errors regarding dangling Hrefs when trying to save the underlying FileProject (after the exploration has terminated) ----------------------------------------------------------------------------- -r3453 | barner | 2016-09-05 15:06:17 MESZ - -- Reset temporary Deployment's references to Component/PlatformArchitectures in all exit paths of evaluateGoal(). -- This fixes errors regarding dangling Hrefs when trying to save the underlying FileProject (after the exploration has terminated) ----------------------------------------------------------------------------- -r3451 | diewald | 2016-09-02 15:36:29 MESZ - -Generalize the DecoderDependencyGraph: DependencyGraph. - -The DecoderDependencyGraph has been generalized such that it can be specialized for the use in the element-wise model transformations. ----------------------------------------------------------------------------- -r3449 | diewald | 2016-09-02 13:06:00 MESZ - -Move all debug graphs to a display subpackage. ----------------------------------------------------------------------------- -r3448 | diewald | 2016-09-02 12:00:08 MESZ - -[WIP] Re-integration of the element-wise model transformation into the modular transformation framework. - -- Removal of unneeded classes. -- WIP: Interface rework. -- TODO: Generalization of the dependency graph used for decoders. -- TODO: Integration of the dependency graph to determine the execution order of the element-wise transformation modules. ----------------------------------------------------------------------------- -r3447 | diewald | 2016-09-02 09:41:47 MESZ - -Correct the usage of the annotation view update in the modular transformation framework. ----------------------------------------------------------------------------- -r3446 | diewald | 2016-09-01 18:26:38 MESZ - -Some code cleanup. ----------------------------------------------------------------------------- -r3439 | diewald | 2016-09-01 15:39:40 MESZ - -Re-include the generation of voter components that was commented out for the transition to the modular transformation framework. ----------------------------------------------------------------------------- -r3438 | diewald | 2016-09-01 14:44:27 MESZ - -Fix the skipping of optional transformation modules with unsatisfied dependencies. ----------------------------------------------------------------------------- -r3437 | diewald | 2016-09-01 14:06:04 MESZ - -Fix the component instantiation such that indeed all abstract components are instantiated (instead of replacing instantiated components with instantiated ones, while some abstract components remain). ----------------------------------------------------------------------------- -r3434 | diewald | 2016-08-31 19:47:41 MESZ - -Do not execute optional transformation modules if not all required inputs are available. ----------------------------------------------------------------------------- -r3433 | diewald | 2016-08-31 19:22:51 MESZ - -- Add a mechanism to the decoder dependency graph that adds identity decoders for any encoding involved in the exploration process. -- Add an identity decoder for AbstractTaskMappingEncodings to make it available for the transformation framework. ----------------------------------------------------------------------------- -r3428 | diewald | 2016-08-31 15:22:11 MESZ - -- Transformation Framework: - - Safety Module: Remove connections between channels (clean impl as module). - - Safety Module: Remove non-needed (abstract) Diag Components from a generated Component Architecture (clean impl as a module). - - Use only abstract task mappings as input for the replication module of the component architecture transformation. - - Also use associated entries (assocs between IMappingEntries) in the element transformation association maps. - - Extend INIT transformation stage to INITIALIZING and INITIALIZED. - - Add a method to the transformation base module that removes model elements and its associations (avoids common errors). - -- Internal DSE engine: - - Add field for associations of task entries to task entries from other DSE process steps. - -- Misc / Bug Fixes: - - Only trigger SafetyConstraint generation for the transformation if the Constraint is specified. - - Suitable toStringMethods for Safety Function encodings. - - Fix bug in the task replication operator. ----------------------------------------------------------------------------- -r3422 | barner | 2016-08-31 09:31:54 MESZ - -- Fix typo ----------------------------------------------------------------------------- -r3418 | barner | 2016-08-30 14:13:08 MESZ - -- Sync with stock AF3 release 2.10.0 - - Bump plugin version to 2.10.0 - - Sync online help ----------------------------------------------------------------------------- -r3417 | barner | 2016-08-30 13:11:20 MESZ - -- Fix typos ----------------------------------------------------------------------------- -r3404 | diewald | 2016-08-26 17:01:08 MESZ - -Introduce the Exploration Evaluator Service. - -- ExplorationEvaluatorService added: - - Evaluators can now be contributed from external plugins. - - Evaluators must register with a ExplorationTarget (1:1 mapping). - - Each contributed evaluator must define the primary phenotype on which it operates (for now) and provide a method to instantiate "itself". - - Example implementation: The EngeryObjectiveMin evaluator has already been migrated. See the plugin.xml file and the corresponding java class. - -- Code simplification & cleanup. ----------------------------------------------------------------------------- -r3382 | diewald | 2016-08-08 17:26:54 MESZ - -Introduce the modular transformation & exploration service framework: -- Model transformations can be demanded by calling "ExplorationService.getService(TransformatorType.class).getTransformedModel(ModelType.class, ...)" if the needed input is provided. -- The model transformation is organized hierarchically such that sub model transformations can be automatically triggered if required (i.e., if a deployment is demanded which requires a generated component architecture). -- States define the execution order of the transformation sub-modules (e.g., INIT, REPLICATING, etc.; see ITransformationModule). -- TransformationStrategies define those model transformations that can be called externally (via the service) and which automate the execution of sub modules that perform the actual transformation. -- Transformation modules are processed dynamically which requires them to declare their required inputs and their resulting outputs. -- Additionally: Several minor bug fixes & code cleanup. ----------------------------------------------------------------------------- -r3248 | barner | 2016-07-08 11:04:21 MESZ - -- Make the following platform utility methods available in DreamsPlatformUtils: - - getEffectiveConnectionTargets() - - isValidConnectionTarget() - - containsPlatformElements() - - connectPlatforms() - - connectPlatforms() - - connectsSwHwPlatform() - - connectsSwHwPlatform() - - connectsSwHwPlatform() - - getReferencedPlatformElements() ----------------------------------------------------------------------------- -r3247 | barner | 2016-07-08 10:40:00 MESZ - -- AF3Utils.getEffectiveConnectionTargets(): remove unused parameter "isReflexive" ----------------------------------------------------------------------------- -r3242 | barner | 2016-07-07 16:36:58 MESZ - -- Include org.fortiss.af3.exploration.alg.jar into product ----------------------------------------------------------------------------- -r3231 | barner | 2016-07-07 12:17:14 MESZ - -- Add missing '.alg' suffix to plugin ids -- In particular, this also directs the edit(or) code for the meta-models moved to this plugin into org.fortiss.af3.exploration.alg.edit(or), which currently does not exist (i.e., the code is not generated) -- Remove .edit code for models that now reside in org.fortiss.af3.exploration.alg ----------------------------------------------------------------------------- -r3223 | diewald | 2016-07-06 16:11:30 MESZ - -- Move the Prototype provider to the .alg subpackage. -- Re-register the prototype provider (got lost during the ecore move). ----------------------------------------------------------------------------- -r3221 | diewald | 2016-07-06 15:10:55 MESZ - -- Add proper model documentation. -- Add deprecation markers where needed (in the documentation). ----------------------------------------------------------------------------- -r3220 | diewald | 2016-07-06 14:21:07 MESZ - -- Add proper model documentation. -- Add deprecation markers where needed (in the documentation). ----------------------------------------------------------------------------- -r3214 | diewald | 2016-07-06 11:37:50 MESZ - -Throw an Exception if no Gateway is defined for an OnChipNetworkDriver. ----------------------------------------------------------------------------- -r3211 | diewald | 2016-07-06 11:26:14 MESZ - -YELLOW ----------------------------------------------------------------------------- -r3198 | diewald | 2016-07-05 13:32:36 MESZ - -Mark implicit constraints via an EAttribute instead of via a marker class. ----------------------------------------------------------------------------- -r3196 | diewald | 2016-07-05 11:09:12 MESZ - -- Update Exploration MM to introduce a separation between "Generic Exploration Targets" and "Expression Targets" to improve the support to the new exploration Dsl. -- Update the genmodel files to reflect these changes. -- Update the edit plugin to the MM changes. ----------------------------------------------------------------------------- -r3184 | diewald | 2016-07-04 21:28:49 MESZ - -Fix error when creating VirtualLinks --> MM modification and temporally disable a check. ----------------------------------------------------------------------------- -r3183 | diewald | 2016-07-04 21:00:34 MESZ - -../.. -> platform:/resource ----------------------------------------------------------------------------- -r3181 | diewald | 2016-07-04 20:51:59 MESZ ----------------------------------------------------------------------------- -r3180 | diewald | 2016-07-04 18:58:20 MESZ - -Move the DesignspaceExplorationFactory to org.fortiss.af3.exploration.alg.utils to avoid conflicts in package naming. ----------------------------------------------------------------------------- -r3179 | diewald | 2016-07-04 18:50:07 MESZ - -Fix some MM code generation issues and use the right factories (move). ----------------------------------------------------------------------------- -r3176 | diewald | 2016-07-04 17:49:51 MESZ - -Fix some model bugs that were introduced when moving MMs recently. ----------------------------------------------------------------------------- -r3175 | diewald | 2016-07-04 17:25:48 MESZ - -Move moea.ecore, explorationDsl.ecore, and most parts of common.ecore from org.fortiss.af3.exploration to org.fortiss.af3.exploration.alg. ----------------------------------------------------------------------------- -r3166 | diewald | 2016-07-04 13:32:26 MESZ - -Add ignore property to generated-src folder. ----------------------------------------------------------------------------- -r3165 | diewald | 2016-07-04 13:31:18 MESZ - -Add generated-src folder. ----------------------------------------------------------------------------- -r3164 | barner | 2016-07-04 13:27:03 MESZ - -- It has been decided to keep a service specific getInstance() method instead of ToolingKernel.getService(), hence revert changes from r3122 ----------------------------------------------------------------------------- -r3158 | diewald | 2016-07-01 18:44:40 MESZ - -- Remove a hack in PlatformCommunicationGraph that excludes Busses from the graph. -- Add a proper mechanism such that resources within a virtualized hardware layer are not considered in the generation of resource connections if none of these elements are selected as deployment targets. As a result, the PlatformCommunicationGrpach is constructed correctly. ----------------------------------------------------------------------------- -r3134 | diewald | 2016-06-30 14:33:52 MESZ - -Add an Exception that is thrown if no deployment targets were specified. ----------------------------------------------------------------------------- -r3132 | diewald | 2016-06-29 18:12:07 MESZ - -Let the ExecDependecyGraph check if all required input Encodings are available & throw an appropriate Exception that indicates the problem if some required input is not available. ----------------------------------------------------------------------------- -r3131 | diewald | 2016-06-29 17:04:21 MESZ - -- Make the ExecDependencyGraph a normal class instead of a singleton. -- Allow the retrieval of IExplorationEncodings registered at the SystemModelAdapter. ----------------------------------------------------------------------------- -r3130 | diewald | 2016-06-29 16:30:56 MESZ - -Fix a bug in the identification of target connectors that caused the VL model transformation to fail under special circumstances. ----------------------------------------------------------------------------- -r3127 | diewald | 2016-06-29 15:48:30 MESZ - -Fix some misdirected edges in the PlatformCommunicationGraph calculation. ----------------------------------------------------------------------------- -r3124 | diewald | 2016-06-29 12:10:28 MESZ - -Add a todo. ----------------------------------------------------------------------------- -r3123 | diewald | 2016-06-29 09:07:59 MESZ - -Fix unconnected NetworkInterfaces for some models. ----------------------------------------------------------------------------- -r3122 | diewald | 2016-06-29 08:39:11 MESZ - -Fix some deprecation warnings resulting from kernel changes. ----------------------------------------------------------------------------- -r3120 | diewald | 2016-06-28 21:14:35 MESZ - -- Add an exception specific for invalid input platform architecture models. -- Fix the connection direction identification prior to building the PlatformCommunicationGraph. -- Fix the connections of edges when construction the PlatformCommunicationGraph. -- Fix some errors in identifying the right target connectors when extracting connections from the platform. -- Cleanup. ----------------------------------------------------------------------------- -r3119 | diewald | 2016-06-28 16:52:26 MESZ - -- Add an exception for invalid input platform models. -- Allow multiple references from OnChipNetworkDrivers in the DSE. ----------------------------------------------------------------------------- -r3114 | diewald | 2016-06-28 15:32:55 MESZ - -Remove an intermediate statement from the SafetyComplianceEvaluator that may hide problems, but was useful during modularization of the DSE framework. ----------------------------------------------------------------------------- -r3113 | diewald | 2016-06-28 15:25:12 MESZ - -Fix the calculation of the execution orders of decoders. ----------------------------------------------------------------------------- -r3112 | diewald | 2016-06-28 13:51:39 MESZ - -- Simplify the execution code for sub-Decoders in CompositeDecoders. -- Correctly consider the execution order calculated by the ExecDependencyGraph in CompositeDecoders. -- Simplify & correct the cloning mechanism for encodings. - ----------------------------------------------------------------------------- -r3108 | diewald | 2016-06-28 10:34:10 MESZ - -- Simplify the message generation. -- Fix duplicate allocation entries after cloning the AbstractTaskMapping. ----------------------------------------------------------------------------- -r3107 | diewald | 2016-06-28 08:33:38 MESZ - -Disable the period consistency check for task graphs for now until full multi-periods are fully supported. -The check currently causes problems with VL generation. ----------------------------------------------------------------------------- -r3104 | diewald | 2016-06-27 17:54:22 MESZ - -Fix & improve the retrieval of components comprising a safety function. ----------------------------------------------------------------------------- -r3103 | diewald | 2016-06-27 16:49:39 MESZ - -Final fix for incorrectly specified periods for task graphs. ----------------------------------------------------------------------------- -r3102 | diewald | 2016-06-27 16:23:06 MESZ - -Improve the identification of invalid period specifications. ----------------------------------------------------------------------------- -r3101 | diewald | 2016-06-27 16:00:28 MESZ - -- Add an InvalidTimingModel exception. -- Fix a ClassCastException in the PeriodConstraint generation. ----------------------------------------------------------------------------- -r3100 | diewald | 2016-06-27 15:47:45 MESZ - -- Add a ConstraintGenerationException. -- Fix the PeriodConstraint generation. ----------------------------------------------------------------------------- -r3098 | diewald | 2016-06-27 11:49:06 MESZ - -Disable AnnotationView updates during Deployment generation. ----------------------------------------------------------------------------- -r3096 | diewald | 2016-06-27 10:39:10 MESZ - -- VL-Generation: Check for equals sets of deployed components and deployable components identified by the DSE. -- DSE: Use Double instead of double for periods. -- Improve the detection of deployable Components. -- Improve the period retrieval to correctly respect hierarchies. -- Fix the input check of the VL generation to valid the deployable component sets (DSE-selected <-> Component allocations in Deployment model). ----------------------------------------------------------------------------- -r3079 | diewald | 2016-06-23 10:26:10 MESZ - -Remove isDebugVerboseEnabled from ExplorationAlgUtils & use ExplorationUtils.isDebugVerboseEnabled() instead. ----------------------------------------------------------------------------- -r3074 | diewald | 2016-06-22 16:32:04 MESZ - -Fix the interpretation of the implements component specification in the VL Generation. ----------------------------------------------------------------------------- -r3073 | diewald | 2016-06-22 16:02:48 MESZ - -- Fix registration of the MessageDecoder. -- Fix launching non-required Decoders for the just created genotype. -- Add support for the Mu parameter (EA-specific parameter). -- Improve the VL Generation performance. ----------------------------------------------------------------------------- -r3072 | diewald | 2016-06-22 13:08:57 MESZ - -- Composite framework: - - Add a mechanism to allow decoding of phenotypes (into other phenotypes). - - Implement an update mechanism for hybrid Phenotypes. -- Remaining Issues: - - Period constraints are currently not evaluated for instantiated components. - - "Empty" schedules are not correctly sorted out in the decoding. ----------------------------------------------------------------------------- -r3064 | barner | 2016-06-21 09:07:30 MESZ - -- Ensure that exceptions actually reach the Eclipse Job that executes the virtual link generation -- TODO: (Re-)consider - - if catching exceptions and re-throwing (other exceptions) always makes sense - - wrap error messages currently printed to sysout into exections - - Extract more exceptions from Opt4J (needed to pass errors during DSE to Eclipse Job) ----------------------------------------------------------------------------- -r3063 | diewald | 2016-06-21 08:34:42 MESZ - -Fix the execution order of decoders in the ExecDependency Graph: inverse ordering after calculation. ----------------------------------------------------------------------------- -r3062 | diewald | 2016-06-20 19:59:20 MESZ - -- Allow requesting of solution model types --> only launch the required creators decoders: - - Introduce a Graph which allows to calculate the required decoders and creators given the set of available decoders and creators and the required phenotypes (that will comprise the model solution set). - - Make the Creators/Decoders aware of the graph. -- Extract the message decoding to a separate Decoder. -- The VL generation now only uses a task mapping and a message encoding --> no more scheduling of VLs. - ----------------------------------------------------------------------------- -r3050 | barner | 2016-06-20 10:00:57 MESZ - -- Rename org.fortiss.af3.exploration.alg.ExplorationUtils to ExplorationAlgUtils -- Create org.fortiss.af3.exploration.ExplorationUtils -- Move ExplorationAlgUtils.isDebugVerboseEnabled() to ExplorationUtils ----------------------------------------------------------------------------- -r3049 | barner | 2016-06-20 09:30:31 MESZ - -- Move isDebugVerboseEnabled() to ExplorationUtils (as static method) ----------------------------------------------------------------------------- -r3044 | barner | 2016-06-18 00:12:37 MESZ - -- Eliminate remaining references to review.ecore - -refs 2606 ----------------------------------------------------------------------------- -r3042 | diewald | 2016-06-17 16:17:22 MESZ - -SafetyIntegrityLevelConstraintEvaluator now operates on InstantiatedTaskMapping instead of StrictTTSchedules. ----------------------------------------------------------------------------- -r3039 | diewald | 2016-06-17 15:57:05 MESZ - -Re-add setting the iteration count via UI. ----------------------------------------------------------------------------- -r3038 | diewald | 2016-06-17 15:26:28 MESZ - -Update ConQat rating of some not-yet-updated files. ----------------------------------------------------------------------------- -r3035 | diewald | 2016-06-17 15:13:23 MESZ - -Add proper toString methods to the FlatGenotypeMap & FlatPhenotypeMap. ----------------------------------------------------------------------------- -r3033 | diewald | 2016-06-17 13:51:48 MESZ ----------------------------------------------------------------------------- -r3032 | diewald | 2016-06-16 20:13:12 MESZ - -Heavy improvement of the composite DSE framework: -- Consequently apply the composite framework to operations: creators, decoders, evaluators. -- Simplification of the framework by removing unneeded generics. -- More consistent use of generics in the operations. -- All task graphs are now encodings --> phenotypes. -- Improved separation between mappings schedules. -- Adjustment of the UI plugin to the changes. -- Much Improved integration of the safety Arch exploration: only thing missing: model export. -- Disabled the voter generation for now. -- MM: Adjust the EMM to also export the input model adapter (aka system model adapter) for later deployment generation. - -Also: Consistently applied the conqat ratings and added some missing documentation. ----------------------------------------------------------------------------- -r2997 | barner | 2016-06-15 09:41:40 MESZ - -- Sync with MM ----------------------------------------------------------------------------- -r2918 | barner | 2016-06-06 14:54:17 MESZ - -- Tooling Kernel service singletons implemented as 'getInstance()' method instead of static variable 'INSTANCE' -refs 2597 - ----------------------------------------------------------------------------- -r2872 | barner | 2016-05-31 17:36:22 MESZ - -- Set plugin name and/or vendor ----------------------------------------------------------------------------- -r2847 | diewald | 2016-05-27 11:10:01 MESZ - -- DreamsTimingUtils: Add a method to retrieve the EventAnnotationBase of Ports that references the associated timing Events. -- MOEA-DSE: Align the behavior of the DSE with the modifications of the timing utils such that the Components considered by the DSE are extracted properly. ----------------------------------------------------------------------------- -r2832 | barner | 2016-05-25 17:11:36 MESZ - -- Rename get{Mint,Period}Value(Component) to get{Mint,Period}(Component) -- Change return type of getMint(*) and getPeriod(*) to Double ----------------------------------------------------------------------------- -r2828 | barner | 2016-05-25 16:52:15 MESZ - -- Mark rtaw.DreamsUtils.getPeriod() and rtaw.DreamsUtils.getMint() as deprecated. Use the versions in DreamsTimingUtils instead which walk up the hierarchy -- DreamsTimingUtils.getPeriodValue(Component) now only investigates the Component, but not its ports any longer. -- Move rtaw.DreamsUtils.getMintValue() to DreamsTimingUtils - ----------------------------------------------------------------------------- -r2787 | diewald | 2016-05-24 09:51:54 MESZ - -- Skip the scheduling of non-periodic messages in the TDMA message scheduler. ----------------------------------------------------------------------------- -r2765 | diewald | 2016-05-19 13:47:23 MESZ - -- Update the VL Generation to be compliant with the latest timing MM. -- Consider TimingEvents when looking for SporadicConstraints. ----------------------------------------------------------------------------- -r2713 | barner | 2016-05-10 14:22:03 MESZ - -- Use ComponentType annotation to mark generated voter components as ComponentType_t.VOTER ----------------------------------------------------------------------------- -r2712 | barner | 2016-05-10 14:16:56 MESZ - -- Fix build after DREAMS timing model updates ----------------------------------------------------------------------------- -r2686 | diewald | 2016-05-04 18:23:35 MESZ - -- Renaming (Contd.): safetyfunctiondesign -> safetyfunctionarch. -- Add copy operators for the SafetyFuncionArchEncoding. -- Minor package restructuring in the copy operators. -- Fixes for the mutation operators of the safety function encoding. -- Extensions to the DREAMS utils to obtain information about the components implementing a safety function as defined in the safety compliance model. -- NOTE: The exploration of safety function architectures is currently disabled due to problems with the crossover operator identification. ----------------------------------------------------------------------------- -r2663 | diewald | 2016-05-03 15:57:56 MESZ - -- Renaming: SafetyFunctionDesign -> SafetyFunctionArchitecture. -- Fill the safety function mutate methods with some life. -- Switch the mutation rate provider from ConstantMutationRate to AdaptiveMutationRate to allow injection of multiple mutate modules. Here, a custom MutationRate class is required to account for composite genotypes. -- Introduce an additional base class for safety function mutate operators to reduce code duplication. ----------------------------------------------------------------------------- -r2634 | diewald | 2016-05-02 13:13:06 MESZ - -- Fix crash in the RC-VirtualLink generation. ----------------------------------------------------------------------------- -r2625 | diewald | 2016-04-29 17:15:14 MESZ - -- Enrich the MutateSafetyFunctionDesignModule such that it registers the Mutation operators if activated in the DSEFactory. ----------------------------------------------------------------------------- -r2622 | diewald | 2016-04-29 14:47:48 MESZ - -- Add an empty module to register the mutate operators. ----------------------------------------------------------------------------- -r2621 | diewald | 2016-04-29 14:09:49 MESZ - -- Add mutation operator classes for safety functions. ----------------------------------------------------------------------------- -r2620 | diewald | 2016-04-29 13:56:14 MESZ - -- Separate the mutation base class into a MutationBase class and a MutationTaskBase class. -- YELLOW for mutation classes where possible. ----------------------------------------------------------------------------- -r2618 | diewald | 2016-04-29 13:17:39 MESZ - -- Add utility methods to extract information about safety functions from a safety compliance model: Number of safety functions, traces to involved AF3 components and their role within a specific safety function. -- Restructure the mutation operators (java packages). -- Extend the use of generics within the SystemModelAdapter. ----------------------------------------------------------------------------- -r2607 | diewald | 2016-04-28 15:50:32 MESZ - -- Add first version of the IKLSafetyFunctionAdapter which encapsulates information about safety functions extracted from IKL's safety compliance model. -- Use a type parameter to denote which component types are used to realize the safety function: Currently only Components. ----------------------------------------------------------------------------- -r2606 | diewald | 2016-04-28 12:59:48 MESZ - -- Finalize the safety function encoding creator. -- Add a field in the system model adapter that contains the safety function adapters. -- Stylistic documentation fixes in the TaskMappngCreator class. ----------------------------------------------------------------------------- -r2604 | diewald | 2016-04-28 11:01:09 MESZ - -- Remove outdated guava library version 18.0. -- Add source annotations for guava version 19.0. -- Add an adapter interface for safetyfunctions. -- Add an encoding/genotype for exploring safety functions. -- Add a (not yet functional) creator for safety function encodings/genotypes. ----------------------------------------------------------------------------- -r2591 | diewald | 2016-04-27 12:04:24 MESZ - -Minor fix for the documentation of the nextInt(int) method of the RandomExploration random number generator. ----------------------------------------------------------------------------- -r2590 | diewald | 2016-04-27 12:02:29 MESZ - -- Improve the documentation of the RandomExploration random number generator. ----------------------------------------------------------------------------- -r2583 | diewald | 2016-04-26 17:47:24 MESZ - -- Rework the calculation of the required exponent to represent a set of BigDecimals as BigIntegers such that a given precision is preserved. NOTE: The demanded precision is no longer defined by a decimal number, but by an integer denoting the n-th position of the fractional digit. ----------------------------------------------------------------------------- -r2571 | diewald | 2016-04-22 18:02:55 MESZ - -- Readd the migrator for the MOEA-based DSE. -- Correct the return type parameter of the SafetyComplianceConstraint. -- Re-introduce: the generic of the ExplorationTargets defines the return type. -- Correct the handling of the return type in the DSE when creating the Exploration Solutions. -- Add a utility method that allows to determine the substitution type of a type parameter defined in any super class or interface that has only ONE generic parameter. -- Add a mechanism to the exploration editor that allows to set and get the parameters which are encoded in an expression via reflection.l ----------------------------------------------------------------------------- -r2570 | barner | 2016-04-21 17:17:27 MESZ - -- Change the representation of temporal values from double to BigDecimal (in org.fortiss.af3.timing timing.ecore) -- This data type is used in the schedule and the PSM MM -- Adjust code that works on these models ----------------------------------------------------------------------------- -r2546 | diewald | 2016-04-08 13:42:37 MESZ - -- Fix genmodel of dsl_v2 ecore: Add editDirectory, proper package names to prevent overriding of previously generated files. -- Fix plugin.xml: correct the generated packages. -- Update edit plugin. ----------------------------------------------------------------------------- -r2513 | barner | 2016-03-29 14:31:54 MESZ - -- Disable arrayAccessors option in all .genmodels and adjust source code where needed (method to access the list representing a reference 'foo' with cardinality > 1 is now named getFoo() instead of getFooList()) -- The inconsistent use of arrayAccessors caused compilation problems in some cases, which is why it has also bee disabled in the org.fortiss.af3.base plugin ----------------------------------------------------------------------------- -r2512 | diewald | 2016-03-29 14:20:01 MESZ - -- Correctly export the solutions found by the DSE in the EMF-based solution representation. -- Make the visual solution representation work again: Base the UI-plugin on the EMF-based solution representation. ----------------------------------------------------------------------------- -r2510 | diewald | 2016-03-29 10:39:46 MESZ - -- Fix the creation of ComponentMultiAllocationConstraint Evaluators. -- Solutions: Use the create method from the DesignSpaceExplorationModelElementFactory to avoid an NPE. -- Use the new PeriodConstraint consequently. -- Replace all occurences of FixedDeploymentConstraints with ComponentMultiAlloctionConstraints. ----------------------------------------------------------------------------- -r2507 | diewald | 2016-03-28 22:37:47 MESZ - -- Refinement of Exploration ecore models. -- MOEA DSE now uses the new ExplorationTargets (-> Exploration DSL) -- Added Migrator for old DSE models. -- The DSE now uses the DSE extension mechanism (demanding parameters & registering the backend). -- Update of the edit plugin. -refs 2535 - ----------------------------------------------------------------------------- -r2494 | diewald | 2016-03-22 14:06:08 MEZ - -- Correct usage of java-subpackages in the genmodel files. -- Use the "LocationType" in the LocationConstraint & LocationPattern. -- Renamings in the MOEA EMF model. -- Add migrator for concrete MOEA Exploration targets & common exploration targets. (NOT registered yet) -- Add model element factories for the exploratin DSL and the common exploration targets. -- Alignments in the exploration.alg plugin. -- Update edit plugin. ----------------------------------------------------------------------------- -r2491 | diewald | 2016-03-18 18:10:11 MEZ - -- Add an extension point to the exploration plugin that allows register DSE backends. -- The extension points must implement IDseBackend. -- The parameters are passed via IDseInputParameters (a base class exists). -- The DseBackendHandler singleton is used to call the backends and it caches values for this call. -- Initial version of ExplorationTarget migrator. ----------------------------------------------------------------------------- -r2462 | diewald | 2016-03-16 14:54:02 MEZ - -- Intermediate version of exploration MM as an attempt to fix build error. ----------------------------------------------------------------------------- -r2461 | diewald | 2016-03-16 13:43:00 MEZ - -- Fix intermediate misconceptions in the Exploration DSL. -- Remove the MOEAExplorationObective and -Constraint. -- Create a LocationExpression. -- Create a common LocationConstraint. -- Create a common ComponentAllocationConstraint. ----------------------------------------------------------------------------- -r2458 | diewald | 2016-03-16 09:29:31 MEZ - -- Rename SeparationDimension -> LocationDimension. -- Replace ResourceLink superclass of MemoryConstraint with the correct class ResourceDimension. ----------------------------------------------------------------------------- -r2455 | diewald | 2016-03-15 20:06:15 MEZ - -- Align with most recent Exploration Meta-Model changes. -- Update the edit plugins. ----------------------------------------------------------------------------- -r2429 | hoelzl | 2016-03-08 11:49:51 MEZ - -Changed pom.xml to point to new parent-pom.xml location and removed outdated 'indigo' suffix. -refs "2499" - ----------------------------------------------------------------------------- -r2420 | diewald | 2016-03-07 11:58:27 MEZ - -- Bug fix: Use only abstract IDeployableComponentAdapters to find scheduleable Components (in the EDF scheduler). -- Cleanup & remove a warning. ----------------------------------------------------------------------------- -r2419 | diewald | 2016-03-04 19:05:52 MEZ - -- Parametrize almost all (SystemModel)Adapters with generics such that The DSE is more type-safe w.r.t. the In-/Output. ----------------------------------------------------------------------------- -r2404 | diewald | 2016-03-04 08:47:30 MEZ - -org.fortiss.exploration.(alg/ui): -- Add a flag to the explorer that indicates whether implicit constraints shall be generated prior to the exploration. -- Disable the implicit constraint generation for the VL generation. ----------------------------------------------------------------------------- -r2403 | diewald | 2016-03-03 18:10:02 MEZ - -org.fortiss.af3.exploration.alg: -- Add a collection of scheduleable components to the SystemModelAdapter that is derived from the set of deployable components and defiens those components which can be scheduled by an periodic scheduler. -- Extend the StrictTTScheduler (and the EDF- and TDMAScheduler) such that unscheduleable Components and Messages are not processed by them. -- Extend the VL generation such that a MINT is added to Sporadic VLs. ----------------------------------------------------------------------------- -r2342 | diewald | 2016-02-24 17:26:16 MEZ - -org.fortiss.af3.exploration.alg: -- Bugfix: Only add those tasks from the abstract task graph to the instantiated task graph which were also contained in the original abstract task graph (not all tasks contained in any task graph). -- Throw a ScheduleRuntimeException, if no WCET has been specified for an allocation that is attempted to be scheduled by the EDF scheduler. ----------------------------------------------------------------------------- -r2206 | barner | 2016-02-22 11:57:07 MEZ - -- Bump AF3 version number from 2.8.0 to 2.9.0 ----------------------------------------------------------------------------- -r2192 | diewald | 2016-02-20 15:01:49 MEZ - -org.fortiss.af3.exploration.alg: -- Upload correct jar. ----------------------------------------------------------------------------- -r2142 | barner | 2016-02-11 15:58:24 MEZ - -- Move DreamsTimingUtils to eu.dreamsproject.application ----------------------------------------------------------------------------- -r2128 | diewald | 2016-02-05 17:30:27 MEZ - -org.fortiss.af3.exploration.alg: -- Fix the instance task graph to contain only tasks that correspond to the tasks of its associated abstract task graph, not the complete set of tasks. -- Introduce an assertion to "harden" the instance task graph creation (fixes a todo & avoids an actually unneeded check). ----------------------------------------------------------------------------- -r2093 | diewald | 2016-01-29 11:30:35 MEZ - -org.fortiss.af3.exploration.alg: -- Add a state machine to track the transformation status of modules. It prevents a wrong order in calling the single operations and multiple calls at one time which will result in broken models. - -org.fortiss.af3.exploration.ui: -- Show an error dialog if an Exception occurs during the transformation. ----------------------------------------------------------------------------- -r2077 | diewald | 2016-01-28 11:05:05 MEZ - -org.fortiss.af3.exploration.alg: -- Add guava source annotations. -- Improvements to Model Generation/Transformation framework: - - Call a set of generation/transformation operations of the generation/transformation modules automatically from the model generation strategy such that code duplication in the concrete model generators/transformators is avoided. Consequently, the concrete model generators/transformators only need to perform the registration of the modules and the preparation and "finalization" of the model. - - Introduce a marker interface for other interfaces that define generation/transformation operations. - - Add the IElementModule interface to allow element-based Generation/Transformation modules to declare the element types on which they operate. - - Switch from Map to Multimap for the associative map of original to generated elements. - - Bug fix for inserting replica of Events in the generated TimingDescription. -- Cleanup. ----------------------------------------------------------------------------- -r2076 | diewald | 2016-01-26 13:43:23 MEZ - -org.fortiss.af3.exploration: -- Remove copies of abstract components and their children that were instantiated from the generated-to-original element map. ----------------------------------------------------------------------------- -r2075 | diewald | 2016-01-26 12:03:54 MEZ - -org.fortiss.af3.exploration.alg: -- Fix the references from TimingEvents to instances of components: - * Instance elements are no longer identified by the ModelGenerationModules, instead the collection of instantiated elements must be provided by the predecessor generators/transformators. - * The ComponentArchitectureGenerator now offers a list with instantiated elements. -- Cleanup. ----------------------------------------------------------------------------- -r2074 | diewald | 2016-01-25 18:10:38 MEZ - -org.fortiss.af3.exploration.alg: -- Initial implementation of the model generation/transformation "framework": - * The model generation follows the strategy pattern. - * Sub-elements are handled in "modules" which must be called from the concrete strategy's methods. - * The prototype is currently only used to adjust the references of timing Events to the instances of Components. - * The remaining parts of the timing model need to be handled using the framework. - * TODO: Apply the "framework" to the ComponentArchitecture and Deployment Generation. ----------------------------------------------------------------------------- -r2067 | diewald | 2016-01-21 11:09:27 MEZ - -org.fortiss.af3.exploration.alg: -- Push fix for setting source and target components of deadline constraints. -- 1st skeleton implementation of model genertation/transformation "framework". ----------------------------------------------------------------------------- -r2056 | diewald | 2016-01-13 16:27:43 MEZ - -org.fortiss.af3.exploration.alg: -- Improves the creation of IDeployableComponentadapters such that the instantiation mechanism for components is supported properly -- Corrects the instantiation of IDeployableComponentAdapters within the encoding. -- Corrects the ComponentArchitecture and Deployment generation and aligns it with the changes mentioned above. -- Fixes the Reliability evaluator. -- Fixes the VirtualLink generation based on a given Deployment. ----------------------------------------------------------------------------- -r2054 | diewald | 2016-01-12 10:41:04 MEZ - -org.fortiss.af3.exploration.alg: -- Code cleanup and removal of deprecated TODOs/FIXMEs. ----------------------------------------------------------------------------- -r2053 | diewald | 2016-01-12 10:12:06 MEZ - -org.fortiss.af3.exploration.alg: -- Code cleanup. ----------------------------------------------------------------------------- -r2052 | diewald | 2016-01-12 09:02:57 MEZ - -org.fortiss.af3.exploration.alg: -- Generalize the treatment of the FailureRate annotation for virtual resources in the AF3ResourceAdapter. -- Bug fix to remove the "abstract" Components from the TaskGraph containing the instances instead of removing them from the "abstract" TaskGraph. ----------------------------------------------------------------------------- -r2051 | diewald | 2016-01-11 17:54:36 MEZ - -org.fortiss.af3.exploration.alg: -- Make the VL export safer against accessing non-existing objects. ----------------------------------------------------------------------------- -r2050 | diewald | 2016-01-11 17:13:33 MEZ - -org.fortiss.af3.exploration.alg: -- Remove deprecated FIXMEs. -- The removal of tasks from TaskGraphs is now handled internally in the TaskGraphs. ----------------------------------------------------------------------------- -r2049 | diewald | 2016-01-11 16:41:42 MEZ - -org.fortiss.af3.exploration.alg: -- Remove outdated FIXMEs. -- Improve the repair mechanism such that both swapping of Component->ExU allocations and a random re-allocation is possible. The selected mechanism is determined randomly. ----------------------------------------------------------------------------- -r2048 | diewald | 2016-01-11 16:02:33 MEZ - -org.fortiss.af3.exploration.alg: -- Make the EMFModelWrapper more thread safe. -- Solve FIXME: Make comparison based on objects instead of IDs. ----------------------------------------------------------------------------- -r2027 | barner | 2015-12-18 11:44:07 MEZ - -- Move apfloat library from org.fortiss.af3.schedule to org.fortiss.af3.exploration.alg again. -- org.fortiss.af3.schedule uses BigDecimal now ----------------------------------------------------------------------------- -r2026 | barner | 2015-12-17 16:49:51 MEZ - -- Add suffixes to lcm/gcd methods working on collections that indicate the object type -- Required to enable the implementation of support for further types (would have the same type erasure, otherwise) ----------------------------------------------------------------------------- -r2025 | barner | 2015-12-17 11:54:33 MEZ - -- Move apfloat.jar to org.fortiss.af3.schedule (and export it from) -- In order to avoid numerical instabilities when working with temporal values, APFLOAT needs to be used there as well. ----------------------------------------------------------------------------- -r2011 | diewald | 2015-12-15 14:59:42 MEZ - -org.fortiss.af3.exploration.alg: -- Fix the parallel execution of the DSE. The most important aspect of the fix is the introduction of the singleton EMFModelConcurrentHandler that wraps few problematic calls to the underlying model such that consistency is ensured (which EMF itself does not provide). ----------------------------------------------------------------------------- -r2005 | diewald | 2015-12-14 18:00:18 MEZ - -org.fortiss.af3.exploration.alg: -- Separate the ComponentArchitecture generation from the Deployment Generation. -- Created an interface & base class for model generation. ----------------------------------------------------------------------------- -r1998 | diewald | 2015-12-14 14:30:27 MEZ - -org.fortiss.af3.exploration.alg: -- Fix the virtual link generation for the generated component architectures. -- Cleanup, typo fix. ----------------------------------------------------------------------------- -r1925 | diewald | 2015-12-03 17:03:43 MEZ - -Cleanup. ----------------------------------------------------------------------------- -r1924 | diewald | 2015-12-03 17:02:55 MEZ - -org.fortiss.af3.exploration.alg: -- Activate the VirtualLink generation for exported Deployments again. ----------------------------------------------------------------------------- -r1922 | diewald | 2015-12-03 15:38:47 MEZ - -org.fortiss.af3.exploration.alg: -- Utils: Add static collections to define end-points of VirtualLinks and hidden layers (plus helper method). -- VirtualLink export: Hide details of Hypervisors, i.e. do not create VirtualLinks for contained elements. ----------------------------------------------------------------------------- -r1920 | diewald | 2015-12-03 13:18:29 MEZ - -org.fortiss.af3.exploration.alg: -- Cleanup & Refactoring for the VirtualLink generation. ----------------------------------------------------------------------------- -r1919 | barner | 2015-12-03 13:07:25 MEZ - -- Sync edit plugins with MMs ----------------------------------------------------------------------------- -r1918 | diewald | 2015-12-02 17:12:50 MEZ - -org.fortiss.af3.exploration.alg: -- Improved allocation constraint handling in the task mapping encoding. -- Cleanup & Refactoring for the VirtualLink generation. ----------------------------------------------------------------------------- -r1913 | diewald | 2015-12-02 14:15:08 MEZ - -org.fortiss.af3.exploration.alg: -- Cleanup. ----------------------------------------------------------------------------- -r1911 | diewald | 2015-12-02 13:01:12 MEZ - -org.fortiss.af3.exploration.alg: -- Adapt to latest changes in the safetyconstraintchecker interface. -- Cleanup/Refactoring in the VL generation. ----------------------------------------------------------------------------- -r1905 | diewald | 2015-12-02 08:27:37 MEZ - -org.fortiss.af3.exploration.alg: -- Get rid of the Singleton SystemModelServer (-> SystemModelAdapter) that was used to provide the systemModelAdapter instance to the Mating Module. Instead, the inject mechanism combined with the Named-annotation is used to bind the SystemModelAdapter reference in the Mating Module to the instance of the SystemModelAdapter. ----------------------------------------------------------------------------- -r1899 | diewald | 2015-12-01 14:07:15 MEZ - -org.fortiss.af3.exploration.alg: -- Add generation of the ImplementsComponentRef Specification for generated ComponentArchitectures during Deployment export. ----------------------------------------------------------------------------- -r1892 | diewald | 2015-11-30 18:01:21 MEZ - -org.fortiss.af3.exploration.alg: -- Temporally disable VL generation. ----------------------------------------------------------------------------- -r1891 | diewald | 2015-11-30 17:57:59 MEZ - -org.fortiss.af3.exploration.alg: -- Now really disable VL debug graph generation. ----------------------------------------------------------------------------- -r1890 | diewald | 2015-11-30 17:57:28 MEZ - -org.fortiss.af3.exploration.alg: -- Now really disable VL debug graph generation. ----------------------------------------------------------------------------- -r1889 | diewald | 2015-11-30 17:54:39 MEZ - -org.fortiss.af3.exploration.alg: -- Disable VL debug graph generation. -- Cleanup. ----------------------------------------------------------------------------- -r1888 | diewald | 2015-11-30 17:49:41 MEZ - -org.fortiss.af3.exploration.alg (/ui): -- Init work for repair methods. -- Additional X-over operator. -- All evaluators now return Value<?>s (more generic). -- Ext. to implicit constr. gen. -- Cleanup. -- More robust solution handling. ----------------------------------------------------------------------------- -r1881 | diewald | 2015-11-27 14:52:24 MEZ - -org.fortiss.af3.exploration.alg: -- Add updated guice package in build properties. ----------------------------------------------------------------------------- -r1878 | diewald | 2015-11-27 14:31:44 MEZ - -org.fortiss.af3.exploration.alg: -- Add guice-assistedinject package in build properties. ----------------------------------------------------------------------------- -r1877 | diewald | 2015-11-27 14:30:43 MEZ - -org.fortiss.af3.exploration.alg: -- Update guice to version 4.0. -- Add guice-assistedinject package. ----------------------------------------------------------------------------- -r1867 | diewald | 2015-11-25 19:29:35 MEZ - -org.fortiss.af3.exploration.alg: -- Intermediate version of the bug fix for VirtualLink generation: - * Connector graph is correct now. - * Fixed issue: One vertex (an offchip connector is present in the graph that should not be there). - * INVALID ISSUE: Some "hull" connectors are present in the graph that should not be there. -> These Connectors are not present in the graph. - * REMAINING ISSUE: Needs heavy refactoring, many commented out code, modified logic, code duplication. ----------------------------------------------------------------------------- -r1859 | diewald | 2015-11-25 15:00:23 MEZ - -org.fortiss.af3.exploration.alg: -- Update evaluator for the SafetyComplianceSpecification to latest version of the safetystandards plugin (2015-11-25). -- Intermediate version of the bug fix for VirtualLink generation: - * Connector graph is correct (except 1 vertex & some other "hull" ports). - * Fixed issue: The BusMasterPort at receiving NIs is contained in the Route which should not be the case. - * Fixed issue: For inter-device communication, the predecessor connector is not remembered, but calculated on the fly. This in only valid for single link connections (respecting the direction). - * REMAINING ISSUE: One vertex (an offchip connector is present in the graph that should not be there). - * REMAINING ISSUE: Some "hull" connectors are present in the graph that should not be there. ----------------------------------------------------------------------------- -r1851 | diewald | 2015-11-25 10:32:11 MEZ - -org.fortiss.af3.exploration.alg: -- Intermediate version of the bug fix for VirtualLink generation: - * Connector graph is almost correct. - * REMAINING ISSUE: The BusMasterPort at receiving NIs is contained in the Route which should not be the case. - * REMAINING ISSUE: For inter-device communication, the predecessor connector is not remembered, but calculated on the fly. This in only valid for single link connections (respecting the direction). ----------------------------------------------------------------------------- -r1849 | diewald | 2015-11-24 14:42:43 MEZ - -org.fortiss.af3.exploration.alg: -- Add separate Copy modules for abstract and instantiated task mapping. -- Add decoding mechanism to instantiate the task mappings. An InstantiatedTaskMapping is now a Genotype AND a Phenotype. -- Fix bug with duplicated task graphs in the encodings. -- Add debug method to validate output from deployment generation (commented out). -- Initial work to fix the Virtual Link export (NOT WORKING CORRECTLY YET, WORK IN PORGRESS). -- Cleanup. ----------------------------------------------------------------------------- -r1842 | diewald | 2015-11-22 23:27:33 MEZ - -org.fortiss.af3.exploration.alg: -- Fix bug rel. to actually deployed components in the PeriodConstraint evaluator. ----------------------------------------------------------------------------- -r1837 | diewald | 2015-11-20 15:45:17 MEZ - -org.fortiss.af3.exploration.alg: -- Upload possibly forgotten jar again. ----------------------------------------------------------------------------- -r1830 | diewald | 2015-11-20 12:08:07 MEZ - -org.fortiss.af3.exploration.alg: -- Finalize the modifications for the export of Deployments and its corresponding ComponentArchitecture with support for instantiated components while providing a multimap that associates the components from the input model to the components of the generated architecture. -- Cleanup. ----------------------------------------------------------------------------- -r1820 | barner | 2015-11-20 09:36:33 MEZ - -- Create and initialize PortMapping for VirtualLinks sender and receiver ports in createVlSementsWithPorts() ----------------------------------------------------------------------------- -r1811 | barner | 2015-11-19 15:53:54 MEZ - -- Fix typo in method name ----------------------------------------------------------------------------- -r1802 | diewald | 2015-11-19 15:23:22 MEZ - -org.fortiss.af3.exploration.alg: -- Update AF3 adapters to match definition of data size in bytes of VLs. ----------------------------------------------------------------------------- -r1793 | diewald | 2015-11-19 14:23:44 MEZ - -org.fortiss.af3.exploration.alg: -- Prevent initialization of util classes. -- Cleanup. ----------------------------------------------------------------------------- -r1791 | diewald | 2015-11-19 13:59:53 MEZ - -org.fortiss.af3.exploration.alg: -- Adopt latest modifications from SafetyConstraintChecker. ----------------------------------------------------------------------------- -r1778 | diewald | 2015-11-19 10:56:09 MEZ - -org.fortiss.af3.exploration.alg: -- Add export of Google Guava jar. -- Add export for the collector package of Google Guava. -- Generate a association map that relates components of the input component architecture to the DSE with a possibly generated component architecture when exporting the results as an AF3 deployment. ----------------------------------------------------------------------------- -r1775 | barner | 2015-11-18 17:41:04 MEZ - -- Move the following VirtualLink annotations (+ value providers + the universally applicable registrations) from eu.dreamsproject.psm to org.fortiss.af3.deployment - - PsmPortAccessRights -> TransceiverPortAccessRights - - PsmPortDirection -> TransceiverPortDirection - - PsmPortSemantics -> TransceiverPortSemantics - - VlPayloadSize - - VlSender - - VlReceivers - - VlTempRepetition - - VlTrafficType -- Also move the corresponding EENumns - - TrafficType - - TrafficDirection - - PortSemantics -- Eliminate psm.ecore//#Time (in favour of timing.ecore//#Time) -- TODO: Unify (scheduling.ecore//#Time with timing.ecore//#Time). - -- This changes also adds the new plugin https://source.fortiss.org/svn/dreams/src/af3/trunk/org.fortiss.af3.timing.edit - ----------------------------------------------------------------------------- -r1768 | barner | 2015-11-18 11:43:16 MEZ - -- Remove from org.fortiss.af3.timing (#2388) - - model/timing.ecore - - ComponentInstruction - - TimingRequirementsPeriod - - WcetWcett - - Value providers - - Most importantly, this allows to remove the dependency from af3.timing to af3.deployment - -- Remove the following outdated migrators (that have been shipped with 2.8 and (some even for 2.7?)) - that directly or indirectly depended on the above types - - org.fortiss.af3.timing.migration.WcetDeploymentParameterMigrator - - org.fortiss.af3.scheduling.migration.MemorySpecToAnnotationMigration - - org.fortiss.af3.scheduling.migration.ResourceTableToAnnotationMigrationProvider - - org.fortiss.af3.exploration.alg.migration.RemoveTimingRequirementPeriodMigrationProvider - - eu.dreamsproject.platform.migration.EnergyParameterMigrator - -- org.fortiss.af3.deployment - - Move registration of Wcet annotation for org.fortiss.af3.deployment.model.DeploymentParameterValue here. Adds dependency to af3.timing - -- org.fortiss.af3.scheduling.utils.SpecificationsUtils - - Remove unused utility methods - - Remove utility methods that have effectively been a NOP since the underlying annotations have been a NOP. - Instead of keeping the methods, modify the (few) callers that already worked around the issue by using default values (most notably org.fortiss.af3.scheduling.modeltransformation.DAGExtractionWithoutDeployment - and org.fortiss.af3.efficientdeployment.ui.wizard.{deployment.DeploymentGenerationWizardPage3Backend, scheduling.ScheduleGenerationWizardPageParametersOverviewBackend}: - - Directly use the default value - - Remove NOP call to deprecated method - - Add TODO -refs 2388 - ----------------------------------------------------------------------------- -r1766 | diewald | 2015-11-18 10:06:05 MEZ - -org.fortiss.af3.exploration.alg: -- Add a check and verbose output if the SafetyComplianceConstraint evaluation fails. ----------------------------------------------------------------------------- -r1760 | diewald | 2015-11-17 10:25:21 MEZ - -org.fortiss.af3.exploration.alg: -- Comply with latest interface change of the safety constraint checker: Do not generate a safetycomplianceconstraint file when being triggered from the DSE. ----------------------------------------------------------------------------- -r1753 | diewald | 2015-11-16 16:02:13 MEZ - -org.fortiss.af3.exploration: -- Prevent the creation of an UnsupportedOperationException if getLimitation() is not implemented by a concrete constraint. Instead, a compilation error is shown. ----------------------------------------------------------------------------- -r1743 | diewald | 2015-11-16 09:13:38 MEZ - -org.fortiss.af3.exploration.alg: -- Reset ids of model elements for the generated component architecture only if the deployment & component architecture are exported into the AF3 project. For generated architectures, the IDs can be used to identify equivalent components in the original architecture and the generated one. -- Improve the safety compliance constraint penalty function. ----------------------------------------------------------------------------- -r1740 | barner | 2015-11-13 16:00:04 MEZ - -- ExplorationUtils.getAF3HardwarePlatform() -> PlatformArchitectureUtils.getPhysicalPlatformArchitecture() -- ExplorationUtils.getResourceReferences(IPlatformResource) -> PlatformArchitectureUtils.getResourceReferences(IModelElement) ----------------------------------------------------------------------------- -r1739 | barner | 2015-11-13 15:32:51 MEZ - -- Move getFirstChildWithType() from ExplorationUtils to EcoreUtils ----------------------------------------------------------------------------- -r1737 | barner | 2015-11-13 15:16:40 MEZ - -- Move DreamsPlatformUtils.getParentElements() -> KernelModelElementUtils ----------------------------------------------------------------------------- -r1736 | barner | 2015-11-13 15:11:45 MEZ - -Move DreamsPlatformUtils.{disableNotificationsOf(), enableNotificationsOf(), setNotificationsOf()} to EcoreUtils ----------------------------------------------------------------------------- -r1735 | barner | 2015-11-13 15:04:16 MEZ - -- Move DreamsPlatformUtils.getReferencedElementsWithType() and .getThisAndParentReferencedElementsWithType() to -PlatformArchitectureUtils ----------------------------------------------------------------------------- -r1732 | diewald | 2015-11-13 13:15:39 MEZ - -org.fortiss.af3.exploration.alg: -- Disable verbose debug output for safetycomlianceconstraint evaluator. ----------------------------------------------------------------------------- -r1729 | diewald | 2015-11-13 12:03:26 MEZ - -org.fortiss.af3.exploration.(alg/edit/ui): -- Adopt changes from the exploration MM. -- Modify the SafetyIntegrityLevel evaluator to use the getLimitation method (impl example). -- Adjust the weighting function of SafetyComplianceLevel evaluator (More steep for small violation to enforce zero violations). -- Re-implement priorities for MO/Vector optimization: Highest prio to constraints (same classes have the same prio), Priorities from the exploration objectives are taken from the model (with an offset to prios of the constraints). ----------------------------------------------------------------------------- -r1677 | diewald | 2015-11-10 17:17:41 MEZ - -org.fortiss.af3.exploration.alg: -- Revert to previous PsmPort generation in the VL export. ----------------------------------------------------------------------------- -r1674 | diewald | 2015-11-10 13:54:51 MEZ - -org.fortiss.af3.exploration.alg: -- Finish refactoring of the Virtual Link export. -- Cleanup. ----------------------------------------------------------------------------- -r1669 | diewald | 2015-11-10 10:52:21 MEZ - -org.fortiss.af3.exploration.alg: -- Remove accidentially commited uml diagrams. ----------------------------------------------------------------------------- -r1668 | diewald | 2015-11-10 10:49:02 MEZ - -org.fortiss.af3.exploration.alg: -- Fix duplicate TransceiverPort generation for Virtual Link export. ----------------------------------------------------------------------------- -r1662 | diewald | 2015-11-10 09:57:56 MEZ - -org.fortiss.exploration.alg: -- Refactoring of VL generation code. ----------------------------------------------------------------------------- -r1658 | diewald | 2015-11-09 17:36:37 MEZ - -org.fortiss.af3.exploration.alg: -- Cleanup and refactoring in the VirtualLink export. ----------------------------------------------------------------------------- -r1656 | diewald | 2015-11-09 15:38:35 MEZ - -org.fortiss.exploration.alg: -- Do not generate Virtual Links for aperiodic messages (as written in D1.2.1 - DREAMS architectural style). ----------------------------------------------------------------------------- -r1639 | diewald | 2015-11-09 10:09:41 MEZ - -org.fortiss.af3.exploration.alg: -- Enable the DSE to be executed using timing models that do not define periods.This allows VL generation for arbitrary DREAMS systems. -- Add a utility method to easily identify type correspondences in adapters & model transformations. -- Improve exception handling in the SystemModelAdpater. ----------------------------------------------------------------------------- -r1635 | barner | 2015-11-09 09:14:40 MEZ - -- Move org.fortiss.af3.exploration.alg.utils.MathUtils -> org.fortiss.af3.schedule.utils.MathUtils in order to enable is use in the eu.dreamsproject.psm ----------------------------------------------------------------------------- -r1634 | barner | 2015-11-09 09:09:16 MEZ - -- Style cleanup (no functional change) ----------------------------------------------------------------------------- -r1607 | barner | 2015-11-05 18:32:49 MEZ - -- Rename VlTypePart -> VlTrafficType -- Eliminate VlTempDeviation. Phase and jitter are described in the corresponding Triggers of a schedule instead ----------------------------------------------------------------------------- -r1605 | diewald | 2015-11-05 17:48:11 MEZ - -org.fortiss.af3.exploration.alg: -- Enable processing of input models which are non-periodic (to generate VLs). ----------------------------------------------------------------------------- -r1600 | diewald | 2015-11-05 17:01:01 MEZ - -org.fortiss.af3.exploration.alg: -- Align with SafetyConstraintChecker changes to suppress output when being called from the DSE. ----------------------------------------------------------------------------- -r1597 | diewald | 2015-11-05 15:10:23 MEZ - -org.fortiss.af3.exploration.alg: -- Add some documentation. ----------------------------------------------------------------------------- -r1594 | diewald | 2015-11-05 13:44:29 MEZ - -org.fortiss.af3.exploration.alg: -- Fix build error. -- Annotate generated VirtualLinks with their type, e.g. TimeTriggered, based on the Signal Type. -- Defined a Signal Type which is attached to ISignalAdapters to allow non-time triggered signaling. These types are currently read from a DREAMS timing model. ----------------------------------------------------------------------------- -r1580 | diewald | 2015-11-05 09:06:45 MEZ - -org.fortiss.af3.exploration.alg: -- Fix the instantiation of IKL's safety constraint checker in the evaluator. ----------------------------------------------------------------------------- -r1562 | diewald | 2015-11-04 09:13:35 MEZ - -org.fortiss.af3.exploration.alg: -- Build jar file only if the needed files are present to prevent creation of garbage (=empty) jar. ----------------------------------------------------------------------------- -r1533 | barner | 2015-10-30 10:53:56 MEZ - -- Rename package eu.dreamsproject.psm.util -> eu.dreamsproject.psm.utils ----------------------------------------------------------------------------- -r1522 | diewald | 2015-10-28 18:07:19 MEZ - -org.fortiss.af3.exploration.alg: -- Fix: Do not try to get a period for components that are not specified in a PeriodicConstraint. ----------------------------------------------------------------------------- -r1517 | barner | 2015-10-28 00:07:41 MEZ - -- psm.ecore - - DreamsVirtualLinkId -> VirtualLinkId - - Use VirtualLinkId, TrafficType, Time also for annotations, i.e. retire VlType eenum defined in annotation.virtuallink package ----------------------------------------------------------------------------- -r1492 | diewald | 2015-10-23 18:08:10 MESZ - -org.fortiss.af3.exploration.alg: -- Preparational work to support non-periodic Virtual Links. ----------------------------------------------------------------------------- -r1485 | diewald | 2015-10-23 14:39:16 MESZ - -org.fortiss.af3.exploration.alg: -- Rename IMessageAdapter and AF3MessageAdapter to ISignalAdapter and AF3SignalAdapter ----------------------------------------------------------------------------- -r1482 | diewald | 2015-10-23 09:29:05 MESZ - -org.fortiss.af3.exploration.alg: -- Fix a concurrent access issue. -- Add support for threaded execution (eclipse Job) of the DSE for deployments to generate virtual links. -- Minor cleanups. - -eu.dreamsproject.deployment.ui: -- Launch the Virtual Link generation in its own Job to not block the UI. ----------------------------------------------------------------------------- -r1448 | diewald | 2015-10-20 14:52:23 MESZ - -org.fortiss.af3.exploration.alg: -- Fill Virtual Link annotations with values. ----------------------------------------------------------------------------- -r1436 | diewald | 2015-10-20 11:31:04 MESZ - -eu.dreamsproject.deployment.ui: -- Minor improvements to the VirtualLink editor. -org.fortiss.af3.deployment: -- Implement decomposition of RoutingAllocations/VirtualLinks/Segments. -org.fortiss.af3.exploration(.alg/.ui): -- Bug fix to allow model creation from the UI. -- Fix ConcurrentModificationException in exploration.alg. -- Set some default parameters in the Exploration MM. ----------------------------------------------------------------------------- -r1416 | barner | 2015-10-19 16:15:35 MESZ - -- Add ANT task that can be used to create a JAR file bundeling a compiled version of this plugin's source code. -- Add Eclipse builder configuration that automatically triggers the ANT task when the src/ or META-INF/ folder is modified. -- Add initial version of lib/org.fortiss.af3.exploration.alg.jar and register it in the classpath ----------------------------------------------------------------------------- -r1414 | diewald | 2015-10-18 15:13:57 MESZ - -org.fortiss.af3.exploration -- Improve VirtualLink generation -- Initial work to let DSE run in a separate thread for programatically launched DSE runs. -eu.dreamsproject.psm: -- Make VlSender & -Receivers annotations DerivedAnnotations ----------------------------------------------------------------------------- -r1408 | diewald | 2015-10-15 11:23:21 MESZ - -org.fortiss.af3.exploration(.*): -- Add support to generate VirtualLinks for a given Deployment: - * Add support code to launch the DSE with FixedDeploymentConstraints only. - * Add support to create a SystemModelAdapter from a given Deployment. -- Improved handling of DREAMS timing models. -eu.dreamsproject.deployment.ui: -- Correct wrong illustration of VirtualLinks. -- Adaptions to latest MM changes. - ----------------------------------------------------------------------------- -r1407 | barner | 2015-10-14 13:40:38 MESZ - -- Redesign PsmPorts - - Automatic assignment during routing - - Stored as TransceiverPortAllocations - - Implement concrete types for DREAMS use cases: partition, NI, etc. -- VLs: Segments can be charaterized by either a TranceiverPort or a Transceiver ----------------------------------------------------------------------------- -r1406 | barner | 2015-10-14 12:52:10 MESZ - -- Fix typo in message ----------------------------------------------------------------------------- -r1401 | barner | 2015-10-13 10:16:35 MESZ - -org.fortiss.af3.deployment - - deployment.ecore - - Hook TransceiverPortAllocation into Deployment root object - - TransceiverAllocation - - Extend with optional 'transceiverPort' field. - - TODO: In the long run, deprecate 'transceiver' with this new 'transceiverPort' field - - Set minimum cardinality of 'port' and 'transceiver' to 1 - - Segment - - transceiverPortAllocation -> transceiverPort - - Do not define as containment. TransceiverPorts are owned by TransceiverPortAllocations - - Add some documentation to affected classes. - - DeploymentModelElementFactory - - Add createTransceiverPort() - -- eu.dreamsproject.psm - - Adjust to deployment changes - - TODO: DreamsPsmModelElementFactory.createTransceiverPort(): Define and use TransceiverPorts required for DREAMS platform - -- org.fortiss.af3.exploration.alg / org.fortiss.af3.deployment.ui - - Adjust to deployment changes ----------------------------------------------------------------------------- -r1397 | diewald | 2015-10-12 11:15:57 MESZ - -org.fortiss.af3.exploration.alg: -- Limit debug output. ----------------------------------------------------------------------------- -r1395 | diewald | 2015-10-09 16:37:14 MESZ - -org.fortiss.af3.exploration.alg: -- Improve the creation of the Virtual Links: The required model elements are now created entirely in the PSM/Deployment plugins. -- Fix the deadline calculation to respect diverse implementations of the referenced start/end components. -- Minor fix to the AcyclicTaskGraph. ----------------------------------------------------------------------------- -r1385 | diewald | 2015-10-08 11:52:44 MESZ - -org.fortiss.af3.exploration(.*): -- Prepare the Exploration MM for becoming the base model in AF3: - * Rename some EClasses (Optimization... -> Exploration...). - * Cleanup the references: ExplorationTargets are not referenced by problem dimensions any more, but directly through the ExplorationSpecification as it was originally intended. - * Adjust the algorithmic part of the DSE to these modifications. -- Introduce "Hidden" Constraints which are constructed based on the input models. These constraints are added to the Exploration specification to allow future tracking in a DSE history (see AF3 DSE). -- Separate the DeadlineConstraint into a "real" deadline constraint and a PeriodConstraint which is a HiddenConstraint and calculated from the SystemModelAdapter. -- Fix a concurrency issue related to attaching task graphs to encodings. ----------------------------------------------------------------------------- -r1365 | diewald | 2015-10-05 15:17:39 MESZ - -org.fortiss.af3.exploration(.*): -- Make the OptimizationConstraint use Generics. -- Add Eops to retrieve the bounds of constraints and the allowed relaxations. -- Improve & simplify the calculation of the acyclic task graphs. ----------------------------------------------------------------------------- -r1360 | diewald | 2015-09-30 12:52:17 MESZ - -org.fortiss.af3.exploration.alg: -- Fix a bug in the lcm calculation used for hyperperiod calculation. ----------------------------------------------------------------------------- -r1358 | diewald | 2015-09-26 11:11:01 MESZ - -org.fortiss.af3.exploration.alg: -- Fix gcd calculation if period < 1. ----------------------------------------------------------------------------- -r1327 | diewald | 2015-09-24 09:53:55 MESZ - -org.fortiss.af3.exploration.alg: -- Fix memory leak in the TaskMappingEncoding. The allocationMap was not cleared, when a new mapping was set. ----------------------------------------------------------------------------- -r1321 | barner | 2015-09-22 17:49:35 MESZ - -- Re-add .jars to bin.includes (lost when splitting plugin into DSE goal model and algorithmic plugin) ----------------------------------------------------------------------------- -r1311 | diewald | 2015-09-21 16:04:12 MESZ - -Move the Compositors from the UI the model plugins. -refs 2228 - ----------------------------------------------------------------------------- -r1293 | diewald | 2015-09-18 14:45:49 MESZ - -Update all DREAMS-related plugins to Java 8. ----------------------------------------------------------------------------- -r1285 | barner | 2015-09-16 21:40:58 MESZ - -- createDefaultSafetyComplianceConstraint(): SafetyComplianceConstraint has been removed from SafetyComplianceConstraint.ecore in eu.dreamsproject.ikerlan.safetystandards ----------------------------------------------------------------------------- -r1254 | diewald | 2015-09-11 11:25:10 MESZ - -org.fortiss.af3.exploration.alg: -- Add pom.xml for integration into jenkins build. ----------------------------------------------------------------------------- -r1253 | diewald | 2015-09-11 11:02:41 MESZ - -org.fortiss.af3.exploration(.alg): -- Move the PrototypeProvider back to the model plugin, such that DSE models can be instantiated from the context menu again. -- Cleanups. ----------------------------------------------------------------------------- -r1249 | diewald | 2015-09-10 16:54:25 MESZ - -Separation of the model of the model and the algorithmic part of the org.fortiss.af3.exploration plugin: -- The model remains in the org.fortiss.af3.exploration plugin to remain compatible with the existing models. -- The algorithmic part (the content of the src folder) is now contained in a plugin called org.fortiss.af3.exploration.alg. -- The SafetyComplianceConstraint has been removed from the exploration model and placed in the appropriate IKL-plugin. It is made accessible by the from the .ui plugin. ----------------------------------------------------------------------------- -r1244 | diewald | 2015-09-10 11:59:08 MESZ - -org.fortiss.af3.exploration.alg: -- Initial commit of the (yet empty) af3 plugin containing algorithms for the DSE. ----------------------------------------------------------------------------- -r1243 | diewald | 2015-09-10 11:29:08 MESZ - -Create project folder for algorithmic part of the exploration. ----------------------------------------------------------------------------- diff --git a/org.fortiss.af3.exploration.alg/master/lib/aopalliance-1.0.jar b/org.fortiss.af3.exploration.alg/master/lib/aopalliance-1.0.jar deleted file mode 100644 index 578b1a0c359ef88a84461bdb91d9d0041afd54de..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/aopalliance-1.0.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/apfloat.jar b/org.fortiss.af3.exploration.alg/master/lib/apfloat.jar deleted file mode 100644 index 72055b008c415415c031e08a75e91a19ba9691b8..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/apfloat.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/asm-3.1.jar b/org.fortiss.af3.exploration.alg/master/lib/asm-3.1.jar deleted file mode 100644 index 8217cae0a1bc977b241e0c8517cc2e3e7cede276..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/asm-3.1.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/cglib-2.2.1-v20090111.jar b/org.fortiss.af3.exploration.alg/master/lib/cglib-2.2.1-v20090111.jar deleted file mode 100644 index cfd5ae7273729999ca32ba6bfa761f522cce6dbc..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/cglib-2.2.1-v20090111.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/commons-collections4-4.1-javadoc.jar b/org.fortiss.af3.exploration.alg/master/lib/commons-collections4-4.1-javadoc.jar deleted file mode 100644 index e050a31ba3bc26b96a9d25b3a1611a0fbae82dbf..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/commons-collections4-4.1-javadoc.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/commons-collections4-4.1.jar b/org.fortiss.af3.exploration.alg/master/lib/commons-collections4-4.1.jar deleted file mode 100644 index 43a9413b930b0f474efd2817c195ef2a88d7f7b2..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/commons-collections4-4.1.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/guava-19.0-sources.jar b/org.fortiss.af3.exploration.alg/master/lib/guava-19.0-sources.jar deleted file mode 100644 index 633c3157dcb937fa5f3fdeb9f243e79643807893..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/guava-19.0-sources.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/guava-19.0.jar b/org.fortiss.af3.exploration.alg/master/lib/guava-19.0.jar deleted file mode 100644 index b175ca867fe4320dfcf53877ec5984d49ce401e3..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/guava-19.0.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/guice-4.0-sources.jar b/org.fortiss.af3.exploration.alg/master/lib/guice-4.0-sources.jar deleted file mode 100644 index 2e9e7f6e3350a55e831c164dac033590bea048f7..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/guice-4.0-sources.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/guice-4.0.jar b/org.fortiss.af3.exploration.alg/master/lib/guice-4.0.jar deleted file mode 100644 index f4fc9ffd26def00267bd1eda11f088a32ccbfe1f..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/guice-4.0.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/guice-assistedinject-4.0-sources.jar b/org.fortiss.af3.exploration.alg/master/lib/guice-assistedinject-4.0-sources.jar deleted file mode 100644 index 7b14a9f67737d0ab960d7397a60da48c0a016726..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/guice-assistedinject-4.0-sources.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/guice-assistedinject-4.0.jar b/org.fortiss.af3.exploration.alg/master/lib/guice-assistedinject-4.0.jar deleted file mode 100644 index e890f2c3ed69d8006ba38167dd326314e8e7e1bf..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/guice-assistedinject-4.0.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/guice-multibindings-4.0-sources.jar b/org.fortiss.af3.exploration.alg/master/lib/guice-multibindings-4.0-sources.jar deleted file mode 100644 index 8b1ac090b53dede5b94490c641b2b34ba5c411de..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/guice-multibindings-4.0-sources.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/guice-multibindings-4.0.jar b/org.fortiss.af3.exploration.alg/master/lib/guice-multibindings-4.0.jar deleted file mode 100644 index e0d3e57f79c3d311f443028a841b6a1055d7c888..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/guice-multibindings-4.0.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/javax.inject-1.jar b/org.fortiss.af3.exploration.alg/master/lib/javax.inject-1.jar deleted file mode 100644 index b2a9d0bf7bd463a6361898b36f010edd05c0cf6e..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/javax.inject-1.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/jgraph-5.13.0.0.jar b/org.fortiss.af3.exploration.alg/master/lib/jgraph-5.13.0.0.jar deleted file mode 100644 index a85374053ff73cb28e39a3a9fb2a42cdf087b88f..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/jgraph-5.13.0.0.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/jgrapht-0.9.0-src.jar b/org.fortiss.af3.exploration.alg/master/lib/jgrapht-0.9.0-src.jar deleted file mode 100644 index 1c5c5c91460cc81a3ace08f2b72ad42697c59c5f..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/jgrapht-0.9.0-src.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/jgrapht-core-0.9.0.jar b/org.fortiss.af3.exploration.alg/master/lib/jgrapht-core-0.9.0.jar deleted file mode 100644 index 88aecca16086b067886a08cb415e384ea8bcda35..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/jgrapht-core-0.9.0.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/jgrapht-ext-0.9.0.jar b/org.fortiss.af3.exploration.alg/master/lib/jgrapht-ext-0.9.0.jar deleted file mode 100644 index a0dc32a1777a81a884923605dfa152bc74be96fd..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/jgrapht-ext-0.9.0.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/jgraphx-2.0.0.1.jar b/org.fortiss.af3.exploration.alg/master/lib/jgraphx-2.0.0.1.jar deleted file mode 100644 index 7b36c99f26054c961c9f7e38395690b05473a39f..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/jgraphx-2.0.0.1.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/licenses/COPYING b/org.fortiss.af3.exploration.alg/master/lib/licenses/COPYING deleted file mode 100644 index 3ca70f2406dc10697dc36ea103788bc2fd6893dc..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/lib/licenses/COPYING +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/org.fortiss.af3.exploration.alg/master/lib/licenses/guice.txt b/org.fortiss.af3.exploration.alg/master/lib/licenses/guice.txt deleted file mode 100644 index 75b52484ea471f882c29e02693b4f02dba175b5e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/lib/licenses/guice.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/org.fortiss.af3.exploration.alg/master/lib/licenses/mersennetwister.txt b/org.fortiss.af3.exploration.alg/master/lib/licenses/mersennetwister.txt deleted file mode 100644 index fe57568792d477943711b6fc1794334043769564..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/lib/licenses/mersennetwister.txt +++ /dev/null @@ -1,5 +0,0 @@ -The Mersenne Twister random number generator by David Beaumont -is licensed under the GNU LGPL (http://www.gnu.org/copyleft/lesser.html). - -http://goui.net/ - diff --git a/org.fortiss.af3.exploration.alg/master/lib/licenses/prettify.txt b/org.fortiss.af3.exploration.alg/master/lib/licenses/prettify.txt deleted file mode 100644 index 75b52484ea471f882c29e02693b4f02dba175b5e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/lib/licenses/prettify.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/org.fortiss.af3.exploration.alg/master/lib/licenses/sat4j.txt b/org.fortiss.af3.exploration.alg/master/lib/licenses/sat4j.txt deleted file mode 100644 index f5b7702243b4b6940c10f1c4b9206aad748e4569..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/lib/licenses/sat4j.txt +++ /dev/null @@ -1,502 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - <one line to give the library's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - <signature of Ty Coon>, 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! \ No newline at end of file diff --git a/org.fortiss.af3.exploration.alg/master/lib/opt4j-core-3.1.3.jar b/org.fortiss.af3.exploration.alg/master/lib/opt4j-core-3.1.3.jar deleted file mode 100644 index 715589f9c201ae455c5cf71bf53d508e6ca247b1..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/opt4j-core-3.1.3.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/opt4j-operators-3.1.3.jar b/org.fortiss.af3.exploration.alg/master/lib/opt4j-operators-3.1.3.jar deleted file mode 100644 index e35f0fd3a5a749882d2173321607a438b43c1334..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/opt4j-operators-3.1.3.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/opt4j-optimizers-SNAPSHOT-20161006.jar b/org.fortiss.af3.exploration.alg/master/lib/opt4j-optimizers-SNAPSHOT-20161006.jar deleted file mode 100644 index b29e6b6e486da93d54be70e0a14dfe7bc15093a3..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/opt4j-optimizers-SNAPSHOT-20161006.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/opt4j-optimizers-SNAPSHOT-20161110-sources.jar b/org.fortiss.af3.exploration.alg/master/lib/opt4j-optimizers-SNAPSHOT-20161110-sources.jar deleted file mode 100644 index 9759e21327c8f074f0c24389312c07ec6e6ee4fe..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/opt4j-optimizers-SNAPSHOT-20161110-sources.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/opt4j-optimizers-SNAPSHOT-20161110.jar b/org.fortiss.af3.exploration.alg/master/lib/opt4j-optimizers-SNAPSHOT-20161110.jar deleted file mode 100644 index 28737ea225984f076b05eb7d066dfd162ac18855..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/opt4j-optimizers-SNAPSHOT-20161110.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/opt4j-satdecoding-3.1.3.jar b/org.fortiss.af3.exploration.alg/master/lib/opt4j-satdecoding-3.1.3.jar deleted file mode 100644 index 988f8c23e5a3fb21ec3397a575af1474c5338be2..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/opt4j-satdecoding-3.1.3.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/opt4j-source-3.1.3.jar b/org.fortiss.af3.exploration.alg/master/lib/opt4j-source-3.1.3.jar deleted file mode 100644 index bd5a8128d4314d048b039bf9d3e8866b30cd14b0..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/opt4j-source-3.1.3.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/opt4j-viewer-3.1.3.jar b/org.fortiss.af3.exploration.alg/master/lib/opt4j-viewer-3.1.3.jar deleted file mode 100644 index f9c38cc45d1103269eb31422f87d136125a5f1ee..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/opt4j-viewer-3.1.3.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/org.ow2.sat4j.core-2.3.3.jar b/org.fortiss.af3.exploration.alg/master/lib/org.ow2.sat4j.core-2.3.3.jar deleted file mode 100644 index 41a9df30d2df763ae0511985a385daf1f251ec4d..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/org.ow2.sat4j.core-2.3.3.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/lib/org.ow2.sat4j.pb-2.3.3.jar b/org.fortiss.af3.exploration.alg/master/lib/org.ow2.sat4j.pb-2.3.3.jar deleted file mode 100644 index d1775b843a512176e0d49d6110a4ae80452031c1..0000000000000000000000000000000000000000 Binary files a/org.fortiss.af3.exploration.alg/master/lib/org.ow2.sat4j.pb-2.3.3.jar and /dev/null differ diff --git a/org.fortiss.af3.exploration.alg/master/model/common.ecore b/org.fortiss.af3.exploration.alg/master/model/common.ecore deleted file mode 100644 index 5c67982a4dce1ddad4b345bae7cadf60a65a338b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/model/common.ecore +++ /dev/null @@ -1,205 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="model" nsURI="http://www.fortiss.org/af3/exploration/common" - nsPrefix="org-fortiss-af3-exploration-common"> - <eClassifiers xsi:type="ecore:EClass" name="MOExplorationObjective" abstract="true" - interface="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="{@link ExplorationObjective} suitable for the definition of Multi-Objective DSE problems."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="priority" lowerBound="1" - eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Defines the weighting of a single {@MOExplorationObjective} instance that is relevant for the backend solver."/> - </eAnnotations> - </eStructuralFeatures> - <eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationObjective"> - <eTypeArguments eTypeParameter="#//MOExplorationObjective/T"/> - </eGenericSuperTypes> - </eClassifiers> - <eSubpackages name="location" nsURI="http://www.fortiss.org/af3/exploration/common/location" - nsPrefix="org-fortiss-af3-exploration-common-location"> - <eClassifiers xsi:type="ecore:EClass" name="LocationDimension" abstract="true" - interface="true" eSuperTypes="platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//IProblemDimension"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="{@link IProblemDimension} to mark {@link ExplorationTarget}s that describe the location of requesters to resources, e.g. {@link Component}s to {@link IPlatformResource}s."/> - </eAnnotations> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="LocationConstraint" eSuperTypes="#//location/LocationDimension explorationDsl.ecore#//MOEAExplorationExpression"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY. {@link ExplorationConstraint} to define limitations on the location of requesters to resources, e.g., {@link Component}s to {@link IPlatformresource}s."/> - </eAnnotations> - <eTypeParameters name="LHT"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eTypeParameters name="RHT"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eOperations name="getLeftModelElement" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY. Returns the left hand {@link IModelElement} referenced in the pattern of {@code this} constraint."/> - <details key="body" value="return LocationConstraintStaticImpl.getLeftModelElement(this);"/> - </eAnnotations> - <eGenericType eTypeParameter="#//location/LocationConstraint/LHT"/> - </eOperations> - <eOperations name="getRightModelElement" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY. Returns the right hand {@link IModelElement} referenced in the pattern of {@code this} constraint."/> - <details key="body" value="return LocationConstraintStaticImpl.getRightModelElement(this);"/> - </eAnnotations> - <eGenericType eTypeParameter="#//location/LocationConstraint/RHT"/> - </eOperations> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ComponentAllocationConstraint"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericSuperTypes eClassifier="#//location/LocationConstraint"> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ExecutionUnit"/> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationConstraint"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBooleanObject"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ComponentDislocationConstraint"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericSuperTypes eClassifier="#//location/LocationConstraint"> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ExecutionUnit"/> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationConstraint"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBooleanObject"/> - </eGenericSuperTypes> - </eClassifiers> - </eSubpackages> - <eSubpackages name="time" nsURI="http://www.fortiss.org/af3/exploration/common/time" - nsPrefix="org-fortiss-af3-exploration-common-time"> - <eClassifiers xsi:type="ecore:EClass" name="TimeDimension" abstract="true" interface="true" - eSuperTypes="platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//IProblemDimension"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="{@link IProblemDimension} to mark {@link ExplorationTarget}s that operate on temporal properties."/> - </eAnnotations> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="DeadlineConstraint"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="TODO: write documentation (in the model!)"/> - </eAnnotations> - <eOperations name="getLimitation" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="body" value="return getDeadline();"/> - <details key="documentation" value="TODO: write documentation (in the model!)"/> - </eAnnotations> - </eOperations> - <eOperations name="getStartComponent" lowerBound="1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Returns the {@link Component} whose start execution time defines the beginning of the deadline."/> - <details key="body" value="return DeadlineConstraintStaticImpl.getStartComponent(this);"/> - </eAnnotations> - </eOperations> - <eOperations name="setStartComponent" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Sets the {@link Component} whose start execution time defines the beginning of the deadline."/> - <details key="body" value="DeadlineConstraintStaticImpl.setStartComponent(this, component);"/> - </eAnnotations> - <eParameters name="component" lowerBound="1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - </eOperations> - <eOperations name="getEndComponent" lowerBound="1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Returns the {@link Component} whose execution end time must may not be beyond the deadline."/> - <details key="body" value="return DeadlineConstraintStaticImpl.getEndComponent(this);"/> - </eAnnotations> - </eOperations> - <eOperations name="setEndComponent" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Sets the {@link Component} whose execution end time must may not be beyond the deadline."/> - <details key="body" value="DeadlineConstraintStaticImpl.setEndComponent(this, component);"/> - </eAnnotations> - <eParameters name="component" lowerBound="1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - </eOperations> - <eOperations name="getDeadline" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Returns the deadline value that defines the maximally allowed latency between the start time of the start{@link Component} and the finish time of the end{@link Component}."/> - <details key="body" value="return DeadlineConstraintStaticImpl.getDeadline(this);"/> - </eAnnotations> - </eOperations> - <eOperations name="setDeadline" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Returns the deadline value that defines the maximally allowed latency between the start time of the start{@link Component} and the finish time of the end{@link Component}."/> - <details key="body" value="DeadlineConstraintStaticImpl.setDeadline(this, period);"/> - </eAnnotations> - <eParameters name="period" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"/> - </eOperations> - <eGenericSuperTypes eClassifier="#//time/TimeDimension"/> - <eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationConstraint"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"/> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="ecore:EClass explorationDsl.ecore#//MOEAExplorationExpression"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="LatencyCalc"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericSuperTypes eClassifier="ecore:EClass explorationDsl.ecore#//expressions/ArithmeticExpression"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="DeadlineComp"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericSuperTypes eClassifier="ecore:EClass explorationDsl.ecore#//operators/ComparisonOp"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"/> - <eTypeArguments eClassifier="#//time/LatencyCalc"/> - <eTypeArguments eClassifier="ecore:EClass explorationDsl.ecore#//types/NumberLiteral"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"/> - </eTypeArguments> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="PeriodConstraint"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eOperations name="getLimitation" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - <details key="body" value="return getPeriod();"/> - </eAnnotations> - </eOperations> - <eOperations name="getComponent" lowerBound="1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY. Returns the {@link Component} for which a defined period must hold."/> - <details key="body" value="return PeriodConstraintStaticImpl.getComponent(this);"/> - </eAnnotations> - </eOperations> - <eOperations name="setComponent" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY. Sets the {@link Component} for which a defined period must hold, i.e. the {@link Component} must be scheduled within this time frame."/> - <details key="body" value="PeriodConstraintStaticImpl.setComponent(this, component);"/> - </eAnnotations> - <eParameters name="component" lowerBound="1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - </eOperations> - <eOperations name="getPeriod" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY. Returns the period value which is defined in {@code this} {@link ExplorationConstraint}."/> - <details key="body" value="return PeriodConstraintStaticImpl.getPeriod(this);"/> - </eAnnotations> - </eOperations> - <eOperations name="setPeriod" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY. Sets the period which must be kept by this constraint's referenced {@link Component}, i.e. the {@link Component} must be scheduled within this time frame."/> - <details key="body" value="PeriodConstraintStaticImpl.setPeriod(this, period);"/> - </eAnnotations> - <eParameters name="period" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"/> - </eOperations> - <eGenericSuperTypes eClassifier="#//time/TimeDimension"/> - <eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationConstraint"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"/> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="ecore:EClass explorationDsl.ecore#//MOEAExplorationExpression"/> - </eClassifiers> - </eSubpackages> -</ecore:EPackage> diff --git a/org.fortiss.af3.exploration.alg/master/model/common.genmodel b/org.fortiss.af3.exploration.alg/master/model/common.genmodel deleted file mode 100644 index 45779878a98afe132d6e162510ee67feb4576a1c..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/model/common.genmodel +++ /dev/null @@ -1,61 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" - xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.fortiss.af3.exploration.alg/generated-src" - editDirectory="/org.fortiss.af3.exploration.edit.alg/generated-src" editorDirectory="/org.fortiss.af3.exploration.alg.editor/generated-src" - modelPluginID="org.fortiss.af3.exploration.alg" modelName="Model" editPluginClass="org.fortiss.af3.exploration.model.provider.ExplorationEditPlugin" - editorPluginClass="org.fortiss.af3.exploration.presentation.ExplorationEditorPlugin" - testsDirectory="/org.fortiss.af3.exploration.alg.tests/generated-src" importerID="org.eclipse.emf.importer.ecore" - containmentProxies="true" complianceLevel="5.0" copyrightFields="false" usedGenPackages="platform:/resource/org.fortiss.tooling.base/model/base.genmodel#//model platform:/resource/org.fortiss.af3.component/model/component.genmodel#//model explorationDsl.genmodel#//model platform:/resource/org.fortiss.af3.exploration/model/exploration.genmodel#//model platform:/resource/org.fortiss.af3.exploration/model/dsl_v2.genmodel#//model platform:/resource/org.fortiss.af3.expression/model/expression.genmodel#//model platform:/resource/org.fortiss.af3.platform/model/platform.genmodel#//model platform:/resource/org.fortiss.af3.project/model/project.genmodel#//model platform:/resource/org.fortiss.af3.safety/model/safety.genmodel#//model platform:/resource/org.fortiss.tooling.kernel/model/kernel.genmodel#//model"> - <foreignModel>common.ecore</foreignModel> - <genPackages prefix="Common" basePackage="org.fortiss.af3.exploration" disposableProviderFactory="true" - ecorePackage="common.ecore#/"> - <genClasses image="false" ecoreClass="common.ecore#//MOExplorationObjective"> - <genTypeParameters ecoreTypeParameter="common.ecore#//MOExplorationObjective/T"/> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute common.ecore#//MOExplorationObjective/priority"/> - </genClasses> - <nestedGenPackages prefix="Location" basePackage="org.fortiss.af3.exploration.model" - disposableProviderFactory="true" ecorePackage="common.ecore#//location"> - <genClasses image="false" ecoreClass="common.ecore#//location/LocationDimension"/> - <genClasses ecoreClass="common.ecore#//location/LocationConstraint"> - <genTypeParameters ecoreTypeParameter="common.ecore#//location/LocationConstraint/LHT"/> - <genTypeParameters ecoreTypeParameter="common.ecore#//location/LocationConstraint/RHT"/> - <genOperations ecoreOperation="common.ecore#//location/LocationConstraint/getLeftModelElement"/> - <genOperations ecoreOperation="common.ecore#//location/LocationConstraint/getRightModelElement"/> - </genClasses> - <genClasses ecoreClass="common.ecore#//location/ComponentAllocationConstraint"/> - <genClasses ecoreClass="common.ecore#//location/ComponentDislocationConstraint"/> - </nestedGenPackages> - <nestedGenPackages prefix="Time" basePackage="org.fortiss.af3.exploration.model" - disposableProviderFactory="true" ecorePackage="common.ecore#//time"> - <genClasses image="false" ecoreClass="common.ecore#//time/TimeDimension"/> - <genClasses ecoreClass="common.ecore#//time/DeadlineConstraint"> - <genOperations ecoreOperation="common.ecore#//time/DeadlineConstraint/getLimitation"/> - <genOperations ecoreOperation="common.ecore#//time/DeadlineConstraint/getStartComponent"/> - <genOperations ecoreOperation="common.ecore#//time/DeadlineConstraint/setStartComponent"> - <genParameters ecoreParameter="common.ecore#//time/DeadlineConstraint/setStartComponent/component"/> - </genOperations> - <genOperations ecoreOperation="common.ecore#//time/DeadlineConstraint/getEndComponent"/> - <genOperations ecoreOperation="common.ecore#//time/DeadlineConstraint/setEndComponent"> - <genParameters ecoreParameter="common.ecore#//time/DeadlineConstraint/setEndComponent/component"/> - </genOperations> - <genOperations ecoreOperation="common.ecore#//time/DeadlineConstraint/getDeadline"/> - <genOperations ecoreOperation="common.ecore#//time/DeadlineConstraint/setDeadline"> - <genParameters ecoreParameter="common.ecore#//time/DeadlineConstraint/setDeadline/period"/> - </genOperations> - </genClasses> - <genClasses ecoreClass="common.ecore#//time/LatencyCalc"/> - <genClasses ecoreClass="common.ecore#//time/DeadlineComp"/> - <genClasses ecoreClass="common.ecore#//time/PeriodConstraint"> - <genOperations ecoreOperation="common.ecore#//time/PeriodConstraint/getLimitation"/> - <genOperations ecoreOperation="common.ecore#//time/PeriodConstraint/getComponent"/> - <genOperations ecoreOperation="common.ecore#//time/PeriodConstraint/setComponent"> - <genParameters ecoreParameter="common.ecore#//time/PeriodConstraint/setComponent/component"/> - </genOperations> - <genOperations ecoreOperation="common.ecore#//time/PeriodConstraint/getPeriod"/> - <genOperations ecoreOperation="common.ecore#//time/PeriodConstraint/setPeriod"> - <genParameters ecoreParameter="common.ecore#//time/PeriodConstraint/setPeriod/period"/> - </genOperations> - </genClasses> - </nestedGenPackages> - </genPackages> -</genmodel:GenModel> diff --git a/org.fortiss.af3.exploration.alg/master/model/explorationDsl.ecore b/org.fortiss.af3.exploration.alg/master/model/explorationDsl.ecore deleted file mode 100644 index 446a2ec429571ac2d720348685eeae3f1d2d661d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/model/explorationDsl.ecore +++ /dev/null @@ -1,546 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="model" nsURI="http://www.fortiss.org/af3/explorationdsl" nsPrefix="org-fortiss-af3-explorationdsl"> - <eClassifiers xsi:type="ecore:EClass" name="MOEAExplorationExpression" abstract="true" - interface="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eStructuralFeatures xsi:type="ecore:EReference" name="moeaExpression" eType="#//expressions/Expression" - containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - </eStructuralFeatures> - </eClassifiers> - <eSubpackages name="operators" nsURI="http://www.fortiss.org/af3/exploration/operators" - nsPrefix="org-fortiss-af3-exploration-operators"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eClassifiers xsi:type="ecore:EEnum" name="ArithmeticOperatorEnum"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eLiterals name="ADD"/> - <eLiterals name="SUB" value="1"/> - <eLiterals name="MUL" value="2"/> - <eLiterals name="DIV" value="3"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EEnum" name="BooleanOperatorEnum"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eLiterals name="NOT"/> - <eLiterals name="AND" value="1"/> - <eLiterals name="OR" value="2"/> - <eLiterals name="XOR" value="3"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EEnum" name="ComparisonOperatorEnum"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eLiterals name="LESS"/> - <eLiterals name="LESS_OR_EQUAL" value="1"/> - <eLiterals name="EQUAL" value="2"/> - <eLiterals name="GREATER_OR_EQUAL" value="3"/> - <eLiterals name="GREATER" value="4"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EEnum" name="LocationOperatorEnum"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eLiterals name="Allocation"/> - <eLiterals name="Dislocation" value="1"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EEnum" name="OptimizationDirectionEnum"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eLiterals name="MIN"/> - <eLiterals name="MAX" value="1"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EEnum" name="QuantifierEnum"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eLiterals name="FOR_ALL"/> - <eLiterals name="EXIST" value="1"/> - <eLiterals name="ANY" value="1"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="Operator" abstract="true" interface="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="OP"/> - <eTypeParameters name="RHT"/> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="operator" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="TODO: write documentation (in the model!)"/> - </eAnnotations> - <eGenericType eTypeParameter="#//operators/Operator/OP"/> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EReference" name="right" lowerBound="1" - containment="true"> - <eGenericType eTypeParameter="#//operators/Operator/RHT"/> - </eStructuralFeatures> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="DualOperator"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="LHT"/> - <eTypeParameters name="OP"/> - <eTypeParameters name="RHT"/> - <eStructuralFeatures xsi:type="ecore:EReference" name="left" lowerBound="1" - containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericType eTypeParameter="#//operators/DualOperator/LHT"/> - </eStructuralFeatures> - <eGenericSuperTypes eClassifier="#//operators/Operator"> - <eTypeArguments eTypeParameter="#//operators/DualOperator/OP"/> - <eTypeArguments eTypeParameter="#//operators/DualOperator/RHT"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ArithmeticOp"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eTypeParameters name="LHE"> - <eBounds eClassifier="#//expressions/ArithmeticExpression"> - <eTypeArguments eTypeParameter="#//operators/ArithmeticOp/T"/> - </eBounds> - </eTypeParameters> - <eTypeParameters name="RHE"> - <eBounds eClassifier="#//expressions/ArithmeticExpression"> - <eTypeArguments eTypeParameter="#//operators/ArithmeticOp/T"/> - </eBounds> - </eTypeParameters> - <eGenericSuperTypes eClassifier="#//operators/DualOperator"> - <eTypeArguments eTypeParameter="#//operators/ArithmeticOp/LHE"/> - <eTypeArguments eClassifier="#//operators/ArithmeticOperatorEnum"/> - <eTypeArguments eTypeParameter="#//operators/ArithmeticOp/RHE"/> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="#//expressions/ArithmeticExpression"> - <eTypeArguments eTypeParameter="#//operators/ArithmeticOp/T"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ComparisonOp"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eTypeParameters name="LHT"> - <eBounds eClassifier="#//expressions/ArithmeticExpression"> - <eTypeArguments eTypeParameter="#//operators/ComparisonOp/T"/> - </eBounds> - </eTypeParameters> - <eTypeParameters name="RHT"> - <eBounds eClassifier="#//expressions/ArithmeticExpression"> - <eTypeArguments eTypeParameter="#//operators/ComparisonOp/T"/> - </eBounds> - </eTypeParameters> - <eGenericSuperTypes eClassifier="#//operators/DualOperator"> - <eTypeArguments eClassifier="#//expressions/ArithmeticExpression"> - <eTypeArguments eTypeParameter="#//operators/ComparisonOp/T"/> - </eTypeArguments> - <eTypeArguments eClassifier="#//operators/ComparisonOperatorEnum"/> - <eTypeArguments eClassifier="#//expressions/ArithmeticExpression"> - <eTypeArguments eTypeParameter="#//operators/ComparisonOp/T"/> - </eTypeArguments> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="#//expressions/BooleanExpression"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="LocationOp"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="LHT"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eTypeParameters name="RHT"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eGenericSuperTypes eClassifier="#//operators/DualOperator"> - <eTypeArguments eClassifier="#//expressions/ElementExpression"> - <eTypeArguments eTypeParameter="#//operators/LocationOp/LHT"/> - </eTypeArguments> - <eTypeArguments eClassifier="#//operators/LocationOperatorEnum"/> - <eTypeArguments eClassifier="#//expressions/ElementExpression"> - <eTypeArguments eTypeParameter="#//operators/LocationOp/RHT"/> - </eTypeArguments> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="#//expressions/BooleanExpression"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="OptimizationDirection"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericSuperTypes eClassifier="#//operators/Operator"> - <eTypeArguments eClassifier="#//operators/OptimizationDirectionEnum"/> - <eTypeArguments eClassifier="#//expressions/ArithmeticExpression"> - <eTypeArguments/> - </eTypeArguments> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="QuantifierOp"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericSuperTypes eClassifier="#//operators/Operator"> - <eTypeArguments eClassifier="#//operators/QuantifierEnum"/> - <eTypeArguments eClassifier="#//types/SetType"> - <eTypeArguments/> - </eTypeArguments> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="SummationOp"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eGenericSuperTypes eClassifier="#//operators/Operator"> - <eTypeArguments eClassifier="#//operators/ArithmeticOperatorEnum"/> - <eTypeArguments eClassifier="#//expressions/ArithmeticExpression"> - <eTypeArguments eTypeParameter="#//operators/SummationOp/T"/> - </eTypeArguments> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="#//expressions/ArithmeticExpression"> - <eTypeArguments eTypeParameter="#//operators/SummationOp/T"/> - </eGenericSuperTypes> - </eClassifiers> - </eSubpackages> - <eSubpackages name="expressions" nsURI="http://www.fortiss.org/af3/exploration/expressions" - nsPrefix="org-fortiss-af3-exploration-expressions"> - <eClassifiers xsi:type="ecore:EClass" name="Expression" abstract="true" interface="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ObjectiveExpression" eSuperTypes="#//expressions/Expression #//operators/OptimizationDirection"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ConstraintExpression" eSuperTypes="#//expressions/Expression"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"> - <eBounds eClassifier="#//expressions/BooleanExpression"/> - </eTypeParameters> - <eStructuralFeatures xsi:type="ecore:EReference" name="prefix" lowerBound="1" - upperBound="-1" eType="#//expressions/PrefixExpression" containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EReference" name="predicate" upperBound="-1" - eType="#//expressions/BooleanExpression" containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EReference" name="expression" lowerBound="1" - containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericType eTypeParameter="#//expressions/ConstraintExpression/T"/> - </eStructuralFeatures> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="PrefixExpression" abstract="true" - interface="true" eSuperTypes="#//expressions/Expression"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eStructuralFeatures xsi:type="ecore:EReference" name="quantifier" lowerBound="1" - eType="#//operators/QuantifierOp" containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EReference" name="set" lowerBound="1" containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericType eClassifier="#//types/SetType"> - <eTypeArguments/> - </eGenericType> - </eStructuralFeatures> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="BooleanExpression" abstract="true" - interface="true" eSuperTypes="#//expressions/Expression"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ArithmeticExpression" abstract="true" - interface="true" eSuperTypes="#//expressions/Expression"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ElementExpression" eSuperTypes="#//expressions/Expression"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="ME"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eStructuralFeatures xsi:type="ecore:EReference" name="modelElement"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericType eTypeParameter="#//expressions/ElementExpression/ME"/> - </eStructuralFeatures> - </eClassifiers> - </eSubpackages> - <eSubpackages name="patterns" nsURI="http://www.fortiss.org/af3/exploration/patterns" - nsPrefix="org-fortiss-af3-exploration-patterns"> - <eClassifiers xsi:type="ecore:EDataType" name="Function" instanceClassName="java.util.function.Function"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eTypeParameters name="R"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="LocationPattern"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="LHT"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eTypeParameters name="RHT"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eGenericSuperTypes eClassifier="#//expressions/ConstraintExpression"> - <eTypeArguments eClassifier="#//operators/LocationOp"> - <eTypeArguments eTypeParameter="#//patterns/LocationPattern/LHT"/> - <eTypeArguments eTypeParameter="#//patterns/LocationPattern/RHT"/> - </eTypeArguments> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ElementProperty"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="ME"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eTypeParameters name="T"/> - <eOperations name="getProperty" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericType eTypeParameter="#//patterns/ElementProperty/T"/> - </eOperations> - <eStructuralFeatures xsi:type="ecore:EReference" name="modelElement" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericType eTypeParameter="#//patterns/ElementProperty/ME"/> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="propertyGetter" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericType eClassifier="#//patterns/Function"> - <eTypeArguments eTypeParameter="#//patterns/ElementProperty/ME"/> - <eTypeArguments eTypeParameter="#//patterns/ElementProperty/T"/> - </eGenericType> - </eStructuralFeatures> - <eGenericSuperTypes eClassifier="#//types/ArithmeticVariable"> - <eTypeArguments eTypeParameter="#//patterns/ElementProperty/T"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="LocationProperty"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="LA"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eTypeParameters name="RA"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eTypeParameters name="T"/> - <eStructuralFeatures xsi:type="ecore:EReference" name="locOp" lowerBound="1" - containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericType eClassifier="#//operators/LocationOp"> - <eTypeArguments eTypeParameter="#//patterns/LocationProperty/LA"/> - <eTypeArguments eTypeParameter="#//patterns/LocationProperty/RA"/> - </eGenericType> - </eStructuralFeatures> - <eGenericSuperTypes eClassifier="#//types/ArithmeticVariable"> - <eTypeArguments eTypeParameter="#//patterns/LocationProperty/T"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ValueComparison"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eTypeParameters name="AE"> - <eBounds eClassifier="#//expressions/ArithmeticExpression"> - <eTypeArguments eTypeParameter="#//patterns/ValueComparison/T"/> - </eBounds> - </eTypeParameters> - <eGenericSuperTypes eClassifier="#//operators/ComparisonOp"> - <eTypeArguments eTypeParameter="#//patterns/ValueComparison/T"/> - <eTypeArguments eTypeParameter="#//patterns/ValueComparison/AE"/> - <eTypeArguments eClassifier="#//types/NumberLiteral"> - <eTypeArguments eTypeParameter="#//patterns/ValueComparison/T"/> - </eTypeArguments> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="SinglePropValueComparison"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eTypeParameters name="ME"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eGenericSuperTypes eClassifier="#//patterns/ValueComparison"> - <eTypeArguments eTypeParameter="#//patterns/SinglePropValueComparison/T"/> - <eTypeArguments eClassifier="#//patterns/ElementProperty"> - <eTypeArguments eTypeParameter="#//patterns/SinglePropValueComparison/ME"/> - <eTypeArguments eTypeParameter="#//patterns/SinglePropValueComparison/T"/> - </eTypeArguments> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="TwoPropertyValueComparison"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eTypeParameters name="LME"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eTypeParameters name="RME"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eGenericSuperTypes eClassifier="#//patterns/ValueComparison"> - <eTypeArguments eTypeParameter="#//patterns/TwoPropertyValueComparison/T"/> - <eTypeArguments eClassifier="#//patterns/TwoPropCalcExpression"> - <eTypeArguments eTypeParameter="#//patterns/TwoPropertyValueComparison/T"/> - <eTypeArguments eTypeParameter="#//patterns/TwoPropertyValueComparison/LME"/> - <eTypeArguments eTypeParameter="#//patterns/TwoPropertyValueComparison/RME"/> - </eTypeArguments> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="TwoPropCalcExpression"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eTypeParameters name="LME"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eTypeParameters name="RME"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eGenericSuperTypes eClassifier="#//operators/ArithmeticOp"> - <eTypeArguments eTypeParameter="#//patterns/TwoPropCalcExpression/T"/> - <eTypeArguments eClassifier="#//patterns/ElementProperty"> - <eTypeArguments eTypeParameter="#//patterns/TwoPropCalcExpression/LME"/> - <eTypeArguments eTypeParameter="#//patterns/TwoPropCalcExpression/T"/> - </eTypeArguments> - <eTypeArguments eClassifier="#//patterns/ElementProperty"> - <eTypeArguments eTypeParameter="#//patterns/TwoPropCalcExpression/RME"/> - <eTypeArguments eTypeParameter="#//patterns/TwoPropCalcExpression/T"/> - </eTypeArguments> - </eGenericSuperTypes> - </eClassifiers> - </eSubpackages> - <eSubpackages name="types" nsURI="http://www.fortiss.org/af3/exploration/types" - nsPrefix="org-fortiss-af3-exploration-types"> - <eClassifiers xsi:type="ecore:EClass" name="NumberLiteral"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericType eTypeParameter="#//types/NumberLiteral/T"/> - </eStructuralFeatures> - <eGenericSuperTypes eClassifier="#//expressions/ArithmeticExpression"> - <eTypeArguments eTypeParameter="#//types/NumberLiteral/T"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="RealLiteral"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericSuperTypes eClassifier="#//types/NumberLiteral"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBigDecimal"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="IntegerLiteral"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericSuperTypes eClassifier="#//types/NumberLiteral"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBigInteger"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="Variable"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericType eTypeParameter="#//types/Variable/T"/> - </eStructuralFeatures> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ArithmeticVariable"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eGenericSuperTypes eClassifier="#//types/Variable"> - <eTypeArguments eTypeParameter="#//types/ArithmeticVariable/T"/> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="#//expressions/ArithmeticExpression"> - <eTypeArguments eTypeParameter="#//types/ArithmeticVariable/T"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="SetType"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eGenericSuperTypes eClassifier="#//types/Variable"> - <eTypeArguments eTypeParameter="#//types/SetType/T"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ModelElementVariable"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="ME"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eGenericSuperTypes eClassifier="#//types/Variable"> - <eTypeArguments eTypeParameter="#//types/ModelElementVariable/ME"/> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="#//expressions/ElementExpression"> - <eTypeArguments eTypeParameter="#//types/ModelElementVariable/ME"/> - </eGenericSuperTypes> - </eClassifiers> - </eSubpackages> -</ecore:EPackage> diff --git a/org.fortiss.af3.exploration.alg/master/model/explorationDsl.genmodel b/org.fortiss.af3.exploration.alg/master/model/explorationDsl.genmodel deleted file mode 100644 index 648be71ebcb35f7f16b6a219fa1c3b9e45025b5e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/model/explorationDsl.genmodel +++ /dev/null @@ -1,173 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" - xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.fortiss.af3.exploration.alg/generated-src" - editDirectory="/org.fortiss.af3.exploration.alg.edit/generated-src" editorDirectory="/org.fortiss.af3.exploration.alg.editor/generated-src" - modelPluginID="org.fortiss.af3.exploration.alg" modelName="Model" editPluginClass="org.fortiss.af3.exploration.dsl.model.provider.ExplorationEditPlugin" - editorPluginClass="org.fortiss.af3.exploration.presentation.ExplorationEditorPlugin" - testsDirectory="/org.fortiss.af3.exploration.alg.tests/generated-src" importerID="org.eclipse.emf.importer.ecore" - containmentProxies="true" complianceLevel="5.0" copyrightFields="false" editPluginID="org.fortiss.af3.exploration.alg.edit" - editorPluginID="org.fortiss.af3.exploration.alg.editor" usedGenPackages="platform:/resource/org.fortiss.tooling.base/model/base.genmodel#//model platform:/resource/org.fortiss.tooling.kernel/model/kernel.genmodel#//model"> - <foreignModel>explorationDsl.ecore</foreignModel> - <genPackages prefix="Model" basePackage="org.fortiss.af3.exploration.dsl" disposableProviderFactory="true" - ecorePackage="explorationDsl.ecore#/"> - <genClasses image="false" ecoreClass="explorationDsl.ecore#//MOEAExplorationExpression"> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference explorationDsl.ecore#//MOEAExplorationExpression/moeaExpression"/> - </genClasses> - <nestedGenPackages prefix="Operators" basePackage="org.fortiss.af3.exploration.dsl.model" - disposableProviderFactory="true" ecorePackage="explorationDsl.ecore#//operators"> - <genEnums typeSafeEnumCompatible="false" ecoreEnum="explorationDsl.ecore#//operators/ArithmeticOperatorEnum"> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/ArithmeticOperatorEnum/ADD"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/ArithmeticOperatorEnum/SUB"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/ArithmeticOperatorEnum/MUL"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/ArithmeticOperatorEnum/DIV"/> - </genEnums> - <genEnums typeSafeEnumCompatible="false" ecoreEnum="explorationDsl.ecore#//operators/BooleanOperatorEnum"> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/BooleanOperatorEnum/NOT"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/BooleanOperatorEnum/AND"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/BooleanOperatorEnum/OR"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/BooleanOperatorEnum/XOR"/> - </genEnums> - <genEnums typeSafeEnumCompatible="false" ecoreEnum="explorationDsl.ecore#//operators/ComparisonOperatorEnum"> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/ComparisonOperatorEnum/LESS"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/ComparisonOperatorEnum/LESS_OR_EQUAL"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/ComparisonOperatorEnum/EQUAL"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/ComparisonOperatorEnum/GREATER_OR_EQUAL"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/ComparisonOperatorEnum/GREATER"/> - </genEnums> - <genEnums typeSafeEnumCompatible="false" ecoreEnum="explorationDsl.ecore#//operators/LocationOperatorEnum"> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/LocationOperatorEnum/Allocation"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/LocationOperatorEnum/Dislocation"/> - </genEnums> - <genEnums typeSafeEnumCompatible="false" ecoreEnum="explorationDsl.ecore#//operators/OptimizationDirectionEnum"> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/OptimizationDirectionEnum/MIN"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/OptimizationDirectionEnum/MAX"/> - </genEnums> - <genEnums typeSafeEnumCompatible="false" ecoreEnum="explorationDsl.ecore#//operators/QuantifierEnum"> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/QuantifierEnum/FOR_ALL"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/QuantifierEnum/EXIST"/> - <genEnumLiterals ecoreEnumLiteral="explorationDsl.ecore#//operators/QuantifierEnum/ANY"/> - </genEnums> - <genClasses image="false" ecoreClass="explorationDsl.ecore#//operators/Operator"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/Operator/OP"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/Operator/RHT"/> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute explorationDsl.ecore#//operators/Operator/operator"/> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference explorationDsl.ecore#//operators/Operator/right"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//operators/DualOperator"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/DualOperator/LHT"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/DualOperator/OP"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/DualOperator/RHT"/> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference explorationDsl.ecore#//operators/DualOperator/left"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//operators/ArithmeticOp"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/ArithmeticOp/T"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/ArithmeticOp/LHE"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/ArithmeticOp/RHE"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//operators/ComparisonOp"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/ComparisonOp/T"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/ComparisonOp/LHT"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/ComparisonOp/RHT"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//operators/LocationOp"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/LocationOp/LHT"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/LocationOp/RHT"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//operators/OptimizationDirection"/> - <genClasses ecoreClass="explorationDsl.ecore#//operators/QuantifierOp"/> - <genClasses ecoreClass="explorationDsl.ecore#//operators/SummationOp"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//operators/SummationOp/T"/> - </genClasses> - </nestedGenPackages> - <nestedGenPackages prefix="Expressions" basePackage="org.fortiss.af3.exploration.dsl.model" - disposableProviderFactory="true" ecorePackage="explorationDsl.ecore#//expressions"> - <genClasses image="false" ecoreClass="explorationDsl.ecore#//expressions/Expression"/> - <genClasses ecoreClass="explorationDsl.ecore#//expressions/ObjectiveExpression"/> - <genClasses ecoreClass="explorationDsl.ecore#//expressions/ConstraintExpression"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//expressions/ConstraintExpression/T"/> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference explorationDsl.ecore#//expressions/ConstraintExpression/prefix"/> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference explorationDsl.ecore#//expressions/ConstraintExpression/predicate"/> - <genFeatures notify="false" createChild="false" propertySortChoices="true" - ecoreFeature="ecore:EReference explorationDsl.ecore#//expressions/ConstraintExpression/expression"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//expressions/PrefixExpression"> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference explorationDsl.ecore#//expressions/PrefixExpression/quantifier"/> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference explorationDsl.ecore#//expressions/PrefixExpression/set"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//expressions/BooleanExpression"/> - <genClasses ecoreClass="explorationDsl.ecore#//expressions/ArithmeticExpression"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//expressions/ArithmeticExpression/T"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//expressions/ElementExpression"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//expressions/ElementExpression/ME"/> - <genFeatures notify="false" createChild="false" propertySortChoices="true" - ecoreFeature="ecore:EReference explorationDsl.ecore#//expressions/ElementExpression/modelElement"/> - </genClasses> - </nestedGenPackages> - <nestedGenPackages prefix="Patterns" basePackage="org.fortiss.af3.exploration.dsl.model" - disposableProviderFactory="true" ecorePackage="explorationDsl.ecore#//patterns"> - <genDataTypes ecoreDataType="explorationDsl.ecore#//patterns/Function"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/Function/T"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/Function/R"/> - </genDataTypes> - <genClasses ecoreClass="explorationDsl.ecore#//patterns/LocationPattern"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/LocationPattern/LHT"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/LocationPattern/RHT"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//patterns/ElementProperty"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/ElementProperty/ME"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/ElementProperty/T"/> - <genFeatures notify="false" createChild="false" propertySortChoices="true" - ecoreFeature="ecore:EReference explorationDsl.ecore#//patterns/ElementProperty/modelElement"/> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute explorationDsl.ecore#//patterns/ElementProperty/propertyGetter"/> - <genOperations ecoreOperation="explorationDsl.ecore#//patterns/ElementProperty/getProperty"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//patterns/LocationProperty"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/LocationProperty/LA"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/LocationProperty/RA"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/LocationProperty/T"/> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference explorationDsl.ecore#//patterns/LocationProperty/locOp"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//patterns/ValueComparison"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/ValueComparison/T"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/ValueComparison/AE"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//patterns/SinglePropValueComparison"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/SinglePropValueComparison/T"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/SinglePropValueComparison/ME"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//patterns/TwoPropertyValueComparison"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/TwoPropertyValueComparison/T"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/TwoPropertyValueComparison/LME"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/TwoPropertyValueComparison/RME"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//patterns/TwoPropCalcExpression"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/TwoPropCalcExpression/T"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/TwoPropCalcExpression/LME"/> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//patterns/TwoPropCalcExpression/RME"/> - </genClasses> - </nestedGenPackages> - <nestedGenPackages prefix="Types" basePackage="org.fortiss.af3.exploration.dsl.model" - disposableProviderFactory="true" ecorePackage="explorationDsl.ecore#//types"> - <genClasses image="false" ecoreClass="explorationDsl.ecore#//types/NumberLiteral"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//types/NumberLiteral/T"/> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute explorationDsl.ecore#//types/NumberLiteral/value"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//types/RealLiteral"/> - <genClasses ecoreClass="explorationDsl.ecore#//types/IntegerLiteral"/> - <genClasses ecoreClass="explorationDsl.ecore#//types/Variable"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//types/Variable/T"/> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute explorationDsl.ecore#//types/Variable/value"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//types/ArithmeticVariable"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//types/ArithmeticVariable/T"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//types/SetType"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//types/SetType/T"/> - </genClasses> - <genClasses ecoreClass="explorationDsl.ecore#//types/ModelElementVariable"> - <genTypeParameters ecoreTypeParameter="explorationDsl.ecore#//types/ModelElementVariable/ME"/> - </genClasses> - </nestedGenPackages> - </genPackages> -</genmodel:GenModel> diff --git a/org.fortiss.af3.exploration.alg/master/model/generate-ecore.xml b/org.fortiss.af3.exploration.alg/master/model/generate-ecore.xml deleted file mode 100644 index 19e92d0352d8c3d9914e0060b85c543e1740014b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/model/generate-ecore.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- - $Id: generate-ecore.xml 3211 2016-07-06 09:26:14Z diewald $ - @version $Rev: 3211 $ - @ConQAT.Rating YELLOW Hash: 2E67BF6F5D8E249F2906F0D624AD0CCF ---> -<project name="org.fortiss.af3.exploration" default="generate-ecore" basedir=".."> - - <property name="common.name" value="common" /> - <property name="explorationDsl.name" value="explorationDsl" /> - <property name="moea.name" value="moea" /> - - <property name="model.project" value="org.fortiss.af3.exploration.alg" /> - - <!-- Classpath Definition --> - <buckminster.valuepath id="project.classpath" value="${fs:project.classpath}" /> - <path id="classpath"> - <path refid="project.classpath"/> - - <!-- add src to the classpath as only the bin directory is in the classpath - and some resources such as the workflow or properties file might not yet - have been copied to the bin directory --> - <pathelement location="src"/> - </path> - - <!-- Generation Tasks --> - <target name="generate-ecore"> - <emf.Ecore2Java - model="model/${explorationDsl.name}.ecore" - genModel="model/${explorationDsl.name}.genmodel" - modelProject="/${model.project}" - modelProjectFragmentPath="generated-src" - reconcileGenModel="reload"> - </emf.Ecore2Java> - <emf.Ecore2Java - model="model/${common.name}.ecore" - genModel="model/${common.name}.genmodel" - modelProject="/${model.project}" - modelProjectFragmentPath="generated-src" - reconcileGenModel="reload"> - </emf.Ecore2Java> - <emf.Ecore2Java - model="model/${moea.name}.ecore" - genModel="model/${moea.name}.genmodel" - modelProject="/${model.project}" - modelProjectFragmentPath="generated-src" - reconcileGenModel="reload"> - </emf.Ecore2Java> - </target> -</project> \ No newline at end of file diff --git a/org.fortiss.af3.exploration.alg/master/model/moea.ecore b/org.fortiss.af3.exploration.alg/master/model/moea.ecore deleted file mode 100644 index d4aa8ab91f7408805fc0e8a4bd29c4cbac8a2452..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/model/moea.ecore +++ /dev/null @@ -1,575 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="model" nsURI="http://www.fortiss.org/af3/exploration/moea" nsPrefix="org-fortiss-af3-exploration-moea"> - <eClassifiers xsi:type="ecore:EClass" name="ExplorationManager" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//IProjectRootElement"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Model equivalent for the GUI editor to allow the definition of {@link DseSpecification}s."/> - </eAnnotations> - <eStructuralFeatures xsi:type="ecore:EReference" name="dseSpecifications" upperBound="-1" - eType="#//DseSpecification" containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="List of {@link DseSpecification}s defined via {@code this} {@link ExplorationManager}. There exists only one {@link ExplorationManager} per AF3 project."/> - </eAnnotations> - </eStructuralFeatures> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="DseSpecification" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//INamedCommentedElement"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Contains the selected {@link IOptimizer}, the {@link SystemParameter}s, and the {@link ExplorationSpecification} that define a particular DSE problemn."/> - </eAnnotations> - <eStructuralFeatures xsi:type="ecore:EReference" name="features" lowerBound="1" - upperBound="-1" eType="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//IExplorationFeature" - containment="true"/> - <eStructuralFeatures xsi:type="ecore:EReference" name="optimizer" lowerBound="1" - eType="#//parameters/IOptimizer" containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Selected {@link IOptimizer} that is used to perform the DSE."/> - </eAnnotations> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EReference" name="parameters" lowerBound="1" - eType="#//parameters/SystemParameters" containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="{@link SystemParameters} that must be considered during the DSE."/> - </eAnnotations> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EReference" name="targetSpecification" lowerBound="1" - eType="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationSpecification" - containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Specification of the {@link ExplorationTarget}s, i.e., objectives and constraints, which define the optima and the feasible reagin for the DSE problem."/> - </eAnnotations> - </eStructuralFeatures> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ImplementsComponentRef" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IHiddenSpecification"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="For {@link Component}s in a "100% {@link ComponentArchitecture}" this specification contains a reference to the {@link Component} in the "150% / 125% {@link ComponentArchitecture}" which they implement. Note that this specification only exists in {@link ComponentArchitecture}s that are actually generated from a "150% / 125% {@link ComponentArchitecture}"."/> - </eAnnotations> - <eStructuralFeatures xsi:type="ecore:EReference" name="refComponent" lowerBound="1" - eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EEnum" name="VoterType_t"> - <eLiterals name="MajorityVoter"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="VoterType" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IHiddenSpecification"> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" lowerBound="1" eType="#//VoterType_t"/> - </eClassifiers> - <eSubpackages name="annotation" nsURI="http://www.fortiss.org/af3/exploration/moea/annotation" - nsPrefix="org-fortiss-af3-exploration-moea-annotation"> - <eClassifiers xsi:type="ecore:EClass" name="ComponentDiverseImplRef" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IAnnotatedSpecification platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IHiddenSpecification"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="{@link IAnnotatedSpecification} providing a reference to a set of differing implementations of the specified {@link Component}, hence providing diverse implementations."/> - </eAnnotations> - <eStructuralFeatures xsi:type="ecore:EReference" name="componentRef" upperBound="-1" - eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - </eClassifiers> - </eSubpackages> - <eSubpackages name="feature" nsURI="http://www.fortiss.org/af3/exploration/moea/feature" - nsPrefix="org-fortiss-af3-exploration-moea-feature"> - <eClassifiers xsi:type="ecore:EClass" name="SafetyExploration" eSuperTypes="platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//IExplorationFeature"> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="adapters" upperBound="-1" - eType="#//feature/ISafetyFunctionAdapter" transient="true"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="TaskInstantiation" eSuperTypes="platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//IExplorationFeature"/> - <eClassifiers xsi:type="ecore:EClass" name="TaskMapping" eSuperTypes="platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//IExplorationFeature"/> - <eClassifiers xsi:type="ecore:EDataType" name="ISafetyFunctionAdapter" instanceClassName="org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISafetyFunctionAdapter" - serializable="false"/> - </eSubpackages> - <eSubpackages name="parameters" nsURI="http://www.fortiss.org/af3/exploration/moea/parameters" - nsPrefix="org-fortiss-af3-exploration-moea-parameters"> - <eClassifiers xsi:type="ecore:EEnum" name="ExecutionModel"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Defines the failure assumption."/> - </eAnnotations> - <eLiterals name="TT_FAIL_SILENCE"/> - <eLiterals name="TT_FAULT_DETECTION_VOTING" value="1"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="SystemParameters"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Defines the parameters associated with the system models."/> - </eAnnotations> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="executionModel" lowerBound="1" - eType="#//parameters/ExecutionModel"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Defines the failure assumption of the system."/> - </eAnnotations> - </eStructuralFeatures> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="IOptimizer" abstract="true" interface="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Marker interface for available optimization backends for the DSE."/> - </eAnnotations> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="EAOptimizer" eSuperTypes="#//parameters/IOptimizer"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="{@link IOptimizer} backend for evolutionary algorithms which also contains the relevant parameters for this kind of optimizer."/> - </eAnnotations> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="alpha" lowerBound="1" - eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt" defaultValueLiteral="1000"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Defines the size of the population."/> - </eAnnotations> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="mu" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt" - defaultValueLiteral="50"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Number of parents to generate the offspring added to the population for the next iteration of the algorithm."/> - </eAnnotations> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="iterations" lowerBound="1" - eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt" defaultValueLiteral="100"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Defines the number of iterations (aka generations) before the optimization terminates and the found solution(s) (if any) are returned."/> - </eAnnotations> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="spea2Tournament" lowerBound="1" - eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt" defaultValueLiteral="5"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Defines the selection pressure for the SPEA2 genetic algorithm."/> - </eAnnotations> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="parallelExecution" lowerBound="1" - eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean" - defaultValueLiteral="false"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Defines whether the algorithm shall use parallel processing, if available in the algorithm."/> - </eAnnotations> - </eStructuralFeatures> - </eClassifiers> - </eSubpackages> - <eSubpackages name="predefined" nsURI="http://www.fortiss.org/af3/exploration/moea/predefined" - nsPrefix="org-fortiss-af3-exploration-moea-predefined"> - <eClassifiers xsi:type="ecore:EEnum" name="FailureMode"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Defines the failure modes of tasks."/> - </eAnnotations> - <eLiterals name="FailSafe"/> - <eLiterals name="FailOperational" value="1"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EEnum" name="FailureType"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Defines which types of failures shall be considered in the reliability analysis."/> - </eAnnotations> - <eLiterals name="DUF"/> - <eLiterals name="SDC" value="1"/> - <eLiterals name="ALL" value="2" literal="ALL"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="FailureMinObjective"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="{@link ExplorationObjective} that minimizes the failure probability of a defined task."/> - </eAnnotations> - <eOperations name="getTargetComponent" lowerBound="1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Returns the {@link Component} that is the subject of the {@link ReliabilityAnalysis} which is the target of the minimization."/> - <details key="body" value="return FailureMinObjectiveStaticImpl.getFailureMinTargetComponent(this);"/> - </eAnnotations> - </eOperations> - <eOperations name="setTargetComponent" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Sets the given {@link Component} as the subject of the {@link ReliabilityAnalysis} which is the target of the minimization."/> - <details key="body" value="FailureMinObjectiveStaticImpl.setFailureMinTargetComponent(this, targetComponent);"/> - </eAnnotations> - <eParameters name="targetComponent" lowerBound="1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - </eOperations> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="mode" lowerBound="1" - eType="#//predefined/FailureMode" defaultValueLiteral="FailSafe"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Defines the failure modes of the tasks."/> - </eAnnotations> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" lowerBound="1" - eType="#//predefined/FailureType"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Defines which types of failures shall be considered in the reliability analysis."/> - </eAnnotations> - </eStructuralFeatures> - <eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/dimensions.ecore#//ResourceDimension"/> - <eGenericSuperTypes eClassifier="ecore:EClass explorationDsl.ecore#//MOEAExplorationExpression"/> - <eGenericSuperTypes eClassifier="ecore:EClass common.ecore#//MOExplorationObjective"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ReliabilityAnalysis"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eGenericSuperTypes eClassifier="ecore:EClass explorationDsl.ecore#//expressions/ArithmeticExpression"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"/> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="ecore:EClass explorationDsl.ecore#//expressions/ElementExpression"> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="ecore:EClass explorationDsl.ecore#//MOEAExplorationExpression"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="EnergyMinObjective"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="{@link ExplorationObjective} that minimizes the consumed emergy of a system."/> - </eAnnotations> - <eGenericSuperTypes eClassifier="ecore:EClass common.ecore#//MOExplorationObjective"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"/> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/dimensions.ecore#//EnergyDimension"/> - <eGenericSuperTypes eClassifier="ecore:EClass explorationDsl.ecore#//MOEAExplorationExpression"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="MultiLocationConstraint"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="LHT"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eTypeParameters name="RHT"> - <eBounds eClassifier="ecore:EClass platform:/resource/org.fortiss.tooling.base/model/base.ecore#//element/IModelElement"/> - </eTypeParameters> - <eOperations name="getLeftMultiLocationModelElement" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Returns the {@link IModelElement} defined on the left hand side of an {@link LocationOp}."/> - <details key="body" value="return MultiLocationConstraintStaticImpl.getLeftMultiLocationModelElement(this);"/> - </eAnnotations> - <eGenericType eTypeParameter="#//predefined/MultiLocationConstraint/LHT"/> - </eOperations> - <eOperations name="getAllRightMultiLocationModelElements" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Returns the {@link EEList} of all {@link IModelElement} defined on the right hand side of an {@link LocationOp} of the contained {@link LocationConstraint}s."/> - <details key="body" value="return MultiLocationConstraintStaticImpl.getAllRightMultiLocationModelElements(this);"/> - </eAnnotations> - <eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEList"> - <eTypeArguments eTypeParameter="#//predefined/MultiLocationConstraint/RHT"/> - </eGenericType> - </eOperations> - <eStructuralFeatures xsi:type="ecore:EReference" name="singleLocationConstraints" - lowerBound="1" upperBound="-1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY. Defines the list of {@link LocationConstraint}s comprising {@code this} constraint."/> - </eAnnotations> - <eGenericType eClassifier="ecore:EClass common.ecore#//location/LocationConstraint"> - <eTypeArguments eTypeParameter="#//predefined/MultiLocationConstraint/LHT"/> - <eTypeArguments eTypeParameter="#//predefined/MultiLocationConstraint/RHT"/> - </eGenericType> - </eStructuralFeatures> - <eGenericSuperTypes eClassifier="ecore:EClass common.ecore#//location/LocationConstraint"> - <eTypeArguments eTypeParameter="#//predefined/MultiLocationConstraint/LHT"/> - <eTypeArguments eTypeParameter="#//predefined/MultiLocationConstraint/RHT"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ComponentMultiAllocationConstraint"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY. Defines to which {@link ExecutionUnit}s a {@link Component} may be allocated to."/> - </eAnnotations> - <eOperations name="setComponentMultiAllocations" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Sets the set of allowed {@link ComponentAllocation}s for the given {@link Component} to the set of {@link ExecutionUnit}s. Here, any of the given {@link ExecutionUnit}s is a valid allocation traget, where the given {@link Component} is not required to have an instance on each of the given {@link ExecutionUnit}s."/> - <details key="body" value="ComponentMultiAllocationConstraintStaticImpl.setComponentMultiAllocations(this, comp, execUnits);"/> - </eAnnotations> - <eParameters name="comp" lowerBound="1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - <eParameters name="execUnits" lowerBound="1"> - <eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEList"> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ExecutionUnit"/> - </eGenericType> - </eParameters> - </eOperations> - <eOperations name="getComponent" lowerBound="1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Returns the {@link Component} which is restricted in it allocation targets."/> - <details key="body" value="return getLeftMultiLocationModelElement();"/> - </eAnnotations> - </eOperations> - <eOperations name="getExecutionUnits" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Returns the list of {@link ExecutionUnit}s which are allowed allocation targets."/> - <details key="body" value="return getAllRightMultiLocationModelElements();"/> - </eAnnotations> - <eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEList"> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ExecutionUnit"/> - </eGenericType> - </eOperations> - <eGenericSuperTypes eClassifier="#//predefined/MultiLocationConstraint"> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ExecutionUnit"/> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationConstraint"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBooleanObject"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ComponentMultiDislocationConstraint"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY. Defines to which {@link ExecutionUnit}s a {@link Component} may be <b>NOT</b> allocated to."/> - </eAnnotations> - <eOperations name="setComponentMultiDislocations" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Sets the set of disallowed {@link ComponentDislocation}s for the given {@link Component} to the set of {@link ExecutionUnit}s. Here, any of the given {@link ExecutionUnit}s is an invalid allocation traget for any instance of the given {@link Component}."/> - <details key="body" value="ComponentMultiDislocationConstraintStaticImpl.setComponentMultiDislocations(this, comp, execUnits);"/> - </eAnnotations> - <eParameters name="comp" lowerBound="1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - <eParameters name="execUnits" lowerBound="1"> - <eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEList"> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ExecutionUnit"/> - </eGenericType> - </eParameters> - </eOperations> - <eOperations name="getComponent" lowerBound="1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Returns the {@link Component} which is restricted in it allocation targets."/> - <details key="body" value="return getLeftMultiLocationModelElement();"/> - </eAnnotations> - </eOperations> - <eOperations name="getExecutionUnits" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Returns the list of {@link ExecutionUnit}s which are disallowed allocation targets."/> - <details key="body" value="return getAllRightMultiLocationModelElements();"/> - </eAnnotations> - <eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEList"> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ExecutionUnit"/> - </eGenericType> - </eOperations> - <eGenericSuperTypes eClassifier="#//predefined/MultiLocationConstraint"> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ExecutionUnit"/> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationConstraint"> - <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBooleanObject"/> - </eGenericSuperTypes> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="SafetyIntegrityLevelConstraint"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY. Defines for which {@link Component}s their specified SIL must be considered in the evaluation."/> - </eAnnotations> - <eOperations name="getLimitation" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="TODO: write documentation (in the model!)"/> - <details key="body" value="return SafetyIntegrityLevelConstraintStaticImpl.getLimitation(this);"/> - </eAnnotations> - <eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEList"> - <eTypeArguments eClassifier="ecore:EEnum platform:/resource/org.fortiss.af3.safety/model/safety.ecore#//SIL"/> - </eGenericType> - </eOperations> - <eStructuralFeatures xsi:type="ecore:EReference" name="components" lowerBound="1" - upperBound="-1" eType="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="List of {@link Component}s whose SIL has to be considered in the allocation."/> - </eAnnotations> - </eStructuralFeatures> - <eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationConstraint"> - <eTypeArguments eClassifier="ecore:EEnum platform:/resource/org.fortiss.af3.safety/model/safety.ecore#//SIL"/> - </eGenericSuperTypes> - <eGenericSuperTypes eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/dimensions.ecore#//SafetyDimension"/> - <eGenericSuperTypes eClassifier="ecore:EClass explorationDsl.ecore#//MOEAExplorationExpression"/> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="SafetyComparison"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="DEPRECATED/LEGACY."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eGenericSuperTypes eClassifier="ecore:EClass explorationDsl.ecore#//operators/ComparisonOp"> - <eTypeArguments eTypeParameter="#//predefined/SafetyComparison/T"/> - <eTypeArguments eClassifier="ecore:EClass explorationDsl.ecore#//patterns/ElementProperty"> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.component/model/component.ecore#//Component"/> - <eTypeArguments eTypeParameter="#//predefined/SafetyComparison/T"/> - </eTypeArguments> - <eTypeArguments eClassifier="ecore:EClass explorationDsl.ecore#//patterns/ElementProperty"> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.platform/model/platform.ecore#//ExecutionUnit"/> - <eTypeArguments eTypeParameter="#//predefined/SafetyComparison/T"/> - </eTypeArguments> - </eGenericSuperTypes> - </eClassifiers> - </eSubpackages> - <eSubpackages name="solutions" nsURI="http://www.fortiss.org/af3/exploration/moea/solutions" - nsPrefix="org-fortiss-af3-exploration-moea-solutions"> - <eClassifiers xsi:type="ecore:EClass" name="ExplorationResult"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Contains the evaluation result of a single {@link ExplorationTarget}."/> - </eAnnotations> - <eTypeParameters name="T"/> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="result" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Contains the evaluation result of a single {@link ExplorationTarget}."/> - </eAnnotations> - <eGenericType eTypeParameter="#//solutions/ExplorationResult/T"/> - </eStructuralFeatures> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ExplorationSolutionSet" eSuperTypes="platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationSolution"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Contains the set of {@link ExplorationSolution}s that are solutions to the problem defined in the {@link ExplorationSpecification}."/> - </eAnnotations> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="inputModelAdapter" lowerBound="1" - eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaObject"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="References the corresponding input models."/> - </eAnnotations> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EReference" name="targetSpecification" - lowerBound="1" eType="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationSpecification"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="References the {@link ExplorationSpecification} for which {@this ExplorationSolutionSet} provides solutions."/> - </eAnnotations> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EReference" name="solutions" upperBound="-1" - eType="#//solutions/SingleExplorationSolutionMap" containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Contains the single solutions that are maps relating the {@link ExplorationTarget}s with their (evaluation) {@link ExplorationResult}s."/> - </eAnnotations> - </eStructuralFeatures> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="SingleExplorationSolutionMap"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Represents a single solution as a map relating the {@link ExplorationTarget}s with their (evaluation) {@link ExplorationResult}s."/> - </eAnnotations> - <eOperations name="containsKey" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Mirrors the standard {@link java.util.Map#containsKey} method."/> - <details key="body" value="return solutionMap.containsKey(key);"/> - </eAnnotations> - <eParameters name="key"> - <eGenericType eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationTarget"> - <eTypeArguments/> - </eGenericType> - </eParameters> - </eOperations> - <eOperations name="containsValue" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Mirrors the standard {@link java.util.Map#containsValue} method."/> - <details key="body" value="return solutionMap.containsValue(value);"/> - </eAnnotations> - <eParameters name="value"> - <eGenericType eClassifier="#//solutions/ExplorationResult"> - <eTypeArguments/> - </eGenericType> - </eParameters> - </eOperations> - <eOperations name="get" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Mirrors the standard {@link java.util.Map#get} method, except that the Types of the key ({@link ExplorationTarget}) and the returned value ({@link ExplorationValue}) will match."/> - <details key="body" value="return (ExplorationResult<T>)solutionMap.get(key);"/> - </eAnnotations> - <eGenericType eClassifier="#//solutions/ExplorationResult"> - <eTypeArguments eTypeParameter="#//solutions/SingleExplorationSolutionMap/get/T"/> - </eGenericType> - <eTypeParameters name="T"/> - <eParameters name="key"> - <eGenericType eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationTarget"> - <eTypeArguments eTypeParameter="#//solutions/SingleExplorationSolutionMap/get/T"/> - </eGenericType> - </eParameters> - </eOperations> - <eOperations name="keySet" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Mirrors the standard {@link java.util.Map#keySet} method."/> - <details key="body" value="return new <%org.eclipse.emf.common.util.BasicEList%><ExplorationTarget<?>>(solutionMap.keySet());"/> - </eAnnotations> - <eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEList"> - <eTypeArguments eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationTarget"> - <eTypeArguments/> - </eTypeArguments> - </eGenericType> - </eOperations> - <eOperations name="put" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Mirrors the standard {@link java.util.Map#get} method, except that the Types of the key ({@link ExplorationTarget}) and the returned value ({@link ExplorationValue}) must match."/> - <details key="body" value="return (ExplorationResult<T>)solutionMap.put(key, value);"/> - </eAnnotations> - <eGenericType eClassifier="#//solutions/ExplorationResult"> - <eTypeArguments eTypeParameter="#//solutions/SingleExplorationSolutionMap/put/T"/> - </eGenericType> - <eTypeParameters name="T"/> - <eParameters name="key"> - <eGenericType eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationTarget"> - <eTypeArguments eTypeParameter="#//solutions/SingleExplorationSolutionMap/put/T"/> - </eGenericType> - </eParameters> - <eParameters name="value"> - <eGenericType eClassifier="#//solutions/ExplorationResult"> - <eTypeArguments eTypeParameter="#//solutions/SingleExplorationSolutionMap/put/T"/> - </eGenericType> - </eParameters> - </eOperations> - <eOperations name="removeKey" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Mirrors the standard {@link java.util.Map#removeKey} method, except that the Types of the key ({@link ExplorationTarget}) and the returned value ({@link ExplorationValue}) will match."/> - <details key="body" value="return (ExplorationResult<T>)solutionMap.get(key);"/> - </eAnnotations> - <eGenericType eClassifier="#//solutions/ExplorationResult"> - <eTypeArguments eTypeParameter="#//solutions/SingleExplorationSolutionMap/removeKey/T"/> - </eGenericType> - <eTypeParameters name="T"/> - <eParameters name="key"> - <eGenericType eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationTarget"> - <eTypeArguments eTypeParameter="#//solutions/SingleExplorationSolutionMap/removeKey/T"/> - </eGenericType> - </eParameters> - </eOperations> - <eOperations name="values" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Mirrors the standard {@link java.util.Map#values} method, except that its returned value is an {@link EList} instead of a {@link Collection} due to EMF limitations."/> - <details key="body" value="return new <%org.eclipse.emf.common.util.BasicEList%><ExplorationResult<?>>(solutionMap.values());"/> - </eAnnotations> - <eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEList"> - <eTypeArguments eClassifier="#//solutions/ExplorationResult"> - <eTypeArguments/> - </eTypeArguments> - </eGenericType> - </eOperations> - <eOperations name="getSolutionModel" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Allows to retrieve an attached solution model of this representation of a single solution."/> - <details key="body" value="return SingleExplorationSolutionMapStaticImpl.getModel(this, modelType);"/> - </eAnnotations> - <eGenericType eTypeParameter="#//solutions/SingleExplorationSolutionMap/getSolutionModel/T"/> - <eTypeParameters name="T"/> - <eParameters name="modelType" lowerBound="1"> - <eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass"> - <eTypeArguments eTypeParameter="#//solutions/SingleExplorationSolutionMap/getSolutionModel/T"/> - </eGenericType> - </eParameters> - </eOperations> - <eOperations name="putSolutionModel" lowerBound="1"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Allows to attach a solution model to this representation of a single solution."/> - <details key="body" value="SingleExplorationSolutionMapStaticImpl.putSolutionModel(this, modelType, solutionModel);"/> - </eAnnotations> - <eTypeParameters name="T"/> - <eParameters name="modelType" lowerBound="1"> - <eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass"> - <eTypeArguments eTypeParameter="#//solutions/SingleExplorationSolutionMap/putSolutionModel/T"/> - </eGenericType> - </eParameters> - <eParameters name="solutionModel" lowerBound="1"> - <eGenericType eTypeParameter="#//solutions/SingleExplorationSolutionMap/putSolutionModel/T"/> - </eParameters> - </eOperations> - <eStructuralFeatures xsi:type="ecore:EReference" name="solutionMap" lowerBound="1" - upperBound="-1" eType="#//solutions/ExplorationTargetToExplorationResultMap" - containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="EMF-implementation of the backend map."/> - </eAnnotations> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EReference" name="solutionModelMap" lowerBound="1" - upperBound="-1" eType="#//solutions/EJavaClassToEJavaObjectMap" containment="true"> - <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> - <details key="documentation" value="Allows to optionally attach calculated solution models to a single solution. They are identified by their type."/> - </eAnnotations> - </eStructuralFeatures> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="ExplorationTargetToExplorationResultMap" - instanceClassName="java.util.Map$Entry"> - <eStructuralFeatures xsi:type="ecore:EReference" name="key" lowerBound="1"> - <eGenericType eClassifier="ecore:EClass platform:/resource/org.fortiss.af3.exploration/model/exploration.ecore#//ExplorationTarget"> - <eTypeArguments/> - </eGenericType> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EReference" name="value" lowerBound="1" - containment="true"> - <eGenericType eClassifier="#//solutions/ExplorationResult"> - <eTypeArguments/> - </eGenericType> - </eStructuralFeatures> - </eClassifiers> - <eClassifiers xsi:type="ecore:EClass" name="EJavaClassToEJavaObjectMap" instanceClassName="java.util.Map$Entry"> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="key" lowerBound="1"> - <eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass"> - <eTypeArguments/> - </eGenericType> - </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" lowerBound="1" - eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaObject"/> - </eClassifiers> - </eSubpackages> -</ecore:EPackage> diff --git a/org.fortiss.af3.exploration.alg/master/model/moea.genmodel b/org.fortiss.af3.exploration.alg/master/model/moea.genmodel deleted file mode 100644 index 288aa08132ceb2f7a83b41d3934563460fabf482..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/model/moea.genmodel +++ /dev/null @@ -1,178 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" - xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.fortiss.af3.exploration.alg/generated-src" - editDirectory="/org.fortiss.af3.exploration.alg.edit/generated-src" editorDirectory="/org.fortiss.af3.exploration.alg.editor/generated-src" - modelPluginID="org.fortiss.af3.exploration.alg" modelName="Model" editPluginClass="org.fortiss.af3.exploration.model.provider.ExplorationEditPlugin" - editorPluginClass="org.fortiss.af3.exploration.presentation.ExplorationEditorPlugin" - testsDirectory="/org.fortiss.af3.exploration.alg.tests/generated-src" importerID="org.eclipse.emf.importer.ecore" - containmentProxies="true" complianceLevel="5.0" copyrightFields="false" editPluginID="org.fortiss.af3.exploration.alg.edit" - editorPluginID="org.fortiss.af3.exploration.alg.editor" usedGenPackages="platform:/resource/org.fortiss.tooling.base/model/base.genmodel#//model platform:/resource/org.fortiss.af3.component/model/component.genmodel#//model common.genmodel#//model explorationDsl.genmodel#//model platform:/resource/org.fortiss.af3.exploration/model/exploration.genmodel#//model platform:/resource/org.fortiss.af3.exploration/model/dimensions.genmodel#//model platform:/resource/org.fortiss.af3.exploration/model/dsl_v2.genmodel#//model platform:/resource/org.fortiss.af3.expression/model/expression.genmodel#//model platform:/resource/org.fortiss.af3.platform/model/platform.genmodel#//model platform:/resource/org.fortiss.af3.project/model/project.genmodel#//model platform:/resource/org.fortiss.af3.safety/model/safety.genmodel#//model platform:/resource/org.fortiss.tooling.kernel/model/kernel.genmodel#//model"> - <foreignModel>moea.ecore</foreignModel> - <genPackages prefix="Moea" basePackage="org.fortiss.af3.exploration.moea" disposableProviderFactory="true" - ecorePackage="moea.ecore#/"> - <genEnums typeSafeEnumCompatible="false" ecoreEnum="moea.ecore#//VoterType_t"> - <genEnumLiterals ecoreEnumLiteral="moea.ecore#//VoterType_t/MajorityVoter"/> - </genEnums> - <genClasses ecoreClass="moea.ecore#//ExplorationManager"> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference moea.ecore#//ExplorationManager/dseSpecifications"/> - </genClasses> - <genClasses ecoreClass="moea.ecore#//DseSpecification"> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference moea.ecore#//DseSpecification/features"/> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference moea.ecore#//DseSpecification/optimizer"/> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference moea.ecore#//DseSpecification/parameters"/> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference moea.ecore#//DseSpecification/targetSpecification"/> - </genClasses> - <genClasses ecoreClass="moea.ecore#//ImplementsComponentRef"> - <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference moea.ecore#//ImplementsComponentRef/refComponent"/> - </genClasses> - <genClasses ecoreClass="moea.ecore#//VoterType"> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//VoterType/type"/> - </genClasses> - <nestedGenPackages prefix="Annotation" basePackage="org.fortiss.af3.exploration.moea.model" - disposableProviderFactory="true" ecorePackage="moea.ecore#//annotation"> - <genClasses ecoreClass="moea.ecore#//annotation/ComponentDiverseImplRef"> - <genFeatures notify="false" createChild="false" propertySortChoices="true" - ecoreFeature="ecore:EReference moea.ecore#//annotation/ComponentDiverseImplRef/componentRef"/> - </genClasses> - </nestedGenPackages> - <nestedGenPackages prefix="Feature" basePackage="org.fortiss.af3.exploration.moea.model" - disposableProviderFactory="true" ecorePackage="moea.ecore#//feature"> - <genDataTypes ecoreDataType="moea.ecore#//feature/ISafetyFunctionAdapter"/> - <genClasses ecoreClass="moea.ecore#//feature/SafetyExploration"> - <genFeatures notify="false" createChild="false" propertySortChoices="true" - ecoreFeature="ecore:EAttribute moea.ecore#//feature/SafetyExploration/adapters"/> - </genClasses> - <genClasses ecoreClass="moea.ecore#//feature/TaskInstantiation"/> - <genClasses ecoreClass="moea.ecore#//feature/TaskMapping"/> - </nestedGenPackages> - <nestedGenPackages prefix="Parameters" basePackage="org.fortiss.af3.exploration.moea.model" - disposableProviderFactory="true" ecorePackage="moea.ecore#//parameters"> - <genEnums typeSafeEnumCompatible="false" ecoreEnum="moea.ecore#//parameters/ExecutionModel"> - <genEnumLiterals ecoreEnumLiteral="moea.ecore#//parameters/ExecutionModel/TT_FAIL_SILENCE"/> - <genEnumLiterals ecoreEnumLiteral="moea.ecore#//parameters/ExecutionModel/TT_FAULT_DETECTION_VOTING"/> - </genEnums> - <genClasses ecoreClass="moea.ecore#//parameters/SystemParameters"> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//parameters/SystemParameters/executionModel"/> - </genClasses> - <genClasses image="false" ecoreClass="moea.ecore#//parameters/IOptimizer"/> - <genClasses ecoreClass="moea.ecore#//parameters/EAOptimizer"> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//parameters/EAOptimizer/alpha"/> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//parameters/EAOptimizer/mu"/> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//parameters/EAOptimizer/iterations"/> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//parameters/EAOptimizer/spea2Tournament"/> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//parameters/EAOptimizer/parallelExecution"/> - </genClasses> - </nestedGenPackages> - <nestedGenPackages prefix="Predefined" basePackage="org.fortiss.af3.exploration.moea.model" - disposableProviderFactory="true" ecorePackage="moea.ecore#//predefined"> - <genEnums typeSafeEnumCompatible="false" ecoreEnum="moea.ecore#//predefined/FailureMode"> - <genEnumLiterals ecoreEnumLiteral="moea.ecore#//predefined/FailureMode/FailSafe"/> - <genEnumLiterals ecoreEnumLiteral="moea.ecore#//predefined/FailureMode/FailOperational"/> - </genEnums> - <genEnums typeSafeEnumCompatible="false" ecoreEnum="moea.ecore#//predefined/FailureType"> - <genEnumLiterals ecoreEnumLiteral="moea.ecore#//predefined/FailureType/DUF"/> - <genEnumLiterals ecoreEnumLiteral="moea.ecore#//predefined/FailureType/SDC"/> - <genEnumLiterals ecoreEnumLiteral="moea.ecore#//predefined/FailureType/ALL"/> - </genEnums> - <genClasses ecoreClass="moea.ecore#//predefined/FailureMinObjective"> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//predefined/FailureMinObjective/mode"/> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//predefined/FailureMinObjective/type"/> - <genOperations ecoreOperation="moea.ecore#//predefined/FailureMinObjective/getTargetComponent"/> - <genOperations ecoreOperation="moea.ecore#//predefined/FailureMinObjective/setTargetComponent"> - <genParameters ecoreParameter="moea.ecore#//predefined/FailureMinObjective/setTargetComponent/targetComponent"/> - </genOperations> - </genClasses> - <genClasses ecoreClass="moea.ecore#//predefined/ReliabilityAnalysis"/> - <genClasses ecoreClass="moea.ecore#//predefined/EnergyMinObjective"/> - <genClasses ecoreClass="moea.ecore#//predefined/MultiLocationConstraint"> - <genTypeParameters ecoreTypeParameter="moea.ecore#//predefined/MultiLocationConstraint/LHT"/> - <genTypeParameters ecoreTypeParameter="moea.ecore#//predefined/MultiLocationConstraint/RHT"/> - <genFeatures notify="false" createChild="false" propertySortChoices="true" - ecoreFeature="ecore:EReference moea.ecore#//predefined/MultiLocationConstraint/singleLocationConstraints"/> - <genOperations ecoreOperation="moea.ecore#//predefined/MultiLocationConstraint/getLeftMultiLocationModelElement"/> - <genOperations ecoreOperation="moea.ecore#//predefined/MultiLocationConstraint/getAllRightMultiLocationModelElements"/> - </genClasses> - <genClasses ecoreClass="moea.ecore#//predefined/ComponentMultiAllocationConstraint"> - <genOperations ecoreOperation="moea.ecore#//predefined/ComponentMultiAllocationConstraint/setComponentMultiAllocations"> - <genParameters ecoreParameter="moea.ecore#//predefined/ComponentMultiAllocationConstraint/setComponentMultiAllocations/comp"/> - <genParameters ecoreParameter="moea.ecore#//predefined/ComponentMultiAllocationConstraint/setComponentMultiAllocations/execUnits"/> - </genOperations> - <genOperations ecoreOperation="moea.ecore#//predefined/ComponentMultiAllocationConstraint/getComponent"/> - <genOperations ecoreOperation="moea.ecore#//predefined/ComponentMultiAllocationConstraint/getExecutionUnits"/> - </genClasses> - <genClasses ecoreClass="moea.ecore#//predefined/ComponentMultiDislocationConstraint"> - <genOperations ecoreOperation="moea.ecore#//predefined/ComponentMultiDislocationConstraint/setComponentMultiDislocations"> - <genParameters ecoreParameter="moea.ecore#//predefined/ComponentMultiDislocationConstraint/setComponentMultiDislocations/comp"/> - <genParameters ecoreParameter="moea.ecore#//predefined/ComponentMultiDislocationConstraint/setComponentMultiDislocations/execUnits"/> - </genOperations> - <genOperations ecoreOperation="moea.ecore#//predefined/ComponentMultiDislocationConstraint/getComponent"/> - <genOperations ecoreOperation="moea.ecore#//predefined/ComponentMultiDislocationConstraint/getExecutionUnits"/> - </genClasses> - <genClasses ecoreClass="moea.ecore#//predefined/SafetyIntegrityLevelConstraint"> - <genFeatures notify="false" createChild="false" propertySortChoices="true" - ecoreFeature="ecore:EReference moea.ecore#//predefined/SafetyIntegrityLevelConstraint/components"/> - <genOperations ecoreOperation="moea.ecore#//predefined/SafetyIntegrityLevelConstraint/getLimitation"/> - </genClasses> - <genClasses ecoreClass="moea.ecore#//predefined/SafetyComparison"> - <genTypeParameters ecoreTypeParameter="moea.ecore#//predefined/SafetyComparison/T"/> - </genClasses> - </nestedGenPackages> - <nestedGenPackages prefix="Solutions" basePackage="org.fortiss.af3.exploration.moea.model" - disposableProviderFactory="true" ecorePackage="moea.ecore#//solutions"> - <genClasses ecoreClass="moea.ecore#//solutions/ExplorationResult"> - <genTypeParameters ecoreTypeParameter="moea.ecore#//solutions/ExplorationResult/T"/> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//solutions/ExplorationResult/result"/> - </genClasses> - <genClasses ecoreClass="moea.ecore#//solutions/ExplorationSolutionSet"> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//solutions/ExplorationSolutionSet/inputModelAdapter"/> - <genFeatures notify="false" createChild="false" propertySortChoices="true" - ecoreFeature="ecore:EReference moea.ecore#//solutions/ExplorationSolutionSet/targetSpecification"/> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference moea.ecore#//solutions/ExplorationSolutionSet/solutions"/> - </genClasses> - <genClasses ecoreClass="moea.ecore#//solutions/SingleExplorationSolutionMap"> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference moea.ecore#//solutions/SingleExplorationSolutionMap/solutionMap"/> - <genFeatures notify="false" createChild="false" propertySortChoices="true" - ecoreFeature="ecore:EReference moea.ecore#//solutions/SingleExplorationSolutionMap/solutionModelMap"/> - <genOperations ecoreOperation="moea.ecore#//solutions/SingleExplorationSolutionMap/containsKey"> - <genParameters ecoreParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/containsKey/key"/> - </genOperations> - <genOperations ecoreOperation="moea.ecore#//solutions/SingleExplorationSolutionMap/containsValue"> - <genParameters ecoreParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/containsValue/value"/> - </genOperations> - <genOperations ecoreOperation="moea.ecore#//solutions/SingleExplorationSolutionMap/get"> - <genParameters ecoreParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/get/key"/> - <genTypeParameters ecoreTypeParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/get/T"/> - </genOperations> - <genOperations ecoreOperation="moea.ecore#//solutions/SingleExplorationSolutionMap/keySet"/> - <genOperations ecoreOperation="moea.ecore#//solutions/SingleExplorationSolutionMap/put"> - <genParameters ecoreParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/put/key"/> - <genParameters ecoreParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/put/value"/> - <genTypeParameters ecoreTypeParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/put/T"/> - </genOperations> - <genOperations ecoreOperation="moea.ecore#//solutions/SingleExplorationSolutionMap/removeKey"> - <genParameters ecoreParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/removeKey/key"/> - <genTypeParameters ecoreTypeParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/removeKey/T"/> - </genOperations> - <genOperations ecoreOperation="moea.ecore#//solutions/SingleExplorationSolutionMap/values"/> - <genOperations ecoreOperation="moea.ecore#//solutions/SingleExplorationSolutionMap/getSolutionModel"> - <genParameters ecoreParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/getSolutionModel/modelType"/> - <genTypeParameters ecoreTypeParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/getSolutionModel/T"/> - </genOperations> - <genOperations ecoreOperation="moea.ecore#//solutions/SingleExplorationSolutionMap/putSolutionModel"> - <genParameters ecoreParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/putSolutionModel/modelType"/> - <genParameters ecoreParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/putSolutionModel/solutionModel"/> - <genTypeParameters ecoreTypeParameter="moea.ecore#//solutions/SingleExplorationSolutionMap/putSolutionModel/T"/> - </genOperations> - </genClasses> - <genClasses ecoreClass="moea.ecore#//solutions/ExplorationTargetToExplorationResultMap"> - <genFeatures notify="false" createChild="false" propertySortChoices="true" - ecoreFeature="ecore:EReference moea.ecore#//solutions/ExplorationTargetToExplorationResultMap/key"/> - <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference moea.ecore#//solutions/ExplorationTargetToExplorationResultMap/value"/> - </genClasses> - <genClasses ecoreClass="moea.ecore#//solutions/EJavaClassToEJavaObjectMap"> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//solutions/EJavaClassToEJavaObjectMap/key"/> - <genFeatures createChild="false" ecoreFeature="ecore:EAttribute moea.ecore#//solutions/EJavaClassToEJavaObjectMap/value"/> - </genClasses> - </nestedGenPackages> - </genPackages> -</genmodel:GenModel> diff --git a/org.fortiss.af3.exploration.alg/master/plugin.properties b/org.fortiss.af3.exploration.alg/master/plugin.properties deleted file mode 100644 index 217fb0c4ea72e20cf6efca3a137d9675c64d8a2d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/plugin.properties +++ /dev/null @@ -1,8 +0,0 @@ - -# <copyright> -# </copyright> -# -# $Id: plugin.properties 2872 2016-05-31 15:36:22Z barner $ - -pluginName = Exploration Algorithms -providerName = fortiss GmbH diff --git a/org.fortiss.af3.exploration.alg/master/plugin.xml b/org.fortiss.af3.exploration.alg/master/plugin.xml deleted file mode 100644 index 3c091022ecfaa9cc3490646592c36e1144498fe6..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/plugin.xml +++ /dev/null @@ -1,251 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> - -<!-- - <copyright> - </copyright> - - $Id: plugin.xml 3877 2016-11-10 09:35:28Z diewald $ ---> - -<plugin> - <extension-point id="transformationModule" name="Transformation Module" schema="schema/transformationModule.exsd"/> - <extension-point id="evaluator" name="Evaluator" schema="schema/evaluator.exsd"/> - <extension-point id="repairModule" name="RepairModule" schema="schema/repairModule.exsd"/> - <extension-point id="constraintTransformationModule" name="Constraint Transformation Module" schema="schema/constraintTransformationModule.exsd"/> - - <!-- Value providers for the annotation classes --> - <extension - point="org.fortiss.tooling.base.annotation"> - <annotation - binding="org.fortiss.af3.safety.annotation.valueprovider.SafeFailureFractionValueProvider"> - <modelElementClass - modelElementClass="org.fortiss.af3.platform.model.ExecutionUnit"> - </modelElementClass> - </annotation> - <annotation binding="org.fortiss.af3.exploration.alg.annotation.valueprovider.ComponentImplDiversityRefValueProvider"> - <modelElementClass modelElementClass="org.fortiss.af3.component.model.Component"/> - </annotation> - </extension> - - <extension - id="org.fortiss.af3.exploration.dsebackend" - point="org.fortiss.af3.exploration.dsebackend"> - <dsebackend - class="org.fortiss.af3.exploration.alg.contribution.Opt4JDseBackend"> - </dsebackend> - </extension> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated explorationDsl --> - <package - uri="http://www.fortiss.org/af3/explorationdsl" - class="org.fortiss.af3.exploration.dsl.model.ModelPackage" - genModel="model/explorationDsl.genmodel"/> - </extension> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated explorationDsl --> - <package - uri="http://www.fortiss.org/af3/exploration/operators" - class="org.fortiss.af3.exploration.dsl.model.operators.OperatorsPackage" - genModel="model/explorationDsl.genmodel"/> - </extension> - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated explorationDsl --> - <package - uri="http://www.fortiss.org/af3/exploration/expressions" - class="org.fortiss.af3.exploration.dsl.model.expressions.ExpressionsPackage" - genModel="model/explorationDsl.genmodel"/> - </extension> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated explorationDsl --> - <package - uri="http://www.fortiss.org/af3/exploration/patterns" - class="org.fortiss.af3.exploration.dsl.model.patterns.PatternsPackage" - genModel="model/explorationDsl.genmodel"/> - </extension> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated explorationDsl --> - <package - uri="http://www.fortiss.org/af3/exploration/types" - class="org.fortiss.af3.exploration.dsl.model.types.TypesPackage" - genModel="model/explorationDsl.genmodel"/> - </extension> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated moea --> - <package - uri="http://www.fortiss.org/af3/exploration/moea" - class="org.fortiss.af3.exploration.moea.model.MoeaPackage" - genModel="model/moea.genmodel"/> - </extension> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated moea --> - <package - uri="http://www.fortiss.org/af3/exploration/moea/annotation" - class="org.fortiss.af3.exploration.moea.model.annotation.AnnotationPackage" - genModel="model/moea.genmodel"/> - </extension> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated moea --> - <package - uri="http://www.fortiss.org/af3/exploration/moea/feature" - class="org.fortiss.af3.exploration.moea.model.feature.FeaturePackage" - genModel="model/moea.genmodel"/> - </extension> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated moea --> - <package - uri="http://www.fortiss.org/af3/exploration/moea/parameters" - class="org.fortiss.af3.exploration.moea.model.parameters.ParametersPackage" - genModel="model/moea.genmodel"/> - </extension> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated moea --> - <package - uri="http://www.fortiss.org/af3/exploration/moea/predefined" - class="org.fortiss.af3.exploration.moea.model.predefined.PredefinedPackage" - genModel="model/moea.genmodel"/> - </extension> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated moea --> - <package - uri="http://www.fortiss.org/af3/exploration/moea/solutions" - class="org.fortiss.af3.exploration.moea.model.solutions.SolutionsPackage" - genModel="model/moea.genmodel"/> - </extension> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated common --> - <package - uri="http://www.fortiss.org/af3/exploration/common" - class="org.fortiss.af3.exploration.model.CommonPackage" - genModel="model/common.genmodel"/> - </extension> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated common --> - <package - uri="http://www.fortiss.org/af3/exploration/common/location" - class="org.fortiss.af3.exploration.model.location.LocationPackage" - genModel="model/common.genmodel"/> - </extension> - - <extension point="org.eclipse.emf.ecore.generated_package"> - <!-- @generated common --> - <package - uri="http://www.fortiss.org/af3/exploration/common/time" - class="org.fortiss.af3.exploration.model.time.TimePackage" - genModel="model/common.genmodel"/> - </extension> - <extension - id="org.fortiss.af3.exploration.alg.transformationModule" - point="org.fortiss.af3.exploration.alg.transformationModule"> - <transformationModule - module="org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch.ComponentArchitectureFinalizer"> - <modelElementClass - modelElementClass="org.fortiss.af3.component.model.ComponentArchitecture"> - </modelElementClass> - </transformationModule> - <transformationModule - module="org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch.ComponentArchitectureInitializer"> - <modelElementClass - modelElementClass="org.fortiss.af3.component.model.ComponentArchitecture"> - </modelElementClass> - </transformationModule> - <!--transformationModule - module="org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch.ComponentArchitectureInserter"> - <modelElementClass - modelElementClass="org.fortiss.af3.component.model.ComponentArchitecture"> - </modelElementClass> - </transformationModule--> - <transformationModule - module="org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch.ComponentArchitectureInstantiator"> - <modelElementClass - modelElementClass="org.fortiss.af3.component.model.ComponentArchitecture"> - </modelElementClass> - </transformationModule> - <transformationModule - module="org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch.ComponentArchitectureReplicator"> - <modelElementClass - modelElementClass="org.fortiss.af3.component.model.ComponentArchitecture"> - </modelElementClass> - </transformationModule> - <transformationModule - module="org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch.ComponentArchitectureTransformer"> - <modelElementClass - modelElementClass="org.fortiss.af3.component.model.ComponentArchitecture"> - </modelElementClass> - </transformationModule> - <transformationModule - module="org.fortiss.af3.exploration.alg.dse.modeltransformation.deployment.DeploymentFinalizer"> - <modelElementClass - modelElementClass="org.fortiss.af3.deployment.model.Deployment"> - </modelElementClass> - </transformationModule> - <transformationModule - module="org.fortiss.af3.exploration.alg.dse.modeltransformation.deployment.DeploymentInitializer"> - <modelElementClass - modelElementClass="org.fortiss.af3.deployment.model.Deployment"> - </modelElementClass> - </transformationModule> - <transformationModule - module="org.fortiss.af3.exploration.alg.dse.modeltransformation.deployment.DeploymentReplicator"> - <modelElementClass - modelElementClass="org.fortiss.af3.deployment.model.Deployment"> - </modelElementClass> - </transformationModule> - <transformationModule - module="org.fortiss.af3.exploration.alg.dse.modeltransformation.deployment.ExplorationSolutionToDeployment"> - <modelElementClass - modelElementClass="org.fortiss.af3.deployment.model.Deployment"> - </modelElementClass> - </transformationModule> - <transformationModule - module="org.fortiss.af3.exploration.alg.dse.modeltransformation.safety.SafetyDiagUnitRemover"> - <modelElementClass - modelElementClass="org.fortiss.af3.component.model.ComponentArchitecture"> - </modelElementClass> - </transformationModule> - </extension> - <extension - id="org.fortiss.af3.exploration.alg.transformationModule" - point="org.fortiss.af3.exploration.alg.transformationModule"> - <transformationModule - module="org.fortiss.af3.exploration.alg.dse.modeltransformation.safety.SafetyChannelPortReplicator"> - <modelElementClass - modelElementClass="org.fortiss.af3.component.model.ComponentArchitecture"> - </modelElementClass> - </transformationModule> - </extension> - <extension - id="org.fortiss.af3.exploration.alg.evaluator" - point="org.fortiss.af3.exploration.alg.evaluator"> - <evaluator - module="org.fortiss.af3.exploration.alg.dse.evaluator.objective.EnergyObjectiveEvaluator"> - <modelElementClass - modelElementClass="org.fortiss.af3.exploration.moea.model.predefined.EnergyMinObjective"> - </modelElementClass> - </evaluator> - <evaluator - module="org.fortiss.af3.exploration.alg.dse.evaluator.objective.MappingEvaluatorObjective"> - <modelElementClass - modelElementClass="org.fortiss.af3.exploration.model.ObjectiveExpression"> - </modelElementClass> - </evaluator> - <evaluator - module="org.fortiss.af3.exploration.alg.dse.evaluator.constraint.MappingEvaluatorConstraint"> - <modelElementClass - modelElementClass="org.fortiss.af3.exploration.model.ConstraintExpression"> - </modelElementClass> - </evaluator> - </extension> -</plugin> diff --git a/org.fortiss.af3.exploration.alg/master/pom.xml b/org.fortiss.af3.exploration.alg/master/pom.xml deleted file mode 100644 index d3cf397d2a9c43e19054b89082c94430dc024a82..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - $Id: pom.xml 3418 2016-08-30 12:13:08Z barner $ - @version $Rev: 3418 $ - @ConQAT.Rating YELLOW Hash: 8E4EDB3139807C233D5B61B625C07C5C ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.fortiss.af3</groupId> - <artifactId>org.fortiss.af3.exploration.alg</artifactId> - <packaging>eclipse-plugin</packaging> - - <parent> - <groupId>org.fortiss.std.pom</groupId> - <artifactId>std-parent-pom</artifactId> - <version>1.0</version> - <relativePath>../../parent-pom.xml</relativePath> - </parent> - - <version>2.11.0-SNAPSHOT</version> -</project> \ No newline at end of file diff --git a/org.fortiss.af3.exploration.alg/master/schema/constraintTransformationModule.exsd b/org.fortiss.af3.exploration.alg/master/schema/constraintTransformationModule.exsd deleted file mode 100644 index 09233e9bbd46847428ff19818125ebd09797d8c3..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/schema/constraintTransformationModule.exsd +++ /dev/null @@ -1,107 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="org.fortiss.af3.exploration.alg" xmlns="http://www.w3.org/2001/XMLSchema"> -<annotation> - <appInfo> - <meta.schema plugin="org.fortiss.af3.exploration.alg" id="constraintTransformationModule" name="Constraint Transformation Module"/> - </appInfo> - <documentation> - - </documentation> - </annotation> - - <include schemaLocation="schema://org.fortiss.tooling.kernel/schema/modelElement.exsd"/> - - <element name="extension"> - <annotation> - <appInfo> - <meta.element /> - </appInfo> - </annotation> - <complexType> - <sequence> - <element ref="constraintTransformationModule" minOccurs="1" maxOccurs="unbounded"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="constraintTransformationModule"> - <complexType> - <sequence> - <element ref="modelElementClass" minOccurs="1" maxOccurs="unbounded"/> - </sequence> - <attribute name="module" type="string" use="required"> - <annotation> - <documentation> - The model element compositor. - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn=":org.fortiss.af3.exploration.alg.service.IExplorationContraintTransformationModule"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiinfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - -</schema> diff --git a/org.fortiss.af3.exploration.alg/master/schema/evaluator.exsd b/org.fortiss.af3.exploration.alg/master/schema/evaluator.exsd deleted file mode 100644 index 172f7d118356a8f57636665d2d8488b3563328d9..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/schema/evaluator.exsd +++ /dev/null @@ -1,107 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="org.fortiss.af3.exploration.alg" xmlns="http://www.w3.org/2001/XMLSchema"> -<annotation> - <appInfo> - <meta.schema plugin="org.fortiss.af3.exploration.alg" id="evaluator" name="Evaluator"/> - </appInfo> - <documentation> - [Enter description of this extension point.] - </documentation> - </annotation> - - <include schemaLocation="schema://org.fortiss.tooling.kernel/schema/modelElement.exsd"/> - - <element name="extension"> - <annotation> - <appInfo> - <meta.element /> - </appInfo> - </annotation> - <complexType> - <sequence minOccurs="1" maxOccurs="unbounded"> - <element ref="evaluator"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="evaluator"> - <complexType> - <sequence> - <element ref="modelElementClass" minOccurs="1" maxOccurs="unbounded"/> - </sequence> - <attribute name="module" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn=":org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiinfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - -</schema> diff --git a/org.fortiss.af3.exploration.alg/master/schema/repairModule.exsd b/org.fortiss.af3.exploration.alg/master/schema/repairModule.exsd deleted file mode 100644 index fb5a26f2f6942056604eec8ba24230fe6a04a7f3..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/schema/repairModule.exsd +++ /dev/null @@ -1,107 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="org.fortiss.af3.exploration.alg" xmlns="http://www.w3.org/2001/XMLSchema"> -<annotation> - <appInfo> - <meta.schema plugin="org.fortiss.af3.exploration.alg" id="repairModule" name="RepairModule"/> - </appInfo> - <documentation> - Extension point to be implemented by repair modules. It allows to "repair" Genotypes based on the evaluation results. - </documentation> - </annotation> - - <include schemaLocation="schema://org.fortiss.tooling.kernel/schema/modelElement.exsd"/> - - <element name="extension"> - <annotation> - <appInfo> - <meta.element /> - </appInfo> - </annotation> - <complexType> - <sequence minOccurs="1" maxOccurs="unbounded"> - <element ref="repairModule"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="repairModule"> - <complexType> - <sequence> - <element ref="objectClass"/> - </sequence> - <attribute name="module" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn=":org.fortiss.af3.exploration.alg.service.IRepairModule"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - AF3 2.11 - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiinfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - -</schema> diff --git a/org.fortiss.af3.exploration.alg/master/schema/transformationModule.exsd b/org.fortiss.af3.exploration.alg/master/schema/transformationModule.exsd deleted file mode 100644 index c5f7c6625f8ed9b2814bd0127baf621087dbb9b3..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/schema/transformationModule.exsd +++ /dev/null @@ -1,107 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- Schema file written by PDE --> -<schema targetNamespace="org.fortiss.af3.exploration.alg" xmlns="http://www.w3.org/2001/XMLSchema"> -<annotation> - <appInfo> - <meta.schema plugin="org.fortiss.af3.exploration.alg" id="transformationModule" name="Transformation Module"/> - </appInfo> - <documentation> - - </documentation> - </annotation> - - <include schemaLocation="schema://org.fortiss.tooling.kernel/schema/modelElement.exsd"/> - - <element name="extension"> - <annotation> - <appInfo> - <meta.element /> - </appInfo> - </annotation> - <complexType> - <sequence> - <element ref="transformationModule" minOccurs="1" maxOccurs="unbounded"/> - </sequence> - <attribute name="point" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="id" type="string"> - <annotation> - <documentation> - - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string"> - <annotation> - <documentation> - - </documentation> - <appInfo> - <meta.attribute translatable="true"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="transformationModule"> - <complexType> - <sequence> - <element ref="modelElementClass" minOccurs="1" maxOccurs="unbounded"/> - </sequence> - <attribute name="module" type="string" use="required"> - <annotation> - <documentation> - The model element compositor. - </documentation> - <appInfo> - <meta.attribute kind="java" basedOn=":org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule"/> - </appInfo> - </annotation> - </attribute> - </complexType> - </element> - - <annotation> - <appInfo> - <meta.section type="since"/> - </appInfo> - <documentation> - [Enter the first release in which this extension point appears.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="examples"/> - </appInfo> - <documentation> - [Enter extension point usage example here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="apiinfo"/> - </appInfo> - <documentation> - [Enter API information here.] - </documentation> - </annotation> - - <annotation> - <appInfo> - <meta.section type="implementation"/> - </appInfo> - <documentation> - [Enter information about supplied implementation of this extension point.] - </documentation> - </annotation> - - -</schema> diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/ExplorationAlg.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/ExplorationAlg.java deleted file mode 100644 index 6ceb51d3eca9534772eca21522d6b2e5bf6bb2da..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/ExplorationAlg.java +++ /dev/null @@ -1,83 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExplorationAlg.java 3875 2016-11-09 16:18:09Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg; - -import static org.fortiss.af3.exploration.alg.ExplorationAlgActivator.getDefault; -import static org.fortiss.af3.exploration.alg.service.ExplorationService.getService; - -import org.fortiss.af3.exploration.alg.service.IExplorationConstraintTransformationService; -import org.fortiss.af3.exploration.alg.service.IExplorationEvaluatationService; -import org.fortiss.af3.exploration.alg.service.IExplorationRepairService; -import org.fortiss.af3.exploration.alg.service.IExplorationService; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService; -import org.fortiss.af3.exploration.alg.service.internal.ExplorationConstraintTransformationService; -import org.fortiss.af3.exploration.alg.service.internal.ExplorationEvaluationService; -import org.fortiss.af3.exploration.alg.service.internal.ExplorationRepairService; -import org.fortiss.af3.exploration.alg.service.internal.ExplorationTransformationService; -import org.osgi.framework.BundleContext; - -/** - * Centralized class that provides the startup routines of all services provided by this plugin. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3875 $ - * @ConQAT.Rating RED Hash: 517D1711FB1E18CAE3E08D72920846ED - */ -public final class ExplorationAlg { - - /** - * Initializes the {@link IExplorationService}s contained in this plugin (first service - * activation stage). - */ - public static void initialize() { - registerServices(); - - getService(IExplorationConstraintTransformationService.class).initializeService(); - getService(IExplorationEvaluatationService.class).initializeService(); - getService(IExplorationRepairService.class).initializeService(); - getService(IExplorationTransformationService.class).initializeService(); - } - - /** Registers the provided services with the {@link BundleContext}. */ - private static void registerServices() { - BundleContext context = getDefault().getBundle().getBundleContext(); - - context.registerService(IExplorationConstraintTransformationService.class.getName(), - ExplorationConstraintTransformationService.getInstance(), null); - context.registerService(IExplorationEvaluatationService.class.getName(), - ExplorationEvaluationService.getInstance(), null); - context.registerService(IExplorationRepairService.class.getName(), - ExplorationRepairService.getInstance(), null); - context.registerService(IExplorationTransformationService.class.getName(), - ExplorationTransformationService.getInstance(), null); - } - - /** - * Starts the {@link IExplorationService}s contained in this plugin (second service activation - * stage). - */ - public static void start() { - getService(IExplorationConstraintTransformationService.class).startService(); - // The Transformation Service must be started before the Evaluation Service such that it can - // check for the availability of required transformation modules. - getService(IExplorationTransformationService.class).startService(); - getService(IExplorationEvaluatationService.class).startService(); - getService(IExplorationRepairService.class).startService(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/ExplorationAlgActivator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/ExplorationAlgActivator.java deleted file mode 100644 index 47e6ae9b68012ec5e4d6a13ffabc757cda495599..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/ExplorationAlgActivator.java +++ /dev/null @@ -1,56 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExplorationAlgActivator.java 3770 2016-10-25 13:50:28Z diewald $ -| | -| Copyright 2013 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3770 $ - * @ConQAT.Rating RED Hash: 2775799EEBECA23B88F232FF162983D8 - */ -public class ExplorationAlgActivator extends Plugin { - /** The plug-in ID. */ - public static final String PLUGIN_ID = ExplorationAlgActivator.class.getPackage().getName(); //$NON-NLS-1$ - - /** The shared instance. */ - private static ExplorationAlgActivator plugin; - - /** {@inheritDoc} */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /** {@inheritDoc} */ - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** Returns the shared instance. */ - public static ExplorationAlgActivator getDefault() { - return plugin; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/annotation/valueprovider/ComponentImplDiversityRefValueProvider.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/annotation/valueprovider/ComponentImplDiversityRefValueProvider.java deleted file mode 100644 index d3eecaf0a9856853f7b12aabf48c86dabf579867..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/annotation/valueprovider/ComponentImplDiversityRefValueProvider.java +++ /dev/null @@ -1,148 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComponentImplDiversityRefValueProvider.java 1804 2015-11-19 14:28:47Z barner $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.annotation.valueprovider; - -import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.component.utils.ComponentArchitectureUtils; -import org.fortiss.af3.exploration.moea.model.annotation.AnnotationPackage; -import org.fortiss.af3.exploration.moea.model.annotation.ComponentDiverseImplRef; -import org.fortiss.tooling.base.annotation.valueprovider.EStructuralFeatureDescriptor; -import org.fortiss.tooling.base.annotation.valueprovider.EStructuralFeatureValueProviderBase; -import org.fortiss.tooling.base.annotation.valueprovider.IAnnotationValueProvider; -import org.fortiss.tooling.base.model.element.IAnnotatedSpecification; - -/** - * {@link IAnnotationValueProvider} for referencing {@link Component}s that represent a diverse - * implementation of a component that is part of a functional description of a - * {@link ComponentArchitecture} - * - * @author barner - * @author $Author: barner $ - * @version $Rev: 1804 $ - * @ConQAT.Rating RED Hash: 82835CDFD50148F99673264F2C847168 - */ -public class ComponentImplDiversityRefValueProvider extends - EStructuralFeatureValueProviderBase<ComponentDiverseImplRef> { - - /** - * {@link EStructuralFeatureDescriptor} that filters the available objects to be selected for - * the reference provided by this annotation. - */ - private static class DiversityRefFilterEStructuralFeatureDescriptor extends - EStructuralFeatureDescriptor { - - /** Constructs a new {@link DiversityRefFilterEStructuralFeatureDescriptor}. */ - public DiversityRefFilterEStructuralFeatureDescriptor(EReference eReference, - EReferenceScope eReferenceScope) { - super(eReference, eReferenceScope); - } - - /** {@inheritDoc} */ - @Override - public boolean isAvailableObject(EObject obj, IAnnotatedSpecification specification, - EObject modelElement) { - - // Only offer only Components - if(!(obj instanceof Component)) { - return false; - } - Component refComponent = (Component)obj; - - // Allow references to Components implementing diversity only if the "abstract", i.e. - // the referencing, Component is atomic. - if(modelElement instanceof Component && - ComponentArchitectureUtils.isAtomicComponent((Component)modelElement)) { - - ComponentArchitecture targetCompArch = - getParentElement(obj, ComponentArchitecture.class, false); - - // Check, whether the the parent ComponentArchitcture is the component pool (via the - // name of the top-level Component). - if(targetCompArch != null && - targetCompArch.getTopComponent().getName().contains("Component Pool")) { - // Do not allow self references inside the component pool. - ComponentArchitecture sourceCompArch = - getParentElement(modelElement, ComponentArchitecture.class, false); - if(sourceCompArch != null && sourceCompArch != targetCompArch) { - // Only return diverse Component implementations if the referenced Component - // is a sub-element of a Component in the Component Pool. (2nd layer) - if(getDistToTopLevel(refComponent, targetCompArch) == 1) { - return true; - } - } - } - } - return false; - } - } - - /** - * Returns the "level" in the hierarchy of a "pure" {@link ComponentArchitecture} i.e. a - * {@link ComponentArchitecture} consisting only of {@link Component}s. The {@link Component}s - * contained in the top level component are considered to be at level 0. - */ - private static int getDistToTopLevel(Component comp, ComponentArchitecture compArch) { - if(comp == compArch.getTopComponent()) { - return -1; - } - - Component parentComp = comp.getParentComponent(); - int level = 0; - while(parentComp != null && parentComp != compArch.getTopComponent()) { - parentComp = parentComp.getParentComponent(); - level++; - } - - return level; - } - - /** {@link EStructuralFeature}s managed by this {@link IAnnotationValueProvider}. */ - private static Map<String, EStructuralFeatureDescriptor> createStructuralFeatureDescriptorMap() { - Map<String, EStructuralFeatureDescriptor> rval = - new HashMap<String, EStructuralFeatureDescriptor>(); - - rval.put(IAnnotationValueProvider.DEFAULT_KEY, - new DiversityRefFilterEStructuralFeatureDescriptor( - AnnotationPackage.Literals.COMPONENT_DIVERSE_IMPL_REF__COMPONENT_REF, - EStructuralFeatureDescriptor.EReferenceScope.PROJECT)); - - return Collections.unmodifiableMap(rval); - } - - /** Constructs a value provider for the (derived) {@link ComponentDiverseImplRef} annotation. */ - public ComponentImplDiversityRefValueProvider() { - super(AnnotationPackage.Literals.COMPONENT_DIVERSE_IMPL_REF, - createStructuralFeatureDescriptorMap()); - } - - /** {@inheritDoc} */ - @Override - public String getAnnotationName(ComponentDiverseImplRef specification) { - return "Diverse Implementations"; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/contribution/Opt4JDseBackend.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/contribution/Opt4JDseBackend.java deleted file mode 100644 index b24d9bf2829907e189087f4dff8f0e223ab26e62..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/contribution/Opt4JDseBackend.java +++ /dev/null @@ -1,121 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: Opt4JDseBackend.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.contribution; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.exploration.alg.dse.CompositeExplorationSolution; -import org.fortiss.af3.exploration.alg.dse.Explorer; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemParameterContainer; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3.AF3SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.extension.DseInputParametersBase; -import org.fortiss.af3.exploration.extension.IDseBackend; -import org.fortiss.af3.exploration.extension.IDseInputParameters; -import org.fortiss.af3.exploration.model.ExplorationSolution; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.IExplorationFeature; -import org.fortiss.af3.exploration.moea.model.DseSpecification; -import org.fortiss.af3.exploration.moea.model.solutions.ExplorationSolutionSet; -import org.fortiss.af3.platform.model.PlatformArchitecture; - -/** - * Contributor class to allow launching this DSE backend from the DSE perspective. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: 6672F9F74B05BA6FE90A150D49FAB27D - */ -public class Opt4JDseBackend implements IDseBackend { - - /** Holds the input parameters required for the DSE in this plugin. */ - private Opt4JDSEInputParameters inputParameterContainer = new Opt4JDSEInputParameters(); - - /** {@inheritDoc} */ - @Override - public IDseInputParameters getRequiredParameterContainer() { - return inputParameterContainer; - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Optional<ExplorationSolution> executeDSE(ExplorationSpecification expSpec, - Set<Class<?>> solutionTypes, IDseInputParameters inputParameters, - Collection<IExplorationFeature> explorationModules, IProgressMonitor monitor) - throws Exception { - ExplorationSolutionSet explorationSolutionSet; - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - inputParameters.validateInputParametersPresent(); - if(!(inputParameters instanceof Opt4JDSEInputParameters)) { - throw new Exception("Wrong input parameter container type."); - } - Opt4JDSEInputParameters parameters = (Opt4JDSEInputParameters)inputParameters; - - // Input to DSE: {@link SystemModelAdapter} and {@link DesignSpaceExploration}. - // SystemModelAdapter systemModelAdapter; - systemModelAdapter = - new AF3SystemModelAdapter( - parameters.getInputParameter(ComponentArchitecture.class), - parameters.getInputParameter(PlatformArchitecture.class), - parameters.getInputParameter(SystemParameterContainer.class)); - - try { - Explorer explorer = new Explorer(); - Set<Class<? extends IExplorationEncoding>> solPhenotypeTypes = new HashSet<>(); - for(Class<?> solType : solutionTypes) { - if(!IExplorationEncoding.class.isAssignableFrom(solType)) { - throw new Exception( - "The demanded solution is not available in the sleceted DSE backend."); - } - solPhenotypeTypes.add((Class<? extends IExplorationEncoding>)solType); - } - CompositeExplorationSolution<?> expResult = - explorer.explore(parameters.getInputParameter(DseSpecification.class), expSpec, - systemModelAdapter, solPhenotypeTypes, monitor, true); - explorationSolutionSet = expResult.convertToExplorationSolution(); - explorationSolutionSet.setInputModelAdapter(systemModelAdapter); - } catch(Exception ex) { - // TODO: readd code to present the schedule which failed... Use the LoggingService from - // the kernel. - // ExplorationUiUtil.showExceptionErrorAsync( - // "Design Space Exploration: Error", ex.getMessage(), ex); - // if(ex instanceof ScheduleRuntimeException) { - // StrictTTSchedule<?, ?> faultySchedule = - // ((ScheduleRuntimeException)ex).getSchedule(); - // SchedulePlotter sp = new SchedulePlotter(faultySchedule); - // sp.createPlot(); - // } - throw ex; - } - return Optional.of(explorationSolutionSet); - } - - /** Defines the required input parameters of this DSE backend. */ - protected class Opt4JDSEInputParameters extends DseInputParametersBase { - // Parameter container wrapping a standard java map. - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/CompositeExplorationSolution.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/CompositeExplorationSolution.java deleted file mode 100644 index 9d8028679601d188ffa66cc41f237ed7b614027b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/CompositeExplorationSolution.java +++ /dev/null @@ -1,170 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CompositeExplorationSolution.java 3180 2016-07-04 16:58:20Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse; - -import static org.fortiss.af3.exploration.alg.util.DesignSpaceExplorationModelElementFactory.createSingleExplorationSolutionMap; - -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.IExplorationSolution; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.IScheduleSolution; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.moea.model.solutions.ExplorationResult; -import org.fortiss.af3.exploration.moea.model.solutions.ExplorationSolutionSet; -import org.fortiss.af3.exploration.moea.model.solutions.SingleExplorationSolutionMap; -import org.fortiss.af3.exploration.moea.model.solutions.SolutionsFactory; -import org.opt4j.core.Value; - -/** - * Result of a DSE run, i.e. the {@link IExplorationSolution}s and {@link SolutionQuantification}s - * for all pareto-optimal {@link IExplorationSolution}s. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3180 $ - * @ConQAT.Rating RED Hash: F349D62B3028382E9C30576B28B0F311 - */ -public class CompositeExplorationSolution<P extends Phenotype> { - - /** - * Map to store the {@link SolutionQuantification} for all pareto-optimal - * {@link IExplorationSolution}s of an exploration run. - */ - private Map<IExplorationSolution<?>, SolutionQuantification> explorationResultMap = - new HashMap<IExplorationSolution<?>, SolutionQuantification>(); - - /** Number of completed iterations that produced this {@link CompositeExplorationSolution}. */ - private int completedIterations; - - /** - * Adds the {@link SolutionQuantification} for a given {@link IExplorationSolution}. - */ - public void addExplorationSolution(IExplorationSolution<?> solution, - SolutionQuantification result) { - explorationResultMap.put(solution, result); - } - - /** - * Deletes a {@link IExplorationSolution} and its according {@link SolutionQuantification} from - * the map containing the results. - * This method is useful for removing, e.g., infeasible results. - */ - public void deleteSolutionQuantification(IExplorationSolution<?> solution) { - explorationResultMap.remove(solution); - } - - /** - * Returns the Map of exploration solutions in the form {@link IExplorationSolution}, - * {@link SolutionQuantification}. This method is intended to provide intermediate or final - * solution to the user. - */ - public Map<IExplorationSolution<?>, SolutionQuantification> getSolutionQuantification() { - return explorationResultMap; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - String rval = - "After " + completedIterations + - " completed iterations, the exploration result contains " + - explorationResultMap.size() + " individual(s) (= archive size).\n\n"; - - for(IExplorationSolution<?> solution : explorationResultMap.keySet()) { - IScheduleSolution<?> scheduleSolution = solution.getSubSolution(StrictTTSchedule.class); - InstantiatedTaskMappingEncoding<?> mappingSolution = - solution.getSubSolution(InstantiatedTaskMappingEncoding.class); - rval += "------------------------------------------------\n"; - rval += "Encoding (genotype):\n" + mappingSolution + "\n"; - rval += "Solution (phenotype):\n" + scheduleSolution + "\n"; - } - - return rval; - } - - /** Creates a copy of the ExplorationResult object this operator is applied to. */ - public CompositeExplorationSolution<P> copy() { - CompositeExplorationSolution<P> duplicatedExplorationResult = - new CompositeExplorationSolution<P>(); - - for(IExplorationSolution<?> solution : explorationResultMap.keySet()) { - duplicatedExplorationResult.addExplorationSolution(solution, - explorationResultMap.get(solution)); - } - - duplicatedExplorationResult.setCompletedIterations(completedIterations); - - return duplicatedExplorationResult; - } - - /** Records the number of completed iterations. */ - public void setCompletedIterations(int completedIterations) { - this.completedIterations = completedIterations; - } - - /** Returns the number of completed iterations. */ - public int getCompletedIterations() { - return completedIterations; - } - - /** - * Returns {@code this} {@link CompositeExplorationSolution} as a {@link ExplorationSolutionSet} - * . - */ - @SuppressWarnings("unchecked") - public <T> ExplorationSolutionSet convertToExplorationSolution() throws Exception { - ExplorationSolutionSet expSol = SolutionsFactory.eINSTANCE.createExplorationSolutionSet(); - for(Entry<IExplorationSolution<?>, SolutionQuantification> singleSolutionEntry : explorationResultMap - .entrySet()) { - SingleExplorationSolutionMap expSolutionMap = createSingleExplorationSolutionMap(); - IExplorationSolution<?> singleSolution = singleSolutionEntry.getKey(); - - // Be transparent, provide all Phenotypes - for(Class<? extends Phenotype> subSolutionType : singleSolution - .getAllSubSolutionClasses()) { - // TODO: Dirty cast, remove. - expSolutionMap.putSolutionModel((Class<T>)subSolutionType, - (T)singleSolution.getSubSolution(subSolutionType)); - } - - for(Entry<ExplorationTarget<?>, Value<?>> solEntry : singleSolutionEntry.getValue() - .entrySet()) { - if(expSolutionMap.containsKey(solEntry.getKey())) { - throw new Exception( - "Could not convert to the ExplorationResult to an ExplorationSolutionSet. The exist multiple results for the ExplorationTarget " + - solEntry.getKey().getName() + - " where there should be only one."); - } - // TODO: this is unsafe, the SolutionQuantification class should be either - // eliminated, or adapted such that we obtain the type safety that is also aimed - // at in the EMM. - @SuppressWarnings("rawtypes") ExplorationResult res = - SolutionsFactory.eINSTANCE.createExplorationResult(); - res.setResult(solEntry.getValue().getDouble()); - expSolutionMap.put((ExplorationTarget<?>)solEntry.getKey(), res); - } - expSol.getSolutions().add(expSolutionMap); - } - return expSol; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/DSEFactory.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/DSEFactory.java deleted file mode 100644 index 68b8cbc4f48a5d4fca6673aa6ba2ebebd86bf1e7..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/DSEFactory.java +++ /dev/null @@ -1,317 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DSEFactory.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse; - -import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf; - -import java.util.ArrayList; -import java.util.List; - -import javax.activation.UnsupportedDataTypeException; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.ArchitectureExplorationCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.safetyfunctionarch.SafetyFunctionArchCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.AbstractTaskMappingCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.TaskMappingCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -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.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph.DecoderDependencyGraph; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.problem.CompositeProblemModuleBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.ArchitectureDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.ArchitectureExplorationProblemModule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.StrictTTDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.comm.MessageDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatemapping.AbstractTaskMappingDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatetaskgraph.InstantiatedTaskMappingDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatetaskgraph.InstantiatedTaskMappingDecoderAcyclic; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.safetyfunction.SFEncodingDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.safetyfunction.SFGraphDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.safetyfunction.SFMappingConstraintDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.safetyfunction.SFMappingDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.taskmapping.AbstractTaskMappingIdentityDecoder; -import org.fortiss.af3.exploration.alg.dse.evaluator.ArchitectureEvaluator; -import org.fortiss.af3.exploration.alg.dse.sysmodel.FailSilentExecModelFactory; -import org.fortiss.af3.exploration.alg.dse.sysmodel.FaultDetectionVotingExecModelFactory; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.moea.model.DseSpecification; -import org.fortiss.af3.exploration.moea.model.feature.SafetyExploration; -import org.fortiss.af3.exploration.moea.model.parameters.ExecutionModel; - -/** - * Factory to create exploration problems solved by the DSE. It is used to create the single parts - * of the chain that define and solve the associated optimization problem. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: 0A1C5E9A6738703F9964D7DB6F92A1C8 - */ -public class DSEFactory { - - /** The instance (singleton) of the {@link DSEFactory}. */ - private static final class InstanceHolder { - /** the "real" instance. */ - static final DSEFactory INSTANCE = new DSEFactory(); - } - - /** Private constructor to prevent instantiation from external (singleton). */ - private DSEFactory() { - } - - /** Returns the instance of this {@link DSEFactory}. */ - public static DSEFactory getInstance() { - return InstanceHolder.INSTANCE; - } - - /** - * Creates/Registers the sub problem definitions that compose the overall architectural - * exploration problem. - * - * @param archExpProblemModule - * The {@link CompositeProblemModuleBase} declaring the architectural exploration - * problem. - * @param dse - * The design space exploration description. - * @param systemModelAdapter - * The adapter to model of the system on which the dse is executed. - * @throws Exception - * if (one of) the sub problem(s) cannot be registered. - */ - @SuppressWarnings("unchecked") - public - <C, S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - void createSubProblems(ArchitectureExplorationProblemModule archExpProblemModule, - DseSpecification dse, ExplorationSpecification expSpec, - SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execDepGraph) throws Exception { - // Java-limitation: it is not possible to pass the generic to the static methods. - TaskMappingFactory<S, T> tmFactory = - (TaskMappingFactory<S, T>)TaskMappingFactory.getInstance(); - SafetyExploration sfExplorationModule = - pickFirstInstanceOf(SafetyExploration.class, dse.getFeatures()); - if(sfExplorationModule != null) { - // Initialize & register safety function adapters with the SystemModelAdapter. - sfExplorationModule.getAdapters().parallelStream() - .forEach(a -> a.initializeAdapter(systemModelAdapter)); - systemModelAdapter.addSafetyFunctionAdapters(sfExplorationModule.getAdapters()); - createSafetyFunctionArchProblem(archExpProblemModule, systemModelAdapter, execDepGraph); - } - createAbstractTaskMappingProblem(tmFactory, archExpProblemModule, expSpec, - systemModelAdapter, execDepGraph); - createTaskMappingInstantiationProblem(tmFactory, archExpProblemModule, expSpec, - systemModelAdapter, execDepGraph); - } - - /** - * Creates the safety function architecture exploration sub-problem, or, more specifically, - * the - * creators of this sub-problem. - * - * @param archExpProblemModule - * The {@link CompositeProblemModuleBase} declaring the architectural exploration - * problem. - * @param systemModelAdapter - * The adapter to model of the system on which the dse is executed. - * @throws Exception - * if (one of) the sub problem(s) cannot be registered. - */ - @SuppressWarnings("unchecked") - private <C, T extends SafetyFunctionArchEncoding<C>> void createSafetyFunctionArchProblem( - ArchitectureExplorationProblemModule archExpProblemModule, - SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execDepGraph) throws Exception { - // These suppress warnings are required since type erasure in Java does not allow to pass - // XY<Z>.class. - @SuppressWarnings("rawtypes") SafetyFunctionArchCreator sfCreator = - new SafetyFunctionArchCreator<C>(systemModelAdapter, execDepGraph); - @SuppressWarnings("rawtypes") SFEncodingDecoder sfEncodingDecoder = - new SFEncodingDecoder<>(); - @SuppressWarnings("rawtypes") SFGraphDecoder sfGraphDecoder = - new SFGraphDecoder<C>(systemModelAdapter); - @SuppressWarnings("rawtypes") SFMappingDecoder sfMappingDecoder = - new SFMappingDecoder<C>(systemModelAdapter); - @SuppressWarnings("rawtypes") SFMappingConstraintDecoder sfMappingConstraintDecoder = - new SFMappingConstraintDecoder<C>(systemModelAdapter); - - sfCreator.registerAssocDecoders(sfEncodingDecoder); - sfCreator.registerAssocDecoders(sfGraphDecoder); - sfCreator.registerAssocDecoders(sfMappingDecoder); - sfCreator.registerAssocDecoders(sfMappingConstraintDecoder); - - @SuppressWarnings("rawtypes") List<ComposableDecoder> sfDecoders = new ArrayList<>(); - sfDecoders.add(sfEncodingDecoder); - sfDecoders.add(sfGraphDecoder); - sfDecoders.add(sfMappingDecoder); - sfDecoders.add(sfMappingConstraintDecoder); - - archExpProblemModule.registerSubProblem(SafetyFunctionArchEncoding.class, sfCreator, - sfDecoders); - } - - /** - * Creates a task mapping sub-problem (see {@link AbstractTaskMappingEncoding}) which describes - * the problem of mapping a logical/functional application architecture to a defined platform - * architecture. Note that logical components may also be empty containers in this sub problem - * description and which must be instantiated first to derive a valid deployment. - * - * @param tmFactory - * Factory which manages the creation tasks associated with task mapping problems - * @param archExpProblemModule - * The {@link CompositeProblemModuleBase} declaring the architectural exploration - * problem. - * @param dse - * The design space exploration description. - * @param systemModelAdapter - * The adapter to model of the system on which the dse is executed. - * @throws Exception - * if (one of) the sub problem(s) cannot be registered. - */ - @SuppressWarnings("unchecked") - private <S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - void createAbstractTaskMappingProblem(TaskMappingFactory<S, T> tmFactory, - ArchitectureExplorationProblemModule archExpProblemModule, - ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execDepGraph) throws Exception { - Class<AbstractTaskMappingEncoding> tmEnodingClass = AbstractTaskMappingEncoding.class; - AbstractTaskMappingCreator tmCreator = - tmFactory.createAbstractTaskMappingCreator(expSpec, systemModelAdapter, - execDepGraph); - @SuppressWarnings("rawtypes") List<ComposableDecoder> abstrTaskDecoders = new ArrayList<>(); - AbstractTaskMappingDecoder<?, ?> atmDecoder = - tmFactory.createAbstractTaskMappingDecoder(systemModelAdapter, expSpec); - AbstractTaskMappingIdentityDecoder idtDecoder = new AbstractTaskMappingIdentityDecoder(); - abstrTaskDecoders.add(atmDecoder); - abstrTaskDecoders.add(idtDecoder); - // TODO: replace with the registration method that uses lists. - tmCreator.registerAssocDecoders(atmDecoder); - tmCreator.registerAssocDecoders(idtDecoder); - - archExpProblemModule.registerSubProblem(tmEnodingClass, tmCreator, abstrTaskDecoders); - } - - /** - * Creates a task mapping sub-problem (see {@link InstantiatedTaskMappingEncoding}) which - * describes - * the problem of instantiating a mapped logical/functional application architecture to a - * defined platform architecture. Here, the focus is on optimizing the instantiation of - * "abstract" {@link IDeployableComponentAdapter}s. - * - * @param tmFactory - * Factory which manages the creation tasks associated with task mapping problems - * @param archExpProblemModule - * The {@link CompositeProblemModuleBase} declaring the architectural exploration - * problem. - * @param dse - * The design space exploration description. - * @param systemModelAdapter - * The adapter to model of the system on which the dse is executed. - * @throws Exception - * if (one of) the sub problem(s) cannot be registered. - */ - @SuppressWarnings("unchecked") - private <S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - void createTaskMappingInstantiationProblem(TaskMappingFactory<S, T> tmFactory, - ArchitectureExplorationProblemModule archExpProblemModule, - ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execDepGraph) throws Exception { - // These suppress warnings are required since type erasure in Java does not allow to pass - // XY<Z>.class. - StrictTTDecoder<S, T> tmDecoder = - tmFactory.createStrictTTDecoder(systemModelAdapter, expSpec); - InstantiatedTaskMappingDecoder<S, ?> tgDecoder = - tmFactory.createInstantiatedTaskMappingDecoder(systemModelAdapter); - InstantiatedTaskMappingDecoderAcyclic<S, ?> acycTgDecoder = - tmFactory.createAbstractToAcyclicTaskGraphDecoder(systemModelAdapter); - @SuppressWarnings("rawtypes") MessageDecoder msgDecoder = - tmFactory.createMessageDecoder(systemModelAdapter); - @SuppressWarnings("rawtypes") TaskMappingCreator tmCreator = - tmFactory.createTaskMappingCreator(expSpec, systemModelAdapter, execDepGraph); - @SuppressWarnings("rawtypes") List<ComposableDecoder> instTaskDecoders = new ArrayList<>(); - instTaskDecoders.add(tgDecoder); - instTaskDecoders.add(acycTgDecoder); - instTaskDecoders.add(msgDecoder); - instTaskDecoders.add(tmDecoder); - tmCreator.registerAssocDecoders(instTaskDecoders); - - archExpProblemModule.registerSubProblem(InstantiatedTaskMappingEncoding.class, tmCreator, - instTaskDecoders); - } - - /** - * Creates a new {@link ArchitectureExplorationCreator} which manages the creation of the - * concrete architecture exploration problem, i.e. the {@link ArchitectureExplorationCreator} - * calls the creators of the genotypes composing the architecture exploration problem. - */ - public ArchitectureExplorationCreator createArchitectureExplorationCreator( - ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new ArchitectureExplorationCreator(expSpec, systemModelAdapter); - } - - /** - * Returns the {@link TaskMappingFactory} that fits the given {@link ExecutionModel} from the - * DSE. - * - * @throws UnsupportedDataTypeException - * if the given {@link ExecutionModel} is not "wrapped" to factory in this method. - */ - public TaskMappingFactory<? extends TaskMappingEntry, ? extends TaskMappingEncoding<?>> - createTaskMappingFactory(ExecutionModel execModel) throws UnsupportedDataTypeException { - switch(execModel) { - case TT_FAIL_SILENCE: - return FailSilentExecModelFactory.getInstance(); - case TT_FAULT_DETECTION_VOTING: - return FaultDetectionVotingExecModelFactory.getInstance(); - default: - throw new UnsupportedDataTypeException( - "Cannot create a factory for the execution model " + execModel.getName() + - ". There is no no factory registered for this executio model."); - } - } - - /** - * Creates a decoder for the architectural exploration problem that shall be solved by the - * DSE. - * It delegates the subproblems to sub decoders, e.g. a decoder for the task mapping problem. - */ - public ArchitectureDecoder createArchitectureDecoder( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execdepGraph) { - return new ArchitectureDecoder(systemModelAdapter, execdepGraph); - } - - /** - * Creates an evaluator for the architectural exploration problem that shall be solved by the - * DSE. - * It delegates the evaluation of the overall problem to sub-decoders, e.g. an evaluator of the - * power consumption of a TT-schedule. - */ - public ArchitectureEvaluator createArchitectureEvaluator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new ArchitectureEvaluator(systemModelAdapter); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/Explorer.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/Explorer.java deleted file mode 100644 index dfe56ecc0798defc8b0238ecd9bba0723eac4f64..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/Explorer.java +++ /dev/null @@ -1,239 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: Explorer.java 3964 2016-12-12 12:55:09Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse; - -import static org.fortiss.af3.exploration.alg.service.ExplorationService.getService; -import static org.fortiss.tooling.common.util.LambdaUtils.filterByType; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.IExplorerBackend; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.Opt4JExplorerBackend; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationConstraintTransformationService; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.ExternalModelTarget; -import org.fortiss.af3.exploration.model.GenericConstraint; -import org.fortiss.af3.exploration.moea.model.DseSpecification; -import org.fortiss.af3.exploration.moea.model.parameters.EAOptimizer; -import org.fortiss.af3.exploration.moea.model.parameters.IOptimizer; -import org.fortiss.tooling.kernel.utils.EcoreUtils; - -/** - * Explorer - entry point to architectural exploration - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3964 $ - * @ConQAT.Rating RED Hash: 2F41260A0AE6F1FBED8BD7EE0C3ED7F2 - */ -public class Explorer { - - /** - * Performs the DSE defined a given {@link DseSpecification} specification on a given - * system model (represented by a {@link SystemModelAdapter}). - * - * @throws Exception - */ - public CompositeExplorationSolution<?> explore(DseSpecification dse, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - Set<Class<? extends IExplorationEncoding>> requestedSolutions, - boolean generateImplicitConstraints) throws Exception { - return explore(dse, dse.getTargetSpecification(), systemModelAdapter, requestedSolutions, - null, generateImplicitConstraints); - } - - /** - * Performs the DSE defined a given {@link DseSpecification} specification on a given - * system model (represented by a {@link SystemModelAdapter}). - */ - public CompositeExplorationSolution<?> explore(DseSpecification dse, - ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - Set<Class<? extends IExplorationEncoding>> requestedSolutions, - IProgressMonitor progressMonitor, boolean generateImplicitConstraints) throws Exception { - - validateDesignSpaceExploration(dse, expSpec); - validateSystemModelAdapter(systemModelAdapter); - - // Clear & add implicit constraints to the Goal specification that are defined by the system - // model. - Map<ExplorationTarget<?>, ExplorationTarget<?>> targetAssocMap = new HashMap<>(); - ExplorationSpecification expSpecCopy = - copyExplorationSpecification(expSpec, targetAssocMap); - if(generateImplicitConstraints) { - expSpecCopy.getTargets().addAll( - ImplicitExplorationTargetFactory.getInstance() - .createImplicitExplorationTargets(expSpecCopy, systemModelAdapter)); - } - - // Extract external models to add them to the available input models. - for(ExplorationTarget<?> expTarget : expSpecCopy.getTargets()) { - if(expTarget instanceof ExternalModelTarget) { - Collection<EObject> extModels = - ((ExternalModelTarget)expTarget).getExternalModels(); - for(EObject extModel : extModels) { - @SuppressWarnings("unchecked") Class<? extends EObject> modelType = - (Class<? extends EObject>)extModel.eClass().getInstanceClass(); - systemModelAdapter.putInputModel(modelType, extModel); - } - } - } - - // Execute the Constraint Transformation. - IExplorationConstraintTransformationService constrService = - getService(IExplorationConstraintTransformationService.class); - Collection<GenericConstraint<?>> genConstrs = - filterByType(expSpecCopy.getTargets(), new ArrayList<GenericConstraint<?>>(), - GenericConstraint.class); - Collection<ExplorationConstraint<?>> transformedConstrs = - constrService.getTransformedConstraints(systemModelAdapter, genConstrs); - expSpecCopy.getTargets().addAll(transformedConstrs); - - // Invoke the backend in order to perform the DSE - IExplorerBackend<? extends IOptimizer> explorerBackend = - createExplorerBackend(dse, expSpec, targetAssocMap, systemModelAdapter, - requestedSolutions, progressMonitor); - CompositeExplorationSolution<?> explorationResult = explorerBackend.explore(); - - // Print results - System.out.println(explorationResult); - - return explorationResult; - } - - /** - * Copies a DSE model, and returns a map that associates the {@link ExplorationTarget}s given in - * the original {@link ExplorationSpecification} with the copied ones. - */ - private ExplorationSpecification copyExplorationSpecification(ExplorationSpecification expSpec, - Map<ExplorationTarget<?>, ExplorationTarget<?>> assocMap) { - ExplorationSpecification expSpecCopy = EcoreUtils.copy(expSpec); - expSpecCopy.getTargets().clear(); - - // TODO: Instead of this extra hook, use the M2MCopier. - for(ExplorationTarget<?> target : expSpec.getTargets()) { - ExplorationTarget<?> targetCopy = EcoreUtils.copy(target); - expSpecCopy.getTargets().add(targetCopy); - assocMap.put(target, targetCopy); - } - return expSpecCopy; - } - - /** Helper method to issue an exception for invalid DSE configurations */ - private void createDesignSpaceExplorationConfigurationException(final String msg) - throws Exception { - throw new Exception("DSE configuration: " + msg); - } - - // TODO: Port validation of DSE configuration to model validation framework that creates markers - // in the problem view - /** Validation of DSE configuration */ - private void validateDesignSpaceExploration(DseSpecification dse, - ExplorationSpecification expSpec) throws Exception { - if(dse == null) { - createDesignSpaceExplorationConfigurationException("No DSE configuration has been specified."); - // Never here - return; - } - - if(dse.getParameters() == null) { - createDesignSpaceExplorationConfigurationException("No optimizer independent parameters have been provided."); - } - - if(dse.getParameters().getExecutionModel() == null) { - createDesignSpaceExplorationConfigurationException("No execution model has been specified."); - } - - if(dse.getOptimizer() == null) { - createDesignSpaceExplorationConfigurationException("No optimizer backend has been specified."); - } - - if(expSpec.getTargets() == null || expSpec.getTargets().isEmpty()) { - createDesignSpaceExplorationConfigurationException("No ExplorationTargets have been provided."); - } - } - - // TODO: Use a subclassed Exception here. - /** Helper method to issue an exception for invalid input system models */ - private void createSystemModelAdapterConfigurationException(final String msg) throws Exception { - throw new Exception("System model: " + msg); - } - - // TODO: Port validation of system model to model validation framework that creates markers - // in the problem view - /** Validation of system model */ - private void - validateSystemModelAdapter(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws Exception { - - if(systemModelAdapter == null) { - createSystemModelAdapterConfigurationException("No DSE configuration has been specified."); - return; - } - - if(systemModelAdapter.getDeployableComponents().isEmpty()) { - createSystemModelAdapterConfigurationException("Component architecture does not contain any deployable components.\n\nMake sure the \"Trigger\" annotation have been defined for all components that should be deployed."); - } - - if(systemModelAdapter.getDeploymentTargets().isEmpty()) { - createSystemModelAdapterConfigurationException("Platform architecture does not contain any deployment targets.\n\nMake sure the \"Deployment Target\" annotation has been set for all execution units that should be deployed.\n\nMaybe you selected the wrong platform architecture?"); - } - - if(systemModelAdapter.getTaskGraphs().isEmpty()) { - createSystemModelAdapterConfigurationException("System model does not contain any valid task graphs. All tasks in a task graph must share the same period."); - } - - if(systemModelAdapter.getAcyclicTaskGraphs().isEmpty()) { - createSystemModelAdapterConfigurationException("System model does not contain any valid task graphs. All tasks in a task graph must share the same period."); - } - - // FIXME: readd? ==>> VL Generation. - // if(systemModelAdapter.getHyperPeriod() <= 0) { - // createSystemModelAdapterConfigurationException("System model does not have a valid hyper period."); - // } - - } - - /** Explorer backend */ - private Opt4JExplorerBackend createExplorerBackend(DseSpecification dse, - ExplorationSpecification expSpec, - Map<ExplorationTarget<?>, ExplorationTarget<?>> targetAssocMap, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - Set<Class<? extends IExplorationEncoding>> requestedSolutions, - IProgressMonitor progressMonitor) throws Exception { - if(dse.getOptimizer() instanceof EAOptimizer) { - return new Opt4JExplorerBackend(dse, expSpec, targetAssocMap, systemModelAdapter, - requestedSolutions, progressMonitor); - } - - createDesignSpaceExplorationConfigurationException("Unsupported exploration backend."); - - // Never here - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/ImplicitExplorationTargetFactory.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/ImplicitExplorationTargetFactory.java deleted file mode 100644 index 7384ddce6553774409fdac096bf60955a6a3b4f4..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/ImplicitExplorationTargetFactory.java +++ /dev/null @@ -1,143 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ImplicitExplorationTargetFactory.java 3875 2016-11-09 16:18:09Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse; - -import java.util.ArrayList; -import java.util.Collection; - -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; -import org.fortiss.af3.exploration.alg.exception.ConstraintGenerationException; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.time.PeriodConstraint; -import org.fortiss.af3.exploration.moea.model.DseSpecification; -import org.fortiss.af3.exploration.util.CommonExplorationTagetModelElementFactory; - -/** - * Factory for creating implicit Exploration Targets based on the input system model. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3875 $ - * @ConQAT.Rating RED Hash: 603F4C8A3E53A7722647095F71E15AD6 - */ -public class ImplicitExplorationTargetFactory { - - /** The instance (singleton) of the {@link ImplicitExplorationTargetFactory}. */ - private static final class InstanceHolder { - /** the "real" instance. */ - static final ImplicitExplorationTargetFactory INSTANCE = - new ImplicitExplorationTargetFactory(); - } - - /** Private constructor to prevent instantiation from external (singleton). */ - private ImplicitExplorationTargetFactory() { - } - - /** Returns the instance of this {@link DSEFactory}. */ - public static ImplicitExplorationTargetFactory getInstance() { - return InstanceHolder.INSTANCE; - } - - /** - * Creates "implicit" {@link ExplorationTarget}s from the {@link SystemModelAdapter} and adds - * them to the given {@link DseSpecification} model. - * "Implicit" {@link ExplorationTarget}s are defined by the system model itself and cannot be - * <i>directly</i> modified by the user. - * - * @param dse - * {@link DseSpecification} to which the "implicit" {@link ExplorationTarget}s - * shall be added. - * @param systemModelAdapter - * {@link SystemModelAdapter} from which the "implicit" {@link ExplorationTarget}s - * are deduced. - * @throws Exception - * if any of the constraint generators fails. - */ - public Collection<ExplorationConstraint<?>> createImplicitExplorationTargets( - ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - Collection<ExplorationConstraint<?>> constraints = new ArrayList<>(); - constraints.addAll(createPeriodConstraints(systemModelAdapter)); - - // Reassign the ids of generated constraints. By default, they are set to 0. Each constraint - // needs a "unique" id for its constraint type. - int constrId = 0; - for(ExplorationConstraint<?> curConstraint : constraints) { - curConstraint.setId(constrId); - constrId++; - } - - return constraints; - } - - /** - * Creates a {@link PeriodConstraint} for each {@link TaskGraph} present in the - * {@link SystemModelAdapter}. - * - * @throws ConstraintGenerationException - * if the generation of any {@link PeriodConstraint} fails. - */ - private static Collection<ExplorationConstraint<?>> createPeriodConstraints( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws ConstraintGenerationException { - Collection<ExplorationConstraint<?>> constraints = new ArrayList<>(); - for(TaskGraph tg : systemModelAdapter.getTaskGraphs()) { - for(IDeployableComponentAdapter<?> component : tg.getTasks()) { - if(!(component.getObject() instanceof Component)) { - throw new ConstraintGenerationException(PeriodConstraint.class, - "Invalid model element type for this constraint: " + - component.getObject().getClass().getSimpleName() + - ". Expected a Component."); - } - constraints.add(createPeriodConstraint((Component)component.getObject(), - tg.getPeriod())); - } - } - return constraints; - } - - /** - * Factory method to create {@link PeriodConstraint}s. - * - * @throws ConstraintGenerationException - * if the period value is invalid ({@code null}, or <= 0). - */ - private static PeriodConstraint createPeriodConstraint(Component component, Double period) - throws ConstraintGenerationException { - if(component == null) { - throw new ConstraintGenerationException(PeriodConstraint.class, - "Cannot generate a PeriodConstraint for a 'null' Component."); - } - if(period == null || period <= 0.0) { - throw new ConstraintGenerationException(PeriodConstraint.class, - "Invalid period specified for the Component " + component.getName() + "."); - } - - PeriodConstraint periodConstraint = - CommonExplorationTagetModelElementFactory.createPeriodConstraint(); - periodConstraint.setName("Period Constraint(" + periodConstraint.getId() + ")"); - periodConstraint.setComponent(component); - periodConstraint.setPeriod(period); - return periodConstraint; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/SolutionQuantification.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/SolutionQuantification.java deleted file mode 100644 index ad9f1b2930a954f979155cb343bbb48910b9743e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/SolutionQuantification.java +++ /dev/null @@ -1,98 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SolutionQuantification.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse; - -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.opt4j.core.Value; - -/** - * Exploration result for a single solution, i.e. its fitness w.r.t to the investigated optimization - * dimensions. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 8946DC6B0F62C2DD67BC1820D00BBC73 - */ -public class SolutionQuantification { - - /** - * Map to store the fitness values for a single solution w.r.t to the investigated optimization - * dimensions. - */ - private Map<ExplorationTarget<?>, Value<?>> solutionQuantificationMap = new HashMap<>(); - - /** Adds a fitness value for a given optimization dimension */ - public <T> void addSingleExplorationResult(final ExplorationTarget<T> target, Value<?> value) { - solutionQuantificationMap.put(target, value); - } - - /** - * Returns the quantification (the evaluation result as a double value) for the given - * {@link ExplorationTarget}. - */ - public Double getQuantificationOf(ExplorationTarget<?> expTarget) { - Value<?> value = getTarget(expTarget); - if(value != null) { - return value.getDouble(); - } - return null; - } - - /** - * Returns the {@link Value} (evaluation result) from the internal map. First it checks whether - * the given type is registered in the map. If none is found all entries are checked whether - * they are a super type of the given type and the first match is returned. - */ - public Value<?> getTarget(ExplorationTarget<?> expTarget) { - Value<?> value = solutionQuantificationMap.get(expTarget); - - if(value == null) { - for(ExplorationTarget<?> currExpTgt : solutionQuantificationMap.keySet()) { - if(expTarget.getClass().isAssignableFrom(currExpTgt.getClass())) { - value = solutionQuantificationMap.get(currExpTgt); - } - } - } - - return value; - } - - /** Returns the {@link ExplorationTarget} -> {@link Value} entries of the internal map. */ - public Set<Entry<ExplorationTarget<?>, Value<?>>> entrySet() { - return solutionQuantificationMap.entrySet(); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - String rval = ""; - for(ExplorationTarget<?> target : solutionQuantificationMap.keySet()) { - rval += - (target.getName() + "(id: " + target.getId() + ")" + "=" + - solutionQuantificationMap.get(target) + ", "); - } - - return rval; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/TaskMappingFactory.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/TaskMappingFactory.java deleted file mode 100644 index e92a36ae2aea88ba20e52d90556a2b00b300cc3d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/TaskMappingFactory.java +++ /dev/null @@ -1,493 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: TaskMappingFactory.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.AbstractTaskMappingCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.TaskMappingCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.InstantiatedTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -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.backend.opt4j.extensions.compositegene.graph.DecoderDependencyGraph; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover.CrossoverRandManyAllocation; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover.CrossoverSingleAllocation; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping.MutateAllocation; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping.MutateRedundancyDecrement; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping.MutateRedundancyIncrement; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.EvaluatorWrapper; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.StrictTTDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.comm.MessageDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatemapping.AbstractTaskMappingDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatetaskgraph.InstantiatedTaskMappingDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatetaskgraph.InstantiatedTaskMappingDecoderAcyclic; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.comm.IMessageRouter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.comm.ShortestPathRouter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.sched.proc.EDFSchedulerBase; -import org.fortiss.af3.exploration.alg.service.internal.ExplorationEvaluationService; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.time.DeadlineConstraint; -import org.fortiss.af3.exploration.model.time.PeriodConstraint; -import org.fortiss.af3.exploration.moea.model.DseSpecification; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiAllocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiDislocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.FailureMinObjective; -import org.fortiss.af3.exploration.moea.model.predefined.SafetyIntegrityLevelConstraint; -import org.fortiss.af3.safety.model.SIL; - -import com.google.inject.TypeLiteral; - -/** - * This abstract factory is responsible for creating the EvaluatorWrappers that are required to hand - * over objectives and constraints to the optimization. Here, a differentiation is made for the - * objectives and constraints. The implementation of the specific create functions must be made - * within factories that are specific for a execution model (like fail silent, fault detection - * etc.). - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: 30207B476D6ABC24517A29ECFE1D0DB4 - */ -public abstract class TaskMappingFactory<S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> { - - /** Error message for non-implemented operators etc. related to schedules */ - private String SCHED_NOT_IMPL_MSG = - "Error: This operation is not implemented for the execution model defined in the design space exploration. Please implement the operation for this execution model, or avoid calling this function if it is not necessary."; - - /** Error message for non-implemented operators etc. related to optimization goals */ - private String GOAL_NOT_IMPL_MSG = - "Error: This optimization goal is not implemented. Please implement the goal, or remove it from your design space exploration model."; - - /** The instance (singleton) of the EvaluatorWrapper factory. */ - protected static TaskMappingFactory<?, ?> instance; - - /** Returns the singleton implementing this abstract factory. */ - public static TaskMappingFactory<?, ?> getInstance() { - if(instance == null) { - throw new UnsupportedOperationException( - "TaskMapping factory in not yet initialized. A factory of a concrete TaskMapping must be created first."); - } - return instance; - } - - /* - * Construct Creators for the task mapping - */ - - /** Creates and returns a {@link TypeLiteral} of the specific encoding of the task mapping. */ - public abstract TypeLiteral<T> createGenotypeTypeLiteral(); - - /** - * Creates an abstract TaskMappingCreator which maps components that needs to be instatiated - * first before they can be deployed onto a platform. - * - * @param dse - * design space exploration model defined in the GUI - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - */ - public AbstractTaskMappingCreator createAbstractTaskMappingCreator( - ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execDepGraph) { - return new AbstractTaskMappingCreator(expSpec, systemModelAdapter, execDepGraph); - } - - /** - * Creates a TaskMappingCreator that matches the given execution model. - * - * @param dse - * design space exploration model defined in the GUI - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - * @param execDepGraph - */ - // TODO: document execDepGraph param. - public TaskMappingCreator<S, T> createTaskMappingCreator(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execDepGraph) { - throw new UnsupportedOperationException(SCHED_NOT_IMPL_MSG); - } - - /** - * Creates a TaskMappingCreator that matches the given execution model. - * - * @param dse - * design space exploration model defined in the GUI - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - * @param abstractEnc - */ - // TODO: update doc - public TaskMappingCreator<S, T> createTaskMappingCreator(DseSpecification dse, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - AbstractTaskMappingEncoding abstractEnc) { - throw new UnsupportedOperationException(SCHED_NOT_IMPL_MSG); - } - - /* - * Construct execution model specific operators - */ - - /** - * Creates an execution model specific {@link MutateAllocation} operator. - * - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - */ - public MutateAllocation<? extends TaskMappingEntry, ? extends TaskMappingEncoding<?>> - createMutateAllocationOperator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - throw new UnsupportedOperationException(SCHED_NOT_IMPL_MSG); - } - - /** - * Creates an execution model specific {@link MutateRedundancyDecrement} operator. - * - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - */ - public MutateRedundancyDecrement<?, ?> createMutateRedundancyDecrementOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - throw new UnsupportedOperationException(SCHED_NOT_IMPL_MSG); - } - - /** - * Creates an execution model specific {@link MutateRedundancyIncrement} operator. - * - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - */ - public MutateRedundancyIncrement<?, ?> createMutateRedundancyIncrementOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - throw new UnsupportedOperationException(SCHED_NOT_IMPL_MSG); - } - - /** - * Creates an execution model specific {@link CrossoverRandManyAllocation} operator - * - * @param systemModelAdapter - * The system model deduced from the logical and technical architecture. - * @param rate - * The rate or probability of such that the the operator is applied. - */ - public CrossoverRandManyAllocation<?, ?> createCrossoverRandManyAllocationOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, double rate) { - throw new UnsupportedOperationException(SCHED_NOT_IMPL_MSG); - } - - /** - * Creates an execution model specific {@link CrossoverRandManyAllocation} operator - * - * @param systemModelAdapter - * The system model deduced from the logical and technical architecture. - * @param rate - * The rate or probability of such that the the operator is applied. - */ - public CrossoverSingleAllocation<?, ?> createCrossoverSingleAllocationOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, double rate) { - throw new UnsupportedOperationException(SCHED_NOT_IMPL_MSG); - } - - /* - * Construct Decoders for the genotypes, aka task mappings. - */ - - // TODO: correct the type parameters --> Instantiated XY - /** - * Decoder to instantiate an {@link AbstractTaskMappingEncoding} into an - * {@link InstantiatedTaskMappingEncoding}. - * - * @param systemModelAdapter - * The system model deduced from the logical and technical architecture. - * @param explorationDefinition - * The model of the DSE; This information can be useful for the decoders to optimize - * the decoding strategy - */ - public AbstractTaskMappingDecoder<?, ?> createAbstractTaskMappingDecoder( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - throw new UnsupportedOperationException( - "The Decoder to instantiate an \"abstract\" Task Mapping has not been defined for current Execution Model."); - } - - /** - * Creates and returns a {@link InstantiatedTaskMappingDecoder}. - * - * @param systemModelAdapter - * The system model deduced from the logical and technical architecture. - * @return An instance of a {@link InstantiatedTaskMappingDecoder}. - */ - // TODO: remove these suppress warnings by propagating the generic C. - @SuppressWarnings({"rawtypes", "unchecked"}) - public InstantiatedTaskMappingDecoder<S, InstantiatedTaskGraphEncoding> - createInstantiatedTaskMappingDecoder( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new InstantiatedTaskMappingDecoder(systemModelAdapter); - } - - /** - * Creates and returns a {@link InstantiatedTaskMappingDecoderAcyclic}. - * - * @param systemModelAdapter - * The system model deduced from the logical and technical architecture. - * @return An instance on an {@link InstantiatedTaskMappingDecoderAcyclic}. - */ - public InstantiatedTaskMappingDecoderAcyclic<S, ?> createAbstractToAcyclicTaskGraphDecoder( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - throw new UnsupportedOperationException( - "The Decoder to instantiate an \"abstract\" and acyclic Task Graph has not been defined for current Execution Model."); - } - - /** - * Creates and returns a {@link MessageDecoder}. - * - * @param systemModelAdapter - * The system model deduced from the logical and technical architecture. - * @return An instance of a {@link MessageDecoder}. - */ - public MessageDecoder<S, T> createMessageDecoder( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - throw new UnsupportedOperationException( - "The Decoder which generates messages from task mappings has not been defined for current Execution Model."); - } - - /** - * Creates a scheduling strategy-"independent" decoder. Here, the basic time architecture is to - * be defined, e.g. time triggered scheduling. - * - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - * @param explorationDefinition - * The model of the DSE; This information can be useful for the decoders to optimize - * the decoding strategy - */ - public StrictTTDecoder<S, T> createStrictTTDecoder( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - throw new UnsupportedOperationException(SCHED_NOT_IMPL_MSG); - } - - /** - * Creates a scheduling strategy-"independent" decoder for task mapping encodings. It provides a - * {@link ShortestPathRouter} to find the shortest communication path between two communicating - * instantiations of an {@link IDeployableComponentAdapter} for a given platform. - */ - public IMessageRouter createShortestPathRouter( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new ShortestPathRouter(systemModelAdapter); - } - - /** - * Creates an basic EDF scheduler that is used to decode task mappings into schedules for the - * given execution model - * - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - * @param expSpec - * DSE goal specification used within the exploration, useful for scheduling - */ - public EDFSchedulerBase<?, ?> createEDFScheduler( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - throw new UnsupportedOperationException(SCHED_NOT_IMPL_MSG); - } - - /* - * Construct Evaluators for Optimization Goals - */ - - /** - * Decides, which create method has to be called for a specific goal. - * - * @throws Exception - */ - @SuppressWarnings("unchecked") - public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, RT, ET> - createEvaluatorWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - ExplorationEvaluationService<?> evalService = ExplorationEvaluationService.getInstance(); - EvaluatorWrapper<?, RT, ET> evaluatorWrapper = - (EvaluatorWrapper<?, RT, ET>)evalService.createEvalWrapperFor(systemModelAdapter, - goal); - - // TODO: remove the block below when all evaluators are migrated to the service interface. - if(evaluatorWrapper == null) { - /* First, the wrappers for the objectives are created */ - if(goal instanceof FailureMinObjective) { - evaluatorWrapper = - (EvaluatorWrapper<?, RT, ET>)createFailureMinObjectiveWrapper(goal, - priority, systemModelAdapter); - } - - /* Then, the constraints are handled */ - else if(goal instanceof DeadlineConstraint) { - evaluatorWrapper = - (EvaluatorWrapper<?, RT, ET>)createDeadlineConstraintWrapper(goal, - priority, systemModelAdapter); - } else if(goal instanceof PeriodConstraint) { - evaluatorWrapper = - (EvaluatorWrapper<?, RT, ET>)createPeriodConstraintWrapper(goal, priority, - systemModelAdapter); - } else if(goal instanceof ComponentMultiAllocationConstraint) { - evaluatorWrapper = - (EvaluatorWrapper<?, RT, ET>)createComponentMultiAllocationConstraintWrapper( - goal, priority, systemModelAdapter); - } else if(goal instanceof ComponentMultiDislocationConstraint) { - evaluatorWrapper = - (EvaluatorWrapper<?, RT, ET>)createComponentMultiDislocationConstraintWrapper( - goal, priority, systemModelAdapter); - } else if(goal instanceof SafetyIntegrityLevelConstraint) { - evaluatorWrapper = - (EvaluatorWrapper<?, RT, ET>)createSafetyIntegrityLevelConstraintWrapper( - goal, priority, systemModelAdapter); - } - } - - if(evaluatorWrapper == null) { - throw new InstantiationException("Error: The optimization goal " + goal.getName() + - " is unknown. Please implement it or remove it from your design space exploration model"); - } - return evaluatorWrapper; - } - - /** - * Creates the Evaluator Wrapper for the reliability maximization objective. - * - * @param optGoal - * the optimization goal for which the wrapper shall be created - * @param priority - * Gives a priority to the solver performing the evaluation for each target. It - * defines the order of evaluation. - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - * @throws Exception - * if the input model validation fails. - */ - protected <RT, ET extends ExplorationTarget<RT>> - EvaluatorWrapper<?, Double, FailureMinObjective> createFailureMinObjectiveWrapper( - ExplorationTarget<?> optGoal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - throw new UnsupportedOperationException(GOAL_NOT_IMPL_MSG); - } - - /** - * Creates the Evaluator Wrapper for the deadline constraints. - * - * @param optGoal - * the optimization goal for which the wrapper shall be created - * @param priority - * Gives a priority to the solver performing the evaluation for each target. It - * defines the order of evaluation. - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - * @throws Exception - * if the input model validation fails. - */ - protected <RT, ET extends ExplorationTarget<RT>> - EvaluatorWrapper<?, Double, DeadlineConstraint> createDeadlineConstraintWrapper( - ExplorationTarget<?> optGoal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - throw new UnsupportedOperationException(GOAL_NOT_IMPL_MSG); - } - - /** - * Creates the Evaluator Wrapper for the (hidden/implicit) period constraints. - * - * @param optGoal - * the optimization goal for which the wrapper shall be created - * @param priority - * Gives a priority to the solver performing the evaluation for each target. It - * defines the order of evaluation. - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - * @throws Exception - * if the input model validation fails. - */ - protected <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, PeriodConstraint> - createPeriodConstraintWrapper(ExplorationTarget<?> optGoal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - throw new UnsupportedOperationException(GOAL_NOT_IMPL_MSG); - } - - /** - * Creates the Evaluator Wrapper for the fixed deployment constraints. - * - * @param optGoal - * the optimization goal for which the wrapper shall be created - * @param priority - * Gives a priority to the solver performing the evaluation for each target. It - * defines the order of evaluation. - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - * @throws Exception - * if the input model validation fails. - */ - protected <RT, ET extends ExplorationTarget<RT>> - EvaluatorWrapper<?, Boolean, ComponentMultiAllocationConstraint> - createComponentMultiAllocationConstraintWrapper(ExplorationTarget<?> optGoal, - int priority, SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws Exception { - throw new UnsupportedOperationException(GOAL_NOT_IMPL_MSG); - } - - /** - * Creates the Evaluator Wrapper for the exclude (forbidden) deployment constraints. - * - * @param optGoal - * the optimization goal for which the wrapper shall be created - * @param priority - * Gives a priority to the solver performing the evaluation for each target. It - * defines the order of evaluation. - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - * @throws Exception - * if the input model validation fails. - */ - protected <RT, ET extends ExplorationTarget<RT>> - EvaluatorWrapper<?, Boolean, ComponentMultiDislocationConstraint> - createComponentMultiDislocationConstraintWrapper(ExplorationTarget<?> optGoal, - int priority, SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws Exception { - throw new UnsupportedOperationException(GOAL_NOT_IMPL_MSG); - } - - /** - * Creates the Evaluator Wrapper for {@link SafetyIntegrityLevelConstraint}s. - * - * @param optGoal - * the optimization goal for which the wrapper shall be created - * @param priority - * Gives a priority to the solver performing the evaluation for each target. It - * defines the order of evaluation. - * @param systemModelAdapter - * the system model deduced from the logical and technical architecture - * @throws Exception - * if the input model validation fails. - */ - protected <RT, ET extends ExplorationTarget<RT>> - EvaluatorWrapper<?, SIL, SafetyIntegrityLevelConstraint> - createSafetyIntegrityLevelConstraintWrapper(ExplorationTarget<?> optGoal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - throw new UnsupportedOperationException(GOAL_NOT_IMPL_MSG); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/ExplorerBackendBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/ExplorerBackendBase.java deleted file mode 100644 index cd01c8955251a72936c6dcae3e5123e8176764d4..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/ExplorerBackendBase.java +++ /dev/null @@ -1,200 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExplorerBackendBase.java 3479 2016-09-09 10:00:05Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -import javax.activation.UnsupportedDataTypeException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.fortiss.af3.exploration.alg.dse.DSEFactory; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.EvaluatorWrapper; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.IExplorationSolution; -import org.fortiss.af3.exploration.alg.dse.evaluator.constraint.IConstraintEvaluator; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.random.RandomExploration; -import org.fortiss.af3.exploration.alg.dse.sysmodel.random.RandomExploration.RandomnessType; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.moea.model.DseSpecification; -import org.fortiss.af3.exploration.moea.model.parameters.IOptimizer; -import org.opt4j.core.Value; -import org.opt4j.core.problem.Evaluator; - -/** - * Base class for general optimization backends. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3479 $ - * @ConQAT.Rating RED Hash: 999A1E6B5851A42DAC7A93994943795D - */ -public abstract class ExplorerBackendBase<O extends IOptimizer> implements IExplorerBackend<O> { - - /** DSE specification (optimizer parameters, goal specification, input model, ...) */ - // TODO: remove the DSE Spec. It is currently here - protected DseSpecification dse; - - /** Contains all ExplorationTargets of the exploration. */ - protected ExplorationSpecification expSpec; - - /** - * Map that relates the {@link ExplorationTarget}s from input specification with the - * {@link ExplorationTarget}s that are actually used in the DSE. - */ - protected Map<ExplorationTarget<?>, ExplorationTarget<?>> targetAssocMap; - - /** Representation of system model (=input) that is evaluated during this DSE run */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Set of requested {@link ComposablePhenotype}s that form the solution set. */ - protected Set<Class<? extends IExplorationEncoding>> requestedSolutions; - - /** - * {@link IProgressMonitor} used to visualize the progress of the exploration process (may be - * {@code null}). - */ - protected IProgressMonitor progressMonitor; - - /** - * Contains the EvaluatorWrapper factory. It is used to instantiate the objectives and - * constraints that are used during the exploration for specific execution models. - */ - protected DSEFactory explorationFactory; - - /** - * Constructor that initializes the DSE backend with the given optimizer independent parameters - * and the goal specification - */ - protected ExplorerBackendBase(DseSpecification dse, ExplorationSpecification expSpec, - Map<ExplorationTarget<?>, ExplorationTarget<?>> targetAssocMap, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - Set<Class<? extends IExplorationEncoding>> requestedSolutions, - IProgressMonitor progressMonitor) { - this.dse = dse; - this.expSpec = expSpec; - this.targetAssocMap = targetAssocMap; - this.systemModelAdapter = systemModelAdapter; - this.requestedSolutions = requestedSolutions; - this.progressMonitor = progressMonitor; - - // TODO: Initialization of the TaskMappingFactory is currently done here to allow an - // instantiation of the Evaluators by the goals. Those are generified, and hence, the - // instance must exist already. - try { - DSEFactory.getInstance().createTaskMappingFactory( - dse.getParameters().getExecutionModel()); - } catch(UnsupportedDataTypeException e) { - // See todo above - e.printStackTrace(); - } - - // (Re-)Initialize the Random number generator - initCentralRandomGenerator(); - } - - /** - * (Re-)Initializes the central random number generator of the DSE. It must be re-initialized on - * successive runs to obtain deterministic behavior. - */ - private void initCentralRandomGenerator() { - if(!RandomExploration.getInstance().isInitialized()) { - try { - RandomExploration.getInstance().init(RandomnessType.realRandom, 30); - } catch(Exception e) { - // This is the correct place to initialize the central random generator. - assert (false) : "The centralized random number generator of the DSE has been initialized in another location, where it should not be initialized."; - } - } else { - try { - RandomExploration.getInstance().reInit(); - } catch(Exception e) { - // This is the correct place to re-initialize the central random generator, it has - // been initialized in this place before. - assert (false) : "The centralized random number generator of the DSE has not been initialized."; - } - } - } - - /** - * Performs the initialization of the optimizer backend. Must be called from constructor in - * concrete derived classes. - */ - protected abstract void init(O optimizer); - - /** - * Feasibility check for the results from the exploration. It validates that each constraint is - * fulfilled by applying the validate function of the {@link IConstraintEvaluator}s onto each - * possible solution. - */ - // protected CompositeExplorationSolution<?> validate( - // CompositeExplorationSolution<?> explorationResult, - // Collection<EvaluatorWrapper<?, ?, ?>> evalWrappers) { - // CompositeExplorationSolution<?> feasibleExplorationResult = explorationResult.copy(); - // - // // Iterate over all (feasible + infeasible) solutions - // for(Entry<IExplorationSolution<?>, SolutionQuantification> solution : explorationResult - // .getSolutionQuantification().entrySet()) { - // boolean isFeasible = - // validateSolution(solution.getKey(), solution.getValue(), evalWrappers); - // - // // Remove the current solution if the feasibility check failed. - // if(!isFeasible) { - // feasibleExplorationResult.deleteSolutionQuantification(solution.getKey()); - // } - // } - // - // return feasibleExplorationResult; - // } - - /** */ - protected <M extends Phenotype> boolean validateSolution(IExplorationSolution<?> solution, - ExplorationConstraint target, Value<?> value, - Collection<EvaluatorWrapper<?, ?, ?>> evalWrappers) { - EvaluatorWrapper<?, ?, ?> evalWrapper = getEvaluatorOf(target, evalWrappers); - - assert (evalWrapper.getEvaluator() instanceof IConstraintEvaluator) : "The evaluator for the exploration constraint " + - target.getName() + " has an evaluator which is not an IConstraintEvaluator."; - - @SuppressWarnings("unchecked") Class<M> phenoClass = - (Class<M>)evalWrapper.getTargetPhenotypeType(); - M targetSubSolution = solution.getSubSolution(phenoClass); - return ((IConstraintEvaluator<?, ?, ?>)evalWrapper.getEvaluator()).validate(target, - targetSubSolution, phenoClass, value); - } - - /** - * From a given set of {@link Evaluator}s that are {@link EvaluatorWrapper}s, return the first - * found evaluator that is associated with the given {@link ExplorationTarget}. - */ - private <E extends EvaluatorWrapper<?, ?, ?>> E getEvaluatorOf(ExplorationTarget<?> expTarget, - Collection<E> evaluators) { - for(E evaluator : evaluators) { - if(expTarget.getClass().isAssignableFrom(evaluator.getTargetType())) { - return evaluator; - } - } - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/IExplorerBackend.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/IExplorerBackend.java deleted file mode 100644 index d2fa976aad8b6df62f468c54ee8eafee8747115b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/IExplorerBackend.java +++ /dev/null @@ -1,39 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IExplorerBackend.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend; - -import org.fortiss.af3.exploration.alg.dse.CompositeExplorationSolution; -import org.fortiss.af3.exploration.moea.model.parameters.IOptimizer; - -/** - * Common interface for all optimization backends. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 78EE1823181065759CFC4234315FFABC - */ -public interface IExplorerBackend<O extends IOptimizer> { - /** - * Execute optimization - * - * @throws Exception - */ - // TODO: add distinct exceptions if stroing the solution fails. - public abstract CompositeExplorationSolution<?> explore() throws Exception; -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/SolutionCandidateBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/SolutionCandidateBase.java deleted file mode 100644 index 5a2a817a50a1f33c912a6d8703208b674fb3287d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/SolutionCandidateBase.java +++ /dev/null @@ -1,173 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SolutionCandidateBase.java 2054 2016-01-12 09:41:04Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.IProblemDimension; -import org.fortiss.tooling.kernel.utils.EcoreUtils; - -/** - * Base class to track status information of "individual evolution" during opitmization. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 2054 $ - * @ConQAT.Rating RED Hash: 6B3BE7A912B4D3BB9E980FA38FD3E604 - */ -// TODO: transform this class into a status genotype the track the status information. -@SuppressWarnings("javadoc") -public class SolutionCandidateBase { - - private Collection<ExplorationConstraint<?>> constraints; - - private Map<IProblemDimension, Integer> constraintViolationsPerProblemDimension; - - private Map<IProblemDimension, Double> constraintViolationDegreePerProblemDimension; - - private Map<ExplorationConstraint<?>, Double> constraintViolationValue; - - private Map<ExplorationConstraint<?>, Double> constraintViolationValueTracker; - - private Map<ExplorationConstraint<?>, Integer> constraintViolationTracker; - - // TODO: replace this local eps-tolerance with a settable one - private double violationTolerance = 1e-9; - - /** Constructor */ - public SolutionCandidateBase() { - constraintViolationsPerProblemDimension = new HashMap<>(); - constraintViolationDegreePerProblemDimension = new HashMap<>(); - constraintViolationValue = new HashMap<>(); - constraintViolationValueTracker = new HashMap<>(); - constraintViolationTracker = new HashMap<>(); - } - - /** - * Adds the problem dimensions and constraints for a given {link GoalSpecification}. These are - * required to allow tracking and evaluating constraint violation of the possible solutions of - * the DSE. - */ - public void addConstraints(ExplorationSpecification specification) { - constraints = - specification.getTargets().stream() - .filter(t -> (t instanceof ExplorationConstraint<?>)) - .map(ExplorationConstraint.class::cast).collect(Collectors.toList()); - constraints.forEach(c -> doAddConstraint(c)); - } - - private void doAddConstraint(ExplorationConstraint<?> constraint) { - constraintViolationValue.put(constraint, 0.0); - constraintViolationValueTracker.put(constraint, 0.0); - constraintViolationTracker.put(constraint, 0); - } - - public void addConstraintVioloation(ExplorationConstraint<?> violatedConstraint, - double violationValue) { - - // The ordering in calling these functions is important as to get the reset condition for - // the problem dimensions correctly. - // TODO: reset constraint violation if violationValue equals zero - addConstraintViolationToConstraint(violatedConstraint, violationValue); - addConstraintViolationToProblemDimension(violatedConstraint, violationValue); - } - - public void updateConstraintViolationsForProblemDimensions() { - // TODO: Original functionality is probably broken, rework during the transition to status - // genotype. - double violationValue = 0.0; - int constraintViolationCount = 0; - for(ExplorationConstraint<?> constraint : constraints) { - Optional<IProblemDimension> probDim = - Arrays.stream(constraint.getClass().getInterfaces()) - .filter(i -> IProblemDimension.class.isAssignableFrom(i.getClass())) - .map(IProblemDimension.class::cast).findFirst(); - if(constraintViolationValue.containsKey(constraint)) { - if(constraintViolationValue.get(constraint) > violationTolerance) { - constraintViolationCount++; - } - violationValue += constraintViolationValue.get(constraint); - } - - constraintViolationDegreePerProblemDimension.put(probDim.get(), violationValue); - constraintViolationsPerProblemDimension.put(probDim.get(), constraintViolationCount); - } - } - - private void addConstraintViolationToConstraint(ExplorationConstraint<?> violatedConstraint, - double violationValue) { - int violationCount = 0; - double constraintViolation = 0.0; - double violationTrackerValue = 0.0; - // TODO: Fix: Assume, the vales of the maps are always set jointly. - if(constraintViolationValue.containsKey(violatedConstraint) && - constraintViolationValueTracker.containsKey(violatedConstraint) && - constraintViolationTracker.containsKey(violatedConstraint)) { - constraintViolation = constraintViolationValue.get(violatedConstraint); - violationTrackerValue = constraintViolationValueTracker.get(violatedConstraint); - violationCount = constraintViolationTracker.get(violatedConstraint); - } - - constraintViolation += violationValue; - violationTrackerValue += violationValue; - violationCount++; - - constraintViolationValue.put(violatedConstraint, constraintViolation); - constraintViolationValueTracker.put(violatedConstraint, violationTrackerValue); - constraintViolationTracker.put(violatedConstraint, violationCount); - } - - private void addConstraintViolationToProblemDimension( - ExplorationConstraint<?> violatedConstraint, double violationValue) { - EList<EClass> constraintSuperEClasses = violatedConstraint.eClass().getESuperTypes(); - EList<IProblemDimension> associatedProblemDimensionList = - EcoreUtils.pickInstanceOf(IProblemDimension.class, constraintSuperEClasses); - - IProblemDimension associatedProblemDimension = associatedProblemDimensionList.get(0); - - int constraintViolationCount = 0; - double constraintViolationValue = 0.0; - // TODO: Fix: Assume, constraintViolationsPerProblemDimension and - // constraintViolationDegreePerProblemDimension are always set jointly. - if(constraintViolationsPerProblemDimension.containsKey(associatedProblemDimension) && - constraintViolationDegreePerProblemDimension - .containsKey(associatedProblemDimension)) { - constraintViolationCount = - constraintViolationsPerProblemDimension.get(associatedProblemDimension); - constraintViolationValue = - constraintViolationDegreePerProblemDimension.get(associatedProblemDimension); - } - - constraintViolationCount++; - constraintViolationValue += violationValue; - - constraintViolationsPerProblemDimension.put(associatedProblemDimension, - constraintViolationCount); - constraintViolationDegreePerProblemDimension.put(associatedProblemDimension, - constraintViolationValue); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/Opt4JExplorationSolutionSet.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/Opt4JExplorationSolutionSet.java deleted file mode 100644 index c940d8770370982dd87295835babd32ddd0e6561..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/Opt4JExplorationSolutionSet.java +++ /dev/null @@ -1,65 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: Opt4JExplorationSolutionSet.java 3184 2016-07-04 19:28:49Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j; - -import java.util.Map; - -import org.fortiss.af3.exploration.alg.dse.CompositeExplorationSolution; -import org.fortiss.af3.exploration.alg.dse.SolutionQuantification; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.ProblemModuleBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.IExplorationSolution; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.opt4j.core.Individual; -import org.opt4j.core.Objective; -import org.opt4j.core.optimizer.Archive; - -/** - * Result of an Opt4J run, i.e. the {@link SolutionQuantification}s for all pareto-optimal - * {@link IExplorationSolution}s. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3184 $ - * @ConQAT.Rating RED Hash: EBAB34167BA939EE73D41B47018CDF62 - */ -public class Opt4JExplorationSolutionSet<P extends Phenotype> extends - CompositeExplorationSolution<P> { - - /** - * Constructs an {@link CompositeExplorationSolution} representation from the results obtained - * by an Opt4J - * run, i.e. the {@link SolutionQuantification}s for all pareto-optimal - * {@link IExplorationSolution}s. - * - * @throws Exception - * if the evaluation result for an {@link Objective} of an individual cannot be - * identified. - */ - Opt4JExplorationSolutionSet(Archive archive, - Map<ExplorationTarget<?>, ExplorationTarget<?>> copiedTargetAssocMap, - ProblemModuleBase<?, ?, ?> problemModule) throws Exception { - for(Individual individual : archive) { - @SuppressWarnings("unchecked") IExplorationSolution<P> expSolution = - (IExplorationSolution<P>)individual.getPhenotype(); - addExplorationSolution(expSolution, - new Opt4JSingleExplorationSolution(individual.getObjectives(), - copiedTargetAssocMap, problemModule)); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/Opt4JExplorerBackend.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/Opt4JExplorerBackend.java deleted file mode 100644 index 598658e5b3e0460c32ce81a487a6a4aa71c94031..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/Opt4JExplorerBackend.java +++ /dev/null @@ -1,332 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: Opt4JExplorerBackend.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j; - -import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.fortiss.af3.exploration.alg.dse.CompositeExplorationSolution; -import org.fortiss.af3.exploration.alg.dse.backend.ExplorerBackendBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.mating.MatingCrossoverMutateRepairModule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.copy.safetyfunctionarch.CopySafetyFunctionArchModule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.copy.taskmapping.CopyTaskMappingModule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover.CrossoverAbstractTaskMappingModule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover.NopCrossoverInstantiatedTaskMappingModule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover.NopCrossoverSFArchModule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.safetyarch.MutateSafetyFunctionArchitectureModule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskinstantiation.MutateTaskInstanceModule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping.MutateTaskMappingModule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.ArchitectureExplorationProblemModule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.ArchitectureSolution; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.IExplorationSolution; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.moea.model.DseSpecification; -import org.fortiss.af3.exploration.moea.model.feature.SafetyExploration; -import org.fortiss.af3.exploration.moea.model.parameters.EAOptimizer; -import org.opt4j.core.Individual; -import org.opt4j.core.Objective; -import org.opt4j.core.Objectives; -import org.opt4j.core.Value; -import org.opt4j.core.common.archive.DefaultArchive; -import org.opt4j.core.common.completer.IndividualCompleterModule; -import org.opt4j.core.config.Task; -import org.opt4j.core.config.TaskStateListener; -import org.opt4j.core.optimizer.Archive; -import org.opt4j.core.optimizer.Control; -import org.opt4j.core.start.Opt4JTask; -import org.opt4j.optimizers.ea.EvolutionaryAlgorithmModule; -import org.opt4j.optimizers.ea.Spea2Module; - -import com.google.inject.Module; - -/** - * Opt4J optimization backend that defines the DSE task for this particular optimization framework. - * Here, the problem definitiona, the variation modules, the optimizer, and the solution format are - * defined. Additionally, the optimization task is started here and the results are returned. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: 807972F8C6C82F89D3226DBEB4124C97 - */ -public class Opt4JExplorerBackend extends ExplorerBackendBase<EAOptimizer> { - - /** Opt4J optimization process */ - private Opt4JTask opt4JTask; - - /** EA parameters. */ - private EAOptimizer opt4JParameters; - - /** - * Contains the problem module that includes the evaluators associated with the goals of the - * DSE. - */ - private ArchitectureExplorationProblemModule archExplorationProblemModule; - - /** - * Constructor that initializes the Opt4J backend, and sets optimizer independent parameters - * and the goal specification - * - * @throws Exception - */ - public Opt4JExplorerBackend(DseSpecification dse, ExplorationSpecification expSpec, - Map<ExplorationTarget<?>, ExplorationTarget<?>> targetAssocMap, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - Set<Class<? extends IExplorationEncoding>> requestedSolutions, - IProgressMonitor progressMonitor) throws Exception { - // Optimizer independent configuration - super(dse, expSpec, targetAssocMap, systemModelAdapter, requestedSolutions, progressMonitor); - - if(dse.getOptimizer() instanceof EAOptimizer) { - init((EAOptimizer)dse.getOptimizer()); - } else { - throw new Exception( - "Opt4JExplorerBackend cannot be configured with optimizer dependent configuration of type " + - dse.getClass()); - } - } - - /** {@inheritDoc} */ - @Override - protected void init(EAOptimizer opt4JParameters) { - this.opt4JParameters = opt4JParameters; - - System.out.println("Initializing EA optimizer (generations: " + "" + - opt4JParameters.getIterations() + ", alpha: " + opt4JParameters.getAlpha() + ")."); - - // Instantiate modules that describe the optimization problem - Collection<Module> modules = new ArrayList<Module>(); - - // Evolutionary algorithm module - EvolutionaryAlgorithmModule evolutionaryAlgorithmModule = new EvolutionaryAlgorithmModule(); - evolutionaryAlgorithmModule.setGenerations(opt4JParameters.getIterations()); - evolutionaryAlgorithmModule.setAlpha(opt4JParameters.getAlpha()); - evolutionaryAlgorithmModule.setMu(opt4JParameters.getMu()); - evolutionaryAlgorithmModule.setCrossoverRate(0.3); - modules.add(evolutionaryAlgorithmModule); - - // SPEA2 specific module - Spea2Module spea2Module = new Spea2Module(); - spea2Module.setTournament(opt4JParameters.getSpea2Tournament()); - modules.add(spea2Module); - // Nsga2Module nsga2Module = new Nsga2Module(); - // modules.add(nsga2Module); - - MatingCrossoverMutateRepairModule mating = - new MatingCrossoverMutateRepairModule(systemModelAdapter); - modules.add(mating); - - // TODO: Replace {@link MultiEvaluator} with {@link ExplorationGoalPriorityMultiEvaluator} - // that is - // not based on a @Priority annotation, but on the priority attribute provided by the goal - // specifications for the different optimization dimensions. - // AbstractModule multiEvaluatorModule = new AbstractModule() { - // @Override - // protected void configure() { - // bind(MultiEvaluator.class).to(ExplorationGoalPriorityMultiEvaluator.class); - // - // } - // }; - // modules.add(multiEvaluatorModule); - - archExplorationProblemModule = - new ArchitectureExplorationProblemModule(dse, expSpec, systemModelAdapter, - requestedSolutions); - modules.add(archExplorationProblemModule); - - // Configure operators - // 1. Crossover - CrossoverAbstractTaskMappingModule crossoverModule = - new CrossoverAbstractTaskMappingModule(systemModelAdapter, 0.3); - modules.add(crossoverModule); - NopCrossoverInstantiatedTaskMappingModule nopCrossoverInstMapping = - new NopCrossoverInstantiatedTaskMappingModule(); - modules.add(nopCrossoverInstMapping); - NopCrossoverSFArchModule nopCrossoverSFArch = new NopCrossoverSFArchModule(); - modules.add(nopCrossoverSFArch); - - // ===================================== - // 2. Mutation (in order) - // ===================================== - - // Safety functions (if the safety exploration module is enabled) - if(pickFirstInstanceOf(SafetyExploration.class, dse.getFeatures()) != null) { - MutateSafetyFunctionArchitectureModule sfArchModule = - new MutateSafetyFunctionArchitectureModule(systemModelAdapter); - modules.add(sfArchModule); - - // FIXME: add the safety complianceSpec to the input models if needed. - // Also add the SafetyCompliance model to the set of input models. - // SafetyComplianceConstraint scConstr = - // (SafetyComplianceConstraint)targetAssocMap - // .entrySet() - // .stream() - // .filter(e -> SafetyComplianceConstraint.class.isAssignableFrom(e - // .getKey().getClass())).findAny().get().getValue(); - // - // systemModelAdapter.putInputModel(SafetyComplianceSpecification.class, - // scConstr.getSafetyComplianceSpecification()); - } - - // Task instantiation - MutateTaskInstanceModule mutateInstanceModule = - new MutateTaskInstanceModule(systemModelAdapter); - // mutateInstanceModule.setMutationRateType(MutationRateType.ADAPTIVE); - modules.add(mutateInstanceModule); - - // Task allocation - MutateTaskMappingModule mutateModule = new MutateTaskMappingModule(systemModelAdapter); - // mutateModule.setMutationRateType(MutationRateType.ADAPTIVE); - // mutateModule.setMutationRate(0.125); - modules.add(mutateModule); - - // 3. Genotype copy - modules.add(new CopyTaskMappingModule()); - modules.add(new CopySafetyFunctionArchModule()); - - // Define a completer module that "controls" the execution of the decode and the evaluation - // phases. It also allows to parallelize the execution of these phases. - IndividualCompleterModule comp = new IndividualCompleterModule(); - if(opt4JParameters.isParallelExecution()) { - comp.setType(IndividualCompleterModule.Type.PARALLEL); - comp.setThreads(Runtime.getRuntime().availableProcessors()); - } - modules.add(comp); - - // Create and initialize optimization task - opt4JTask = new Opt4JTask(false); - opt4JTask.init(modules); - - if(progressMonitor != null) { - opt4JTask.addStateListener(new TaskStateListener() { - - @Override - public void stateChanged(Task task) { - // stateChanged() is invoked after every generation - progressMonitor.worked(1); - - if(progressMonitor.isCanceled()) { - System.out.println("DSE has been canceled."); - Control control = opt4JTask.getInstance(Control.class); - control.doStop(); - } - } - }); - } - } - - /** - * {@inheritDoc} - * - * @throws Exception - */ - @Override - public CompositeExplorationSolution<?> explore() throws Exception { - - System.out.println("Running EA optimization..."); - if(progressMonitor != null) { - progressMonitor.beginTask("EA optimization", opt4JParameters.getIterations()); - } - - CompositeExplorationSolution<?> rval = null; - Exception ex = null; - try { - // Execute optimization - opt4JTask.execute(); - - // Collect the set objectives - Collection<Objective> objectiveSet = new HashSet<>(); - for(ExplorationTarget<?> copiedExpTarget : targetAssocMap.values()) { - if(!(copiedExpTarget instanceof ExplorationConstraint<?>)) { - Objective constraintObjective = - archExplorationProblemModule.getObjectiveOf(copiedExpTarget); - objectiveSet.add(constraintObjective); - } - } - - Archive archive = new DefaultArchive(); - Archive completeArchive = opt4JTask.getInstance(Archive.class); - - // Check each individual for constraint violations and only further process those which - // violate none. - Collection<Individual> feasibleIndividuals = new ArrayList<>(); - for(Individual curIndividual : completeArchive) { - boolean satisfiesAllConstraints = true; - for(ExplorationConstraint<?> target : pickInstanceOf(ExplorationConstraint.class, - expSpec.getTargets())) { - Objective objective = archExplorationProblemModule.getObjectiveOf(target); - Value<?> value = curIndividual.getObjectives().get(objective); - if(!validateSolution((IExplorationSolution<?>)curIndividual.getPhenotype(), - target, value, archExplorationProblemModule.getEvaluators())) { - satisfiesAllConstraints = false; - } - } - - if(satisfiesAllConstraints) { - feasibleIndividuals.add(curIndividual); - } - } - - // For the final Pareto-Front calculation, consider only Objectives. - // Create a new archive with the same individuals that have only objective evaluations. - // TODO: For robust optimization, we should also consider a distance metric to the - // constraint's bounds. - for(Individual curIndividual : feasibleIndividuals) { - Objectives oldObjectives = curIndividual.getObjectives(); - Objectives reducedObjectives = new Objectives(); - for(Entry<Objective, Value<?>> singleObjective : oldObjectives) { - if(objectiveSet.contains(singleObjective.getKey())) { - reducedObjectives.add(singleObjective.getKey(), singleObjective.getValue()); - } - } - curIndividual.setObjectives(reducedObjectives); - archive.update(curIndividual); - } - - rval = - new Opt4JExplorationSolutionSet<ArchitectureSolution>(archive, targetAssocMap, - archExplorationProblemModule); - - rval.setCompletedIterations(opt4JTask.getIteration()); - - } catch(Exception e) { - ex = e; - } finally { - opt4JTask.close(); - } - - if(ex != null) { - throw ex; - } - - return rval; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/Opt4JSingleExplorationSolution.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/Opt4JSingleExplorationSolution.java deleted file mode 100644 index 13c89a8921108055c138c362251ae8808b656f20..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/Opt4JSingleExplorationSolution.java +++ /dev/null @@ -1,86 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: Opt4JSingleExplorationSolution.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j; - -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.getSubstitutionTypeOfGenericIface; - -import java.util.Map; -import java.util.Map.Entry; - -import org.fortiss.af3.exploration.alg.dse.SolutionQuantification; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.ProblemModuleBase; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.tooling.base.model.element.IModelElement; -import org.opt4j.core.Objective; -import org.opt4j.core.Objectives; - -/** - * Exploration result for a single solution computed by Opt4J, i.e. its fitness w.r.t to the - * investigated optimization dimensions. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: B3B30685BA7E630630E46968DACAEF20 - */ -public class Opt4JSingleExplorationSolution extends SolutionQuantification { - - /** - * Constructs the {@SolutionQuantification} representation of the - * fitness values for a single solution w.r.t to the investigated optimization dimensions - * obtained by an Opt4J run. - * - * @throws Exception - * if the evaluation result for an {@link Objective} cannot be identified. - */ - Opt4JSingleExplorationSolution(Objectives objectives, - Map<ExplorationTarget<?>, ExplorationTarget<?>> targetAssocMap, - ProblemModuleBase<?, ?, ?> problemModule) throws Exception { - for(Entry<ExplorationTarget<?>, ExplorationTarget<?>> targetAssoc : targetAssocMap - .entrySet()) { - // Determine the ExplorationTarget class to identify the correct return value type. - Objective objective = problemModule.getObjectiveOf(targetAssoc.getValue()); - ExplorationTarget<?> concreteExpTarget = targetAssoc.getKey(); - Class<?> expectedResultType = - getSubstitutionTypeOfGenericIface(concreteExpTarget, ExplorationTarget.class); - // FIXME: throw an exception here. - assert (expectedResultType != null) : "Could not determine the result type of the exploration target " + - concreteExpTarget.getName() + - ". Possible reasons are a missing deduction from the class ExplorationTarget or a missing parameter substitiution in the concrete ExplorationTarget."; - - // Type check the result vs. the expected type defined by the exploration target. - Object result = objectives.get(objective).getValue(); - - // FIXME: remove this hack: Instead, the safetycomplianceconstraint should have the - // right type parameter for the value and interface the repair mechanism - // differently. - if(expectedResultType.equals(Boolean.class) || - IModelElement.class.isAssignableFrom(expectedResultType)) { - result = new Boolean(objectives.get(objective).getDouble() <= 10E-9); - } else if(result != null && !result.getClass().equals(expectedResultType)) { - // Note: if the result is null, a serious constraint violation is indicated. Its - // corresponding solution will be filtered out in a later stage. - throw new IllegalArgumentException( - "Incompatible evaluation result type for the exploration target " + - concreteExpTarget.getName() + "."); - } - // "Store" the result if the type of the result is the expected one. - addSingleExplorationResult(concreteExpTarget, objectives.get(objective)); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/ArchitectureExplorationCreator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/ArchitectureExplorationCreator.java deleted file mode 100644 index 6bf821d867b9e3323fc279f3e91e74c55fdaa86c..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/ArchitectureExplorationCreator.java +++ /dev/null @@ -1,58 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ArchitectureExplorationCreator.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.create; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.ArchitectureExplorationEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.create.CompositeCreatorBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.opt4j.core.problem.Creator; - -import com.google.inject.Inject; - -/** - * {@link Creator} of the {@link ArchitectureExplorationEncoding} of an architectural exploration - * problem, that consists of sub encodings. Refer to {@link ComposableGenotype} for further - * documentation. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 621D2365276CA35B8FF9F5B8834C59AB - */ -public class ArchitectureExplorationCreator extends - CompositeCreatorBase<ArchitectureExplorationEncoding> { - - /** DSE specification */ - protected ExplorationSpecification expSpec; - - /** Constructor. */ - @Inject - public ArchitectureExplorationCreator(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - this.expSpec = expSpec; - } - - /** {@inheritDoc} */ - @Override - public ArchitectureExplorationEncoding createComposite() { - return new ArchitectureExplorationEncoding(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/safetyfunctionarch/SafetyFunctionArchCreator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/safetyfunctionarch/SafetyFunctionArchCreator.java deleted file mode 100644 index 242fa6541e62a8afa362652f7e74476cae94874f..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/safetyfunctionarch/SafetyFunctionArchCreator.java +++ /dev/null @@ -1,66 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SafetyFunctionArchCreator.java 3451 2016-09-02 13:36:29Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.safetyfunctionarch; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.create.ComposableCreatorBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.FlatGenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph.DecoderDependencyGraph; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; - -import com.google.inject.Inject; - -/** - * Creator for the {@link SafetyFunctionArchEncoding} that provides a standard encoding for the - * exploration of safety function designs. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3451 $ - * @ConQAT.Rating RED Hash: BF0E2928922764EA1711587B4803C626 - */ -public class SafetyFunctionArchCreator<C> extends - ComposableCreatorBase<SafetyFunctionArchEncoding<C>> { - - /** Constructor. */ - @Inject - public SafetyFunctionArchCreator(SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execDepGraph) { - super(systemModelAdapter, execDepGraph); - } - - /** {@inheritDoc} */ - @SuppressWarnings({"rawtypes", "unchecked"}) - @Override - public SafetyFunctionArchEncoding<C> createComposable(FlatGenotypeMap createdGenotypes, - FlatPhenotypeMap decodedPhenotypes) { - // It is clear that the generic is right. However, the compiler does not get it. Thus, - // suppress the corresponding Warnings. - return new SafetyFunctionArchEncoding(systemModelAdapter.getSafetyFunctionAdapters(), true, - true); - } - - /** {@inheritDoc} */ - @Override - public Class<? extends IExplorationEncoding> getCreatedEncoding() { - return SafetyFunctionArchEncoding.class; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/taskmapping/AbstractTaskMappingCreator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/taskmapping/AbstractTaskMappingCreator.java deleted file mode 100644 index 5fe1f91fc05d35848c6449a8186f4bba4a856639..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/taskmapping/AbstractTaskMappingCreator.java +++ /dev/null @@ -1,82 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AbstractTaskMappingCreator.java 3480 2016-09-09 13:31:04Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.FlatGenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph.DecoderDependencyGraph; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.opt4j.core.Genotype; -import org.opt4j.core.problem.Creator; - -import com.google.inject.Inject; - -/** - * {@link Creator} for an {@link AbstractTaskMappingEncoding}, i.e. a {@link Genotype} that may - * refer which need to be instantiated. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3480 $ - * @ConQAT.Rating RED Hash: 84C723B9A07A7EB3626B8640078BDDB6 - */ -public class AbstractTaskMappingCreator extends - TaskMappingCreator<AbstractTaskMappingEntry, AbstractTaskMappingEncoding> { - - /** Constructor */ - @Inject - public AbstractTaskMappingCreator(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execDepGraph) { - super(expSpec, systemModelAdapter, execDepGraph); - } - - /** - * {@inheritDoc} - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - @Override - public AbstractTaskMappingEncoding createComposable(FlatGenotypeMap createdGenotypes, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) throws ExplorationException { - AbstractTaskGraphEncoding<?, ?> atgEnc = - decodedPhenotypes.getEncoding(AbstractTaskGraphEncoding.class); - assert (atgEnc != null) : "The required abstract task graph encoding could not be found in the map of already decoded phenotypes."; - // The AbstractTaskMappingEncoding may be NULL to indicate that no previous step produced a - // partial mapping. - AbstractTaskMappingEncoding atmEnc = - createdGenotypes.get(AbstractTaskMappingEncoding.class); - return new AbstractTaskMappingEncoding(expSpec, systemModelAdapter, atgEnc, atmEnc); - } - - /** {@inheritDoc} */ - @Override - public Class<? extends IExplorationEncoding> getCreatedEncoding() { - return AbstractTaskMappingEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/taskmapping/FailSilentTaskMappingCreator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/taskmapping/FailSilentTaskMappingCreator.java deleted file mode 100644 index 7f5a1ae04db3be7b8cf053ada1232df80abd46f5..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/taskmapping/FailSilentTaskMappingCreator.java +++ /dev/null @@ -1,76 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FailSilentTaskMappingCreator.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FailSilentTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FailSilentTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.FlatGenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph.DecoderDependencyGraph; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.model.ExplorationSpecification; - -import com.google.inject.Inject; - -/** - * Creator of random task mappings for fail-silent execution model - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: BE96FE6CA38EE830867EEF62E0332F15 - */ -public class FailSilentTaskMappingCreator extends - TaskMappingCreator<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> { - - /** - * Constructs a task mapping creator for a given DSE specification and input model - * (execution model = fail-silent) - */ - @Inject - public FailSilentTaskMappingCreator(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execDepGraph) { - super(expSpec, systemModelAdapter, execDepGraph); - } - - /** {@inheritDoc} */ - @Override - public FailSilentTaskMappingEncoding createComposable(FlatGenotypeMap createdGenotypes, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) { - AbstractTaskGraphEncoding<?, ?> atgEnc = - decodedPhenotypes.getEncoding(AbstractTaskGraphEncoding.class); - assert (atgEnc != null) : "The required abstract task graph encoding could not be found in the map of already decoded phenotypes."; - AbstractTaskMappingEncoding atmEnc = - createdGenotypes.get(AbstractTaskMappingEncoding.class); - assert (atmEnc != null) : "The required abstract task mapping encoding could not be found in the map of already decoded phenotypes."; - return new FailSilentTaskMappingEncoding(expSpec, systemModelAdapter, atgEnc, atmEnc); - } - - // TODO: remove this method: use the identifier from the encoding, instead. - /** {@inheritDoc} */ - @Override - public Class<? extends IExplorationEncoding> getCreatedEncoding() { - return InstantiatedTaskMappingEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/taskmapping/FaultDetectionVotingTaskMappingCreator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/taskmapping/FaultDetectionVotingTaskMappingCreator.java deleted file mode 100644 index 59b44564bca787736f91c73a859bc3b963062fc2..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/taskmapping/FaultDetectionVotingTaskMappingCreator.java +++ /dev/null @@ -1,77 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FaultDetectionVotingTaskMappingCreator.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FaultDetectionVotingTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FaultDetectionVotingTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.FlatGenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph.DecoderDependencyGraph; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.model.ExplorationSpecification; - -import com.google.inject.Inject; - -/** - * Creator of random task mappings for fail-silent execution model - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: AC7EC5E2BEE4C324CB03ACDE91821063 - */ -public class FaultDetectionVotingTaskMappingCreator - extends - TaskMappingCreator<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> { - - /** - * Constructs a task mapping creator for a given DSE specification and input model - * (execution model = fault-detection and voting) - */ - @Inject - public FaultDetectionVotingTaskMappingCreator(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execDepGraph) { - super(expSpec, systemModelAdapter, execDepGraph); - } - - /** {@inheritDoc} */ - @Override - public FaultDetectionVotingTaskMappingEncoding createComposable( - FlatGenotypeMap createdGenotypes, FlatPhenotypeMap<Phenotype> decodedPhenotypes) { - AbstractTaskGraphEncoding<?, ?> atgEnc = - decodedPhenotypes.getEncoding(AbstractTaskGraphEncoding.class); - assert (atgEnc != null) : "The required abstract task graph encoding could not be found in the map of already decoded phenotypes."; - AbstractTaskMappingEncoding atmEnc = - createdGenotypes.get(AbstractTaskMappingEncoding.class); - assert (atmEnc != null) : "The required abstract task mapping encoding could not be found in the map of already decoded phenotypes."; - return new FaultDetectionVotingTaskMappingEncoding(expSpec, systemModelAdapter, atgEnc, - atmEnc); - } - - /** {@inheritDoc} */ - @Override - public Class<? extends IExplorationEncoding> getCreatedEncoding() { - return InstantiatedTaskMappingEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/taskmapping/TaskMappingCreator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/taskmapping/TaskMappingCreator.java deleted file mode 100644 index c0f2ea36997f94eb8f1d26900d0ec8e9e10953c7..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/create/taskmapping/TaskMappingCreator.java +++ /dev/null @@ -1,55 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: TaskMappingCreator.java 3451 2016-09-02 13:36:29Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.create.ComposableCreatorBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph.DecoderDependencyGraph; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.opt4j.core.Genotype; -import org.opt4j.core.problem.Creator; - -import com.google.inject.Inject; - -/** - * {@link Creator} module for general {@link TaskMappingEncoding}s {@link Genotype}s. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3451 $ - * @ConQAT.Rating RED Hash: ACA5ABFB89AA10B63CF80A39ED6B6173 - */ - -public abstract class TaskMappingCreator<S extends TaskMappingEntry, T extends TaskMappingEncoding<?>> - extends ComposableCreatorBase<T> { - - /** DSE specification. */ - protected ExplorationSpecification expSpec; - - /** Constructor. */ - @Inject - public TaskMappingCreator(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execDepGraph) { - super(systemModelAdapter, execDepGraph); - this.expSpec = expSpec; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/ArchExpSubEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/ArchExpSubEncoding.java deleted file mode 100644 index 54493fc912f8c60afa76fef3a2fe1be34c32716f..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/ArchExpSubEncoding.java +++ /dev/null @@ -1,35 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ArchExpSubEncoding.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; - -/** - * Marker interface for encodings of sub problems of an architectural exploration problem solved by - * the DSE. All sub encodings must inherit from this interface to be properly recognized. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 5689F53CFA04401B588CA43875D062C7 - */ - -public interface ArchExpSubEncoding extends ComposableGenotype { - // TODO: Check whether this interface can be removed. - // Marker interface. -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/ArchitectureExplorationEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/ArchitectureExplorationEncoding.java deleted file mode 100644 index d3ee644f5e7d4dee38d01ee404ade1cc398caf82..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/ArchitectureExplorationEncoding.java +++ /dev/null @@ -1,35 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ArchitectureExplorationEncoding.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.opt4j.core.genotype.CompositeGenotype; - -/** - * Allows to instantiate an encoding of an {@link ArchitectureExplorationEncoding} used to describe - * an architectural exloration problem. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: D4E881E2ACB8E1514E8C63551C1A67D9 - */ -public class ArchitectureExplorationEncoding extends - CompositeGenotype<Class<? extends ComposableGenotype>, ComposableGenotype> { - // "Marker" class. -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/MappingEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/MappingEncoding.java deleted file mode 100644 index f7b6df2cb3877d4e8b824e22cea6e2aa2dd62805..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/MappingEncoding.java +++ /dev/null @@ -1,34 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2017 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; -import org.opt4j.core.Genotype; - -/** - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 936D4CA6FBCFCA888354239999C51B52 - */ -public interface MappingEncoding<G extends Genotype> extends ComposablePhenotype<G>, - IMappingEncoding { - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/comm/MessageEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/comm/MessageEncoding.java deleted file mode 100644 index 4caeaeccc7cbd48e6f6dc0dd1212f37ea49e69ed..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/comm/MessageEncoding.java +++ /dev/null @@ -1,67 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MessageEncoding.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.comm; - -import static org.fortiss.tooling.common.util.LambdaUtils.filterSet; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -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.comm.Message; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.extension.IDseInputParameters.SignalType; - -/** - * {@link IExplorationEncoding} that defines the {@link Message}s which are transmitted on a target - * platform subject to some mapping. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: 5EA9D27DEA9CA9BB67BBFB96ADA404D9 - */ -public class MessageEncoding<S extends TaskMappingEntry, T extends TaskMappingEncoding<S>> - implements IExplorationEncoding, ComposablePhenotype<T> { - - /** Contains the set of generated messages. */ - Collection<Message> messages; - - /** Constructor. */ - public MessageEncoding(Collection<Message> messages) { - this.messages = messages; - } - - /** Returns the collection of all generated messages. */ - public Collection<Message> getAllMessages() { - return messages; - } - - /** Returns all messages that are sent periodically. */ - public Collection<Message> getPeriodicMessages() { - return filterSet(messages, m -> m.getSignalAdapter().getSignalType() == SignalType.PERIODIC); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Class<? extends ComposablePhenotype<?>> getPTypeToRegister() { - return (Class<? extends ComposablePhenotype<?>>)MessageEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/comm/constraint/InternalIsolatedCommunicationSet.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/comm/constraint/InternalIsolatedCommunicationSet.java deleted file mode 100644 index a0e174f92468a5fce376622e981bc9023ccd1dac..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/comm/constraint/InternalIsolatedCommunicationSet.java +++ /dev/null @@ -1,189 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.comm.constraint; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.dsl_v2.model.expression.IExpression; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationTarget; - -/** - * DSE-internal {@link ExplorationConstraint} that marks a group of {@link IMappingEntry}s that are - * only allowed to communicate with each other or {@link IMappingEntry}s which ar enot part of any - * other {@link InternalIsolatedCommunicationSet}. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 3FBA33610B5E09FCD89E8CAE0FADA17B - */ -// TODO: Clarify the internal ExplorationConstraint concept to allow for a cleaner implementation. -@SuppressWarnings("javadoc") -public class InternalIsolatedCommunicationSet extends EObjectImpl implements - ExplorationConstraint<Boolean>, Cloneable { - - private int id = 0; - - private String name = ""; - - private String comment = ""; - - private boolean isSoft = false; - - private Set<IMappingEntry> isolatedCommunicationSet; - - public InternalIsolatedCommunicationSet(Set<IMappingEntry> isolatedCommunicationSet) { - this.isolatedCommunicationSet = isolatedCommunicationSet; - } - - public InternalIsolatedCommunicationSet(InternalIsolatedCommunicationSet other) { - this.isolatedCommunicationSet = new HashSet<>(other.isolatedCommunicationSet); - this.name = other.name; - this.comment = other.comment; - this.isSoft = other.isSoft; - } - - /** {@inheritDoc} */ - @Override - public String getComment() { - return comment; - } - - /** {@inheritDoc} */ - @Override - public void setComment(String value) { - comment = value; - } - - /** {@inheritDoc} */ - @Override - public String getName() { - return name; - } - - /** {@inheritDoc} */ - @Override - public void setName(String value) { - name = value; - } - - /** {@inheritDoc} */ - @Override - public int getId() { - return id; - } - - /** {@inheritDoc} */ - @Override - public void setId(int value) { - id = value; - } - - /** {@inheritDoc} */ - @Override - public boolean isIsSoft() { - return isSoft; - } - - /** {@inheritDoc} */ - @Override - public void setIsSoft(boolean value) { - isSoft = value; - } - - /** {@inheritDoc} */ - @Override - public boolean isImplicit() { - return true; - } - - /** {@inheritDoc} */ - @Override - public void setImplicit(boolean value) { - // NOP. - } - - public Set<IMappingEntry> getIsolatedCommunicationSet() { - return isolatedCommunicationSet; - } - - public void setIsolatedCommunicationSet(Set<IMappingEntry> isolatedCommunicationSet) { - this.isolatedCommunicationSet = isolatedCommunicationSet; - } - - public void addToIsolatedCommunicationSet(Collection<? extends IMappingEntry> addEntries) { - this.isolatedCommunicationSet.addAll(addEntries); - } - - public void removeFromIsolatedCommunicationSet(Collection<? extends IMappingEntry> rmEntries) { - this.isolatedCommunicationSet.removeAll(rmEntries); - } - - public void replaceEntry(IMappingEntry oldEntry, IMappingEntry newEntry) { - this.isolatedCommunicationSet.remove(oldEntry); - this.isolatedCommunicationSet.add(newEntry); - } - - public void replaceEntriesIfPresent( - Map<? extends IMappingEntry, ? extends IMappingEntry> replacementMap) { - for(Entry<? extends IMappingEntry, ? extends IMappingEntry> entry : replacementMap - .entrySet()) { - if(contains(entry.getKey())) { - replaceEntry(entry.getKey(), entry.getValue()); - } - } - } - - public boolean contains(IMappingEntry entry) { - return isolatedCommunicationSet.contains(entry); - } - - @Override - public Object clone() { - return new InternalIsolatedCommunicationSet(this); - } - - /** {@inheritDoc} */ - @Override - public IExpression getExpression() { - // TODO Auto-generated method stub - return null; - } - - /** {@inheritDoc} */ - @Override - public void setExpression(IExpression value) { - // TODO Auto-generated method stub - - } - - /** {@inheritDoc} */ - @Override - public EList<ExplorationTarget<Boolean>> getContainedTargets() { - // TODO Auto-generated method stub - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/safetyfunctionarch/SafetyFunctionArchEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/safetyfunctionarch/SafetyFunctionArchEncoding.java deleted file mode 100644 index 47a6e544017f4f44eeb384b6e45648e9ea4e9e91..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/safetyfunctionarch/SafetyFunctionArchEncoding.java +++ /dev/null @@ -1,192 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SafetyFunctionArchEncoding.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch; - -import static org.fortiss.af3.exploration.alg.util.AF3Utils.getChannelNumbersSafetyArch; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.getTriggerNumbersSafetyArch; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.isDiagConnectedSafetyArch; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.isDiagPresentSafetyArch; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISafetyFunctionAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.random.RandomExploration; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.safety.model.SafetyArchitecture; -import org.opt4j.core.Genotype; - -/** - * Encodes the design of safety functions that are contained in a logical architecture. It consists - * of the {@link SafetyFunctionArchEntry}s of all identified safety function of the input model. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: AF50E8B9D777FA0BB274BB4E0227FFB4 - */ -public class SafetyFunctionArchEncoding<C> implements IExplorationEncoding, ComposableGenotype, - ComposablePhenotype<SafetyFunctionArchEncoding<C>>, Cloneable { - - /** Random generator */ - private RandomExploration rand = RandomExploration.getInstance(); - - /** - * Collection that consists of safety function design entries for each safety function that is - * present in the input models. - */ - private List<SafetyFunctionArchEntry<C>> safetyFunctionArch = new ArrayList<>(); - - /** - * Constructor for creating a {@link SafetyFunctionArchEncoding} with entries for each safety - * function defined in the input models. The selected entries can be either {@code randomize}d - * or default to a 1oo1 design. - */ - public SafetyFunctionArchEncoding(Collection<ISafetyFunctionAdapter<C>> safetyFunctions, - boolean initialize, boolean randomize) { - if(initialize) { - for(ISafetyFunctionAdapter<C> currSF : safetyFunctions) { - if(randomize) { - safetyFunctionArch.add(createRandomSFDesign(currSF)); - } else { - safetyFunctionArch.add(createDefaultSFDesign(currSF)); - } - } - } - } - - /** - * Constructor for creating a {@link SafetyFunctionArchEncoding} with the given encoding. Each - * {@link SafetyFunctionArchEntry} will be cloned. - */ - public SafetyFunctionArchEncoding(Collection<SafetyFunctionArchEntry<C>> safetyFunctionDesigns) { - for(SafetyFunctionArchEntry<C> entry : safetyFunctionDesigns) { - this.safetyFunctionArch.add(entry.clone()); - } - } - - /** Creates a 1oo1 {@link SafetyFunctionArchEntry}. */ - public SafetyFunctionArchEntry<C> - createDefaultSFDesign(ISafetyFunctionAdapter<C> safetyFunction) { - return new SafetyFunctionArchEntry<C>(safetyFunction, 1, 0, false, false); - } - - /** - * Creates a {@link SafetyFunctionArchEntry} with randomized parameters subject to the - * limitations defined in the given {@link ISafetyFunctionAdapter}. - */ - public SafetyFunctionArchEntry<C> - createRandomSFDesign(ISafetyFunctionAdapter<C> safetyFunction) { - List<SafetyArchitecture> sfArch = - new ArrayList<>(safetyFunction.getAllowedSafetyArchitectures()); - int randSFArchIdx = rand.nextInt(sfArch.size()); - SafetyArchitecture selectedSFArch = sfArch.get(randSFArchIdx); - - int selChannelNum = getChannelNumbersSafetyArch(selectedSFArch); - int triggerNum = getTriggerNumbersSafetyArch(selectedSFArch); - boolean diagPresent = isDiagPresentSafetyArch(selectedSFArch).orElse(false); - boolean diagUnitConnected = isDiagConnectedSafetyArch(selectedSFArch).orElse(false); - - return new SafetyFunctionArchEntry<C>(safetyFunction, selChannelNum, triggerNum, - diagPresent, diagUnitConnected); - } - - /** - * Adds a {@link SafetyFunctionArchEntry} to the encoding of all safety functions in the - * system. - */ - public boolean addEntry(SafetyFunctionArchEntry<C> entry) { - return safetyFunctionArch.add(entry); - } - - /** - * Returns the {@link SafetyFunctionArchEntry} that is located at the given {@code index} of the - * encoding. - */ - public SafetyFunctionArchEntry<C> getEntry(int index) { - if(index < 0 || index >= safetyFunctionArch.size()) { - return null; - } - return safetyFunctionArch.get(index); - } - - /** - * Returns the {@link SafetyFunctionArchEntry}s that compose {@code this} - * {@link SafetyFunctionArchEncoding}. - */ - public Collection<SafetyFunctionArchEntry<C>> getAllEntries() { - return safetyFunctionArch; - } - - /** - * Returns the {@link SafetyFunctionArchEntry} that represents the chosen design of the given - * {@link ISafetyFunctionAdapter}. - */ - public Optional<SafetyFunctionArchEntry<C>> - getDesignOf(ISafetyFunctionAdapter<?> safetyFunction) { - return safetyFunctionArch.stream() - .filter(sfd -> sfd.getSafetyFunctionAdapter() == safetyFunction).findAny(); - } - - /** {@inheritDoc} */ - @Override - public int size() { - return safetyFunctionArch.size(); - } - - /** {@inheritDoc} */ - @Override - public <G extends Genotype> G newInstance() { - Collection<ISafetyFunctionAdapter<C>> sfAdapters = - safetyFunctionArch.stream().map(sf -> sf.getSafetyFunctionAdapter()) - .collect(Collectors.toList()); - @SuppressWarnings("unchecked") G sfArchEncoding = - (G)new SafetyFunctionArchEncoding<C>(sfAdapters, true, true); - return sfArchEncoding; - } - - /** {@inheritDoc} */ - @Override - public Object clone() { - return new SafetyFunctionArchEncoding<C>(safetyFunctionArch); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return getAllEntries().toString(); - } - - /** {@inheritDoc} */ - @Override - public Class<? extends ComposableGenotype> getGTypeToRegister() { - return SafetyFunctionArchEncoding.class; - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Class<? extends ComposablePhenotype<?>> getPTypeToRegister() { - return (Class<? extends ComposablePhenotype<?>>)SafetyFunctionArchEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/safetyfunctionarch/SafetyFunctionArchEntry.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/safetyfunctionarch/SafetyFunctionArchEntry.java deleted file mode 100644 index 0da9ea08ed95c70718e874045c3eb5f08df34f24..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/safetyfunctionarch/SafetyFunctionArchEntry.java +++ /dev/null @@ -1,178 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SafetyFunctionArchEntry.java 3714 2016-10-17 13:51:34Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISafetyFunctionAdapter; - -/** - * Represents the chosen design of a single safety function, e.g. 1oo2D as defined in the IEC61508 - * standard. - * <p> - * Each entry has the following properties: - * <li>Number of channels.</li> - * <li>Number of required signals from independent channels to trigger the safety function.</li> - * <li>Presence of a diagnostic unit connected to the output unit/voter.</li> - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3714 $ - * @ConQAT.Rating RED Hash: 65CE739775A71C4BD65E5BAE492C1A83 - */ -public class SafetyFunctionArchEntry<C> implements Cloneable { - - /** References the safety function whose design is represented by {@code this} class. */ - private ISafetyFunctionAdapter<C> safetyFunction; - - /** Defines the number of (independent) channels. */ - private int numChannels = 1; - - /** Defines the number of independent signals to trigger the safety function. */ - private int triggerSignalIdx = 0; - - /** - * Number corresponding to the index defining the required number of signal to trigger the - * safety function. - */ - private int triggerSignalNum = 0; - - /** Presence of a diagnostic unit. */ - // NOTE: Assumption #(diagUnits) == #(channels)! - private boolean diagnosticUnitPresent = false; - - /** Whether a (present) diagnostic unit is connected to the output "voter". */ - private boolean diagnosticUnitConnected = false; - - /** Constructor. */ - public SafetyFunctionArchEntry(ISafetyFunctionAdapter<C> safetyFunction, int numChannels, - int numTriggerSignals, boolean diagnosisUnitPresent, boolean diagnosticUnitConnected) { - this.safetyFunction = safetyFunction; - this.numChannels = numChannels; - this.triggerSignalNum = numTriggerSignals; - for(int i = 0; i < safetyFunction.getAllAllowedTriggerSignalNumbers().size(); i++) { - if(safetyFunction.getAllowedChannelNumbers()[i] == triggerSignalNum) { - this.triggerSignalIdx = i; - break; - } - } - this.diagnosticUnitPresent = diagnosisUnitPresent; - this.diagnosticUnitConnected = diagnosticUnitConnected; - } - - /** Returns the safety function whose design is represented by {@code this} class. */ - public ISafetyFunctionAdapter<C> getSafetyFunctionAdapter() { - return safetyFunction; - } - - /** Returns the number of channels of {@code this} design of the safety function. */ - public int getNumChannels() { - return numChannels; - } - - /** Sets the number of channels that realize {@code this} safety function. */ - // TODO: Guard to check valid numbers. - public void setNumChannels(int numChannels) { - this.numChannels = numChannels; - - // Also adjust/align the trigger signals. - int[] triggerSigNum = safetyFunction.getAllowedTriggerSignalNumbers(numChannels); - - for(int i = 0; i < triggerSigNum.length; i++) { - if(triggerSigNum[i] == this.triggerSignalNum) { - this.triggerSignalIdx = i; - return; - } - } - - this.triggerSignalIdx = triggerSigNum.length - 1; - this.triggerSignalNum = triggerSigNum[triggerSignalIdx]; - } - - /** - * Returns the number of signal of {@code this} architecture of the safety function that is - * required to trigger the safety function. - */ - public int getNumTriggerSignal() { - int[] triggerSigNum = safetyFunction.getAllowedTriggerSignalNumbers(numChannels); - return triggerSigNum[triggerSignalIdx]; - } - - /** - * Returns the index of the of the current selection of required signals that trigger - * {@code this} safety function. The index is defined on the array of trigger signals subject to - * the number of channels, i.e. it depends on the selected safety architecture. - */ - public int getTriggerSignalIdx() { - return triggerSignalIdx; - } - - /** - * Sets the index of the array defining the required signals that trigger {@code this} safety - * function to the given value. The number of allowed trigger signal is subject ot the selected - * number of channels. - */ - // TODO: Guard to check valid numbers. - public void setTriggerSignalIdx(int triggerSignalIdx) { - int[] triggerSigNum = safetyFunction.getAllowedTriggerSignalNumbers(numChannels); - if(triggerSignalIdx <= triggerSigNum.length) { - this.triggerSignalIdx = triggerSignalIdx; - this.triggerSignalNum = - safetyFunction.getAllowedTriggerSignalNumbers(numChannels)[triggerSignalIdx]; - } - } - - /** - * Returns whether a diagnosis unit is present in {@code this} design of the safety - * function. - */ - public boolean isDiagnosicUnitPresent() { - return diagnosticUnitPresent; - } - - /** Whether to use a not to use a diagnostic unit. */ - // TODO: Guard to check valid numbers. - public void setDiagnosicUnitPresent(boolean diagnosicUnitPresent) { - this.diagnosticUnitPresent = diagnosicUnitPresent; - } - - /** - * Returns whether a diagnosis unit is connected to a voter/output unit in {@code this} design - * of the safety function. - */ - public boolean isDiagnosicUnitConnected() { - return diagnosticUnitConnected; - } - - /** Whether a diagnostic unit shall be connected to the output unit / voter. */ - public void setDiagnosicUnitConnected(boolean diagnosticUnitConnected) { - this.diagnosticUnitConnected = diagnosticUnitConnected; - } - - /** {@inheritDoc} */ - @Override - public SafetyFunctionArchEntry<C> clone() { - return new SafetyFunctionArchEntry<C>(safetyFunction, numChannels, triggerSignalIdx, - diagnosticUnitPresent, diagnosticUnitConnected); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "SfArch: " + getNumTriggerSignal() + "oo" + getNumChannels() + - (isDiagnosicUnitPresent() ? (isDiagnosicUnitConnected() ? "D" : "DU") : "") + "\n"; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/AbstractTaskGraphEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/AbstractTaskGraphEncoding.java deleted file mode 100644 index 87f7fb879f58ad79eff17762433e442340e0db0a..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/AbstractTaskGraphEncoding.java +++ /dev/null @@ -1,54 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AbstractTaskGraphEncoding.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -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.arch.taskgraph.TaskGraph; - -/** - * {@link TaskGraphEncoding} for {@link TaskGraph}s that <i>may</i> contain <i>abstract</i> tasks, - * i.e. tasks that need to be instantiated with <i>concrete</i> tasks from a library. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: 1E871574CDBA7188AB4D369D0E7CD98A - */ -public class AbstractTaskGraphEncoding<G extends ComposableGenotype, C> extends - TaskGraphEncoding<G, C, DefaultTaskGraph> { - - /** Constructor. See {@link TaskGraphEncoding#TaskGraphEncoding(SystemModelAdapter)}. */ - public AbstractTaskGraphEncoding(SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** Copy Constructor. See {@link TaskGraphEncoding#TaskGraphEncoding(TaskGraphEncoding)}. */ - public AbstractTaskGraphEncoding(AbstractTaskGraphEncoding<G, C> encoding) { - super(encoding); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Class<? extends ComposablePhenotype<?>> getPTypeToRegister() { - return (Class<? extends ComposablePhenotype<?>>)AbstractTaskGraphEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/InstantiatedAcyclicTaskGraphEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/InstantiatedAcyclicTaskGraphEncoding.java deleted file mode 100644 index 4401a169748b2c2f75a6ce69b990c8a1c0eb6cb8..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/InstantiatedAcyclicTaskGraphEncoding.java +++ /dev/null @@ -1,69 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: InstantiatedAcyclicTaskGraphEncoding.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph; - -import java.util.Collection; - -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.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -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.DefaultTaskGraph; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; - -/** - * {@link TaskGraphEncoding} for {@link AcyclicTaskGraph}s that contain <i>concrete</i> tasks - * exclusively. The contained {@link TaskGraph}s are directed and acyclic and hence a suitable input - * for schedulers. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: E42FC40C8CDDF9ADDC642CA42B18F49A - */ -public class InstantiatedAcyclicTaskGraphEncoding<T extends InstantiatedTaskMappingEntry, C> - extends TaskGraphEncoding<InstantiatedTaskMappingEncoding<T>, C, AcyclicTaskGraph> { - - /** - * Constructor. See {@link TaskGraphEncoding#TaskGraphEncoding(SystemModelAdapter, Collection)}. - */ - public InstantiatedAcyclicTaskGraphEncoding( - SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter, - Collection<DefaultTaskGraph> taskGraphs) { - super(systemModelAdapter, AcyclicTaskGraph.transformToAcyclicGraphs(taskGraphs)); - } - - /** Constructor. See {@link TaskGraphEncoding#TaskGraphEncoding(SystemModelAdapter)}. */ - public InstantiatedAcyclicTaskGraphEncoding( - SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** Copy Constructor. See {@link TaskGraphEncoding#TaskGraphEncoding(TaskGraphEncoding)}. */ - public InstantiatedAcyclicTaskGraphEncoding(InstantiatedAcyclicTaskGraphEncoding<T, C> encoding) { - super(encoding); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Class<? extends ComposablePhenotype<?>> getPTypeToRegister() { - return (Class<? extends ComposablePhenotype<?>>)InstantiatedAcyclicTaskGraphEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/InstantiatedTaskGraphEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/InstantiatedTaskGraphEncoding.java deleted file mode 100644 index 8cb02ba87641c442c4fe35cb0c1dbb8ecde83647..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/InstantiatedTaskGraphEncoding.java +++ /dev/null @@ -1,64 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: InstantiatedTaskGraphEncoding.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph; - -import java.util.Collection; - -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.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -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.arch.taskgraph.TaskGraph; - -/** - * {@link TaskGraphEncoding} for {@link TaskGraph}s that contain <i>concrete</i> tasks exclusively. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: 8EF5A4473BDCFD72A3AED1A40E8ACBBF - */ -public class InstantiatedTaskGraphEncoding<T extends InstantiatedTaskMappingEntry, C> extends - TaskGraphEncoding<InstantiatedTaskMappingEncoding<T>, C, DefaultTaskGraph> { - - /** - * Constructor. See {@link TaskGraphEncoding#TaskGraphEncoding(SystemModelAdapter, Collection)}. - */ - public InstantiatedTaskGraphEncoding(SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter, - Collection<DefaultTaskGraph> taskGraphs) { - super(systemModelAdapter, taskGraphs); - } - - /** Constructor. See {@link TaskGraphEncoding#TaskGraphEncoding(SystemModelAdapter)}. */ - public InstantiatedTaskGraphEncoding(SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** Copy Constructor. See {@link TaskGraphEncoding#TaskGraphEncoding(TaskGraphEncoding)}. */ - public InstantiatedTaskGraphEncoding(InstantiatedTaskGraphEncoding<T, C> encoding) { - super(encoding); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Class<? extends ComposablePhenotype<?>> getPTypeToRegister() { - return (Class<? extends ComposablePhenotype<?>>)InstantiatedTaskGraphEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/SafeTaskGraphEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/SafeTaskGraphEncoding.java deleted file mode 100644 index e7de3d3de857c9bbe439b560ae2f0d80aaf70dbf..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/SafeTaskGraphEncoding.java +++ /dev/null @@ -1,53 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SafeTaskGraphEncoding.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; - -/** - * {@link TaskGraphEncoding} which provides {@link TaskGraph}s for explored architectures of safety - * functions that are encoded by a {@link SafetyFunctionArchEncoding}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: 62C48EEC73FEB8FB565197D21B2E4E04 - */ -public class SafeTaskGraphEncoding<C> extends - AbstractTaskGraphEncoding<SafetyFunctionArchEncoding<C>, C> { - - /** Constructor. See {@link TaskGraphEncoding#TaskGraphEncoding(SystemModelAdapter)}. */ - public SafeTaskGraphEncoding(SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** Copy Constructor. See {@link TaskGraphEncoding#TaskGraphEncoding(TaskGraphEncoding)}. */ - public SafeTaskGraphEncoding(SafeTaskGraphEncoding<C> encoding) { - super(encoding); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Class<? extends ComposablePhenotype<?>> getPTypeToRegister() { - return (Class<? extends ComposablePhenotype<?>>)SafeTaskGraphEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/TaskGraphEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/TaskGraphEncoding.java deleted file mode 100644 index 1a01bfa75e83e7a03a89b3d4dbf140ebbcf9547f..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskgraph/TaskGraphEncoding.java +++ /dev/null @@ -1,333 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: TaskGraphEncoding.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph; - -import static org.fortiss.af3.exploration.alg.util.GraphUtils.getGraphOf; - -import java.util.Collection; -import java.util.HashSet; -import java.util.stream.Collectors; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.ChannelAdapterWeightedEdge; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.opt4j.core.Genotype; - -/** - * Encoding (as a {@link Genotype}) which represents the set of deployable Components that shall be - * mapped to {@link IExecutionUnitAdapter}s by the DSE. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: ACAC81CFC026063D5266CBF1AC4DB252 - */ -public class TaskGraphEncoding<G extends Genotype, C, T extends TaskGraph> implements - IExplorationEncoding, ComposablePhenotype<G>, Cloneable { - - /** References the {@link SystemModelAdapter} which adapts the input models. */ - protected SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter; - - /** {@link TaskGraph} that represents the deployable components and their signals. */ - protected Collection<T> taskGraphs; - - /** - * Collection of {@link IDeployableComponentAdapter}s that shall be mapped to deployment targets - * ({@link IExecutionUnitAdapter}). - */ - protected Collection<IDeployableComponentAdapter<C>> deployableComponents = new HashSet<>(); - - /** - * Subset of {@link IDeployableComponentAdapter}s from the collection of deployable components - * that may be replicated. - */ - protected Collection<IDeployableComponentAdapter<C>> replicableComponents = new HashSet<>(); - - /** - * Constructor that initializes {@code this} encoding with the collection of - * {@link IDeployableComponentAdapter}s as they are extracted from the input models. - */ - @SuppressWarnings("unchecked") - public TaskGraphEncoding(SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - - taskGraphs = - (Collection<T>)systemModelAdapter.getTaskGraphs().stream().map(tg -> tg.copy()) - .collect(Collectors.toSet()); - - replicableComponents.addAll(systemModelAdapter.getReplicableComponents()); - deployableComponents.addAll(systemModelAdapter.getDeployableComponents()); - } - - /** - * Constructor that initializes {@code this} encoding with the collection of - * {@link IDeployableComponentAdapter}s as they are extracted from the input models. - */ - public TaskGraphEncoding(SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter, - Collection<T> taskGraphs) { - this(systemModelAdapter); - this.taskGraphs = taskGraphs; - - this.deployableComponents.clear(); - - for(TaskGraph tg : taskGraphs) { - @SuppressWarnings("unchecked") Collection<? extends IDeployableComponentAdapter<C>> tasks = - (Collection<? extends IDeployableComponentAdapter<C>>)tg.getTasks(); - deployableComponents.addAll(tasks); - } - } - - /** - * Copy constructor that takes an existing {@link TaskGraphEncoding} as input and - * generates an equivalent copy. - */ - public TaskGraphEncoding(TaskGraphEncoding<G, C, T> encoding) { - taskGraphs.addAll(encoding.getTaskGraphs()); - deployableComponents.addAll(encoding.deployableComponents); - replicableComponents.addAll(encoding.replicableComponents); - } - - /** Returns the collection of {@link TaskGraph}s composing {@code this} encoding. */ - public Collection<T> getTaskGraphs() { - return taskGraphs; - } - - /** - * Adds the given {@link IDeployableComponentAdapter} to its corresponding {@link TaskGraph} in - * {@code this} encoding. - */ - public void addTask(IDeployableComponentAdapter<C> task) { - // TODO: Here, we use the assumption that the given task refers to a task that is also - // present in the system model adapter. - - TaskGraph taskGraph = getGraphOf(task, taskGraphs); - // Find the right Task Graph, in case the task does not exist in any of the task graphs of - // this encoding. - if(taskGraph == null) { - taskGraph = findTGBySystemModel(systemModelAdapter.getTaskGraph(task)); - } - - // TODO: This should be transformed into an exception. - assert (taskGraph != null) : "The task to be added could be neither found in this encoding, nor the input models."; - - taskGraph.addTask(task); - deployableComponents.add(task); - if(task.getMinReplication() != task.getMaxReplication()) { - replicableComponents.add(task); - } - } - - /** - * Detects whether the {@link TaskGraph} of the input system model references any tasks of the - * internal {@link TaskGraph}s and returns the first matching {@link TaskGraph}. - */ - private TaskGraph findTGBySystemModel(TaskGraph systemTG) { - for(TaskGraph currTG : taskGraphs) { - if(currTG.containsAnyTaskOf(systemTG.getTasks())) { - return currTG; - } - } - return null; - } - - /** - * Adds all signals defined in the input models for the given - * {@link IDeployableComponentAdapter} which must be contained in any of the internal - * {@link TaskGraph}s. - */ - public void addSignalsOf(IDeployableComponentAdapter<C> task) { - // The given task must be in the any of the task graphs! - - T taskGraph = getGraphOf(task, taskGraphs); - // TODO: This should be transformed into an exception. - assert (taskGraph != null); - - TaskGraph systemTG = systemModelAdapter.getTaskGraph(task); - Collection<ChannelAdapterWeightedEdge> incomingEdges = - systemTG.getGraph().incomingEdgesOf(task); - Collection<ChannelAdapterWeightedEdge> outgoingEdges = - systemTG.getGraph().outgoingEdgesOf(task); - - for(ChannelAdapterWeightedEdge edge : incomingEdges) { - IDeployableComponentAdapter<?> source = systemTG.getGraph().getEdgeSource(edge); - taskGraph.getGraph().addEdge(source, task, edge); - } - - for(ChannelAdapterWeightedEdge edge : outgoingEdges) { - IDeployableComponentAdapter<?> target = systemTG.getGraph().getEdgeTarget(edge); - taskGraph.getGraph().addEdge(task, target, edge); - } - } - - /** - * Adds the signals of a cloned task by querying the existing signals from the clone's original - * task. - */ - public void addClonedSignalsOf(IDeployableComponentAdapter<C> originalTask, - IDeployableComponentAdapter<C> clonedTask) { - // The given task must be in the any of the task graphs! - - T taskGraph = getGraphOf(originalTask, taskGraphs); - // TODO: This should be transformed into an exception. - assert (taskGraph != null); - - Collection<ChannelAdapterWeightedEdge> incomingEdges = - taskGraph.getGraph().incomingEdgesOf(originalTask); - Collection<ChannelAdapterWeightedEdge> outgoingEdges = - taskGraph.getGraph().outgoingEdgesOf(originalTask); - - for(ChannelAdapterWeightedEdge edge : incomingEdges) { - IDeployableComponentAdapter<?> source = taskGraph.getGraph().getEdgeSource(edge); - taskGraph.getGraph().addEdge(source, clonedTask, - new ChannelAdapterWeightedEdge(edge.getChannelAdapter())); - } - - for(ChannelAdapterWeightedEdge edge : outgoingEdges) { - IDeployableComponentAdapter<?> target = taskGraph.getGraph().getEdgeTarget(edge); - taskGraph.getGraph().addEdge(clonedTask, target, - new ChannelAdapterWeightedEdge(edge.getChannelAdapter())); - } - } - - /** - * Clones the given {@link IDeployableComponentAdapter} and adds it to the corresponding task - * graph and further data structures. - */ - public IDeployableComponentAdapter<C> cloneTask(IDeployableComponentAdapter<C> task) { - // Clone the task and add it to the corresponding task graph. - TaskGraph taskGraph = getGraphOf(task, taskGraphs); - IDeployableComponentAdapter<C> clonedTask = task.clone(); - taskGraph.addTask(clonedTask); - addClonedSignalsOf(task, clonedTask); - // Add the cloned task to the cache sets. - deployableComponents.add(clonedTask); - if(replicableComponents.contains(task)) { - replicableComponents.add(clonedTask); - } - - return clonedTask; - } - - /** Returns the {@link TaskGraph} containing the given task or {@code null} if none is found. */ - // TODO: Change the parameter again to IDeployableComponentAdapter<C>: pass the type parameter - // to the scheduler. - public T getTaskGraphOf(IDeployableComponentAdapter<?> task) { - return getGraphOf(task, taskGraphs); - } - - /** Whether {@code this} encoding contains the given task. */ - public boolean containsTask(IDeployableComponentAdapter<C> task) { - return getGraphOf(task, taskGraphs) != null; - } - - /** - * Removes the given {@link IDeployableComponentAdapter} from the {@link TaskGraph} containing - * the particular task and from the caches. - * <p> - * <i>Side-note:</i> Each task may be located in only one {@link TaskGraph}. - * - * @returns {@code true} iff a containing {@link TaskGraph} has been found. - * */ - public boolean removeTask(IDeployableComponentAdapter<C> task) { - TaskGraph taskGraph = getGraphOf(task, taskGraphs); - if(taskGraph != null) { - taskGraph.removeTask(task); - deployableComponents.remove(task); - replicableComponents.remove(task); - return true; - } - assert (false); // Never here. - return false; - } - - /** - * Returns the deployable (software) component that are present in the internal - * {@link TaskGraph}s. May contain "abstract" {@link Component}s. - */ - public Collection<IDeployableComponentAdapter<?>> getDeployableComponents() { - // return deployableComponents; - Collection<IDeployableComponentAdapter<?>> deplComp = new HashSet<>(); - for(T tg : taskGraphs) { - deplComp.addAll(tg.getTasks()); - } - return deplComp; - } - - // TODO: Consider implementing this method as a map, since this operation is run often? - /** - * Returns the {@link IDeployableComponentAdapter} that is constructed form the given object. - * - * @param originalEObject - * The object for which the corresponding {@link IDeployableComponentAdapter} shall - * be identified. - * @return The asociated {@link IDeployableComponentAdapter}, or {@code null} if none can be - * identified. - */ - public synchronized IDeployableComponentAdapter<C> getDeployableComponentOf( - EObject originalEObject) { - for(IDeployableComponentAdapter<C> deployableComponentAdapter : deployableComponents) { - if(deployableComponentAdapter.getObject() == originalEObject) { - return deployableComponentAdapter; - } - } - return null; - } - - /** - * Returns the deployable (software) components that my be - * replicated. May contain "abstract" {@link Component}s. - */ - public Collection<IDeployableComponentAdapter<C>> getReplicableComponents() { - return replicableComponents; - } - - /** - * Returns the {@link IDeployableComponentAdapter} that wraps the given {@link EObject}. Here, - * only those {@link IDeployableComponentAdapter} are searched which can be actually executed on - * {@link ExecutionUnit}s, i.e. "abstract" components are not considered. - */ - public IDeployableComponentAdapter<C> - getReplicableDeployableComponentOf(EObject originalEObject) { - for(IDeployableComponentAdapter<C> deployableComponentAdapter : replicableComponents) { - if(deployableComponentAdapter.getObject() == originalEObject) { - return deployableComponentAdapter; - } - } - return null; - } - - /** {@inheritDoc} */ - @Override - public Object clone() { - return new TaskGraphEncoding<G, C, T>(this); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Class<? extends ComposablePhenotype<?>> getPTypeToRegister() { - return (Class<? extends ComposablePhenotype<?>>)TaskGraphEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/TaskMappingEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/TaskMappingEncoding.java deleted file mode 100644 index 125466c6f361c45398fd3f70dad2a0dc3233fa41..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/TaskMappingEncoding.java +++ /dev/null @@ -1,885 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: TaskMappingEncoding.java 3888 2016-11-11 11:56:13Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ - -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping; - -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.castToRawColl; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -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; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.TaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.constraint.InternalReplicationConstraint; -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.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -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.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.DefaultTaskGraph; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.random.RandomExploration; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.util.ExplorationAlgDebugUtils; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiAllocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiDislocationConstraint; -import org.fortiss.af3.platform.model.ExecutionUnit; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.ListMultimap; -import com.google.common.collect.Multimap; - -/** - * Problem encoding of a task mapping (with redundancy). - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3888 $ - * @ConQAT.Rating RED Hash: 3B3778916988AD5A3122766A3D295D1F - */ -public abstract class TaskMappingEncoding<T extends TaskMappingEntry> implements IMappingEncoding, - ComposableGenotype, MappingEncoding, ArchExpSubEncoding, IExplorationEncoding, - ConstrainedEncoding, Cloneable { - /** Random generator */ - private RandomExploration rand = RandomExploration.getInstance(); - - /** DSE specification */ - protected ExplorationSpecification expSpec; - - /** Map holding the DSE-internal constraints. */ - // TODO: Remove InternalConstraint map or replace with a generic mapping Encoding. - // Alternative solution: Mode the map to the operators. - protected Multimap<Class<? extends ExplorationConstraint<?>>, ExplorationConstraint<?>> constraintMap = - HashMultimap.create(); - - /** Stores the references between {@link IMappingEntry} to keep track of association updates. */ - protected Multimap<IMappingEntry, IMappingEntry> referencedByMap = HashMultimap.create(); - - /** - * Map of disallowed {@link IDeployableComponentAdapter} -> {@link IExecutionUnitAdapter} - * allocations. - */ - // TODO: Move to a central place, but where? - protected Multimap<IDeployableComponentAdapter<?>, IExecutionUnitAdapter<?>> disallowedAllocations; - - /** - * Map of disallowed {@link IDeployableComponentAdapter} -> {@link IExecutionUnitAdapter} - * allocations. - */ - // TODO: Move to a central place, but where? - protected Multimap<IDeployableComponentAdapter<?>, IExecutionUnitAdapter<?>> allowedAllocations; - - /** Deployable component adapters that shall not be considered by the redundancy operator. */ - protected Collection<IDeployableComponentAdapter<?>> fixAllocatedComponents; - - /** Representation of input system */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** - * Collection of deployable {@link IDeployableComponentAdapter}s represented by {@code this} - * mapping. - */ - protected Collection<IDeployableComponentAdapter<?>> deployableComponents; - - /** The input {@link TaskGraphEncoding} that contains the tasks and their signals. */ - protected TaskGraphEncoding<?, ?, ?> tgEncoding; - - /** - * Allocation map - * <ul> - * <li>key: the software component (task)</li> - * <li>value: the set of hardware components (cores)</li> - * <li>Multiple entry in the list represent redundant mapping</li> - */ - protected ListMultimap<IDeployableComponentAdapter<?>, T> allocationMap; - - /** Ratio between the generation of RoundRobin based and pure random mapping generation. */ - private final double fixToRandomRatio = 0.25; - - /** - * Constructor that is initialized with a reference to the DSE specification and the input - * system. - */ - public TaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - TaskGraphEncoding<?, ?, ?> tgEncoding) { - this.expSpec = expSpec; - this.systemModelAdapter = systemModelAdapter; - this.tgEncoding = tgEncoding; - this.deployableComponents = castToRawColl(tgEncoding.getDeployableComponents()); - allocationMap = ArrayListMultimap.create(); - - disallowedAllocations = createDisallowedAllocationMap(); - allowedAllocations = createAllowedAllocationMap(); - fixAllocatedComponents = createFixAllocationCollection(); - } - - /** - * Constructor that optionally initializes the encoding to a random encoding. - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - public TaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, boolean initialize) - throws ExplorationException { - this(expSpec, systemModelAdapter, new TaskGraphEncoding<>(systemModelAdapter)); - if(initialize) { - resetEncoding(); - } - } - - /** - * Constructor that optionally initializes the encoding to a random encoding - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - public TaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - TaskGraphEncoding<?, ?, ?> tgEncoding, boolean initialize) throws ExplorationException { - this(expSpec, systemModelAdapter, tgEncoding); - if(initialize) { - resetEncoding(); - } - } - - /** - * Constructor that optionally initializes the encoding to a random encoding - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - public TaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - TaskGraphEncoding<?, ?, ?> tgEncoding, TaskMappingEncoding<?> incompleteEncoding) - throws ExplorationException { - this(expSpec, systemModelAdapter, tgEncoding); - completeEncoding(incompleteEncoding); - } - - /** - * Adds the given {@link TaskMappingEntry} to the internal allocation table and adds the - * references between {@link TaskMappingEntry}s accordingly. - * - * @param entry - * {@link TaskMappingEntry} to be added to the allocation table. - */ - protected void addAllocation(T entry) { - allocationMap.put(entry.getDeployableComponent(), entry); - referencedByMap.putAll(entry, entry.getAssociatedElement()); - } - - /** - * Creates a collection of component adapters whose redundancy shall not be modified by the - * corresponding operator -> define it as fix. - */ - // TODO: Exchange this workaround with a mechanism that allows to "reserve" deployable - // components (-> marker) to not be processed by subsequent operators. - private Collection<IDeployableComponentAdapter<?>> createFixAllocationCollection() { - Collection<IDeployableComponentAdapter<?>> fixAllocatedComponents = new HashSet<>(); - for(IDeployableComponentAdapter<?> compAdp : deployableComponents) { - Optional<ComponentMultiDislocationConstraint> constr = - expSpec.getTargets().stream() - .filter(c -> (c instanceof ComponentMultiDislocationConstraint)) - .map(ComponentMultiDislocationConstraint.class::cast) - .filter(c -> c.getComponent() == compAdp.getObject()).findAny(); - if(constr.isPresent()) { - fixAllocatedComponents.add(systemModelAdapter.getDeployableComponentOf(constr.get() - .getComponent())); - } - } - return fixAllocatedComponents; - } - - /** - * Adds a component adapter whose redundancy shall not be modified by the - * corresponding operator -> define it as fix. - */ - // TODO: Exchange this workaround with a mechanism that allows to "reserve" deployable - // components (-> marker) to not be processed by subsequent operators. - public void addFixAllocation(IDeployableComponentAdapter<?> compAdp, - Collection<IExecutionUnitAdapter<?>> validAllocTargets) { - fixAllocatedComponents.add(compAdp); - validAllocTargets.forEach(t -> allowedAllocations.put(compAdp, t)); - } - - /** - * Creates a map which refers those {@link IExecutionUnitAdapter}s that are invalid allocation - * targets of the given component. - */ - private Multimap<IDeployableComponentAdapter<?>, IExecutionUnitAdapter<?>> - createDisallowedAllocationMap() { - Multimap<IDeployableComponentAdapter<?>, IExecutionUnitAdapter<?>> rval = - HashMultimap.create(); - - Collection<ComponentMultiDislocationConstraint> forbiddenDeploymentConstraints = - getChildrenWithType(expSpec, ComponentMultiDislocationConstraint.class); - - for(ComponentMultiDislocationConstraint currentConstraint : forbiddenDeploymentConstraints) { - for(IDeployableComponentAdapter<?> currentComponentAdapter : systemModelAdapter - .getDeployableComponents()) { - if(currentComponentAdapter.getObject() == currentConstraint.getComponent()) { - // TODO: Remove dependency on AF3 here. - Collection<ExecutionUnit> forbiddenAF3TargetsOfComponent = - currentConstraint.getExecutionUnits(); - for(IExecutionUnitAdapter<?> currentForbiddenTargetUnit : systemModelAdapter - .getDeploymentTargets()) { - if(forbiddenAF3TargetsOfComponent.contains(currentForbiddenTargetUnit - .getObject())) { - rval.put(currentComponentAdapter, currentForbiddenTargetUnit); - } - } - } - } - } - - return rval; - } - - /** - * Creates a lookup map that holds the collection of all disallowed mapping targets of - * {@link IDeployableComponentAdapter}s. - */ - private Multimap<IDeployableComponentAdapter<?>, IExecutionUnitAdapter<?>> - createAllowedAllocationMap() { - Multimap<IDeployableComponentAdapter<?>, IExecutionUnitAdapter<?>> rval = - HashMultimap.create(); - - Collection<ComponentMultiAllocationConstraint> allowedDeploymentConstraints = - getChildrenWithType(expSpec, ComponentMultiAllocationConstraint.class); - Collection<IDeployableComponentAdapter<?>> constrainedComponentAdps = new HashSet<>(); - - for(ComponentMultiAllocationConstraint currentConstraint : allowedDeploymentConstraints) { - for(IDeployableComponentAdapter<?> currentComponentAdapter : systemModelAdapter - .getDeployableComponents()) { - if(currentComponentAdapter.getObject() == currentConstraint.getComponent()) { - constrainedComponentAdps.add(currentComponentAdapter); - - // TODO: Remove dependency on AF3 here. - Collection<ExecutionUnit> allowedAF3TargetsOfComponent = - currentConstraint.getExecutionUnits(); - for(IExecutionUnitAdapter<?> currentAllowedTargetUnit : systemModelAdapter - .getDeploymentTargets()) { - if(allowedAF3TargetsOfComponent.contains(currentAllowedTargetUnit - .getObject())) { - rval.put(currentComponentAdapter, currentAllowedTargetUnit); - } - } - } - } - } - - for(IDeployableComponentAdapter<?> curDeplComp : deployableComponents) { - // TODO: create a field for the deployment targets. - if(!constrainedComponentAdps.contains(curDeplComp)) { - systemModelAdapter.getDeploymentTargets().forEach(t -> rval.put(curDeplComp, t)); - } - } - - return rval; - } - - /** - * Returns the collection of allowed mapping targets if a - * {@link ComponentMultiAllocationConstraint} is defined, otherwise {@code null} is returned. - */ - public Collection<IExecutionUnitAdapter<?>> getAllowedAllocations( - IDeployableComponentAdapter<?> deployableComponent) { - IDeployableComponentAdapter<?> origComponent = - systemModelAdapter.getDeployableComponentOf((EObject)deployableComponent - .getObject()); - return allowedAllocations.get(origComponent); - } - - /** - * Returns the collection of disallowed mapping targets if a - * {@link ComponentMultiDislocationConstraint} is defined, otherwise null is returned. - */ - public Collection<IExecutionUnitAdapter<?>> getDisAllowedAllocations( - IDeployableComponentAdapter<?> deployableComponent) { - IDeployableComponentAdapter<?> origComponent = - systemModelAdapter.getDeployableComponentOf((EObject)deployableComponent - .getObject()); - return disallowedAllocations.get(origComponent); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public <U extends ExplorationConstraint<?>> Collection<U> getConstraintsOf(Class<U> type) { - return (Collection<U>)constraintMap.get(type); - } - - /** {@inheritDoc} */ - @Override - public Multimap<Class<? extends ExplorationConstraint<?>>, ExplorationConstraint<?>> - getConstraints() { - return constraintMap; - } - - /** {@inheritDoc} */ - @Override - public <U extends ExplorationConstraint<?>> void replaceConstraints( - Multimap<Class<? extends U>, U> constraintMap) { - constraintMap.keySet().forEach(c -> this.constraintMap.removeAll(c)); - this.constraintMap.putAll(constraintMap); - } - - /** {@inheritDoc} */ - @Override - public <U extends ExplorationConstraint<?>> void replaceConstraints(Class<U> type, - Collection<U> constraints) { - constraintMap.replaceValues(type, constraints); - } - - /** {@inheritDoc} */ - @Override - public <U extends ExplorationConstraint<?>> void putConstraint(Class<U> type, U constraint) { - constraintMap.put(type, constraint); - } - - /** {@inheritDoc} */ - @Override - public <U extends ExplorationConstraint<?>> void removeConstraint(Class<U> type, U constraint) { - constraintMap.remove(type, constraint); - } - - /** - * Initializes the allocation table for the {@link IDeployableComponentAdapter}s that are not - * yet present in the given {@code incompleteEncoding}. - * - * @param incompleteEncoding - * Partial Decoding to be completed. - * @throws ExplorationException - * if no valid allocation targets can be identified. - */ - public void completeEncoding(TaskMappingEncoding<?> incompleteEncoding) - throws ExplorationException { - ArrayList<IDeployableComponentAdapter<?>> allocComponents = new ArrayList<>(); - allocComponents.addAll(deployableComponents); - - if(incompleteEncoding != null) { - allocComponents.removeAll(incompleteEncoding.getDeployedComponents()); - - incompleteEncoding.getMappingEntries().forEach( - e -> addAllocation(createEntry(e.getDeployableComponent(), e.getTarget()))); - } - - createEncoding(allocComponents); - } - - /** - * Resets the encoding to a random encoding where each target component is arbitrarily mapped to - * a deployment target. The resulting mapping can include redundancy, and respects potential - * {@link ComponentMultiAllocationConstraint}s and {@link ComponentMultiDislocationConstraint}s. - * - * @throws ExplorationException - * if no valid allocation targets can be identified. - */ - public void resetEncoding() throws ExplorationException { - assert (false); - allocationMap.clear(); - createEncoding(deployableComponents); - } - - /** - * Creates {@link TaskMappingEntry}s for the given set of {@link IDeployableComponentAdapter}s. - * - * @param allocatableComponents - * Collection of components to generated {@link TaskMappingEntry}s for. - * @throws ExplorationException - * if no valid allocation targets can be identified. - */ - protected void createEncoding(Collection<IDeployableComponentAdapter<?>> allocatableComponents) - throws ExplorationException { - double selRandOrFixedInit = rand.nextDouble(); - List<IExecutionUnitAdapter<?>> execTargets = - new ArrayList<>(systemModelAdapter.getDeploymentTargets()); - int roundRobinAllocIdx = rand.nextInt(execTargets.size()); - - List<IDeployableComponentAdapter<?>> compColl = new ArrayList<>(allocatableComponents); - if(selRandOrFixedInit < fixToRandomRatio) { - Collections.shuffle(compColl); - } - - for(IDeployableComponentAdapter<?> deployableComponent : compColl) { - List<IExecutionUnitAdapter<?>> validExecTargets = execTargets; - if(allowedAllocations.containsKey(deployableComponent)) { - validExecTargets = - allowedAllocations.get(deployableComponent).stream() - .collect(Collectors.toList()); - } - - if(selRandOrFixedInit < fixToRandomRatio) { - generateRandomDeployment(deployableComponent); - } else { - for(int repl = 0; repl < deployableComponent.getMaxReplication(); repl++) { - int calcTargetIdx = roundRobinAllocIdx % validExecTargets.size(); - addAllocation(createEntry(deployableComponent, - validExecTargets.get(calcTargetIdx))); - roundRobinAllocIdx++; - if(roundRobinAllocIdx == execTargets.size()) { - roundRobinAllocIdx = 0; - } - } - } - } - - if(!ExplorationAlgDebugUtils.checkTaskMappingForSFConsistency(this)) { - System.out.println("Error."); - } - } - - /** - * Creates an (encoding specific) mapping entry the describes that a given deployable component - * is mapped to a deployment target. - */ - protected abstract T createEntry(IDeployableComponentAdapter<?> deployableComponent, - IExecutionUnitAdapter<?> deploymentTarget); - - /** - * Creates a {@link TaskMappingEntry} and adds it to {@code this} mapping. The given - * {@link TaskMappingEntry} defines the source and the target for the created - * {@link TaskMappingEntry}. - * - * @param allocEntry - * Existing {@link TaskMappingEntry} serving as a template for the created - * {@link TaskMappingEntry}. - * @return The created {@link TaskMappingEntry}. - */ - public <S extends TaskMappingEntry> T createAndAddEntry(S allocEntry) { - T newEntry = createEntry(allocEntry); - addAllocation(newEntry); - return newEntry; - } - - /** - * Creates an (encoding specific) mapping entry that is derived from another - * {@link TaskMappingEntry}. - * - * @param allocEntry - * {@link TaskMappingEntry} from which the returned {@link TaskMappingEntry} is - * derived. - */ - protected <S extends TaskMappingEntry> T createEntry(S allocEntry) { - throw new UnsupportedOperationException( - "Creating a TaskMappingEntry based on the given TaskMappingEntry is not supported/implemented."); - } - - /** - * Constructs a random {@TaskMappingEntry} for the given deployable - * component. The deployment targets can be given as a list, otherwise the deployment targets - * are taken from the platform. - * - * @throws ExplorationException - * if no valid allocation targets can be identified. - */ - public T createRandomEntry(IDeployableComponentAdapter<?> deployableComponent, - List<IExecutionUnitAdapter<?>> deploymentTargets) throws ExplorationException { - IExecutionUnitAdapter<?> target = null; - - // Select from remaining allowed deployment targets if no set of desired deployment targets - // is given - if(deploymentTargets == null || deploymentTargets.isEmpty()) { - deploymentTargets = new ArrayList<IExecutionUnitAdapter<?>>(); - if(allowedAllocations.containsKey(deployableComponent)) { - deploymentTargets.addAll(allowedAllocations.get(deployableComponent)); - } else { - deploymentTargets.addAll(systemModelAdapter.getDeploymentTargets()); - } - } - - // Remove any disallowed mapping - deploymentTargets.removeAll(getExcludedDeploymentTargets(deployableComponent)); - - if(!deploymentTargets.isEmpty()) { - target = deploymentTargets.get(rand.nextInt(deploymentTargets.size())); - } - - if(target == null) { - throw new ExplorationException( - "Could not create an allocation entry for the Component " + - deployableComponent.getName() + - ". Typical reasons include:\n" + - "1. An over-constrained ExplorationSpecification such that there " + - "exist no valid allocation targets." + - "2. Desired but non-selected deployment targets in the annoation view " + - "of the logical platforms" + - "3. Selection of a Component that shall not be allocated. The selection of " + - "'deployable' Components is done via the timing model where the 'lowest' timing " + - "event specifies the layer (for each cluster) of components to allocate."); - } - - return createEntry(deployableComponent, target); - } - - /** - * Constructs a random {@TaskMappingEntry} for the given deployable - * component. This method respects {@link ComponentMultiDislocationConstraint}s. - * - * @throws ExplorationException - * if no valid allocation targets can be identified. - */ - public T createRandomEntry(IDeployableComponentAdapter<?> deployableComponent) - throws ExplorationException { - return createRandomEntry(deployableComponent, null); - } - - /** - * Constructs a random {@TaskMappingEntry} for the given deployable - * component and adds it to the internal allocation map. This method respects - * {@link ComponentMultiDislocationConstraint}s. - * - * @throws ExplorationException - * if no valid allocation targets can be identified. - */ - public T createAndAddRandomEntry(IDeployableComponentAdapter<?> deployableComponent) - throws ExplorationException { - T entry = createRandomEntry(deployableComponent, null); - addAllocation(entry); - return entry; - } - - /** Removes the given {@code entry} of the given {@code task} from the mapping. */ - public void removeEntry(T entry) { - allocationMap.remove(entry.getDeployableComponent(), entry); - referencedByMap.get(entry).forEach(e -> e.rmAssociatedElement(entry)); - } - - /** - * Removes a randomly selected entry of the given {@link IDeployableComponentAdapter} from the - * mapping. - */ - public T removeRandomEntry(IDeployableComponentAdapter<?> deployableComponent) { - List<T> entries = new ArrayList<>(); - entries.addAll(allocationMap.get(deployableComponent)); - int idx = rand.nextInt(entries.size()); - T rmEntry = entries.get(idx); - removeEntry(rmEntry); - return rmEntry; - } - - /** - * Removes the given {@link IDeployableComponentAdapter} and, consequently, all associated - * entries from the mapping. - */ - public Collection<T> removeTask(IDeployableComponentAdapter<?> deployableComponent) { - for(T entry : allocationMap.get(deployableComponent)) { - referencedByMap.get(entry).forEach(e -> e.rmAssociatedElement(entry)); - } - return allocationMap.removeAll(deployableComponent); - } - - // TODO: Do not handle this in the encodings / mutation operators! - /** - * Determines if a deployable component is subject to a - * {@link ComponentMultiAllocationConstraint} - */ - public boolean hasFixedDeployment(IDeployableComponentAdapter<?> deployableComponent) { - return fixAllocatedComponents.contains(deployableComponent); - } - - // TODO: Do not handle this in the encodings / mutation operators! - /** - * Generates a fixed deployment for a given deployable component (based on a - * {@link ComponentMultiAllocationConstraint} specification) - * - * @param deployableComponent - * Deployable component for which fixed deployment is to be generated for - */ - public void generateFixedDeployment(IDeployableComponentAdapter<?> deployableComponent) { - Collection<ComponentMultiAllocationConstraint> constraints = - expSpec.getTargets().stream() - .filter(t -> (t instanceof ComponentMultiAllocationConstraint)) - .map(ComponentMultiAllocationConstraint.class::cast) - .collect(Collectors.toList()); - for(ComponentMultiAllocationConstraint cons : constraints) { - if(cons.getComponent() == deployableComponent.getObject()) { - removeTask(deployableComponent); - List<IExecutionUnitAdapter<?>> execList = - new ArrayList<>(systemModelAdapter.getDeploymentTargets()); - execList = - execList.stream() - .filter(e -> cons.getExecutionUnits().contains(e.getObject())) - .collect(Collectors.toList()); - int allocIdx = 0; - for(int i = 0; i < deployableComponent.getMaxReplication(); i++) { - allocIdx = rand.nextInt(execList.size()); - addAllocation(createEntry(deployableComponent, execList.get(allocIdx))); - } - } - } - } - - /** - * Generates a random deployment for a given deployable component (potentially including - * redundancy). - * - * @param deployableComponent - * Deployable component for which fixed deployment is to be generated for - * @throws ExplorationException - * if no valid allocation targets can be identified. - */ - private void generateRandomDeployment(IDeployableComponentAdapter<?> deployableComponent) - throws ExplorationException { - // TODO: Model degree of admissible redundancy as a constraint? - int min = deployableComponent.getMinReplication(); - int max = deployableComponent.getMaxReplication(); - - int num = rand.nextInt(max) + min; - for(int i = 0; i < num; i++) { - // This respects ExcludeDeploymentConstraints - // TODO: Generic handling of constraints - addAllocation(createRandomEntry(deployableComponent)); - } - } - - /** - * Determines the list of deployment target to which a given deployable component may not be - * deployed. These restrictions are derived from {@link InternalSeparationConstraint}s and - * {@link ComponentMultiDislocationConstraint}s. - * - * @param deployableComponent - */ - private Collection<IExecutionUnitAdapter<?>> getExcludedDeploymentTargets( - IDeployableComponentAdapter<?> deployableComponent) { - Collection<IExecutionUnitAdapter<?>> rval = getDisAllowedAllocations(deployableComponent); - - Collection<InternalSeparationConstraint> sepConstraints = - getConstraintsOf(InternalSeparationConstraint.class); - - Optional<InternalSeparationConstraint> relevantSepConstraint = - sepConstraints.stream() - .filter(c -> c.getRequesterSet().contains(deployableComponent)).findAny(); - - if(relevantSepConstraint.isPresent()) { - // TODO: consider the separation level in the selection of forbidden deployment targets. - Collection<IMappingEntry> existingEntries = getIMappingEntriesOf(deployableComponent); - existingEntries.forEach(e -> rval.add(e.getTarget())); - } - - if(rval != null) { - return rval; - } - return Collections.emptySet(); - } - - /** Returns the deployable components that are mapped in this {@link TaskMappingEncoding} */ - @Override - public Collection<IDeployableComponentAdapter<?>> getDeployedComponents() { - return allocationMap.keySet(); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Collection<IMappingEntry> getIMappingEntriesOf( - IDeployableComponentAdapter<?> deployableComponent) { - return (Collection<IMappingEntry>)allocationMap.get(deployableComponent); - } - - /** Returns the deployment target to which a given deployable component has been assigned */ - @SuppressWarnings("unchecked") - @Override - public Collection<IMappingEntry> getIMappingEntries() { - return (Collection<IMappingEntry>)allocationMap.values(); - } - - /** {@inheritDoc} */ - @Override - public boolean containsEntry(IMappingEntry entry) { - return allocationMap.containsValue(entry); - } - - /** Returns the deployment target to which a given deployable component has been assigned */ - public Collection<T> getMappingEntries() { - return allocationMap.values(); - } - - /** - * Returns the deployment target to which a given deployable component has been assigned. - * - * @returns {@code null} if no entry in the allocation table is found. - */ - public Collection<T> getMappingEntriesOf(IDeployableComponentAdapter<?> deployableComponent) { - return allocationMap.get(deployableComponent); - } - - /** - * Returns the collection of {@link IExecutionUnitAdapter}s onto which the given - * {@link IDeployableComponentAdapter} is allocated to. - */ - public Collection<IExecutionUnitAdapter<?>> getMappingTargetsOf( - IDeployableComponentAdapter<?> deployableComponent) { - Collection<IExecutionUnitAdapter<?>> executionTargets = - new HashSet<IExecutionUnitAdapter<?>>(); - for(IMappingEntry currentEntry : getMappingEntriesOf(deployableComponent)) { - executionTargets.add(currentEntry.getTarget()); - } - return executionTargets; - } - - /** - * Returns the deployment targets to which a given deployable component has been assigned - * (similar to {#link getAssignedDeploymentTargets( - * IDeployableComponentAdapter)} - */ - @Override - public synchronized Collection<IResourceAdapter<?>> getAllocatedResourcesFor( - IRequestAdapter<?> deployableComponent) { - if(!(deployableComponent instanceof IDeployableComponentAdapter<?>)) { - return null; - } - - Collection<IResourceAdapter<?>> allocatedResourcesForRequester = - new ArrayList<IResourceAdapter<?>>(); - for(IMappingEntry currentMappingEntry : allocationMap - .get((IDeployableComponentAdapter<?>)deployableComponent)) { - allocatedResourcesForRequester.add(currentMappingEntry.getTarget()); - } - return allocatedResourcesForRequester; - } - - /** Assigns deployment targets to a deployable component */ - public void setAssignedResources(IDeployableComponentAdapter<?> deployableComponent, - List<T> deploymentTargets) { - removeTask(deployableComponent); - deploymentTargets.forEach(e -> addAllocation(e)); - } - - /** Creates a copy of the internal allocation map of {@code this} {@link TaskMappingEncoding}. */ - public ListMultimap<IDeployableComponentAdapter<?>, T> - copyAllocationMap(Map<T, T> copyAssocMap) { - ListMultimap<IDeployableComponentAdapter<?>, T> copiedMap = ArrayListMultimap.create(); - for(Entry<IDeployableComponentAdapter<?>, T> tmEntry : allocationMap.entries()) { - @SuppressWarnings("unchecked") T mappingEntry = (T)tmEntry.getValue().clone(); - copiedMap.put(tmEntry.getKey(), mappingEntry); - copyAssocMap.put(tmEntry.getValue(), mappingEntry); - } - return copiedMap; - } - - /** Creates a copy of the internal constraint map of {@code this} {@link TaskMappingEncoding}. */ - public Multimap<Class<? extends ExplorationConstraint<?>>, ExplorationConstraint<?>> - copyConstraintMap(Map<T, T> copyAssocMap) { - Multimap<Class<? extends ExplorationConstraint<?>>, ExplorationConstraint<?>> copiedMap = - HashMultimap.create(); - for(Entry<Class<? extends ExplorationConstraint<?>>, ExplorationConstraint<?>> cEntry : constraintMap - .entries()) { - ExplorationConstraint<?> cpConstr = null; - // TODO: generic solution for the copy mechanism. - if(cEntry.getValue() instanceof InternalSeparationConstraint) { - cpConstr = - (ExplorationConstraint<?>)((InternalSeparationConstraint)cEntry.getValue()) - .clone(); - } else if(cEntry.getValue() instanceof InternalReplicationConstraint) { - cpConstr = - (ExplorationConstraint<?>)((InternalReplicationConstraint)cEntry.getValue()) - .clone(); - } else if(cEntry.getValue() instanceof InternalIsolatedCommunicationSet) { - InternalIsolatedCommunicationSet commConstr = - (InternalIsolatedCommunicationSet)((InternalIsolatedCommunicationSet)cEntry - .getValue()).clone(); - if(copyAssocMap != null) { - commConstr.replaceEntriesIfPresent(copyAssocMap); - } - cpConstr = commConstr; - } - copiedMap.put(cEntry.getKey(), cpConstr); - } - return copiedMap; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - String str = ""; - - for(IDeployableComponentAdapter<?> deployableComponent : allocationMap.keySet()) { - str += "Mapping: " + deployableComponent.getName() + " -> " + "{"; - - if(allocationMap.get(deployableComponent) != null) { - for(T tgt : allocationMap.get(deployableComponent)) { - str += tgt + ", "; - } - } - str += "}\n"; - } - return str; - } - - /** - * Returns all independent {@link DefaultTaskGraph}s contained in this - * {@link SystemModelAdapter}. - */ - public TaskGraphEncoding<?, ?, ?> getTaskGraphEncoding() { - return tgEncoding; - } - - /** - * Returns the task allocation map - */ - public Map<IDeployableComponentAdapter<?>, Collection<T>> getAllocationMap() { - return allocationMap.asMap(); - } - - /** - * Returns the task allocation multimap. - */ - public Multimap<IDeployableComponentAdapter<?>, T> getAllocationMultiMap() { - return allocationMap; - } - - /** - * Returns the size of the encoding - */ - @Override - public int size() { - return allocationMap.size(); - } - - /** {@inheritDoc} */ - @Override - public Object clone() { - throw new UnsupportedOperationException( - "The clone operation MUST be implemented in the concrete classes of the TaskMappingEncoding. Otherwise, the algorithm does not operate as expected!"); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/TaskMappingEntry.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/TaskMappingEntry.java deleted file mode 100644 index 30e9aad34190429abe8ccb668045047a19ccd6af..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/TaskMappingEntry.java +++ /dev/null @@ -1,106 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: TaskMappingEntry.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.MutableClassToInstanceMap; - -/** - * Base class for {@link TaskMappingEntry}s representing the one allocation of an - * {@link IDeployableComponentAdapter} to an {@link IExecutionUnitAdapter}. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: 3ACC77B2D6EE2B946F4DFDAA3E0B7431 - */ -public abstract class TaskMappingEntry implements IMappingEntry { - /** Deployment target to which task is mapped */ - private IExecutionUnitAdapter<?> target; - - /** {@link IDeployableComponentAdapter} that is "realized" by this {@link TaskMappingEntry}. */ - protected IDeployableComponentAdapter<?> deploymentSource; - - /** Associated {@link IMappingEntry}s that were generated during the DSE process. */ - private ClassToInstanceMap<IMappingEntry> associatedEntries = MutableClassToInstanceMap - .create(); - - /** Constructs a mapping entry the represents the mapping to a given deployment target. */ - protected TaskMappingEntry(IDeployableComponentAdapter<?> deployableComponent, - IExecutionUnitAdapter<?> target) { - this.deploymentSource = deployableComponent; - this.target = target; - } - - /** {@inheritDoc} */ - @Override - public IExecutionUnitAdapter<?> getTarget() { - return target; - } - - /** - * Sets target {@link IExecutionUnitAdapter} to the given {@link IExecutionUnitAdapter} - * overriding the previous target reference. - * - * @param target - * {@link IExecutionUnitAdapter} defining the allocation target. - */ - public void resetTarget(IExecutionUnitAdapter<?> target) { - this.target = target; - } - - /** {@inheritDoc} */ - @Override - public IDeployableComponentAdapter<?> getDeployableComponent() { - return deploymentSource; - } - - /** {@inheritDoc} */ - @Override - public void addAssociatedElement(IMappingEntry assocEntry) { - associatedEntries.put(assocEntry.getClass(), assocEntry); - } - - /** {@inheritDoc} */ - @Override - public void rmAssociatedElement(IMappingEntry entry) { - associatedEntries.remove(entry); - } - - /** {@inheritDoc} */ - @Override - public Collection<IMappingEntry> getAssociatedElement() { - return associatedEntries.values(); - } - - /** {@inheritDoc} */ - @Override - public <T extends IMappingEntry> T getAssociatedElement(Class<T> type) { - return associatedEntries.getInstance(type); - } - - /** {@inheritDoc} */ - @Override - public abstract TaskMappingEntry clone(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/abstractmapping/AbstractTaskMappingEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/abstractmapping/AbstractTaskMappingEncoding.java deleted file mode 100644 index 7708d557f044bd2a8f80260bbdfed1e83bed2e2d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/abstractmapping/AbstractTaskMappingEncoding.java +++ /dev/null @@ -1,165 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AbstractTaskMappingEncoding.java 3885 2016-11-11 09:41:01Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping; - -import java.util.HashMap; -import java.util.Map; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.SafeTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.opt4j.core.Genotype; - -/** - * {@link Genotype} which encodes an {@link TaskMappingEncoding} that may contain - * {@link TaskMappingEntry}s which are required to be initialized. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3885 $ - * @ConQAT.Rating RED Hash: DFA8BDB7233EA65E2B01D9C08975192B - */ -public class AbstractTaskMappingEncoding extends TaskMappingEncoding<AbstractTaskMappingEntry> { - - /** - * Constructor that is initialized with a reference to the DSE specification and the input - * system model. - */ - AbstractTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - SafeTaskGraphEncoding<?> tgEncoding) { - super(expSpec, systemModelAdapter, tgEncoding); - } - - /** - * Constructor that optionally initializes the encoding to a random encoding - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - public AbstractTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - SafeTaskGraphEncoding<?> tgEncoding, boolean initialize) throws ExplorationException { - super(expSpec, systemModelAdapter, tgEncoding, initialize); - } - - /** - * Constructor that optionally initializes the encoding to a random encoding - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - public AbstractTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, boolean initialize) - throws ExplorationException { - super(expSpec, systemModelAdapter, initialize); - } - - /** - * Constructor that optionally initializes the encoding to a random encoding - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - public AbstractTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - AbstractTaskGraphEncoding<?, ?> atgEnc, boolean initialize) throws ExplorationException { - super(expSpec, systemModelAdapter, atgEnc, initialize); - } - - /** - * Constructor that generated a new {@link AbstractTaskMappingEncoding} preserving the - * allocations from the given {@code partialEncoding}. - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - public AbstractTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - AbstractTaskGraphEncoding<?, ?> atgEnc, AbstractTaskMappingEncoding partialEncoding) - throws ExplorationException { - super(expSpec, systemModelAdapter, atgEnc, partialEncoding); - } - - /** {@inheritDoc} */ - @Override - public AbstractTaskMappingEntry createEntry(IDeployableComponentAdapter<?> deployableComponent, - IExecutionUnitAdapter<?> deploymentTarget) { - // Request not needed to construct a {@link FailSilentTaskMappingEncoding} - if(deploymentTarget == null) { - return null; - } - - return new AbstractTaskMappingEntry(deployableComponent, deploymentTarget); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public AbstractTaskMappingEncoding newInstance() { - try { - return new AbstractTaskMappingEncoding(expSpec, systemModelAdapter, true); - } catch(ExplorationException e) { - // Opt4J does not allow to throw Exceptions here. - throw new RuntimeException(e); - } - } - - /** {@inheritDoc} */ - @Override - public Object clone() { - AbstractTaskMappingEncoding clonedEncoding; - try { - clonedEncoding = new AbstractTaskMappingEncoding(expSpec, systemModelAdapter, false); - } catch(ExplorationException e) { - // Opt4J does not allow to throw Exceptions here. - throw new RuntimeException(e); - } - - Map<AbstractTaskMappingEntry, AbstractTaskMappingEntry> copyAssocMap = new HashMap<>(); - - clonedEncoding.allocationMap = copyAllocationMap(copyAssocMap); - clonedEncoding.constraintMap = copyConstraintMap(copyAssocMap); - clonedEncoding.getDeployedComponents().forEach(c -> c.updateInstatiationData()); - return clonedEncoding; - } - - /** {@inheritDoc} */ - @Override - public Class<? extends ComposableGenotype> getGTypeToRegister() { - return AbstractTaskMappingEncoding.class; - } - - /** {@inheritDoc} */ - @Override - public Class<? extends ComposablePhenotype<?>> getPTypeToRegister() { - return (Class<? extends ComposablePhenotype<?>>)AbstractTaskMappingEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/abstractmapping/AbstractTaskMappingEntry.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/abstractmapping/AbstractTaskMappingEntry.java deleted file mode 100644 index 3773bb4966bb0364735b6f165d5de96c0b1122fa..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/abstractmapping/AbstractTaskMappingEntry.java +++ /dev/null @@ -1,52 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AbstractTaskMappingEntry.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; - -/** - * {@link TaskMappingEntry} whose referenced {@link IDeployableComponentAdapter} may require - * initialization to derive a "valid" mapping. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: A8BBB8FC82364F1AD4D6FB187F51156D - */ -public class AbstractTaskMappingEntry extends TaskMappingEntry implements Cloneable { - - /** Constructs a mapping entry the represents the mapping to a given deployment target. */ - public AbstractTaskMappingEntry(IDeployableComponentAdapter<?> deployableComponent, - IExecutionUnitAdapter<?> deploymentTarget) { - super(deployableComponent, deploymentTarget); - } - - /** {@inheritDoc} */ - @Override - public AbstractTaskMappingEntry clone() { - return new AbstractTaskMappingEntry(getDeployableComponent(), getTarget()); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return getTarget().getName(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/constraint/InternalReplicationConstraint.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/constraint/InternalReplicationConstraint.java deleted file mode 100644 index 493d413061c5aa9f4eb1b86a440f1b486522abab..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/constraint/InternalReplicationConstraint.java +++ /dev/null @@ -1,182 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.constraint; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IRequestAdapter; -import org.fortiss.af3.exploration.dsl_v2.model.expression.IExpression; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationTarget; - -/** - * DSE-internal constraint to define the bounds for the number of replica of an - * {@link IDeployableComponentAdapter}. - * NOTE: This constraint is only a temporary solution until a solution is found which allows to use - * the EMM for this task. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: B0DECAF3E8F577A789C92EE5B5730E57 - */ -@SuppressWarnings("javadoc") -public class InternalReplicationConstraint extends EObjectImpl implements - ExplorationConstraint<Boolean> { - - private int id = 0; - - private String name = ""; - - private String comment = ""; - - private boolean isSoft = false; - - private IRequestAdapter<?> replicationObject; - - private int min = 1; - - private int max = 1; - - public InternalReplicationConstraint(IRequestAdapter<?> replicationObject, int min, int max) { - this.replicationObject = replicationObject; - this.min = min; - this.max = max; - } - - public InternalReplicationConstraint(InternalReplicationConstraint other) { - this.replicationObject = other.replicationObject; - this.min = other.min; - this.max = other.max; - this.name = other.name; - this.comment = other.comment; - this.isSoft = other.isSoft; - } - - /** {@inheritDoc} */ - @Override - public String getComment() { - return comment; - } - - /** {@inheritDoc} */ - @Override - public void setComment(String value) { - comment = value; - } - - /** {@inheritDoc} */ - @Override - public String getName() { - return name; - } - - /** {@inheritDoc} */ - @Override - public void setName(String value) { - name = value; - } - - /** {@inheritDoc} */ - @Override - public int getId() { - return id; - } - - /** {@inheritDoc} */ - @Override - public void setId(int value) { - id = value; - } - - /** {@inheritDoc} */ - @Override - public boolean isIsSoft() { - return isSoft; - } - - /** {@inheritDoc} */ - @Override - public void setIsSoft(boolean value) { - isSoft = value; - } - - /** {@inheritDoc} */ - @Override - public boolean isImplicit() { - return true; - } - - /** {@inheritDoc} */ - @Override - public void setImplicit(boolean value) { - // NOP. - } - - public int getMin() { - return min; - } - - public void setMin(int value) { - min = value; - } - - public int getMax() { - return max; - } - - public void setMax(int value) { - max = value; - } - - public IRequestAdapter<?> getReplicationObject() { - return replicationObject; - } - - public void setReplicationObject(IRequestAdapter<?> value) { - replicationObject = value; - } - - /** {@inheritDoc} */ - @Override - public Object clone() { - return new InternalReplicationConstraint(this); - } - - /** {@inheritDoc} */ - @Override - public IExpression getExpression() { - // TODO Auto-generated method stub - return null; - } - - /** {@inheritDoc} */ - @Override - public void setExpression(IExpression value) { - // TODO Auto-generated method stub - - } - - /** {@inheritDoc} */ - @Override - public EList<ExplorationTarget<Boolean>> getContainedTargets() { - // TODO Auto-generated method stub - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/constraint/InternalSeparationConstraint.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/constraint/InternalSeparationConstraint.java deleted file mode 100644 index 72d79af1885bbdf2091d9fd0748a90ac8af76cf2..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/constraint/InternalSeparationConstraint.java +++ /dev/null @@ -1,175 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.constraint; - -import java.util.Collection; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IRequestAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.dsl_v2.model.expression.IExpression; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.platform.model.IPlatformResource; - -/** - * DSE-internal constraint to define which {@link IMappingEntry}s of a - * {@link IDeployableComponentAdapter} needs to be spatially separated. - * NOTE: This constraint is only a temporary solution until a solution is found which allows to use - * the EMM for this task. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: B3F05A763AD1A0D86111248365E5B88E - */ -@SuppressWarnings("javadoc") -public class InternalSeparationConstraint extends EObjectImpl implements - ExplorationConstraint<Boolean>, Cloneable { - - private int id = 0; - - private String name = ""; - - private String comment = ""; - - private boolean isSoft = false; - - private Collection<? extends IRequestAdapter<?>> requesterSet; - - private Class<? extends IPlatformResource> separationLayer; - - public InternalSeparationConstraint(Collection<? extends IRequestAdapter<?>> requesterSet, - Class<? extends IPlatformResource> separationLayer) { - this.requesterSet = requesterSet; - this.separationLayer = separationLayer; - } - - public InternalSeparationConstraint(InternalSeparationConstraint other) { - this.requesterSet = other.requesterSet; - this.separationLayer = other.separationLayer; - this.name = other.name; - this.comment = other.comment; - this.isSoft = other.isSoft; - } - - /** {@inheritDoc} */ - @Override - public String getComment() { - return comment; - } - - /** {@inheritDoc} */ - @Override - public void setComment(String value) { - comment = value; - } - - /** {@inheritDoc} */ - @Override - public String getName() { - return name; - } - - /** {@inheritDoc} */ - @Override - public void setName(String value) { - name = value; - } - - /** {@inheritDoc} */ - @Override - public int getId() { - return id; - } - - /** {@inheritDoc} */ - @Override - public void setId(int value) { - id = value; - } - - /** {@inheritDoc} */ - @Override - public boolean isIsSoft() { - return isSoft; - } - - /** {@inheritDoc} */ - @Override - public void setIsSoft(boolean value) { - isSoft = value; - } - - /** {@inheritDoc} */ - @Override - public boolean isImplicit() { - return true; - } - - /** {@inheritDoc} */ - @Override - public void setImplicit(boolean value) { - // NOP. - } - - public Collection<? extends IRequestAdapter<?>> getRequesterSet() { - return requesterSet; - } - - public void setRequesterSet(Collection<? extends IRequestAdapter<?>> value) { - requesterSet = value; - } - - public Class<? extends IPlatformResource> getSeparationLayer() { - return separationLayer; - } - - public void setSeparationLayer(Class<? extends IPlatformResource> value) { - separationLayer = value; - } - - /** {@inheritDoc} */ - @Override - public Object clone() { - return new InternalSeparationConstraint(this); - } - - /** {@inheritDoc} */ - @Override - public IExpression getExpression() { - // TODO Auto-generated method stub - return null; - } - - /** {@inheritDoc} */ - @Override - public void setExpression(IExpression value) { - // TODO Auto-generated method stub - - } - - /** {@inheritDoc} */ - @Override - public EList<ExplorationTarget<Boolean>> getContainedTargets() { - // TODO Auto-generated method stub - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/FailSilentTaskMappingEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/FailSilentTaskMappingEncoding.java deleted file mode 100644 index 4dd45c9837e34ff73c7c3fa07c82b7626f185429..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/FailSilentTaskMappingEncoding.java +++ /dev/null @@ -1,138 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FailSilentTaskMappingEncoding.java 3480 2016-09-09 13:31:04Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ - -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.moea.model.DseSpecification; - -/** - * Problem encoding consisting of redundant {@link TaskMappingEntry}s with fail-silent assumption. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3480 $ - * @ConQAT.Rating RED Hash: 71B4DFB05BA4E173B987F2A8D530F5F6 - */ -public class FailSilentTaskMappingEncoding extends - InstantiatedTaskMappingEncoding<FailSilentTaskMappingEntry> { - - /** - * Constructor that is initialized with a reference to the DSE specification and the input - * system model. - */ - FailSilentTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - AbstractTaskGraphEncoding<?, ?> tgEncoding) { - super(expSpec, systemModelAdapter, tgEncoding); - } - - // TODO: Check whether the two constructors below are actually needed. - /** - * Constructor that optionally initializes the encoding to a random encoding - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - public FailSilentTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - AbstractTaskGraphEncoding<?, ?> tgEncoding, boolean initialize) - throws ExplorationException { - super(expSpec, systemModelAdapter, tgEncoding, initialize); - } - - /** - * Constructor that optionally initializes the encoding to a random encoding - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - public FailSilentTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, boolean initialize) - throws ExplorationException { - super(expSpec, systemModelAdapter, initialize); - } - - /** - * Constructor which derives the resulting {@link FailSilentTaskMappingEncoding} from the given - * {@link AbstractTaskMappingEncoding}. - */ - public FailSilentTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - AbstractTaskGraphEncoding<?, ?> tgEncoding, AbstractTaskMappingEncoding abstractEncoding) { - super(expSpec, systemModelAdapter, tgEncoding, abstractEncoding); - } - - /** {@inheritDoc} */ - @Override - public FailSilentTaskMappingEntry createEntry( - IDeployableComponentAdapter<?> deployableComponent, - IExecutionUnitAdapter<?> deploymentTarget) { - // Request not needed to construct a {@link FailSilentTaskMappingEncoding} - if(deploymentTarget == null) { - return null; - } - - return new FailSilentTaskMappingEntry(deployableComponent, deploymentTarget); - } - - /** {@inheritDoc} */ - @Override - public <S extends TaskMappingEntry> FailSilentTaskMappingEntry createEntry(S mapping) { - if(mapping instanceof AbstractTaskMappingEntry) { - return new FailSilentTaskMappingEntry((AbstractTaskMappingEntry)mapping); - } - return super.createEntry(mapping); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public FailSilentTaskMappingEncoding newInstance() { - try { - return new FailSilentTaskMappingEncoding(expSpec, systemModelAdapter, true); - } catch(ExplorationException e) { - // Opt4J does not allow to throw Exceptions here. - throw new RuntimeException(e); - } - } - - /** {@inheritDoc} */ - @Override - public Object clone() { - // TODO: Here, we should maintain the mapping. - FailSilentTaskMappingEncoding clonedEncoding; - try { - clonedEncoding = new FailSilentTaskMappingEncoding(expSpec, systemModelAdapter, false); - } catch(ExplorationException e) { - // Opt4J does not allow to throw Exceptions here. - throw new RuntimeException(e); - } - return clonedEncoding; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/FailSilentTaskMappingEntry.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/FailSilentTaskMappingEntry.java deleted file mode 100644 index 107ec320bf399a665d8cd852bc32e2ab8ce0fcc1..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/FailSilentTaskMappingEntry.java +++ /dev/null @@ -1,63 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FailSilentTaskMappingEntry.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; - -/** - * {@link TaskMappingEntry} used for encoding redundant {@link FailSilentTaskMappingEncoding}s (with - * fail-silent assumption) - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 0846ADC9D6ECEB2917FAD88D690AE7F9 - */ -public class FailSilentTaskMappingEntry extends InstantiatedTaskMappingEntry implements Cloneable { - - /** Constructs a mapping entry the represents the mapping to a given deployment target. */ - FailSilentTaskMappingEntry(IDeployableComponentAdapter<?> deployableComponent, - IExecutionUnitAdapter<?> deploymentTarget) { - super(deployableComponent, deploymentTarget); - } - - /** - * Constructor that generates a {@link FailSilentTaskMappingEntry} of a - * {@link FailSilentTaskMappingEncoding} for each {@link AbstractTaskMappingEntry} of a - * {@link AbstractTaskMappingEncoding}. - */ - public FailSilentTaskMappingEntry(AbstractTaskMappingEntry abstractEntry) { - super(abstractEntry); - } - - /** {@inheritDoc} */ - @Override - public FailSilentTaskMappingEntry clone() { - return new FailSilentTaskMappingEntry(getDeployableComponent(), getTarget()); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return getTarget().getName(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/FaultDetectionVotingTaskMappingEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/FaultDetectionVotingTaskMappingEncoding.java deleted file mode 100644 index 078276d9860240db47712b23f47129460d7ee59b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/FaultDetectionVotingTaskMappingEncoding.java +++ /dev/null @@ -1,144 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FaultDetectionVotingTaskMappingEncoding.java 3480 2016-09-09 13:31:04Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.model.ExplorationSpecification; - -/** - * Problem encoding of redundant {@link TaskMappingEncoding}s with fault detection and voting. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3480 $ - * @ConQAT.Rating RED Hash: FFA7C644FDD1EC609A8E735B1D2AA403 - */ -public class FaultDetectionVotingTaskMappingEncoding extends - InstantiatedTaskMappingEncoding<FaultDetectionVotingTaskMappingEntry> implements Cloneable { - - /** - * Constructor that is initialized with a reference to the DSE specification and the input - * system model. - */ - FaultDetectionVotingTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - AbstractTaskGraphEncoding<?, ?> tgEncoding) { - super(expSpec, systemModelAdapter, tgEncoding); - } - - // TODO: Check whether the two constructors below are actually needed. - /** - * Constructor that optionally initializes the encoding to a random encoding - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - public FaultDetectionVotingTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - AbstractTaskGraphEncoding<?, ?> tgEncoding, boolean initialize) - throws ExplorationException { - super(expSpec, systemModelAdapter, tgEncoding, initialize); - assert (false) : "Never here any more."; - } - - /** - * Constructor that optionally initializes the encoding to a random encoding - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - public FaultDetectionVotingTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, boolean initialize) - throws ExplorationException { - super(expSpec, systemModelAdapter, initialize); - assert (false) : "Never here any more."; - } - - /** - * Constructor which derives the resulting {@link FaultDetectionVotingTaskMappingEncoding} from - * the given {@link AbstractTaskMappingEncoding}. - */ - public FaultDetectionVotingTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - AbstractTaskGraphEncoding<?, ?> tgEncoding, AbstractTaskMappingEncoding abstractEncoding) { - super(expSpec, systemModelAdapter, tgEncoding, abstractEncoding); - } - - /** {@inheritDoc} */ - @Override - public FaultDetectionVotingTaskMappingEntry createEntry( - IDeployableComponentAdapter<?> deployableComponent, - IExecutionUnitAdapter<?> deploymentTarget) { - if(deployableComponent == null || deploymentTarget == null) { - return null; - } - - return new FaultDetectionVotingTaskMappingEntry(deployableComponent.clone(), - deploymentTarget, tgEncoding.getTaskGraphOf(deployableComponent) - .getRandomFaultDetectorId(deployableComponent)); - } - - /** {@inheritDoc} */ - @Override - public <S extends TaskMappingEntry> FaultDetectionVotingTaskMappingEntry createEntry(S mapping) { - if(mapping instanceof AbstractTaskMappingEntry) { - // TODO: Do not use 0, magic constant. - return new FaultDetectionVotingTaskMappingEntry((AbstractTaskMappingEntry)mapping, 0); - } - return super.createEntry(mapping); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public FaultDetectionVotingTaskMappingEncoding newInstance() { - try { - return new FaultDetectionVotingTaskMappingEncoding(expSpec, systemModelAdapter, true); - } catch(ExplorationException e) { - // Opt4J does not allow to throw Exceptions here. - throw new RuntimeException(e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public Object clone() { - // TODO: Here, we should maintain the mapping. - FaultDetectionVotingTaskMappingEncoding clonedEncoding = null; - try { - clonedEncoding = - new FaultDetectionVotingTaskMappingEncoding(expSpec, systemModelAdapter, false); - } catch(ExplorationException e) { - // Opt4J does not allow to throw Exceptions here. - throw new RuntimeException(e); - } - return clonedEncoding; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/FaultDetectionVotingTaskMappingEntry.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/FaultDetectionVotingTaskMappingEntry.java deleted file mode 100644 index 9438a4f48f3a083492d7c1d522b3f8ac68e325ae..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/FaultDetectionVotingTaskMappingEntry.java +++ /dev/null @@ -1,84 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FaultDetectionVotingTaskMappingEntry.java 2419 2016-03-04 18:05:52Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; - -/** - * {@link TaskMappingEntry} used for encoding redundant - * {@link FaultDetectionVotingTaskMappingEncoding}s what consider fault detection and voting. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 2419 $ - * @ConQAT.Rating RED Hash: 5D45A4A9867B9CB8400DCC920B17A135 - */ -public class FaultDetectionVotingTaskMappingEntry extends InstantiatedTaskMappingEntry implements - Cloneable { - /** Fault detector ID */ - // TODO: Investigate use of IDs in reliability analysis. - private int faultDetectorID; - - /** - * Constructs a mapping entry the represents the mapping to a given deployment target and which - * specifies the ID of the used fault detector - */ - public FaultDetectionVotingTaskMappingEntry(IDeployableComponentAdapter<?> deployableComponent, - IExecutionUnitAdapter<?> target, int i) { - super(deployableComponent, target); - faultDetectorID = i; - } - - /** - * Constructor that generates a {@link FailSilentTaskMappingEntry} of a - * {@link FailSilentTaskMappingEncoding} for each {@link AbstractTaskMappingEntry} of a - * {@link AbstractTaskMappingEncoding}. - */ - public FaultDetectionVotingTaskMappingEntry(AbstractTaskMappingEntry abstractEntry, int i) { - super(abstractEntry); - faultDetectorID = i; - } - - /** - * Returns the ID of the used fault detector. - */ - public int getFaultDetectorID() { - return faultDetectorID; - } - - /** {@inheritDoc} */ - @Override - public FaultDetectionVotingTaskMappingEntry clone() { - return new FaultDetectionVotingTaskMappingEntry(getDeployableComponent(), getTarget(), - faultDetectorID); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - String rval = getTarget().getName(); - - rval = rval.concat("(" + faultDetectorID + ")"); - - return rval; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/InstantiatedTaskMappingEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/InstantiatedTaskMappingEncoding.java deleted file mode 100644 index 23ce0b1cf8bf3435acbfa576a88d48df332b7f71..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/InstantiatedTaskMappingEncoding.java +++ /dev/null @@ -1,153 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: InstantiatedTaskMappingEncoding.java 3885 2016-11-11 09:41:01Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.opt4j.core.Genotype; - -/** - * {@link Genotype} encoding a {@link TaskMappingEncoding} whose - * {@link InstantiatedTaskMappingEntry}s - * are instantiated during the construction. Therefore, it requires an - * {@link AbstractTaskMappingEncoding}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3885 $ - * @ConQAT.Rating RED Hash: E58523ED4F83F1D082C0A6D327A72F34 - */ -public abstract class InstantiatedTaskMappingEncoding<T extends InstantiatedTaskMappingEntry> - extends TaskMappingEncoding<T> { - - /** - * Constructor that is initialized with a reference to the DSE specification and the input - * system model. - */ - protected InstantiatedTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - AbstractTaskGraphEncoding<?, ?> tgEncoding) { - super(expSpec, systemModelAdapter, tgEncoding); - } - - // TODO: Check whether the two constructors below are actually needed. - /** - * Constructor that optionally initializes the encoding to a random encoding - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - public InstantiatedTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - AbstractTaskGraphEncoding<?, ?> tgEncoding, boolean initialize) - throws ExplorationException { - super(expSpec, systemModelAdapter, tgEncoding, initialize); - } - - /** - * Constructor that optionally initializes the encoding to a random encoding - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - public InstantiatedTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, boolean initialize) - throws ExplorationException { - super(expSpec, systemModelAdapter, initialize); - } - - /** - * Constructor which derives the resulting {@link InstantiatedTaskMappingEncoding} from the - * given {@link AbstractTaskMappingEncoding}. - */ - public InstantiatedTaskMappingEncoding(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - AbstractTaskGraphEncoding<?, ?> tgEncoding, AbstractTaskMappingEncoding abstractEncoding) { - super(expSpec, systemModelAdapter, tgEncoding); - this.constraintMap = abstractEncoding.copyConstraintMap(null); - instantiateAbstractEntries(abstractEncoding); - } - - /** - * Instantiates the {@link IDeployableComponentAdapter}s of the given - * {@link AbstractTaskMappingEncoding} which must be replaced by a "concrete" - * {@link IDeployableComponentAdapter} representing one possible implementation of the - * {@link IDeployableComponentAdapter} that shall be replaced. (ref. Diversity) - */ - public void instantiateAbstractEntries(AbstractTaskMappingEncoding abstractEncoding) { - for(AbstractTaskMappingEntry abstractEntry : abstractEncoding.getMappingEntries()) { - T instantiatedEntry = createEntry(abstractEntry); - instantiatedEntry.addAssociatedElement(abstractEntry); - abstractEntry.addAssociatedElement(instantiatedEntry); - addAllocation(instantiatedEntry); - } - } - - /** {@inheritDoc} */ - @Override - public Collection<IExecutionUnitAdapter<?>> getAllowedAllocations( - IDeployableComponentAdapter<?> deployableComponent) { - if(deployableComponent.isInstantiation()) { - deployableComponent = deployableComponent.getReplacedComponent(); - } - return super.getAllowedAllocations(deployableComponent); - } - - /** {@inheritDoc} */ - @Override - public Collection<IExecutionUnitAdapter<?>> getDisAllowedAllocations( - IDeployableComponentAdapter<?> deployableComponent) { - if(deployableComponent.isInstantiation()) { - deployableComponent = deployableComponent.getReplacedComponent(); - } - return super.getDisAllowedAllocations(deployableComponent); - } - - /** {@inheritDoc} */ - @Override - public Object clone() { - throw new UnsupportedOperationException( - "The clone operation MUST be implemented in the concrete classes of the InstantiatedTaskMappingEncoding. Otherwise, the algorithm does not operate as expected!"); - } - - /** {@inheritDoc} */ - @Override - public Class<? extends ComposableGenotype> getGTypeToRegister() { - return InstantiatedTaskMappingEncoding.class; - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Class<? extends ComposablePhenotype<?>> getPTypeToRegister() { - return (Class<? extends ComposablePhenotype<?>>)InstantiatedTaskMappingEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/InstantiatedTaskMappingEntry.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/InstantiatedTaskMappingEntry.java deleted file mode 100644 index 57b4565f766e548f7b6b79cc11577bab24db883b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/encoding/taskmapping/instantiatedmapping/InstantiatedTaskMappingEntry.java +++ /dev/null @@ -1,92 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: InstantiatedTaskMappingEntry.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping; - -import java.util.ArrayList; -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.random.RandomExploration; - -/** - * {@link TaskMappingEntry} whose referenced {@link IDeployableComponentAdapter} only refers to - * already instantiated {@link IDeployableComponentAdapter}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: CBD09B1B0B5F0D70EDEAEDFF0136C555 - */ -public abstract class InstantiatedTaskMappingEntry extends TaskMappingEntry implements Cloneable { - - /** Constructs a mapping entry the represents the mapping to a given deployment target. */ - public InstantiatedTaskMappingEntry(IDeployableComponentAdapter<?> deployableComponent, - IExecutionUnitAdapter<?> deploymentTarget) { - super(deployableComponent, deploymentTarget); - } - - /** - * Constructor that generates a {@link InstantiatedTaskMappingEntry} of a - * {@link InstantiatedTaskMappingEncoding} for each {@link AbstractTaskMappingEntry} of a - * {@link AbstractTaskMappingEncoding}. Thereby, {@link AbstractTaskMappingEntry}s requiring - * instantiation will be replaced by a matching, randomly picked - * {@link IDeployableComponentAdapter}. - */ - public InstantiatedTaskMappingEntry(AbstractTaskMappingEntry abstractEntry) { - this(abstractEntry.getDeployableComponent(), abstractEntry.getTarget()); - addAssociatedElement(abstractEntry); - abstractEntry.addAssociatedElement(this); - if(deploymentSource.isInstantiationRequired()) { - IDeployableComponentAdapter<?> abstractComponent = deploymentSource; - deploymentSource = pickRandomReplacementComponent(deploymentSource); - deploymentSource.setReplacedComponent(abstractComponent); - } - } - - /** - * Iff the given {@link IDeployableComponentAdapter} must be instantiated/replaced by a - * "concrete" {@link IDeployableComponentAdapter}, this method returns a randomly picked and - * appropriate {@link IDeployableComponentAdapter}. The returned - * {@link IDeployableComponentAdapter} is picked from the set of replacement - * {@link IDeployableComponentAdapter}s of the given input {@link IDeployableComponentAdapter}. - * <p> - * {@code null} is returned if the given {@link IDeployableComponentAdapter} does not require - * instantiation or no "replacement components were defined. - */ - public IDeployableComponentAdapter<?> pickRandomReplacementComponent( - IDeployableComponentAdapter<?> abstractComponent) { - if(!deploymentSource.isInstantiationRequired()) { - return null; - } - - // TODO: parameterize the collection: cast to raw was used, but is no longer applicable, - // since we have an EList here now. - Collection<IDeployableComponentAdapter<?>> replacementComponents = - new ArrayList<>(abstractComponent.getReplacementComponents()); - RandomExploration randomGenerator = RandomExploration.getInstance(); - int replacementBound = replacementComponents.size() - 1; - int replacementIdx = - replacementBound > 0 ? randomGenerator.nextInt(replacementComponents.size()) : 0; - return ((IDeployableComponentAdapter<?>)replacementComponents.toArray()[replacementIdx]) - .clone(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/create/ComposableCreator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/create/ComposableCreator.java deleted file mode 100644 index 14c0efd219bbe9d0efcafde747dbfa738d8077f9..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/create/ComposableCreator.java +++ /dev/null @@ -1,124 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComposableCreator.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.create; - -import java.util.List; -import java.util.Set; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.FlatGenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.opt4j.core.Genotype; -import org.opt4j.core.genotype.CompositeGenotype; -import org.opt4j.core.problem.Creator; -import org.opt4j.core.problem.Decoder; - -/** - * Interface for creating {@link ComposableGenotype}s, i.e. {@link Genotype}s that compose a - * {@link CompositeGenotype}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: 0993CB328A85F9FA4E063798EF9EB0D1 - */ -public interface ComposableCreator<G extends ComposableGenotype> { - - /** - * Creates a {@link ComposableGenotype}. This method is called by the parent - * {@link CompositeGenotype}. - * - * @param createdGenotypes - * Map that lists already created {@link Genotype}s by their Type.. - * @return The {@link ComposableGenotype}. May be a {@link CompositeGenotype} itself. - * @throws ExplorationException - */ - G createComposable(FlatGenotypeMap createdGenotypes, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) throws ExplorationException; - - /** - * Registers {@link Decoder}s that decode the {@link Genotype} created by {@code this} - * {@link Creator}. It is absolutely required to launch these {@link Decoder}s after the - * creation such that the generated {@link Phenotype}s are available for other {@link Creator}s - * that require these {@link Phenotype}s and which are launched subsequently to {@code this} - * {@link Creator}. - * - * @param decoders - * List of {@link Decoder}s that are executed in the order of the List. - */ - void - registerAssocDecoders( - List<ComposableDecoder<G, ? extends ComposablePhenotype<G>>> decoders); - - /** - * Registers {@link Decoder}s that decode the {@link Genotype} created by {@code this} - * {@link Creator}. It is absolutely required to launch these {@link Decoder}s after the - * creation such that the generated {@link Phenotype}s are available for other {@link Creator}s - * that require these {@link Phenotype}s and which are launched subsequently to {@code this} - * {@link Creator}. - * - * @param decoders - * {@link Decoder}s that are executed in the order of the parameter list. - */ - void registerAssocDecoders(@SuppressWarnings("unchecked") ComposableDecoder<G, ?>... decoders); - - /** - * Decodes the created {@link Phenotype} using the set of registered {@link Decoder}s. The - * generated {@link Phenotype}s are returned in the form of {@link FlatPhenotypeMap}. The given - * {@link FlatPhenotypeMap} encodes {@link Phenotype}s that were already decoded earlier in the - * exploration process. - * - * @param genotype - * Created {@link Genotype} that shall be decoded. - * @param decodedPhenotypes - * {@link FlatPhenotypeMap} of already decoded {@link Phenotype}s. - * @param createdGenotypeTypeSet - * TODO - * @return {@link FlatPhenotypeMap} of decoded {@link Phenotype} by the registered - * {@link Decoder}s. - * @throws DecodingException - */ - <P extends ComposablePhenotype<G>> FlatPhenotypeMap<Phenotype> decodeCreatedGenotype( - G genotype, FlatPhenotypeMap<Phenotype> decodedPhenotypes, - Set<Class<? extends Genotype>> createdGenotypeTypeSet) throws DecodingException; - - /** - * Launches an identity decoder if there is any registered for {@code this} - * {@link ComposableCreator}. An identity decoder is a decoder that injects a hybrid genotype in - * the {@link FlatPhenotypeMap} such that it can be accessed by other decoders. - * - * @param genotype - * The created {@link Genotype}. - * @param decodedPhenotypes - * Previously decoded {@link Phenotype}s. - * @return Modified {@code decodedPhenotype} map. - * @throws DecodingException - * if the identity decoder fails. - */ - <P extends ComposablePhenotype<G>> FlatPhenotypeMap<Phenotype> identityDecodeCreatedGenotype( - G genotype, FlatPhenotypeMap<Phenotype> decodedPhenotypes) throws DecodingException; - - /** Returns the type of the created {@link IExplorationEncoding} / {@link Genotype}. */ - Class<? extends IExplorationEncoding> getCreatedEncoding(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/create/ComposableCreatorBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/create/ComposableCreatorBase.java deleted file mode 100644 index 3fc381bfe5b7779312751f1617e962dd763c4d72..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/create/ComposableCreatorBase.java +++ /dev/null @@ -1,213 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComposableCreatorBase.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.create; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph.DecoderDependencyGraph; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.decode.ConstraintGenerationDecoder; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.util.ExplorationAlgDebugUtils; -import org.opt4j.core.Genotype; -import org.opt4j.core.problem.Decoder; - -/** - * Base class for {@link ComposableCreator}s. It handles the decoding of the created - * {@link Genotype} by launching the registered {@link Decoder}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: 10ADB9907718BFF00670CC67B888C643 - */ -public abstract class ComposableCreatorBase<G extends ComposableGenotype> implements - ComposableCreator<G> { - - /** References the input models */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** References the {@link ComposableDecoder}s that decode the created {@link Genotype}. */ - private List<ComposableDecoder<G, ? extends ComposablePhenotype<G>>> subDecoders = - new ArrayList<>(); - - /** - * Captures which {@link ComposableDecoder}s were already executed to avoid multiple executions - * of already executed decoders in the creation phase. - */ - private Map<ComposableDecoder<G, ? extends ComposablePhenotype<G>>, Boolean> decoderExecuted = - new HashMap<>(); - - /** - * References the {@link DecoderDependencyGraph} which defines execution orders and which - * {@link Phenotype}s are needed within the DSE. - */ - DecoderDependencyGraph depGraph; - - /** Default constructor that requires a representation of the input models. */ - public ComposableCreatorBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph depGraph) { - this.systemModelAdapter = systemModelAdapter; - this.depGraph = depGraph; - } - - /** {@inheritDoc} */ - @Override - public void registerAssocDecoders( - List<ComposableDecoder<G, ? extends ComposablePhenotype<G>>> decoders) { - subDecoders.addAll(decoders); - decoders.forEach(d -> decoderExecuted.put(d, false)); - } - - /** {@inheritDoc} */ - @SafeVarargs - @Override - final public void registerAssocDecoders(ComposableDecoder<G, ?>... decoders) { - for(ComposableDecoder<G, ?> dec : decoders) { - @SuppressWarnings("unchecked") ComposableDecoder<G, ? extends ComposablePhenotype<G>> castedDec = - (ComposableDecoder<G, ? extends ComposablePhenotype<G>>)dec; - subDecoders.add(castedDec); - decoderExecuted.put(castedDec, false); - } - } - - /** - * {@inheritDoc} - * - * @throws DecodingException - */ - @Override - public <P extends ComposablePhenotype<G>> FlatPhenotypeMap<Phenotype> decodeCreatedGenotype( - G genotype, FlatPhenotypeMap<Phenotype> decodedPhenotypes, - Set<Class<? extends Genotype>> createdGenotypeTypeSet) throws DecodingException { - FlatPhenotypeMap<Phenotype> phenotypes = - new FlatPhenotypeMap<Phenotype>(systemModelAdapter); - Collection<Class<? extends IExplorationEncoding>> reqPhenotypeTypes = - depGraph.getAllRequiredTypes(); - FlatPhenotypeMap<Phenotype> intermediatePhenos = - new FlatPhenotypeMap<Phenotype>(systemModelAdapter); - intermediatePhenos.addAll(decodedPhenotypes); - - @SuppressWarnings("unchecked") Optional<? extends ComposableDecoder<G, P>> idDecoder = - (Optional<? extends ComposableDecoder<G, P>>)subDecoders - .stream() - .filter(d -> Arrays.asList(genotype.getClass()).containsAll( - d.getRequiredTypes())).findAny(); - - for(ComposableDecoder<G, ? extends ComposablePhenotype<G>> decoder : subDecoders) { - if(!isHybridPhenoRequiredAndCreated(createdGenotypeTypeSet, decoder.getRequiredTypes()) || - Genotype.class.isAssignableFrom(decoder.getOutputType())) { - continue; - } - - @SuppressWarnings("unchecked") ComposableDecoder<G, P> castedDecoder = - (ComposableDecoder<G, P>)decoder; - @SuppressWarnings("unchecked") Class<P> decPhenotypeType = - (Class<P>)decoder.getOutputType(); - // TODO: Here, the check with the Required Phenotypes should be removed, and replaced - // with a check such that the required pheno/genotypes are available at this point. - if(!decoderExecuted.get(decoder) && decoder != idDecoder.orElse(null) && - reqPhenotypeTypes.contains(decPhenotypeType) && - intermediatePhenos.containsAll(castedDecoder.getRequiredTypes())) { - decoderExecuted.put(decoder, true); - - @SuppressWarnings("unchecked") P decPhenotype = - (P)decoder.decodeComposable(genotype, intermediatePhenos); - // Null indicates a decoding error here. - if(decPhenotype == null && !(decoder instanceof ConstraintGenerationDecoder)) { - throw new DecodingException(genotype, decoder); - } - - if(decPhenotype != null) { - if(decPhenotype instanceof TaskMappingEncoding && - !ExplorationAlgDebugUtils - .checkTaskMappingForSFConsistency((TaskMappingEncoding<?>)decPhenotype)) { - // TODO: Remove this debug code. Is an Exception required instead? - System.out.println("Error."); - } - - phenotypes.putEncoding(decPhenotype.getPTypeToRegister(), decPhenotype); - intermediatePhenos.putEncoding(decPhenotype.getPTypeToRegister(), decPhenotype); - } - } - } - return phenotypes; - } - - /** - * Checks whether the collection of required input types contains hybrid {@link Genotype}s and - * if they were already created. - */ - private boolean isHybridPhenoRequiredAndCreated( - Set<Class<? extends Genotype>> createdGenotypeTypeSet, Collection<Class<?>> reqTypes) { - for(Class<?> reqType : reqTypes) { - if(Genotype.class.isAssignableFrom(reqType) && - !createdGenotypeTypeSet.contains(reqType)) { - return false; - } - } - return true; - } - - /** {@inheritDoc} */ - @Override - public - <P extends ComposablePhenotype<G>> - FlatPhenotypeMap<Phenotype> - identityDecodeCreatedGenotype(G genotype, FlatPhenotypeMap<Phenotype> decodedPhenotypes) - throws DecodingException { - FlatPhenotypeMap<Phenotype> phenotypes = - new FlatPhenotypeMap<Phenotype>(systemModelAdapter); - FlatPhenotypeMap<Phenotype> intermediatePhenos = - new FlatPhenotypeMap<Phenotype>(systemModelAdapter); - intermediatePhenos.addAll(decodedPhenotypes); - - // If an identity decoder is present, execute it before any other decoder to ensure all - // required data is available to the decoders. - @SuppressWarnings("unchecked") Optional<? extends ComposableDecoder<G, P>> idDecoder = - (Optional<? extends ComposableDecoder<G, P>>)subDecoders - .stream() - .filter(d -> Arrays.asList(genotype.getClass()).containsAll( - d.getRequiredTypes())).findAny(); - if(idDecoder.isPresent()) { - P decPhenotype = idDecoder.get().decodeComposable(genotype, intermediatePhenos); - if(decPhenotype == null) { - throw new DecodingException(genotype, idDecoder.get()); - } - @SuppressWarnings("unchecked") Class<P> decType = (Class<P>)decPhenotype.getClass(); - phenotypes.putEncoding(decType, decPhenotype); - intermediatePhenos.putEncoding(decType, decPhenotype); - } - - return intermediatePhenos; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/create/CompositeCreator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/create/CompositeCreator.java deleted file mode 100644 index 6e0edd8bae5db83252242663dfcb2f0eb7bf0c84..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/create/CompositeCreator.java +++ /dev/null @@ -1,55 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CompositeCreator.java 3033 2016-06-17 11:51:48Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.create; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.opt4j.core.genotype.CompositeGenotype; -import org.opt4j.core.problem.Creator; - -/** - * {@link Creator} for {@link CompositeGenotype}s. The creation of {@link ComposableGenotype}s - * comprising the {@link CompositeGenotype} must be handled by implementing classes. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3033 $ - * @ConQAT.Rating RED Hash: 312EB4EED46ACC4AA728A8567C0AF7D2 - */ -public interface CompositeCreator<G extends CompositeGenotype<Class<? extends ComposableGenotype>, ? extends ComposableGenotype>> - extends Creator<G> { - - /** Creates the {@link ComposableGenotype}. */ - G createComposite(); - - /** - * Calls the {@code create()} method of {@link ComposableGenotype}s registered at this - * {@link CompositeCreator}. - * - * @throws DecodingException - */ - <N extends ComposableGenotype, P extends ComposablePhenotype<N>> void createSubGenotypes( - G compositeGenotype) throws DecodingException; - - /** - * Registers a {@link Creator} of a {@link ComposableGenotype} with this - * {@link CompositeCreator}. - */ - <C extends ComposableGenotype> void registerSubCreator(ComposableCreator<?> subCreator); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/create/CompositeCreatorBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/create/CompositeCreatorBase.java deleted file mode 100644 index b5af5e34317aea485ceb4bc5508b0f28108f0851..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/create/CompositeCreatorBase.java +++ /dev/null @@ -1,143 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CompositeCreatorBase.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.create; - -import java.util.LinkedList; -import java.util.List; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.FlatGenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.opt4j.core.genotype.CompositeGenotype; -import org.opt4j.core.problem.Creator; - -import com.google.inject.Inject; - -/** - * Base class of the {@link Creator} for {@link CompositeGenotype}s. It handles the creation of the - * {@link ComposableGenotype}s comprising this {@link CompositeGenotype}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: 4C185ED1B08430018EAEEC420BDA566C - */ -public abstract class CompositeCreatorBase<G extends CompositeGenotype<Class<? extends ComposableGenotype>, ComposableGenotype>> - implements CompositeCreator<G> { - /** - * Contains the {@link Creator}s for the {@link ComposableGenotype}s that comprise the - * {@link CompositeGenotype} created by this {@link CompositeCreator}. - */ - private List<ComposableCreator<? extends ComposableGenotype>> subCreators = new LinkedList<>(); - - /** Representation of input system. */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** - * Default Constructor that requires a {@link SystemModelAdapter} such that {@link Creator}s are - * aware of the input models. - */ - @Inject - public CompositeCreatorBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } - - /** {@inheritDoc} */ - @Override - public G create() { - G compositeGenoype = createComposite(); - try { - createSubGenotypes(compositeGenoype); - } catch(DecodingException e) { - // Comply with the Opt4J framework: Wrap into a RuntimeException. - throw new RuntimeException(e); - } - - return compositeGenoype; - } - - /** - * {@inheritDoc} - * - * @throws DecodingException - */ - // TODO: Also requires the dependency graph? - @Override - public <N extends ComposableGenotype, P extends ComposablePhenotype<N>> void - createSubGenotypes(G compositeGenotype) throws DecodingException { - FlatGenotypeMap createdGenotypes = new FlatGenotypeMap(); - FlatPhenotypeMap<Phenotype> decodedPhenotypes = - new FlatPhenotypeMap<Phenotype>(systemModelAdapter); - - for(ComposableCreator<? extends ComposableGenotype> creator : subCreators) { - @SuppressWarnings("unchecked") ComposableCreator<N> castedCreator = - (ComposableCreator<N>)creator; - N subGenotype; - try { - subGenotype = castedCreator.createComposable(createdGenotypes, decodedPhenotypes); - } catch(ExplorationException e) { - // TODO: Introduce a CreateException. - throw new RuntimeException(e); - } - - @SuppressWarnings("unchecked") Class<N> subGenotypeClass = - (Class<N>)subGenotype.getGTypeToRegister(); - compositeGenotype.put(subGenotypeClass, subGenotype); - createdGenotypes.put(subGenotypeClass, subGenotype); - - // Directly execute the identity decoders. They have no other dependencies, but allow - // the access to the created - decodedPhenotypes.addAll(castedCreator.identityDecodeCreatedGenotype(subGenotype, - decodedPhenotypes)); - - // TODO #checking: invoke the checking here. - - // Execute decoders that are based on the just created Genotype such that subsequent - // decoders can access these Phenotypes. - for(ComposableCreator<? extends ComposableGenotype> curCreator : subCreators) { - @SuppressWarnings("unchecked") ComposableCreator<N> curCastedCreator = - (ComposableCreator<N>)curCreator; - @SuppressWarnings("unchecked") Class<P> createdType = - (Class<P>)curCreator.getCreatedEncoding(); - N curGenotype = subGenotype; - if(!subGenotypeClass.equals(createdType)) { - @SuppressWarnings("unchecked") N castedCurGenotype = - (N)decodedPhenotypes.getEncoding(createdType); - curGenotype = castedCurGenotype; - } - if(curGenotype != null) { - decodedPhenotypes.addAll(curCastedCreator.decodeCreatedGenotype(curGenotype, - decodedPhenotypes, createdGenotypes.keySet())); - } - } - } - } - - /** {@inheritDoc} */ - @Override - public <C extends ComposableGenotype> void registerSubCreator(ComposableCreator<?> subCreator) { - if(subCreator != null) { - subCreators.add(subCreator); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/ComposableDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/ComposableDecoder.java deleted file mode 100644 index b3582990253c2733de84f370a39991b406973d03..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/ComposableDecoder.java +++ /dev/null @@ -1,80 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComposableDecoder.java 3451 2016-09-02 13:36:29Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.problem.CompositeProblemModuleBase; -import org.fortiss.af3.exploration.alg.graph.IDependencyModule; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.opt4j.core.Genotype; -import org.opt4j.core.problem.Decoder; - -/** - * {@link Decoder}s for {@link ComposableGenotype}s must implement this interface and be registered - * as part of a sub problem to the {@link CompositeProblemModuleBase}, such that the sub problem is - * solved automatically. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3451 $ - * @ConQAT.Rating RED Hash: 62C4D78593B24C20FEC7B1D4BC3AEF56 - */ -public interface ComposableDecoder<G extends ComposableGenotype, P extends ComposablePhenotype<?>> - extends IDependencyModule<IExplorationEncoding, P> { - - /** - * Passes the {@link ComposableGenotype} to the concrete decode method of the concrete - * {@link ComposableDecoder} and returns the resulting {@link ComposablePhenotype}. - * <p> - * <b>Implementation note:</b> <br> - * The body of the method typically looks as follows: <br> - * {@code return decode((ConecreteGenotype)genotype);} - * - * @genotype The concrete {@link ComposableGenotype} that shall be decoded. - * - * @returns The concrete {@link ComposablePhenotype} resulting form the decoding. - * - * @throws DecodingException - * If decoding the given {@link Genotype} is not possible. - */ - P decodeComposable(G genotype, FlatPhenotypeMap<Phenotype> decodedPhenotypes) - throws DecodingException; - - /** - * Updates the given {@code outGenotype} using the information encoded in the {@code inGenotype} - * . It is used for <i>hybrid Phenotypes</i> that are also {@link Genotype} and for which - * existing information shall not be destroyed by creating a completely new {@link Phenotype}/ - * {@link Genotype}. - * - * @param inGenotype - * Input {@link Genotype} that is used to update the {@code outGenotype}. - * @param outGenotype - * {@link Genotype} to be updated. - * @param decodedPhenotypes - * Map of already decoded {@link Phenotype}s. - * @return The updated {@link Phenotype}. - * @throws DecodingException - * If updating the given {@link Genotype} is not possible. - */ - P updateComposable(G inGenotype, P outGenotype, FlatPhenotypeMap<Phenotype> decodedPhenotypes) - throws DecodingException; -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/ComposableDecoderBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/ComposableDecoderBase.java deleted file mode 100644 index ca5e0cc98e371dfedd90b0b0bac0b70f6c2650ad..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/ComposableDecoderBase.java +++ /dev/null @@ -1,41 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComposableDecoderBase.java 3451 2016-09-02 13:36:29Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; - -/** - * Base class for {@link ComposableDecoder}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3451 $ - * @ConQAT.Rating RED Hash: 378ECE4AEA793F48379C243CF11D0831 - */ -public abstract class ComposableDecoderBase<G extends ComposableGenotype, P extends ComposablePhenotype<?>> - implements ComposableDecoder<G, P> { - - // TODO: implement the following method here: The class hierarchy must be traversed. Then, also - // the interface (ComposableDecoder) can be specialized to Class<P>. - // public Class<P> getDecodedPhenotypeType() { - // TypeVariable<?>[] genericTypes = ExplorationUtils.get; - // assert (genericTypes.length == 2); - // return (Class<P>)genericTypes[1].getClass(); - // } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/CompositeDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/CompositeDecoder.java deleted file mode 100644 index f990ec49d703a0fc96d1cbae2720122efcf46e0f..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/CompositeDecoder.java +++ /dev/null @@ -1,65 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CompositeDecoder.java 3062 2016-06-20 17:59:20Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode; - -import java.util.Map; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.CompositePhenotype; -import org.jgrapht.experimental.dag.DirectedAcyclicGraph.CycleFoundException; -import org.opt4j.core.Genotype; -import org.opt4j.core.genotype.CompositeGenotype; -import org.opt4j.core.problem.Decoder; - -/** - * {@link Decoder}s of {@link CompositeGenotype}s implement this interface. The {@link Decoder}s of - * the {@link ComposableGenotype}s comprising the {@link CompositeGenotype} will be delegated by the - * implementing class. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3062 $ - * @ConQAT.Rating RED Hash: 94D2BED3181E9749F65A43B2CDB377CE - */ -public interface CompositeDecoder<C extends CompositeGenotype<Class<? extends ComposableGenotype>, ? extends ComposableGenotype>, P extends CompositePhenotype<? extends Genotype>> - extends Decoder<C, P> { - - /** - * Performs the merge of the sub-{@link Genotype}s of {#link V} to the {@link CompositeGenotype} - * {#link V}. - * - * @param subPhenotypes - * Map relating the sub-{@link Genotype}s with their decoding result (aka phenotype). - * @return The {@link CompositeGenotype} {#link P} or {@code null} if the merge fails. - */ - <CP extends ComposablePhenotype<? extends Genotype>> P mergeSubPhenotypes( - Map<Class<CP>, CP> subPhenotypes); - - /** - * Adds a {@link ComposableDecoder} for the given {@link ComposablePhenotype}. The decoding - * will triggered automatically and user defined merge function will consider the resulting - * {@link ComposablePhenotype} of this {@link ComposableDecoder}. - * - * @throws CycleFoundException - */ - // TODO: add doc for exception. - <G extends ComposableGenotype, CP extends ComposablePhenotype<G>, D extends ComposableDecoder<G, CP>> - void registerSubDecoder(Class<G> subGenotype, D subDecoder) throws CycleFoundException; - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/CompositeDecoderBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/CompositeDecoderBase.java deleted file mode 100644 index 3ac66c8e0a1710e60e29db4f97fd8f95be974fdd..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/CompositeDecoderBase.java +++ /dev/null @@ -1,262 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CompositeDecoderBase.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode; - -import static org.fortiss.af3.exploration.util.ExplorationUtils.isDebugVerboseEnabled; - -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Map.Entry; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.create.ComposableCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.MissingDependencyException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph.DecoderDependencyGraph; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.CompositePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.jgrapht.experimental.dag.DirectedAcyclicGraph.CycleFoundException; -import org.opt4j.core.Genotype; -import org.opt4j.core.genotype.CompositeGenotype; -import org.opt4j.core.problem.Decoder; - -/** - * Base class for decoding {@link CompositeGenotype}s. It is responsible for managing the decoding - * the sub-{@link ComposableGenotype}s that form the {@link CompositeGenotype}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: 29B7EB1096C939A3B9322F7DD992F588 - */ -public abstract class CompositeDecoderBase<C extends CompositeGenotype<Class<? extends ComposableGenotype>, ComposableGenotype>, P extends CompositePhenotype<?>> - implements CompositeDecoder<C, P> { - - /** representation of the input models. */ - private SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** - * References the {@link DecoderDependencyGraph} which defines execution orders and which - * {@link Phenotype}s are needed within the DSE. - */ - protected DecoderDependencyGraph depGraph; - - /** - * Collection of {@link ComposablePhenotype} types that are needed to generated the {#link - * requestedPhenotypeTypes}. - */ - Collection<Class<? extends Phenotype>> requiredPhenotypeTypes; - - /** - * Collection of {@link ComposablePhenotype}s that were externally demanded as a solution to - * input DSE problem. - */ - Collection<Class<? extends Phenotype>> requestedPhenotypeTypes; - - /** Relates decoders with the {@link Genotype}-Type that they decode. */ - private Map<ComposableDecoder<? extends ComposableGenotype, ? extends ComposablePhenotype<?>>, Class<? extends ComposableGenotype>> registeredSubDecoders = - new HashMap<>(); - - /** - * {@link LinkedHashMap} referencing the required decoders for the given optimization problem - * that respects the execution order calculated by the {@link DecoderDependencyGraph}. - */ - private LinkedHashMap<ComposableDecoder<ComposableGenotype, ComposablePhenotype<?>>, Class<? extends ComposableGenotype>> subDecoders = - new LinkedHashMap<>(); - - /** - * Flag to determine whether all required {@link ComposableDecoder}s (indicated by the - * {@link DecoderDependencyGraph}) are registered. - */ - private boolean isDecoderRegistrationChecked = false; - - /** Default constructor that requires a representation of the input models. */ - public CompositeDecoderBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph depGraph) { - this.systemModelAdapter = systemModelAdapter; - this.depGraph = depGraph; - } - - /** - * Decodes the given {@link Genotype} which is a {@link CompositeGenotype}. It launches all - * registered {@link Decoder}s for its {@link ComposableGenotype}s that compose the given - * {@link CompositeGenotype}. - * - * This method is called from {@link CompositeDecoderBase#decode(CompositeGenotype)}. It is - * implemented separately such that type-to-object equivalence is enforced for the background - * maps. - * - * @param genotype - * {@link Genotype} (i.e., a {@link CompositeGenotype}) for which the sub-decoders - * will be launched. - * @return The decoded {@link CompositePhenotype} which contains the decoded - * {@link ComposablePhenotype}s. - * @throws DecodingException - * if a required {@link ComposableDecoder} is not registered, or one of the - * sub-Decoders produces an error. - * @throws MissingDependencyException - * if some required {@link IExplorationEncoding} of a {@link ComposableDecoder} is - * not provided by another one, a {@link ComposableCreator}, or the - * {@link SystemModelAdapter}. - */ - public <SP extends Genotype, CG extends ComposableGenotype, CP extends ComposablePhenotype<CG>> - P decodeInternal(C genotype) throws DecodingException, MissingDependencyException { - Map<Class<CP>, CP> subPhenotypes = new HashMap<>(); - FlatPhenotypeMap<Phenotype> decodedPhenotypes = - new FlatPhenotypeMap<Phenotype>(systemModelAdapter); - - if(!isDecoderRegistrationChecked) { - isDecoderRegistrationChecked = true; - - for(ComposableDecoder<?, ?> decoder : depGraph.getOperatorExecOrder()) { - if(registeredSubDecoders.containsKey(decoder)) { - @SuppressWarnings("unchecked") ComposableDecoder<ComposableGenotype, ComposablePhenotype<?>> castedDecoder = - (ComposableDecoder<ComposableGenotype, ComposablePhenotype<?>>)decoder; - subDecoders.put(castedDecoder, registeredSubDecoders.get(decoder)); - } else { - throw new DecodingException( - genotype, - decoder, - "The sub-decoder " + - decoder.getClass().getSimpleName() + - " has been found in the dependency graph but it has not been regirstered at this composite decoder."); - } - } - } - - for(Entry<ComposableDecoder<ComposableGenotype, ComposablePhenotype<?>>, Class<? extends ComposableGenotype>> decodeEntry : subDecoders - .entrySet()) { - @SuppressWarnings("unchecked") Class<CG> genotypeKey = - (Class<CG>)decodeEntry.getValue(); - CG decodeableGenotype = genotype.get(genotypeKey); - - @SuppressWarnings("unchecked") ComposableDecoder<CG, CP> castedDecoder = - (ComposableDecoder<CG, CP>)decodeEntry.getKey(); - @SuppressWarnings("unchecked") Class<CP> decType = - (Class<CP>)castedDecoder.getOutputType(); - CP curPhenotype = null; - - // Decode a "normal" phenotype; Update a "Hybrid Phenotype" whose encoded information - // shall not be just overridden. - if(Genotype.class.isAssignableFrom(decType)) { - CP oldGenotype = genotype.get(decType); - curPhenotype = - castedDecoder.updateComposable(decodeableGenotype, oldGenotype, - decodedPhenotypes); - } else { - curPhenotype = - castedDecoder.decodeComposable(decodeableGenotype, decodedPhenotypes); - } - - // Catch erroneous phenotypes (failed decoding). - if(curPhenotype != null) { - // TODO #checking: invoke the checking here. - - @SuppressWarnings("unchecked") Class<CP> penotypeClass = - (Class<CP>)curPhenotype.getPTypeToRegister(); - subPhenotypes.put(penotypeClass, curPhenotype); - decodedPhenotypes.putEncoding(penotypeClass, curPhenotype); - - // Include all demanded inputs of a decoder that are Phenotypes as well, but which - // are provided by the systemModelAdapter. They may be needed by the model - // transformation framework, hence include them in the output encodings. - for(Class<?> encodingClass : castedDecoder.getRequiredTypes()) { - if(Phenotype.class.isAssignableFrom(encodingClass)) { - @SuppressWarnings("unchecked") Class<? extends Phenotype> castedEncClass = - (Class<? extends Phenotype>)encodingClass; - decodedPhenotypes.putEncoding(castedEncClass, - decodedPhenotypes.getEncoding(castedEncClass)); - } - } - - if(curPhenotype instanceof ComposableGenotype) { - addHybridGenoPhenotype(genotype, curPhenotype, penotypeClass); - } - } - } - - P compositePhenotype = mergeSubPhenotypes(subPhenotypes); - for(Entry<Class<CP>, CP> subPhenotype : subPhenotypes.entrySet()) { - compositePhenotype.putSubPhenotype(subPhenotype.getKey(), subPhenotype.getValue()); - } - - return compositePhenotype; - } - - /** - * <b>NOTE:</b> Sub-implementations MUST call {@code super.decode(genotype)}!!! - * <p> - * {@inheritDoc} - */ - @Override - public P decode(C genotype) { - try { - return decodeInternal(genotype); - } catch(DecodingException | MissingDependencyException e) { - if(isDebugVerboseEnabled()) { - e.printStackTrace(); - } - throw new RuntimeException(e); - } - } - - /** - * Adds a hybrid geno-/phenotype to the given {@link CompositeGenotype}. A hybrid - * geno-/phenotype is a {@link ComposableGenotype} which is a Phenotype but also a Genotype - * that is used to calculate an dependent Phenotype. - */ - @SuppressWarnings("unchecked") - private <V extends ComposableGenotype, M extends ComposablePhenotype<?>> void - addHybridGenoPhenotype(C genotype, M curPhenotype, Class<M> penotypeClass) { - for(Class<? extends ComposableGenotype> registeredType : genotype.keySet()) { - if(registeredType.isAssignableFrom(penotypeClass)) { - genotype.put((Class<V>)penotypeClass, (V)curPhenotype); - return; - } - } - // Only relevant during development --> asserts should be enabled. - assert (false) : "There is no decoder registered for the hybrid pheno- and genotype " + - penotypeClass + "."; - } - - /** - * {@inheritDoc} - * - * @throws CycleFoundException - */ - @Override - public - <G extends ComposableGenotype, CP extends ComposablePhenotype<G>, D extends ComposableDecoder<G, CP>> - void registerSubDecoder(Class<G> subGenotype, D subDecoder) throws CycleFoundException { - if(subGenotype == null || subDecoder == null) { - return; - } - - registeredSubDecoders.put(subDecoder, subGenotype); - - @SuppressWarnings("unchecked") ComposableDecoder<ComposableGenotype, ComposablePhenotype<?>> castedSubDecoder = - (ComposableDecoder<ComposableGenotype, ComposablePhenotype<?>>)subDecoder; - depGraph.addOperator(castedSubDecoder); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/PhenotypeDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/PhenotypeDecoder.java deleted file mode 100644 index 41cb23e8aa5d99b2ebd3a8d352a75473a0d9ec40..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/decode/PhenotypeDecoder.java +++ /dev/null @@ -1,89 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: PhenotypeDecoder.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.problem.CompositeProblemModuleBase; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.opt4j.core.Genotype; -import org.opt4j.core.problem.Decoder; - -/** - * {@link Decoder}s for {@link Phenotype}s must implement this interface and be registered - * as part of a sub problem to the {@link CompositeProblemModuleBase}, such that the sub problem is - * solved automatically. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: 6334B9B20BB123E5891FB9A4A9C8A68B - */ -public interface PhenotypeDecoder<P extends Phenotype> { - - /** - * Decodes a {@link Phenotype} contained in the given {@link FlatPhenotypeMap} and returns it. - * - * @param decodedPhenotypes - * Map of already decoded {@link Phenotype}s. - * - * @returns The concrete {@link ComposablePhenotype} resulting form the decoding. - * - * @throws DecodingException - * If decoding the given {@link Genotype} is not possible. - */ - // TODO: update documentation. - // TODO: Pass the phenotype to be decoded as a separate parameter. - P decodeComposable(FlatPhenotypeMap<Phenotype> decodedPhenotypes) throws DecodingException; - - /** - * Updates the given {@link Phenotype} using the information encoded in the given - * {@link FlatPhenotypeMap} (which contains the already decoded {@link Phenotype}s) and returns - * it. - * - * @param decodedPhenotypes - * Map of already decoded {@link Phenotype}s. - * - * @returns The concrete {@link ComposablePhenotype} resulting form the decoding. - * - * @throws DecodingException - * If decoding the given {@link Genotype} is not possible. - */ - P updateComposable(P outGenotype, FlatPhenotypeMap<Phenotype> decodedPhenotypes) - throws DecodingException; - - /** - * Returns the collection of {@link ComposablePhenotype} types that are required as direct - * inputs to this {@link PhenotypeDecoder}. - */ - Collection<Class<? extends IExplorationEncoding>> getRequiredPhenotypeTypes(); - - /** - * Returns the collection of {@link IExplorationEncoding} that may provide optional information - * for the decoding of the input {@link Genotype}s but which are not required for a successful - * decoding. - */ - Collection<Class<? extends IExplorationEncoding>> getOptionalEncodingTypes(); - - /** Returns the type of the decoded {@link ComposablePhenotype}. */ - Class<? extends Phenotype> getDecodedPhenotypeType(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/evaluate/ComposableEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/evaluate/ComposableEvaluator.java deleted file mode 100644 index 06a68d5830b27540b189fb35b067009f1ac4bab3..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/evaluate/ComposableEvaluator.java +++ /dev/null @@ -1,59 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComposableEvaluator.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.opt4j.core.Objectives; -import org.opt4j.core.problem.Evaluator; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * Common interface of {@link Evaluator}s of {@link ComposablePhenotype}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: D47347505A968014F1004269C3099AD5 - */ -public interface ComposableEvaluator<P extends Object> { - /** - * Passes the {@link ComposablePhenotype} to the concrete evaluate method of the concrete - * {@link ComposableEvaluator} and returns the resulting {@link Objectives}. - * <p> - * <b>Implementation note:</b> <br> - * The body of the method typically looks as follows: <br> - * {@code return decode((ConecretePhenotype)phenotype);} - * - * @param clazz - * Type of the {@link ComposablePhenotype} to be evaluated. - * @param phenotype - * The concrete {@link Phenotype} that shall be decoded. - * @param phenotypes - * Map of decoded {@link Phenotype}s which may provide additional input. - * @param transformedModels - * TODO - * @returns The concrete evaluation results in the form of {@link Objectives}. - */ - <CP extends ComposablePhenotype<?>> Objectives evaluateComposable(Class<CP> clazz, - CP phenotype, FlatPhenotypeMap<Phenotype> phenotypes, - ClassToInstanceMap<EObject> transformedModels); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/evaluate/CompositeEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/evaluate/CompositeEvaluator.java deleted file mode 100644 index dbe0de908404095fe294c2720f756c4e69e0dc6f..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/evaluate/CompositeEvaluator.java +++ /dev/null @@ -1,69 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CompositeEvaluator.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate; - -import java.util.Collection; -import java.util.Set; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.CompositePhenotype; -import org.opt4j.core.Objectives; -import org.opt4j.core.Value; -import org.opt4j.core.genotype.CompositeGenotype; -import org.opt4j.core.problem.Evaluator; - -/** - * Interface for evaluators of {@link CompositePhenotype}s. It defines a 'merge' method that each - * concrete {@link CompositeEvaluator} must implement and which describes how the single - * {@link ComposablePhenotype}s are merged into a {@link CompositePhenotype}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: E54D706B912A419F3F8127FD5FACEABB - */ -public interface CompositeEvaluator<P> extends Evaluator<P> { - - /** - * Adds a {@link ComposableEvaluator} for the given {@link ComposablePhenotype} class. The - * evaluation will be triggered automatically by the evaluation of the {@link CompositeGenotype} - * and user defined merge function will consider the resulting {@link Objectives} of this - * {@link ComposableEvaluator}, if desired. - */ - <S extends ComposablePhenotype<?>> void registerSubEvaluator(Class<S> subPhenotype, - ComposableEvaluator<S> subEvaluator) throws Exception; - - /** - * Merges the evaluations of {@link ComposablePhenotype}s into an evaluation of the overall - * {@link CompositeGenotype}. - */ - Value<?> mergeSubEvaluations(Collection<Value<?>> results); - - /** - * Returns the collection of {@link ComposableEvaluator}s registered for this - * {@link ComposableEvaluator}. - */ - Collection<ComposableEvaluator<? extends ComposablePhenotype<?>>> getSubEvaluators(); - - /** - * Returns the collection of {@link ComposableEvaluator}s registered for this - * {@link ComposableEvaluator} and all its children. Recursive version of - * {@link #getSubEvaluators()}. - */ - Set<ComposableEvaluator<? extends ComposablePhenotype<?>>> getAllSubEvaluators(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/evaluate/CompositeEvaluatorBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/evaluate/CompositeEvaluatorBase.java deleted file mode 100644 index 75dad88a265db4eaab63ca4d3eb0ed9eab223924..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/evaluate/CompositeEvaluatorBase.java +++ /dev/null @@ -1,275 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CompositeEvaluatorBase.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate; - -import static org.fortiss.af3.exploration.alg.service.ExplorationService.getService; -import static org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext.DSE_INTERNAL; -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.pickInstanceOf; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.CompositePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.EvaluatorWrapper; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMultiMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEvaluatationService; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.opt4j.core.Genotype; -import org.opt4j.core.Objective; -import org.opt4j.core.Objectives; -import org.opt4j.core.Value; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.MutableClassToInstanceMap; - -/** - * Base class for Evaluators of {@link CompositePhenotype}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: CE83131FB12EBD6AC292C4D76ABC8A2C - */ -public abstract class CompositeEvaluatorBase<P extends CompositePhenotype<?>> implements - CompositeEvaluator<P> { - - /** Representation of the input models. */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Flag to mark that marks the top-most evaluator in the composite structure. */ - protected boolean isTopLevelEvaluator = false; - - /** Flag to determine if the {@link #init()} routine was launched for this instance. */ - private boolean isInitialized = false; - - /** References the models provided by the {@link IExplorationTransformationService}. */ - protected ClassToInstanceMap<EObject> transformedModels = MutableClassToInstanceMap.create(); - - /** Collection of required models demanded by the evaluators. */ - protected Collection<Class<? extends EObject>> requiredTransformedModelTypes; - - /** - * Correlates the {@link ComposablePhenotype}s with the corresponding - * {@link ComposableEvaluator}s forming this CompositeEvaluator. - */ - @SuppressWarnings("unchecked") - private SubClassToInstanceMultiMap<ComposablePhenotype<?>, ComposableEvaluator<? extends ComposablePhenotype<?>>> subEvaluators = - new SubClassToInstanceMultiMap<>( - (Class<? extends ComposablePhenotype<?>>)ComposablePhenotype.class); - - /** Default constructor which requires a {@link SystemModelAdapter} to access the input models. */ - public CompositeEvaluatorBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - - if(!ComposableEvaluator.class.isAssignableFrom(getClass())) { - isTopLevelEvaluator = true; - } - } - - /** - * Performs the initialization of {@code this} {@link CompositeEvaluator} that cannot be done in - * the constructor, e.g., due to the missing registration of sub evaluators. - * It is executed when {@link #evaluateInternal(CompositePhenotype)} is executed for the first - * time of this instance. - */ - protected void init() { - if(isInitialized) { - return; - } - isInitialized = true; - - if(isTopLevelEvaluator) { - Set<IExplorationTargetEvaluator<?, ?, ?>> allSubEvaluators = new HashSet<>(); - getAllSubEvaluators().forEach( - e -> allSubEvaluators.add(((EvaluatorWrapper<?, ?, ?>)e).getEvaluator())); - - @SuppressWarnings("unchecked") Collection<Class<? extends EObject>> tempReqModels = - getService(IExplorationEvaluatationService.class).getRequiredTransformedModels( - allSubEvaluators); - requiredTransformedModelTypes = tempReqModels; - } - } - - /** - * Internal method that calls the evaluators for {@link ComposableGenotype}s. - * <b>NOTE:</b> Sub-implementations must call {@code super.decode(P)}!!! - * - * @param phenotype - * {@link Phenotype} that shall be evaluated w.r.t. to the - * {@link ExplorationSpecification}. - * @return Evaluation result as {@link Objectives}. - */ - public <S extends ComposablePhenotype<?>> Objectives evaluateInternal(P phenotype) { - init(); - - Multimap<Objective, Value<?>> subObjectivesEvaluations = HashMultimap.create(); - Multimap<Objective, S> objectiveContribPheno = HashMultimap.create(); - - FlatPhenotypeMap<Phenotype> phenotypeTypeMap = null; - if(isTopLevelEvaluator) { - phenotypeTypeMap = constructPhenotypeMap(phenotype); - } else { - // TODO: Create an EvaluationException and use it here. - throw new RuntimeException( - "The phenotype type map could not be created for the top-most evaluator."); - } - - ClassToInstanceMap<EObject> transformedModels = MutableClassToInstanceMap.create(); - if(isTopLevelEvaluator && !requiredTransformedModelTypes.isEmpty()) { - try { - transformedModels = - getService(IExplorationTransformationService.class).getTransformedModels( - DSE_INTERNAL, null, phenotypeTypeMap.asExplorationEncoding(), - systemModelAdapter.getInputModels(), requiredTransformedModelTypes, - null); - } catch(Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - Iterator<Entry<Class<? extends ComposablePhenotype<? extends Genotype>>, ComposablePhenotype<? extends Genotype>>> phenoIter = - phenotype.iterator(); - while(phenoIter.hasNext()) { - Entry<Class<? extends ComposablePhenotype<? extends Genotype>>, ComposablePhenotype<? extends Genotype>> phenoEntry = - phenoIter.next(); - @SuppressWarnings("unchecked") S subPhenotype = (S)phenoEntry.getValue(); - @SuppressWarnings("unchecked") Class<S> key = (Class<S>)phenoEntry.getKey(); - @SuppressWarnings("unchecked") Collection<ComposableEvaluator<? extends ComposablePhenotype<?>>> phenoSubEvaluators = - subEvaluators.get((Class<? extends ComposablePhenotype<?>>)phenoEntry - .getValue().getClass()); - if(phenoSubEvaluators != null) { - // If no subEvaluator is registered, only decoding shall be performed -> no - // evaluation. - Objectives evalResults = new Objectives(); - for(ComposableEvaluator<? extends ComposablePhenotype<?>> subEvaluator : phenoSubEvaluators) { - evalResults = - subEvaluator.evaluateComposable(key, subPhenotype, phenotypeTypeMap, - transformedModels); - Iterator<Entry<Objective, Value<?>>> resultIterator = evalResults.iterator(); - while(resultIterator.hasNext()) { - Entry<Objective, Value<?>> result = resultIterator.next(); - objectiveContribPheno.put(result.getKey(), subPhenotype); - subObjectivesEvaluations.put(result.getKey(), result.getValue()); - - } - } - } - } - - transformedModels.clear(); - - Objectives mergedObjectives = new Objectives(); - for(Entry<Objective, Collection<S>> objPheno : objectiveContribPheno.asMap().entrySet()) { - // TODO : re-add merged value as a separate value. - Value<?> objectiveEvalValue = - mergeSubEvaluations(subObjectivesEvaluations.get(objPheno.getKey())); - mergedObjectives.add(objPheno.getKey(), objectiveEvalValue); - // Objective objective = objPheno.getKey(); - // for(Value<?> val - // mergedObjectives.add(objPheno.getKey(), - // subObjectivesEvaluations.get(objPheno.getKey())); - } - - return mergedObjectives; - } - - /** {@inheritDoc} */ - @Override - public Objectives evaluate(P phenotype) { - return evaluateInternal(phenotype); - } - - /** {@inheritDoc} */ - @Override - public <S extends ComposablePhenotype<?>> void registerSubEvaluator(Class<S> subPhenotype, - ComposableEvaluator<S> subEvaluator) throws Exception { - subEvaluators.put(subPhenotype, subEvaluator); - } - - /** {@inheritDoc} */ - @Override - public Collection<ComposableEvaluator<? extends ComposablePhenotype<?>>> getSubEvaluators() { - Collection<ComposableEvaluator<? extends ComposablePhenotype<?>>> allSubEvaluators = - new HashSet<>(); - for(ComposableEvaluator<? extends ComposablePhenotype<?>> evaluators : subEvaluators - .values()) { - allSubEvaluators.add(evaluators); - } - return allSubEvaluators; - } - - /** {@inheritDoc} */ - @Override - public Set<ComposableEvaluator<? extends ComposablePhenotype<?>>> getAllSubEvaluators() { - Set<ComposableEvaluator<? extends ComposablePhenotype<?>>> allSubEvaluators = - new HashSet<>(); - // Get the direct sub-Evaluators. - allSubEvaluators.addAll(subEvaluators.values()); - - // Recursively fetch the nested sub-Evaluators. - @SuppressWarnings("rawtypes") Collection<CompositeEvaluator> compositeSubEvaluators = - pickInstanceOf(CompositeEvaluator.class, subEvaluators.values()); - for(CompositeEvaluator<?> curCompositeEval : compositeSubEvaluators) { - allSubEvaluators.addAll(curCompositeEval.getAllSubEvaluators()); - } - - return allSubEvaluators; - } - - /** - * Constructs a flattened version of the given {@link CompositePhenotype}, i.e. a - * {@link FlatPhenotypeMap}. - */ - private - <G extends Genotype, CP extends CompositePhenotype<?>, SP extends ComposablePhenotype<G>> - FlatPhenotypeMap<Phenotype> constructPhenotypeMap(CP phenotype) { - FlatPhenotypeMap<Phenotype> phenotypeTypeMap = - new FlatPhenotypeMap<Phenotype>(systemModelAdapter); - @SuppressWarnings("unchecked") LinkedList<SP> subPhenotypes = - new LinkedList<SP>((Collection<? extends SP>)phenotype.getSubPhenotypes()); - while(!subPhenotypes.isEmpty()) { - SP currSubPhenotype = subPhenotypes.poll(); - @SuppressWarnings("unchecked") Class<SP> currSupPhenotypeType = - (Class<SP>)currSubPhenotype.getClass(); - phenotypeTypeMap.putEncoding(currSupPhenotypeType, currSubPhenotype); - if(CompositePhenotype.class.isAssignableFrom(currSubPhenotype.getClass())) { - @SuppressWarnings("unchecked") List<SP> subPhenos = - (List<SP>)phenotype.getSubPhenotypes(); - subPhenotypes.addAll(0, subPhenos); - } - } - - return phenotypeTypeMap; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/exception/DecodingException.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/exception/DecodingException.java deleted file mode 100644 index 8814da5e1495fc8a4f9b8670f46f1be98586a699..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/exception/DecodingException.java +++ /dev/null @@ -1,70 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DecodingException.java 3480 2016-09-09 13:31:04Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.opt4j.core.Genotype; -import org.opt4j.core.problem.Decoder; - -/** - * Container for exceptions thrown in the decoding steps. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3480 $ - * @ConQAT.Rating RED Hash: 3C84B0252388D8EADFEF818C0F2910DB - */ -public class DecodingException extends ExplorationException { - /** Constructor specialized for decoding errors. */ - public DecodingException(Genotype gentotype, Decoder<?, ?> decoder) { - super("Decoding Error: Could not decode " + gentotype + " using the decoder " + decoder + - "."); - } - - /** Constructor specialized for decoding errors. Takes an additional message. */ - public DecodingException(Genotype gentotype, Decoder<?, ?> decoder, String msg) { - super("Decoding Error: Could not decode " + gentotype + " using the decoder " + decoder + - ". " + msg); - } - - /** Constructor specialized for decoding errors. Takes an additional message. */ - public DecodingException(Genotype gentotype, Decoder<?, ?> decoder, String msg, Exception e) { - super("Decoding Error: Could not decode " + gentotype + " using the decoder " + decoder + - ". " + msg, e); - } - - /** Constructor specialized for decoding errors. */ - public DecodingException(Genotype gentotype, ComposableDecoder<?, ?> decoder) { - super("Decoding Error: Could not decode " + gentotype + " using the decoder " + decoder + - "."); - } - - /** Constructor specialized for decoding errors. Takes an additional message. */ - public DecodingException(Genotype gentotype, ComposableDecoder<?, ?> decoder, String msg) { - super("Decoding Error: Could not decode " + gentotype + " using the decoder " + decoder + - ". " + msg); - } - - /** Constructor specialized for decoding errors. Takes an additional message. */ - public DecodingException(Genotype gentotype, ComposableDecoder<?, ?> decoder, String msg, - Exception e) { - super("Decoding Error: Could not decode " + gentotype + " using the decoder " + decoder + - ". " + msg, e); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/exception/DependencyException.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/exception/DependencyException.java deleted file mode 100644 index 4283fd25f4edf1572c055e0257671618159bf49d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/exception/DependencyException.java +++ /dev/null @@ -1,42 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DependencyException.java 3480 2016-09-09 13:31:04Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception; - -import org.fortiss.af3.exploration.alg.exception.ExplorationException; - -/** - * Exception to be thrown whenever a some dependency in the DSE cannot be satisfied, e.g., if some - * required input encoding is missing. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3480 $ - * @ConQAT.Rating RED Hash: A28B31975B79BEDA5BB28FFD02E26120 - */ -public class DependencyException extends ExplorationException { - - /** Constructor. */ - public DependencyException(String msg) { - super(msg); - } - - /** Constructor that stacks the given Exception. */ - public DependencyException(String msg, Exception e) { - super(msg, e); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/exception/MissingDependencyException.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/exception/MissingDependencyException.java deleted file mode 100644 index 88f122c203c79fe0b5abf96cfb9fd13a668fdadc..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/exception/MissingDependencyException.java +++ /dev/null @@ -1,44 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MissingDependencyException.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; - -/** - * Exception to be thrown whenever a some dependency in the DSE cannot be satisfied - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: 980CBA6940BEF3047411EF9EF005BADC - */ -public class MissingDependencyException extends DependencyException { - - /** Constructor for missing dependencies of {@link ComposableDecoder}s. */ - public MissingDependencyException(ComposableDecoder<?, ?> dec, - Class<? extends IExplorationEncoding> enc, String msg) { - super( - "The encoding " + - enc.getSimpleName() + - " required by the decoder " + - dec.getClass().getSimpleName() + - "could not be found. Please check if all required encodings are available, and that the dependencies are correctly defined. Details: " + - msg); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/genotype/ComposableGenotype.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/genotype/ComposableGenotype.java deleted file mode 100644 index def74068942b4be639a377f9e4f598851e075c53..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/genotype/ComposableGenotype.java +++ /dev/null @@ -1,38 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComposableGenotype.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype; - -import org.opt4j.core.Genotype; -import org.opt4j.core.genotype.CompositeGenotype; - -/** - * Interface for {@link Genotype}s that compose a {@link CompositeGenotype}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: D8B5AFBB8BFDDAC1265E90086AC67A4D - */ -public interface ComposableGenotype extends Genotype { - - /** - * Returns the type which shall be used to register the {@link ComposableGenotype} at its - * containing {@link CompositeGenotype}. - */ - Class<? extends ComposableGenotype> getGTypeToRegister(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/genotype/FlatGenotypeMap.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/genotype/FlatGenotypeMap.java deleted file mode 100644 index 9cdbb32d42cf8ac8178586a6131939685ccad0f3..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/genotype/FlatGenotypeMap.java +++ /dev/null @@ -1,47 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FlatGenotypeMap.java 3035 2016-06-17 13:13:23Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.CompositePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.opt4j.core.Genotype; -import org.opt4j.core.genotype.CompositeGenotype; - -/** - * Allows to capture the already created/decoded {@link Phenotype}s and pass them to their successor - * creators/decoders as a flat map that associates a {@link Phenotype}s type with its instance. - * Using a {@link CompositePhenotype} for this job allows to "protect" the internal map from - * unintended read/write operations. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3035 $ - * @ConQAT.Rating RED Hash: F18EE4BF8BD55B14AFED72D10A129213 - */ -public class FlatGenotypeMap extends CompositeGenotype<Class<? extends Genotype>, Genotype> { - // No "real" implementation required. The base class does this job. - - /** {@inheritDoc} */ - @Override - public String toString() { - String ownName = getClass().getSimpleName() + ": \n"; - StringBuilder strBuilder = new StringBuilder(ownName); - map.keySet().forEach(g -> strBuilder.append("-> " + g.getSimpleName() + "\n")); - return strBuilder.toString(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/graph/DecoderDependencyGraph.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/graph/DecoderDependencyGraph.java deleted file mode 100644 index 48a282bc851127895a290c05b6c77911b0601507..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/graph/DecoderDependencyGraph.java +++ /dev/null @@ -1,101 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DecoderDependencyGraph.java 3747 2016-10-21 14:10:16Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph; - -import java.util.Collection; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Set; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.create.ComposableCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.MissingDependencyException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.decode.ConstraintGenerationDecoder; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.graph.DependencyGraph; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.opt4j.core.problem.Creator; -import org.opt4j.core.problem.Decoder; - -/** - * Defines the Execution order of {@link Decoder}s / {@link Creator}s etc. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3747 $ - * @ConQAT.Rating RED Hash: F21C1E8B3019427B78789FD3EE968BA7 - */ -public class DecoderDependencyGraph - extends - DependencyGraph<IExplorationEncoding, ComposableDecoder<ComposableGenotype, ComposablePhenotype<?>>, DecoderEdge<ComposableGenotype, ComposablePhenotype<?>>> { - - /** Set of {@link IExplorationEncoding} types that can be obtained from the SystemModelAdapter. */ - protected Set<Class<? extends IExplorationEncoding>> sysModelEncodings; - - /** Internal graph representation for the execution order of {@link Creator}s. */ - private HashSet<ComposableCreator<?>> registeredCreators = new HashSet<>(); - - /** Constructor. */ - public DecoderDependencyGraph(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - Set<Class<? extends IExplorationEncoding>> pTypeCollection) { - super(pTypeCollection, IExplorationEncoding.class); - sysModelEncodings = systemModelAdapter.getRegisteredEncodingTypes(); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - protected void checkMissingDependencies() throws MissingDependencyException { - for(ComposableDecoder<?, ?> dec : operatorExecOrder) { - Collection<Class<?>> reqEncodings = dec.getRequiredTypes(); - for(Class<?> reqEnc : reqEncodings) { - if(!dependencyDagGraph - .containsVertex((Class<? extends IExplorationEncoding>)reqEnc) && - !registeredCreators.stream().anyMatch( - c -> c.getCreatedEncoding().equals(reqEnc)) && - !sysModelEncodings.contains(reqEnc)) { - throw new MissingDependencyException(dec, - (Class<? extends IExplorationEncoding>)reqEnc, ""); - } - } - } - } - - /** {@inheritDoc} */ - @Override - protected Comparator<ComposableDecoder<ComposableGenotype, ComposablePhenotype<?>>> - getSubExecListComparator() { - return new Comparator<ComposableDecoder<ComposableGenotype, ComposablePhenotype<?>>>() { - @Override - public int compare(ComposableDecoder<ComposableGenotype, ComposablePhenotype<?>> o1, - ComposableDecoder<ComposableGenotype, ComposablePhenotype<?>> o2) { - if(o1 instanceof ConstraintGenerationDecoder && - o2 instanceof ConstraintGenerationDecoder) { - return 0; - } else if(o1 instanceof ConstraintGenerationDecoder) { - return 1; - } else if(o2 instanceof ConstraintGenerationDecoder) { - return -1; - } - return 0; - } - }; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/graph/DecoderEdge.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/graph/DecoderEdge.java deleted file mode 100644 index d30d376f8b304917b11e7139fb7edba9430a4894..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/graph/DecoderEdge.java +++ /dev/null @@ -1,36 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DecoderEdge.java 3451 2016-09-02 13:36:29Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.graph.DependencyEdge; - -/** - * Wrapper for the edges in the {@link DecoderDependencyGraph} --> {@link ComposableDecoder}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3451 $ - * @ConQAT.Rating RED Hash: 64E3C97868042CCA97F591E915895C14 - */ -public class DecoderEdge<G extends ComposableGenotype, P extends ComposablePhenotype<?>> extends - DependencyEdge<ComposableDecoder<G, P>> { - // All required implementation is to found in the parent class. -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/ComposablePhenotype.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/ComposablePhenotype.java deleted file mode 100644 index 306f7be96b1867ef96464d5878f3a913430b6fdc..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/ComposablePhenotype.java +++ /dev/null @@ -1,39 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComposablePhenotype.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.opt4j.core.Genotype; - -/** - * Interface for {@link Phenotype}s that compose a {@link CompositePhenotype}. Counterpart to - * {@link ComposableGenotype}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: E7831730F898048117BBACDB1CA242B0 - */ -public interface ComposablePhenotype<G extends Genotype> extends Phenotype { - - /** - * Returns the type which shall be used to register the {@link ComposablePhenotype} at its - * containing {@link CompositePhenotype}. - */ - Class<? extends ComposablePhenotype<?>> getPTypeToRegister(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/CompositePhenotype.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/CompositePhenotype.java deleted file mode 100644 index 6db60e8cec76c4dce9ef0aca59e72bf0b773bee2..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/CompositePhenotype.java +++ /dev/null @@ -1,64 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CompositePhenotype.java 3072 2016-06-22 11:08:57Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype; - -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.opt4j.core.Genotype; -import org.opt4j.core.genotype.CompositeGenotype; - -/** - * Interface for {@link CompositePhenotype}s generated by decoders which operate on - * {@link CompositeGenotype}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3072 $ - * @ConQAT.Rating RED Hash: D900549C15CC8FC478E1ACB43598C19F - */ -public interface CompositePhenotype<G extends Genotype> - extends - Phenotype, - Iterable<Entry<Class<? extends ComposablePhenotype<? extends Genotype>>, ComposablePhenotype<? extends Genotype>>> { - - /** - * Returns the {@link ComposablePhenotype} that corresponds to the given - * {@link ComposablePhenotype} class. - */ - <GT extends Genotype, CP extends ComposablePhenotype<GT>> CP getSubPhenotype( - Class<CP> subPhenotype); - - /** - * Defines a correspondence between a {@link ComposableGenotype} class and its - * {@link ComposablePhenotype}. - */ - <GT extends Genotype, CP extends ComposablePhenotype<GT>> void putSubPhenotype( - Class<CP> subGenotype, CP curPhenotype); - - /** - * Returns the collection of {@link ComposablePhenotype}s that make up this - * {@link ComposableGenotype}. - */ - List<ComposablePhenotype<? extends Genotype>> getSubPhenotypes(); - - /** Returns the Class -> {@link Phenotype} entries of the enclosed map. */ - Set<Class<? extends ComposablePhenotype<? extends Genotype>>> keySet(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/CompositePhenotypeBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/CompositePhenotypeBase.java deleted file mode 100644 index b1a6cf55f40e20fe328f40d273517ec905b8e9e6..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/CompositePhenotypeBase.java +++ /dev/null @@ -1,88 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CompositePhenotypeBase.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; - -import org.opt4j.core.Genotype; - -/** - * Base class for {@link CompositePhenotype}s which consists of {@link ComposablePhenotype}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 031F7511012F0AAF6A3F3D9ED53B493E - */ -public abstract class CompositePhenotypeBase<G extends Genotype> implements CompositePhenotype<G> { - - /** - * Map which correlates the {@link ComposablePhenotype} classes with their corresponding - * {@link ComposablePhenotype}s, out of which this {@link CompositePhenotype} consists. - */ - protected LinkedHashMap<Class<? extends ComposablePhenotype<? extends Genotype>>, ComposablePhenotype<? extends Genotype>> subPhenotypes = - new LinkedHashMap<>(); - - /** {@inheritDoc} */ - @Override - public <GT extends Genotype, CP extends ComposablePhenotype<GT>> CP getSubPhenotype( - Class<CP> subGenotypeClass) { - for(Entry<Class<? extends ComposablePhenotype<? extends Genotype>>, ComposablePhenotype<? extends Genotype>> composablePheno : subPhenotypes - .entrySet()) { - if(subGenotypeClass.isAssignableFrom(composablePheno.getKey())) { - @SuppressWarnings("unchecked") CP retPhenotype = (CP)composablePheno.getValue(); - return retPhenotype; - } - } - return null; - } - - /** {@inheritDoc} */ - @Override - public <GT extends Genotype, CP extends ComposablePhenotype<GT>> void putSubPhenotype( - Class<CP> subGenotypeClass, CP subPhenotype) { - subPhenotypes.put(subGenotypeClass, subPhenotype); - } - - /** {@inheritDoc} */ - @Override - public List<ComposablePhenotype<?>> getSubPhenotypes() { - ArrayList<ComposablePhenotype<?>> retList = new ArrayList<>(); - subPhenotypes.values().stream().forEachOrdered(p -> retList.add(p)); - return retList; - } - - /** {@inheritDoc} */ - @Override - public - Iterator<Entry<Class<? extends ComposablePhenotype<? extends Genotype>>, ComposablePhenotype<? extends Genotype>>> - iterator() { - return subPhenotypes.entrySet().iterator(); - } - - /** {@inheritDoc} */ - @Override - public Set<Class<? extends ComposablePhenotype<? extends Genotype>>> keySet() { - return subPhenotypes.keySet(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/FlatPhenotypeMap.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/FlatPhenotypeMap.java deleted file mode 100644 index a361cc7b1818413a2e23884da974c6788a282959..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/FlatPhenotypeMap.java +++ /dev/null @@ -1,91 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FlatPhenotypeMap.java 3478 2016-09-09 09:54:32Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; - -/** - * Allows to capture the already created/decoded {@link Phenotype}s and pass them to their successor - * creators/decoders as a flat map that associates a {@link Phenotype}s type with its instance. - * Using a {@link CompositePhenotype} for this job allows to "protect" the internal map from - * unintended read/write operations. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3478 $ - * @ConQAT.Rating RED Hash: E96855061F4A94C84D2AE992FF86D03C - */ -public class FlatPhenotypeMap<T extends Phenotype> extends ExplorationEncodingMap<T> { - - /** Constructor. */ - public FlatPhenotypeMap(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** - * Returns the {@link Phenotype} of the given type. If no {@link Phenotype} of the given type - * can be found, {@code null} is returned. - */ - @Override - public <P extends T> P getEncoding(Class<P> subGenotypeClass) { - P phenotype = getEncodingInternal(subGenotypeClass); - if(phenotype == null) { - if(IExplorationEncoding.class.isAssignableFrom(subGenotypeClass)) { - @SuppressWarnings("unchecked") Class<IExplorationEncoding> inputEncoding = - (Class<IExplorationEncoding>)subGenotypeClass; - assert (systemModelAdapter != null) : "The SystemModelAdapter is required for CompositePhenotypes as an alternate source of input encodings."; - @SuppressWarnings("unchecked") P encoding = - (P)systemModelAdapter.getInputEncoding(inputEncoding); - phenotype = encoding; - } - } - - return phenotype; - } - - /** - * Determines whether {@code this} {@link FlatPhenotypeMap} contains {@link ComposablePhenotype} - * s of all given types, or it is able to retrieve the demanded types via the - * {@link SystemModelAdapter}. - */ - @SuppressWarnings("unchecked") - public <P extends T> boolean containsAll(Collection<Class<?>> phenoCollection) { - return phenoCollection.stream().allMatch(p -> contains((Class<P>)p)); - } - - /** - * Determines whether {@code this} {@link FlatPhenotypeMap} provides access to a - * {@link Phenotype} of the given type. - */ - public <P extends T> boolean contains(Class<P> phenotypeType) { - return getEncoding(phenotypeType) != null; - } - - /** - * Returns {@code this} {@link FlatPhenotypeMap} as an {@link ExplorationEncodingMap} such that - * its entries are represented by {@link IExplorationEncoding}s. - */ - @SuppressWarnings("unchecked") - public ExplorationEncodingMap<IExplorationEncoding> asExplorationEncoding() { - return (ExplorationEncodingMap<IExplorationEncoding>)this; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/Phenotype.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/Phenotype.java deleted file mode 100644 index 483fecba55293625ce877ac0acf4f4c5affdd912..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/phenotype/Phenotype.java +++ /dev/null @@ -1,32 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: Phenotype.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype; - -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; - -/** - * Interface for phenotypes (not present any more in Opt4J). - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: CF18332ABFE93B0A6963E2AD1EF119E5 - */ -public interface Phenotype extends IExplorationEncoding { - // Marker interface. -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/problem/CompositeProblemModuleBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/problem/CompositeProblemModuleBase.java deleted file mode 100644 index abbdb4470096c40ce175418e168a37413ab66feb..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/compositegene/problem/CompositeProblemModuleBase.java +++ /dev/null @@ -1,97 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CompositeProblemModuleBase.java 3062 2016-06-20 17:59:20Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.problem; - -import java.util.List; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.create.ComposableCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.create.CompositeCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.CompositeDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.CompositePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.ProblemModuleBase; -import org.jgrapht.experimental.dag.DirectedAcyclicGraph.CycleFoundException; -import org.opt4j.core.Genotype; -import org.opt4j.core.genotype.CompositeGenotype; -import org.opt4j.core.problem.Creator; -import org.opt4j.core.problem.Decoder; -import org.opt4j.core.problem.ProblemModule; - -/** - * Base class for {@link ProblemModule}s which are described by sub {@link ProblemModule}s. Used for - * optimization problems that are described by a {@link ComposableGenotype}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3062 $ - * @ConQAT.Rating RED Hash: 1848FD2A769F27CED17C360D4EA2FEC9 - */ -public abstract class CompositeProblemModuleBase<C extends CompositeGenotype<Class<? extends ComposableGenotype>, ComposableGenotype>, P extends CompositePhenotype<?>, CD extends CompositeDecoder<C, P>> - extends ProblemModuleBase<C, CompositeCreator<C>, CD> { - - /** - * Helper method to register sub problems at the composite problem description (module). - * - * @param subGenotypeClass - * {@link Genotype} (class) encoding the problem description. - * @param subCreator - * {@link Creator} for initial encodings of the particular sub problem (starting - * points). - * @param subDecoder - * {@link Decoder} to derive sub-solutions from the sub encodings. If the given - * {@code subDecoder} equals {@code null} no {@link Decoder} will be registered for - * the given {@subGenotype}. - * @throws CycleFoundException - */ - // TODO: document exception. - public - <CG extends ComposableGenotype, CP extends ComposablePhenotype<CG>, CC extends ComposableCreator<CG>, D extends ComposableDecoder<CG, CP>> - void registerSubProblem(Class<CG> subGenotypeClass, CC subCreator, D subDecoder) - throws CycleFoundException { - creator.registerSubCreator(subCreator); - if(subDecoder != null) { - decoder.registerSubDecoder(subGenotypeClass, subDecoder); - } - } - - /** - * Helper method to register sub problems at the composite problem description (module). - * - * @param subGenotypeClass - * Genotype (class) encoding the problem description. - * @param subCreator - * Creator for initial encodings of the particular sub problem (starting points). - * @param subDecoders - * Collection of {@link Decoder}s to derive sub-solutions from the sub encodings. - * @throws CycleFoundException - */ - // TODO: document exception. - public - <CG extends ComposableGenotype, CP extends ComposablePhenotype<CG>, CC extends ComposableCreator<CG>, D extends ComposableDecoder<CG, CP>> - void registerSubProblem(Class<CG> subGenotypeClass, CC subCreator, List<D> subDecoders) - throws CycleFoundException { - creator.registerSubCreator(subCreator); - if(subDecoders != null) { - for(D currDecoder : subDecoders) { - decoder.registerSubDecoder(subGenotypeClass, currDecoder); - } - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/decode/ConstraintGenerationDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/decode/ConstraintGenerationDecoder.java deleted file mode 100644 index 123ab4d95f6a0b3525030c0d406f20998a88fe3a..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/decode/ConstraintGenerationDecoder.java +++ /dev/null @@ -1,34 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.decode; - -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.opt4j.core.problem.Decoder; - -/** - * Marker interface for {@link Decoder}s that produce constraints that are added to an - * {@link IExplorationEncoding} - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 641F6187743A7C8CFA7B53D6C5B0A9E5 - */ -public interface ConstraintGenerationDecoder { - // Marker interface. -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/encoding/ConstrainedEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/encoding/ConstrainedEncoding.java deleted file mode 100644 index bf88b7c8f649e74839637817e5dfacf2de515904..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/extensions/encoding/ConstrainedEncoding.java +++ /dev/null @@ -1,98 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.encoding; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.model.ExplorationConstraint; - -import com.google.common.collect.Multimap; - -/** - * {@link ConstrainedEncoding}s are {@link IExplorationEncoding}s that may carry constraints which - * limit the allowed operation performed on them. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: FB163322A476AC709F455BCD72E8B64E - */ -public interface ConstrainedEncoding extends IExplorationEncoding { - - /** - * Returns the collection of {@link ExplorationConstraint}s that are of the given type. - * - * @param type - * of the {@link ExplorationConstraint}s. - * @return Collection of {@link ExplorationConstraint}s of the given type, or an empty - * collection if none exist. - */ - <T extends ExplorationConstraint<?>> Collection<T> getConstraintsOf(Class<T> type); - - /** - * Returns the {@link Multimap} containing the complete set of constraints defined on a - * particular encoding which can be queried by their type. - */ - Multimap<Class<? extends ExplorationConstraint<?>>, ExplorationConstraint<?>> getConstraints(); - - /** - * Adds a given collection of {@link ExplorationConstraint}s to the encoding which is identified - * by the given type. Existing {@link ExplorationConstraint}s identified by the same type are - * replaced. - * - * @param type - * to identify the {@link ExplorationConstraint}s. - * @param constraints - * Collection of {@link ExplorationConstraint}s to be added to the encoding. - */ - <T extends ExplorationConstraint<?>> void replaceConstraints(Class<T> type, - Collection<T> constraints); - - /** - * Replaces all existing constraint sets with identical keys with those present in the given - * map. - * - * @param constraintMap - * Replacement constraints. - */ - <T extends ExplorationConstraint<?>> void replaceConstraints( - Multimap<Class<? extends T>, T> constraintMap); - - /** - * Adds the given {@code constraint} to the set of constraints that is identified by the given - * {@code type}. - * - * @param type - * Constraint set identifier. - * @param constraint - * Constraint to add to possibly existing constraint set. - */ - <T extends ExplorationConstraint<?>> void putConstraint(Class<T> type, T constraint); - - /** - * Removes the given {@code constraint} from the set of constraints that is identified by the - * given {@code type}. - * - * @param type - * Constraint set identifier. - * @param constraint - * Constraint to remove from the constraint set. - */ - <T extends ExplorationConstraint<?>> void removeConstraint(Class<T> type, T constraint); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/mating/MatingCrossoverMutateRepair.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/mating/MatingCrossoverMutateRepair.java deleted file mode 100644 index d647178aa47e9819438702c2dd4d609d4b7a55e6..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/mating/MatingCrossoverMutateRepair.java +++ /dev/null @@ -1,155 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MatingCrossoverMutateRepair.java 3885 2016-11-11 09:41:01Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.mating; - -import static org.fortiss.af3.exploration.alg.service.ExplorationService.getService; - -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.alg.service.IExplorationRepairService; -import org.fortiss.af3.exploration.alg.service.IRepairModule; -import org.opt4j.core.Genotype; -import org.opt4j.core.Individual; -import org.opt4j.core.IndividualFactory; -import org.opt4j.core.common.random.Rand; -import org.opt4j.core.genotype.CompositeGenotype; -import org.opt4j.operators.copy.Copy; -import org.opt4j.operators.crossover.Crossover; -import org.opt4j.operators.crossover.Pair; -import org.opt4j.operators.mutate.Mutate; -import org.opt4j.operators.mutate.MutationRate; -import org.opt4j.optimizers.ea.Coupler; -import org.opt4j.optimizers.ea.CrossoverRate; -import org.opt4j.optimizers.ea.Mating; -import org.opt4j.optimizers.ea.MatingCrossoverMutate; - -import com.google.inject.Inject; -import com.google.inject.name.Named; - -/** - * {@link Mating} module that extends {@link MatingCrossoverMutate} by providing an additional - * repair mechanism. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3885 $ - * @ConQAT.Rating RED Hash: 61353E5AB421A8456F8BD8517C8C971D - */ -public class MatingCrossoverMutateRepair extends MatingCrossoverMutate { - - /** References the input model. */ - @Inject - @Named("SystemModelAdapter") - private SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** - * Constructor for the {@link MatingCrossoverMutateRepair} module which extends - * {@link MatingCrossoverMutate}. - */ - @Inject - public MatingCrossoverMutateRepair(Crossover<Genotype> crossover, Mutate<Genotype> mutate, - Copy<Genotype> copy, Coupler coupler, CrossoverRate crossoverRate, - MutationRate mutationRate, Rand random, IndividualFactory individualFactory) { - super(crossover, mutate, copy, coupler, crossoverRate, mutationRate, random, - individualFactory); - } - - /** {@inheritDoc} */ - @Override - protected Pair<Individual> mate(Individual parent1, Individual parent2, boolean doCrossover) { - Individual repaired1; - Individual repaired2; - try { - repaired1 = repairGenotype(parent1); - repaired2 = repairGenotype(parent2); - } catch(ExplorationException e) { - // Opt4J does not allow to throw Exceptions here. - throw new RuntimeException(e); - } - - Pair<Individual> pair; - if(repaired1 == null && repaired2 == null) { - pair = super.mate(parent1, parent2, doCrossover); - } else if(repaired1 == null) { - pair = super.mate(parent1, repaired2, doCrossover); - } else if(repaired2 == null) { - pair = super.mate(repaired1, parent2, doCrossover); - } else { - pair = new Pair<Individual>(repaired1, repaired2); - } - - // TODO #checking: Add a final check here, to capture repair errors. - - return pair; - } - - /** - * Triggers the repair method for {@link Individual}s. - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - private Individual repairGenotype(Individual ind) throws ExplorationException { - boolean isRepaired = false; - Genotype genotype = ind.getGenotype(); - - for(IRepairModule<?> repairModule : getService(IExplorationRepairService.class) - .getRepairFunctionsOf(genotype, systemModelAdapter)) { - if(repairModule.needsRepair(genotype, ind.getObjectives().getValues())) { - ComposableGenotype copiedGenotype = (ComposableGenotype)copy.copy(genotype); - repairModule.repairGenotype(copiedGenotype, ind.getObjectives().getValues()); - isRepaired = true; - } - } - - if(genotype instanceof CompositeGenotype<?, ?>) { - @SuppressWarnings("unchecked") Queue<ComposableGenotype> traversalQueue = - new LinkedList<>(((CompositeGenotype<?, ComposableGenotype>)genotype).values()); - while(!traversalQueue.isEmpty()) { - ComposableGenotype curGenotype = traversalQueue.poll(); - List<IRepairModule<ComposableGenotype>> repairModules = - getService(IExplorationRepairService.class).getRepairFunctionsOf( - curGenotype, systemModelAdapter); - for(IRepairModule<?> curRepairModule : repairModules) { - if(curRepairModule.needsRepair(curGenotype, ind.getObjectives().getValues())) { - ComposableGenotype copiedGenotype = - (ComposableGenotype)copy.copy(curGenotype); - curRepairModule.repairGenotype(copiedGenotype, ind.getObjectives() - .getValues()); - isRepaired = true; - } - } - - if(curGenotype instanceof CompositeGenotype) { - @SuppressWarnings("unchecked") CompositeGenotype<?, ComposableGenotype> castedGenotype = - (CompositeGenotype<?, ComposableGenotype>)curGenotype; - traversalQueue.addAll(castedGenotype.values()); - } - } - } - - return isRepaired ? individualFactory.create(genotype) : null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/mating/MatingCrossoverMutateRepairModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/mating/MatingCrossoverMutateRepairModule.java deleted file mode 100644 index a5deb78e2236a9686ce9580c428f32d6549c361b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/mating/MatingCrossoverMutateRepairModule.java +++ /dev/null @@ -1,63 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MatingCrossoverMutateRepairModule.java 3478 2016-09-09 09:54:32Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.mating; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.opt4j.optimizers.ea.Mating; -import org.opt4j.optimizers.ea.MatingModule; - -import com.google.inject.Provides; -import com.google.inject.Singleton; -import com.google.inject.name.Named; -import com.google.inject.name.Names; - -/** - * Guice module that binds the {@link MatingCrossoverMutateRepairModule} to Opt4J. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3478 $ - * @ConQAT.Rating RED Hash: 6444B42A03FC91F3C8FB63EF09DD8E36 - */ -public class MatingCrossoverMutateRepairModule extends MatingModule { - - /** References the input model adapter. */ - private final SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Constructor. */ - public MatingCrossoverMutateRepairModule(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } - - /** {@inheritDoc} */ - @Override - protected void config() { - binder().bind(Mating.class).to(MatingCrossoverMutateRepair.class); - - binder().bind(SystemModelAdapter.class).annotatedWith(Names.named("SystemModelAdapter")) - .toInstance(systemModelAdapter); - } - - /** Returns the systemModelAdapter referenced by {@code this} module. */ - @Provides - @Singleton - @Named("SystemModelAdapter") - public SystemModelAdapter<?, ?, ?, ?, ?, ?> getSystemModelAdapter() { - return systemModelAdapter; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/ComposableOperatorClassPredicate.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/ComposableOperatorClassPredicate.java deleted file mode 100644 index 1dad5f6206ba654edae942250e18baa72a5d91b3..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/ComposableOperatorClassPredicate.java +++ /dev/null @@ -1,125 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComposableOperatorClassPredicate.java 1249 2015-09-10 14:54:25Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator; - -import java.util.List; -import java.util.Objects; - -import org.apache.commons.lang.ClassUtils; -import org.opt4j.core.Genotype; -import org.opt4j.core.genotype.CompositeGenotype; -import org.opt4j.operators.AbstractGenericOperator.OperatorClassPredicate; - -/** - * Predicate class to determine whether an operator is applicable for the given {@link Genotype}, or - * its direct superclass. Used for determine the applicability of operators to - * {@link CompositeGenotype}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 1249 $ - * @ConQAT.Rating RED Hash: 2234389B2786C685962D8E139657FA13 - */ -public class ComposableOperatorClassPredicate extends OperatorClassPredicate { - - /** - * Constructor. - * - * @param clazz - * Class of the Genotype for which the Predicate shall be constructed. - */ - public ComposableOperatorClassPredicate(Class<? extends Genotype> clazz) { - super(clazz); - } - - /** - * {@inheritDoc} - * <p> - * <b>NOTE:</b> The {@code hashCode} method from {@link OperatorClassPredicate} is overridden - * again, since some non-deterministic behaviour could be observed when using it. Using the - * class-only-based predicate instead is not an option due to our implementation of the - * operators (and the selector). - * */ - @Override - public int hashCode() { - return Objects.hash(clazz); - } - - /** {@inheritDoc} */ - @Override - public boolean equals(Object obj) { - if(this == obj) { - return true; - } - if(obj == null) { - return false; - } - if(getClass() != obj.getClass()) { - return false; - } - OperatorClassPredicate other = (OperatorClassPredicate)obj; - if(clazz == null) { - if(other.getClazz() != null) { - return false; - } - } else if(!clazz.equals(other.getClazz())) { - return false; - } - return true; - } - - /** {@inheritDoc} */ - @Override - public boolean evaluate(Genotype obj) { - if(clazz.equals(obj.getClass())) { - return true; - } - // Here, we always obtain a list of classes. For unknown reasons, this not already - // defined as such in apache commons... - @SuppressWarnings("unchecked") List<Class<?>> superclassList = - ClassUtils.getAllSuperclasses(obj.getClass()); - for(Class<?> currentSuperclass : superclassList) { - if(Genotype.class.isAssignableFrom(currentSuperclass)) { - @SuppressWarnings({"unchecked"}) ComposableOperatorClassPredicate superPredicate = - new ComposableOperatorClassPredicate( - (Class<? extends Genotype>)currentSuperclass); - if(this.equals(superPredicate)) { - return true; - } - } - } - - // Here, we always obtain a list of classes. For unknown reasons, this not already - // defined as such in apache commons... - @SuppressWarnings("unchecked") List<Class<?>> implementedInterfaces = - ClassUtils.getAllInterfaces(obj.getClass()); - for(Class<?> currentInterface : implementedInterfaces) { - // if(Genotype.class.isAssignableFrom(currentInterface)) { - @SuppressWarnings({"unchecked"}) ComposableOperatorClassPredicate superPredicate = - new ComposableOperatorClassPredicate( - (Class<? extends Genotype>)currentInterface); - if(this.equals(superPredicate)) { - return true; - } - // } - } - - return false; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/OperatorUtil.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/OperatorUtil.java deleted file mode 100644 index 170935d451aa888a6882bc212bf7b482bfabbf55..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/OperatorUtil.java +++ /dev/null @@ -1,76 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: OperatorUtil.java 1249 2015-09-10 14:54:25Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection.IOperatorSelector; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection.OperatorSelectorPredicate; -import org.opt4j.core.Genotype; -import org.opt4j.core.optimizer.Operator; -import org.opt4j.operators.AbstractGenericOperator.OperatorPredicate; - -import com.google.inject.Binder; -import com.google.inject.TypeLiteral; -import com.google.inject.multibindings.MapBinder; - -/** - * This module groups mutation operators that affect the mapping of tasks to execution units. - * - * Base class for mutate operator module that enables the registration of pre-constructed operators, - * which thus can be constructed using a non-default constructor. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 1249 $ - * @ConQAT.Rating RED Hash: DDCC5E6C8C5BE9951DE4A5546F27D114 - */ -public class OperatorUtil { - - /** - * Registers a pre-constructed operator instance with the Opt4J framework, i.e. an operator that - * can be built using a non-default constructor and that thus can be based on external state. - */ - public static <O extends Operator<?>> void addOperatorInstance(O operator, - IOperatorSelector operatorSelector, Binder binder, TypeLiteral<O> typeLiteral) { - addOperatorMapBinding(binder, operator, typeLiteral, new OperatorSelectorPredicate( - operator, operatorSelector)); - } - - /** - * Registers a pre-constructed operator instance with the Opt4J framework, i.e. an operator that - * can be built using a non-default constructor and that thus can be based on external state. - * The operator will be only applied to the given {@link Genotype}. - */ - public static <G extends Genotype, O extends Operator<?>> void addOperatorInstance( - Class<G> genotypeType, O operator, IOperatorSelector operatorSelector, Binder binder, - TypeLiteral<O> typeLiteral) { - addOperatorMapBinding(binder, operator, typeLiteral, new OperatorSelectorPredicate( - operator, new ComposableOperatorClassPredicate(genotypeType), operatorSelector)); - } - - /** Registers a pre-constructed operator and predicate instance with the Opt4J framework. */ - private static <O extends Operator<?>> void addOperatorMapBinding(Binder binder, O operator, - TypeLiteral<O> typeLiteral, OperatorSelectorPredicate predicate) { - // This is inspired from org.opt4j.operators.OperatorModule.addOperator(), which does not - // allow to pass parameters to the constructor of the operators. Hence, a pre-constructed - // mutate operator is bound here (using toInstance() instead of to()). - MapBinder<OperatorPredicate, O> map = - MapBinder.newMapBinder(binder, new TypeLiteral<OperatorPredicate>() { // empty - }, typeLiteral); - map.addBinding(predicate).toInstance(operator); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/safetyfunctionarch/CopySafetyFunctionArch.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/safetyfunctionarch/CopySafetyFunctionArch.java deleted file mode 100644 index 921dddbe3dc80468b5d10f33e28f3c8b13abce7c..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/safetyfunctionarch/CopySafetyFunctionArch.java +++ /dev/null @@ -1,38 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CopySafetyFunctionArch.java 2686 2016-05-04 16:23:35Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.copy.safetyfunctionarch; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.opt4j.operators.copy.Copy; - -/** - * Operator that creates copies of a {@link SafetyFunctionArchEncoding}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 2686 $ - * @ConQAT.Rating RED Hash: AEB159C26237DB308778A312705CE363 - */ -public class CopySafetyFunctionArch implements Copy<SafetyFunctionArchEncoding<?>> { - - /** {@inheritDoc} */ - @Override - public SafetyFunctionArchEncoding<?> copy(SafetyFunctionArchEncoding<?> other) { - return (SafetyFunctionArchEncoding<?>)other.clone(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/safetyfunctionarch/CopySafetyFunctionArchModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/safetyfunctionarch/CopySafetyFunctionArchModule.java deleted file mode 100644 index 5efa1a5fa490d6ddb199372df6b512376c4fa7a4..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/safetyfunctionarch/CopySafetyFunctionArchModule.java +++ /dev/null @@ -1,38 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CopySafetyFunctionArchModule.java 2686 2016-05-04 16:23:35Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.copy.safetyfunctionarch; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.opt4j.operators.copy.CopyModule; - -/** - * Opt4J module for the general copy operator of {@link SafetyFunctionArchEncoding}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 2686 $ - * @ConQAT.Rating RED Hash: D4570F673FCD314E8A75337E3675DE79 - */ -public class CopySafetyFunctionArchModule extends CopyModule { - - /** {@inheritDoc} */ - @Override - protected void config() { - addOperator(CopySafetyFunctionArch.class); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/taskmapping/CopyAbstractTaskMapping.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/taskmapping/CopyAbstractTaskMapping.java deleted file mode 100644 index 64bb6a2e5c0eb36688e7713e948947f853ac5efb..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/taskmapping/CopyAbstractTaskMapping.java +++ /dev/null @@ -1,38 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CopyAbstractTaskMapping.java 2686 2016-05-04 16:23:35Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.copy.taskmapping; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.opt4j.operators.copy.Copy; - -/** - * Operator that creates copies of a {@link TaskMappingEncoding}s. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 2686 $ - * @ConQAT.Rating RED Hash: 2F82DB5417A0EC3DBE08815181CBCE65 - */ -public class CopyAbstractTaskMapping implements Copy<AbstractTaskMappingEncoding> { - /** {@inheritDoc} */ - @Override - public AbstractTaskMappingEncoding copy(AbstractTaskMappingEncoding other) { - return (AbstractTaskMappingEncoding)other.clone(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/taskmapping/CopyInstanceTaskMapping.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/taskmapping/CopyInstanceTaskMapping.java deleted file mode 100644 index 0025f13eea89765221fad52a6a913a9a9f07710e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/taskmapping/CopyInstanceTaskMapping.java +++ /dev/null @@ -1,38 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CopyInstanceTaskMapping.java 2686 2016-05-04 16:23:35Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.copy.taskmapping; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; -import org.opt4j.operators.copy.Copy; - -/** - * Operator that creates copies of a {@link TaskMappingEncoding}s. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 2686 $ - * @ConQAT.Rating RED Hash: E5C2EBB2C415EF144F959F4FB7D04AF7 - */ -public class CopyInstanceTaskMapping implements Copy<InstantiatedTaskMappingEncoding<?>> { - /** {@inheritDoc} */ - @Override - public InstantiatedTaskMappingEncoding<?> copy(InstantiatedTaskMappingEncoding<?> other) { - return (InstantiatedTaskMappingEncoding<?>)other.clone(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/taskmapping/CopyTaskMappingModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/taskmapping/CopyTaskMappingModule.java deleted file mode 100644 index 563792c4298416de34fb88a7e60ee727b037725f..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/copy/taskmapping/CopyTaskMappingModule.java +++ /dev/null @@ -1,38 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CopyTaskMappingModule.java 2686 2016-05-04 16:23:35Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.copy.taskmapping; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.opt4j.operators.copy.CopyModule; - -/** - * Opt4J module for the general copy operator of {@link TaskMappingEncoding}s. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 2686 $ - * @ConQAT.Rating RED Hash: A9768F7453202508B2E8773736F2F58E - */ -public class CopyTaskMappingModule extends CopyModule { - /** {@inheritDoc} */ - @Override - protected void config() { - addOperator(CopyAbstractTaskMapping.class); - addOperator(CopyInstanceTaskMapping.class); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverAbstractTaskMappingModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverAbstractTaskMappingModule.java deleted file mode 100644 index 40d01ef001f8f5ac0e0ac9858b50247378132351..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverAbstractTaskMappingModule.java +++ /dev/null @@ -1,55 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CrossoverAbstractTaskMappingModule.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover; - -import org.fortiss.af3.exploration.alg.dse.TaskMappingFactory; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; - -/** - * Crossover module selecting the {@link CrossoverRandManyAllocation} operator to be applied on - * {@link AbstractTaskMappingEncoding}s. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 50C0A8E171D19E506A8D065333E5372D - */ -public class CrossoverAbstractTaskMappingModule extends CrossoverOperatorModuleBase { - /** Crossover rate */ - private double rate; - - /** References the {@link SystemModelAdapter} that handles the input models. */ - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Constructor where execution model and mutation rate has to be specified */ - public CrossoverAbstractTaskMappingModule( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, double rate) { - this.systemModelAdapter = systemModelAdapter; - this.rate = rate; - } - - /** {@inheritDoc} */ - @Override - public void config() { - super.config(); - - addOperatorInstance(AbstractTaskMappingEncoding.class, TaskMappingFactory.getInstance() - .createCrossoverRandManyAllocationOperator(systemModelAdapter, rate)); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverAllocationBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverAllocationBase.java deleted file mode 100644 index 3369a2caca205f62bdad58d56de8abeddb3a5706..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverAllocationBase.java +++ /dev/null @@ -1,116 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CrossoverAllocationBase.java 3885 2016-11-11 09:41:01Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover; - -import static java.lang.Math.max; -import static java.lang.Math.min; - -import java.util.ArrayList; -import java.util.List; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.comm.constraint.InternalIsolatedCommunicationSet; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.random.RandomExploration; -import org.opt4j.operators.crossover.Crossover; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; - -/** - * Base class for crossover operations on the allocations of {@link IDeployableComponentAdapter}s to - * {@link IExecutionUnitAdapter}s. It requires two parent {@link TaskMappingEncoding}s whose - * allocations are swapped. - * - * @author huang - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3885 $ - * @ConQAT.Rating RED Hash: 174AC325675EB3679369664F9985048D - */ -public abstract class CrossoverAllocationBase<S extends TaskMappingEntry, T extends TaskMappingEncoding<S>> - implements Crossover<T> { - - /** Reference to the {@link SystemModelAdapter} which handles the input models. */ - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Cross-over rate */ - protected double rate; - - /** Random generator */ - protected RandomExploration rand = RandomExploration.getInstance(); - - /** Constructor that allows to set the cross-over rate */ - public CrossoverAllocationBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - double rate) { - this.systemModelAdapter = systemModelAdapter; - this.rate = rate; - } - - /** - * Performs the actual crossover (swapping) operation between the offspring encodings {#link - * newEncoding1} and {#link newEncoding2} for the allocations/mapping of the given - * {@link IDeployableComponentAdapter}. - */ - protected void crossoverAllocation(IDeployableComponentAdapter<?> deployableComponent, - T newEncoding1, T newEncoding2) { - List<S> newAssignedResources1 = - new ArrayList<>(newEncoding1.getMappingEntriesOf(deployableComponent)); - List<S> newAssignedResources2 = - new ArrayList<>(newEncoding2.getMappingEntriesOf(deployableComponent)); - - // Only swap as many entries as the smaller list has -> avoid inconsistencies due to wrong - // replication number. - BiMap<S, S> swapMap = HashBiMap.create(); - int size1 = newAssignedResources1.size(); - int size2 = newAssignedResources2.size(); - int sizeDiff = max(size1, size2) - min(size1, size2); - int offset = rand.nextInt(sizeDiff + 1); - for(int i = 0; i < min(size1, size2); i++) { - S elem1 = - size1 > size2 ? newAssignedResources1.get(i + offset) : newAssignedResources1 - .get(i); - S elem2 = - size2 > size1 ? newAssignedResources2.get(i + offset) : newAssignedResources2 - .get(i); - swapMap.put(elem1, elem2); - if(size1 > size2) { - newAssignedResources1.set(i + offset, elem2); - newAssignedResources2.set(i, elem1); - } else { - newAssignedResources1.set(i, elem2); - newAssignedResources2.set(i + offset, elem1); - } - } - // TODO: develop concept to update internal constraints automatically. - for(InternalIsolatedCommunicationSet commConstr : newEncoding1 - .getConstraintsOf(InternalIsolatedCommunicationSet.class)) { - commConstr.replaceEntriesIfPresent(swapMap); - } - for(InternalIsolatedCommunicationSet commConstr : newEncoding2 - .getConstraintsOf(InternalIsolatedCommunicationSet.class)) { - commConstr.replaceEntriesIfPresent(swapMap.inverse()); - } - - newEncoding1.setAssignedResources(deployableComponent, newAssignedResources1); - newEncoding2.setAssignedResources(deployableComponent, newAssignedResources2); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverOperatorModuleBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverOperatorModuleBase.java deleted file mode 100644 index 05297def56cd281661e4b1090b0600d8ee2cb9a5..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverOperatorModuleBase.java +++ /dev/null @@ -1,55 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CrossoverOperatorModuleBase.java 1888 2015-11-30 16:49:41Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.OperatorUtil; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection.IMultiSelectorOperatorModule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection.IOperatorSelector; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection.RoundRobinOperatorSelector; -import org.opt4j.core.Genotype; -import org.opt4j.operators.crossover.BasicCrossoverModule; -import org.opt4j.operators.crossover.Crossover; - -/** - * Base class for crossover operator module that enables the registration of pre-constructed - * operators, which thus can be constructed using a non-default constructor. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 1888 $ - * @ConQAT.Rating RED Hash: 21908DA2D5DD2AA7D9A72FACF1B2AE0C - */ -public abstract class CrossoverOperatorModuleBase extends BasicCrossoverModule implements - IMultiSelectorOperatorModule<Crossover<?>> { - /** Default selection strategy for crossover operators: round robin */ - private IOperatorSelector operatorSelector = new RoundRobinOperatorSelector(); - - /** {@inheritDoc} */ - @Override - public void addOperatorInstance(Class<? extends Genotype> genotypeType, - Crossover<?> crossoverOperator) { - OperatorUtil.addOperatorInstance(genotypeType, crossoverOperator, operatorSelector, - binder(), getOperatorTypeLiteral()); - } - - /** {@inheritDoc} */ - @Override - public IOperatorSelector getOperatorSelector(Class<? extends Genotype> genotypeType) { - return operatorSelector; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverRandManyAllocation.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverRandManyAllocation.java deleted file mode 100644 index ca780ee1b76a09e8546959305ad16256d7551bdd..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverRandManyAllocation.java +++ /dev/null @@ -1,69 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CrossoverRandManyAllocation.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.opt4j.operators.crossover.Pair; - -/** - * Applies the crossover operation on the allocations of {@link IDeployableComponentAdapter}s to - * {@link IExecutionUnitAdapter}s. It requires two parent {@link TaskMappingEncoding}s whose - * allocations are randomly swapped to generate two new children {@link TaskMappingEncoding}s. - * - * @author huang - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 07FECF5FE2DAA99C4E5D48B8530DA03B - */ -public class CrossoverRandManyAllocation<S extends TaskMappingEntry, T extends TaskMappingEncoding<S>> - extends CrossoverAllocationBase<S, T> { - - /** Constructor that allows to set the cross-over rate */ - public CrossoverRandManyAllocation(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - double rate) { - super(systemModelAdapter, rate); - } - - /** {@inheritDoc} */ - @Override - public Pair<T> crossover(T encoding1, T encoding2) { - @SuppressWarnings("unchecked") T newEncoding1 = (T)encoding1.clone(); - @SuppressWarnings("unchecked") T newEncoding2 = (T)encoding2.clone(); - - for(IDeployableComponentAdapter<?> deployableComponent : encoding1.getDeployedComponents()) { - if(rand.nextDouble() < rate) { - crossoverAllocation(deployableComponent, newEncoding1, newEncoding2); - } - } - - // Check whether the a modification happened, if not enforce one. - if(newEncoding1 == encoding1 || newEncoding1 == encoding2) { - int randomIdx = encoding1.getDeployedComponents().toArray().length - 1; - IDeployableComponentAdapter<?> randomlySelectedComponent = - (IDeployableComponentAdapter<?>)encoding1.getDeployedComponents().toArray()[randomIdx]; - crossoverAllocation(randomlySelectedComponent, newEncoding1, newEncoding2); - } - - return new Pair<T>(newEncoding1, newEncoding2); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverSingleAllocation.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverSingleAllocation.java deleted file mode 100644 index 814f9ad7de59d43fb28381fa8bfb07ab7071ca80..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/CrossoverSingleAllocation.java +++ /dev/null @@ -1,75 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CrossoverSingleAllocation.java 2419 2016-03-04 18:05:52Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.opt4j.operators.crossover.Pair; - -/** - * Applies the crossover operation on the allocations of {@link IDeployableComponentAdapter}s to - * {@link IExecutionUnitAdapter}s. It requires two parent {@link TaskMappingEncoding}s for which a - * single allocation is randomly swapped to generate two new children {@link TaskMappingEncoding}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 2419 $ - * @ConQAT.Rating RED Hash: 5AAE02D8C401D79ABA8552B700C459FA - */ -public class CrossoverSingleAllocation<S extends TaskMappingEntry, T extends TaskMappingEncoding<S>> - extends CrossoverAllocationBase<S, T> { - - /** Constructor that allows to set the cross-over rate */ - public CrossoverSingleAllocation(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - double rate) { - super(systemModelAdapter, rate); - } - - /** {@inheritDoc} */ - @Override - public Pair<T> crossover(T encoding1, T encoding2) { - @SuppressWarnings("unchecked") T newEncoding1 = (T)encoding1.clone(); - @SuppressWarnings("unchecked") T newEncoding2 = (T)encoding2.clone(); - - int deplCompSize = encoding1.getDeployedComponents().toArray().length; - int randomIdx = rand.nextInt(deplCompSize - 1); - IDeployableComponentAdapter<?> randomlySelectedComponent = - (IDeployableComponentAdapter<?>)encoding1.getDeployedComponents().toArray()[randomIdx]; - - // TODO: Improve Crossover operator to respect allocation constraints. - // boolean didCrossover = false; - // int randomIdx = initRandomIdx; - // for(int cnt = 0; !didCrossover && cnt < - // systemModelAdapter.getDeployableComponents().size(); cnt++) { - // - // if(newEncoding2.getAllowedAllocations(deployableComponent)); - // (IDeployableComponentAdapter)encoding1.getDeployedComponents().toArray()[randomIdx++]; - // - // randomIdx++; - // if(randomIdx == deplCompSize) { - // randomIdx = 0; - // } - // } - crossoverAllocation(randomlySelectedComponent, newEncoding1, newEncoding2); - - return new Pair<T>(newEncoding1, newEncoding2); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/NopCrossover.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/NopCrossover.java deleted file mode 100644 index ff01608fe9d7bd31e389a6f6a3eed23687ccc381..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/NopCrossover.java +++ /dev/null @@ -1,41 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: NopCrossover.java 2686 2016-05-04 16:23:35Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover; - -import org.opt4j.core.Genotype; -import org.opt4j.core.genotype.CompositeGenotype; -import org.opt4j.operators.crossover.Crossover; -import org.opt4j.operators.crossover.Pair; - -/** - * Crossover operator performing a No-Op. It is employed whenever no crossover operation shall be - * applied to {@link Genotype}s since Opt4J would use a a generic crossover operator otherwise. - * Useful for {@link CompositeGenotype}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 2686 $ - * @ConQAT.Rating RED Hash: B54DDFF5C70AD37E8EE3AEF0571D316F - */ -public class NopCrossover implements Crossover<Genotype> { - /** {@inheritDoc} */ - @Override - public Pair<Genotype> crossover(Genotype encoding1, Genotype encoding2) { - return new Pair<Genotype>(encoding1, encoding2); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/NopCrossoverInstantiatedTaskMappingModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/NopCrossoverInstantiatedTaskMappingModule.java deleted file mode 100644 index 56d24e74cf8b050be22588d9a075e0c0414dddf9..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/NopCrossoverInstantiatedTaskMappingModule.java +++ /dev/null @@ -1,40 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: NopCrossoverInstantiatedTaskMappingModule.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; - -/** - * Crossover module selecting the {@link NopCrossover} operator to be applied on - * {@link InstantiatedTaskMappingEncoding}s, i.e. no crossover operation will be applied. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 31DA03F0F41CDD7FED4B0D961D80DB62 - */ -public class NopCrossoverInstantiatedTaskMappingModule extends CrossoverOperatorModuleBase { - - /** {@inheritDoc} */ - @Override - public void config() { - super.config(); - - addOperatorInstance(InstantiatedTaskMappingEncoding.class, new NopCrossover()); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/NopCrossoverSFArchModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/NopCrossoverSFArchModule.java deleted file mode 100644 index 825b38c57026c1873e751f2f8dbfc13d5e54d0ec..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/NopCrossoverSFArchModule.java +++ /dev/null @@ -1,40 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: NopCrossoverSFArchModule.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; - -/** - * Crossover module selecting the {@link NopCrossover} operator to be applied on - * {@link SafetyFunctionArchEncoding}s, i.e. no crossover operation will be applied. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 6C8ED47DBDDB6A586C43DF7BC1BB3374 - */ -public class NopCrossoverSFArchModule extends CrossoverOperatorModuleBase { - - /** {@inheritDoc} */ - @Override - public void config() { - super.config(); - - addOperatorInstance(SafetyFunctionArchEncoding.class, new NopCrossover()); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/failSilent/CrossoverAllocationFailSilent.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/failSilent/CrossoverAllocationFailSilent.java deleted file mode 100644 index cda0485a50cd694372f463d1739c6fa145c45ca7..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/failSilent/CrossoverAllocationFailSilent.java +++ /dev/null @@ -1,41 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CrossoverAllocationFailSilent.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover.failSilent; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FailSilentTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FailSilentTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover.CrossoverRandManyAllocation; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; - -/** - * Performs the {@link CrossoverRandManyAllocation} operation on - * {@link FailSilentTaskMappingEncoding}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 50A28CFFB773ACE1EDD57017A07CBF65 - */ -public class CrossoverAllocationFailSilent extends - CrossoverRandManyAllocation<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> { - /** Constructs a resource allocation crossover operator for fail-silent execution model */ - public CrossoverAllocationFailSilent(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - double rate) { - super(systemModelAdapter, rate); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/faultDetectionVoting/CrossoverAllocationFaultDetectionVoting.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/faultDetectionVoting/CrossoverAllocationFaultDetectionVoting.java deleted file mode 100644 index c1c2c27dd661f9d71c20deee8150b6be3147cb4e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/crossover/faultDetectionVoting/CrossoverAllocationFaultDetectionVoting.java +++ /dev/null @@ -1,42 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CrossoverAllocationFaultDetectionVoting.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover.faultDetectionVoting; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FaultDetectionVotingTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FaultDetectionVotingTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover.CrossoverRandManyAllocation; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; - -/** - * Performs the {@link CrossoverRandManyAllocation} operation on - * {@link FaultDetectionVotingTaskMappingEncoding}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 6E0E6014E4C2771CF9030C91363F04CE - */ -public class CrossoverAllocationFaultDetectionVoting - extends - CrossoverRandManyAllocation<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> { - /** Constructs a resource allocation crossover operator for fail-silent execution model */ - public CrossoverAllocationFaultDetectionVoting( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, double rate) { - super(systemModelAdapter, rate); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/MutateBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/MutateBase.java deleted file mode 100644 index 48009a4026b6299207fdd85356fdf64dd5c0b91a..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/MutateBase.java +++ /dev/null @@ -1,45 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateBase.java 2620 2016-04-29 11:56:14Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.random.RandomExploration; -import org.opt4j.core.Genotype; -import org.opt4j.operators.mutate.Mutate; - -/** - * Base class for {@link Mutate} operators that provides the {@link SystemModelAdapter} and a random - * number generator. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 2620 $ - * @ConQAT.Rating RED Hash: FE76A883F5AFE8524FDC5ADB495ED106 - */ -public abstract class MutateBase<T extends Genotype> implements Mutate<T> { - /** Random generator */ - protected RandomExploration rand = RandomExploration.getInstance(); - - /** Representation of input system */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Constructs a new mutation operator for a given exploration run */ - protected MutateBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/MutateOperatorModuleBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/MutateOperatorModuleBase.java deleted file mode 100644 index ba337fa1ed20e94d910e956d2e6eec6cbce6f7f2..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/MutateOperatorModuleBase.java +++ /dev/null @@ -1,67 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateOperatorModuleBase.java 2620 2016-04-29 11:56:14Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate; - -import java.util.HashMap; -import java.util.Map; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.OperatorUtil; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection.IMultiSelectorOperatorModule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection.IOperatorSelector; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection.RoundRobinOperatorSelector; -import org.opt4j.core.Genotype; -import org.opt4j.core.optimizer.Operator; -import org.opt4j.operators.mutate.BasicMutateModule; -import org.opt4j.operators.mutate.Mutate; - -/** - * Base class for mutate operator module that enables the registration of pre-constructed operators, - * which thus can be constructed using a non-default constructor. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 2620 $ - * @ConQAT.Rating RED Hash: C4B10495D5E711BB8C62EBB6D7282D93 - */ -public abstract class MutateOperatorModuleBase extends BasicMutateModule implements - IMultiSelectorOperatorModule<Mutate<?>> { - /** - * Contains the correspondences between the {@link Genotype}s and the {@link IOperatorSelector} - * selecting the {@link Operator}s used to modify the {@link Genotype}s. - */ - private Map<Class<? extends Genotype>, IOperatorSelector> selectorForGenotype = - new HashMap<Class<? extends Genotype>, IOperatorSelector>(); - - /** {@inheritDoc} */ - @Override - public void - addOperatorInstance(Class<? extends Genotype> genotypeType, Mutate<?> mutateOperator) { - if(selectorForGenotype.get(genotypeType) == null) { - selectorForGenotype.put(genotypeType, new RoundRobinOperatorSelector()); - } - OperatorUtil.addOperatorInstance(genotypeType, mutateOperator, - selectorForGenotype.get(genotypeType), binder(), getOperatorTypeLiteral()); - - } - - /** {@inheritDoc} */ - @Override - public IOperatorSelector getOperatorSelector(Class<? extends Genotype> genotypeType) { - return selectorForGenotype.get(genotypeType); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateChannelNumber.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateChannelNumber.java deleted file mode 100644 index 7e5be6ca332eb50ce475f1bf91709b4fc8a444df..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateChannelNumber.java +++ /dev/null @@ -1,65 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateChannelNumber.java 2686 2016-05-04 16:23:35Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.safetyarch; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.opt4j.operators.mutate.Mutate; - -/** - * {@link Mutate} operator that varies the number of channels which realize a safety function. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 2686 $ - * @ConQAT.Rating RED Hash: E57496C8DAA01405C14BC25FB891B36B - */ -public class MutateChannelNumber<C> extends MutateSafetyArchBase<C> { - - /** Constructor. */ - protected MutateChannelNumber(SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public void mutate(SafetyFunctionArchEncoding<C> genotype, double p) { - // Determine the safety functions that shall be manipulated. - Collection<SafetyFunctionArchEntry<C>> selEntries = selectSafetyFunctions(genotype, p); - - for(SafetyFunctionArchEntry<C> sfEntry : selEntries) { - int[] allowedChannels = sfEntry.getSafetyFunctionAdapter().getAllowedChannelNumbers(); - int selectedChannelIdx = sfEntry.getNumChannels(); - if(rand.nextBoolean()) { - // Increase number of channels. - selectedChannelIdx++; - selectedChannelIdx = - selectedChannelIdx < allowedChannels.length ? selectedChannelIdx : 0; - } else { - // Decrease number of channels. - selectedChannelIdx--; - selectedChannelIdx = - selectedChannelIdx < 0 ? selectedChannelIdx : allowedChannels.length - 1; - } - sfEntry.setNumChannels(allowedChannels[selectedChannelIdx]); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateConnectedDiagnosisPresent.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateConnectedDiagnosisPresent.java deleted file mode 100644 index 866cfbdad4c2969d80657f5ec0935abadbdbb6d6..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateConnectedDiagnosisPresent.java +++ /dev/null @@ -1,64 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateConnectedDiagnosisPresent.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.safetyarch; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.opt4j.operators.mutate.Mutate; - -/** - * {@link Mutate} operator that alters the presence of a diagnostic unit of a safety function which - * is connected to the output unit of a safety function. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: 68DE5435A078310C3187F32C39AEF629 - */ -public class MutateConnectedDiagnosisPresent<C> extends MutateSafetyArchBase<C> { - - /** Constructor. */ - protected MutateConnectedDiagnosisPresent( - SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public void mutate(SafetyFunctionArchEncoding<C> genotype, double p) { - // Determine the safety functions that shall be manipulated. - Collection<SafetyFunctionArchEntry<C>> selEntries = selectSafetyFunctions(genotype, p); - - for(SafetyFunctionArchEntry<C> sfEntry : selEntries) { - // Toggle the presence of a diagnostic unit for this safety function. This has only an - // effect if the selected architecture supports additional diagnostic units. - // 2/3 --> equal distribution of choices considering the connection to an output unit. - boolean diagPresent = sfEntry.isDiagnosicUnitPresent(); - if(rand.nextInt(3) < 2) { - sfEntry.setDiagnosicUnitPresent(!diagPresent); - } - - if(diagPresent && rand.nextBoolean()) { - sfEntry.setDiagnosicUnitConnected(!sfEntry.isDiagnosicUnitConnected()); - } - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateSafetyArchBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateSafetyArchBase.java deleted file mode 100644 index 01cbadf8ba4a25cfadc7009033a11bb1b101cb6d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateSafetyArchBase.java +++ /dev/null @@ -1,65 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateSafetyArchBase.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.safetyarch; - -import java.util.ArrayList; -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.MutateBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.opt4j.operators.mutate.Mutate; - -/** - * Base class for {@link Mutate} operators that manipulate the entries of a - * {@link SafetyFunctionArchEncoding}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 7FCF5518D97A47C58590789B74DF80ED - */ -public abstract class MutateSafetyArchBase<C> extends MutateBase<SafetyFunctionArchEncoding<C>> { - - /** Constructor. */ - protected MutateSafetyArchBase(SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** - * Selects a collection of {@link SafetyFunctionArchEntry}s from the given - * {@link SafetyFunctionArchEncoding} whose element number depends on the given probability - * {@code p}. - */ - protected Collection<SafetyFunctionArchEntry<C>> selectSafetyFunctions( - SafetyFunctionArchEncoding<C> genotype, double p) { - Collection<SafetyFunctionArchEntry<C>> selEntries = new ArrayList<>(); - int size = genotype.size(); - int idx = rand.nextInt(size); - for(int i = 0; i < genotype.size(); i++) { - if(idx < p * size) { - SafetyFunctionArchEntry<C> entry = genotype.getEntry(idx); - if(entry != null) { - selEntries.add(entry); - } - } - } - return selEntries; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateSafetyFunctionArchitectureModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateSafetyFunctionArchitectureModule.java deleted file mode 100644 index 682d5a8f04e2c909ddcfa871afe5140c3b7e1ae8..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateSafetyFunctionArchitectureModule.java +++ /dev/null @@ -1,60 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateSafetyFunctionArchitectureModule.java 2686 2016-05-04 16:23:35Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.safetyarch; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.MutateOperatorModuleBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.opt4j.core.Genotype; -import org.opt4j.operators.mutate.Mutate; - -import com.google.inject.Module; - -/** - * {@link Module} registering the {@link Mutate} operators within Opt4J that alter the - * {@link SafetyFunctionArchEncoding} {@link Genotype}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 2686 $ - * @ConQAT.Rating RED Hash: D672A42F8B0E0CB7A166C0092B8B95CA - */ -public class MutateSafetyFunctionArchitectureModule extends MutateOperatorModuleBase { - /** Representation of input system */ - private SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Constructor where the input system model has to be specified. */ - public MutateSafetyFunctionArchitectureModule( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } - - /** {@inheritDoc} */ - @SuppressWarnings({"rawtypes", "unchecked"}) - @Override - public void config() { - super.config(); - - addOperatorInstance(SafetyFunctionArchEncoding.class, new MutateChannelNumber( - systemModelAdapter)); - addOperatorInstance(SafetyFunctionArchEncoding.class, new MutateSafetyTriggerSignalNumber( - systemModelAdapter)); - addOperatorInstance(SafetyFunctionArchEncoding.class, new MutateConnectedDiagnosisPresent( - systemModelAdapter)); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateSafetyTriggerSignalNumber.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateSafetyTriggerSignalNumber.java deleted file mode 100644 index 5261121042866e0e70a0b15bc6dd3fc68abeb04e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/safetyarch/MutateSafetyTriggerSignalNumber.java +++ /dev/null @@ -1,69 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateSafetyTriggerSignalNumber.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.safetyarch; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.opt4j.operators.mutate.Mutate; - -/** - * {@link Mutate} operator that alters the number of channels that is required to trigger the safety - * function. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: 39213A7EE823E895B246664DAB083865 - */ -public class MutateSafetyTriggerSignalNumber<C> extends MutateSafetyArchBase<C> { - - /** Constructor. */ - protected MutateSafetyTriggerSignalNumber( - SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public void mutate(SafetyFunctionArchEncoding<C> genotype, double p) { - // Determine the safety functions that shall be manipulated. - Collection<SafetyFunctionArchEntry<C>> selEntries = selectSafetyFunctions(genotype, p); - - for(SafetyFunctionArchEntry<C> sfEntry : selEntries) { - int[] allowedTriggers = - sfEntry.getSafetyFunctionAdapter().getAllowedTriggerSignalNumbers( - sfEntry.getNumChannels()); - int selectedTriggerIdx = sfEntry.getTriggerSignalIdx(); - if(rand.nextBoolean()) { - // Increase the req. number of trigger for the safety function. - selectedTriggerIdx++; - selectedTriggerIdx = - selectedTriggerIdx < allowedTriggers.length ? selectedTriggerIdx - 1 : 0; - } else { - // Decrease the req. number of trigger for the safety function. - selectedTriggerIdx--; - selectedTriggerIdx = - selectedTriggerIdx >= 0 ? selectedTriggerIdx : allowedTriggers.length - 1; - } - sfEntry.setTriggerSignalIdx(selectedTriggerIdx); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskinstantiation/MutateTaskInstance.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskinstantiation/MutateTaskInstance.java deleted file mode 100644 index 280435a532a4d8be459da35047ea483fc4f3c260..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskinstantiation/MutateTaskInstance.java +++ /dev/null @@ -1,81 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateTaskInstance.java 2686 2016-05-04 16:23:35Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskinstantiation; - -import java.util.Collection; -import java.util.HashSet; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -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.backend.opt4j.operator.mutate.taskmapping.MutateTasksBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; -import org.opt4j.operators.mutate.Mutate; - -/** - * {@link Mutate} operator which manipulates the instantiation of the referenced - * {@link IDeployableComponentAdapter} of a {@link InstantiatedTaskMappingEntry}. The instantiated - * {@link IDeployableComponentAdapter} is randomly selected from the set of instantiatable - * {@link IDeployableComponentAdapter}s of the associated {@link AbstractTaskMappingEntry}. - * <p> - * <b>NOTE:</b> Currently, this is a Nop operator, as a correct handling of {@link TaskGraph}s and - * an appropriate reliability analysis must be worked out. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 2686 $ - * @ConQAT.Rating RED Hash: C0C772FB0600C5FFD1AB80E7635A9E36 - */ -public class MutateTaskInstance - extends - MutateTasksBase<InstantiatedTaskMappingEntry, InstantiatedTaskMappingEncoding<InstantiatedTaskMappingEntry>> { - /** - * Collection of {@link IDeployableComponentAdapter}s which must be instantiated to obtain a - * "concrete" logical model". - */ - private Collection<IDeployableComponentAdapter<?>> abstractComponents; - - /** Constructor. */ - public MutateTaskInstance(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - abstractComponents = new HashSet<IDeployableComponentAdapter<?>>(); - - for(IDeployableComponentAdapter<?> deployableComponent : systemModelAdapter - .getDeployableComponents()) { - if(deployableComponent.isInstantiationRequired()) { - abstractComponents.add(deployableComponent); - } - } - } - - /** {@inheritDoc} */ - @Override - public void mutate(InstantiatedTaskMappingEncoding<InstantiatedTaskMappingEntry> encoding, - double rate) { - if(rand.nextDouble() < rate) { - // TODO: Evaluate mutation of the diverse implementation. - @SuppressWarnings("unused") int applyToIdx = 0; - if(abstractComponents.size() > 1) { - applyToIdx = rand.nextInt(abstractComponents.size() - 1); - } - // candidates for this mutation operation. - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskinstantiation/MutateTaskInstanceModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskinstantiation/MutateTaskInstanceModule.java deleted file mode 100644 index cf2c03dd2fb46ca545d96f81f90fb9da07128926..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskinstantiation/MutateTaskInstanceModule.java +++ /dev/null @@ -1,60 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateTaskInstanceModule.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskinstantiation; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.MutateOperatorModuleBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping.MutateTaskMappingModule; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.opt4j.operators.mutate.Mutate; - -import com.google.inject.Module; - -/** - * {@link Module} registering the {@link MutateTaskInstance} operator within Opt4J for - * {@link InstantiatedTaskMappingEncoding}s. - * <p> - * <b>NOTE:</b> Currently, the {@link MutateTaskInstance} operator is registered within the - * {@link MutateTaskMappingModule}, as Opt4J currently does not allow to add multiple {@link Mutate} - * modules. To fix this issue, Opt4J must allow defining the mutation rate per genotype. Once this - * is resolved, this module will be used. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: A35691096EA5E331A854BCAAC328C20A - */ -public class MutateTaskInstanceModule extends MutateOperatorModuleBase { - - /** Representation of input system */ - private SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Constructor where the input system model has to be specified. */ - public MutateTaskInstanceModule(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } - - /** {@inheritDoc} */ - @Override - public void config() { - super.config(); - - addOperatorInstance(InstantiatedTaskMappingEncoding.class, new MutateTaskInstance( - systemModelAdapter)); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateAllocation.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateAllocation.java deleted file mode 100644 index c10819111ba3506a811b2a0731ad5312ee80fb59..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateAllocation.java +++ /dev/null @@ -1,126 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateAllocation.java 3885 2016-11-11 09:41:01Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping; - -import static java.lang.Math.max; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; - -/** - * Mutate operator manipulates the allocation of tasks to resources by replacing an existing - * allocation with a new random allocation. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3885 $ - * @ConQAT.Rating RED Hash: 17A379CA64905722F8DA257F892D6B71 - */ -public class MutateAllocation<S extends TaskMappingEntry, T extends TaskMappingEncoding<S>> extends - MutateTasksBase<S, T> { - - /** Constructs a new allocation mutation operator for a given exploration run */ - public MutateAllocation(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** Constant to enable / disable replication count check. */ - private static final boolean CHECK_REPLICATION_COUNT = false; - - /** {@inheritDoc} */ - @Override - public void mutate(T encoding, double rate) { - checkReplicationCount(encoding); - - Collection<IDeployableComponentAdapter<?>> encDeplComponents = - new ArrayList<>(encoding.getDeployedComponents()); - for(IDeployableComponentAdapter<?> deployableComponent : encDeplComponents) { - if(rand.nextDouble() < rate) { - Collection<S> assignedResources = encoding.getMappingEntriesOf(deployableComponent); - if(assignedResources == null) { - return; - } - // Perform the re-allocation - try { - reAllocateMappingEntry(encoding, deployableComponent); - } catch(ExplorationException e) { - // Opt4J does not allow to throw Exceptions here. - throw new RuntimeException(e); - } - checkReplicationCount(encoding); - } - } - - checkReplicationCount(encoding); - } - - /** Checks the replication count and prints a message in case of errors. */ - private void checkReplicationCount(T encoding) { - if(CHECK_REPLICATION_COUNT) { - for(IDeployableComponentAdapter<?> currentComponent : systemModelAdapter - .getDeployableComponents()) { - if(encoding.getAllocatedResourcesFor(currentComponent).size() != 1) { - System.out.println("Encoding replications exceed the allowed amount"); - } - } - } - } - - /** - * Performs the actual re-allocation of the given {@link IDeployableComponentAdapter}. - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - private void reAllocateMappingEntry(T encoding, - IDeployableComponentAdapter<?> deployableComponent) throws ExplorationException { - // The assigned resources must be an indexed list, such that randomly determined allocations - // can be directly removed using a random number generator. - List<S> assignedResources = (List<S>)encoding.getMappingEntriesOf(deployableComponent); - if(assignedResources.isEmpty()) { - return; - } - - // Reassign a random allocation... - // max(...) is required as nextInt does not support a bound of 0. - int selIdx = max(0, rand.nextInt(assignedResources.size()) - 1); - S selectedEntry = assignedResources.get(selIdx); - - // This respects {@link ExcludeDeploymentConstraint}s. - if(encoding.hasFixedDeployment(deployableComponent)) { - List<IExecutionUnitAdapter<?>> targets = - new ArrayList<>(encoding.getAllowedAllocations(deployableComponent)); - int selExecU = max(0, rand.nextInt(targets.size()) - 1); - selectedEntry.resetTarget(targets.get(selExecU)); - } else { - List<IExecutionUnitAdapter<?>> targets = - new ArrayList<>(systemModelAdapter.getDeploymentTargets()); - int selExecU = max(0, rand.nextInt(targets.size()) - 1); - selectedEntry.resetTarget(targets.get(selExecU)); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateRedundancy.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateRedundancy.java deleted file mode 100644 index a098c5231995c050fb7ab4d84259c2ac05e5345c..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateRedundancy.java +++ /dev/null @@ -1,94 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateRedundancy.java 3747 2016-10-21 14:10:16Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping; - -import java.util.Collection; -import java.util.Optional; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.constraint.InternalReplicationConstraint; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; - -/** - * Base class for mutate operator that manipulate the redundancy of allocations. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3747 $ - * @ConQAT.Rating RED Hash: 43B7D2128EC15E30F289DE89B9B6953E - */ -public abstract class MutateRedundancy<S extends TaskMappingEntry, T extends TaskMappingEncoding<S>> - extends MutateTasksBase<S, T> { - - /** Constructs a new redundancy mutation operator for a given exploration run */ - MutateRedundancy(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public void mutate(T encoding, double rate) { - for(IDeployableComponentAdapter<?> deployableComponent : encoding.getDeployedComponents()) { - if(rand.nextDouble() < rate) { - // TODO: remove filter for fixed Deployment: It is not needed. - // No replication for Components with a fixed Deployment & Components which shall - // not be replicated (see the SystemModelAdapter). - if(!encoding.hasFixedDeployment(deployableComponent) && - systemModelAdapter.getReplicableComponents().contains(deployableComponent)) { - - // TODO: Model minimum and maximum replication count as constraint? - // Do the actual mutation of the allocation of the current request - try { - int minReplication = deployableComponent.getMinReplication(); - int maxReplication = deployableComponent.getMaxReplication(); - Collection<InternalReplicationConstraint> replConstraints = - encoding.getConstraintsOf(InternalReplicationConstraint.class); - Optional<InternalReplicationConstraint> curReplConstraint = - replConstraints - .stream() - .filter(c -> c.getReplicationObject() == deployableComponent) - .findAny(); - if(curReplConstraint.isPresent()) { - minReplication = curReplConstraint.get().getMin(); - maxReplication = curReplConstraint.get().getMax(); - } - - mutate(encoding, deployableComponent, minReplication, maxReplication); - } catch(ExplorationException e) { - // Opt4J does not allow to throw Exceptions here. - throw new RuntimeException(e); - } - } - // TODO: What about temporal redundancy at the fixed resource - } - } - } - - /** - * Performs the mutation of a single allocation - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - protected abstract void mutate(T encoding, IDeployableComponentAdapter<?> deployableComponent, - int minReplicatation, int maxReplication) throws ExplorationException; -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateRedundancyDecrement.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateRedundancyDecrement.java deleted file mode 100644 index 5f2ebbc94fbcf75e8ada3aa2b7fc29afc70eeb24..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateRedundancyDecrement.java +++ /dev/null @@ -1,55 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateRedundancyDecrement.java 2620 2016-04-29 11:56:14Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; - -/** - * Mutate operator that decreases the redundancy of allocations. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 2620 $ - * @ConQAT.Rating RED Hash: 945E9B5E1053F9642E119D418B07484A - */ -public class MutateRedundancyDecrement<S extends TaskMappingEntry, T extends TaskMappingEncoding<S>> - extends MutateRedundancy<S, T> { - - /** Constructs a new decrement redundancy mutation operator for a given exploration run */ - public MutateRedundancyDecrement(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - protected void mutate(T encoding, IDeployableComponentAdapter<?> deployableComponent, - int minReplicatation, int maxReplication) { - Collection<S> assignedResources = encoding.getMappingEntriesOf(deployableComponent); - assert (assignedResources != null); - - // Decrease redundancy: keep at least the minimum number of required deployments - if(assignedResources.size() - 1 >= minReplicatation) { - assignedResources.remove(rand.nextInt(assignedResources.size())); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateRedundancyIncrement.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateRedundancyIncrement.java deleted file mode 100644 index 394dc41c14e9020dcdb46bb87db7a58d18367b64..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateRedundancyIncrement.java +++ /dev/null @@ -1,68 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateRedundancyIncrement.java 3480 2016-09-09 13:31:04Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping; - -import java.util.Collection; - -import org.conqat.lib.commons.collections.CollectionUtils; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; - -/** - * Mutate operator that decreases the redundancy of allocations. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3480 $ - * @ConQAT.Rating RED Hash: 711FED961D96E5D8F42368FECA874ECA - */ -public class MutateRedundancyIncrement<S extends TaskMappingEntry, T extends TaskMappingEncoding<S>> - extends MutateRedundancy<S, T> { - /** Constructs a new increment redundancy mutation operator for a given exploration run */ - public MutateRedundancyIncrement(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** - * {@inheritDoc} - * - * @throws ExplorationException - */ - @Override - protected void mutate(T encoding, IDeployableComponentAdapter<?> deployableComponent, - int minReplicatation, int maxReplication) throws ExplorationException { - Collection<S> assignedResources = encoding.getMappingEntriesOf(deployableComponent); - assert (assignedResources != null); - - // increase redundancy: the maximum replication should not be exceeded - if(assignedResources.size() < maxReplication) { - // This respects {@link ExcludeDeploymentConstraint}s - // The following code ensures an equal distribution of temporal and spatial replication - if(rand.nextBoolean()) { - assignedResources.add(encoding.createRandomEntry(deployableComponent, - CollectionUtils.asRandomAccessList(encoding - .getMappingTargetsOf(deployableComponent)))); - } else { - assignedResources.add(encoding.createRandomEntry(deployableComponent)); - } - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateTaskMappingModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateTaskMappingModule.java deleted file mode 100644 index 715689ba124136d435790708c9d75c4209f15c2c..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateTaskMappingModule.java +++ /dev/null @@ -1,62 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateTaskMappingModule.java 2663 2016-05-03 13:57:56Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping; - -import org.fortiss.af3.exploration.alg.dse.TaskMappingFactory; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.MutateOperatorModuleBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.opt4j.operators.mutate.Mutate; - -import com.google.inject.Module; - -/** - * This {@link Module} registers {@link Mutate} operators in Opt4J which manipulate the - * {@link TaskMappingEncoding}s. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 2663 $ - * @ConQAT.Rating RED Hash: 194BD37098F9831E6E02D36D7A9E092B - */ -public class MutateTaskMappingModule extends MutateOperatorModuleBase { - /** Representation of input system */ - private SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Constructor where the input system model has to be specified. */ - public MutateTaskMappingModule(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } - - /** {@inheritDoc} */ - @Override - public void config() { - super.config(); - TaskMappingFactory<? extends TaskMappingEntry, ? extends TaskMappingEncoding<?>> tmFactory = - TaskMappingFactory.getInstance(); - - addOperatorInstance(AbstractTaskMappingEncoding.class, - tmFactory.createMutateAllocationOperator(systemModelAdapter)); - addOperatorInstance(AbstractTaskMappingEncoding.class, - tmFactory.createMutateRedundancyDecrementOperator(systemModelAdapter)); - addOperatorInstance(AbstractTaskMappingEncoding.class, - tmFactory.createMutateRedundancyIncrementOperator(systemModelAdapter)); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateTasksBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateTasksBase.java deleted file mode 100644 index 93f9893d73a2cb204397d5eaa3759888009f2830..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/mutate/taskmapping/MutateTasksBase.java +++ /dev/null @@ -1,40 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MutateTasksBase.java 2620 2016-04-29 11:56:14Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.MutateBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; - -/** - * Base class for mutation operator defined for {@link TaskMappingEncoding}s. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 2620 $ - * @ConQAT.Rating RED Hash: AECD623B84E8B899B5A30E4774DA4636 - */ -public abstract class MutateTasksBase<S extends TaskMappingEntry, T extends TaskMappingEncoding<S>> - extends MutateBase<T> { - - /** Constructor. */ - protected MutateTasksBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/IMultiSelectorOperatorModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/IMultiSelectorOperatorModule.java deleted file mode 100644 index 01d18b27fed7a649a40f129e6b735c6205fb71c0..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/IMultiSelectorOperatorModule.java +++ /dev/null @@ -1,51 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IMultiSelectorOperatorModule.java 1249 2015-09-10 14:54:25Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection; - -import org.opt4j.core.Genotype; -import org.opt4j.core.optimizer.Operator; -import org.opt4j.operators.OperatorModule; - -/** - * Interface for adding (possibly multiple) operators to multiple {@link Genotype}s. The - * {@link IOperatorSelector} is used to select one operator that shall be aplied for the given given - * {@link Genotype}. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 1249 $ - * @ConQAT.Rating RED Hash: 097375C36BCCBAEAA7DD25A18D594877 - */ -public interface IMultiSelectorOperatorModule<O extends Operator<?>> { - /** - * Registers a pre-constructed mutation operator instance with an {@link OperatorModule} and a - * specific {@link Genotype} provided by the Opt4J framework. The operator will be applied only - * to the given {@link Genotype}. - */ - public void addOperatorInstance(Class<? extends Genotype> genotypeType, O crossoverOperator); - - /** - * Returns the {@link IOperatorSelector} used to manage the selection of operators registered - * with the instance of the class implementing this interface (used internally by - * {@link #addOperatorInstance(Class, Operator)}). - * - * Implementations must ensure that the same {@link IOperatorSelector} instance is returned for - * all calls of {@link #addOperatorInstance(Class, Operator)}. - */ - public IOperatorSelector getOperatorSelector(Class<? extends Genotype> genotypeType); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/IOperatorSelector.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/IOperatorSelector.java deleted file mode 100644 index 7acb574aee216b4cd2b8e1b9ad1d8256777c87ef..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/IOperatorSelector.java +++ /dev/null @@ -1,53 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IOperatorSelector.java 1249 2015-09-10 14:54:25Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection; - -import org.opt4j.core.optimizer.Operator; -import org.opt4j.operators.AbstractGenericOperator; - -/** - * Interface to define custom operator selection strategies. In order apply such strategy in the - * optimization run of Opt4J, for each operator type (e.g., mutation, crossover, ...) one instance - * of a class implementing this interface is shared between dedicated per-operator - * instances of the {@link OperatorSelectorPredicate} wrapper. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 1249 $ - * @ConQAT.Rating RED Hash: DE3E74531167C41F8FF007676599165B - */ -public interface IOperatorSelector { - - /** - * Returns true iff the operator managed by the corresponding {@link OperatorSelectorPredicate} - * should be selected at the current stage of the optimization run. - * - * {@link OperatorSelectorPredicate#evaluate(org.opt4j.core.Genotype)} (which is triggered by - * {@link AbstractGenericOperator#getOperator(org.opt4j.core.Genotype)}) delegates the - * actual work to this method - */ - public abstract boolean evaluate(Operator<?> operator); - - /** - * Registers an operator with this {@link IOperatorSelector}. This method is - * invoked from the constructor - * {@link OperatorSelectorPredicate#OperatorSelectorPredicate(Operator, IOperatorSelector)}. - */ - public abstract void register(Operator<?> operator); - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/ISelectorOperatorModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/ISelectorOperatorModule.java deleted file mode 100644 index f117e0796521801cb2bf09f4f3e2be073b9efcaa..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/ISelectorOperatorModule.java +++ /dev/null @@ -1,49 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ISelectorOperatorModule.java 1249 2015-09-10 14:54:25Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection; - -import org.opt4j.core.Genotype; -import org.opt4j.core.optimizer.Operator; -import org.opt4j.operators.OperatorModule; - -/** - * Interface for adding (possibly multiple) operators and selecting operators which are then applied - * to a {@link Genotype}. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 1249 $ - * @ConQAT.Rating RED Hash: 7E6C141236799E4FA0828A99A2D8D9AC - */ -public interface ISelectorOperatorModule<O extends Operator<?>> { - /** - * Registers a pre-constructed mutation operator instance with an {@link OperatorModule} - * provided by the Opt4J framework. - */ - public void addOperatorInstance(O operator); - - /** - * Returns the {@link IOperatorSelector} used to manage the selection of operators registered - * with the instance of the class implementing this interface (used internally by - * {@link #addOperatorInstance(Operator)}). - * - * Implementations must ensure that the same {@link IOperatorSelector} instance is returned for - * all calls of {@link #addOperatorInstance(Operator)}. - */ - public IOperatorSelector getOperatorSelector(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/OperatorSelectorBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/OperatorSelectorBase.java deleted file mode 100644 index f08be2a462ee0a283456f04c821eeaa30cc557e8..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/OperatorSelectorBase.java +++ /dev/null @@ -1,107 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: OperatorSelectorBase.java 1249 2015-09-10 14:54:25Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection; - -import java.util.HashMap; -import java.util.Map; - -import org.opt4j.core.optimizer.Operator; -import org.opt4j.operators.AbstractGenericOperator; - -/** - * Base class for operator selection strategies. It is best suited for index-based strategies, such - * as the ones provided by {@link RoundRobinOperatorSelector} and {@link RandomOperatorSelector}. - * - * Since the set of all operators available for a particular operator type (e.g., mutation, - * cross-over) is known to this class / the {@link IOperatorSelector} interface, also heuristics - * based on the state of the optimization (e.g., current population) are possible (requires - * acquisition of this information). - * - * Classes providing a specific selection strategy will typically only override the - * {@code *internal()} methods, whereas the methods inherited from {@link IOperatorSelector} serve - * as interface to {@link OperatorSelectorPredicate}. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 1249 $ - * @ConQAT.Rating RED Hash: B6A705EEDD2826487247BEAE1B755D99 - */ -public abstract class OperatorSelectorBase implements IOperatorSelector { - /** Map: Operator -> 0-based index */ - protected Map<Operator<?>, Integer> operatorToIndexMap = new HashMap<Operator<?>, Integer>(); - - /** - * Number of invocations of {@link #evaluate(Operator)} in the current operator lookup loop in - * {@link AbstractGenericOperator#getOperator(org.opt4j.core.Genotype)}). Required to ensure - * that an operator is returned in any round (= |number of operators managed by this - * {@link IOperatorSelector}|, triggered by a single invocation of - * {@link AbstractGenericOperator#getOperator(org.opt4j.core.Genotype)}). In case an operator - * selection strategy would not select any operator in particular round, the last operator - * evaluated in that round will be returned. - */ - private int evaluationCount; - - /** {@inheritDoc} */ - @Override - public void register(Operator<?> operator) { - operatorToIndexMap.put(operator, operatorToIndexMap.size()); - registerInternal(operator); - } - - /** - * Selection strategy specific registration of an operator. See - * {@link IOperatorSelector#register(Operator)}. - * - * @param operator - * Operator to be registered. - */ - protected void registerInternal(Operator<?> operator) { - // By default, do nothing - } - - /** {@inheritDoc} */ - @Override - public final boolean evaluate(Operator<?> operator) { - - int numOperators = operatorToIndexMap.size(); - - // The actual evaluation if the current operator is to be selected - boolean rval = evaluateInternal(operator); - - evaluationCount++; - if(rval || evaluationCount == numOperators) { - // Operator has been selected, or this is the last operator to be investigated in this - // round. - - // Reset - evaluationCount = 0; - finalizeSelectionRoundInternal(); - - // Ensure that last operator is selected in any case - rval = true; - } - - return rval; - } - - /** The actual selection strategy (invoked from {@link #evaluate(Operator)}. */ - protected abstract boolean evaluateInternal(Operator<?> operator); - - /** Selection strategy finalization of a selection round. */ - protected abstract void finalizeSelectionRoundInternal(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/OperatorSelectorPredicate.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/OperatorSelectorPredicate.java deleted file mode 100644 index ed40f7641af1281e34233b6e8b5e8ada60237e98..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/OperatorSelectorPredicate.java +++ /dev/null @@ -1,83 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: OperatorSelectorPredicate.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.ComposableOperatorClassPredicate; -import org.opt4j.core.Genotype; -import org.opt4j.core.optimizer.Operator; -import org.opt4j.operators.AbstractGenericOperator.OperatorPredicate; - -/** - * {@link OperatorPredicate} implementation that delegates the actual work to a - * {@link IOperatorSelector} object. For each class of operators (e.g., mutate, crossover, ...), a - * single {@link IOperatorSelector} is shared between operator-specific - * {@link OperatorSelectorPredicate} wrappers. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 7E2395C0700DC998A73A71F609F228A1 - */ -public class OperatorSelectorPredicate implements OperatorPredicate { - /** Operator whose selection is determined by this {@link OperatorSelectorPredicate}. */ - private Operator<?> operator; - - /** */ - private ComposableOperatorClassPredicate genotypePredicate; - - /** {@link IOperatorSelector} to which the actual work is delegated. */ - private IOperatorSelector operatorSelector; - - /** - * Constructs a new {@link OperatorSelectorPredicate} for a given operation. All operators of a - * particular class (mutate, crossover, ...) must share the some {@link IOperatorSelector} - * object. - */ - public OperatorSelectorPredicate(Operator<?> operator, IOperatorSelector operatorSelector) { - this.operator = operator; - this.operatorSelector = operatorSelector; - operatorSelector.register(operator); - } - - /** - * Constructs a new {@link OperatorSelectorPredicate} for a given genotype(class) and operation. - * The genotype parameter determines the genotype to which the given operator shall be applied. - * All operators of a particular class (mutate, crossover, ...) must share the same - * {@link IOperatorSelector} object. - */ - public OperatorSelectorPredicate(Operator<?> operator, - ComposableOperatorClassPredicate genotypePredicate, IOperatorSelector operatorSelector) { - this.operator = operator; - this.genotypePredicate = genotypePredicate; - this.operatorSelector = operatorSelector; - operatorSelector.register(operator); - } - - /** {@inheritDoc} */ - @Override - public boolean evaluate(Genotype genotype) { - Boolean geneMatch = null; - if(genotypePredicate != null) { - geneMatch = genotypePredicate.evaluate(genotype); - } - boolean opMatch = operatorSelector.evaluate(operator); - - return (geneMatch != null) ? (geneMatch && opMatch) : opMatch; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/RandomOperatorSelector.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/RandomOperatorSelector.java deleted file mode 100644 index 430d665c451ee4068dd7eeab4747807ed76abf23..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/RandomOperatorSelector.java +++ /dev/null @@ -1,58 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: RandomOperatorSelector.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.random.RandomExploration; -import org.opt4j.core.optimizer.Operator; - -/** - * In each selection round (see {@link OperatorSelectorBase}), selects are a random operator from - * the set of registered operators. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 34CE4F16434138D0DF2147E7A71CC0DE - */ -public class RandomOperatorSelector extends OperatorSelectorBase { - /** Random generator */ - private RandomExploration rand = RandomExploration.getInstance(); - - /** Operator selected for the current round (selected randomly for each selection round). */ - private int currentOperator; - - /** {@inheritDoc} */ - @Override - protected void registerInternal(Operator<?> operator) { - currentOperator = rand.nextInt(operatorToIndexMap.size()); - } - - /** {@inheritDoc} */ - @Override - protected boolean evaluateInternal(Operator<?> operator) { - boolean rval = (operatorToIndexMap.get(operator) == currentOperator); - return rval; - } - - /** {@inheritDoc} */ - @Override - protected void finalizeSelectionRoundInternal() { - currentOperator = rand.nextInt(operatorToIndexMap.size()); - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/RoundRobinOperatorSelector.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/RoundRobinOperatorSelector.java deleted file mode 100644 index b3e75a300fd4e4e61cb72008ab906a4111accd02..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/operator/selection/RoundRobinOperatorSelector.java +++ /dev/null @@ -1,48 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: RoundRobinOperatorSelector.java 1249 2015-09-10 14:54:25Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.selection; - -import org.opt4j.core.optimizer.Operator; - -/** - * Selection strategy that selects operators in a round-robin fashion (in the registration order of - * the operators). - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 1249 $ - * @ConQAT.Rating RED Hash: 3763E14FA05909AEA072F868B6474606 - */ -public class RoundRobinOperatorSelector extends OperatorSelectorBase { - /** Operator selected for the current round */ - private int currentOperator; - - /** {@inheritDoc} */ - @Override - protected boolean evaluateInternal(Operator<?> operator) { - boolean rval = (operatorToIndexMap.get(operator) == currentOperator); - return rval; - } - - /** {@inheritDoc} */ - @Override - protected void finalizeSelectionRoundInternal() { - currentOperator++; - currentOperator %= operatorToIndexMap.size(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ArchExpSubDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ArchExpSubDecoder.java deleted file mode 100644 index df52d99bf75e5ca1c62f5b6a34e0f3a5818b5cd8..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ArchExpSubDecoder.java +++ /dev/null @@ -1,34 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ArchExpSubDecoder.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.opt4j.core.problem.Decoder; - -/** - * Marker interface for {@link Decoder}s of {@link ComposableGenotype}s of an architectural - * exploration problem. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 3D22E7F33D861F29FD53A03A8C51E684 - */ -public interface ArchExpSubDecoder { - // Marker interface. -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ArchitectureDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ArchitectureDecoder.java deleted file mode 100644 index 60baea30d7736348a6cb54e8e8fd5f39a48c9bec..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ArchitectureDecoder.java +++ /dev/null @@ -1,60 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ArchitectureDecoder.java 3451 2016-09-02 13:36:29Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem; - -import java.util.Map; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.ArchExpSubEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.ArchitectureExplorationEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.CompositeDecoderBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph.DecoderDependencyGraph; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.ArchitectureSolution; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.opt4j.core.Genotype; -import org.opt4j.core.genotype.CompositeGenotype; -import org.opt4j.core.problem.Decoder; - -import com.google.inject.Inject; - -/** - * {@link Decoder} for {@link CompositeGenotype} {@link ArchExpSubEncoding} which encodes an - * architectural exploration problem. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3451 $ - * @ConQAT.Rating RED Hash: 3A8C3057677972437CD31CB11BAB34B1 - */ -public class ArchitectureDecoder extends - CompositeDecoderBase<ArchitectureExplorationEncoding, ArchitectureSolution> { - - /** Default constructor that makes the input models accessible for the decoders. */ - @Inject - public ArchitectureDecoder(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execdepGraph) { - super(systemModelAdapter, execdepGraph); - } - - /** {@inheritDoc} */ - @Override - public <CP extends ComposablePhenotype<? extends Genotype>> ArchitectureSolution - mergeSubPhenotypes(Map<Class<CP>, CP> subPhenotypes) { - return new ArchitectureSolution(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ArchitectureExplorationProblemModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ArchitectureExplorationProblemModule.java deleted file mode 100644 index 944f0cb81f89c53186e5a415cef4823331afc3b1..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ArchitectureExplorationProblemModule.java +++ /dev/null @@ -1,90 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ArchitectureExplorationProblemModule.java 3451 2016-09-02 13:36:29Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem; - -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.rethrow; - -import java.util.Set; - -import org.fortiss.af3.exploration.alg.dse.DSEFactory; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.ArchitectureExplorationEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph.DecoderDependencyGraph; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.ArchitectureSolution; -import org.fortiss.af3.exploration.alg.dse.evaluator.ArchitectureEvaluator; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.moea.model.DseSpecification; - -/** - * Problem module for fail-silent execution model, that encapsulates a creator, a decoder and - * the set of goal-specific evaluators. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3451 $ - * @ConQAT.Rating RED Hash: 1057BA4E10055241F65F27E0247DB322 - */ -public class ArchitectureExplorationProblemModule - extends - DseProblemModuleBase<ArchitectureExplorationEncoding, ArchitectureSolution, ArchitectureDecoder> { - - /** Constructor. */ - public ArchitectureExplorationProblemModule(DseSpecification dse, - ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - Set<Class<? extends IExplorationEncoding>> requestedSolutions) { - super(dse, expSpec, systemModelAdapter, requestedSolutions); - } - - /** Configure genotype creator (execution model dependent), problem decoder and goal evaluators. */ - @Override - protected void config() { - /* - * Bind the Creators and the Decoders to the opt4j optimization problem. The evaluators are - * added separately. - */ - DSEFactory dseFactory = DSEFactory.getInstance(); - - ArchitectureEvaluator archEvaluator = - dseFactory.createArchitectureEvaluator(systemModelAdapter); - - // Dependency graph for the execution order. - DecoderDependencyGraph execDepGraph = - new DecoderDependencyGraph(systemModelAdapter, requestedSolutions); - - // TODO: construct the execution dependency graph elsewhere? - bindProblem(dseFactory.createArchitectureExplorationCreator(expSpec, systemModelAdapter), - dseFactory.createArchitectureDecoder(systemModelAdapter, execDepGraph), - archEvaluator); - - // Create/Bind the subproblems of the architectural exploration problem. - try { - dseFactory.createSubProblems(this, dse, expSpec, systemModelAdapter, execDepGraph); - } catch(Exception e) { - throw new RuntimeException("Failed setting up the DSE Problem instance.", e); - } - - // Create evaluators wrappers (based on provided goal specification) - try { - addGoalEvaluators(archEvaluator); - } catch(Exception e) { - throw rethrow(e); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/DseProblemModuleBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/DseProblemModuleBase.java deleted file mode 100644 index 5a4fae5becba2a3645c1fabce379da2c9b16eaea..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/DseProblemModuleBase.java +++ /dev/null @@ -1,206 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DseProblemModuleBase.java 3404 2016-08-26 15:01:08Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem; - -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import org.fortiss.af3.exploration.alg.ExplorationAlgActivator; -import org.fortiss.af3.exploration.alg.dse.TaskMappingFactory; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.CompositeDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate.ComposableEvaluator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate.CompositeEvaluator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.CompositePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.problem.CompositeProblemModuleBase; -import org.fortiss.af3.exploration.alg.dse.evaluator.ArchitectureEvaluator; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationObjective; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.MOExplorationObjective; -import org.fortiss.af3.exploration.moea.model.DseSpecification; -import org.fortiss.tooling.kernel.utils.LoggingUtils; -import org.opt4j.core.Objective; -import org.opt4j.core.genotype.CompositeGenotype; -import org.opt4j.core.problem.Evaluator; - -/** - * Base class for problems that are solved within this DSE. It allows to create - * {@link EvaluatorWrapper}s which associate {@link ExplorationTarget}s with {@link Evaluator}s of - * possible solutions to the problem that shall be solved by the DSE. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3404 $ - * @ConQAT.Rating RED Hash: 3992B2DBE2C863364D7F45ED3F8F4458 - */ -public abstract class DseProblemModuleBase<C extends CompositeGenotype<Class<? extends ComposableGenotype>, ComposableGenotype>, P extends CompositePhenotype<?>, CD extends CompositeDecoder<C, P>> - extends CompositeProblemModuleBase<C, P, CD> { - - /** DSE configuration */ - protected DseSpecification dse; - - protected ExplorationSpecification expSpec; - - /** Representation of input system */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Set of requested {@link ComposablePhenotype}s that form the solution set. */ - Set<Class<? extends IExplorationEncoding>> requestedSolutions; - - /** - * Constructor the DSE specification and an adapter to the input system model has to be - * specified. - */ - public DseProblemModuleBase(DseSpecification dse, ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - Set<Class<? extends IExplorationEncoding>> requestedSolutions) { - this.dse = dse; - this.expSpec = expSpec; - this.systemModelAdapter = systemModelAdapter; - this.requestedSolutions = requestedSolutions; - } - - /** - * Adds the evaluators of the sub problems of the architectural exploration. - * - * @throws Exception - */ - protected <RT, T extends ExplorationTarget<RT>, S extends Phenotype, E extends Evaluator<?>> - void addGoalEvaluators(CompositeEvaluator<P> dseEvaluator) throws Exception { - Collection<ExplorationTarget<?>> targets = expSpec.getTargets(); - Collection<ExplorationConstraint<?>> constraints = - targets.stream().filter(t -> t instanceof ExplorationConstraint<?>) - .map(ExplorationConstraint.class::cast).collect(Collectors.toList()); - - int currentConstrPrio = 0; - Map<Class<? extends ExplorationTarget<?>>, Integer> priorityMap = new LinkedHashMap<>(); - for(ExplorationConstraint<?> currConstraint : constraints) { - if(!priorityMap.containsKey(currConstraint.getClass())) { - @SuppressWarnings("unchecked") Class<? extends ExplorationTarget<?>> contraintType = - (Class<? extends ExplorationTarget<?>>)currConstraint.getClass(); - priorityMap.put(contraintType, currentConstrPrio); - currentConstrPrio++; - } - } - - int objectivePrioOffset = currentConstrPrio; - int nonMOObjectiveCounter = 0; - Collection<ExplorationObjective<?>> objectives = - targets.stream().filter(t -> t instanceof ExplorationObjective<?>) - .map(ExplorationObjective.class::cast).collect(Collectors.toList()); - for(ExplorationObjective<?> currObjective : objectives) { - nonMOObjectiveCounter++; - if(MOExplorationObjective.class.isAssignableFrom(currObjective.getClass())) { - if(!priorityMap.containsKey(currObjective.getClass())) { - int objPrio = ((MOExplorationObjective<?>)currObjective).getPriority(); - @SuppressWarnings("unchecked") Class<? extends ExplorationTarget<?>> objectiveType = - (Class<? extends ExplorationTarget<?>>)currObjective.getClass(); - priorityMap.put(objectiveType, objectivePrioOffset + objPrio); - } - } else { - LoggingUtils.warning( - ExplorationAlgActivator.getDefault(), - "Could not extract the priority of the objective " + - currObjective.getName() + "."); - @SuppressWarnings("unchecked") Class<? extends ExplorationTarget<?>> objectiveType = - (Class<? extends ExplorationTarget<?>>)currObjective.getClass(); - priorityMap.put(objectiveType, objectivePrioOffset + nonMOObjectiveCounter); - } - } - - for(ExplorationTarget<?> target : targets) { - @SuppressWarnings({"cast", "unchecked"}) EvaluatorWrapper<?, RT, T> evalWrapper = - (EvaluatorWrapper<?, RT, T>)addGoalEvaluator(dseEvaluator, (T)target, - priorityMap.get(target.getClass())); - Objective evalObjective = evalWrapper.getObjective(); - targetObjectiveAssoc.put(target, evalObjective); - } - } - - /** - * Adds an goal-specific {@link EvaluatorWrapper} to the {@link ArchitectureEvaluator}. - * - * @throws Exception - */ - protected - <RT, T extends ExplorationTarget<RT>, S extends ComposablePhenotype<?>, E extends ComposableEvaluator<S>> - EvaluatorWrapper<?, RT, T> addGoalEvaluator(CompositeEvaluator<P> dseEvaluator, T goal, - int priority) throws Exception { - @SuppressWarnings("unchecked") EvaluatorWrapper<?, RT, T> wrappedEvaluator = - (EvaluatorWrapper<?, RT, T>)TaskMappingFactory.getInstance() - .createEvaluatorWrapper(goal, priority, systemModelAdapter); - if(wrappedEvaluator != null) { - // Here, we check whether the goal evaluator is defined for composable phenotypes (only - // composable evaluators are allowed then). - if(ComposablePhenotype.class - .isAssignableFrom(wrappedEvaluator.getTargetPhenotypeType())) { - - Class<?> phenotypeClass = wrappedEvaluator.getTargetPhenotypeType(); - - if(ComposablePhenotype.class.isAssignableFrom(phenotypeClass)) { - // if(phenoClass.isAssignableFrom(phenotypeClass) && - // evalClass.isAssignableFrom(wrappedEvaluator.getClass())) { - @SuppressWarnings("unchecked") Class<S> subPhenotypeClass = - (Class<S>)phenotypeClass; - @SuppressWarnings("unchecked") E wrappedSubEvaluator = (E)wrappedEvaluator; - - try { - dseEvaluator.registerSubEvaluator(subPhenotypeClass, wrappedSubEvaluator); - } catch(Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - // Register the wrapped Evaluator, - registerEvaluator(wrappedEvaluator); - // } - // else { - // throw new IllegalArgumentException("The sub-phenotye class " + - // phenotypeClass + " and the evaluator class " + - // wrappedEvaluator.getClass() + " does not match the classes " + - // phenoClass + " and " + evalClass + " used to describe the problem."); - // } - } else { - throw new Exception(); - } - } else if(!(ComposablePhenotype.class.isAssignableFrom(wrappedEvaluator - .getTargetPhenotypeType()))) { - // Otherwise, a "simple" goal evaluator is created - addEvaluator(wrappedEvaluator); - } else { - throw new Exception(); - } - } else { - // TODO: Evaluate, if the optimization should stop here, i.e. throw an exception or - // similar (if possible). - System.out.println("Could not instantiate an evaluator for goal of dimension \"" + - goal.getName() + "\". Skipping."); - return null; - } - - return wrappedEvaluator; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/EvaluatorWrapper.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/EvaluatorWrapper.java deleted file mode 100644 index 54748f20eef91b6462ce6f6cf539156fb36b2e62..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/EvaluatorWrapper.java +++ /dev/null @@ -1,189 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: EvaluatorWrapper.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.evaluator.ArchExpSubEvaluator; -import org.fortiss.af3.exploration.alg.dse.evaluator.ExplorationTargetEvaluatorBase; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.dsl.model.MOEAExplorationExpression; -import org.fortiss.af3.exploration.dsl.model.expressions.Expression; -import org.fortiss.af3.exploration.dsl.model.operators.OptimizationDirection; -import org.fortiss.af3.exploration.dsl.model.operators.OptimizationDirectionEnum; -import org.fortiss.af3.exploration.dsl_v2.model.expression.IExpression; -import org.fortiss.af3.exploration.dsl_v2.model.function.Maximize; -import org.fortiss.af3.exploration.dsl_v2.model.function.Minimize; -import org.fortiss.af3.exploration.model.ExplorationObjective; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.opt4j.core.DoubleValue; -import org.opt4j.core.Objective; -import org.opt4j.core.Objective.Sign; -import org.opt4j.core.Objectives; -import org.opt4j.core.Value; -import org.opt4j.core.problem.Evaluator; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * Opt4J specific goal evaluator wrapper that delegates the actual evaluation to a strategy object - * of type {@link ExplorationTargetEvaluatorBase} - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: FF60522059CC98B16B0B8A3D80BB5D49 - */ -public class EvaluatorWrapper<P, RT, T extends ExplorationTarget<RT>> implements - ArchExpSubEvaluator<P>, Evaluator<P> { - - /** Objective to track evaluation of this {@link ExplorationTarget} */ - private Objective objective; - - /** Actual underlying evaluator */ - private IExplorationTargetEvaluator<P, RT, T> evaluator; - - /** Goal specification */ - private T explorationTarget; - - /** Contains the priority of the {@link ExplorationTarget} of the {@link EvaluatorWrapper}. */ - private int targetPriority; - - /** Phenotypes, i.e. (sub-)solutions, to which this operator may be applied to. */ - private Class<P> targetPhenotypeType; - - /** Constructor that creates an evaluator wrapper for a given {@link ExplorationTarget}. */ - public EvaluatorWrapper(T goal, IExplorationTargetEvaluator<P, RT, T> evaluator, int priority, - Class<? extends P> primaryInputType) { - - // Construct EA objectives and register it in objective map. Do not give an - // "optimization direction" (min/max) in case of constraints. They default to minimization. - OptimizationDirectionEnum direction = OptimizationDirectionEnum.MIN; - // TODO: Remove after deprecation of the MoeaExpression. Check first to handle this special - // case. - if(goal instanceof MOEAExplorationExpression) { - Expression moExpr = ((MOEAExplorationExpression)goal).getMoeaExpression(); - if(moExpr instanceof OptimizationDirection) { - direction = ((OptimizationDirection)moExpr).getOperator(); - } - } else if(goal instanceof ExplorationObjective) { - // TODO: Reconsider the wrapping / passing to the ExpressionEvaluators. Probably, the - // evaluators only need to be aware of the systemModelAdapter and the exploration - // expression. - IExpression expr = goal.getExpression(); - if(expr instanceof Minimize) { - direction = OptimizationDirectionEnum.MIN; - } else if(expr instanceof Maximize) { - direction = OptimizationDirectionEnum.MAX; - } - } - - String objectiveName = - goal.getName() == null ? goal.getClass().toString() + - Integer.toString(goal.getId()) : goal.getName() + - Integer.toString(goal.getId()); - objective = - new Objective(objectiveName, direction == OptimizationDirectionEnum.MIN ? Sign.MIN - : Sign.MAX); - - this.explorationTarget = goal; - this.evaluator = evaluator; - this.targetPriority = priority; - @SuppressWarnings("unchecked") Class<P> targetPhenotypeType = (Class<P>)primaryInputType; - this.targetPhenotypeType = targetPhenotypeType; - } - - /** - * Returns the priority of this evaluator (based on the priority specified for the underlying - * goal) - */ - public int getPriority() { - return targetPriority; - } - - /** {@inheritDoc} */ - @Override - public <CP extends ComposablePhenotype<?>> Objectives evaluateComposable(Class<CP> clazz, - CP phenotype, FlatPhenotypeMap<Phenotype> phenotypes, - ClassToInstanceMap<EObject> transformedModels) { - Objectives objectives = new Objectives(); - - // TODO: Do we really need the evalu - @SuppressWarnings("unchecked") P castedPhenotype = (P)phenotype; - - Value<?> evalResult = new DoubleValue(Double.MAX_VALUE); - try { - evalResult = evaluator.evaluateGoal(castedPhenotype, phenotypes, transformedModels); - } catch(Exception e) { - // The Opt4J framework only allows us to throw runtime exceptions. - throw new RuntimeException(new ExplorationException("The evaluatior " + - this.toString() + " failed to evaluate the ExplorationTarget " + - explorationTarget.getName() + ".", e)); - } - - objectives.add(objective, evalResult); - - return objectives; - } - - /** {@inheritDoc} */ - @Override - public Objectives evaluate(P phenotype) { - // TODO: Investigate when this method is called. Should be never the case... - assert (false); - Objectives objectives = new Objectives(); - - Value<?> evalResult = new DoubleValue(Double.MAX_VALUE); - try { - evalResult = evaluator.evaluateGoal(phenotype, null, null); - } catch(Exception e) { - // The Opt4J framework only allows us to throw runtime exceptions. - throw new RuntimeException(new ExplorationException("The evaluatior " + - this.toString() + " failed to evaluate the ExplorationTarget " + - explorationTarget.getName() + ".", e)); - } - - objectives.add(objective, evalResult); - - return objectives; - } - - /** Returns the type of the goal this evaluator is built for. */ - @SuppressWarnings("unchecked") - public Class<T> getTargetType() { - return (Class<T>)explorationTarget.getClass(); - } - - /** Returns the underlying (actual) evaluator. */ - public IExplorationTargetEvaluator<P, RT, T> getEvaluator() { - return evaluator; - } - - /** Returns the objective associated with the wrapped {@link Evaluator}. */ - public Objective getObjective() { - return objective; - } - - /** Returns the class of the phenotype to */ - public Class<P> getTargetPhenotypeType() { - return targetPhenotypeType; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ExplorationGoalPriorityMultiEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ExplorationGoalPriorityMultiEvaluator.java deleted file mode 100644 index 110d2c4f72b82195d238c1c01640bb2aa1840c0e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ExplorationGoalPriorityMultiEvaluator.java +++ /dev/null @@ -1,82 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExplorationGoalPriorityMultiEvaluator.java 3404 2016-08-26 15:01:08Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem; - -import java.util.Comparator; -import java.util.Set; -import java.util.TreeSet; - -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.opt4j.core.Objectives; -import org.opt4j.core.problem.Evaluator; -import org.opt4j.core.problem.MultiEvaluator; - -import com.google.inject.Inject; -import com.google.inject.Provider; - -/** - * Specialized {@link MultiEvaluator} that determines the priority of the evaluators based on the - * priorities provided in the underlying goal specification. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3404 $ - * @ConQAT.Rating RED Hash: 22B82A2A194E1AC276EECF094BAF2E4F - */ -public class ExplorationGoalPriorityMultiEvaluator extends MultiEvaluator { - - /** Sorted set (order = priority, lower priority = higher priority */ - private Set<EvaluatorWrapper<?, ?, ExplorationTarget<?>>> evaluatorWrappers = - new TreeSet<EvaluatorWrapper<?, ?, ExplorationTarget<?>>>( - new EvaluatorWrapperPriorityComparator()); - - /** Creates a new {@link ExplorationGoalPriorityMultiEvaluator}. */ - @SuppressWarnings("unchecked") - @Inject - public ExplorationGoalPriorityMultiEvaluator(Set<Evaluator<Object>> evaluators, - Provider<Objectives> objectivesProvider) { - super(evaluators, objectivesProvider); - - // Set is sorted by priority - evaluatorWrappers - .addAll((Set<? extends EvaluatorWrapper<?, ?, ExplorationTarget<?>>>)evaluators); - } - - /** Priority comparator that is based on the priority provided in the goal specification */ - private static class EvaluatorWrapperPriorityComparator implements - Comparator<EvaluatorWrapper<?, ?, ExplorationTarget<?>>> { - - /** {@inheritDoc} */ - @Override - public int compare(EvaluatorWrapper<?, ?, ExplorationTarget<?>> e1, - EvaluatorWrapper<?, ?, ExplorationTarget<?>> e2) { - int p1 = e1.getPriority(); - int p2 = e2.getPriority(); - if(p1 == p2) { - // Total order required - return e1.hashCode() - e2.hashCode(); - } - return p1 - p2; - } - } - - /** Returns the EvaluatorWrappers that are also used to validate the results. */ - public Set<EvaluatorWrapper<?, ?, ExplorationTarget<?>>> getEvaluatorWrappers() { - return evaluatorWrappers; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ProblemModuleBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ProblemModuleBase.java deleted file mode 100644 index 0c1a2e5db13ff4803cff4410be691a85fdc6ed65..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/ProblemModuleBase.java +++ /dev/null @@ -1,192 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ProblemModuleBase.java 3404 2016-08-26 15:01:08Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.opt4j.core.Genotype; -import org.opt4j.core.Objective; -import org.opt4j.core.problem.Creator; -import org.opt4j.core.problem.Decoder; -import org.opt4j.core.problem.Evaluator; -import org.opt4j.core.problem.ProblemModule; - -import com.google.inject.TypeLiteral; -import com.google.inject.multibindings.Multibinder; - -/** - * Base class for a problem module that enables the registration of pre-constructed - * creators/decoders/evaluators, and which thus can be constructed using a non-default constructor. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3404 $ - * @ConQAT.Rating RED Hash: DB64E6F1AAFB963A6FDA0B91F995040A - */ -public abstract class ProblemModuleBase<G extends Genotype, R extends Creator<G>, D extends Decoder<G, ?>> - extends org.opt4j.core.problem.ProblemModule { - - /** Stores the {@link Creator} bound to this {@link ProblemModule}. */ - protected R creator; - - /** Stores the {@link Decoder} bound to this {@link ProblemModule}. */ - protected D decoder; - - /** Stores the {@link Evaluator}s bound to this {@link ProblemModule}. */ - protected Collection<EvaluatorWrapper<?, ?, ?>> evaluators; - - /** Map that stores the associations between {@link ExplorationTarget}s and Objectives. */ - protected Map<ExplorationTarget<?>, Objective> targetObjectiveAssoc; - - /** Constructor. */ - public ProblemModuleBase() { - evaluators = new HashSet<>(); - targetObjectiveAssoc = new ConcurrentHashMap<>(); - } - - /** Returns the {@link Objective} associated with the given {@link ExplorationTarget}. */ - public Objective getObjectiveOf(ExplorationTarget<?> target) { - return targetObjectiveAssoc.get(target); - } - - /** - * Registers a pre-constructed evaluator instances with the Opt4J framework. - */ - protected void addEvaluator(EvaluatorWrapper<?, ?, ?> evaluator) { - assert (false); - registerEvaluator(evaluator); - } - - /** Adds the given {@link Evaluator} to the Opt4J framework. */ - private void addEvaluator(Evaluator<?> evaluator) { - // It is crucial that the Multibinder and the TypeLiteral are defined for - // <Evaluator<Object>, since otherwise the binding of the evaluators will fail. - Multibinder<Evaluator<Object>> multibinder = - Multibinder.newSetBinder(binder(), new TypeLiteral<Evaluator<Object>>() { // - }); - - addEvaluator(evaluator, multibinder); - } - - /** - * Registers the given {@link EvaluatorWrapper} with {@code this} class such that it can be used - * for the result validation. - */ - protected void registerEvaluator(EvaluatorWrapper<?, ?, ?> evaluator) { - evaluators.add(evaluator); - } - - /** - * Registers a {@link Collection} of pre-constructed evaluator instances with the Opt4J - * framework. - */ - protected void addEvaluators(Collection<EvaluatorWrapper<?, ?, ?>> evaluators) { - - // It is crucial that the Multibinder and the TypeLiteral are defined for - // <Evaluator<Object>, since otherwise the binding of the evaluators will fail. - Multibinder<Evaluator<Object>> multibinder = - Multibinder.newSetBinder(binder(), new TypeLiteral<Evaluator<Object>>() { // - }); - - // Configure evaluators (based on provided goal specification) - for(EvaluatorWrapper<?, ?, ?> eval : evaluators) { - addEvaluator(eval, multibinder); - evaluators.add(eval); - } - } - - /** Helper method to register a pre-constructed evaluator instance with the Opt4J framework. */ - @SuppressWarnings("unchecked") - private void addEvaluator(Evaluator<? extends Object> evaluator, - Multibinder<Evaluator<Object>> multibinder) { - - // It is crucial that the Multibinder and the TypeLiteral are defined for - // <Evaluator<Object>, since otherwise the binding of the evaluators will fail. - - // This is inspired from ProblemModule.addEvaluator(), which does not allow to pass - // parameters to the constructor of the evaluators. Hence, evaluators are instantiated here, - // and the binding is performed against these instances. - multibinder.addBinding().toInstance((Evaluator<Object>)evaluator); - } - - /** Registers a pre-constructor creator and decoder with the Opt4J engine. */ - @SuppressWarnings("unchecked") - protected void bindProblem(R creator, D decoder) { - registerCreatorDecoder(creator, decoder); - - // This is inspired from ProblemModule.bindProblem(), which does not allow to pass - // parameters to the constructor of the creators/decoders. Hence, a pre-constructed - // creator/decoder is bound here. - - // Note that in contrast to ProblemModule.bindProblem(), the creator and the decoder - // are not bound in the singleton scope, since these classes need to be parameterized - // with the current input model. - binder().bind(new TypeLiteral<Creator<Genotype>>() { // empty - }).toInstance((Creator<Genotype>)creator); - - binder().bind(new TypeLiteral<Decoder<Genotype, Object>>() { // empty - }).toInstance((Decoder<Genotype, Object>)decoder); - } - - /** Registers a pre-constructor creator, decoder, and evaluator with the Opt4J engine. */ - @SuppressWarnings("unchecked") - // TODO: remove casts and rethrow the exception. - protected - void bindProblem(R creator, D decoder, Evaluator<? extends Phenotype> evaluator) { - registerCreatorDecoder(creator, decoder); - - // This is inspired from ProblemModule.bindProblem(), which does not allow to pass - // parameters to the constructor of the creators/decoders. Hence, a pre-constructed - // creator/decoder is bound here. - - // Note that in contrast to ProblemModule.bindProblem(), the creator and the decoder - // are not bound in the singleton scope, since these classes need to be parameterized - // with the current input model. - binder().bind(new TypeLiteral<Creator<Genotype>>() { // empty - }).toInstance((Creator<Genotype>)creator); - - binder().bind(new TypeLiteral<Decoder<Genotype, Object>>() { // empty - }).toInstance((Decoder<Genotype, Object>)decoder); - - addEvaluator(evaluator); - } - - /** - * Stores the associated creator and decoder at this class, if they are not already set. (They - * might be set for this {@link ProblemModule} already, if multiple {@link Evaluator}s are - * defined). - */ - private void registerCreatorDecoder(R creator, D decoder) { - if(this.creator == null) { - this.creator = creator; - } - if(this.decoder == null) { - this.decoder = decoder; - } - } - - /** Returns the set of evaluators bound to this instance of the {@link ProblemModule}. */ - public Collection<EvaluatorWrapper<?, ?, ?>> getEvaluators() { - return evaluators; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/StrictTTDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/StrictTTDecoder.java deleted file mode 100644 index a767a613c8e29cd24a687489e5c47551340931f2..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/StrictTTDecoder.java +++ /dev/null @@ -1,148 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: StrictTTDecoder.java 3455 2016-09-05 14:05:21Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem; - -import java.util.ArrayList; -import java.util.Collection; -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.taskgraph.InstantiatedAcyclicTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.InstantiatedTaskGraphEncoding; -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.backend.opt4j.extensions.compositegene.decode.ComposableDecoderBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.sched.comm.TDMABusScheduler; -import org.fortiss.af3.exploration.alg.dse.sysmodel.sched.proc.EDFSchedulerBase; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.opt4j.core.Genotype; - -import com.google.inject.Inject; - -/** - * The Decoder decodes {@link Genotype}s into phenotype objects. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3455 $ - * @ConQAT.Rating RED Hash: DB9B3A7C894FB62A238F988DDA6F7186 - */ -public class StrictTTDecoder<S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - extends ComposableDecoderBase<T, StrictTTSchedule<S, T>> implements ArchExpSubDecoder { - - /** Representation of input system model */ - private SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Underlying EDF task scheduler */ - private EDFSchedulerBase<S, T> simpleEDFScheduler; - - /** Underlying bus scheduler */ - private TDMABusScheduler<S, T> simpleBusScheduler; - - /** - * Constructs a new decoder that constructs {@link StrictTTSchedule}s for a given exploration - * run. - */ - @SuppressWarnings("unchecked") - @Inject - public StrictTTDecoder(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - this.systemModelAdapter = systemModelAdapter; - - TaskMappingFactory<?, ?> tmFactory = TaskMappingFactory.getInstance(); - - simpleEDFScheduler = - (EDFSchedulerBase<S, T>)tmFactory.createEDFScheduler(systemModelAdapter, expSpec); - simpleBusScheduler = new TDMABusScheduler<S, T>(systemModelAdapter, expSpec); - - } - - /** {@inheritDoc} */ - @Override - public StrictTTSchedule<S, T> decodeComposable(T genotype, - FlatPhenotypeMap<Phenotype> phenotypeTypeMap) { - @SuppressWarnings("unchecked") MessageEncoding<S, T> msgEnc = - phenotypeTypeMap.getEncoding(MessageEncoding.class); - assert (msgEnc != null) : "The required message encoding could not be found in the map of already decoded phenotypes."; - @SuppressWarnings("unchecked") InstantiatedAcyclicTaskGraphEncoding<S, ?> acycItgEnc = - phenotypeTypeMap.getEncoding(InstantiatedAcyclicTaskGraphEncoding.class); - assert (acycItgEnc != null) : "The required acyclic and instantiated task graph 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); - - assert (schedule.validateSchedule(true)); - - // TODO: Find out why the message scheduler does not require the task graph. Actually, it - // should require it... - simpleBusScheduler.schedule(schedule, msgEnc.getPeriodicMessages(), acycItgEnc); - assert (schedule.validateSchedule(true)); - - return schedule; - } - - /** - * {@inheritDoc} - * - * @throws DecodingException - * see {@link ComposableDecoderBase} - */ - @Override - public StrictTTSchedule<S, T> updateComposable(T inGenotype, - StrictTTSchedule<S, T> outGenotype, FlatPhenotypeMap<Phenotype> decodedPhenotypes) - throws DecodingException { - // Not required: The message encoding is a Phenotype only. - return null; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> reqTypes = new ArrayList<>(); - reqTypes.add(InstantiatedTaskMappingEncoding.class); - reqTypes.add(MessageEncoding.class); - reqTypes.add(InstantiatedAcyclicTaskGraphEncoding.class); - // FIXME: Remove as soon as the evaluators can declare their required Phenotypes!!! (Needed - // for the period evaluator) - reqTypes.add(InstantiatedTaskGraphEncoding.class); - - return reqTypes; - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Class<StrictTTSchedule<S, T>> getOutputType() { - Class<? super StrictTTSchedule<S, T>> retType = StrictTTSchedule.class; - return (Class<StrictTTSchedule<S, T>>)retType; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/comm/MessageDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/comm/MessageDecoder.java deleted file mode 100644 index 3156603f135d386a6ba11eae797566905f1f4563..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/comm/MessageDecoder.java +++ /dev/null @@ -1,144 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MessageDecoder.java 3852 2016-11-07 12:22:38Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.comm; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -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.taskgraph.InstantiatedTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoderBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.comm.Message; -import org.fortiss.af3.exploration.alg.dse.sysmodel.comm.MessageGenerator; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.comm.IMessageRouter; -import org.jgrapht.DirectedGraph; -import org.jgrapht.graph.DefaultEdge; - -import com.google.inject.Inject; - -/** - * {@link ComposableDecoder} that takes an {@link InstantiatedTaskMappingEncoding} and a) an - * generates the required messages for this {@link InstantiatedTaskMappingEncoding} and b) routes - * the generated {@link Message} on the target platform. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3852 $ - * @ConQAT.Rating RED Hash: 1AFE09EC4655ABFD18208EC432F94EFD - */ -public class MessageDecoder<S extends TaskMappingEntry, T extends TaskMappingEncoding<S>> extends - ComposableDecoderBase<T, MessageEncoding<S, T>> { - - /** References the input system models. */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** - * {@link MessageGenerator} which analyzes an {@link InstantiatedTaskMappingEncoding} and - * determines the required {@link Message}s. - */ - protected MessageGenerator<S, T> messageGenerator; - - /** References the {@link IMessageRouter} selected in the Constructor. */ - protected IMessageRouter messageRouter; - - /** Default constructor that requires a reference to the input models. */ - @Inject - public MessageDecoder(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - - TaskMappingFactory<?, ?> tmFactory = TaskMappingFactory.getInstance(); - - messageGenerator = new MessageGenerator<S, T>(systemModelAdapter); - messageRouter = tmFactory.createShortestPathRouter(systemModelAdapter); - } - - /** - * {@inheritDoc} - * - * @throws DecodingException - */ - @Override - public MessageEncoding<S, T> decodeComposable(T genotype, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) throws DecodingException { - Collection<Message> generatedMessages = messageGenerator.generateMessages(genotype); - - Map<Message, DirectedGraph<IResourceAdapter<?>, DefaultEdge>> messageRouteMap = - messageRouter.calculateMessageRoutes(generatedMessages); - if(messageRouteMap == null) { - // At least one *invalid* communication link is required by the given mapping => - // infeasible mapping. - throw new DecodingException(genotype, this, - "At least one message could not be routed from the sending unit to all its receivers."); - } - - // Add the calculated routes to the generated Messages. - for(Message msg : generatedMessages) { - msg.setRoute(messageRouteMap.get(msg)); - } - - return new MessageEncoding<>(generatedMessages); - } - - /** - * {@inheritDoc} - * - * @throws DecodingException - * see {@link ComposableDecoder}. - */ - @Override - public MessageEncoding<S, T> updateComposable(T inGenotype, MessageEncoding<S, T> outGenotype, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) throws DecodingException { - // Not required: The message encoding is a Phenotype only. - // TODO: Throw a decoding exception, instead. - return null; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> reqTypes = new ArrayList<>(); - reqTypes.add(InstantiatedTaskMappingEncoding.class); - reqTypes.add(InstantiatedTaskGraphEncoding.class); - return reqTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @SuppressWarnings("rawtypes") - @Override - public Class<MessageEncoding> getOutputType() { - return MessageEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatemapping/AbstractTaskMappingDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatemapping/AbstractTaskMappingDecoder.java deleted file mode 100644 index 2152164d770b5226efed63c5ad2f882caf0a63b4..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatemapping/AbstractTaskMappingDecoder.java +++ /dev/null @@ -1,85 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AbstractTaskMappingDecoder.java 3455 2016-09-05 14:05:21Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatemapping; - -import java.util.ArrayList; -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -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.backend.opt4j.extensions.compositegene.decode.ComposableDecoderBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.ArchExpSubDecoder; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.opt4j.core.problem.Decoder; - -import com.google.inject.Inject; - -/** - * Base class for {@link Decoder}s that instantiate {@link AbstractTaskMappingEncoding}s to - * {@link InstantiatedTaskMappingEncoding}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3455 $ - * @ConQAT.Rating RED Hash: 25AB4DF7E4D03ABAA60E7E28658DE1C1 - */ -public abstract class AbstractTaskMappingDecoder<S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - extends ComposableDecoderBase<AbstractTaskMappingEncoding, T> implements ArchExpSubDecoder { - - /** Reference to the {@link SystemModelAdapter} that handles input models for the DSE. */ - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Reference to the {@link ExplorationSpecification} specification that defines the DSE. */ - ExplorationSpecification expSpec; - - /** Constructs a new decoder that instantiates {@link AbstractTaskMappingEncoding}. */ - @Inject - public AbstractTaskMappingDecoder(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - this.systemModelAdapter = systemModelAdapter; - this.expSpec = expSpec; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> reqTypes = new ArrayList<>(); - reqTypes.add(AbstractTaskMappingEncoding.class); - reqTypes.add(AbstractTaskGraphEncoding.class); - - return reqTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - Collection<Class<?>> optTypes = new ArrayList<>(); - optTypes.add(AbstractTaskGraphEncoding.class); - return optTypes; - } - - /** {@inheritDoc} */ - @SuppressWarnings("rawtypes") - @Override - public Class<InstantiatedTaskMappingEncoding> getOutputType() { - return InstantiatedTaskMappingEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatemapping/FailSilentAbstractTaskMappingDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatemapping/FailSilentAbstractTaskMappingDecoder.java deleted file mode 100644 index 2b4008285f5de7416dbe3b473423566fc6859435..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatemapping/FailSilentAbstractTaskMappingDecoder.java +++ /dev/null @@ -1,131 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FailSilentAbstractTaskMappingDecoder.java 3964 2016-12-12 12:55:09Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatemapping; - -import static org.fortiss.tooling.common.util.LambdaUtils.filterSet; - -import java.util.ArrayList; -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FailSilentTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FailSilentTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.model.ExplorationSpecification; - -/** - * Decoder for instantiating an {@link AbstractTaskMappingEncoding} to a - * {@link FailSilentTaskMappingEncoding}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3964 $ - * @ConQAT.Rating RED Hash: A61358D62FF54024F8D3E639F4CE99F5 - */ -public class FailSilentAbstractTaskMappingDecoder extends - AbstractTaskMappingDecoder<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> { - - /** Constructor. */ - public FailSilentAbstractTaskMappingDecoder( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - super(systemModelAdapter, expSpec); - } - - /** {@inheritDoc} */ - @Override - public FailSilentTaskMappingEncoding decodeComposable(AbstractTaskMappingEncoding genotype, - FlatPhenotypeMap<Phenotype> phenotypeTypeMap) { - assert (false); - AbstractTaskGraphEncoding<?, ?> atgEnc = - phenotypeTypeMap.getEncoding(AbstractTaskGraphEncoding.class); - assert (atgEnc != null) : "The required abstract task graph encoding could not be found in the map of already decoded phenotypes."; - return new FailSilentTaskMappingEncoding(expSpec, systemModelAdapter, atgEnc, genotype); - } - - // TODO: Abstract to the AbstractTaskMappingDecoder. - /** - * {@inheritDoc} - * - * @throws DecodingException - * see {@link ComposableDecoder}. - */ - @Override - public FailSilentTaskMappingEncoding - updateComposable(AbstractTaskMappingEncoding inGenotype, - FailSilentTaskMappingEncoding outGenotype, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) throws DecodingException { - outGenotype.replaceConstraints(inGenotype.getConstraints()); - - for(IDeployableComponentAdapter<?> comp : inGenotype.getDeployedComponents()) { - Collection<AbstractTaskMappingEntry> abstrEntries = - inGenotype.getMappingEntriesOf(comp); - Collection<FailSilentTaskMappingEntry> instEntries; - if(comp.isInstantiationRequired()) { - instEntries = - filterSet(outGenotype.getMappingEntries(), e -> e.getDeployableComponent() - .getReplacedComponent() == comp); - } else { - instEntries = outGenotype.getMappingEntriesOf(comp); - } - - // Missing Associations between instantiated and abstract entries indicate the need to - // create or remove corresp. entries. - for(AbstractTaskMappingEntry abstrEntry : abstrEntries) { - if(abstrEntry.getAssociatedElement().isEmpty()) { - outGenotype.createAndAddEntry(abstrEntry); - } - } - - Collection<FailSilentTaskMappingEntry> rmEntries = new ArrayList<>(); - for(FailSilentTaskMappingEntry instEntry : instEntries) { - if(instEntry.getAssociatedElement().isEmpty()) { - rmEntries.add(instEntry); - } - } - rmEntries.forEach(e -> outGenotype.removeEntry(e)); - } - - // Remove all tasks that are present in the output encoding but not in the input encoding. - Collection<IDeployableComponentAdapter<?>> rmTasks = new ArrayList<>(); - for(IDeployableComponentAdapter<?> comp : outGenotype.getDeployedComponents()) { - IDeployableComponentAdapter<?> rmComponent = comp; - if(comp.isInstantiation()) { - comp = comp.getReplacedComponent(); - } - if(!inGenotype.getDeployedComponents().contains(comp)) { - rmTasks.add(rmComponent); - } - } - rmTasks.forEach(e -> outGenotype.removeTask(e)); - - for(FailSilentTaskMappingEntry entry : outGenotype.getMappingEntries()) { - entry.resetTarget(entry.getAssociatedElement(AbstractTaskMappingEntry.class) - .getTarget()); - } - - return outGenotype; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatemapping/FaultDetectionVotingAbstractTaskMappingDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatemapping/FaultDetectionVotingAbstractTaskMappingDecoder.java deleted file mode 100644 index 8f32e0c726229464eee259bd114826294b963127..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatemapping/FaultDetectionVotingAbstractTaskMappingDecoder.java +++ /dev/null @@ -1,132 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FaultDetectionVotingAbstractTaskMappingDecoder.java 3964 2016-12-12 12:55:09Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatemapping; - -import static org.fortiss.tooling.common.util.LambdaUtils.filterSet; - -import java.util.ArrayList; -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FaultDetectionVotingTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FaultDetectionVotingTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.opt4j.core.problem.Decoder; - -/** - * {@link Decoder} for instantiating an {@link AbstractTaskMappingEncoding} to a - * {@link FaultDetectionVotingTaskMappingEncoding}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3964 $ - * @ConQAT.Rating RED Hash: 9194E3ABADE5223BA1A30E9A1190240D - */ -public class FaultDetectionVotingAbstractTaskMappingDecoder - extends - AbstractTaskMappingDecoder<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> { - - /** Constructor. */ - public FaultDetectionVotingAbstractTaskMappingDecoder( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - super(systemModelAdapter, expSpec); - } - - /** {@inheritDoc} */ - @Override - public FaultDetectionVotingTaskMappingEncoding decodeComposable( - AbstractTaskMappingEncoding genotype, FlatPhenotypeMap<Phenotype> phenotypeTypeMap) { - assert (false); - AbstractTaskGraphEncoding<?, ?> atgEnc = - phenotypeTypeMap.getEncoding(AbstractTaskGraphEncoding.class); - assert (atgEnc != null) : "The required abstract task graph encoding could not be found in the map of already decoded phenotypes."; - return new FaultDetectionVotingTaskMappingEncoding(expSpec, systemModelAdapter, atgEnc, - genotype); - } - - /** - * {@inheritDoc} - * - * @throws DecodingException - * see {@link DecodingException}. - */ - @Override - public FaultDetectionVotingTaskMappingEncoding updateComposable( - AbstractTaskMappingEncoding inGenotype, - FaultDetectionVotingTaskMappingEncoding outGenotype, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) throws DecodingException { - outGenotype.replaceConstraints(inGenotype.getConstraints()); - - for(IDeployableComponentAdapter<?> comp : inGenotype.getDeployedComponents()) { - Collection<AbstractTaskMappingEntry> abstrEntries = - inGenotype.getMappingEntriesOf(comp); - Collection<FaultDetectionVotingTaskMappingEntry> instEntries; - if(comp.isInstantiationRequired()) { - instEntries = - filterSet(outGenotype.getMappingEntries(), e -> e.getDeployableComponent() - .getReplacedComponent() == comp); - } else { - instEntries = outGenotype.getMappingEntriesOf(comp); - } - - // Missing Associations between instantiated and abstract entries indicate the need to - // create or remove corresp. entries. - for(AbstractTaskMappingEntry abstrEntry : abstrEntries) { - if(abstrEntry.getAssociatedElement().isEmpty()) { - outGenotype.createAndAddEntry(abstrEntry); - } - } - - Collection<FaultDetectionVotingTaskMappingEntry> rmEntries = new ArrayList<>(); - for(FaultDetectionVotingTaskMappingEntry instEntry : instEntries) { - if(instEntry.getAssociatedElement().isEmpty()) { - rmEntries.add(instEntry); - } - } - rmEntries.forEach(e -> outGenotype.removeEntry(e)); - } - - // Remove all tasks that are present in the output encoding but not in the input encoding. - Collection<IDeployableComponentAdapter<?>> rmTasks = new ArrayList<>(); - for(IDeployableComponentAdapter<?> comp : outGenotype.getDeployedComponents()) { - IDeployableComponentAdapter<?> rmComponent = comp; - if(comp.isInstantiation()) { - comp = comp.getReplacedComponent(); - } - if(!inGenotype.getDeployedComponents().contains(comp)) { - rmTasks.add(rmComponent); - } - } - rmTasks.forEach(e -> outGenotype.removeTask(e)); - - for(FaultDetectionVotingTaskMappingEntry entry : outGenotype.getMappingEntries()) { - entry.resetTarget(entry.getAssociatedElement(AbstractTaskMappingEntry.class) - .getTarget()); - } - - return outGenotype; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatetaskgraph/InstantiatedTaskMappingDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatetaskgraph/InstantiatedTaskMappingDecoder.java deleted file mode 100644 index 094032bd255bd9ed14ba8b1824e6e201a53be97a..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatetaskgraph/InstantiatedTaskMappingDecoder.java +++ /dev/null @@ -1,322 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: InstantiatedTaskMappingDecoder.java 3841 2016-11-04 14:51:29Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatetaskgraph; - -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.castToRawColl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.stream.Collectors; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.InstantiatedTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -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.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoderBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.ChannelAdapterWeightedEdge; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.DefaultTaskGraph; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraphInstantiator; - -import com.google.inject.Inject; - -/** - * {@link ComposableDecoder} that takes an {@link InstantiatedTaskMappingEncoding} as input and - * generates an {@link InstantiatedTaskGraphEncoding} from it. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3841 $ - * @ConQAT.Rating RED Hash: 829C5647738AABB80395B7C05D57AEB6 - */ -public class InstantiatedTaskMappingDecoder<T extends InstantiatedTaskMappingEntry, C> - extends - ComposableDecoderBase<InstantiatedTaskMappingEncoding<T>, InstantiatedTaskGraphEncoding<T, C>> { - - /** Representation of input system model */ - private SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Constructs a new decoder to generate {@link InstantiatedTaskGraphEncoding}. */ - @Inject - public InstantiatedTaskMappingDecoder(SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } - - /** {@inheritDoc} */ - @Override - public InstantiatedTaskGraphEncoding<T, C> decodeComposable( - InstantiatedTaskMappingEncoding<T> genotype, - FlatPhenotypeMap<Phenotype> phenotypeTypeMap) throws DecodingException { - @SuppressWarnings("unchecked") AbstractTaskGraphEncoding<AbstractTaskMappingEncoding, C> atgEnc = - phenotypeTypeMap.getEncoding(AbstractTaskGraphEncoding.class); - assert (atgEnc != null) : "The required abstract task graph encoding could not be found in the map of already decoded phenotypes."; - - SafetyFunctionArchEncoding<?> sfEnc = - phenotypeTypeMap.getEncoding(SafetyFunctionArchEncoding.class); - - Collection<DefaultTaskGraph> tgColl = atgEnc.getTaskGraphs(); - TaskGraphInstantiator<DefaultTaskGraph> tgInstatiator = - new TaskGraphInstantiator<>(tgColl, genotype); - InstantiatedTaskGraphEncoding<T, C> itgEnc = - new InstantiatedTaskGraphEncoding<T, C>(systemModelAdapter, - tgInstatiator.createMultipleInstanceTaskGraphs(tgColl)); - - if(sfEnc != null) { - removeInterSafetyChannelSignals(sfEnc, itgEnc); - } - - return itgEnc; - } - - /** - * Removes signals from the {@link InstantiatedTaskGraphEncoding} that were introduced by - * replications but which connect independent safety channels. This is not desired, so remove - * all edges (signals) in the task graph that induce connections between the safety channels. - */ - // FIXME: also consider other realizing components. - // TODO: consider moving this operation - private void removeInterSafetyChannelSignals(SafetyFunctionArchEncoding<?> sfEnc, - InstantiatedTaskGraphEncoding<T, C> itgEnc) throws DecodingException { - for(SafetyFunctionArchEntry<?> sfEntry : sfEnc.getAllEntries()) { - Collection<IDeployableComponentAdapter<?>> sfCompAdps = - castToRawColl(sfEntry.getSafetyFunctionAdapter().getRealizingComponents()); - assert (sfCompAdps.size() > 0); - IDeployableComponentAdapter<?> sfCompAdp = sfCompAdps.stream().findAny().get(); - - // Get the "containing" task graph. We must check all replacement components (instances) - // since we don't know which one was instantiated (or it would be more costly to find - // out). - DefaultTaskGraph sfTG = null; - for(IDeployableComponentAdapter<?> curSFCompAdp : sfCompAdp.getReplacementComponents()) { - sfTG = itgEnc.getTaskGraphOf(curSFCompAdp); - if(sfTG != null) { - break; - } - } - if(sfTG == null) { - throw new DecodingException(sfEnc, this, "Could not retrieve the TaskGraph" + - " of the Component Adapter " + sfCompAdp.getName() + "."); - } - - // TODO: Remove non-allowed communication using the commented out code below to obtain - // a more consistent and generic solution. - // for(InternalIsolatedCommunicationSet isoCommSet : genotype - // .getConstraintsOf(InternalIsolatedCommunicationSet.class)) { - // Collection<IMappingEntry> entries = isoCommSet.getIsolatedCommunicationSet(); - // Collection<IDeployableComponentAdapter<?>> compAdps = - // map(entries, e -> e.getDeployableComponent()); - // for(IMappingEntry entry : entries) { - // IMappingEntry instEntry = entry.getAssociatedElement().stream().findAny().get(); - // IDeployableComponentAdapter<?> currComp = instEntry.getDeployableComponent(); - // Collection<InternalIsolatedCommunicationSet> others = - // getOtherIsolationCommConstraints(genotype, entry); - // Collection<IDeployableComponentAdapter<?>> connComps = - // Graphs.successorListOf(sfTG.getGraph(), currComp); - // for(IDeployableComponentAdapter<?> connCompAdp : connComps) { - // if(isPartOfOtherIsolationCommConstraint(others, connCompAdp)) { - // sfTG.getGraph().removeEdge(currComp, connCompAdp); - // } - // } - // - // connComps = Graphs.predecessorListOf(sfTG.getGraph(), currComp); - // for(IDeployableComponentAdapter<?> connCompAdp : connComps) { - // if(isPartOfOtherIsolationCommConstraint(others, connCompAdp)) { - // sfTG.getGraph().removeEdge(connCompAdp, currComp); - // } - // } - // } - // } - - Collection<IDeployableComponentAdapter<?>> connectedSFUnits = new ArrayList<>(); - Collection<IDeployableComponentAdapter<?>> connectedDiagUnits = new ArrayList<>(); - Collection<IDeployableComponentAdapter<?>> connectedOutUnit = new ArrayList<>(); - for(int channelIdx = 0; channelIdx < sfEntry.getNumChannels(); channelIdx++) { - Collection<IDeployableComponentAdapter<?>> sfUnits = - castToRawColl(sfEntry.getSafetyFunctionAdapter().getRealizingComponents()); - Collection<IDeployableComponentAdapter<?>> diagUnits = - castToRawColl(sfEntry.getSafetyFunctionAdapter().getDiagnosticComponents()); - // TODO: knowledge about the modeL: output unit not instantiated: - IDeployableComponentAdapter<?> outputUnit = - sfEntry.getSafetyFunctionAdapter().getOutputComponent(); - // TODO: only for a single diag unit. - Collection<IDeployableComponentAdapter<?>> realizingSFUnits = - itgEnc.getDeployableComponents().stream() - .filter(d -> sfUnits.contains(d.getReplacedComponent())) - .collect(Collectors.toList()); - Collection<IDeployableComponentAdapter<?>> realizingDiagUnits = - itgEnc.getDeployableComponents().stream() - .filter(d -> diagUnits.contains(d.getReplacedComponent())) - .collect(Collectors.toList()); - Collection<IDeployableComponentAdapter<?>> outComps = - itgEnc.getDeployableComponents().stream() - .filter(d -> d.getObject() == outputUnit.getObject()) - .collect(Collectors.toList()); - - // Pick an sf component instance that is assigned to the current channel. - IDeployableComponentAdapter<?> currentChannelSFUnit = null; - for(IDeployableComponentAdapter<?> curSFUnit : realizingSFUnits) { - if(!connectedSFUnits.contains(curSFUnit)) { - // Remember that the diagnostic unit is associated with one channel --> no - // elimination of the signal. - connectedSFUnits.add(curSFUnit); - currentChannelSFUnit = curSFUnit; - break; - } - } - // Pick an diagnostic component instance that is assigned to the current channel. - IDeployableComponentAdapter<?> currentChannelDiagUnit = null; - for(IDeployableComponentAdapter<?> curDiagUnit : realizingDiagUnits) { - if(!connectedDiagUnits.contains(curDiagUnit)) { - // Remember that the diagnostic unit is associated with one channel --> no - // elimination of the signal. - connectedDiagUnits.add(curDiagUnit); - currentChannelDiagUnit = curDiagUnit; - break; - } - } - // Pick an io component instance that is assigned to the current channel. - IDeployableComponentAdapter<?> currentChannelOutputUnit = null; - for(IDeployableComponentAdapter<?> curOutUnit : outComps) { - if(!connectedOutUnit.contains(curOutUnit)) { - // Remember that the diagnostic unit is associated with one channel --> no - // elimination of the signal. - connectedDiagUnits.add(curOutUnit); - currentChannelOutputUnit = curOutUnit; - break; - } - } - - for(IDeployableComponentAdapter<?> curSFUnit : realizingSFUnits) { - if(currentChannelSFUnit != curSFUnit) { - // Eliminate all other signals to different channels. - ChannelAdapterWeightedEdge interChannelSignal = - sfTG.getGraph().getEdge(currentChannelDiagUnit, curSFUnit); - sfTG.getGraph().removeEdge(interChannelSignal); - interChannelSignal = - sfTG.getGraph().getEdge(currentChannelOutputUnit, curSFUnit); - sfTG.getGraph().removeEdge(interChannelSignal); - } - } - for(IDeployableComponentAdapter<?> curDiagUnit : realizingDiagUnits) { - if(currentChannelDiagUnit != curDiagUnit) { - // Eliminate all other signals to different channels. - ChannelAdapterWeightedEdge interChannelSignal = - sfTG.getGraph().getEdge(currentChannelSFUnit, curDiagUnit); - sfTG.getGraph().removeEdge(interChannelSignal); - interChannelSignal = - sfTG.getGraph().getEdge(currentChannelOutputUnit, curDiagUnit); - sfTG.getGraph().removeEdge(interChannelSignal); - } - } - for(IDeployableComponentAdapter<?> curOutUnit : outComps) { - if(currentChannelOutputUnit != curOutUnit) { - // Eliminate all other signals to different channels. - ChannelAdapterWeightedEdge interChannelSignal = - sfTG.getGraph().getEdge(currentChannelSFUnit, curOutUnit); - sfTG.getGraph().removeEdge(interChannelSignal); - interChannelSignal = - sfTG.getGraph().getEdge(currentChannelDiagUnit, curOutUnit); - sfTG.getGraph().removeEdge(interChannelSignal); - } - } - } - } - } - - // TODO: Remove non-allowed communication using the commented out code above and below to obtain - // a more consistent and generic solution. - // private Collection<InternalIsolatedCommunicationSet> getOtherIsolationCommConstraints( - // TaskMappingEncoding<?> encoding, IMappingEntry entry) { - // // TODO: here we use the knowledge that we have instantiated task mapping entries. - // IMappingEntry actualEntry = entry.getAssociatedElement(AbstractTaskMappingEntry.class); - // - // Collection<InternalIsolatedCommunicationSet> otherConstraints = new HashSet<>(); - // Collection<InternalIsolatedCommunicationSet> isoComm = - // encoding.getConstraintsOf(InternalIsolatedCommunicationSet.class); - // for(InternalIsolatedCommunicationSet constr : isoComm) { - // if(!constr.getIsolatedCommunicationSet().contains(actualEntry)) { - // otherConstraints.add(constr); - // } - // } - // - // return otherConstraints; - // } - // - // private boolean isPartOfOtherIsolationCommConstraint( - // Collection<InternalIsolatedCommunicationSet> other, - // IDeployableComponentAdapter<?> compAdp) { - // for(InternalIsolatedCommunicationSet constr : other) { - // for(IMappingEntry entry : constr.getIsolatedCommunicationSet()) { - // if(entry.getAssociatedElement().stream().findAny().get().getDeployableComponent() == compAdp) - // { - // return true; - // } - // } - // } - // - // return false; - // } - - /** - * {@inheritDoc} - * - * @throws DecodingException - * see {@link ComposableDecoder}. - */ - @Override - public InstantiatedTaskGraphEncoding<T, C> updateComposable( - InstantiatedTaskMappingEncoding<T> inGenotype, - InstantiatedTaskGraphEncoding<T, C> outGenotype, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) throws DecodingException { - // Not required: The InstantiatedTaskGraphEncoding is a Phenotype only. - // TODO: Throw a decoding exception, instead. - return null; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> reqTypes = new ArrayList<>(); - reqTypes.add(InstantiatedTaskMappingEncoding.class); - reqTypes.add(AbstractTaskGraphEncoding.class); - return reqTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - Collection<Class<?>> optTypes = new ArrayList<>(); - optTypes.add(SafetyFunctionArchEncoding.class); - return optTypes; - } - - /** {@inheritDoc} */ - @SuppressWarnings("rawtypes") - @Override - public Class<InstantiatedTaskGraphEncoding> getOutputType() { - return InstantiatedTaskGraphEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatetaskgraph/InstantiatedTaskMappingDecoderAcyclic.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatetaskgraph/InstantiatedTaskMappingDecoderAcyclic.java deleted file mode 100644 index abc1f0f67d2608abbade58002d182e66d231aec1..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/instantiatetaskgraph/InstantiatedTaskMappingDecoderAcyclic.java +++ /dev/null @@ -1,122 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: InstantiatedTaskMappingDecoderAcyclic.java 3841 2016-11-04 14:51:29Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatetaskgraph; - -import java.util.ArrayList; -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.InstantiatedAcyclicTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.InstantiatedTaskGraphEncoding; -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.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoderBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; - -import com.google.inject.Inject; - -/** - * {@link ComposableDecoder} that takes an {@link InstantiatedTaskMappingEncoding} as input and - * generates an {@link InstantiatedAcyclicTaskGraphEncoding} from it. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3841 $ - * @ConQAT.Rating RED Hash: 40DCEDA0CAD2CBC88189576F8F4EC089 - */ -public class InstantiatedTaskMappingDecoderAcyclic<T extends InstantiatedTaskMappingEntry, C> - extends - ComposableDecoderBase<InstantiatedTaskMappingEncoding<T>, InstantiatedAcyclicTaskGraphEncoding<T, C>> { - - /** Representation of input system model */ - private SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Constructs a new decoder to generate {@link InstantiatedTaskGraphEncoding}. */ - @Inject - public InstantiatedTaskMappingDecoderAcyclic( - SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } - - /** {@inheritDoc} */ - @Override - public InstantiatedAcyclicTaskGraphEncoding<T, C> decodeComposable( - InstantiatedTaskMappingEncoding<T> genotype, - FlatPhenotypeMap<Phenotype> phenotypeTypeMap) { - // TODO: automate the retrieval of phenotypes. - @SuppressWarnings("unchecked") AbstractTaskGraphEncoding<InstantiatedTaskMappingEncoding<T>, C> atgEnc = - phenotypeTypeMap.getEncoding(AbstractTaskGraphEncoding.class); - assert (atgEnc != null) : "The required abstract task graph encoding could not be found in the map of already decoded phenotypes."; - - @SuppressWarnings("unchecked") InstantiatedTaskGraphEncoding<T, C> itgEnc = - phenotypeTypeMap.getEncoding(InstantiatedTaskGraphEncoding.class); - assert (itgEnc != null) : "The required abstract task graph encoding could not be found in the map of already decoded phenotypes."; - - InstantiatedAcyclicTaskGraphEncoding<T, C> iAtgEnc = - new InstantiatedAcyclicTaskGraphEncoding<T, C>(systemModelAdapter, - itgEnc.getTaskGraphs()); - - return iAtgEnc; - } - - /** - * {@inheritDoc} - * - * @throws DecodingException - * see {@link ComposableDecoder}. - */ - @Override - public InstantiatedAcyclicTaskGraphEncoding<T, C> updateComposable( - InstantiatedTaskMappingEncoding<T> inGenotype, - InstantiatedAcyclicTaskGraphEncoding<T, C> outGenotype, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) throws DecodingException { - // Not required: The InstantiatedTaskGraphEncoding is a Phenotype only. - // TODO: Throw a decoding exception, instead. - return null; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> reqTypes = new ArrayList<>(); - reqTypes.add(InstantiatedTaskMappingEncoding.class); - reqTypes.add(InstantiatedTaskGraphEncoding.class); - - return reqTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - Collection<Class<?>> optTypes = new ArrayList<>(); - optTypes.add(SafetyFunctionArchEncoding.class); - return optTypes; - } - - /** {@inheritDoc} */ - @SuppressWarnings("rawtypes") - @Override - public Class<InstantiatedAcyclicTaskGraphEncoding> getOutputType() { - return InstantiatedAcyclicTaskGraphEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/safetyfunction/SFEncodingDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/safetyfunction/SFEncodingDecoder.java deleted file mode 100644 index 2bbf3b66c90f6aa92fa5877193c1aebc2dd59aa6..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/safetyfunction/SFEncodingDecoder.java +++ /dev/null @@ -1,93 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SFEncodingDecoder.java 3478 2016-09-09 09:54:32Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.safetyfunction; - -import java.util.ArrayList; -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoderBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.ArchExpSubDecoder; - -/** - * Provides a {@link SafetyFunctionArchEncoding} to the set of {@link ComposablePhenotype} types. - * This {@link ComposableDecoder} is an identity operation. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3478 $ - * @ConQAT.Rating RED Hash: D593D50BC45DD092931F3AA73FA628C0 - */ -public class SFEncodingDecoder<C> extends - ComposableDecoderBase<SafetyFunctionArchEncoding<C>, SafetyFunctionArchEncoding<C>> - implements ArchExpSubDecoder { - - /** - * {@inheritDoc} - * - * @throws DecodingException - * see {@link ComposableDecoderBase}. - */ - @Override - public SafetyFunctionArchEncoding<C> decodeComposable(SafetyFunctionArchEncoding<C> genotype, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) throws DecodingException { - return genotype; - } - - /** - * {@inheritDoc} - * - * @throws DecodingException - * see {@link ComposableDecoderBase}. - */ - @Override - public SafetyFunctionArchEncoding<C> - updateComposable(SafetyFunctionArchEncoding<C> inGenotype, - SafetyFunctionArchEncoding<C> outGenotype, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) throws DecodingException { - return inGenotype; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> reqTypes = new ArrayList<>(); - reqTypes.add(SafetyFunctionArchEncoding.class); - return reqTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - Collection<Class<?>> optTypes = new ArrayList<>(); - return optTypes; - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Class<SafetyFunctionArchEncoding<C>> getOutputType() { - Class<? super SafetyFunctionArchEncoding<C>> retType = SafetyFunctionArchEncoding.class; - return (Class<SafetyFunctionArchEncoding<C>>)retType; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/safetyfunction/SFGraphDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/safetyfunction/SFGraphDecoder.java deleted file mode 100644 index 8ceddd6ed4d2fc41cb06536b6132f91c630efabe..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/safetyfunction/SFGraphDecoder.java +++ /dev/null @@ -1,168 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SFGraphDecoder.java 3478 2016-09-09 09:54:32Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.safetyfunction; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.SafeTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.TaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoderBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.CompositeDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.ArchExpSubDecoder; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; - -import com.google.inject.Inject; - -/** - * {@link ComposableDecoder} that generates {@link IDeployableComponentAdapter}s from the - * chosen architecture of a safety function. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3478 $ - * @ConQAT.Rating RED Hash: 0443FC28E6F94A9A6BA5ADA92F01BBFF - */ -public class SFGraphDecoder<C> extends - ComposableDecoderBase<SafetyFunctionArchEncoding<C>, SafeTaskGraphEncoding<C>> implements - ArchExpSubDecoder { - - /** Reference to the {@link SystemModelAdapter} that handles input models for the DSE. */ - SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Constructs a new decoder that instantiates {@link AbstractTaskMappingEncoding}. */ - @Inject - public SFGraphDecoder(SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } - - /** {@inheritDoc} */ - @Override - public SafeTaskGraphEncoding<C> decodeComposable(SafetyFunctionArchEncoding<C> genotype, - FlatPhenotypeMap<Phenotype> phenotypetypeMap) { - if(genotype == null) { - return null; - } - // TODO: we should dynamically retrieve the encoding here, since the statement below assumes - // that this decoding step is performed before others. - SafeTaskGraphEncoding<C> encoding = new SafeTaskGraphEncoding<>(systemModelAdapter); - - for(SafetyFunctionArchEntry<C> sFAEntry : genotype.getAllEntries()) { - boolean diagPresent = sFAEntry.isDiagnosicUnitPresent(); - if(!diagPresent && containsDiagUnits(sFAEntry, encoding)) { - removeDiagUnits(sFAEntry, encoding); - } else if(diagPresent && !containsDiagUnits(sFAEntry, encoding)) { - addDiagUnits(sFAEntry, encoding); - } - } - - return encoding; - } - - /** - * {@inheritDoc} - * - * @throws DecodingException - * see {@link CompositeDecoder}. - */ - @Override - public SafeTaskGraphEncoding<C> updateComposable(SafetyFunctionArchEncoding<C> inGenotype, - SafeTaskGraphEncoding<C> outGenotype, FlatPhenotypeMap<Phenotype> decodedPhenotypes) - throws DecodingException { - // Not required: The abstract task graph encoding is a Phenotype only. - // TODO: Throw a decoding exception, instead. - return null; - } - - /** - * Checks whether the given {@link TaskGraphEncoding} contains diagnostic units from the given - * {@link SafetyFunctionArchEntry}. - */ - private boolean containsDiagUnits(SafetyFunctionArchEntry<C> sFAEntry, - SafeTaskGraphEncoding<C> encoding) { - Collection<IDeployableComponentAdapter<C>> sfComps = - sFAEntry.getSafetyFunctionAdapter().getDiagnosticComponents(); - if(!sfComps.isEmpty()) { - return encoding.containsTask(sfComps.stream().findAny().get()); - } - return false; - } - - /** - * Adds the diagnostic units from the {@link SafetyFunctionArchEntry} to the - * {@link TaskGraphEncoding}. - */ - private void - addDiagUnits(SafetyFunctionArchEntry<C> sFAEntry, SafeTaskGraphEncoding<C> encoding) { - Collection<IDeployableComponentAdapter<C>> diagComps = - sFAEntry.getSafetyFunctionAdapter().getDiagnosticComponents(); - addTasks(diagComps, encoding); - } - - /** - * Adds the given collection of {@link IDeployableComponentAdapter}s from the - * {@link SafetyFunctionArchEntry} to the {@link TaskGraphEncoding}. - */ - private void addTasks(Collection<IDeployableComponentAdapter<C>> deplComp, - SafeTaskGraphEncoding<C> encoding) { - // Add the Components. - deplComp.stream().forEach(task -> encoding.addTask(task)); - - // Add the corresponding signals. - deplComp.stream().forEach(task -> encoding.addSignalsOf(task)); - } - - /** Removes the diagnostic units from the {@link TaskGraphEncoding}. */ - private void removeDiagUnits(SafetyFunctionArchEntry<C> sFAEntry, - SafeTaskGraphEncoding<C> encoding) { - Collection<IDeployableComponentAdapter<C>> sfComps = - sFAEntry.getSafetyFunctionAdapter().getDiagnosticComponents(); - sfComps.stream().forEach(t -> encoding.removeTask(t)); - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> reqTypes = new ArrayList<>(); - reqTypes.add(SafetyFunctionArchEncoding.class); - return reqTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @SuppressWarnings("rawtypes") - @Override - public Class<AbstractTaskGraphEncoding> getOutputType() { - return AbstractTaskGraphEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/safetyfunction/SFMappingConstraintDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/safetyfunction/SFMappingConstraintDecoder.java deleted file mode 100644 index 013a1e3e3444a7aeb37913175a1b5431af853ec6..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/safetyfunction/SFMappingConstraintDecoder.java +++ /dev/null @@ -1,139 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.safetyfunction; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.constraint.InternalReplicationConstraint; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.constraint.InternalSeparationConstraint; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoderBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.decode.ConstraintGenerationDecoder; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISafetyFunctionAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; - -import com.google.inject.Inject; - -/** - * Generates allocation and replication constraints for the safety architectures of the safety - * function of a given {@link SafetyFunctionArchEncoding}. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: FD352BE664B41E2CD4FBEC70BF56C81D - */ -public class SFMappingConstraintDecoder<C> extends - ComposableDecoderBase<SafetyFunctionArchEncoding<C>, AbstractTaskMappingEncoding> implements - ConstraintGenerationDecoder { - - // TODO: replace with a dynamic mechanism for the retrieval of deployable components. - /** Reference to the {@link SystemModelAdapter} that handles input models for the DSE. */ - private SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Constructs a new decoder that instantiates {@link AbstractTaskMappingEncoding}. */ - @Inject - public SFMappingConstraintDecoder(SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } - - /** {@inheritDoc} */ - @Override - public AbstractTaskMappingEncoding decodeComposable(SafetyFunctionArchEncoding<C> genotype, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) { - return null; - } - - /** {@inheritDoc} */ - @Override - public AbstractTaskMappingEncoding updateComposable(SafetyFunctionArchEncoding<C> inGenotype, - AbstractTaskMappingEncoding outGenotype, FlatPhenotypeMap<Phenotype> decodedPhenotypes) { - Collection<IDeployableComponentAdapter<C>> deplComps = new HashSet<>(); - deplComps.addAll(systemModelAdapter.getDeployableComponents()); - for(SafetyFunctionArchEntry<C> sFAEntry : inGenotype.getAllEntries()) { - int channelNumber = sFAEntry.getNumChannels(); - - Collection<InternalReplicationConstraint> replicationConstraints = new HashSet<>(); - for(IDeployableComponentAdapter<?> comp : sFAEntry.getSafetyFunctionAdapter() - .getAllComponents()) { - replicationConstraints.add(new InternalReplicationConstraint(comp, channelNumber, - channelNumber)); - } - - outGenotype.replaceConstraints(InternalReplicationConstraint.class, - replicationConstraints); - } - - outGenotype.replaceConstraints(InternalSeparationConstraint.class, - createSeparationConstraints(inGenotype)); - - return outGenotype; - } - - /** - * Creates {@link InternalSeparationConstraint}s for the sets of realizing, diagnostic, and - * output units of each safety function. - */ - private Collection<InternalSeparationConstraint> createSeparationConstraints( - SafetyFunctionArchEncoding<C> sfEnc) { - Collection<InternalSeparationConstraint> sepConstraints = new HashSet<>(); - - for(SafetyFunctionArchEntry<C> sfEntry : sfEnc.getAllEntries()) { - ISafetyFunctionAdapter<C> sfAdp = sfEntry.getSafetyFunctionAdapter(); - - // TODO: We should not be aware of the Tile type here. - sepConstraints.add(new InternalSeparationConstraint(sfAdp.getRealizingComponents(), - systemModelAdapter.getFaultContainmentRegion())); - sepConstraints.add(new InternalSeparationConstraint(sfAdp.getDiagnosticComponents(), - systemModelAdapter.getFaultContainmentRegion())); - sepConstraints.add(new InternalSeparationConstraint(Arrays.asList(sfAdp - .getOutputComponent()), systemModelAdapter.getFaultContainmentRegion())); - } - - return sepConstraints; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> requiredTypes = new HashSet<>(); - requiredTypes.add(SafetyFunctionArchEncoding.class); - return requiredTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Class<? super AbstractTaskMappingEncoding> getOutputType() { - return AbstractTaskMappingEncoding.class; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/safetyfunction/SFMappingDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/safetyfunction/SFMappingDecoder.java deleted file mode 100644 index 6b23dd313067a76d33ef72005bc621a3ec670b7e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/safetyfunction/SFMappingDecoder.java +++ /dev/null @@ -1,311 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SFMappingDecoder.java 3964 2016-12-12 12:55:09Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.safetyfunction; - -import static org.fortiss.tooling.common.util.LambdaUtils.getFirst; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.comm.constraint.InternalIsolatedCommunicationSet; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoderBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.DecodingException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.decode.ConstraintGenerationDecoder; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; - -import com.google.inject.Inject; - -/** - * Decodes a {@link SafetyFunctionArchEncoding} into an {@link AbstractTaskMappingEncoding}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3964 $ - * @ConQAT.Rating RED Hash: F9AB4D996C8985AC1939B5FAD7D34721 - */ -public class SFMappingDecoder<C> extends - ComposableDecoderBase<SafetyFunctionArchEncoding<C>, AbstractTaskMappingEncoding> implements - ConstraintGenerationDecoder { - - // TODO: replace with a dynamic mechanism for the retrieval of deployable components. - /** Reference to the {@link SystemModelAdapter} that handles input models for the DSE. */ - private SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Constructs a new decoder that instantiates {@link AbstractTaskMappingEncoding}. */ - @Inject - public SFMappingDecoder(SystemModelAdapter<C, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } - - /** - * {@inheritDoc} - * - * @throws DecodingException - * see {@link ComposableDecoder}. - */ - @Override - public AbstractTaskMappingEncoding decodeComposable(SafetyFunctionArchEncoding<C> genotype, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) throws DecodingException { - AbstractTaskMappingEncoding atmEnc = - decodedPhenotypes.getEncoding(AbstractTaskMappingEncoding.class); - assert (atmEnc != null) : "The required abstract task mapping encoding could not be found in the map of already decoded phenotypes."; - return updateComposable(genotype, atmEnc, decodedPhenotypes); - } - - /** - * {@inheritDoc} - * - * @throws DecodingException - * see {@link ComposableDecoder}. - */ - @Override - public AbstractTaskMappingEncoding updateComposable(SafetyFunctionArchEncoding<C> inGenotype, - AbstractTaskMappingEncoding outGenotype, FlatPhenotypeMap<Phenotype> decodedPhenotypes) - throws DecodingException { - if(inGenotype == null) { - return null; - } - - // TODO: replace with a dynamic mechanism for the retrieval of deployable components. - Collection<IDeployableComponentAdapter<C>> deplComps = new HashSet<>(); - deplComps.addAll(systemModelAdapter.getDeployableComponents()); - for(SafetyFunctionArchEntry<C> sFAEntry : inGenotype.getAllEntries()) { - boolean diagPresent = sFAEntry.isDiagnosicUnitPresent(); - int channelNumber = sFAEntry.getNumChannels(); - - Collection<IDeployableComponentAdapter<C>> sfComps = - sFAEntry.getSafetyFunctionAdapter().getRealizingComponents(); - Collection<IDeployableComponentAdapter<C>> diagComps = - sFAEntry.getSafetyFunctionAdapter().getDiagnosticComponents(); - IDeployableComponentAdapter<C> outComponent = - sFAEntry.getSafetyFunctionAdapter().getOutputComponent(); - - // We assume that the entry number must be equal for all realizing components of a - // safety function. - Collection<AbstractTaskMappingEntry> sfEntries = - outGenotype.getMappingEntriesOf(sfComps.stream().findAny().get()); - int entryNumber = sfEntries.size(); - - // TODO: use a more generic solution to instantiate these tyoes of constraints during - // the creation phase. - Set<IMappingEntry> existingEntries = new HashSet<>(); - if(outGenotype.getConstraintsOf(InternalIsolatedCommunicationSet.class).isEmpty()) { - for(IDeployableComponentAdapter<C> comp : sFAEntry.getSafetyFunctionAdapter() - .getAllComponents()) { - Collection<AbstractTaskMappingEntry> curEntry = - outGenotype.getMappingEntriesOf(comp); - assert (curEntry.size() <= 1); - existingEntries.addAll(curEntry); - } - outGenotype.putConstraint(InternalIsolatedCommunicationSet.class, - new InternalIsolatedCommunicationSet(existingEntries)); - } - - // In case that diagnostic units are not present in the *previous* encoding, we need to - // add some more. - Collection<AbstractTaskMappingEntry> diagEntries = - outGenotype.getMappingEntriesOf(diagComps.stream().findAny().get()); - if(diagPresent && diagEntries != null && diagEntries.isEmpty()) { - try { - addMissingDiagUnits(outGenotype, diagComps, entryNumber); - } catch(ExplorationException e) { - throw new DecodingException( - inGenotype, - this, - "Error adding diagnostic components to match the number of safety channels.", - e); - } - } - - // Match the encoding with the selected channel number. - for(int i = entryNumber; i < channelNumber; i++) { - try { - Set<IMappingEntry> createdEntries = new HashSet<>(); - createdEntries.addAll(addSFComponents(outGenotype, sfComps)); - if(diagPresent) { - createdEntries.addAll(addSFComponents(outGenotype, diagComps)); - } - // TODO: for each channel, the output component is "replicated" here. - createdEntries - .addAll(addSFComponents(outGenotype, Arrays.asList(outComponent))); - - outGenotype.putConstraint(InternalIsolatedCommunicationSet.class, - new InternalIsolatedCommunicationSet(createdEntries)); - } catch(ExplorationException e) { - throw new DecodingException( - inGenotype, - this, - "Error adding safety components to match the number of safety channels.", - null); - } - } - List<InternalIsolatedCommunicationSet> isoCommSet = - new ArrayList<>( - outGenotype.getConstraintsOf(InternalIsolatedCommunicationSet.class)); - for(int i = entryNumber - 1; i > channelNumber; i--) { - Collection<IMappingEntry> rmEntries = - isoCommSet.get(i).getIsolatedCommunicationSet(); - - removeSFEntries(outGenotype, rmEntries); - removeMatchingConstraint(outGenotype, getFirst(rmEntries, (s) -> true).orElse(null)); - } - - if(!diagPresent) { - // If no diagnostic unit is present in the encoding, remove its entire task. - removeDiagUnits(outGenotype, diagComps); - } - } - - return outGenotype; - } - - /** - * Adds entries for diagnostic units in the task mapping up to the given number. To be used when - * the encoding previously did not contain diagnostic units. - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - private void addMissingDiagUnits(AbstractTaskMappingEncoding outGenotype, - Collection<IDeployableComponentAdapter<C>> diagComps, int entryNumber) - throws ExplorationException { - List<InternalIsolatedCommunicationSet> isoComm = - new ArrayList<>( - outGenotype.getConstraintsOf(InternalIsolatedCommunicationSet.class)); - for(int i = 0; i < entryNumber; i++) { - Set<IMappingEntry> createdEntries = addSFComponents(outGenotype, diagComps); - InternalIsolatedCommunicationSet curConstr = isoComm.get(i); - curConstr.addToIsolatedCommunicationSet(createdEntries); - } - } - - /** Entirely removes the diagnostic units of a safety function from a given mapping. */ - private void removeDiagUnits(AbstractTaskMappingEncoding outGenotype, - Collection<IDeployableComponentAdapter<C>> diagComps) { - for(IDeployableComponentAdapter<?> diagComp : diagComps) { - Collection<AbstractTaskMappingEntry> removedEntries = outGenotype.removeTask(diagComp); - Collection<InternalIsolatedCommunicationSet> isoCommConstrs = - outGenotype.getConstraintsOf(InternalIsolatedCommunicationSet.class); - if(isoCommConstrs != null) { - // During the first iteration, Diagnostic units may be removed but no constraints - // were generated for them yet, hence check for null here. - isoCommConstrs.forEach(c -> c.removeFromIsolatedCommunicationSet(removedEntries)); - } - } - - } - - /** - * Adds one random entry to the task mapping for each of the given - * {@link IDeployableComponentAdapter}s. - * - * @throws ExplorationException - * if no valid allocation targets can be identified for one - * {@link IDeployableComponentAdapter}. - */ - private Set<IMappingEntry> addSFComponents(AbstractTaskMappingEncoding outGenotype, - Collection<IDeployableComponentAdapter<C>> sfComps) throws ExplorationException { - Set<IMappingEntry> createdEntries = new HashSet<>(); - if(sfComps != null) { - for(IDeployableComponentAdapter<C> curSFComp : sfComps) { - createdEntries.add(outGenotype.createAndAddRandomEntry(curSFComp)); - } - } - - return createdEntries; - } - - /** Removes the given {@link IMappingEntry}s from the {@link AbstractTaskMappingEncoding}. */ - private void removeSFEntries(AbstractTaskMappingEncoding outGenotype, - Collection<IMappingEntry> sfEntries) { - for(IMappingEntry sfEntry : sfEntries) { - outGenotype.removeEntry((AbstractTaskMappingEntry)sfEntry); - } - } - - /** - * Returns the first found {@link InternalIsolatedCommunicationSet} constraint that includes - * the given {@link IMappingEntry}. If none is found {@code null} is returned. - */ - private InternalIsolatedCommunicationSet getMatchingIsolationCommConstraint( - AbstractTaskMappingEncoding outGenotype, IMappingEntry entry) { - InternalIsolatedCommunicationSet matchingConstraint = null; - Collection<InternalIsolatedCommunicationSet> isoComm = - outGenotype.getConstraintsOf(InternalIsolatedCommunicationSet.class); - for(InternalIsolatedCommunicationSet constr : isoComm) { - if(constr.getIsolatedCommunicationSet().contains(entry)) { - matchingConstraint = constr; - break; - } - } - - return matchingConstraint; - } - - /** - * Removes the first found {@link InternalIsolatedCommunicationSet} constraint that includes the - * given {@link IMappingEntry} from the given {@link AbstractTaskMappingEncoding}. - */ - private void removeMatchingConstraint(AbstractTaskMappingEncoding outGenotype, - IMappingEntry entry) { - InternalIsolatedCommunicationSet rmConstr = - getMatchingIsolationCommConstraint(outGenotype, entry); - assert rmConstr != null; - outGenotype.getConstraintsOf(InternalIsolatedCommunicationSet.class).remove(rmConstr); - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> reqTypes = new ArrayList<>(); - reqTypes.add(SafetyFunctionArchEncoding.class); - reqTypes.add(AbstractTaskGraphEncoding.class); - reqTypes.add(AbstractTaskMappingEncoding.class); - return reqTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Class<AbstractTaskMappingEncoding> getOutputType() { - return AbstractTaskMappingEncoding.class; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/taskmapping/AbstractTaskMappingIdentityDecoder.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/taskmapping/AbstractTaskMappingIdentityDecoder.java deleted file mode 100644 index 206c5da99053d7bb2196432972c6df5be0caaeba..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/problem/taskmapping/AbstractTaskMappingIdentityDecoder.java +++ /dev/null @@ -1,78 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SFEncodingDecoder.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.taskmapping; - -import java.util.ArrayList; -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoderBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.ArchExpSubDecoder; - -/** - * Provides a {@link AbstractTaskMappingEncoding} to the set of {@link ComposablePhenotype} types. - * This {@link ComposableDecoder} is an identity operation. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: 7405E05AC5D4882BCCD3C5259DF0DB37 - */ -public class AbstractTaskMappingIdentityDecoder extends - ComposableDecoderBase<AbstractTaskMappingEncoding, AbstractTaskMappingEncoding> implements - ArchExpSubDecoder { - - /** {@inheritDoc} */ - @Override - public AbstractTaskMappingEncoding decodeComposable(AbstractTaskMappingEncoding genotype, - FlatPhenotypeMap<Phenotype> decodedPhenotypes) { - return genotype; - } - - /** {@inheritDoc} */ - @Override - public AbstractTaskMappingEncoding updateComposable(AbstractTaskMappingEncoding inGenotype, - AbstractTaskMappingEncoding outGenotype, FlatPhenotypeMap<Phenotype> decodedPhenotypes) { - return inGenotype; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> reqTypes = new ArrayList<>(); - reqTypes.add(AbstractTaskMappingEncoding.class); - return reqTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - Collection<Class<?>> optTypes = new ArrayList<>(); - return optTypes; - } - - /** {@inheritDoc} */ - @Override - public Class<AbstractTaskMappingEncoding> getOutputType() { - return AbstractTaskMappingEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/repair/RepairModuleBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/repair/RepairModuleBase.java deleted file mode 100644 index fce71cc15373e204dbad3a8b3b28a91be2f6ed09..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/repair/RepairModuleBase.java +++ /dev/null @@ -1,54 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.repair; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IRepairModule; -import org.opt4j.core.Genotype; - -/** - * Base class for {@link IRepairModule}s. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 1C6AB865197AA02BD93923719CA17CC0 - */ -public abstract class RepairModuleBase<T extends Genotype> implements IRepairModule<T> { - - /** References the input model. */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Creates an evaluator for a given exploration goal */ - protected RepairModuleBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } - - /** {@inheritDoc} */ - @Override - public String getIntrospectionLabel() { - return getClass().getSimpleName(); - } - - /** {@inheritDoc} */ - @Override - public boolean showInIntrospectionNavigation() { - // TODO Auto-generated method stub - return false; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/ArchExpSubSolution.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/ArchExpSubSolution.java deleted file mode 100644 index 90be14b9a244ff03594d8635938f2745b62165bd..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/ArchExpSubSolution.java +++ /dev/null @@ -1,33 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ArchExpSubSolution.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.opt4j.core.Genotype; - -/** - * Marker interface for solutions of a sub-problem a architectural exploration problem. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 80ABC7AF9FE060F077DCE78F6C51AA76 - */ -public interface ArchExpSubSolution<S extends Genotype> extends ComposablePhenotype<S> { - // Marker interface. -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/ArchitectureSolution.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/ArchitectureSolution.java deleted file mode 100644 index 549dccb4a71b96a28397c5f104a32b8ba8a09e24..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/ArchitectureSolution.java +++ /dev/null @@ -1,79 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ArchitectureSolution.java 3072 2016-06-22 11:08:57Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedList; -import java.util.Queue; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.ArchitectureExplorationEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.CompositePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.CompositePhenotypeBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; - -/** - * Base class for solutions (=> {@link Phenotype}s) of an architecture exploration problem. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3072 $ - * @ConQAT.Rating RED Hash: 29EED7BB1B7BC04D5E8A35B8C849523D - */ -// TODO: Check commonalities of this class with the FlatPhenotypeMap. -// TODO: Check whether it would be beneficial to create a IExplorationSolutionBase Class. -public class ArchitectureSolution extends CompositePhenotypeBase<ArchitectureExplorationEncoding> - implements IExplorationSolution<ArchExpSubSolution<?>> { - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Collection<Class<? extends ArchExpSubSolution<?>>> getAllSubSolutionClasses() { - Collection<Class<? extends ArchExpSubSolution<?>>> subSolutionClasses = new ArrayList<>(); - Queue<Phenotype> traversalList = new LinkedList<>(); - traversalList.addAll(subPhenotypes.values()); - while(!traversalList.isEmpty()) { - Phenotype phenotype = traversalList.poll(); - subSolutionClasses.add((Class<? extends ArchExpSubSolution<?>>)phenotype.getClass()); - if(phenotype instanceof CompositePhenotype) { - traversalList.addAll(((CompositePhenotype<?>)phenotype).getSubPhenotypes()); - } - } - return subSolutionClasses; - } - - /** {@inheritDoc} */ - @Override - public <T extends Phenotype> T getSubSolution(Class<T> solutionClass) { - Queue<Phenotype> traversalList = new LinkedList<>(); - traversalList.addAll(subPhenotypes.values()); - while(!traversalList.isEmpty()) { - Phenotype phenotype = traversalList.poll(); - - if(solutionClass.isAssignableFrom(phenotype.getClass())) { - @SuppressWarnings("unchecked") T retPheno = (T)phenotype; - return retPheno; - } - - if(phenotype instanceof CompositePhenotype) { - traversalList.addAll(((CompositePhenotype<?>)phenotype).getSubPhenotypes()); - } - } - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/IExplorationSolution.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/IExplorationSolution.java deleted file mode 100644 index 0f49ddf0a2dedcba8a50820e63f351a60e2c899c..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/IExplorationSolution.java +++ /dev/null @@ -1,40 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IExplorationSolution.java 3072 2016-06-22 11:08:57Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; - -/** - * Interface for accessing a single solution of a DSE run. It provides access to the sub solutions - * found by the DSE. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3072 $ - * @ConQAT.Rating RED Hash: 8861F305866BC4C6516C0DEDD7F70EBE - */ -public interface IExplorationSolution<P extends Phenotype> { - - /** Returns the sub solution of this {@link IExplorationSolution}. */ - public <T extends Phenotype> T getSubSolution(Class<T> solutionClass); - - /** Returns all the classes (= keys) of the sub solution of this {@link IExplorationSolution}. */ - public <T extends Phenotype> Collection<Class<T>> getAllSubSolutionClasses(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/IScheduleSolution.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/IScheduleSolution.java deleted file mode 100644 index a0aede961f435ead9817875559fb8a3edc6cfcdd..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/IScheduleSolution.java +++ /dev/null @@ -1,40 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IScheduleSolution.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; - -/** - * Interface allowing external access to schedules that are a solution or part of a solution of a - * DSE run for a defined problem. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: BEF13F6E4A66E4AE99F246EF71C20ED2 - */ -public interface IScheduleSolution<P extends Phenotype> extends IExplorationEncoding { - - /** - * Returns the {@link TimeSlot} that has been reserved for the given {@link IMappingEntry}. - * Returns null, if no {@link TimeSlot} could be found. - */ - public TimeSlot getTimeSlotOf(IMappingEntry entry); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/StrictTTSchedule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/StrictTTSchedule.java deleted file mode 100644 index 1b1c65eebec2f80fdbc26c3a395409ccddfcf2a2..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/StrictTTSchedule.java +++ /dev/null @@ -1,399 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: StrictTTSchedule.java 3879 2016-11-10 10:33:35Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.TreeMap; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -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.IDeployableComponentAdapter; -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.ITransmissionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.comm.Message; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.sched.ScheduleRuntimeException; - -/** - * Time-triggered schedule encoding the temporal execution order of a given - * {@link TaskMappingEncoding}. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3879 $ - * @ConQAT.Rating RED Hash: 05D3AC94CC90DEE9B3BFDD0B76136A34 - */ - -public class StrictTTSchedule<S extends TaskMappingEntry, T extends TaskMappingEncoding<S>> - implements IScheduleSolution<StrictTTSchedule<S, T>>, ComposablePhenotype<T>, - ArchExpSubSolution<T> { - /** - * Amount (of time) which {@link TimeSlot}s are allowed to overlap. Here due to numerical - * imprecision. - */ - // TODO: This should be better placed in the scheduler as some sort of "jitter". - public static double SLOT_OVERLAP_TOLERANCE = 1e-6; - - /** - * {@link HashMap}-based Schedule of a single resource = map: time slot -> request allocated to - * that time slot - */ - public static class ResourceSchedule extends TreeMap<TimeSlot, IRequestAdapter<?>> { - /** - * Indicates whether the temporal order within a {@link ResourceSchedule} is kept. This is - * done by evaluating the predecessor field of {@link TimeSlot}s - */ - public boolean validateResourceSchedule() { - for(TimeSlot slot : keySet()) { - for(TimeSlot pred : slot.getPredecessors()) { - if(pred.getResource() == slot.getResource() && - slot.getStartTime() < pred.getEndTime()) { - return false; - } - } - } - return true; - } - } - - /** - * Schedule data structure = map: resource -> scheduling entries that resource - */ - private Map<IResourceAdapter<?>, ResourceSchedule> schedule; - - /** - * Associates the {@link IMappingEntry}s with their {@link TimeSlot}s. Essentially, a different - * perspective onto the {#link schedule}. - */ - private Map<S, TimeSlot> timeSlotsOfMappingEntries; - - // TODO: Check if there is an Opt4J mechanism to obtain the genotype for a phenotype if this is - // required (e.g., in an evaluator) - /** Maintain a reference to the encoding. */ - private T encoding; - - /** Representation of input system model */ - private SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** - * Constructor that creates a time-triggered schedule for a given encoding (mapping) and - * optionally directly performs the scheduling. - */ - public StrictTTSchedule(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, T encoding) { - schedule = new HashMap<IResourceAdapter<?>, ResourceSchedule>(); - timeSlotsOfMappingEntries = new HashMap<S, TimeSlot>(); - - this.systemModelAdapter = systemModelAdapter; - this.encoding = encoding; - } - - /** Copy constructor. */ - public StrictTTSchedule(StrictTTSchedule<S, T> schedule) { - this.schedule = new HashMap<IResourceAdapter<?>, ResourceSchedule>(); - timeSlotsOfMappingEntries = new HashMap<S, TimeSlot>(); - - this.systemModelAdapter = schedule.systemModelAdapter; - this.encoding = schedule.encoding; - - for(Entry<IResourceAdapter<?>, ResourceSchedule> resSched : schedule.schedule.entrySet()) { - ResourceSchedule newSched = new ResourceSchedule(); - newSched.putAll(resSched.getValue()); - this.schedule.put(resSched.getKey(), newSched); - } - - timeSlotsOfMappingEntries.putAll(schedule.timeSlotsOfMappingEntries); - } - - /** - * Performs a validation of this schedule. Returns {@code true} if the following conditions - * hold: <li>The number of allocations defined in the mapping matches the number of scheduled - * components.</li> <li>No overlap of {@link TimeSlot}s within the schedule of each - * {@link IResourceAdapter}.</li> - */ - public boolean validateSchedule(boolean enableScheduleException) { - if(validateAllocationNumberInSchedule(enableScheduleException) && - validateNoTimeSlotOverlaps(enableScheduleException) && - validateCausalityOfTasks(enableScheduleException)) { - return true; - } - - return false; - } - - /** - * Validates whether the number of {@link TimeSlot}s representing a - * {@link IDeployableComponentAdapter} matches the number of allocations defined in the - * {@link IMappingEncoding} from which this {@link StrictTTSchedule} is derived. - * This check is performed for each {@link IDeployableComponentAdapter} in the - * {@link IMappingEncoding}. - */ - private boolean validateAllocationNumberInSchedule(boolean enableScheduleException) { - for(IDeployableComponentAdapter<?> comp : encoding.getDeployedComponents()) { - int compEncNum = encoding.getMappingEntriesOf(comp).size(); - int compSchedNum = 0; - for(IResourceAdapter<?> resourceAdapter : getResources()) { - for(IRequestAdapter<?> schedComp : getResourceSchedule(resourceAdapter).values()) { - if(schedComp == comp) { - compSchedNum++; - } - } - } - if(compEncNum != compSchedNum && - systemModelAdapter.getScheduleableComponents().contains(comp)) { - System.out - .println("The number of scheduled Components of " + comp.getName() + - " does not match the number defined in the Component->ExecutionUnit mapping."); - if(enableScheduleException) { - throw new ScheduleRuntimeException(this); - } - return false; - } - } - return true; - } - - /** - * Validates for each {@link ResourceSchedule} that no {@link TimeSlot}s have temporal overlaps - * with another {@link TimeSlot} of that {@link ResourceSchedule}. - */ - private boolean validateNoTimeSlotOverlaps(boolean enableScheduleException) { - for(Map.Entry<IResourceAdapter<?>, ResourceSchedule> resourceSchedule : schedule.entrySet()) { - for(TimeSlot currentTimeSlot : resourceSchedule.getValue().keySet()) { - TimeSlot nextTimeSlot = resourceSchedule.getValue().higherKey(currentTimeSlot); - if(nextTimeSlot != null && - currentTimeSlot.getEndTime() > nextTimeSlot.getStartTime() + - SLOT_OVERLAP_TOLERANCE * nextTimeSlot.getStartTime()) { - System.out.println("The time slots " + currentTimeSlot + " and " + - nextTimeSlot + " overlap in the schedule of the resource " + - resourceSchedule.getKey().getName() + ". The schedule is not valid."); - if(enableScheduleException) { - throw new ScheduleRuntimeException(this); - } - return false; - } - } - } - - return true; - } - - /** - * Predicate if this {@link StrictTTSchedule} is causally valid by the order of its - * {@link TimeSlot}s. - * <b>NOTE:</b> Only those {@link TimeSlot} which that are contained in this - * {@link StrictTTSchedule} and for which the predecessor {@link TimeSlot}s are defined are - * validated. - */ - private boolean validateCausalityOfTasks(boolean enableScheduleException) { - for(Map.Entry<IResourceAdapter<?>, ResourceSchedule> resourceSchedule : schedule.entrySet()) { - for(TimeSlot currentTimeSlot : resourceSchedule.getValue().keySet()) { - for(TimeSlot predecessorSlot : currentTimeSlot.getPredecessors()) { - if(currentTimeSlot.getStartTime() < predecessorSlot.getEndTime() - - StrictTTSchedule.SLOT_OVERLAP_TOLERANCE) { - System.out.println("(Temporal) Causality of the time slots " + - predecessorSlot + " (predecessor, resource: " + - predecessorSlot.getResource().getName() + ") and " + - currentTimeSlot + "(successor, resource: " + - currentTimeSlot.getResource().getName() + - ") violated. The schedule is not valid."); - if(enableScheduleException) { - throw new ScheduleRuntimeException(this); - } - return false; - } - } - } - } - - return true; - } - - /** - * Creates a {@link TimeSlot} for a voter and inserts it into the schedule (voters are software - * components that can only be allocated to {@link IExecutionUnitAdapter}s. - */ - public TimeSlot createVoterSlot(S deployedRequest, IExecutionUnitAdapter<?> deploymentTarget, - double start, double end, long iteration) { - TimeSlot slot = createTimeSlot(deployedRequest, deploymentTarget, start, end, iteration); - slot.setVoter(true); - return slot; - } - - /** Registers a {@link TimeSlot} with the appropriate schedule. */ - public TimeSlot - registerTimeSlot(TimeSlot slot, S deployedRequest, IResourceAdapter<?> resource) { - // Create a new TimeSlot and eventually add a new ResourceSchedule, if none exists yet for - // the deployment target. - if(schedule.get(resource) == null) { - ResourceSchedule resourceSchedule = new ResourceSchedule(); - schedule.put(resource, resourceSchedule); - } - - // Separate the registration within the schedule by the mapping entry. If it is non-null, - // the mapping entry represents one instance of a deployable component and is registered - // within an appropriate ResourceSchedule and task mapping map. Otherwise, just register the - // time slot with no associated deployable Component within the appropriate - // ReosurceSchedule; it is most likely a communication resource allocated to a message. - if(deployedRequest != null) { - schedule.get(resource).put(slot, deployedRequest.getDeployableComponent()); - timeSlotsOfMappingEntries.put(deployedRequest, slot); - } else { - schedule.get(resource).put(slot, null); - } - - return slot; - } - - /** - * Creates a {@link TimeSlot} with an iteration number and inserts it into the appropriate - * schedule. - */ - public TimeSlot createTimeSlot(S deployedRequest, IResourceAdapter<?> resource, double start, - double end, long iteration) { - TimeSlot slot = new TimeSlot(deployedRequest, resource, start, end, (int)iteration, false); - return registerTimeSlot(slot, deployedRequest, resource); - } - - /** - * Creates a {@link TimeSlot} with an iteration number and inserts it into the appropriate - * schedule. Additionally, this method sets the predecessor {@link TimeSlot}s, which can be used - * to verify the causal correctness. - */ - public TimeSlot createTimeSlot(S deployedRequest, IResourceAdapter<?> resource, - Collection<TimeSlot> predessorSlots, double start, double end, long iteration) { - TimeSlot slot = - new TimeSlot(deployedRequest, resource, predessorSlots, start, end, (int)iteration, - false); - return registerTimeSlot(slot, deployedRequest, resource); - } - - /** Creates a {@link TimeSlot} specifically for {@link Message}s. */ - public TimeSlot createMessageSlot(Message message, ICommunicationResourceAdapter<?> resource, - double start, double end) { - TimeSlot slot = new TimeSlot(message, resource, start, end); - // TODO: Modify the Message class to contain a reference to the *original* sender. - return registerTimeSlot(slot, null, resource); - } - - /** Returns the resources whose schedule is contained in this {@link StrictTTSchedule}. */ - public Set<IResourceAdapter<?>> getResources() { - return schedule.keySet(); - } - - /** Returns the {@link ResourceSchedule} for a given resource */ - public ResourceSchedule getResourceSchedule(IResourceAdapter<?> resource) { - return schedule.get(resource); - } - - /** {@inheritDoc} */ - @Override - public TimeSlot getTimeSlotOf(IMappingEntry entry) { - return timeSlotsOfMappingEntries.get(entry); - } - - /** - * Return the earliest start time of all time slots that are allocated for the given request. - */ - public double getFirstStartTime(IRequestAdapter<?> request, long iteration) { - - double time = -1; - for(ResourceSchedule resourceSchedule : schedule.values()) { - for(TimeSlot t : resourceSchedule.keySet()) { - if(resourceSchedule.get(t) == request) { - if(t.getIteration() == iteration) { - if(time < 0 || time > t.getStartTime()) { - time = t.getStartTime(); - } - } - } - } - } - return time; - } - - /** Return the latest end time of all time slots that are allocated for the request. */ - public double getLastEndTime(IRequestAdapter<?> request, long iteration) { - - double time = -1; - for(ResourceSchedule resourceSchedule : schedule.values()) { - for(TimeSlot t : resourceSchedule.keySet()) { - if(resourceSchedule.get(t) == request) { - if(t.getIteration() == iteration) { - if(time < 0 || (time > 0 && time < t.getEndTime())) { - time = t.getEndTime(); - } - } - } - } - } - return time; - } - - /** Formats the string representation of a resource */ - private String getResourceName(IResourceAdapter<?> resource) { - String str = resource.getName(); - if(!(resource instanceof ITransmissionUnitAdapter || resource instanceof IGatewayUnitAdapter) && - resource != systemModelAdapter.getHardwareResource(resource)) { - str += "@" + systemModelAdapter.getHardwareResource(resource).getName(); - } - return str; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - String str = ""; - for(IResourceAdapter<?> resource : schedule.keySet()) { - str += getResourceName(resource); - str += ":"; - for(TimeSlot slot : schedule.get(resource).keySet()) { - str += "["; - if(slot.isVoter()) { - str += "voter"; - } else if(slot.getDeployedRequester() != null) { - str += slot.getDeployedRequester().getDeployableComponent().getName(); - } else if(slot.getDeployedMessage() != null) { - str += slot.getDeployedMessage().getSignalAdapter().getName(); - } else { - str += "<>"; - } - str += " @ " + slot + "], "; - } - str += "\n"; - } - return str; - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Class<? extends ComposablePhenotype<?>> getPTypeToRegister() { - return (Class<? extends ComposablePhenotype<?>>)StrictTTSchedule.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/TimeSlot.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/TimeSlot.java deleted file mode 100644 index aa4775a1c12ffa312d3950411de4fefb59fdbfda..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/backend/opt4j/solution/TimeSlot.java +++ /dev/null @@ -1,333 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: TimeSlot.java 2419 2016-03-04 18:05:52Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution; - -import java.util.Collection; -import java.util.Comparator; -import java.util.HashSet; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ICommunicationResourceAdapter; -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.comm.Message; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; - -/** - * Slot of a {@link StrictTTSchedule} reserving a particular time frame at a a - * {@link IResourceAdapter}. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 2419 $ - * @ConQAT.Rating RED Hash: 9F0AE9D9CDA6C6B5D507F9C5BC4D54DE - */ - -public class TimeSlot implements java.lang.Comparable<TimeSlot> { - - /** - * The {@link IResourceAdapter} for which this {@link TimeSlot} is allocated. For instance, a - * {@link StrictTTSchedule} can contain time slots for {@link IExecutionUnitAdapter} and I - */ - private IResourceAdapter<?> resource; - - /** The {@link IMappingEntry} that is represented by this {@link TimeSlot}. */ - private IMappingEntry deployedRequester; - - /** The {@link Message} reserving this {@link TimeSlot} of a communication resource. */ - private Message deployedMessage; - - /** References the {@link TimeSlot}s that are causal predecessors of this {@link TimeSlot}. */ - private Collection<TimeSlot> predecessorSlots; - - /** References the {@link TimeSlot}s that are causal successors of this {@link TimeSlot}. */ - private Collection<TimeSlot> successorSlots; - - /** Start time of {@link TimeSlot}. */ - private double startTime; - - /** End time of {@link TimeSlot}. */ - private double endTime; - - /** Hyper period iteration number of this {@link TimeSlot}. Used for latency checks. */ - private long iteration; - - // TODO: Replace isVoterSlot flag with a subclass of TimeSlot? - /** - * Flag if the time slot is a voter that has been added automatically during the reliability - * analysis. - */ - private boolean isVoterSlot; - - /** - * Constructs a time slot for a given resource, and enables to specify if the slot has been - * allocated for a voter. - */ - public TimeSlot(IMappingEntry deployedRequest, IResourceAdapter<?> resource, double startTime, - double endTime, int iteration, boolean isVoterSlot) { - this.deployedRequester = deployedRequest; - this.startTime = startTime; - this.endTime = endTime; - this.iteration = iteration; - this.resource = resource; - this.isVoterSlot = isVoterSlot; - - this.predecessorSlots = new HashSet<TimeSlot>(); - this.successorSlots = new HashSet<TimeSlot>(); - } - - /** - * Constructs a time slot for a given resource, and enables to specify if the slot has been - * allocated for a voter. Furthermore, the collection of predecessors is defined. - */ - public TimeSlot(IMappingEntry deployedRequest, IResourceAdapter<?> resource, - Collection<TimeSlot> predecessorSlots, double startTime, double endTime, int iteration, - boolean isVoterSlot) { - this(deployedRequest, resource, startTime, endTime, iteration, isVoterSlot); - - this.predecessorSlots.addAll(predecessorSlots); - } - - /** Constructs a time slot for a given mappingEntry. */ - public TimeSlot(IMappingEntry deployedRequest, double startTime, double endTime) { - this(deployedRequest, deployedRequest.getTarget(), startTime, endTime, 0, false); - } - - /** - * Constructs a time slot for a given {@link Message}. Specialized constructor for - * {@link ICommunicationResourceAdapter}s. - */ - public TimeSlot(Message deployedMessage, ICommunicationResourceAdapter<?> resource, - double startTime, double endTime) { - this(null, resource, startTime, endTime, 0, false); - this.deployedMessage = deployedMessage; - } - - /** Returns deployedRequester. */ - public IMappingEntry getDeployedRequester() { - return deployedRequester; - } - - /** Returns the {@link Message} requesting this {@link TimeSlot}. */ - public Message getDeployedMessage() { - return deployedMessage; - } - - /** Returns the slots start time. */ - public double getStartTime() { - return startTime; - } - - /** Returns the slots end time. */ - public double getEndTime() { - return endTime; - } - - /** - * Returns the duration of the slot, i.e. {@link #getEndTime()} - {@link #getStartTime()}. - */ - public double getDuration() { - return endTime - startTime; - } - - /** - * Shifts the time slot in the schedule. - */ - public void shift(double d) { - startTime += d; - endTime += d; - } - - /** Hyper period iteration number of this {@link TimeSlot}. */ - public long getIteration() { - return iteration; - } - - /** - * Returns the resource for which this slot has been allocated. - */ - public IResourceAdapter<?> getResource() { - return resource; - } - - /** Returns true iff the slot has been allocated for a voter */ - public boolean isVoter() { - return isVoterSlot; - } - - /** - * Sets a flag if the time slot is a voter that has been added automatically during the - * reliability analysis. - */ - public void setVoter(boolean isVoterSlot) { - this.isVoterSlot = isVoterSlot; - } - - /** - * Add a {@link TimeSlot} to the collection of causal predecessors {@link TimeSlot}s of this - * {@link TimeSlot}. - * - * @returns {@code true} if the given slot could be added and is not yet present in the list of - * predecessors, {@code false} otherwise. - */ - public boolean addPredecessor(TimeSlot slot) { - return predecessorSlots.add(slot); - } - - /** - * Replaces the predecessor {@link TimeSlot} {#link slotOrig} with {#link replaceSlot}. If - * {#link slotOrig} is not contained in the list of predecessor {@link TimeSlot}s, no - * modification will be performed. - */ - public void replacePredecessor(TimeSlot slotOrig, TimeSlot replaceSlot) { - if(predecessorSlots.remove(slotOrig)) { - predecessorSlots.add(replaceSlot); - } - } - - /** Returns the collection of causal predecessors {@link TimeSlot}s of this {@link TimeSlot}. */ - public Collection<TimeSlot> getPredecessors() { - return predecessorSlots; - } - - /** Clears the collection of causal successors {@link TimeSlot}s of this {@link TimeSlot}. */ - public void clearPredecessors() { - predecessorSlots.clear(); - } - - /** - * Add a {@link TimeSlot} to the collection of causal successors {@link TimeSlot}s of this - * {@link TimeSlot}. - * - * @returns {@code true} if the given slot could be added and is not yet present in the list of - * successors, {@code false} otherwise. - */ - public boolean addSuccessor(TimeSlot slot) { - return successorSlots.add(slot); - } - - /** Returns the collection of causal successors {@link TimeSlot}s of this {@link TimeSlot}. */ - public Collection<TimeSlot> getSuccessors() { - return successorSlots; - } - - /** - * Replaces the successor {@link TimeSlot} {#link slotOrig} with {#link replaceSlot}. If {#link - * slotOrig} is not contained in the list of successor {@link TimeSlot}s, no modification will - * be performed. - */ - public void replaceSuccessor(TimeSlot slotOrig, TimeSlot replaceSlot) { - if(successorSlots.remove(slotOrig)) { - successorSlots.add(replaceSlot); - } - } - - /** Clears the collection of causal successors {@link TimeSlot}s of this {@link TimeSlot}. */ - public void clearSuccessors() { - successorSlots.clear(); - } - - /** - * Comparison of two time slots: - * NO LONGER VALID!:1) if the two slot belong to different resources, compare the resources - * names - * if the two slot belong to the same resources, compare the start time - * */ - // TODO: re-implement this compareTo method, it is a complete mess (refs #6262) - @Override - public int compareTo(TimeSlot slot) { - // TODO: if they are both null, consider them as equal - if(this.resource == null && slot.resource == null) { - return Double.compare(this.startTime, slot.startTime); - } else if(this.resource == null || slot.resource == null) { - return -1; - } - - if(this.resource != slot.resource) { - String n1 = this.resource.getName(); - String n2 = slot.resource.getName(); - if(n1 == null || n2 == null) { - // TODO: if they are both null, consider them as equal - if(n1 == null && n2 == null) { - return Double.compare(this.startTime, slot.startTime); - } - return -1; - } - return n1.compareTo(n2); - } - - // on the same provider - int result = Double.compare(this.startTime, slot.startTime); - return result; - } - - /** {@inheritDoc} */ - @Override - public boolean equals(Object object) { - // Content-based comparison of two {@link TimeSlot}s. - if(object instanceof TimeSlot) { - return(this.compareTo((TimeSlot)object) == 0); - } - return false; - } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - // TODO Meaningful implementation due to custom equals() required? - return super.hashCode(); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "(" + startTime + ", " + endTime + ")"; - } - - /** - * Comparator which determines the (ascending) order of two given {@link TimeSlot}s by their - * start times. - */ - public static class StartTimeSlotComparator implements Comparator<TimeSlot> { - /** {@inheritDoc} */ - @Override - public int compare(TimeSlot slot1, TimeSlot slot2) { - if(slot1 == null && slot2 == null) { - return 0; - } - if(slot1 == null) { - return 1; - } - if(slot2 == null) { - return -1; - } - return Double.compare(slot1.getStartTime(), slot2.getStartTime()); - } - } - - /** - * Comparator which determines the (ascending) order of two given {@link TimeSlot}s by their - * finish(end) times. - */ - public static class ReverseStartTimeSlotComparator extends StartTimeSlotComparator { - /** {@inheritDoc} */ - @Override - public int compare(TimeSlot slot1, TimeSlot slot2) { - return -super.compare(slot1, slot2); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ArchExpSubEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ArchExpSubEvaluator.java deleted file mode 100644 index 73909702ac42d17d26bef5a96fed55b5e5c2549f..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ArchExpSubEvaluator.java +++ /dev/null @@ -1,32 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ArchExpSubEvaluator.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate.ComposableEvaluator; - -/** - * Marker interface for evaluators of sub problems of an architectural exploration problem. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 226E6AB9A2A5AE259C8CBBB49906848F - */ -public interface ArchExpSubEvaluator<P> extends ComposableEvaluator<P> { - // Marker interface. -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ArchitectureEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ArchitectureEvaluator.java deleted file mode 100644 index f1509505fcbab992093c75c606a0db86177bdc3e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ArchitectureEvaluator.java +++ /dev/null @@ -1,65 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ArchitectureEvaluator.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator; - -import java.util.Collection; -import java.util.Iterator; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate.CompositeEvaluator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate.CompositeEvaluatorBase; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.ArchitectureSolution; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.opt4j.core.Value; - -import com.google.inject.Inject; - -/** - * {@link CompositeEvaluator} of an architectural exploration problem. This implementation sums the - * results of an evaluation, if it is defined for multiple sub problems, in the merge method. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: AA12901984299D1BDCDF6999D0A29AAB - */ -public class ArchitectureEvaluator extends CompositeEvaluatorBase<ArchitectureSolution> implements - ITopLevelEvaluator { - - /** Default constructor which requires a {@link SystemModelAdapter} to access the input models. */ - @Inject - public ArchitectureEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public Value<?> mergeSubEvaluations(Collection<Value<?>> results) { - Value<?> evalValue = null; - Iterator<Value<?>> resultIterator = results.iterator(); - while(resultIterator.hasNext()) { - Value<?> subResult = resultIterator.next(); - // TODO: Clarify the semantics of the aggregation of results. Some sort of add operation - // will be need for the "Value" type. The 'getDouble' method is not available in - // general. - evalValue = subResult; - // evalValue += subResults.getDouble(); - } - - return evalValue; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ExplorationTargetEvaluatorBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ExplorationTargetEvaluatorBase.java deleted file mode 100644 index 44a280cb7b1a2773cc6395745f71b4516ffd4fc8..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ExplorationTargetEvaluatorBase.java +++ /dev/null @@ -1,123 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExplorationTargetEvaluatorBase.java 3770 2016-10-25 13:50:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator; - -import java.util.Collection; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem; -import org.fortiss.tooling.kernel.introspection.IIntrospectionItem; -import org.opt4j.core.DoubleValue; -import org.opt4j.core.Value; -import org.opt4j.core.problem.Evaluator; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * Base class for {@link Evaluator}s of {@link ExplorationConstraint}s.. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3770 $ - * @ConQAT.Rating RED Hash: 4D55E0ECDB5F3B2768DA3D16A4CFBF4E - */ -public abstract class ExplorationTargetEvaluatorBase<P, RT, T extends ExplorationTarget<RT>> - implements IExplorationTargetEvaluator<P, RT, T> { - - /** Representation of system model */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Exploration goal evaluated by this evaluator */ - protected T explorationTarget; - - /** Prototype constructor. */ - protected ExplorationTargetEvaluatorBase() { - } - - /** - * Creates an evaluator for a given exploration goal - * - * @throws Exception - * if the input validation fails (has to be implemented by the concrete - * {@link ExplorationTarget} evaluators. - */ - protected ExplorationTargetEvaluatorBase( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, T optTarget) throws Exception { - this.systemModelAdapter = systemModelAdapter; - this.explorationTarget = optTarget; - - validateInputs(); - } - - /** - * Wrapper method for the original evaluate function. - * - * @param transformedModels - * TODO - */ - public Value<?> evaluate(P phenotype, FlatPhenotypeMap<Phenotype> phenotypeTypeMap, - ClassToInstanceMap<EObject> transformedModels) { - if(phenotype == null) { - return new DoubleValue(Double.MAX_VALUE); - } - // TODO #checking: Add an check here to ensure that the evaluators don't mess around with - // the encodings. - Value<?> evalResult = new DoubleValue(Double.MAX_VALUE); - try { - evalResult = evaluateGoal(phenotype, phenotypeTypeMap, transformedModels); - } catch(Exception e) { - // The Opt4J framework only allows us to throw runtime exceptions. - throw new RuntimeException(new ExplorationException("The evaluatior " + - this.toString() + " failed to evaluate the ExplorationTarget " + - explorationTarget.getName() + ".", e)); - } - return evalResult; - } - - /** {@inheritDoc} */ - @Override - public String getIntrospectionLabel() { - return getClass().getSimpleName(); - } - - // TODO: Add the introspection information. - /** {@inheritDoc} */ - @Override - public boolean showInIntrospectionNavigation() { - return true; - } - - /** {@inheritDoc} */ - @Override - public Collection<IIntrospectionItem> getIntrospectionItems() { - return null; - } - - /** {@inheritDoc} */ - @Override - public IIntrospectionDetailsItem getDetailsItem() { - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ExpressionEvaluatorBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ExpressionEvaluatorBase.java deleted file mode 100644 index 0f4d93770b14d1b70462a85451062837a8f3145a..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ExpressionEvaluatorBase.java +++ /dev/null @@ -1,133 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2017 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator; - -import java.util.Collection; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.dsl_v2.model.expression.IExpression; -import org.fortiss.af3.exploration.lang.ExplorationExpressionEvaluator; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.ExplorationTargetExpression; -import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem; -import org.fortiss.tooling.kernel.introspection.IIntrospectionItem; -import org.opt4j.core.DoubleValue; -import org.opt4j.core.Value; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 5DD71550F345CAF7E60260A875EF0B0B - */ -public abstract class ExpressionEvaluatorBase<P extends Phenotype, RT, T extends ExplorationTarget<RT>> - extends ExplorationExpressionEvaluator implements IExplorationTargetEvaluator<P, RT, T> { - - /** Representation of system model */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Exploration goal evaluated by this evaluator */ - protected T explorationTarget; - - protected IExpression expression; - - /** Prototype constructor. */ - protected ExpressionEvaluatorBase() { - } - - /** - * Creates an evaluator for a given exploration goal - * - * @throws Exception - * if the input validation fails (has to be implemented by the concrete - * {@link ExplorationTarget} evaluators. - */ - protected ExpressionEvaluatorBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - T explorationTarget) throws Exception { - if(!(explorationTarget instanceof ExplorationTargetExpression<?>)) { - throw new Exception("The exploration target " + explorationTarget.getName() + " is" + - " not of the ExplorationTargetExpression. Thus, it cannot be evaluated by " + - getClass().getSimpleName() + "."); - - } - - this.systemModelAdapter = systemModelAdapter; - this.explorationTarget = explorationTarget; - this.expression = explorationTarget.getExpression(); - - validateInputs(); - } - - /** - * Wrapper method for the original evaluate function. - * - * @param transformedModels - * TODO - */ - public Value<?> evaluate(P phenotype, FlatPhenotypeMap<Phenotype> phenotypeTypeMap, - ClassToInstanceMap<EObject> transformedModels) { - if(phenotype == null) { - return new DoubleValue(Double.MAX_VALUE); - } - // TODO #checking: Add an check here to ensure that the evaluators don't mess around with - // the encodings. - Value<?> evalResult = new DoubleValue(Double.MAX_VALUE); - try { - evalResult = evaluateGoal(phenotype, phenotypeTypeMap, transformedModels); - } catch(Exception e) { - // The Opt4J framework only allows us to throw runtime exceptions. - throw new RuntimeException(new ExplorationException("The evaluatior " + - this.toString() + " failed to evaluate the ExplorationTarget " + - explorationTarget.getName() + ".", e)); - } - return evalResult; - } - - /** {@inheritDoc} */ - @Override - public String getIntrospectionLabel() { - return getClass().getSimpleName(); - } - - // TODO: Add the introspection information. - /** {@inheritDoc} */ - @Override - public boolean showInIntrospectionNavigation() { - return true; - } - - /** {@inheritDoc} */ - @Override - public Collection<IIntrospectionItem> getIntrospectionItems() { - return null; - } - - /** {@inheritDoc} */ - @Override - public IIntrospectionDetailsItem getDetailsItem() { - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ITopLevelEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ITopLevelEvaluator.java deleted file mode 100644 index 91c4a0808ea72cf055fcde39f79e2a3b03cecfbe..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/ITopLevelEvaluator.java +++ /dev/null @@ -1,34 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ITopLevelEvaluator.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate.CompositeEvaluator; - -/** - * Marker interface for the {@link CompositeEvaluator} which is defined for the overall problem. It - * is used to mark a "starting point" for the evaluation. This evaluator calls other evaluators - * successively. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 6DC462263531029626D77BC230F49BE1 - */ -public interface ITopLevelEvaluator { - // Marker interface. -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/MappingEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/MappingEvaluator.java deleted file mode 100644 index 7ed10785b0fcd7be2ad5afb8778cbe8b29bf754a..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/MappingEvaluator.java +++ /dev/null @@ -1,122 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2017 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator; - -import java.util.ArrayList; -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.MappingEncoding; -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.SystemModelAdapter; -import org.fortiss.af3.exploration.dsl_v2.model.booleanp.Implies; -import org.fortiss.af3.exploration.dsl_v2.model.booleanp.allocation.Allocation; -import org.fortiss.af3.exploration.dsl_v2.model.booleanp.allocation.Dislocation; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.tooling.base.model.element.IModelElement; - -/** - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: BFC6CA0CE0F63E4D70526C49FD1F21E6 - */ -public abstract class MappingEvaluator extends - ExpressionEvaluatorBase<MappingEncoding, Double, ExplorationTarget<Double>> { - - protected MappingEncoding mapping; - - /** Empty prototype constructor. */ - public MappingEvaluator() { - super(); - } - - /** Constructor. */ - public MappingEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationTarget<Double> explorationTarget) throws Exception { - super(systemModelAdapter, explorationTarget); - } - - /** {@inheritDoc} */ - @Override - public Object visit(Allocation alloc) throws Exception { - // TODO: Here, we could use the requester / resource framework for the return types. In - // addition we would obtain a generic mapping evaluator. - IModelElement requester = alloc.getLeft().accept(this, IModelElement.class); - IModelElement resource = alloc.getRight().accept(this, IModelElement.class); - - IRequestAdapter<?> requestAdp = systemModelAdapter.getDeployableComponentOf(requester); - - Collection<IResourceAdapter<?>> allocResourceAdps = - mapping.getAllocatedResourcesFor(requestAdp); - for(IResourceAdapter<?> allocResource : allocResourceAdps) { - if(allocResource.getObject() == resource) { - return Boolean.valueOf(true); - } - } - - return Boolean.valueOf(false); - } - - /** {@inheritDoc} */ - @Override - public Object visit(Dislocation disLoc) throws Exception { - IModelElement requester = disLoc.getLeft().accept(this, IModelElement.class); - IModelElement resource = disLoc.getRight().accept(this, IModelElement.class); - - IRequestAdapter<?> requestAdp = systemModelAdapter.getDeployableComponentOf(requester); - - Collection<IResourceAdapter<?>> allocResourceAdps = - mapping.getAllocatedResourcesFor(requestAdp); - for(IResourceAdapter<?> allocResource : allocResourceAdps) { - if(allocResource.getObject() == resource) { - return Boolean.valueOf(false); - } - } - - return Boolean.valueOf(true); - } - - /** {@inheritDoc} */ - @Override - public Object visit(Implies implies) throws Exception { - // FIXME: How to implement implies? - return null; - } - - /** {@inheritDoc} */ - @Override - public boolean validateInputs() throws Exception { - return true; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredInputTypes() { - Collection<Class<?>> requiredTypes = new ArrayList<>(); - requiredTypes.add(MappingEncoding.class); - return requiredTypes; - } - - /** {@inheritDoc} */ - @Override - public Class<?> getPrimaryInputType() { - return MappingEncoding.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiAllocationConstraintEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiAllocationConstraintEvaluator.java deleted file mode 100644 index 2f515f130b638678a630543ccc7d395f3d9cbdbe..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiAllocationConstraintEvaluator.java +++ /dev/null @@ -1,143 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComponentMultiAllocationConstraintEvaluator.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator.constraint; - -import static org.fortiss.tooling.common.util.LambdaUtils.mapInOut; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiAllocationConstraint; -import org.opt4j.core.DoubleValue; -import org.opt4j.core.Value; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * Deployment constraint which defines the allowed deployments of - * {@link IDeployableComponentAdapter}s to {@link IExecutionUnitAdapter}s. All other allocations are - * forbidden. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: 44203486FB3FAB9BEB1CBCA6F7E8D0B1 - */ -// TODO: Register this evaluator for AstractTaskMappings. -public class ComponentMultiAllocationConstraintEvaluator<S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - extends ConstraintEvaluatorBase<T, Boolean, ComponentMultiAllocationConstraint> { - - /** Constructor. */ - public ComponentMultiAllocationConstraintEvaluator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ComponentMultiAllocationConstraint optGoal) throws Exception { - super(systemModelAdapter, optGoal); - } - - /** {@inheritDoc} */ - @Override - public DoubleValue evaluateGoal(T phenotype, FlatPhenotypeMap<Phenotype> phenotypeTypeMap, - ClassToInstanceMap<EObject> transformedModels) { - // Already considered in the operators. - return new DoubleValue(0.0); - } - - /** - * {@inheritDoc} - * - * @throws Exception - * if the component or execution unit reference is missing, if the component is not - * part of the deployable component set, or if the referenced execution unit is not - * in the set of deployment targets. - */ - @Override - public boolean validateInputs() throws Exception { - if(explorationTarget.getComponent() == null || - systemModelAdapter.getDeployableComponentOf(explorationTarget.getComponent()) == null) { - throw new Exception("The referenced component of the dislocation constraint " + - explorationTarget.getName() + "(id: " + explorationTarget.getId() + - ") is not correctly specified." + - " Either it is missing, or not part of the set of deployable components."); - } - - if(explorationTarget.getExecutionUnits().isEmpty() || - !mapInOut(systemModelAdapter.getDeploymentTargets(), t -> t.getObject(), - ArrayList::new).containsAll(explorationTarget.getExecutionUnits())) { - throw new Exception("The referenced execution unit of the dislocation constraint " + - explorationTarget.getName() + "(id: " + explorationTarget.getId() + - ") is not correctly specified." + - " Either it is missing, or not part of the set of deployment targets."); - } - - return true; - } - - /** {@inheritDoc} */ - @Override - public boolean validateInternal(ExplorationConstraint<?> expTarget, T solution, Value<?> value) { - Collection<IMappingEntry> entries = - solution.getIMappingEntriesOf(systemModelAdapter - .getDeployableComponentOf(((ComponentMultiAllocationConstraint)expTarget) - .getComponent())); - - if(entries.isEmpty()) { - return false; - } - - for(IMappingEntry entry : entries) { - if(!((ComponentMultiAllocationConstraint)expTarget).getExecutionUnits().contains( - entry.getTarget().getObject())) { - return false; - } - } - return true; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredInputTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Class<?> getPrimaryInputType() { - return InstantiatedTaskMappingEncoding.class; - } - - /** {@inheritDoc} */ - @Override - public IExplorationTargetEvaluator<T, Boolean, ComponentMultiAllocationConstraint> - createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ComponentMultiAllocationConstraint explorationTarget) throws Exception { - return new ComponentMultiAllocationConstraintEvaluator<>(systemModelAdapter, - explorationTarget); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiDislocationConstraintEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiDislocationConstraintEvaluator.java deleted file mode 100644 index 1d86dc75536a4fdd5f87b76b63cefabd58e5d755..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ComponentMultiDislocationConstraintEvaluator.java +++ /dev/null @@ -1,128 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComponentMultiDislocationConstraintEvaluator.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator.constraint; - -import static org.fortiss.tooling.common.util.LambdaUtils.mapInOut; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiDislocationConstraint; -import org.opt4j.core.DoubleValue; -import org.opt4j.core.Value; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * Constraint which defines the disallowed allocations of {@link IDeployableComponentAdapter}s to - * {@link IExecutionUnitAdapter}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: F515C13FCF10224B96BC3504A9493BC6 - */ -// TODO: Register this evaluator for AstractTaskMappings. -public class ComponentMultiDislocationConstraintEvaluator<S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - extends ConstraintEvaluatorBase<T, Boolean, ComponentMultiDislocationConstraint> { - - /** Constructor. */ - public ComponentMultiDislocationConstraintEvaluator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ComponentMultiDislocationConstraint optGoal) throws Exception { - super(systemModelAdapter, optGoal); - } - - /** {@inheritDoc} */ - @Override - public DoubleValue evaluateGoal(T phenotype, FlatPhenotypeMap<Phenotype> phenotypeTypeMap, - ClassToInstanceMap<EObject> transformedModels) { - // Already considered in the operators. - return new DoubleValue(0.0); - } - - /** - * {@inheritDoc} - * - * @throws Exception - * if the component or execution unit reference is missing, if the component is not - * part of the deployable component set, or if the referenced execution unit is not - * in the set of deployment targets. - */ - @Override - public boolean validateInputs() throws Exception { - if(explorationTarget.getComponent() == null || - systemModelAdapter.getDeployableComponentOf(explorationTarget.getComponent()) == null) { - throw new Exception("The referenced component of the dislocation constraint " + - explorationTarget.getName() + "(id: " + explorationTarget.getId() + - ") is not correctly specified." + - " Either it is missing, or not part of the set of deployable components."); - } - - if(explorationTarget.getExecutionUnits().isEmpty() || - !mapInOut(systemModelAdapter.getDeploymentTargets(), t -> t.getObject(), - ArrayList::new).containsAll(explorationTarget.getExecutionUnits())) { - throw new Exception("The referenced execution unit of the dislocation constraint " + - explorationTarget.getName() + "(id: " + explorationTarget.getId() + - ") is not correctly specified." + - " Either it is missing, or not part of the set of deployment targets."); - } - - return true; - } - - /** {@inheritDoc} */ - @Override - public boolean validateInternal(ExplorationConstraint<?> expTarget, T solution, Value<?> value) { - // Already considered in the operators. - // TODO: Just to be safe: add a real check. - return true; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredInputTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Class<?> getPrimaryInputType() { - return InstantiatedTaskMappingEncoding.class; - } - - /** {@inheritDoc} */ - @Override - public IExplorationTargetEvaluator<T, Boolean, ComponentMultiDislocationConstraint> - createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ComponentMultiDislocationConstraint explorationTarget) throws Exception { - return new ComponentMultiDislocationConstraintEvaluator<>(systemModelAdapter, - explorationTarget); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ConstraintEvaluatorBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ConstraintEvaluatorBase.java deleted file mode 100644 index 070bea209ca1b72efe276b4f1714ad4c5355acb1..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/ConstraintEvaluatorBase.java +++ /dev/null @@ -1,86 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ConstraintEvaluatorBase.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator.constraint; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.evaluator.ExplorationTargetEvaluatorBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.opt4j.core.Value; -import org.opt4j.core.problem.Evaluator; - -/** - * Base class for {@link Evaluator}s of constraints. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: 0B434E33B9C4DB5CAB207D4F382ED1B2 - */ -public abstract class ConstraintEvaluatorBase<P extends Phenotype, RT, T extends ExplorationConstraint<RT>> - extends ExplorationTargetEvaluatorBase<P, RT, T> implements IConstraintEvaluator<P, RT, T> { - - /** - * Defines the acceptable numeric imprecision, i.e. the allowed violation of constraints during - * the validation phase. - */ - protected final static double NUMERIC_IMPRECISION = 10E-9; - - /** - * Intended for counting the number of iterations of the DSE. It can be used in the evaluate - * method to increase the punishment of constraints with increased progress of the solver. - */ - private int iterationCount; - - /** Prototype constructor. */ - protected ConstraintEvaluatorBase() { - } - - /** Creates an evaluator for a given exploration goal. */ - protected ConstraintEvaluatorBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - T goal) throws Exception { - super(systemModelAdapter, goal); - - // Init with -1 due to automatic increment during readout via its getter function. - iterationCount = -1; - } - - // TODO: remove the line below. A status genotype is needed here. - /** - * Returns the "iteration count". If the iteration count shall be used, it must be called - * EXACTLY ONCE per DSE iteration. - */ - protected int getIterationCountAndIncrement() { - return iterationCount++; - } - - /** {@inheritDoc} */ - @Override - public <M> boolean validate(ExplorationConstraint<?> expTarget, M solution, - Class<M> solutionType, Value<?> value) { - if(!solutionType.isAssignableFrom(solution.getClass())) { - return false; - } - @SuppressWarnings("unchecked") P castSolution = (P)solution; - return validateInternal(expTarget, castSolution, value); - } - - /** Actual validation method that must be implemented by each {@link IConstraintEvaluator}. */ - public abstract boolean validateInternal(ExplorationConstraint<?> expTarget, P solution, - Value<?> value); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/DeadlineConstraintEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/DeadlineConstraintEvaluator.java deleted file mode 100644 index 72426241b57b307bd48803f3b2b4ea77c0d5dd85..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/DeadlineConstraintEvaluator.java +++ /dev/null @@ -1,216 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DeadlineConstraintEvaluator.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator.constraint; - -import static java.lang.Math.pow; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashSet; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.InstantiatedAcyclicTaskGraphEncoding; -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.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3.AF3SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.time.DeadlineConstraint; -import org.opt4j.core.DoubleValue; -import org.opt4j.core.Value; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * Evaluator for deadline objectives. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: CC305857496D18F71932E80CF4D14AB4 - */ -public class DeadlineConstraintEvaluator<S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - extends ConstraintEvaluatorBase<StrictTTSchedule<S, T>, Double, DeadlineConstraint> { - - /** - * The source component which defines the component associated with the start time of this - * deadline. - */ - private Collection<IDeployableComponentAdapter<?>> sourceDeployableComponent; - - /** - * The target component which defines the component associated with the finish time of this - * deadline. - */ - private Collection<IDeployableComponentAdapter<?>> targetDeployableComponent; - - /** Stores the deadline for this goal. */ - private double deadline; - - /** Objective to track evaluation of this {@link ExplorationTarget}. */ - public DeadlineConstraintEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DeadlineConstraint optGoal) throws Exception { - super(systemModelAdapter, optGoal); - sourceDeployableComponent = new ArrayList<>(); - targetDeployableComponent = new ArrayList<>(); - - sourceDeployableComponent.add(systemModelAdapter.getDeployableComponentOf(optGoal - .getStartComponent())); - targetDeployableComponent.add(systemModelAdapter.getDeployableComponentOf(explorationTarget - .getEndComponent())); - - deadline = explorationTarget.getDeadline(); - - // TODO: AD: The cast to the AF3 systemmodeladapter breaks the abstration the goals. It - // 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. - IDeployableComponentAdapter<?> origStartComponent = - ((AF3SystemModelAdapter)systemModelAdapter).getDeployableComponentAdapter(explorationTarget - .getStartComponent()); - if(origStartComponent.isInstantiation()) { - sourceDeployableComponent.add(origStartComponent); - } else { - sourceDeployableComponent.addAll(origStartComponent.getReplacementComponents()); - } - - IDeployableComponentAdapter<?> origTargetComponent = - ((AF3SystemModelAdapter)systemModelAdapter).getDeployableComponentAdapter(explorationTarget - .getEndComponent()); - if(origStartComponent.isInstantiation()) { - targetDeployableComponent.add(origTargetComponent); - } else { - targetDeployableComponent.addAll(origTargetComponent.getReplacementComponents()); - } - } - - /** - * evaluate the deadline objective - * if the deadline is met, we set the fitness value to -1 - * if the deadline is violated, we set the fitness value to the gap between the actual latency - * and the deadline - */ - @Override - public DoubleValue evaluateGoal(StrictTTSchedule<S, T> schedule, - FlatPhenotypeMap<Phenotype> phenotypeTypeMap, - ClassToInstanceMap<EObject> transformedModels) { - @SuppressWarnings("unchecked") InstantiatedAcyclicTaskGraphEncoding<S, ?> acycItgEnc = - phenotypeTypeMap.getEncoding(InstantiatedAcyclicTaskGraphEncoding.class); - assert (acycItgEnc != null) : "The required acyclic and instantiated task graph encoding could not be found in the map of already decoded phenotypes."; - - double retval = 0; - - // One TaskGraph suffices as we know that "replacements" are always located in the same task - // graph. - TaskGraph taskGraph = - acycItgEnc.getTaskGraphOf(sourceDeployableComponent.stream().findFirst().get()); - // we need to check each iteration in the hyper period - for(int i = 0; i < systemModelAdapter.getHyperPeriod() / taskGraph.getPeriod(); i++) { - // Required for the lambda operators. - final int j = i; - - // the start time is the release time of this iteration, which is the beginning - // of the period - // double start = i * tg.getPeriod(); - IDeployableComponentAdapter<?> earliestComp = - sourceDeployableComponent.stream() - .min(Comparator.comparing(t -> schedule.getFirstStartTime(t, j))).get(); - double start = schedule.getFirstStartTime(earliestComp, i); - IDeployableComponentAdapter<?> latestComp = - targetDeployableComponent.stream() - .min(Comparator.comparing(t -> schedule.getLastEndTime(t, j))).get(); - double end = schedule.getLastEndTime(latestComp, i); - double latency = end - start; - - // TODO: fix the logic below, it is a stylistic nightmare. - if(latency <= 0) - continue; - - // see if the deadline is met - if(!(latency > deadline)) { - // deadline ok, keep the retval unchanged - } else { - // deadline violated - if(retval < 0) { - retval = latency - deadline; - } else { - retval += latency - deadline; - } - } - } - - return new DoubleValue(retval > 0 ? pow(retval * getIterationCountAndIncrement(), 2) : 0); - } - - /** {@inheritDoc} */ - @Override - public boolean validateInputs() { - // TODO: AD: is this check really required here? Shouldn't this be done by the - // inputvalidator? - if(explorationTarget.getStartComponent() == null || explorationTarget.getEndComponent() == null || - explorationTarget.getDeadline() <= 0) { - return false; - } - - return true; - } - - /** {@inheritDoc} */ - @Override - public boolean validateInternal(ExplorationConstraint<?> expTarget, - StrictTTSchedule<S, T> solution, Value<?> value) { - // TODO: Readd the getLimitation support or find another way to express the same. - Double evalValue = value.getDouble(); - assert (expTarget instanceof DeadlineConstraint); - if(evalValue > ((DeadlineConstraint)expTarget).getLimitation() - NUMERIC_IMPRECISION) { - return false; - } - return true; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredInputTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(StrictTTSchedule.class); - inputTypes.add(InstantiatedAcyclicTaskGraphEncoding.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Class<?> getPrimaryInputType() { - return StrictTTSchedule.class; - } - - /** {@inheritDoc} */ - @Override - public IExplorationTargetEvaluator<StrictTTSchedule<S, T>, Double, DeadlineConstraint> - createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DeadlineConstraint explorationTarget) throws Exception { - return new DeadlineConstraintEvaluator<S, T>(systemModelAdapter, explorationTarget); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/IConstraintEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/IConstraintEvaluator.java deleted file mode 100644 index da71cc296e453cbf12eea22569cc3eb707395a2e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/IConstraintEvaluator.java +++ /dev/null @@ -1,42 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IConstraintEvaluator.java 3404 2016-08-26 15:01:08Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator.constraint; - -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.opt4j.core.Value; -import org.opt4j.core.problem.Evaluator; - -/** - * Interface for {@link Evaluator}s of constraints. Since constraints are hard requirements to - * possible solutions a problem, a validate method is required to ensure that a feasible solution - * set is provided bys the DSE, i.e. no constraints are violated by these solutions. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3404 $ - * @ConQAT.Rating RED Hash: 80C2AAB7C0FE278EF7459453A884BBA9 - */ -public interface IConstraintEvaluator<P, RT, T extends ExplorationConstraint<RT>> { - - /** - * The {@code validate} is applied to phenotypes in order to check whether proposed solutions - * are contained within the feasible set. - */ - public <M> boolean validate(ExplorationConstraint<?> expTarget, M solution, - Class<M> solutionType, Value<?> value); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/MappingEvaluatorConstraint.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/MappingEvaluatorConstraint.java deleted file mode 100644 index c5bee4721d158b008b2d0f5fcdebf7903fbe5724..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/MappingEvaluatorConstraint.java +++ /dev/null @@ -1,107 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2017 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator.constraint; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.MappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.evaluator.MappingEvaluator; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.dsl_v2.model.function.Maximize; -import org.fortiss.af3.exploration.dsl_v2.model.function.Minimize; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.opt4j.core.IntegerValue; -import org.opt4j.core.Value; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 63CFFFB2D5752389E1FA22AA22F52C81 - */ -public class MappingEvaluatorConstraint extends MappingEvaluator implements - IConstraintEvaluator<MappingEncoding, Boolean, ExplorationConstraint<Boolean>> { - - public MappingEvaluatorConstraint() { - } - - public MappingEvaluatorConstraint(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationTarget<Double> explorationTarget) throws Exception { - super(systemModelAdapter, explorationTarget); - } - - /** {@inheritDoc} */ - @Override - public Value<?> evaluateGoal(MappingEncoding phenotype, - FlatPhenotypeMap<Phenotype> phenotypeTypeMap, - ClassToInstanceMap<EObject> transformedModels) { - mapping = phenotype; - - Boolean retVal = null; - // FIXME: pass parsing exception to upper layers. - try { - retVal = expression.accept(this, Boolean.class); - } catch(Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - // TODO Auto-generated method stub - return new IntegerValue(retVal == true ? 1 : 0); - } - - /** {@inheritDoc} */ - @Override - public Object visit(Maximize max) throws Exception { - // TODO Auto-generated method stub - return null; - } - - /** {@inheritDoc} */ - @Override - public Object visit(Minimize min) throws Exception { - // TODO Auto-generated method stub - return null; - } - - /** {@inheritDoc} */ - @Override - public IExplorationTargetEvaluator<MappingEncoding, Double, ExplorationTarget<Double>> - createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationTarget<Double> explorationTarget) throws InstantiationException, - Exception { - return new MappingEvaluatorConstraint(systemModelAdapter, explorationTarget); - } - - /** {@inheritDoc} */ - @Override - public <M> boolean validate(ExplorationConstraint<?> expTarget, M solution, - Class<M> solutionType, Value<?> value) { - Double evalValue = value.getDouble(); - if(evalValue > 0.0) { - return false; - } - return true; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/PeriodConstraintEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/PeriodConstraintEvaluator.java deleted file mode 100644 index 8ce29b76e27af3670ee5d0a801195736ace3468e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/PeriodConstraintEvaluator.java +++ /dev/null @@ -1,171 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: PeriodConstraintEvaluator.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator.constraint; - -import static java.lang.Math.pow; - -import java.util.Collection; -import java.util.HashSet; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.InstantiatedTaskGraphEncoding; -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.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.time.PeriodConstraint; -import org.opt4j.core.DoubleValue; -import org.opt4j.core.Value; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * This {@link IConstraintEvaluator} evaluates whether all {@link IDeployableComponentAdapter}s are - * executed within their respective period. Any violation is summed and then squared. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: 032C0F97466EE71EF882E2C6F00EE2E7 - */ -public class PeriodConstraintEvaluator<S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - extends ConstraintEvaluatorBase<StrictTTSchedule<S, T>, Double, PeriodConstraint> { - - /** Objective to track evaluation of this {@link ExplorationTarget}. */ - public PeriodConstraintEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - PeriodConstraint optGoal) throws Exception { - super(systemModelAdapter, optGoal); - } - - /** - * evaluate the deadline objective - * if the deadline is met, we set the fitness value to -1 - * if the deadline is violated, we set the fitness value to the gap between the actual latency - * and the deadline - */ - @Override - public DoubleValue evaluateGoal(StrictTTSchedule<S, T> schedule, - FlatPhenotypeMap<Phenotype> phenotypeTypeMap, - ClassToInstanceMap<EObject> transformedModels) { - @SuppressWarnings("unchecked") InstantiatedTaskGraphEncoding<S, ?> itgEnc = - phenotypeTypeMap.getEncoding(InstantiatedTaskGraphEncoding.class); - assert (itgEnc != null) : "The required instantiated task graph encoding could not be found in the map of phenotypes."; - InstantiatedTaskMappingEncoding<?> itmEnc = - phenotypeTypeMap.getEncoding(InstantiatedTaskMappingEncoding.class); - assert (itmEnc != null) : "The required instantiated task mapping encoding could not be found in the map of phenotypes."; - - double retval = 0; - - // we evaluate if all tasks are within the period. we want everything to be - // finished within the period - for(IDeployableComponentAdapter<?> deployableComponent : itmEnc.getDeployedComponents()) { - TaskGraph taskGraph = itgEnc.getTaskGraphOf(deployableComponent); - // we need to check each iteration in the hyper period - if(taskGraph != null) { - for(int i = 0; i < systemModelAdapter.getHyperPeriod() / taskGraph.getPeriod(); i++) { - double periodEnd = (i + 1) * taskGraph.getPeriod(); - double end = schedule.getLastEndTime(deployableComponent, i); - if(end > periodEnd) { - retval += end - periodEnd; - } - } - } - } - - return new DoubleValue(retval > 0 ? pow(retval, 2) : 0); - } - - /** - * {@inheritDoc} - * - * @throws Exception - * if the period of one component is missing, or one combination of a component and - * execution unit has no WCET specified. - */ - @Override - public boolean validateInputs() throws Exception { - // Each deployable component has a period. - for(IDeployableComponentAdapter<?> component : systemModelAdapter.getDeployableComponents()) { - if(component.getTimingRequirementPeriod() == 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" + - " the component itself or indirectly by its ports."); - } - } - - // Check WCETs of each component/execution unit combination. - for(IDeployableComponentAdapter<?> component : systemModelAdapter.getDeployableComponents()) { - for(IExecutionUnitAdapter<?> execUnit : systemModelAdapter.getDeploymentTargets()) { - if(component.getWcet(execUnit) == null) { - throw new Exception("The combination of the component " + component.getName() + - " and the executuion unit " + execUnit.getName() + - " does not have a WCET specified. This parameter is required for the DSE."); - } - } - } - - return true; - } - - /** {@inheritDoc} */ - @Override - public boolean validateInternal(ExplorationConstraint<?> expTarget, - StrictTTSchedule<S, T> solution, Value<?> value) { - Double evalValue = value.getDouble(); - assert (expTarget instanceof PeriodConstraint); - Double limit = ((PeriodConstraint)expTarget).getLimitation(); - limit = limit == null ? 0 : limit; - if(evalValue > limit + NUMERIC_IMPRECISION) { - return false; - } - return true; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredInputTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(StrictTTSchedule.class); - inputTypes.add(InstantiatedTaskGraphEncoding.class); - inputTypes.add(InstantiatedTaskMappingEncoding.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Class<?> getPrimaryInputType() { - return StrictTTSchedule.class; - } - - /** {@inheritDoc} */ - @Override - public IExplorationTargetEvaluator<StrictTTSchedule<S, T>, Double, PeriodConstraint> - createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - PeriodConstraint explorationTarget) throws Exception { - return new PeriodConstraintEvaluator<>(systemModelAdapter, explorationTarget); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/SafetyIntegrityLevelConstraintEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/SafetyIntegrityLevelConstraintEvaluator.java deleted file mode 100644 index e0da43bfe7434841bc6f39f92f7d5d3ad0854864..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/constraint/SafetyIntegrityLevelConstraintEvaluator.java +++ /dev/null @@ -1,218 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SafetyIntegrityLevelConstraintEvaluator.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator.constraint; - -import static java.lang.Math.pow; -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.castToRawColl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.eclipse.emf.common.util.Enumerator; -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Component; -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.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.SafetyIntegrityLevelConstraint; -import org.fortiss.af3.safety.model.SIL; -import org.opt4j.core.DoubleValue; -import org.opt4j.core.Value; -import org.opt4j.core.problem.Evaluator; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * Preliminary {@link Evaluator} to check whether the allocation of specific - * {@link IDeployableComponentAdapter}s to {@link IExecutionUnitAdapter}s satisfy the Safety - * Integrity Level required by the {@link IDeployableComponentAdapter}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: 9CCAB080342B65BF174E719D6D192F3A - */ -public class SafetyIntegrityLevelConstraintEvaluator<S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - extends ConstraintEvaluatorBase<T, SIL, SafetyIntegrityLevelConstraint> { - - /** Constructor. */ - public SafetyIntegrityLevelConstraintEvaluator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - SafetyIntegrityLevelConstraint optGoal) throws Exception { - super(systemModelAdapter, optGoal); - } - - /** {@inheritDoc} */ - @Override - public DoubleValue evaluateGoal(T phenotype, FlatPhenotypeMap<Phenotype> phenotypeTypeMap, - ClassToInstanceMap<EObject> transformedModels) { - List<SIL> silViolations = getSILViolations(phenotype); - double aggregatedViolations = - silViolations.stream().mapToDouble(sil -> pow(sil.getValue(), 2.0)).sum(); - - return new DoubleValue(aggregatedViolations); - } - - /** {@inheritDoc} */ - @Override - public boolean validateInternal(ExplorationConstraint<?> expTarget, T mapping, Value<?> value) { - Map<IDeployableComponentAdapter<?>, Collection<S>> allocationMap = - mapping.getAllocationMap(); - List<IDeployableComponentAdapter<?>> silComponents = getSILComponentAdapters(); - List<SIL> silBounds = explorationTarget.getLimitation(); - for(int idx = 0; idx < silComponents.size(); idx++) { - SIL actualSIL = detectSIL(silComponents.get(idx), allocationMap); - if(actualSIL.getValue() < silBounds.get(idx).getValue()) { - return false; - } - } - return true; - } - - /** {@inheritDoc} */ - @Override - public boolean validateInputs() { - // Currently, there is no known error case needing validation - return true; - } - - /** - * Returns the set of {@link IDeployableComponentAdapter}s that is equivalent to the set of - * {@link Component}s given in the {@link SafetyIntegrityLevelConstraint}. - */ - private List<IDeployableComponentAdapter<?>> getSILComponentAdapters() { - Collection<IDeployableComponentAdapter<?>> deplComp = - castToRawColl(systemModelAdapter.getDeployableComponents()); - return deplComp.stream().filter(c -> explorationTarget.getComponents().contains(c)) - .collect(Collectors.toList()); - } - - /** - * Returns the list of of violated {@link SIL} requirements as the difference between the - * required {@link SIL} and the actually achieved {@link SIL}. - * The list has the same order as the list of referenced {@link Component}s in the - * {@link SafetyIntegrityLevelConstraint}. - */ - private List<SIL> getSILViolations(T mapping) { - List<SIL> silViolations = new ArrayList<>(); - Map<IDeployableComponentAdapter<?>, Collection<S>> allocationMap = - mapping.getAllocationMap(); - List<IDeployableComponentAdapter<?>> silComponents = getSILComponentAdapters(); - List<SIL> silBounds = explorationTarget.getLimitation(); - for(int idx = 0; idx < silComponents.size(); idx++) { - SIL actualSIL = detectSIL(silComponents.get(idx), allocationMap); - silViolations.add(calculateSILViolation(silBounds.get(idx), actualSIL)); - } - return silViolations; - } - - // TODO: Port to org.fortiss.af3.safety - /** Helper function for the calculation of the actual SIL of a deployed component. */ - private SIL detectSIL(IDeployableComponentAdapter<?> deployableComponent, - Map<IDeployableComponentAdapter<?>, Collection<S>> allocationMap) { - // Note: real hw replication is not meant here, just the allocation to different cores/ecus - Collection<S> replica = allocationMap.get(deployableComponent); - - // Determine the number of replications onto different execution units. This separation is - // yet very primitive. - Collection<IExecutionUnitAdapter<?>> hwReplica = new HashSet<IExecutionUnitAdapter<?>>(); - for(S currentTaskReplic : replica) { - hwReplica.add(currentTaskReplic.getTarget()); - } - int silTypeToInt = 0; - - // Determine the SIL of a "safety function", i.e. a safety-annotated component mapped onto - // an execution unit, according to the tables given in IEC 61508-2. - List<SIL> parallelSILs = new ArrayList<SIL>(); - for(IExecutionUnitAdapter<?> ecu : hwReplica) { - double sff = ecu.getSafeFailureFraction(); - if(sff >= 0.0 && sff < 0.6) { - parallelSILs.add(SIL.SIL0); - } else if(sff < 0.9) { - parallelSILs.add(SIL.SIL1); - } else if(sff < 0.99) { - parallelSILs.add(SIL.SIL2); - } else if(sff <= 1.0) { - parallelSILs.add(SIL.SIL3); - } else { - throw new RuntimeException( - "An invalid value for the safe failure fraction has been given to the optimization. The allowed range is 0 to 1."); - } - } - - // Determine the overall SIL of the safety function considering the hardware replication. - // The upper limit is set to 4, in accordance with IEC 61508. - for(SIL sil : parallelSILs) { - silTypeToInt += sil.getValue(); - } - if(silTypeToInt > 4) - silTypeToInt = 4; - - return SIL.get(silTypeToInt); - } - - /** - * Helper function for the calculation of the punishment value for a single SIL violation. - * Currently, this value is determined by the iteration number (weak punishment in the - * beginning) and the quadratical deviation from the desired SIL. - */ - // TODO: Port to org.fortiss.af3.safety - private SIL calculateSILViolation(Enumerator requiredSIL, SIL actualSIL) { - int differenceSIL = requiredSIL.getValue() - actualSIL.getValue(); - return SIL.get(differenceSIL); - - // TODO divide by number of iterations, currently not accessible - // if(differenceSIL > 0) { - // return getIterationCountAndIncrement() * Math.pow(differenceSIL, 2.0); - // } - // return 0.0; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredInputTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(InstantiatedTaskMappingEncoding.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Class<?> getPrimaryInputType() { - return InstantiatedTaskMappingEncoding.class; - } - - /** {@inheritDoc} */ - @Override - public IExplorationTargetEvaluator<T, SIL, SafetyIntegrityLevelConstraint> createEvaluator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - SafetyIntegrityLevelConstraint explorationTarget) throws Exception { - return new SafetyIntegrityLevelConstraintEvaluator<S, T>(systemModelAdapter, - explorationTarget); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/EnergyObjectiveEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/EnergyObjectiveEvaluator.java deleted file mode 100644 index 06d381ac2fd8753b4edaf8059f1f9d2860bc4342..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/EnergyObjectiveEvaluator.java +++ /dev/null @@ -1,155 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: EnergyObjectiveEvaluator.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator.objective; - -import java.util.Collection; -import java.util.HashSet; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule.ResourceSchedule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.TimeSlot; -import org.fortiss.af3.exploration.alg.dse.evaluator.ExplorationTargetEvaluatorBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ICommunicationResourceAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -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.ITransmissionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.moea.model.predefined.EnergyMinObjective; -import org.opt4j.core.DoubleValue; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * Simple energy evaluator that just sums the execution times. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: 8ED9AAE58C86441161E642DC30FE526A - */ -public class EnergyObjectiveEvaluator<S extends TaskMappingEntry, T extends TaskMappingEncoding<S>> - extends ExplorationTargetEvaluatorBase<StrictTTSchedule<S, T>, Double, EnergyMinObjective> { - - /** Creates a template energy objective evaluator */ - public EnergyObjectiveEvaluator() { - } - - /** Creates an energy objective evaluator */ - public EnergyObjectiveEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - EnergyMinObjective goal) throws Exception { - super(systemModelAdapter, goal); - } - - /** - * This energy evaluator sums the slot lengths of the {@link StrictTTSchedule}. Thus, it - * considers all {@link IResourceAdapter}s that are under the regime of that schedule, e.g., - * {@link IExecutionUnitAdapter}s and {@link ITransmissionUnitAdapter}s. - */ - @Override - public DoubleValue evaluateGoal(StrictTTSchedule<S, T> schedule, - FlatPhenotypeMap<Phenotype> phenotypeTypeMap, - ClassToInstanceMap<EObject> transformedModels) { - InstantiatedTaskMappingEncoding<?> itmEnc = - phenotypeTypeMap.getEncoding(InstantiatedTaskMappingEncoding.class); - assert (itmEnc != null) : "The required instantiated task mapping encoding could not be found in the map of already decoded phenotypes."; - - if(schedule.getResources().isEmpty()) { - return new DoubleValue(Double.MAX_VALUE); - } - - double energy = 0; - - for(IResourceAdapter<?> deploymentTarget : schedule.getResources()) { - ResourceSchedule localSchedule = schedule.getResourceSchedule(deploymentTarget); - // Catch the case where no components are deployed on the given resource. - if(localSchedule != null) { - for(TimeSlot t : localSchedule.keySet()) { - assert (t.getDuration() >= 0); - if(deploymentTarget instanceof IExecutionUnitAdapter) { - IExecutionUnitAdapter<?> executionUnit = - (IExecutionUnitAdapter<?>)deploymentTarget; - IDeployableComponentAdapter<?> deployedComponent = - t.getDeployedRequester().getDeployableComponent(); - - energy += deployedComponent.getEnergyConsumption(executionUnit); - } else if(deploymentTarget instanceof ICommunicationResourceAdapter) { - ICommunicationResourceAdapter<?> commResource = - (ICommunicationResourceAdapter<?>)deploymentTarget; - energy += commResource.getPower(t.getDeployedMessage().getMessageSize()); - } - } - } - } - - return new DoubleValue(energy); - } - - /** - * {@inheritDoc} - * - * @throws Exception - */ - @Override - public boolean validateInputs() throws Exception { - // TODO: If constraints exist for the allocation, only consider component / execution unit - // allocations that are valid acc. to these constraints. - for(IDeployableComponentAdapter<?> component : systemModelAdapter.getDeployableComponents()) { - for(IExecutionUnitAdapter<?> execUnit : systemModelAdapter.getDeploymentTargets()) { - if(component.getEnergyConsumption(execUnit) == null) { - throw new Exception( - "The energy consumption of the allocation of the component " + - component.getName() + " to the execution unit " + - execUnit.getName() + " has not been defined. " + - "It is required for the energy minimization objective."); - } - } - } - - return true; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredInputTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(TaskMappingEncoding.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Class<?> getPrimaryInputType() { - return StrictTTSchedule.class; - } - - /** {@inheritDoc} */ - @Override - public IExplorationTargetEvaluator<StrictTTSchedule<S, T>, Double, EnergyMinObjective> - createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - EnergyMinObjective explorationTarget) throws Exception { - return new EnergyObjectiveEvaluator<>(systemModelAdapter, explorationTarget); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FailSilentReliabilityEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FailSilentReliabilityEvaluator.java deleted file mode 100644 index df21e82d83afe742fc1d019d221f698232a33eed..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FailSilentReliabilityEvaluator.java +++ /dev/null @@ -1,121 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FailSilentReliabilityEvaluator.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator.objective; - -import java.util.Collection; -import java.util.HashSet; - -import org.apfloat.Apfloat; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FailSilentTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FailSilentTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -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.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.moea.model.predefined.FailureMinObjective; -import org.fortiss.af3.exploration.moea.model.predefined.FailureType; - -/** - * Reliability analysis for strict time-triggered execution model (with fail-silent assumption). - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: 64B2599A4B72C4B93EEA66D461531DE9 - */ -public class FailSilentReliabilityEvaluator extends - ReliabilityEvaluatorBase<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> { - - /** Creates a fail-silent reliability analysis evaluator for a given exploration goal. */ - public FailSilentReliabilityEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - FailureMinObjective goal) throws Exception { - super(systemModelAdapter, goal); - } - - /** {@inheritDoc} */ - @Override - protected double evaluateInternal( - StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> schedule, - FailSilentTaskMappingEncoding itmEnc, DefaultTaskGraph taskGraph, - FailureType failureProbabilityType) { - - // for the StrictTTFaileSilence model, no sdc could occur - if(failureProbabilityType == FailureType.SDC) { - return 0; - } - - Apfloat overallSuccRate = new Apfloat(1, FP_PRECISION); - Apfloat one = new Apfloat(1, FP_PRECISION); - - for(IDeployableComponentAdapter<?> deployableComponent : itmEnc.getDeployedComponents()) { - // TODO: Check if this correctly determines the taskFailureRate - - // only software tasks are considered - - // the failure rate of the single request - Apfloat taskFailureRate = new Apfloat(1, FP_PRECISION); - // get the set of mappings - Collection<FailSilentTaskMappingEntry> entries = - itmEnc.getMappingEntriesOf(deployableComponent); - for(FailSilentTaskMappingEntry entry : entries) { - Apfloat fr = getComponentFailureRate(deployableComponent, entry.getTarget()); - if(fr != null) { - // the task fails only if all of its instances fail - // ASSUMPTIN: fail-silence - taskFailureRate = taskFailureRate.multiply(fr); - } - - } - // the overall application succeeds only if all of its tasks succeed - Apfloat taskSuccRate = one.subtract(taskFailureRate); - overallSuccRate = overallSuccRate.multiply(taskSuccRate); - } - - // return value is the overall failure probability - return (one.subtract(overallSuccRate)).doubleValue(); - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredInputTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(StrictTTSchedule.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Class<?> getPrimaryInputType() { - return StrictTTSchedule.class; - } - - /** {@inheritDoc} */ - @Override - public - IExplorationTargetEvaluator<StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>, Double, FailureMinObjective> - createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - FailureMinObjective explorationTarget) throws InstantiationException { - try { - return new FailSilentReliabilityEvaluator(systemModelAdapter, explorationTarget); - } catch(Exception e) { - throw new InstantiationException("Cannot instantiate the Evaluator " + - getClass().getSimpleName() + ": " + e.getMessage()); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FaultDetectionVotingReliabilityEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FaultDetectionVotingReliabilityEvaluator.java deleted file mode 100644 index 738832b8cd6c0bdf3af78802fab2615a56233c81..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/FaultDetectionVotingReliabilityEvaluator.java +++ /dev/null @@ -1,402 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FaultDetectionVotingReliabilityEvaluator.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator.objective; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apfloat.Apfloat; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FaultDetectionVotingTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FaultDetectionVotingTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -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.faultmodel.FaultDetector; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.moea.model.predefined.FailureMinObjective; -import org.fortiss.af3.exploration.moea.model.predefined.FailureType; - -/** - * Reliability analysis for strict time-triggered execution model (with fault-detection and voting). - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: 4D432EC4D5854F828EE726172D166149 - */ -public class FaultDetectionVotingReliabilityEvaluator - extends - ReliabilityEvaluatorBase<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> { - - /** Helper class to save the reliability information */ - private class ReliabilityMeasure { - - /** Success */ - public Apfloat suc; - - /** Detected unrecoverable fault */ - public Apfloat duf; - - /** Silent data corruption */ - public Apfloat sdc; - - /** Constructs a new {@link ReliabilityMeasure} (initialized to all zero). */ - public ReliabilityMeasure() { - this(new Apfloat(0, FP_PRECISION), new Apfloat(0, FP_PRECISION), new Apfloat(0, - FP_PRECISION)); - } - - /** Constructs a new {@link ReliabilityMeasure} (initialized to user supplied values) */ - public ReliabilityMeasure(Apfloat suc_in, Apfloat due_in, Apfloat sdc_in) { - suc = suc_in; - duf = due_in; - sdc = sdc_in; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "DUE=" + duf.doubleValue() + ",SDC=" + sdc.doubleValue(); - } - } - - /** Helper class or analyzing reliability of a single task using imperfect fault detectors */ - private class ActorAnalysisNode { - - /** Parent node */ - ActorAnalysisNode parent; - - /** The result: 1: SUC, 0: DUE, -1: SDC */ - int result; - - /** Occurrence probability up to now */ - Apfloat probability; - - /** {@link ActorAnalysisNode}'s level. */ - int level; - - /** Constructs a new {@link ActorAnalysisNode} (initialized to default values). */ - ActorAnalysisNode() { - this(null, 1, new Apfloat(1, FP_PRECISION), -1); - } - - /** Constructs a new {@link ActorAnalysisNode} (initialized to user supplied values). */ - public ActorAnalysisNode(ActorAnalysisNode parent, int result, Apfloat probability, - int level) { - this.parent = parent; - this.result = result; - this.probability = probability; - this.level = level; - } - } - - /** Last schedule */ - private StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> lastSchedule = - null; - - /** Last task graph */ - private DefaultTaskGraph lastTaskGraph = null; - - /** Last analysis result */ - private ReliabilityMeasure lastResult = null; - - /** - * Creates a fault-detection + voting reliability analysis evaluator for a given exploration - * goal. - */ - public FaultDetectionVotingReliabilityEvaluator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, FailureMinObjective target) - throws Exception { - super(systemModelAdapter, target); - } - - /** - * Reliability analysis for strict time-triggered execution model (with fault-detection and - * voting). - */ - @Override - public - double - evaluateInternal( - StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> schedule, - FaultDetectionVotingTaskMappingEncoding itmEnc, DefaultTaskGraph taskGraph, - FailureType failureProbabilityType) { - - // TODO: Implement this caching in a safer way, and potentially extend it to other cases. - // first of all, see if the scenario was just analyzed - if(schedule == lastSchedule && taskGraph == lastTaskGraph && lastResult != null) { - // System.out.println("using last result " + lastResult); - return convertResult(lastResult, failureProbabilityType); - // remember the last analysis scenario, this is used to avoid duplicated analysis for - // SDC and DUF - } - - // not analyzed yet, just do it - FaultDetectionVotingTaskMappingEncoding mapping = itmEnc; - // STEP 1: analyze the reliability of each actor - Map<IDeployableComponentAdapter<?>, ReliabilityMeasure> actorReliabilities = - new HashMap<IDeployableComponentAdapter<?>, ReliabilityMeasure>(); - - for(IDeployableComponentAdapter<?> deployableComponent : taskGraph.getTasks()) { - Collection<FaultDetectionVotingTaskMappingEntry> mappings = - mapping.getMappingEntriesOf(deployableComponent); - // compute the reliability of the task - ReliabilityMeasure rm = taskAnalysis(deployableComponent, taskGraph, mappings); - actorReliabilities.put(deployableComponent, rm); - - // System.out.println("task" + ((NamedObject)task.eContainer()).getName() + ":" + rm - // + "sum="+rm.suc.add(rm.duf).add(rm.sdc)); - } - - // STEP2: analyze the reliability of the application - ReliabilityMeasure appReliability = appAnalysis(taskGraph, actorReliabilities); - // System.out.println(solution.getEncoding()); - // System.out.println("appReliability" + taskgraph + appReliability); - // TODO - appReliability.duf = probabilityToFit(appReliability.duf, taskGraph.getPeriod()); - appReliability.sdc = probabilityToFit(appReliability.sdc, taskGraph.getPeriod()); - - // remember the last analysis - lastSchedule = schedule; - lastTaskGraph = taskGraph; - lastResult = appReliability; - - return convertResult(appReliability, failureProbabilityType); - } - - /** Converts a failure probability to FIT. */ - private Apfloat probabilityToFit(Apfloat p, double period) { - // the period is in primary time unit, convert to second - // TODO: currently, the timeUnit is removed from the model, is set to muesec - // double putos = Explorer.getInstance().toPrimaryTimeUnit(TimeUnitType.SECOND); - double putos = 1.0; - Apfloat numIterationPerHour = new Apfloat(3600.0 * putos / period); - Apfloat fit = - p.multiply(numIterationPerHour).multiply(new Apfloat(1000000000, FP_PRECISION)); - return fit; - } - - /** Entry point for task analysis */ - private ReliabilityMeasure taskAnalysis(IDeployableComponentAdapter<?> deployableComponent, - DefaultTaskGraph taskgraph, Collection<FaultDetectionVotingTaskMappingEntry> mappings) { - - ReliabilityMeasure rm = new ReliabilityMeasure(); - ActorAnalysisNode start = new ActorAnalysisNode(); - - // the iterative analysis routine - taskAnalysis(deployableComponent, start, taskgraph, rm, - (List<FaultDetectionVotingTaskMappingEntry>)mappings); - return rm; - } - - /** Analyzes the reliability of a task. */ - private void taskAnalysis(IDeployableComponentAdapter<?> deployableComponent, - ActorAnalysisNode current, DefaultTaskGraph taskgraph, ReliabilityMeasure rm, - List<FaultDetectionVotingTaskMappingEntry> mappings) { - - // the start node - if(current.level < 0) { - ActorAnalysisNode suc = - new ActorAnalysisNode(current, 1, new Apfloat(1, FP_PRECISION), - current.level + 1); - taskAnalysis(deployableComponent, suc, taskgraph, rm, mappings); - ActorAnalysisNode due = - new ActorAnalysisNode(current, 0, new Apfloat(1, FP_PRECISION), - current.level + 1); - taskAnalysis(deployableComponent, due, taskgraph, rm, mappings); - ActorAnalysisNode sdc = - new ActorAnalysisNode(current, -1, new Apfloat(1, FP_PRECISION), - current.level + 1); - taskAnalysis(deployableComponent, sdc, taskgraph, rm, mappings); - } else { - // compute the local probabilities - FaultDetectionVotingTaskMappingEntry mp = mappings.get(current.level); - Apfloat failureRate = getComponentFailureRate(deployableComponent, mp.getTarget()); - if(failureRate == null) - failureRate = new Apfloat(1, FP_PRECISION); - FaultDetector fd = - taskgraph.getFaultDetector(deployableComponent, mp.getFaultDetectorID()); - double coverage = fd.getCoverage(); - - Apfloat localPr; - Apfloat one = new Apfloat(1, FP_PRECISION); - Apfloat cov = new Apfloat(coverage, FP_PRECISION); - if(current.result > 0) { - localPr = one.subtract(failureRate); - } else if(current.result == 0) { - localPr = failureRate.multiply(cov); - } else { - localPr = failureRate.multiply(one.subtract(cov)); - } - - // System.out.println("level " + current.level+","+current.probability+","+localPr); - // see the if the next level is already the leaves of the tree, if yes, we compute the - // system-level probabilities - // if not, we create the children and continue - if(current.level >= mappings.size() - 1) { - // trace the previous results - ActorAnalysisNode aan = current; - int result = 0; - while(aan.parent != null) { - // sum the results - result += aan.result; - aan = aan.parent; - } - - if(result > 0) { - // result is suc - rm.suc = rm.suc.add(current.probability.multiply(localPr)); - } else if(result == 0) { - rm.duf = rm.duf.add(current.probability.multiply(localPr)); - } else { - rm.sdc = rm.sdc.add(current.probability.multiply(localPr)); - } - } else { - // create the children - ActorAnalysisNode suc = - new ActorAnalysisNode(current, 1, current.probability.multiply(localPr), - current.level + 1); - taskAnalysis(deployableComponent, suc, taskgraph, rm, mappings); - ActorAnalysisNode due = - new ActorAnalysisNode(current, 0, current.probability.multiply(localPr), - current.level + 1); - taskAnalysis(deployableComponent, due, taskgraph, rm, mappings); - ActorAnalysisNode sdc = - new ActorAnalysisNode(current, -1, current.probability.multiply(localPr), - current.level + 1); - taskAnalysis(deployableComponent, sdc, taskgraph, rm, mappings); - } - } - } - - /** - * Analyzes an application (based on the reliability of the individual actors). - * - * @param tg - * {@link DefaultTaskGraph} representing the application - */ - private ReliabilityMeasure appAnalysis(DefaultTaskGraph tg, - Map<IDeployableComponentAdapter<?>, ReliabilityMeasure> actorReliabilities) { - ReliabilityMeasure rm = new ReliabilityMeasure(); - - // SUC: the task is successful, iff all actors are successful - Apfloat taskSuc = computeTaskSuc(actorReliabilities); - - // SDC: a task is SDC iff, at least one of its tasks is SDC and non of them are DUE - Map<IDeployableComponentAdapter<?>, ReliabilityMeasure> actorReliabilitiesCopy = - new HashMap<IDeployableComponentAdapter<?>, ReliabilityMeasure>(actorReliabilities); - Apfloat taskSdc = new Apfloat(0, FP_PRECISION); - taskSdc = computeTaskSdc(actorReliabilitiesCopy); - - // result - Apfloat one = new Apfloat(1, FP_PRECISION); - rm.suc = taskSuc; - rm.sdc = taskSdc; - rm.duf = one.subtract(rm.suc).subtract(rm.sdc); - return rm; - } - - /** Computes the success probability of a task */ - private Apfloat computeTaskSuc( - Map<IDeployableComponentAdapter<?>, ReliabilityMeasure> actorReliabilities) { - // SUC: the task is successful, iff all actors are successful - Apfloat taskSuc = new Apfloat(1, FP_PRECISION); - for(IDeployableComponentAdapter<?> deployableComponent : actorReliabilities.keySet()) { - taskSuc = taskSuc.multiply(actorReliabilities.get(deployableComponent).suc); - } - return taskSuc; - } - - /** - * SDC(T)=SDC(t0)(SUC(T\t0)+SDC(T\t0))+SUC(t0)SDC(T\t0) - * =SDC(t0)SUC(T\t0) + (SDC(t0)+SUC(t0)) SDC(T\t0) - */ - private Apfloat computeTaskSdc( - Map<IDeployableComponentAdapter<?>, ReliabilityMeasure> actorReliabilities) { - - Apfloat taskSdc; - - // get the first entry (make sure map is not empty) - IDeployableComponentAdapter<?> deployableComponent = - (IDeployableComponentAdapter<?>)actorReliabilities.keySet().toArray()[0]; - ReliabilityMeasure rm = actorReliabilities.get(deployableComponent); - // now we can remove the entry from the map - actorReliabilities.remove(deployableComponent); - - if(actorReliabilities.isEmpty()) { - // no more actors - return rm.sdc; - } - - // first item - taskSdc = rm.sdc.multiply(computeTaskSuc(actorReliabilities)); - // second item - Apfloat t0NonDue = rm.sdc.add(rm.suc); - taskSdc = taskSdc.add(t0NonDue.multiply(computeTaskSdc(actorReliabilities))); - return taskSdc; - } - - /** Converts an analysis result according to the selected {@link FailureType}. */ - private double convertResult(ReliabilityMeasure measure, FailureType type) { - if(type == FailureType.DUF) { - // return measure.duf.doubleValue(); - return measure.duf.floatValue(); - } else if(type == FailureType.SDC) { - // return measure.sdc.doubleValue(); - return measure.sdc.floatValue(); - } else if(type == FailureType.ALL) { - // Apfloat one = new Apfloat(1,ReliabilityAnalysis.precision); - // return one.subtract(measure.suc).doubleValue(); - // return measure.duf.add(measure.sdc).doubleValue(); - return measure.duf.add(measure.sdc).floatValue(); - } - - return 0; - } - - /** {@inheritDoc} */ - @Override - public boolean validateInputs() { - // TODO Auto-generated method stub - return true; - } - - /** {@inheritDoc} */ - @Override - public Class<?> getPrimaryInputType() { - return StrictTTSchedule.class; - } - - /** {@inheritDoc} */ - @Override - public - IExplorationTargetEvaluator<StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>, Double, FailureMinObjective> - createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - FailureMinObjective explorationTarget) throws InstantiationException { - try { - return new FaultDetectionVotingReliabilityEvaluator(systemModelAdapter, - explorationTarget); - } catch(Exception e) { - throw new InstantiationException("Cannot instantiate the Evaluator " + - getClass().getSimpleName() + ": " + e.getMessage()); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/MappingEvaluatorObjective.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/MappingEvaluatorObjective.java deleted file mode 100644 index b76d9f5c6bb7b9684f6c3ba38988071b4064d48c..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/MappingEvaluatorObjective.java +++ /dev/null @@ -1,114 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2017 fortiss GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator.objective; - -import java.math.BigInteger; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.MappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.evaluator.MappingEvaluator; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.dsl_v2.model.arithmetic.IArithmeticExpression; -import org.fortiss.af3.exploration.dsl_v2.model.function.Maximize; -import org.fortiss.af3.exploration.dsl_v2.model.function.Minimize; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.opt4j.core.DoubleValue; -import org.opt4j.core.IntegerValue; -import org.opt4j.core.Value; -import org.opt4j.core.problem.Evaluator; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: BF9321A9981F0C0E06DB57288C32803E - */ -public class MappingEvaluatorObjective extends MappingEvaluator { - - /** Prototype Constructor. */ - public MappingEvaluatorObjective() { - } - - /** - * Constructor. - * - * @param systemModelAdapter - * abstracts the input models. - * @param explorationTarget - * Target for which the {@link Evaluator} is constructed. - * @throws Exception - * if the inputs don't satisfy the {@link Evaluator}'s requirements. - */ - public MappingEvaluatorObjective(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationTarget<Double> explorationTarget) throws Exception { - super(systemModelAdapter, explorationTarget); - } - - /** {@inheritDoc} */ - @Override - public Value<?> evaluateGoal(MappingEncoding phenotype, - FlatPhenotypeMap<Phenotype> phenotypeTypeMap, - ClassToInstanceMap<EObject> transformedModels) throws Exception { - mapping = phenotype; - - // For ExplorationObjectives the expression begins either with a Minimize or Maximize - // operation. - // FIXME: bad dsl design... - IArithmeticExpression minMaxTerm = null; - if(expression instanceof Minimize) { - minMaxTerm = ((Minimize)expression).getArgs(); - } else if(expression instanceof Maximize) { - minMaxTerm = ((Maximize)expression).getArgs(); - } - assert (minMaxTerm != null); - - Number retVal = minMaxTerm.accept(this, Number.class); - - return retVal instanceof BigInteger ? new IntegerValue(retVal.intValue()) - : new DoubleValue(retVal.doubleValue()); - } - - /** {@inheritDoc} */ - @Override - public Object visit(Maximize max) throws Exception { - // Max/Min operators are handled in the EvaluationWrapper (pre-processing). - return null; - } - - /** {@inheritDoc} */ - @Override - public Object visit(Minimize min) throws Exception { - // Max/Min operators are handled in the EvaluationWrapper (pre-processing). - return null; - } - - /** {@inheritDoc} */ - @Override - public IExplorationTargetEvaluator<MappingEncoding, Double, ExplorationTarget<Double>> - createEvaluator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationTarget<Double> explorationTarget) throws InstantiationException, - Exception { - return new MappingEvaluatorObjective(systemModelAdapter, explorationTarget); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/ReliabilityEvaluatorBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/ReliabilityEvaluatorBase.java deleted file mode 100644 index 5029ad14e481a78de84bc3fca8012e478822cae4..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/evaluator/objective/ReliabilityEvaluatorBase.java +++ /dev/null @@ -1,388 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ReliabilityEvaluatorBase.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.evaluator.objective; - -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.apfloat.Apfloat; -import org.apfloat.FixedPrecisionApfloatHelper; -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -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.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule; -import org.fortiss.af3.exploration.alg.dse.evaluator.ExplorationTargetEvaluatorBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -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.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.DefaultTaskGraph; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; -import org.fortiss.af3.exploration.alg.dse.sysmodel.faultmodel.FaultDetector; -import org.fortiss.af3.exploration.moea.model.predefined.FailureMinObjective; -import org.fortiss.af3.exploration.moea.model.predefined.FailureType; -import org.opt4j.core.DoubleValue; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * The reliability analysis computes the system-level reliability (in terms of failure probability) - * based on a given component-level reliability. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: 9B6CDC5CC477E81EBD719AF5C465B206 - */ -public abstract class ReliabilityEvaluatorBase<S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - extends ExplorationTargetEvaluatorBase<StrictTTSchedule<S, T>, Double, FailureMinObjective> { - - /** Precision of floating point values */ - protected final static int FP_PRECISION = 50; - - /** Component reliability */ - private Map<IDeployableComponentAdapter<?>, Map<IExecutionUnitAdapter<?>, Apfloat>> componentReliability = - new HashMap<IDeployableComponentAdapter<?>, Map<IExecutionUnitAdapter<?>, Apfloat>>(); - - /** Helper required to perform {@link org.apfloat.Apfloat}-based calculations. */ - private FixedPrecisionApfloatHelper apfloatHelper = new FixedPrecisionApfloatHelper( - FP_PRECISION); - - /** - * References the "target" {@link Component} in the original input model. This is the - * {@link Component} for which the failures shall be minimized. - */ - IDeployableComponentAdapter<?> targetComponent; - - /** - * Constructor. - * - * @throws Exception - * if the {@link IDeployableComponentAdapter} specifying the component to minimize - * the failure rate for is missing. - */ - public ReliabilityEvaluatorBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - FailureMinObjective target) throws Exception { - super(systemModelAdapter, target); - - targetComponent = - systemModelAdapter.getDeployableComponentOf(explorationTarget.getTargetComponent()); - if(targetComponent == null) { - throw new Exception("The Component for which to minimize the failure rate is not" + - " correctly specified. It is either not defined, or it is not part of the" + - " set of deployable Components. The error is caused by " + explorationTarget.getName() + - "(id: " + explorationTarget.getId() + ")."); - } - - // TODO: Check for different implementation of this single initialization for different - // reliability goals. In particular, it must be checked if the current implementation with a - // dedicated ReliabilityEvaluatorBase instance per ReliabilityObjective has the same - // functionality and performance as the original implementation. - // - // If needed, a cache could be implemented. See also similar comment in - // FaultDetectionVotingReliabilityEvaluator.evaluateInternal(). - - // do initialization - System.out.println("initialize reliability analyzer."); - componentReliability.clear(); - // set up the replication bounds - - // extract the detector annotations - for(IDeployableComponentAdapter<?> deployableComponent : systemModelAdapter - .getDeployableComponents()) { - TaskGraph tg = systemModelAdapter.getTaskGraph(deployableComponent); - // TODO: Finalize decoupling of system model - // IRequestAdapter comp = (IRequestAdapter)deployableComponent; - - // TODO: re-add the consideration of fault detector annotations here after the - // annotations (or specifications) are defined - // This block adds a predefined fault detector that has has a specified delay - // for(IModelElementSpecification spec : comp.getSpecifications()) { - // if(spec instanceof FaultDetectorAnnotation) { - // // extract the fault detector annotation - // FaultDetectorAnnotation annotation = (FaultDetectorAnnotation)spec; - // FaultDetector fd = - // new FaultDetector(annotation.getOverhead(), annotation.getCoverage(), - // annotation.getPath()); - // tg.addFaultDetector(deployableComponent, fd); - // } - // } - // add the default fault detector with 0 overhead (native execution) - tg.addFaultDetector(deployableComponent, new FaultDetector(0, 0)); - } - - // we use the classic poisson model and compute the constant failure rate of each software - // task - Set<IExecutionUnitAdapter<?>> targetsToBeRemoved = new HashSet<IExecutionUnitAdapter<?>>(); - - for(IDeployableComponentAdapter<?> deployableComponent : systemModelAdapter - .getRealizableDeployableComponents()) { - - // compute the component failure rates - Map<IExecutionUnitAdapter<?>, Apfloat> taskmap = - componentReliability.get(deployableComponent); - if(taskmap == null) { - taskmap = new HashMap<IExecutionUnitAdapter<?>, Apfloat>(); - componentReliability.put(deployableComponent, taskmap); - } - // for each core that may execute the task, compute the reliability - for(IExecutionUnitAdapter<?> deploymentTarget : systemModelAdapter - .getDeploymentTargets()) { - // if(deploymentTarget instanceof IExecutionUnitAdapter) { - // Component core = (Component)deploymentTarget; - // get the failure rate of this component - double coreFailureRate = -1; - - // TODO: re-add the consideration of fault detector annotations here after the - // annotations (or specifications) are defined. - // For now the failure rate of deployment targets is modeled with a fixed value - coreFailureRate = deploymentTarget.getFailureRate(); - - // coreFailureRate = 0.001; - - if(coreFailureRate < 0) { - // this core is not supported, do not map to this core - // to do this, eliminate this core from the list of possible - // mappings in explorer object - targetsToBeRemoved.add(deploymentTarget); - continue; - } - - storeComponentFailureRate(taskmap, deployableComponent, deploymentTarget, - coreFailureRate); - // } else { - // TODO: Finalize decoupling of system model - // // the resource is not a component but an allocation of a resource - // // we look into its parents to look for the reliability annotation - // TODO: re-add the consideration of fault detector annotations here after the - // annotations (or specifications) are defined. - // The iteration over Eobject's containers can likely be avoided. - // EObject obj = (EObject)deploymentTarget; - // ReliabilityAnnotation annotation = null; - // while(obj != null) { - // if(obj instanceof AcrossComponent) { - // for(IModelElementSpecification spec : ((AcrossComponent)obj) - // .getSpecifications()) { - // if(spec instanceof ReliabilityAnnotation) { - // annotation = (ReliabilityAnnotation)spec; - // break; - // } - // } - // // break if we already found the annotation - // if(annotation != null) - // break; - // } - // obj = obj.eContainer(); - // } - // if(annotation != null) { - // double coreFailureRate = toFailureRate(annotation); - // storeComponentFailureRate(taskmap, task, deploymentTarget, coreFailureRate); - // } else { - // // not supported - // targetsToBeRemoved.add(deploymentTarget); - // } - // storeComponentFailureRate(taskmap, deployableComponent, deploymentTarget, - // coreFailureRate); - // } - } - } - - if(!targetsToBeRemoved.isEmpty()) { - System.out - .println("WARNING: ignoring the following mapping locations due to lack of reliability annotation:"); - for(IExecutionUnitAdapter<?> deploymentTarget : targetsToBeRemoved) { - systemModelAdapter.getDeploymentTargets().remove(deploymentTarget); - System.out.print(deploymentTarget.getName() + ","); - } - System.out.print("\n"); - } - } - - // /** - // * Determine the {@link FailureProbabilityType} based on the concrete - // * {@link ReliabilityMaxObjective}, and partially also based on the selected {@link - // FailureMode} - // * . - // */ - // private FailureProbabilityType getFailureProbabilityType(ReliabilityMaxObjective goal) { - // if(goal instanceof ReliabilityObjectiveDUFfit) { - // return FailureProbabilityType.ALL; - // } else if(goal instanceof ReliabilityObjectiveSDCfit) { - // return FailureProbabilityType.SDC; - // } - // - // assert (goal instanceof ReliabilityObjectiveFailureInTime); - // if(((ReliabilityObjectiveFailureInTime)goal).getMode() == FailureMode.FAIL_OPERATIONAL) { - // return FailureProbabilityType.ALL; - // } - // assert (((ReliabilityObjectiveFailureInTime)goal).getMode() == FailureMode.FAIL_SAFE); - // return FailureProbabilityType.SDC; - // } - - /** {@inheritDoc} */ - @Override - public DoubleValue evaluateGoal(StrictTTSchedule<S, T> schedule, - FlatPhenotypeMap<Phenotype> phenotypeTypeMap, - ClassToInstanceMap<EObject> transformedModels) { - @SuppressWarnings("unchecked") AbstractTaskGraphEncoding<AbstractTaskMappingEncoding, ?> atgEnc = - phenotypeTypeMap.getEncoding(AbstractTaskGraphEncoding.class); - assert (atgEnc != null) : "The required abstract task graph encoding could not be found in the map of phenotypes."; - @SuppressWarnings("unchecked") T itmEnc = - (T)phenotypeTypeMap.getEncoding(InstantiatedTaskMappingEncoding.class); - assert (atgEnc != null) : "The required abstract task graph encoding could not be found in the map of phenotypes."; - // TODO Check if more combinations of the analysis parameters - // ({@link FailureProbabilityType}, {@link ReliabilityMetric} sense. Decide if dedicated - // subclasses of {@link ReliablityObjective}s for these different cases make sense (some of - // them seem to already exist, e.g. {@link ReliabilityObjectiveFailureInTime}, - // {@link ReliabilityObjectiveSDCfit}, and {@link ReliabilityObjectiveDUFfit}), and check if - // it makes sense to further split up the reliability analysis evaluators. - // TODO: It seems that 'comp' is used to identify the task graph for which the analysis is - // performed. - return new DoubleValue(evaluateInternal(schedule, itmEnc, - atgEnc.getTaskGraphOf(targetComponent), explorationTarget.getType())); - // ((AF3SystemModelAdapter)systemModelAdapter).getTaskGraph(optGoal.getComponent()), - // optGoal.getType()); - } - - /** - * Executes the actual reliability analysis. The result is the failure probability in log scale. - * If the failure probability is 0, -100 is returned to avoid log(0). - */ - protected abstract double evaluateInternal(StrictTTSchedule<S, T> schedule, T itmEnc, - DefaultTaskGraph taskGraph, FailureType failureProbabilityType); - - /** - * {@inheritDoc} - * - * @throws Exception - * if the failure rate of physical resources are missing. - */ - @Override - public boolean validateInputs() throws Exception { - // TODO: Proper modularity requires to get rid of the types phys. platform element and - // Executionunit. - for(IResourceAdapter<?> resource : systemModelAdapter.getAvailableResources()) { - if((!resource.isVirtual() || resource instanceof IExecutionUnitAdapter) && - resource.getFailureRate() == null) { - throw new Exception("The failure rate of the platform resource " + - resource.getName() + " or its referenced physical entity is not defined." + - " It is required for the Reliability analysis."); - } - } - - return true; - } - - // private double toLogScale(double value) { - // if(value <= 0) { - // return -100; - // } - // - // return java.lang.Math.log10(value); - // } - - /** Stores the failure rate of a component to a task map. */ - private void storeComponentFailureRate(Map<IExecutionUnitAdapter<?>, Apfloat> taskmap, - IDeployableComponentAdapter<?> deployableComponent, - IExecutionUnitAdapter<?> deploymentTarget, double coreFailureRate) { - // get the execution time from annotation - // TODO: heterogeneous cores - // TODO: Scaling of time unit - double executionTime = deployableComponent.getWcet(deploymentTarget); - // deployableComponent.getComponentWCET(deploymentTarget); - - if(executionTime <= 0) { - System.out.println("WARNING: no delay specification found for component " + - deployableComponent.getName() + "! set to default 1 primary time unit!"); - executionTime = 1; - } - - // compute the reliability according to the exponential model - Apfloat reliability = exponentialReliabilityModel(coreFailureRate, executionTime); - taskmap.put(deploymentTarget, reliability); - Apfloat one = new Apfloat(1, FP_PRECISION); - NumberFormat formatter = new DecimalFormat("0.######E0"); - System.out.println("Task " + deployableComponent.getName() + " on " + - deploymentTarget.getName() + " : " + - formatter.format(one.subtract(reliability).doubleValue())); - } - - /** - * Computes the failure probability of a task w.r.t. the exponential reliability - * model. - * - * @param coreFailureRate - * Execution units failure rate - * - * @param executionTime - * Task's execution time. - */ - private Apfloat exponentialReliabilityModel(double coreFailureRate, double executionTime) { - Apfloat zero = new Apfloat(0, FP_PRECISION); - Apfloat lambda = new Apfloat(coreFailureRate, FP_PRECISION); - Apfloat t = new Apfloat(executionTime, FP_PRECISION); - - Apfloat retval = apfloatHelper.exp(zero.subtract(lambda.multiply(t))); - - return retval; - } - - /** Returns the failure rate for a component. */ - protected Apfloat getComponentFailureRate(IDeployableComponentAdapter<?> deployableComponent, - IExecutionUnitAdapter<?> deploymentTarget) { - if(deployableComponent.getObject() instanceof EObject) { - deployableComponent = - systemModelAdapter - .getRealizeableDeployableComponentOf((EObject)deployableComponent - .getObject()); - if(componentReliability.get(deployableComponent) != null && - componentReliability.get(deployableComponent).get(deploymentTarget) != null) { - Apfloat one = new Apfloat(1, FP_PRECISION); - return one.subtract(componentReliability.get(deployableComponent).get( - deploymentTarget)); - } - } - return null; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredInputTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(StrictTTSchedule.class); - return inputTypes; - } - // - // private Apfloat getComponentReliability(IDeployableComponentAdapter deployableComponent, - // IExecutionUnitAdapter deploymentTarget) { - // if(componentReliability.get(deployableComponent) != null) { - // return componentReliability.get(deployableComponent).get(deploymentTarget); - // } - // return null; - // } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/DeprecatedModelGeneratorBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/DeprecatedModelGeneratorBase.java deleted file mode 100644 index 34f167756e0f43720a4f4a1b5616d31664f5e52b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/DeprecatedModelGeneratorBase.java +++ /dev/null @@ -1,70 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DeprecatedModelGeneratorBase.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation; - -import java.util.Map; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationStrategy; - -import com.google.common.collect.Multimap; - -/** - * Base class for generating AF3 models programmatically. - * <p> - * <b>NOTE:</b> This class will only be present during the transition phase to the new model - * generation/transformation "framework". DO NOT USE ELSEWHERE!!! - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: 33CC9F6CDD91F4FE43213230C881FF6A - */ -public abstract class DeprecatedModelGeneratorBase<T extends EObject> implements - ITransformationStrategy<T> { - - /** - * Associative map which relates elements of a generated model to those of the original input - * model. - */ - protected Map<EObject, EObject> genToOrigAssocMap; - /** - * Associative map which relates elements of an original input model to those of a generated - * model. - */ - protected Multimap<EObject, EObject> origToGenAssocMap; - - /** Constructor. */ - protected DeprecatedModelGeneratorBase(Map<EObject, EObject> genToOrigAssocMap, - Multimap<EObject, EObject> origToGenAssocMap) { - this.genToOrigAssocMap = genToOrigAssocMap; - this.origToGenAssocMap = origToGenAssocMap; - } - - // /** {@inheritDoc} */ - // @Override - // public Map<EObject, EObject> getGenToOrigAssociations() { - // return genToOrigAssocMap; - // } - // - // /** {@inheritDoc} */ - // @Override - // public Multimap<EObject, EObject> getOrigToGenAssociations() { - // return origToGenAssocMap; - // } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/EMFModelConcurrencyHandler.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/EMFModelConcurrencyHandler.java deleted file mode 100644 index c93a7ecbf920c5019588425ad7f1b2bb76f7192d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/EMFModelConcurrencyHandler.java +++ /dev/null @@ -1,158 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: EMFModelConcurrencyHandler.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation; - -import static org.fortiss.tooling.kernel.utils.EcoreUtils.disableNotificationsOf; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.enableNotificationsOf; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.fortiss.tooling.base.model.element.IModelElement; -import org.fortiss.tooling.base.model.element.IModelElementReference; - -/** - * Handles operations on EMF models that are problematic when used from different threads. In order - * to provide the required synchronization before the model is accessed, the - * {@link EMFModelConcurrencyHandler} is implemented as a Singleton. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: F2C64AE29624AA8355ACFCBF095CA1F9 - */ -public class EMFModelConcurrencyHandler { - - /** Holds the instance of the model handler. */ - private volatile static EMFModelConcurrencyHandler INSTANCE; - - /** - * Bookkeeping of objects (value) which have requested to suppress notifications of a model - * element (key, EObject). - */ - private Set<EObject> suppressedNotificationModelEditing; - - /** Constructor. */ - private EMFModelConcurrencyHandler() { - // Prevent direct instantiation. - suppressedNotificationModelEditing = new HashSet<>(); - } - - /** The instance (singleton) of the EvaluatorWrapper factory. */ - public static synchronized EMFModelConcurrencyHandler getInstance() { - if(INSTANCE == null) { - INSTANCE = new EMFModelConcurrencyHandler(); - } - return INSTANCE; - } - - /** - * Helper to reset reference of a temporary object (that is not hooked to the {@link Resource} - * without triggering a model modification. - */ - public synchronized void resetReference(IModelElementReference ref) { - if(ref == null) { - return; - } - - IModelElement refElement = ref.getReference(); - // ITopLevelElement modelContext = - // IPersistencyService.getInstance().getTopLevelElementFor(refElement); - // if(modelContext == null) { - disableNotificationsOf(refElement); - ref.setReference(null); - enableNotificationsOf(refElement); - // } else { - // List<IModelElementReference> refByList = refElement.getReferencedBy(); - // modelContext.runAsNonDirtyingCommand(() -> refByList.remove(ref)); - // // modelContext.removeLastCommandFromStack(); - // } - } - - /** - * Helper to set a {@link IModelElementReference} from a temporary and programmatically - * generated model without triggering a model modification. - * If this method is not used, a notification is triggered from the referenced model because a - * back reference is set (Bi-Reference) in the referenced model. - */ - public synchronized void setReference(IModelElementReference ref, - IModelElement referencedElement) { - if(ref == null) { - return; - } - // - // ITopLevelElement modelContext = - // IPersistencyService.getInstance().getTopLevelElementFor(referencedElement); - // if(modelContext == null) { - disableNotificationsOf(referencedElement); - ref.setReference(referencedElement); - enableNotificationsOf(referencedElement); - // } else { - // modelContext.runAsNonDirtyingCommand(() -> ref.setReference(referencedElement)); - // // modelContext.removeLastCommandFromStack(); - // } - } - - /** - * Determines whether there are still objects that request the given model not to emit - * notifications. - */ - public synchronized boolean isModelEdited(EObject model) { - return suppressedNotificationModelEditing.contains(model); - } - - /** - * Deletes the suppress notification request of the given {@code editingObj} and enables the - * notifications of the given model if there are no more requesters to suppress notifications. - */ - public synchronized void tryEnableNotificationsSyncOf(EObject model) { - getInstance().removeSuppressedNotificationModelEditing(model); - // if(!getInstance().isModelEdited(model)) { - enableNotificationsOf(model); - // } - } - - /** - * Adds a suppress notification request of the given {@code editingObj} and disables the - * notifications of the given model if needed. - */ - public synchronized void tryDisableNotificationsSyncOf(EObject model) { - getInstance().addSuppressedNotificationModelEditing(model); - // if(!getInstance().isModelEdited(model)) { - disableNotificationsOf(model); - // } - } - - /** - * Adds the given {@code editingObj} as a requester to suppress notifications from the given - * {@code model}. - */ - private synchronized void addSuppressedNotificationModelEditing(EObject model) { - suppressedNotificationModelEditing.add(model); - } - - /** - * Removes the given {@code editingObj} as a requester to suppress notifications from the given - * {@code model}. - */ - private synchronized void removeSuppressedNotificationModelEditing(EObject model) { - suppressedNotificationModelEditing.remove(model); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/ITransformationModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/ITransformationModule.java deleted file mode 100644 index 9e5eb75bf8a03ef7cc50ba44e326eedaac38c2bc..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/ITransformationModule.java +++ /dev/null @@ -1,302 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ITransformationModule.java 3642 2016-10-05 07:34:14Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.graph.IDependencyModule; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.guava.TypedBiMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationModule; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; -import org.fortiss.tooling.kernel.service.base.IEObjectAware; - -import com.google.common.collect.Multimap; - -/** - * Interface for any transformation of {@link IExplorationEncoding}s of the DSE to EMF models. - * Each implementing class must declare its output model type via {@link #getOutputType()} and - * its required input types via {@link #getRequiredTypes()}. {@link ITransformationModule}s are - * composable such that each may have submodules that can be queried via {@link #getSubModules()}. - * The submodules must be registered via {@link #registerSubModule(ITransformationModule)}. Further, - * each {@link ITransformationModule} may declare itself to be optional such that it may be ignored - * when being launched as a submodule if the required inputs are not available. - * - * The method - * {@link #transform(TransformationState, TransformationContext, SubClassToInstanceMap, ExplorationEncodingMap, SubClassToInstanceMap, EObject)} - * actually triggers the - * transformation using the - * module itself and its submodules. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3642 $ - * @ConQAT.Rating RED Hash: BE88385EA770F809B879C1C2C7DFDCEA - */ -public interface ITransformationModule<T extends EObject> extends IEObjectAware<T>, - IExplorationModule, IDependencyModule<T, T> { - - /** Defines the state of a Generation/Transformation module for single element types. */ - enum TransformationState { - /** Initial state. */ - INITIALIZING("initializing", false, false, false, false, false, true), - /** Initialization done, e.g., copying the base model. */ - INITIALIZED("initialized", true, false, false, false, false, false), - /** Module currently replicates elements. */ - REPLICATING("replicating", true, false, false, false, false, true), - /** Module replicated the defined element types. */ - REPLICATED("replicated", true, true, false, false, false, false), - /** Module currently instantiates elements. */ - INSTANCIATING("instantiating", true, true, false, false, false, true), - /** Module instantiated the defined element types. */ - INSTANTIATED("instantiated", true, true, true, false, false, false), - /** Module currently inserts elements. */ - INSERTING("inserting", true, true, true, false, false, true), - /** Required elements are inserted. */ - INSERTED("inserted", true, true, true, true, false, false), - /** Final steps to complete the model. */ - FINALIZING("finalizing", true, true, true, true, false, true), - /** Model transformation has finished. */ - FINALIZED("finalized", true, true, true, true, true, false); - - /** State name. */ - private final String name; - - /** Initialization status. */ - private final boolean initialized; - - /** Instantiation status. */ - private final boolean instantiated; - - /** Replication status. */ - private final boolean replicated; - - /** Insertion status. */ - private final boolean inserted; - - /** Finalization status. */ - private final boolean finalized; - - /** Whether the Module is currently working. */ - private final boolean processing; - - /** Constructor. */ - TransformationState(String name, boolean initialized, boolean replicated, - boolean instantiated, boolean inserted, boolean finalized, boolean processing) { - this.name = name; - this.initialized = initialized; - this.replicated = replicated; - this.instantiated = instantiated; - this.inserted = inserted; - this.finalized = finalized; - this.processing = processing; - } - - /** Returns whether the module finished the initialization step. */ - public boolean isInitialized() { - return initialized; - } - - /** Returns whether the module finished the instantiation step. */ - public boolean isInstantiated() { - return instantiated; - } - - /** Returns whether the module finished the replication step. */ - public boolean isReplicated() { - return replicated; - } - - /** Returns whether the module finished the insertion step. */ - public boolean isInserted() { - return inserted; - } - - /** Returns whether the module transformation is finished. */ - public boolean isFinalized() { - return finalized; - } - - /** Returns whether the module is currently performing some operation. */ - public boolean isProcessing() { - return processing; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return name; - } - } - - /** - * Returns the collection of sub-{@link ITransformationModule}s that are registered with - * {@code this} {@link ITransformationModule}. - */ - List<ITransformationModule<?>> getSubModules(); - - /** - * Registers the given {@code subModule} with {@code this} {@link ITransformationModule}. - */ - void registerSubModule(ITransformationModule<?> subModule); - - /** - * Creates another instance of {@code this} {@link ITransformationModule} which will actually - * perform the transformation. - */ - ITransformationModule<T> createModuleInstance() throws TransformationModuleException; - - /** - * Marks the given {@link ITransformationModule} type to not be executed. - * - * @param subModule - * The module type to be blacklisted. - */ - void addBlacklistedModule(Class<? extends ITransformationModule<?>> subModule); - - /** - * Clears the collection of blacklisted modules from {@code this} {@link ITransformationModule}. - */ - void resetBlacklistedModules(); - - /** Predicates whether the execution of is required or optional. */ - boolean isOptional(); - - /** - * Loads the given association maps into {@code this} {@link ITransformationModule}. Typically, - * these maps are passed from the parent {@link ITransformationModule}. - * - * @param encEntryToGenElemAssocs - * Associates entries of {@link IExplorationEncoding}s with model elements. - * @param origToGenElemAssocs - * Associates original input model elements with generated ones. - * @param genToOrigElemAssocs - * Associates generated model elements with those provided by the input models. - */ - void - loadElementAssociations(TypedBiMap<Object, EObject> encEntryToGenElemAssocs, - Multimap<EObject, EObject> origToGenElemAssocs, - Map<EObject, EObject> genToOrigElemAssocs, - Multimap<EObject, EObject> genToGenElemAssocs); - - /** - * Updates the given associative maps that allow to trace objects between the original and the - * transformed model, and between the entries of and exploration encoding and the elements of - * the transformed model. For the update, the associations generated by {@code this} - * {@link ITransformationModule} are utilized. - * - * @param subModule - * contains the updated association maps. - */ - void applyAssociationUpdates(ITransformationModule<?> subModule); - - /** - * Returns the model element of a generated/transformed model which is associated with the given - * entry of an encoding of the solution found by the DSE. - * - * @param encEntry - * The entry of an {@link IExplorationEncoding} to search for. - * @return The associated {@link EObject} of the generated/transformed model. - */ - EObject getModelElementByEncEntry(Object encEntry, Class<EObject> type); - - /** - * Returns the model element from the original model which corresponds to the given model - * element of the generated/transformed model. - * - * @param genElem - * {@link EObject} contained in the generated/transformed model. - * @return The corresponding {@link EObject} from the original (input) architecture. - */ - EObject getOriginalByGenElement(EObject genElem); - - /** - * Removes the given element and its children from its containing model and updates the - * association maps accordingly to reflect this change. - * - * @param element - * The model element to be removed. - */ - void removeGenModelElement(EObject element); - - /** - * Returns the transformation stage at which {@code this} {@link ITransformationModule} shall be - * launched. - */ - TransformationState getActivationStage(); - - /** - * Returns the collection of parent {@link ITransformationModule} which may launch {@code this} - * {@link ITransformationModule} as one of its sub modules. - */ - Collection<Class<? extends ITransformationModule<?>>> getParentModules(); - - /** - * Generates a model of type {@code T} from the input {@code baseModels} and - * {@code exploraionEncodings}. - * - * @param baseModels - * Input EMF models. - * @param explorationEncodings - * {@link IExplorationEncoding}s resulting from the DSE. - * @param outputModel - * The output EMF model which includes the transformation result. It is passed to - * each submodule. May be {@code null} if a new model is created in the - * transformation method. - * @return Transformed model of type {@code T}. - * @throws TransformationModuleException - * If the transformation fails at {@code this} {@link ITransformationModule}. - */ - <N extends EObject, S extends EObject> T transform(TransformationState state, - TransformationContext context, SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException; - - /** - * Returns the associations between elements comprising an exploration encoding and their - * corresponding model elements. - */ - TypedBiMap<Object, EObject> getEncEntryModelElemAssoc(); - - /** - * Returns the associative map which relates elements of a generated model to those of the - * original input - * model. - */ - Map<EObject, EObject> getGenToOrigAssocMap(); - - /** - * Returns the associative map which relates the elements of the original input model to all - * elements which from instances of the particular elements. - */ - Multimap<EObject, EObject> getOrigToGenAssocMap(); - - /** - * Returns the associative map which relates the input elements of the current stage to the - * output elements of the current stage. Here, the current stage does not differentiate between - * the processing and the finish stage. - */ - Multimap<EObject, EObject> getGenToGenAssocMap(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/ITransformationStrategy.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/ITransformationStrategy.java deleted file mode 100644 index 6f45e09835d765fc3568b599668c7eb5fa73ed44..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/ITransformationStrategy.java +++ /dev/null @@ -1,75 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ITransformationStrategy.java 3456 2016-09-05 14:53:35Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.project.model.FileProject; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; - -/** - * Interface that defines common operation to trigger a the generation of a model based on - * implementation specific input models. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3456 $ - * @ConQAT.Rating RED Hash: 9A9B814200D640F8977AE6ACCD315EC0 - */ -public interface ITransformationStrategy<T extends EObject> { - - /** - * Sets the {@code modelContext} that is used by {@link ITransformationStrategy}s if any model - * (transformation result) shall be added to the parent project. - * - * @param modelContext - * context of the parent's project. - */ - void setModelContext(ITopLevelElement modelContext); - - /** - * Sets the name of the resulting model. It is propagated to any sub - * {@link ITransformationStrategy} such that associated models can be identified by their names - * if implemented. - * - * @param transformedModelName - * Name to be set for the top-most requested model. - */ - void setModelName(String transformedModelName); - - /** - * Sets a flag to enable the {@link ITransformationStrategy} to detect whether it has been - * launched as the "mother" strategy or a sub-strategy. - */ - public void setLaunchedAsSubModule(boolean isSubModule); - - /** - * Adds the model resulting from the transformation to the given project that has the given - * context. - * - * @param fp - * The {@link FileProject} to which the transformed model shall be added. - * @param modelContext - * The model context of the given project. - * @throws TransformationModuleException - * if the adding operation fails (the enclosed exception contains the details). - */ - // TODO: remove the model context parameter, or the setModelContext method above. - void addModelToProject(FileProject fp, ITopLevelElement modelContext) - throws TransformationModuleException; -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationModuleBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationModuleBase.java deleted file mode 100644 index cf029b30d42f615e7504efd204c8f4340eab3151..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationModuleBase.java +++ /dev/null @@ -1,65 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.base; - -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; - -import java.util.Collection; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.element.IElementTransformationModule; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; - -/** - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 6E36CF4C1EE8EB5B1B0A2586C8077806 - */ -public abstract class ElementTransformationModuleBase<T extends EObject, O extends EObject> extends - TransformationModuleBase<T> implements IElementTransformationModule<T, O> { - - /** {@inheritDoc} */ - @Override - public <N extends EObject, S extends EObject> T transform(TransformationState state, - TransformationContext context, SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException { - if(outputModel == null) { - throw new TransformationModuleException(this, - "No output model has been passed. It is required to store the transformation results."); - } - - // TODO: find a way to directly use the generic here. - @SuppressWarnings("unchecked") O tempCastedOutputModel = (O)outputModel; - Collection<T> elements = getChildrenWithType(outputModel, getElementClass()); - for(T currElement : elements) { - transformElement(currElement, baseModels, explorationEncodings, transformedModels, - tempCastedOutputModel); - } - - @SuppressWarnings("unchecked") T castedOutputModel = (T)outputModel; - return castedOutputModel; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationStrategyBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationStrategyBase.java deleted file mode 100644 index e0782be0101730e26c0f1f81956be5d3cdd41b8d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/ElementTransformationStrategyBase.java +++ /dev/null @@ -1,226 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.base; - -import static org.fortiss.tooling.common.util.LambdaUtils.filterList; -import static org.fortiss.tooling.common.util.LambdaUtils.filterSet; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf; - -import java.util.Collection; -import java.util.Comparator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationStrategy; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.element.IElementTransformationModule; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; -import org.fortiss.af3.project.model.FileProject; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; - -/** - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: F5D71CF3F8BD16B74A83B825A8736373 - */ -public abstract class ElementTransformationStrategyBase<T extends EObject, O extends EObject> - extends TransformationStrategyBase<T> { - - /** Contains the order to execute the {@link IElementTransformationModule}s. */ - protected List<IElementTransformationModule<EObject, O>> execOrder = new LinkedList<>(); - - /** {@inheritDoc} */ - @Override - public <N extends EObject, S extends EObject> T transform(TransformationState state, - TransformationContext context, SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException { - // TODO: Consider using generics to define the allowed sub-module types. - - // TODO: Throw an exception if the output model is not the same type as the input model. - @SuppressWarnings("unchecked") T castedTransformedModel = (T)outputModel; - this.transformedModel = castedTransformedModel; - - if(execOrder == null || execOrder.isEmpty()) { - calculateModuleExecutionOrder(); - } - - for(IElementTransformationModule<? extends EObject, O> subModule : execOrder) { - if(subModule.getActivationStage() == state || - subModule instanceof ElementTransformationStrategyBase) { - if(subModule.isOptional() && - !canExecuteModule(baseModels, transformedModels, explorationEncodings, - subModule)) { - break; - } - - if(subModule instanceof ITransformationStrategy) { - ((ITransformationStrategy<?>)subModule).setModelContext(modelContext); - ((ITransformationStrategy<?>)subModule).setLaunchedAsSubModule(true); - } - - // TODO: directly specify the output. - @SuppressWarnings("unchecked") O tempCastedOutputModel = - (O)transformedModels.get(subModule.getElementContainerType()); - - subModule.loadElementAssociations(encEntryModelElemAssoc, origToGenAssocMap, - genToOrigAssocMap, genToGenAssocMap); - T transformedModel = - transformElements(subModule, baseModels, explorationEncodings, - transformedModels, tempCastedOutputModel); - if(transformedModel == null) { - throw new TransformationModuleException(subModule, - "The submodule did not return the transformed model. It is required by the framework."); - } - - // Impl classes in EMF _always_ have one interface that specifies the methods etc. - @SuppressWarnings("unchecked") Class<N> transformedModelType = - (Class<N>)transformedModel.getClass().getInterfaces()[0]; - @SuppressWarnings("unchecked") N tempCastedTransformedModel = (N)transformedModel; - transformedModels.put(transformedModelType, tempCastedTransformedModel); - if(getOutputType().isAssignableFrom(transformedModel.getClass())) { - this.transformedModel = transformedModel; - } - applyAssociationUpdates(subModule); - } - } - - executeSubModules( - filterSet(getSubModules(), e -> !(e instanceof IElementTransformationModule<?, ?>)), - context, baseModels, explorationEncodings, transformedModels, state); - - @SuppressWarnings("unchecked") Class<N> tempTransformedModelType = - (Class<N>)transformedModel.getClass().getInterfaces()[0]; - @SuppressWarnings("unchecked") N tempCastedTransformedModel = (N)transformedModel; - transformedModels.put(tempTransformedModelType, tempCastedTransformedModel); - if(getOutputType().isAssignableFrom(transformedModel.getClass())) { - @SuppressWarnings("unchecked") T castedOutputModel = (T)outputModel; - this.transformedModel = castedOutputModel; - } - - // Suppressed warnings: Generics are used here to ensure compatibility between the type - // (class) and the instance. - @SuppressWarnings("unchecked") Class<? extends N> transformedModelType = - (Class<N>)getOutputType(); - @SuppressWarnings("unchecked") N castedOutputModel = (N)transformedModel; - transformedModels.put(transformedModelType, castedOutputModel); - @SuppressWarnings("unchecked") T castedReturnOutputModel = (T)outputModel; - return castedReturnOutputModel; - } - - /** - * Calculates the correct order of execution of element-wise transformation sub-modules. - * It does so by building a graph of the require inputs and output types of the element-wise - * transformation sub modules. - */ - @SuppressWarnings("unchecked") - protected void calculateModuleExecutionOrder() { - execOrder - .addAll((Collection<? extends IElementTransformationModule<EObject, O>>)filterList( - getSubModules(), e -> e instanceof IElementTransformationModule)); - execOrder.sort(new ModuleExecOrderComp()); - } - - /** - * Comparator that sorts a set of {@link IElementTransformationModule}s first by the order of - * the - * {@link org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState} - * which activates them, and then by the order of their required - * inputs. - * This implies that a {@link IElementTransformationModule} may define that all other modules of - * the same - * {@link org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState} - * which output elements of a given type to be executed before the current one. - */ - protected class ModuleExecOrderComp implements - Comparator<IElementTransformationModule<EObject, O>> { - /** {@inheritDoc} */ - @Override - public int compare(IElementTransformationModule<EObject, O> arg0, - IElementTransformationModule<EObject, O> arg1) { - int result = arg0.getActivationStage().compareTo(arg1.getActivationStage()); - - if(result == 0) { - Collection<Class<?>> inputs0 = arg0.getRequiredTypes(); - Collection<Class<?>> inputs1 = arg1.getRequiredTypes(); - if(inputs1.contains(arg0.getOutputType())) { - return -1; - } else if(inputs0.contains(arg1.getOutputType())) { - return 1; - } - } - - return result; - } - } - - /** - * Triggers the registered {@link IElementTransformationModule}s for each {@link EObject} of the - * module's demanded type found in the input model. - * - * @param subModule - * {@link IElementTransformationModule} implementing the element-wise transformation. - * @param baseModels - * Original input models containing information for the transformation. - * @param explorationEncodings - * Original (DSE) encodings containing information for the transformation. - * @param transformedModels - * Optional map of transformed/generated models in the transformation process. - * @param outputModel - * The effective transformation model to operate on. - * @return The transformed {@code outputModel}. - * @throws TransformationModuleException - * If any of the submodules fails. - */ - protected <N extends EObject, S extends EObject> T transformElements( - IElementTransformationModule<? extends EObject, O> subModule, - Map<Class<? extends S>, S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - Map<Class<? extends N>, N> transformedModels, O outputModel) - throws TransformationModuleException { - Collection<? extends EObject> typedElements = - getChildrenWithType(outputModel, subModule.getElementClass()); - for(EObject element : typedElements) { - subModule.transformElement(element, baseModels, explorationEncodings, - transformedModels, outputModel); - } - - @SuppressWarnings("unchecked") T castedOutputModel = (T)outputModel; - return castedOutputModel; - } - - /** {@inheritDoc} */ - @Override - public void addModelToProject(FileProject fp, ITopLevelElement modelContext) - throws TransformationModuleException { - this.modelContext = modelContext; - for(ITransformationStrategy<?> module : pickInstanceOf(ITransformationStrategy.class, - subModules)) { - module.addModelToProject(fp, modelContext); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/TransformationModuleBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/TransformationModuleBase.java deleted file mode 100644 index f70d1e531dc830b4b32b668fa700962f2e643efb..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/TransformationModuleBase.java +++ /dev/null @@ -1,236 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: TransformationModuleBase.java 3642 2016-10-05 07:34:14Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.base; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.HashTypedBiMap; -import org.fortiss.af3.exploration.alg.guava.TypedBiMap; -import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem; -import org.fortiss.tooling.kernel.introspection.IIntrospectionItem; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -/** - * Base class for {@link ITransformationModule}s that maintains a collection of registered - * submodules. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3642 $ - * @ConQAT.Rating RED Hash: 367E0E3C8DEAEFA2F3265267DCFA6335 - */ -public abstract class TransformationModuleBase<T extends EObject> implements - ITransformationModule<T> { - - /** - * Holds associations between elements comprising an exploration encoding and their - * corresponding model elements. - */ - protected TypedBiMap<Object, EObject> encEntryModelElemAssoc = HashTypedBiMap.create(); - - /** - * Associative map which relates elements of a generated model to those of the original input - * model. - */ - protected Map<EObject, EObject> genToOrigAssocMap = new HashMap<>(); - - /** - * Associative map which relates the elements of the original input model to all elements which - * from instances of the particular elements. - */ - protected Multimap<EObject, EObject> origToGenAssocMap = HashMultimap.create(); - - /** - * Associative map which relates the input elements of the current stage to the output elements - * of the current stage. Here, the current stage does not differentiate between the processing - * and the finish stage. - */ - protected Multimap<EObject, EObject> genToGenAssocMap = HashMultimap.create(); - - /** Maintains references to the submodules of {@code this} {@link ITransformationModule}. */ - protected List<ITransformationModule<?>> subModules = new LinkedList<>(); - - /** Set of sub {@link ITransformationModule}s that shall not be executed in one particular run. */ - private Collection<Class<? extends ITransformationModule<?>>> blacklistedModules = - new HashSet<>(); - - /** {@inheritDoc} */ - @Override - public List<ITransformationModule<? extends EObject>> getSubModules() { - return subModules; - } - - /** {@inheritDoc} */ - @Override - public void registerSubModule(ITransformationModule<?> subModule) { - subModules.add(subModule); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public ITransformationModule<T> createModuleInstance() throws TransformationModuleException { - ITransformationModule<T> moduleInstance; - try { - moduleInstance = getClass().newInstance(); - } catch(InstantiationException | IllegalAccessException e) { - throw new TransformationModuleException(this, - "Could not create an instance of this module.", e); - } - - List<ITransformationModule<?>> subModuleInstances = new ArrayList<>(); - for(ITransformationModule<?> subModule : getSubModules()) { - ITransformationModule<?> subModuleInst = subModule.createModuleInstance(); - subModuleInstances.add(subModuleInst); - } - moduleInstance.getSubModules().clear(); - moduleInstance.getSubModules().addAll(subModuleInstances); - - return moduleInstance; - } - - /** {@inheritDoc} */ - @Override - public void - loadElementAssociations(TypedBiMap<Object, EObject> encEntryToGenElemAssocs, - Multimap<EObject, EObject> origToGenElemAssocs, - Map<EObject, EObject> genToOrigElemAssocs, - Multimap<EObject, EObject> genToGenElemAssocs) { - this.encEntryModelElemAssoc = encEntryToGenElemAssocs; - this.genToOrigAssocMap = genToOrigElemAssocs; - this.origToGenAssocMap = origToGenElemAssocs; - this.genToGenAssocMap = genToGenElemAssocs; - } - - /** {@inheritDoc} */ - @Override - public void applyAssociationUpdates(ITransformationModule<?> subModule) { - this.encEntryModelElemAssoc = subModule.getEncEntryModelElemAssoc(); - this.origToGenAssocMap = subModule.getOrigToGenAssocMap(); - this.genToOrigAssocMap = subModule.getGenToOrigAssocMap(); - this.genToGenAssocMap = subModule.getGenToGenAssocMap(); - } - - /** {@inheritDoc} */ - @Override - public EObject getModelElementByEncEntry(Object encEntry, Class<EObject> type) { - return encEntryModelElemAssoc.get(encEntry, type); - } - - /** {@inheritDoc} */ - @Override - public EObject getOriginalByGenElement(EObject genElem) { - return genToOrigAssocMap.get(genElem); - } - - /** {@inheritDoc} */ - @Override - // TODO: rename to removeGenModelElement. - public - void removeGenModelElement(EObject element) { - removeModelElementAssociations(element); - EcoreUtil.delete(element); - } - - /** Removes the given {@code element} from the association maps. */ - private void removeModelElementAssociations(EObject element) { - for(EObject curChildElem : element.eContents()) { - removeModelElementAssociations(curChildElem); - } - EObject origElement = genToOrigAssocMap.get(element); - origToGenAssocMap.remove(origElement, element); - if(origToGenAssocMap.get(origElement) != null && - origToGenAssocMap.get(origElement).isEmpty()) { - // To avoid list with empty associations. - origToGenAssocMap.removeAll(origElement); - } - genToOrigAssocMap.remove(element); - } - - /** {@inheritDoc} */ - @Override - public void addBlacklistedModule(Class<? extends ITransformationModule<?>> subModule) { - blacklistedModules.add(subModule); - } - - /** {@inheritDoc} */ - @Override - public void resetBlacklistedModules() { - blacklistedModules.clear(); - } - - /** {@inheritDoc} */ - @Override - public boolean showInIntrospectionNavigation() { - return true; - } - - /** {@inheritDoc} */ - @Override - public String getIntrospectionLabel() { - return getClass().getSimpleName(); - } - - /** {@inheritDoc} */ - @Override - public Collection<IIntrospectionItem> getIntrospectionItems() { - return null; - } - - /** {@inheritDoc} */ - @Override - public IIntrospectionDetailsItem getDetailsItem() { - return null; - } - - /** {@inheritDoc} */ - @Override - public TypedBiMap<Object, EObject> getEncEntryModelElemAssoc() { - return encEntryModelElemAssoc; - } - - /** {@inheritDoc} */ - @Override - public Map<EObject, EObject> getGenToOrigAssocMap() { - return genToOrigAssocMap; - } - - /** {@inheritDoc} */ - @Override - public Multimap<EObject, EObject> getOrigToGenAssocMap() { - return origToGenAssocMap; - } - - /** {@inheritDoc} */ - @Override - public Multimap<EObject, EObject> getGenToGenAssocMap() { - return genToGenAssocMap; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/TransformationStrategyBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/TransformationStrategyBase.java deleted file mode 100644 index 77ba3179de4117c4e15a72a22fe901fb92c26d51..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/base/TransformationStrategyBase.java +++ /dev/null @@ -1,386 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: TransformationStrategyBase.java 3851 2016-11-07 10:08:11Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.base; - -import static java.util.Collections.sort; -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.pickInstanceOf; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationStrategy; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.element.IElementTransformationModule; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; -import org.fortiss.af3.exploration.alg.service.internal.ExplorationTransformationService; -import org.fortiss.af3.project.model.FileProject; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; -import org.fortiss.tooling.kernel.introspection.IIntrospectionItem; -import org.fortiss.tooling.kernel.model.INamedElement; -import org.fortiss.tooling.kernel.model.IProjectRootElement; -import org.fortiss.tooling.kernel.service.IElementCompositorService; - -/** - * Base class for generating AF3 models programatically. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3851 $ - * @ConQAT.Rating RED Hash: 2D1C7319F7A4462D4505C8907C039B71 - */ -public abstract class TransformationStrategyBase<T extends EObject> extends - TransformationModuleBase<T> implements ITransformationStrategy<T> { - - /** - * Flag that determines whether {@code this} {@link ITransformationStrategy} shall be launched - * in a model context. This is only required for the first {@link ITransformationModule} which - * is executed, not for sub modules. - */ - protected boolean launchedAsSubModule = false; - - /** The original model from which the {@code transformedModel} is generated. */ - protected T transformedModel; - - /** The name of the top-most model to be generated by this transformation process. */ - protected String transformedModelName = ""; - - /** References the original base model (if any). */ - protected T originalModel; - - /** Maintains a reference to the model context in which the transformation is executed. */ - protected ITopLevelElement modelContext; - - /** Caches exceptions that are thrown in the model context. */ - protected TransformationModuleException cachedException; - - /** List of {@link EObject}s that were instantiated in previous generation/transformation steps. */ - protected Collection<EObject> instantiatedElements = new ArrayList<>(); - - /** - * Map that associates the element types with their corresponding element-wise - * {@link ITransformationModule}. - */ - protected Map<Class<? extends EObject>, IElementTransformationModule<?, ?>> generationModuleMap = - new LinkedHashMap<>(); - - /** - * {@inheritDoc} </p> - * This implementation follows the strategy pattern. - * </p> - */ - @Override - public <N extends EObject, S extends EObject> T transform(TransformationState state, - TransformationContext context, SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException { - if(transformedModels == null) { - throw new TransformationModuleException(this, - "The map which will contain all transformed models must be passed."); - } - - transformedModel = - transformInternal(state, context, baseModels, explorationEncodings, - transformedModels); - - if(launchedAsSubModule) { - doSetModelName(); - return transformedModel; - } - - if(cachedException != null) { - TransformationModuleException localException = cachedException; - localException = cachedException; - cachedException = null; - throw localException; - } - - doSetModelName(); - - encEntryModelElemAssoc.clear(); - origToGenAssocMap.clear(); - genToOrigAssocMap.clear(); - - return transformedModel; - } - - /** Sets the name of the transformed model. */ - protected void doSetModelName() { - if(transformedModel instanceof INamedElement) { - boolean notificationsEnabled = transformedModel.eDeliver(); - if(notificationsEnabled) { - transformedModel.eSetDeliver(false); - } - ((INamedElement)transformedModel).setName(transformedModelName); - transformedModel.eSetDeliver(true); - } - } - - /** - * Actual transformation method that launches the registered submodules (i.e., their newly - * created instances) in the order that is given by the - * {@link org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState} - * s. - * - * @param state - * - * @param context - * see - * {@link ExplorationTransformationService#getTransformedModel(TransformationContext, ITopLevelElement, ExplorationEncodingMap, SubClassToInstanceMap, Class, String)} - * . - * @param baseModels - * see - * {@link ITransformationModule#transform(org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState, TransformationContext, SubClassToInstanceMap, ExplorationEncodingMap, SubClassToInstanceMap, EObject)} - * . - * @param explorationEncodings - * see - * {@link ITransformationModule#transform(org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState, TransformationContext, SubClassToInstanceMap, ExplorationEncodingMap, SubClassToInstanceMap, EObject)} - * . - * @param transformedModels - * see - * {@link ITransformationModule#transform(org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState, TransformationContext, SubClassToInstanceMap, ExplorationEncodingMap, SubClassToInstanceMap, EObject)} - * . - * @return The resulting transformed model. - * @throws TransformationModuleException - * if any of the sub modules fails during execution or produces no output. - */ - // TODO update doc "state" - protected <N extends EObject, S extends EObject> T transformInternal(TransformationState state, - TransformationContext context, SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels) throws TransformationModuleException { - @SuppressWarnings("unchecked") T castedTransformedBaseModel = - (T)transformedModels.get(getOutputType()); - this.transformedModel = castedTransformedBaseModel; - - Queue<TransformationState> remainingStates = - new LinkedList<>(Arrays.asList(TransformationState.values())); - - while(!remainingStates.isEmpty()) { - TransformationState currentState = remainingStates.poll(); - - // Clean the intra-generated element associations if we enter a 'processing' stage. - if(currentState.isProcessing()) { - genToGenAssocMap.clear(); - } - - executeSubModules(getSubModules(), context, baseModels, explorationEncodings, - transformedModels, currentState); - } - - // Suppressed warnings: Generics are used here to ensure compatibility between the type - // (class) and the instance. - @SuppressWarnings("unchecked") Class<? extends N> transformedModelType = - (Class<N>)getOutputType(); - @SuppressWarnings("unchecked") N outputModel = (N)transformedModel; - transformedModels.put(transformedModelType, outputModel); - return this.transformedModel; - } - - /** - * Executes the given set of {@link ITransformationModule}s iff the given - * {@link org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState} - * equals the activation state of the sub-module or the sub-module - * is an {@link ElementTransformationStrategyBase}. - * - * @param subModules - * Collection of {@link ITransformationModule}s to (possibly) execute. - * @param context - * Whether or not to export the resulting models into the corresponding project. - * @param baseModels - * Input set of original models. - * @param explorationEncodings - * DSE internal encoding inputs for the transformation. - * @param transformedModels - * Set of models that result from the transformation (output). - * @param currentState - * Current state of the parent {@link ITransformationStrategy}. - * @throws TransformationModuleException - * If any of the submodules fails during execution or in- or outputs are not as - * expected. - */ - protected <N extends EObject, S extends EObject> void executeSubModules( - Collection<ITransformationModule<? extends EObject>> subModules, - TransformationContext context, SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, TransformationState currentState) - throws TransformationModuleException { - - // TODO: consider using the Dependency graph for a) the order in activation stages (needed) - // and b) the sorting by modules vs.strategies. - subModules = new ArrayList<>(subModules); - sort((List<ITransformationModule<? extends EObject>>)subModules, - createModuleStrategyOrder()); - - for(ITransformationModule<? extends EObject> subModule : subModules) { - if(subModule.getActivationStage() == currentState || - (currentState.ordinal() >= subModule.getActivationStage().ordinal() && subModule instanceof ElementTransformationStrategyBase)) { - if(subModule.isOptional() && - !canExecuteModule(baseModels, transformedModels, explorationEncodings, - subModule)) { - continue; - } - - if(subModule instanceof ITransformationStrategy) { - ((ITransformationStrategy<?>)subModule).setModelContext(modelContext); - ((ITransformationStrategy<?>)subModule).setModelName(transformedModelName); - ((ITransformationStrategy<?>)subModule).setLaunchedAsSubModule(true); - } - subModule.loadElementAssociations(encEntryModelElemAssoc, origToGenAssocMap, - genToOrigAssocMap, genToGenAssocMap); - @SuppressWarnings("unchecked") T transformedModel = - (T)subModule.transform(currentState, context, baseModels, - explorationEncodings, transformedModels, this.transformedModel); - if(transformedModel == null) { - throw new TransformationModuleException(subModule, - "The submodule did not return the transformed model. It is required by the framework."); - } - - // Impl classes in EMF _always_ have one interface that specifies the methods - // etc. - @SuppressWarnings("unchecked") Class<N> transformedModelType = - (Class<N>)transformedModel.getClass().getInterfaces()[0]; - @SuppressWarnings("unchecked") N tempCastedTransformedModel = (N)transformedModel; - transformedModels.putInstance(transformedModelType, tempCastedTransformedModel); - if(getOutputType().isAssignableFrom(transformedModel.getClass())) { - this.transformedModel = transformedModel; - } - applyAssociationUpdates(subModule); - } - } - } - - /** - * Determines whether the given {@link ITransformationModule} can be executed with the available - * input set. - */ - protected <N extends EObject, S extends EObject> boolean canExecuteModule( - Map<Class<? extends S>, S> baseModels, Map<Class<? extends N>, N> transformedModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - ITransformationModule<? extends EObject> subModule) { - for(Class<?> reqInput : subModule.getRequiredTypes()) { - // This cast is required since the explorationEncodings only accept - // exploration types -> it is just used for presence checking of a - // corresponding type. During runtime, the type is erased anyway. - @SuppressWarnings("unchecked") Class<? extends IExplorationEncoding> explReqInput = - (Class<? extends IExplorationEncoding>)reqInput; - if(!(baseModels.keySet().stream().anyMatch(m -> m.isAssignableFrom(reqInput))) && - !(transformedModels.keySet().stream().anyMatch(m -> m - .isAssignableFrom(reqInput))) && - !(explorationEncodings.containsEncoding(explReqInput))) { - return false; - } - } - return true; - } - - /** - * {@inheritDoc} - * - * @throws TransformationModuleException - */ - @Override - public void addModelToProject(FileProject fp, ITopLevelElement modelContext) - throws TransformationModuleException { - if(modelContext == null) { - throw new TransformationModuleException(this, - "Cannot add the transformed model to the AF3 Project without a model context. Please provide one."); - } - if(fp == null) { - throw new TransformationModuleException( - this, - "Cannot add the transformed model to the AF3 Project without without a referenced project. Please provide one."); - } - - for(ITransformationStrategy<?> subModule : pickInstanceOf(ITransformationStrategy.class, - getSubModules())) { - subModule.addModelToProject(fp, modelContext); - } - - if(transformedModel instanceof IProjectRootElement) { - doAddModelToProject(fp, (IProjectRootElement)transformedModel); - } - } - - /** Perform the actual adding operation of the transformed model to the AF3 project. */ - private void doAddModelToProject(FileProject fp, IProjectRootElement transformedModel) { - Runnable fpAdder = () -> { - // prepareUniqueID(transformedModel, fp); - IElementCompositorService.getInstance().compose(fp, transformedModel, null); - fp.getRootElements().add(transformedModel); - }; - modelContext.runAsCommand(fpAdder); - } - - /** {@inheritDoc} */ - @Override - public void setModelContext(ITopLevelElement modelContext) { - this.modelContext = modelContext; - } - - /** {@inheritDoc} */ - @Override - public void setModelName(String transformedModelName) { - this.transformedModelName = transformedModelName; - } - - /** {@inheritDoc} */ - @Override - public void setLaunchedAsSubModule(boolean isSubModule) { - this.launchedAsSubModule = isSubModule; - } - - /** {@inheritDoc} */ - @Override - public Collection<IIntrospectionItem> getIntrospectionItems() { - return pickInstanceOf(IIntrospectionItem.class, subModules); - } - - /** - * Comparator that allows sorting a list of {@link ITransformationModule}s such that the - * {@link ITransformationStrategy}s are present upfront. - */ - private <S extends ITransformationModule<?>> Comparator<S> createModuleStrategyOrder() { - return new Comparator<S>() { - @Override - public int compare(S o1, S o2) { - if(o1 instanceof ITransformationStrategy<?> && - o2 instanceof ITransformationStrategy<?>) { - return 0; - } else if(o1 instanceof ITransformationStrategy<?>) { - return 1; - } else if(o2 instanceof ITransformationStrategy<?>) { - return -1; - } - return 0; - } - }; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureFinalizer.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureFinalizer.java deleted file mode 100644 index f84087a673c8628c507da3ddf16c5b691216ddf2..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureFinalizer.java +++ /dev/null @@ -1,163 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComponentArchitectureFinalizer.java 3877 2016-11-10 09:35:28Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -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.modeltransformation.EMFModelConcurrencyHandler; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationModuleBase; -import org.fortiss.af3.exploration.alg.exception.InvalidTimingModelException; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; -import org.fortiss.af3.exploration.moea.model.ImplementsComponentRef; -import org.fortiss.af3.exploration.moea.model.MoeaFactory; -import org.fortiss.tooling.base.model.element.IModelElementSpecification; - -/** - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3877 $ - * @ConQAT.Rating RED Hash: 074E05A44C88E0BD6B068B069239D364 - */ -public class ComponentArchitectureFinalizer extends TransformationModuleBase<ComponentArchitecture> { - - /** {@inheritDoc} */ - @Override - public Class<ComponentArchitecture> getOutputType() { - return ComponentArchitecture.class; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(ComponentArchitecture.class); - inputTypes.add(InstantiatedTaskMappingEncoding.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { - Collection<Class<? extends ITransformationModule<?>>> parentModules = new HashSet<>(); - parentModules.add(ComponentArchitectureTransformer.class); - return parentModules; - } - - /** {@inheritDoc} */ - @Override - public boolean isOptional() { - return false; - } - - /** {@inheritDoc} */ - @Override - public TransformationState getActivationStage() { - return TransformationState.FINALIZING; - } - - /** - * {@inheritDoc} - * - * @throws TransformationModuleException - * see {@link TransformationModuleBase}. - */ - @Override - public <N extends EObject, S extends EObject> ComponentArchitecture transform( - TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException { - // Install the back reference specification to the components in the "150%/125% model". - try { - createImplementsComponentSpecifications(((ComponentArchitecture)outputModel) - .getTopComponent()); - } catch(InvalidTimingModelException e) { - throw new TransformationModuleException(this, - "Could not identify the relevant components, probably due to an inconsistent timing specification."); - } - - // instantiateAnnotationsRecursive((ComponentArchitecture)outputModel); - - // Re-enable notifications for the component architecture representing the replica. - EMFModelConcurrencyHandler.getInstance().tryEnableNotificationsSyncOf(outputModel); - - return (ComponentArchitecture)outputModel; - } - - /** - * Creates a {@link ImplementsComponentRef} {@link IModelElementSpecification} foreach - * {@link Component}-value given in the map that references the corresponding {@link Component} - * -key. Thereby it is possible to identify the implemented {@link Component} (key) from the - * instantiated {@link Component} (value). - * - * @throws InvalidTimingModelException - */ - private void createImplementsComponentSpecifications(Component component) - throws InvalidTimingModelException { - for(Component curComp : component.getSubComponents()) { - EObject originalComponent = genToOrigAssocMap.get(curComp); - - InstantiatedTaskMappingEntry entry = null; - if(originalComponent instanceof Component) { - entry = - (InstantiatedTaskMappingEntry)encEntryModelElemAssoc.inverse().get( - originalComponent, InstantiatedTaskMappingEntry.class); - } - - if(entry != null && entry.getDeployableComponent().isInstantiation()) { - addImplementsComponentRefSpec(curComp, (Component)originalComponent); - } else { - createImplementsComponentSpecifications(curComp); - } - } - } - - /** - * Creates a new {@link ImplementsComponentRef} {@link IModelElementSpecification} for the given - * {@code element} which references the given {@code referencedComponent}. - */ - private void addImplementsComponentRefSpec(Component element, Component referencedComponent) { - List<IModelElementSpecification> specList = element.getSpecifications(); - - ImplementsComponentRef refSpec = MoeaFactory.eINSTANCE.createImplementsComponentRef(); - refSpec.setRefComponent(referencedComponent); - - specList.add(refSpec); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInitializer.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInitializer.java deleted file mode 100644 index 6917015acefb5a9deeee15cd20f0f7ed0af107cd..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInitializer.java +++ /dev/null @@ -1,183 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComponentArchitectureInitializer.java 3797 2016-10-28 11:14:06Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.EMFModelConcurrencyHandler; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationModuleBase; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.element.M2MCopier; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; -import org.fortiss.af3.exploration.alg.util.ExplorationEcoreUtils; -import org.fortiss.af3.project.model.FileProject; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -/** - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3797 $ - * @ConQAT.Rating RED Hash: BF2E2ED46BCC8E410760CC922F0897FE - */ -public class ComponentArchitectureInitializer extends - TransformationModuleBase<ComponentArchitecture> { - - /** {@inheritDoc} */ - @Override - public Class<ComponentArchitecture> getOutputType() { - return ComponentArchitecture.class; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(ComponentArchitecture.class); - inputTypes.add(AbstractTaskMappingEncoding.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { - Collection<Class<? extends ITransformationModule<?>>> parentModules = new HashSet<>(); - parentModules.add(ComponentArchitectureTransformer.class); - return parentModules; - } - - /** {@inheritDoc} */ - @Override - public boolean isOptional() { - return false; - } - - /** {@inheritDoc} */ - @Override - public TransformationState getActivationStage() { - return TransformationState.INITIALIZING; - } - - /** - * {@inheritDoc} - * - * @throws TransformationModuleException - * see {@link TransformationModuleBase}. - */ - @Override - public <N extends EObject, S extends EObject> ComponentArchitecture transform( - TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException { - ComponentArchitecture origCA = - (ComponentArchitecture)baseModels.get(ComponentArchitecture.class); - if(origCA == null) { - throw new TransformationModuleException(this, - "Could not retrieve the original Component Architecture from the set of base models."); - } - - IMappingEncoding mapping = - explorationEncodings.getEncoding(AbstractTaskMappingEncoding.class); - if(mapping == null) { - throw new TransformationModuleException(this, - "An IMappingEncoding is required for this module to operate properly."); - } - - outputModel = setupTransformedComponentArchitecture(origCA, ""); - - updateEncodingAssociations(mapping); - - // Temporally disable notifications to avoid useless notifications when creating the - // component replica and the new IDs. - EMFModelConcurrencyHandler.getInstance().tryDisableNotificationsSyncOf(outputModel); - - return (ComponentArchitecture)outputModel; - } - - /** - * Replicates the {@link ComponentArchitecture} that was used as an input for the DSE. The - * replicated {@link ComponentArchitecture} is added to the {@link FileProject}. The intention - * of this method is to provide a {@link ComponentArchitecture} that contains the spatial - * replica of {@link Component}s that shall be mapped to different ECUs} - */ - private ComponentArchitecture setupTransformedComponentArchitecture( - ComponentArchitecture af3ComponentArchitecture, String addName) { - M2MCopier copier = new M2MCopier(); - ComponentArchitecture transformedComponentArchitecture = - ExplorationEcoreUtils.copy(af3ComponentArchitecture, copier); - copier.entrySet().stream().forEach(e -> genToOrigAssocMap.put(e.getValue(), e.getKey())); - copier.entrySet().stream().forEach(e -> origToGenAssocMap.put(e.getKey(), e.getValue())); - - // Set the Architecture name (via the top Component) - Component topComponent = transformedComponentArchitecture.getTopComponent(); - String caName = topComponent.getName() + "_generated_" + addName; - topComponent.setName(caName); - - return transformedComponentArchitecture; - } - - /** - * Creates associations of {@link IMappingEntry}s that DSE-internally describe task to execution - * unit mappings to generated {@link Component}s that represent the allocated tasks. - * This information is used in subsequent steps in the transformation. Hereby, the - * transformation process is capable of establishing a unique link between entries and model - * elements. - */ - private void updateEncodingAssociations(IMappingEncoding mapping) { - Multimap<Component, Component> processedElements = HashMultimap.create(); - for(IMappingEntry entry : mapping.getIMappingEntries()) { - IDeployableComponentAdapter<?> compAdp = entry.getDeployableComponent(); - Component origAF3Component = (Component)compAdp.getObject(); - Component genAF3Component = null; - - for(EObject generatedComponent : origToGenAssocMap.get(origAF3Component)) { - if(!processedElements.get(origAF3Component).contains(generatedComponent)) { - genAF3Component = (Component)generatedComponent; - break; - } - } - - encEntryModelElemAssoc.put(entry, Component.class, genAF3Component, - AbstractTaskMappingEntry.class); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInserter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInserter.java deleted file mode 100644 index 6ed5ad2fa42811301cb48dfddce47f2419e0f38f..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInserter.java +++ /dev/null @@ -1,234 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComponentArchitectureInserter.java 3561 2016-09-23 14:22:56Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch; - -import static org.fortiss.af3.component.utils.ComponentModelElementFactory.createChannelAndAttach; -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.arrangePorts; -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.calulateOffset; -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.getTargetPorts; -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.replicateInputPortAndAttach; -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.replicateOutputPortAndAttach; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.fortiss.af3.component.model.Channel; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.component.model.InputPort; -import org.fortiss.af3.component.model.OutputPort; -import org.fortiss.af3.component.model.Port; -import org.fortiss.af3.component.utils.ComponentModelElementFactory; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationModuleBase; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; -import org.fortiss.af3.platform.model.IPlatformResource; -import org.fortiss.tooling.base.model.layout.Point; - -/** - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3561 $ - * @ConQAT.Rating RED Hash: E4F4F66ACD90F1346160A73F400C2AFA - */ -public class ComponentArchitectureInserter extends TransformationModuleBase<ComponentArchitecture> { - - /** {@inheritDoc} */ - @Override - public Class<ComponentArchitecture> getOutputType() { - return ComponentArchitecture.class; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(ComponentArchitecture.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { - Collection<Class<? extends ITransformationModule<?>>> parentModules = new HashSet<>(); - parentModules.add(ComponentArchitectureTransformer.class); - return parentModules; - } - - /** {@inheritDoc} */ - @Override - public boolean isOptional() { - return false; - } - - /** {@inheritDoc} */ - @Override - public TransformationState getActivationStage() { - return TransformationState.INSERTING; - } - - /** - * {@inheritDoc} - * - * @throws TransformationModuleException - * see {@link ITransformationModule}. - */ - @Override - public <N extends EObject, S extends EObject> ComponentArchitecture transform( - TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException { - ComponentArchitecture genCA = (ComponentArchitecture)outputModel; - if(genCA == null) { - throw new TransformationModuleException(this, - "Could not retrieve the generated Component Architecture."); - } - - insertVoters(genCA); - - return (ComponentArchitecture)outputModel; - } - - /** - * Inserts voter {@link Component}s into the given {@link ComponentArchitecture}. Voter - * {@link Component}s are added directly in front of the receiver of a signal/message. It takes - * the signals of the original {@link Component} and its replica as an input and forwards the - * result of the voting to the actual receiver {@link Component}. - */ - private Map<Component, IPlatformResource> insertVoters( - ComponentArchitecture replicaAwareComponentArchitecture) { - Map<Component, IPlatformResource> voterAllocations = - new HashMap<Component, IPlatformResource>(); - - Collection<InputPort> allTargetPortsOfReplicatedArch = - getTargetPorts(replicaAwareComponentArchitecture); - - for(InputPort currentTargetPort : allTargetPortsOfReplicatedArch) { - // Evaluate the need to add voters by examining the incoming channels for each target - // port. If these channels were not present in the original architecture, voting is - // needed. - Map<Integer, List<Port>> sourcePortMap = new HashMap<Integer, List<Port>>(); - Map<Port, Channel> sourcePortToTargetChannelMap = new HashMap<Port, Channel>(); - for(Channel currentIncomingChannel : currentTargetPort.getIncomingChannels()) { - int currentId = currentIncomingChannel.getSource().getId(); - List<Port> currentPortList = sourcePortMap.get(currentId); - if(currentPortList == null) { - currentPortList = new ArrayList<Port>(); - } - currentPortList.add(currentIncomingChannel.getSource()); - sourcePortMap.put(currentId, currentPortList); - sourcePortToTargetChannelMap.put(currentIncomingChannel.getSource(), - currentIncomingChannel); - } - - Set<Integer> remainingSourcePortIds = sourcePortMap.keySet(); - while(!remainingSourcePortIds.isEmpty()) { - Integer currentSourcePortId = remainingSourcePortIds.iterator().next(); - Collection<Port> sourcePorts = sourcePortMap.get(currentSourcePortId); - if(sourcePorts.size() > 1) { - // Create voter. - // TODO: assumption that the container is a Component. - Component replicatedComponent = currentTargetPort.getComponent(); - - Component voter = - createVoter(currentTargetPort, sourcePortToTargetChannelMap, - sourcePorts, replicatedComponent); - - // A voter has exactly one output port - assert (voter.getOutputPorts().size() == 1); - OutputPort voterOutput = voter.getOutputPorts().get(0); - - // Connect voter to "original" Component - createChannelAndAttach((Component)voter.eContainer(), "Voting_result", - voterOutput, currentTargetPort); - - // voterAllocations.put(voter, deploymentComponents.get(replicatedComponent)); - } - remainingSourcePortIds.remove(currentSourcePortId); - } - } - - return voterAllocations; - } - - /** Creates a voter {@link Component}. */ - private Component createVoter(InputPort currentTargetPort, - Map<Port, Channel> sourcePortToTargetChannelMap, Collection<Port> sourcePorts, - Component replicatedComponent) { - Component voter = - ComponentModelElementFactory.createComponentAndAttach( - (Component)replicatedComponent.getContainer(), "Voter_" + - replicatedComponent.getName(), false); - - if(replicatedComponent.getLayoutData().get(0) instanceof Point) { - Point p = (Point)EcoreUtil.copy(replicatedComponent.getLayoutData().get(0)); - p = calulateOffset(p, replicatedComponent, -10, true, false); - voter.getLayoutData().set(0, p); - } - - // Create an InputPort at the voter for each incoming Channel of replicated - // Components. - for(Port currentSourcePort : sourcePorts) { - String voterName = "Vin_"; - if(currentSourcePort.getIncoming().isEmpty()) { - voterName += currentSourcePort.getComponent().getName(); - } else { - voterName += currentSourcePort.getName(); - } - InputPort voterInput = replicateInputPortAndAttach(currentSourcePort, voter, voterName); - sourcePortToTargetChannelMap.get(currentSourcePort).setTarget(voterInput); - } - - // Connect voter output port - replicateOutputPortAndAttach(currentTargetPort, voter, "Result_" + voter.getName()); - - arrangePorts(voter.getInputPorts(), voter); - arrangePorts(voter.getOutputPorts(), voter); - - return voter; - } - - // /** Specifies the given voter {@link Component} as a majority voter. */ - // private void addMajorityVoterSpec(Component voterComponent) { - // VoterType vType = MoeaFactory.eINSTANCE.createVoterType(); - // vType.setType(VoterType_t.MAJORITY_VOTER); - // List<IModelElementSpecification> specs = voterComponent.getSpecifications(); - // specs.add(vType); - // } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInstantiator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInstantiator.java deleted file mode 100644 index 52e8ca4224930f7aac8b5c5fff4f27a5c8d1ad35..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureInstantiator.java +++ /dev/null @@ -1,284 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComponentArchitectureInstantiator.java 3964 2016-12-12 12:55:09Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch; - -import static org.eclipse.emf.ecore.util.EcoreUtil.delete; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.getConnectedChannelsOf; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.getConnectedPortsOf; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.getInputOutputPortsOf; -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.pickFirstInstanceOf; -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.connectPort; -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.setGenComponentPos; -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.setReplicaAwareInstElementName; -import static org.fortiss.tooling.common.util.LambdaUtils.filterSet; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.component.model.Port; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -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.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationModuleBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.tooling.base.model.element.IConnector; -import org.fortiss.tooling.kernel.utils.EcoreUtils; - -/** - * Instantiates abstract {@link Component}s in the generated {@link ComponentArchitecture} based on - * the instantiation information contained in the input {@link InstantiatedTaskMappingEncoding}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3964 $ - * @ConQAT.Rating RED Hash: 18A75AA578DD57E5BC5C3C4D5790DC5D - */ -public class ComponentArchitectureInstantiator extends - TransformationModuleBase<ComponentArchitecture> { - - /** References the {@link Component} to {@link ExecutionUnit} mapping calculated by the DSE. */ - IMappingEncoding mapping; - - /** {@inheritDoc} */ - @Override - public Class<ComponentArchitecture> getOutputType() { - return ComponentArchitecture.class; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(InstantiatedTaskMappingEncoding.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { - Collection<Class<? extends ITransformationModule<?>>> parentModules = new HashSet<>(); - parentModules.add(ComponentArchitectureTransformer.class); - return parentModules; - } - - /** {@inheritDoc} */ - @Override - public boolean isOptional() { - return false; - } - - /** {@inheritDoc} */ - @Override - public TransformationState getActivationStage() { - return TransformationState.INSTANCIATING; - } - - /** {@inheritDoc} */ - @Override - public <N extends EObject, S extends EObject> ComponentArchitecture transform( - TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException { - - mapping = explorationEncodings.getEncoding(InstantiatedTaskMappingEncoding.class); - if(mapping == null) { - throw new TransformationModuleException(this, - "An IMappingEncoding is required for this module to operate properly."); - } - - instantiateAbstractAF3Components(); - - return (ComponentArchitecture)outputModel; - } - - /** - * Instantiates the referenced AF3 {@link Component} of each {@link IDeployableComponentAdapter} - * that demands its instantiation. Therefore, the appropriate {@link Component} from the - * Component Pool is copied to the generated {@link ComponentArchitecture}. As a side effect, - * this method updates the {@code genToOrigAssocMap} such that instantiated Components can be - * tracked. - * - * @throws TransformationModuleException - * if the set of deployable {@link Component} in the input - * {@link ComponentArchitecture} cannot be determined. - */ - private void instantiateAbstractAF3Components() throws TransformationModuleException { - Collection<Component> instantiatedComponents = new HashSet<>(); - Collection<EObject> preCleanupElementsCollection = new HashSet<>(); - - for(IDeployableComponentAdapter<?> comp : mapping.getDeployedComponents()) { - if(comp.isInstantiation()) { - Component origComp = (Component)comp.getReplacedComponent().getObject(); - preCleanupElementsCollection.addAll(getChildrenWithType(origComp, EObject.class)); - } - } - - preCleanupElementsCollection.forEach(e -> origToGenAssocMap.removeAll(e)); - - Collection<Component> abstrCompRemovalList = new ArrayList<>(); - - for(IMappingEntry entry : mapping.getIMappingEntries()) { - @SuppressWarnings("unchecked") IDeployableComponentAdapter<Component> compAdp = - (IDeployableComponentAdapter<Component>)entry.getDeployableComponent(); - if(compAdp.isInstantiation()) { - // Randomly take one replicated generated Component that belongs to the - // corresponding adapter. - // Filter out already instantiated components. - // Component abstrGenComponent = - // (Component)origToGenAssocMap - // .get(compAdp.getReplacedComponent().getObject()).stream() - // .filter(c -> !instantiatedComponents.contains(c)).findAny().get(); - AbstractTaskMappingEntry abstrEntry = - entry.getAssociatedElement(AbstractTaskMappingEntry.class); - Component abstrGenComponent = - (Component)encEntryModelElemAssoc.get(abstrEntry, Component.class); - Component poolComponent = compAdp.getObject(); - Component instantiatedComponent = - instantiateComponent(abstrGenComponent, poolComponent); - - // Remove the associated (possibly replicated) "abstract" component. - abstrCompRemovalList.add(abstrGenComponent); - // removeAbstractComponent(abstrGenComponent); - Component origComponent = compAdp.getReplacedComponent().getObject(); - - setReplicaAwareInstElementName(origComponent, abstrGenComponent, - instantiatedComponent); - updateAssocMaps(entry, poolComponent, origComponent, abstrGenComponent, - instantiatedComponent); - instantiatedComponents.add(instantiatedComponent); - } else { - IMappingEntry abstrEntr = - pickFirstInstanceOf(AbstractTaskMappingEntry.class, - entry.getAssociatedElement()); - Component genComp = - (Component)encEntryModelElemAssoc.get(abstrEntr, Component.class); - genToGenAssocMap.put(genComp, genComp); - encEntryModelElemAssoc.put(entry, Component.class, genComp, - InstantiatedTaskMappingEntry.class); - } - } - - abstrCompRemovalList.forEach(c -> removeAbstractComponent(c)); - } - - /** - * Replaces the given {#link abstractComponent} with the given {#link replacementComponent}. - * This method is intended to replace "abstract" {@link Component} with their instances from the - * "Component Pool". - */ - private Component - instantiateComponent(Component abstrComponent, Component replacementComponent) { - Component instantiatedComponent = EcoreUtils.copy(replacementComponent); - instantiatedComponent.setContainer(abstrComponent.getContainer()); - - Collection<Port> instantiatedConnectors = getInputOutputPortsOf(instantiatedComponent); - for(Port movingPort : getInputOutputPortsOf(abstrComponent)) { - // Rewire Channels. - // TODO: Possible NPE if optional is empty. Throw an exception about non-found port name - // here. - Collection<Port> matchingPorts = - filterSet(instantiatedConnectors, p -> movingPort.getName().equals(p.getName())); - Port matchInstantatedConnector = matchingPorts.stream().findAny().get(); - - genToOrigAssocMap.put(matchInstantatedConnector, movingPort); - connectPort(matchInstantatedConnector, getConnectedPortsOf(movingPort), - instantiatedComponent); - } - - // Add position / layout information - setGenComponentPos(abstrComponent, instantiatedComponent); - - return instantiatedComponent; - } - - /** - * Removes the "abstract" {@link Component}s from its parent {@link ComponentArchitecture}, i.e. - * it removes those {@link Component}s which point to an "implementation" in the - * "Component Pool". - */ - // TODO: The parameter should actually be a collection of components. - private void removeAbstractComponent(Component abstrComponent) { - getConnectedChannelsOf(abstrComponent).stream().forEach(ch -> delete(ch)); - delete(abstrComponent); - } - - /** Updates the association maps with the modifications introduced by the instantiation. */ - // TODO: generalize this update method to also consider children. - private void updateAssocMaps(IMappingEntry entry, Component poolComponent, - Component origComponent, Component abstrGenComponent, Component instantiatedComponent) { - origToGenAssocMap.remove(origComponent, abstrGenComponent); - origToGenAssocMap.put(origComponent, instantiatedComponent); - genToOrigAssocMap.remove(poolComponent); - genToOrigAssocMap.put(instantiatedComponent, origComponent); - genToGenAssocMap.put(abstrGenComponent, instantiatedComponent); - for(IConnector abstrPort : abstrGenComponent.getConnectors()) { - origToGenAssocMap.removeAll(abstrPort); - for(IConnector instPort : instantiatedComponent.getConnectors()) { - // Names MUST be identical (convention). - // TODO: Identify a method to identify equal Ports without querying the name. - if(((Port)instPort).getName().equals(((Port)abstrPort).getName())) { - genToGenAssocMap.put(abstrPort, instPort); - origToGenAssocMap.put(abstrPort, instPort); - genToOrigAssocMap.put(instPort, abstrPort); - } - } - } - - // Further we need to update the associations from the ports of the original Component. - for(IConnector abstrPort : origComponent.getConnectors()) { - for(IConnector instPort : instantiatedComponent.getConnectors()) { - // Names MUST be identical (convention). - // TODO: Identify a method to identify equal Ports without querying the name. - if(((Port)instPort).getName().equals(((Port)abstrPort).getName())) { - genToGenAssocMap.put(abstrPort, instPort); - origToGenAssocMap.put(abstrPort, instPort); - genToOrigAssocMap.put(instPort, abstrPort); - } - } - } - - encEntryModelElemAssoc.put(entry, Component.class, instantiatedComponent, - InstantiatedTaskMappingEntry.class); - // entry.getAssociatedElement().forEach( - // e -> encEntryModelElemAssoc.put(e, Component.class, instantiatedComponent, - // e.getClass())); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureReplicator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureReplicator.java deleted file mode 100644 index 826a0914d235d4985fdd77f63ab298bf1775c8c7..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureReplicator.java +++ /dev/null @@ -1,672 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComponentArchitectureReplicator.java 3841 2016-11-04 14:51:29Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch; - -import static org.fortiss.af3.component.utils.ComponentModelElementFactory.createChannelAndAttach; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.getInputOutputPortsOf; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.isAnyParentComponentDeployable; -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.getSourcePorts; -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.arrangePorts; -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.connectPort; -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.getDeployableComponentMap; -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.retrieveDeployableComponents; -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.setGenComponentPos; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf; -import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.findElementById; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; -import java.util.Set; - -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.fortiss.af3.component.model.Channel; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.component.model.InputPort; -import org.fortiss.af3.component.model.OutputPort; -import org.fortiss.af3.component.model.Port; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.comm.constraint.InternalIsolatedCommunicationSet; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationModuleBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.alg.exception.InvalidTimingModelException; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.af3.platform.model.IPlatformResource; -import org.fortiss.tooling.kernel.model.INamedElement; -import org.fortiss.tooling.kernel.utils.EcoreUtils; -import org.omg.IOP.MultipleComponentProfileHelper; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -/** - * Replicates {@link Component}s in the generated {@link ComponentArchitecture} if - * {@link MultipleComponentProfileHelper} {@link IMappingEntry}s of the input - * {@link AbstractTaskMappingEncoding} point to the same {@link Component}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3841 $ - * @ConQAT.Rating RED Hash: 1987993B7FF1EAEB5CA0004088D5DF24 - */ -public class ComponentArchitectureReplicator extends - TransformationModuleBase<ComponentArchitecture> { - - /** Collection of {@link Component}s that can be allocated to {@link IPlatformResource}. */ - private Collection<IDeployableComponentAdapter<Component>> deployableComponentCollection = - new HashSet<>(); - - /** - * Contains the allocation information between possibly replicated {@link Component}s and their - * corresponding {@link IPlatformResource}s. - */ - Map<Component, IPlatformResource> deploymentComponents = new HashMap<>(); - - /** References the original {@link ComponentArchitecture} that was input to the DSE. */ - ComponentArchitecture originalCA; - - /** {@inheritDoc} */ - @Override - public Class<ComponentArchitecture> getOutputType() { - return ComponentArchitecture.class; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(ComponentArchitecture.class); - inputTypes.add(AbstractTaskMappingEncoding.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { - Collection<Class<? extends ITransformationModule<?>>> parentModules = new HashSet<>(); - parentModules.add(ComponentArchitectureTransformer.class); - return parentModules; - } - - /** {@inheritDoc} */ - @Override - public boolean isOptional() { - return false; - } - - /** {@inheritDoc} */ - @Override - public TransformationState getActivationStage() { - return TransformationState.REPLICATING; - } - - /** {@inheritDoc} */ - @Override - public <N extends EObject, S extends EObject> ComponentArchitecture transform( - TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException { - ComponentArchitecture genCA = (ComponentArchitecture)outputModel; - if(genCA == null) { - throw new TransformationModuleException(this, - "Could not retrieve the generated Component Architecture."); - } - - originalCA = (ComponentArchitecture)baseModels.get(ComponentArchitecture.class); - if(originalCA == null) { - throw new TransformationModuleException(this, - "Could not retrieve the original Component Architecture from the set of base models."); - } - - AbstractTaskMappingEncoding mapping = - explorationEncodings.getEncoding(AbstractTaskMappingEncoding.class); - if(mapping == null) { - throw new TransformationModuleException(this, - "An IMappingEncoding is required for this module to operate properly."); - } - - deployableComponentCollection = retrieveDeployableComponents(this, mapping); - Map<IDeployableComponentAdapter<Component>, Component> genCompAssoc = - getDeployableComponentMap(this, origToGenAssocMap, deployableComponentCollection); - - EList<Port> replicatedPorts = new BasicEList<Port>(); - - for(Entry<IDeployableComponentAdapter<Component>, Component> deployedComponentPair : genCompAssoc - .entrySet()) { - Component currentDeployableAf3Component = deployedComponentPair.getValue(); - - Collection<ExecutionUnit> allocatedExecutionUnits = - getExecutionUnitAllocationsFromMapping(mapping - .getAllocatedResourcesFor(deployedComponentPair.getKey())); - Collection<IMappingEntry> currentMappingEntries = - mapping.getIMappingEntriesOf(deployedComponentPair.getKey()); - - List<Component> generatedAndReplicatedComponents = new ArrayList<Component>(); - generatedAndReplicatedComponents.add(currentDeployableAf3Component); - - // TODO: Refactor the following code, the re-use of the Iterator is anything but - // beautiful code. - // Create an iterator which is used to handle the allocations of the replicated - // components. - assert (!allocatedExecutionUnits.isEmpty()) : "Each Component must be allocated to at least one ExecutionUnit."; - Iterator<IMappingEntry> mappingEntryIt = currentMappingEntries.iterator(); - IMappingEntry mappingEntry = mappingEntryIt.next(); - deploymentComponents.put(currentDeployableAf3Component, (ExecutionUnit)mappingEntry - .getTarget().getObject()); - encEntryModelElemAssoc.put(mappingEntry, Component.class, - currentDeployableAf3Component, AbstractTaskMappingEntry.class); - // TODO: If we would use 'e.getClass()' here, we would get a specialization of the - // originally wanted InstantiatedtaskMappingEntry. Use another mechanism to define the - // type of the associated elements. - genToGenAssocMap.put(currentDeployableAf3Component, currentDeployableAf3Component); - - // TODO: A mechanism to retrieve optional solutions from the DSE is needed here. Then, - // we could dynamically "plug in" the detection of required implementsXY specifications, - // e.g. for parts of a safety function. - - if(allocatedExecutionUnits.size() > 1) { - // Collect the InputPorts and the sources of their connectors to restore the - // original connections for the replicated components (incoming part). - Map<InputPort, Collection<Port>> originalComponentInputSources = - getComponentPortToConnectedPortMap(currentDeployableAf3Component, - InputPort.class); - // Collect the OutputPorts and the targets of their connectors to restore the - // original connections for the replicated components (outgoing part). - Map<OutputPort, Collection<Port>> originalComponentOutputTargets = - getComponentPortToConnectedPortMap(currentDeployableAf3Component, - OutputPort.class); - - Multimap<Port, Port> assocGenWithReplPort = HashMultimap.create(); - - // Create replica of the current component based on the number of target resources. - for(int i = 1; i < allocatedExecutionUnits.size(); i++) { - Component replicatedComponent = - replicateComponent(replicatedPorts, currentDeployableAf3Component, - generatedAndReplicatedComponents, - originalComponentInputSources, originalComponentOutputTargets, - assocGenWithReplPort, i); - - allocateReplicatedComponent(deploymentComponents, mappingEntryIt, - replicatedComponent); - - genToGenAssocMap.put(currentDeployableAf3Component, replicatedComponent); - - } - } - // Remember the association between the replicated component and the "original". - // TODO: Replace this method with the new assoc map (see todo above). - createComponentAssocWithReplicaComponents(currentDeployableAf3Component, - generatedAndReplicatedComponents); - } - - // After the replicated Components have been added, the wiring of the of the replicated - // ports and their connected channels must be adjusted through the complete architecture. - try { - createReplicaAwareChannelWiring(genCA, replicatedPorts, deploymentComponents.keySet()); - } catch(InvalidTimingModelException e) { - throw new TransformationModuleException( - this, - "Could not complete the replication transformation step due to an (probably) invalid timing model.", - e); - } - - for(IMappingEntry entry : mapping.getMappingEntries()) { - if(!isPartOfIsolationCommConstraint( - mapping.getConstraintsOf(InternalIsolatedCommunicationSet.class), entry)) { - continue; - } - Component genComponent = (Component)encEntryModelElemAssoc.get(entry, Component.class); - Collection<InternalIsolatedCommunicationSet> others = - getOtherIsolationCommConstraints(mapping, entry); - for(InternalIsolatedCommunicationSet otherSet : others) { - for(IMappingEntry conEntry : otherSet.getIsolatedCommunicationSet()) { - Component otherGenComp = - (Component)encEntryModelElemAssoc.get(conEntry, Component.class); - removeAllConnectionsBetween(genComponent, otherGenComp); - } - } - } - - return genCA; - } - - /** Removes all connections ({@link Channel}s) between the given {@link Component}s. */ - private void removeAllConnectionsBetween(Component firstComp, Component secondComp) { - Collection<Channel> firstCompChannels = new HashSet<>(); - firstComp.getInputPorts().forEach(p -> firstCompChannels.addAll(p.getIncomingChannels())); - firstComp.getOutputPorts().forEach(p -> firstCompChannels.addAll(p.getOutgoingChannels())); - Collection<Channel> rmChannels = new ArrayList<>(); - for(Channel firstCompChannel : firstCompChannels) { - if(firstCompChannel.getSource().getComponent() == secondComp || - firstCompChannel.getTarget().getComponent() == secondComp) { - rmChannels.add(firstCompChannel); - } - } - rmChannels.forEach(ch -> EcoreUtil.delete(ch)); - } - - /** - * Returns a collection of all {@link InternalIsolatedCommunicationSet} constraints that do not - * include the given {@link IMappingEntry}. - */ - private Collection<InternalIsolatedCommunicationSet> getOtherIsolationCommConstraints( - TaskMappingEncoding<?> encoding, IMappingEntry entry) { - Collection<InternalIsolatedCommunicationSet> otherConstraints = new HashSet<>(); - Collection<InternalIsolatedCommunicationSet> isoComm = - encoding.getConstraintsOf(InternalIsolatedCommunicationSet.class); - for(InternalIsolatedCommunicationSet constr : isoComm) { - if(!constr.getIsolatedCommunicationSet().contains(entry)) { - otherConstraints.add(constr); - } - } - - return otherConstraints; - } - - /** - * Returns whether the given {@link IMappingEntry} is included in any of the given - * {@link InternalIsolatedCommunicationSet}s. - */ - private boolean isPartOfIsolationCommConstraint( - Collection<InternalIsolatedCommunicationSet> isoComm, IMappingEntry entry) { - for(InternalIsolatedCommunicationSet constr : isoComm) { - if(constr.contains(entry)) { - return true; - } - } - - return false; - } - - /** - * Transforms a {@link Collection} of {@link IResourceAdapter} that is the result of a mapping - * of a single {@link Component} into a {@link Collection} of {@link ExecutionUnit}s. - */ - private Collection<ExecutionUnit> getExecutionUnitAllocationsFromMapping( - Collection<IResourceAdapter<?>> mappingEntriesOfRequester) { - Collection<ExecutionUnit> allocatedExecutionUnits = new ArrayList<ExecutionUnit>(); - for(IResourceAdapter<?> currentAllocationTarget : mappingEntriesOfRequester) { - assert (currentAllocationTarget.getObject() instanceof ExecutionUnit) : "There are currently no other deployment targets than ExecutionUnits allowed."; - allocatedExecutionUnits.add((ExecutionUnit)currentAllocationTarget.getObject()); - } - return allocatedExecutionUnits; - } - - /** - * Determines the {@link Port}s to which a {@link Component} is connected to. The result is a - * {@link Map} which contains either the input or output ports of the given {@link Component} - * and their connected {@link Port}s. - */ - @SuppressWarnings("unchecked") - private <T extends Port> Map<T, Collection<Port>> getComponentPortToConnectedPortMap( - Component deployableAF3Component, Class<? extends Port> componentPortType) { - EList<T> originalComponentInputPorts = new BasicEList<T>(); - if(InputPort.class.isAssignableFrom(componentPortType)) { - for(InputPort inputPort : deployableAF3Component.getInputPorts()) { - originalComponentInputPorts.add((T)inputPort); - } - } else { - for(OutputPort outputPort : deployableAF3Component.getOutputPorts()) { - originalComponentInputPorts.add((T)outputPort); - } - } - - Map<T, Collection<Port>> originalComponentInputSources = new HashMap<T, Collection<Port>>(); - for(T currentOriginalPort : originalComponentInputPorts) { - List<Channel> connectedChannels = null; - if(InputPort.class.isAssignableFrom(componentPortType)) { - connectedChannels = currentOriginalPort.getIncomingChannels(); - } else { - connectedChannels = currentOriginalPort.getOutgoingChannels(); - } - Collection<Port> connectedPorts = new ArrayList<Port>(); - for(Channel currentChannel : connectedChannels) { - if(InputPort.class.isAssignableFrom(componentPortType)) { - connectedPorts.add(currentChannel.getSource()); - } else { - connectedPorts.add(currentChannel.getTarget()); - } - } - originalComponentInputSources.put(currentOriginalPort, connectedPorts); - } - return originalComponentInputSources; - } - - /** - * Replicates a single {@link Component} from the input {@link ComponentArchitecture} of the - * DSE. - */ - // TODO: cleanup this method: It has a too large signature. - private Component replicateComponent(EList<Port> replicatedPorts, - Component currentDeployableAf3Component, List<Component> origAndReplicatedComponents, - Map<InputPort, Collection<Port>> originalComponentInputSources, - Map<OutputPort, Collection<Port>> originalComponentOutputTargets, - Multimap<Port, Port> assocGenWithReplPort, int i) { - Component replicatedComponent = EcoreUtils.copy(currentDeployableAf3Component); - - // FIXME: remove IOServer hack. - // if(replicatedComponent.getName().contains("IOServer")) { - // for(InputPort inP : replicatedComponent.getInputPorts()) { - // if(inP.getName().contains("InpSupervisionD") || - // inP.getName().contains("InpSupervisionE")) { - // for(Channel inCh : inP.getIncomingChannels()) { - // EcoreUtil.remove(inCh); - // } - // EcoreUtil.remove(inP); - // } - // } - // } - - // TODO: Cleanup, use the new assoc map, the old implementation is buggy. - List<Component> replSubComponents = - getChildrenWithType(replicatedComponent, Component.class); - origAndReplicatedComponents.add(replicatedComponent); - origAndReplicatedComponents.addAll(replSubComponents); - - replicatedComponent.setContainer(currentDeployableAf3Component.getParentComponent()); - replicatedComponent.setName(currentDeployableAf3Component.getName() + "_" + - Integer.toString(i)); - - setGenComponentPos(currentDeployableAf3Component, replicatedComponent); - - // Connect inputs of the replicated Component. - connectReplicatedPorts(originalComponentInputSources, replicatedComponent); - // Connect outputs of the replicated Component. - connectReplicatedPorts(originalComponentOutputTargets, replicatedComponent); - - Component parent = currentDeployableAf3Component.getParentComponent(); - parent.getContainedElements().add(replicatedComponent); - replicatedPorts.addAll(getInputOutputPortsOf(replicatedComponent)); - - Collection<Port> originalPorts = - getChildrenWithType(currentDeployableAf3Component, Port.class); - for(Port currentOrigPort : originalPorts) { - Port replPort = (Port)findElementById(currentOrigPort.getId(), replicatedComponent); - assocGenWithReplPort.put(currentOrigPort, replPort); - } - - // Associate the original Component with its replica. - // Original (possibly abstract) Component. - // TODO: Generalize: It should be possible to create the association based on a - // copy from the pool, not the generated architecture -> Decoupling. - EObject origComponent = genToOrigAssocMap.get(currentDeployableAf3Component); - Map<INamedElement, INamedElement> assocMap = - updateGenToOrigElementMapById(origComponent, currentDeployableAf3Component, - replicatedComponent, INamedElement.class); - genToOrigAssocMap.putAll(assocMap); - assocMap.entrySet().stream().forEach(e -> origToGenAssocMap.put(e.getValue(), e.getKey())); - - for(Port curPort : pickInstanceOf(Port.class, replicatedComponent.eContents())) { - Port baseGenPort = - (Port)findElementById(curPort.getId(), currentDeployableAf3Component); - genToGenAssocMap.put(baseGenPort, curPort); - } - - genToOrigAssocMap.put(replicatedComponent, replicatedComponent); - - return replicatedComponent; - } - - /** - * Replicates the {@link Port}s given in the list {#link portReplicationCollection}. - * Furthermore, channels between the sources/targets of the original {@link Port}s to the - * replicated {@link Port}s are created. Thus, the original data flow is maintained. - */ - // TODO: rework documentation. - private <T extends Port, S extends Port> void connectReplicatedPorts( - Map<T, Collection<S>> connectedPortMap, Component replicatedComponent) { - Collection<T> portReplicationCollection = connectedPortMap.keySet(); - for(T currentPort : portReplicationCollection) { - @SuppressWarnings("unchecked") T replicatedPort = - (T)findElementById(currentPort.getId(), replicatedComponent); - - if(replicatedPort != null) { - connectPort(replicatedPort, connectedPortMap.get(currentPort), replicatedComponent); - } - } - } - - /** - * Initializes the {@link Multimap} that associates {@link Component}s in the original - * {@link ComponentArchitecture} with their respective {@link Component}s in the generated - * {@link ComponentArchitecture}. - */ - // TODO: rework doc. - // TODO: avoid suppresswarning, use common parent class for archs as well. - @SuppressWarnings("unchecked") - private <T extends INamedElement> Map<T, T> updateGenToOrigElementMapById( - EObject originalElement, EObject replElementTemplate, EObject generatedElement, - Class<T> elementType) { - Map<T, T> assocOrigToGenElements = new HashMap<>(); - List<T> origElementList = getChildrenWithType(originalElement, elementType); - origElementList.add((T)originalElement); - - List<T> genElementList = getChildrenWithType(generatedElement, elementType); - genElementList.add((T)generatedElement); - - for(T origElement : origElementList) { - Optional<T> equivElem = - genElementList.stream().filter(c -> (c.getId() == origElement.getId())) - .findAny(); - if(equivElem.isPresent()) { - genToOrigAssocMap.put(equivElem.get(), origElement); - origToGenAssocMap.put(origElement, equivElem.get()); - genToGenAssocMap.put(replElementTemplate, equivElem.get()); - } - } - - return assocOrigToGenElements; - } - - /** - * Allocates the given replicated {@link Component} to the corresponding - * {@link IPlatformResource} indicated by the given {@link IMappingEncoding}. The result is - * stored in the given {@code deployableComponent} Map. - */ - private void allocateReplicatedComponent( - Map<Component, IPlatformResource> deploymentComponents, - Iterator<IMappingEntry> mappingEntryIt, Component replicatedComponent) { - IMappingEntry mappingEntry; - // Allocate the replica of the original component to the ExecutionUnits. - mappingEntry = mappingEntryIt.next(); - deploymentComponents.put(replicatedComponent, (ExecutionUnit)mappingEntry.getTarget() - .getObject()); - encEntryModelElemAssoc.put(mappingEntry, Component.class, replicatedComponent, - AbstractTaskMappingEntry.class); - } - - /** - * Modifies a given map which stores the associations of components with their equivalents in a - * {@link ComponentArchitecture} that considers replica. The associations refer each equivalent - * {@link Component} of an "original" {@link Component}, be it a replica of the respective - * original {@link Component}, or not. - */ - private void createComponentAssocWithReplicaComponents(Component currentGeneratedAf3Component, - List<Component> generatedAndReplicatedComponents) { - // Component originalComponent = - // (Component)findElementById(currentDeployableAf3Component.getId(), originalCA); - Component originalComponent = - (Component)genToOrigAssocMap.get(currentGeneratedAf3Component); - origToGenAssocMap.putAll(originalComponent, generatedAndReplicatedComponents); - genToGenAssocMap.putAll(currentGeneratedAf3Component, generatedAndReplicatedComponents); - // Additionally, consider contained components. - for(Component containedComponent : getChildrenWithType(currentGeneratedAf3Component, - Component.class)) { - originalComponent = (Component)findElementById(containedComponent.getId(), originalCA); - origToGenAssocMap.putAll(originalComponent, generatedAndReplicatedComponents); - genToGenAssocMap.putAll(currentGeneratedAf3Component, generatedAndReplicatedComponents); - } - - for(Port containedPort : getChildrenWithType(currentGeneratedAf3Component, Port.class)) { - Port origPort = (Port)findElementById(containedPort.getId(), originalComponent); - genToGenAssocMap.put(containedPort, origPort); - origToGenAssocMap.put(origPort, containedPort); - } - } - - /** - * Adjusts the wiring of a {@link ComponentArchitecture} that represents a mapping with - * {@link Component} replica. - * First, this method identifies all source {@link Port}s within the replica-aware - * {@link ComponentArchitecture} by using information from the original - * {@link ComponentArchitecture}. Then, the method traverses each {@link Channel} and replicates - * the port and successive {@link Channel}s, if the target {@link Port} belongs to a hull - * {@link Component}. - * - * @throws InvalidTimingModelException - * if the timing specification of any traversed element is inconsistent. - */ - private void createReplicaAwareChannelWiring( - ComponentArchitecture replicaAwareComponentArchitecture, EList<Port> replicatedPorts, - Set<Component> deployableComponentsOfReplicatedArch) throws InvalidTimingModelException { - - // Create a list of Components that contain deployment targets. - EList<Component> allComponentsOfReplicatedAf3Architecture = - getChildrenWithType(replicaAwareComponentArchitecture, Component.class); - List<Component> deployableComponentHullList = new ArrayList<Component>(); - for(Component currentAf3Component : allComponentsOfReplicatedAf3Architecture) { - if(!deployableComponentsOfReplicatedArch.contains(currentAf3Component) && - !isAnyParentComponentDeployable(currentAf3Component, encEntryModelElemAssoc)) { - deployableComponentHullList.add(currentAf3Component); - } - } - - // Build the list of replicated source ports. Therefore, all source ports from the component - // architecture containing the replica are determined, and the original ports are removed - // from the list. - EList<Port> remainingSourcePortsToConnect = - getReplicatedSourcePorts(replicaAwareComponentArchitecture, replicatedPorts); - - while(!remainingSourcePortsToConnect.isEmpty()) { - // Always take the first element form the working list. - Port currentPortToConnect = remainingSourcePortsToConnect.get(0); - for(Channel currentOutgoingChannel : currentPortToConnect.getOutgoingChannels()) { - Port currentTargetPort = currentOutgoingChannel.getTarget(); - if(deployableComponentHullList.contains(currentTargetPort.getOwner())) { - // For hull Components, the target Port needs to be replicated, since this - // cannot be considered when replicating the Components according to the - // mapping. - // FIXME: remove IOServer hack. - if(!currentTargetPort.getComponent().getName().contains("IOServer") || - currentPortToConnect.getComponent().getName().contains("IOServer")) { - Port replicatedPort = EcoreUtil.copy(currentTargetPort); - replicatedPort.setOwner(currentTargetPort.getOwner()); - currentOutgoingChannel.setTarget(replicatedPort); - - String replicatedPortName = - extractReplicatedPortName(currentPortToConnect, replicatedPort); - replicatedPort.setName(replicatedPortName); - - // Differentiate the target ports by their property of being a "hull" - // component - // or a deployment target, since this results in a different channel wiring. - for(Channel currentOutgoingTargetChannel : currentTargetPort - .getOutgoingChannels()) { - Port tgtPort = currentOutgoingTargetChannel.getTarget(); - createChannelAndAttach( - currentOutgoingTargetChannel.getParentComponent(), "", - replicatedPort, tgtPort); - } - // Add the "hull Port" to the working list for further processing - remainingSourcePortsToConnect.add(replicatedPort); - } - } - } - remainingSourcePortsToConnect.remove(0); - } - - // Finally, arrange the ports for the graphical representation (avoid overlap). - for(Component currentHullComponent : deployableComponentHullList) { - arrangePorts(currentHullComponent.getInputPorts(), currentHullComponent); - arrangePorts(currentHullComponent.getOutputPorts(), currentHullComponent); - } - } - - /** - * Returns an {@link EList} of source {@link Port}s that belong to replicated {@link Component} - * s. - * - * @throws InvalidTimingModelException - * if the timing specification of any traversed element is inconsistent. - */ - private EList<Port> getReplicatedSourcePorts( - ComponentArchitecture replicaAwareComponentArchitecture, EList<Port> replicatedPorts) - throws InvalidTimingModelException { - // Get the source ports from the replicated and the original ComponentArchitecture - EList<Port> replicatedSourcePorts = new BasicEList<Port>(); - EList<OutputPort> originalAndReplicatedSourcePorts = - getSourcePorts(replicaAwareComponentArchitecture); - for(Port currentPort : originalAndReplicatedSourcePorts) { - if(replicatedPorts.contains(currentPort)) { - replicatedSourcePorts.add(currentPort); - } - } - - return replicatedSourcePorts; - } - - /** - * Generates the name of a replicated Port to obtain a consistent enumeration within the - * replicated logical architecture and to have unique port naming of "hull" components - * (otherwise the model was invalid). - */ - private String extractReplicatedPortName(Port currentPortToConnect, Port replicatedPort) { - String[] replicatedPortNumber; - // The port number can be derived from the component of the port to connect, or the port - // itself (for hull components). - if(currentPortToConnect.getIncomingChannels().isEmpty()) { - replicatedPortNumber = currentPortToConnect.getComponent().getName().split("_"); - } else { - replicatedPortNumber = currentPortToConnect.getName().split("_"); - } - - return replicatedPort.getName() + "_" + - replicatedPortNumber[replicatedPortNumber.length - 1]; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureTransformer.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureTransformer.java deleted file mode 100644 index 4ef50d0a98faf8153980af4d2434fca4f55ba554..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/ComponentArchitectureTransformer.java +++ /dev/null @@ -1,113 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComponentArchitectureTransformer.java 3458 2016-09-05 17:11:42Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationStrategy; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationStrategyBase; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.deployment.ExplorationSolutionToDeployment; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; -import org.fortiss.af3.exploration.moea.model.solutions.SingleExplorationSolutionMap; -import org.fortiss.tooling.kernel.model.INamedElement; - -/** - * {@link ITransformationStrategy} for {@link ComponentArchitecture}s based on an - * {@link SingleExplorationSolutionMap} explored by the DSE. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3458 $ - * @ConQAT.Rating RED Hash: 428CB3291141E0956246F728C570E296 - */ -public class ComponentArchitectureTransformer extends - TransformationStrategyBase<ComponentArchitecture> { - - /** Returns the list of elements that were instantiated in this generation/transformation step. */ - public Collection<EObject> getInstantiatedElements() { - return instantiatedElements; - } - - /** {@inheritDoc} */ - @Override - public Class<ComponentArchitecture> getOutputType() { - return ComponentArchitecture.class; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(ComponentArchitecture.class); - inputTypes.add(IMappingEncoding.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { - Collection<Class<? extends ITransformationModule<?>>> parentModules = new HashSet<>(); - parentModules.add(ExplorationSolutionToDeployment.class); - return parentModules; - } - - /** {@inheritDoc} */ - @Override - public boolean isOptional() { - return false; - } - - /** {@inheritDoc} */ - @Override - public TransformationState getActivationStage() { - return TransformationState.INITIALIZING; - } - - /** Sets the name of the transformed model. */ - @Override - protected void doSetModelName() { - String name = transformedModelName; - if(launchedAsSubModule) { - name = "Component Architecture - " + name; - } - - setName(name, transformedModel); - setName(name, transformedModel.getTopComponent()); - } - - /** Sets the name of the given Element without triggering a load of notifications. */ - private void setName(String name, INamedElement element) { - boolean notificationsEnabled = element.eDeliver(); - if(notificationsEnabled) { - element.eSetDeliver(false); - } - element.setName(name); - element.eSetDeliver(true); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentFinalizer.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentFinalizer.java deleted file mode 100644 index bbf9d2368a59eaa6e4f33be4bee8c07700fb40d6..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentFinalizer.java +++ /dev/null @@ -1,267 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DeploymentFinalizer.java 3561 2016-09-23 14:22:56Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.deployment; - -import static org.fortiss.af3.deployment.utils.DeploymentModelElementFactory.createComponentAllocation; -import static org.fortiss.af3.deployment.utils.DeploymentParameterUtils.getDeploymentsWithParametersOf; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.getFirstComponentPool; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.resetIds; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.deployment.model.AF3DeploymentFactory; -import org.fortiss.af3.deployment.model.ComponentAllocation; -import org.fortiss.af3.deployment.model.ComponentArchitectureReference; -import org.fortiss.af3.deployment.model.Deployment; -import org.fortiss.af3.deployment.model.DeploymentParameterKey; -import org.fortiss.af3.deployment.model.DeploymentParameterValue; -import org.fortiss.af3.deployment.model.impl.DeploymentParameterKeyToDeploymentParameterValueMapImpl; -import org.fortiss.af3.deployment.utils.DeploymentModelElementFactory; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.EMFModelConcurrencyHandler; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationModuleBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.af3.platform.model.PlatformArchitecture; -import org.fortiss.af3.project.model.FileProject; -import org.fortiss.tooling.kernel.utils.EcoreUtils; - -/** - * Creates the {@link ComponentAllocation}s and the - * {@link DeploymentParameterKeyToDeploymentParameterValueMapImpl}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3561 $ - * @ConQAT.Rating RED Hash: 4FBD82E921C3701C5F79FCF36F643B9A - */ -public class DeploymentFinalizer extends TransformationModuleBase<Deployment> { - - /** {@inheritDoc} */ - @Override - public Class<Deployment> getOutputType() { - return Deployment.class; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(ComponentArchitecture.class); - inputTypes.add(PlatformArchitecture.class); - inputTypes.add(IMappingEncoding.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { - Collection<Class<? extends ITransformationModule<?>>> parentModules = new HashSet<>(); - parentModules.add(ExplorationSolutionToDeployment.class); - return parentModules; - } - - /** {@inheritDoc} */ - @Override - public boolean isOptional() { - return false; - } - - /** {@inheritDoc} */ - @Override - public TransformationState getActivationStage() { - return TransformationState.REPLICATED; - } - - /** {@inheritDoc} */ - @Override - public <N extends EObject, S extends EObject> Deployment transform(TransformationState state, - TransformationContext context, SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException { - IMappingEncoding mapping = explorationEncodings.getEncoding(IMappingEncoding.class); - if(mapping == null) { - throw new TransformationModuleException(this, - "An IMappingEncoding is required for this module to operate properly."); - } - - ComponentArchitecture transformedCA = - (ComponentArchitecture)transformedModels.get(ComponentArchitecture.class); - if(transformedCA == null) { - transformedCA = (ComponentArchitecture)baseModels.get(ComponentArchitecture.class); - if(transformedCA == null) { - throw new TransformationModuleException( - this, - "Neither a transformed, nor an input component architecture has been found that shall be referenced by the transformed deployment."); - } - } - - ComponentArchitecture originalCA = - (ComponentArchitecture)baseModels.get(ComponentArchitecture.class); - if(originalCA == null) { - throw new TransformationModuleException( - this, - "Could not retrieve the original component architecture from the set of base models. Be sure to add it to the required input types."); - } - - PlatformArchitecture originalPA = - (PlatformArchitecture)baseModels.get(PlatformArchitecture.class); - if(originalPA == null) { - throw new TransformationModuleException( - this, - "Could not retrieve the original platform architecture from the set of base models. Be sure to add it to the required input types."); - } - - ComponentArchitectureReference caRef = - AF3DeploymentFactory.eINSTANCE.createComponentArchitectureReference(); - ((Deployment)outputModel).setComponentArchitectureReference(caRef); - EMFModelConcurrencyHandler.getInstance().setReference(caRef, transformedCA); - - // TODO: Maybe distribute the generation of component allocation over the various modules. - ((Deployment)outputModel).getComponentAllocations().addAll( - allocateComponentsToExecutionUnits(mapping)); - - createDeploymentParameterMap(originalCA, originalPA, (Deployment)outputModel, mapping); - - // Re-enable Notifications & the Annotation view update. - EMFModelConcurrencyHandler.getInstance().tryEnableNotificationsSyncOf(outputModel); - - return (Deployment)outputModel; - } - - /** - * Allocates {@link Component}s to {@link ExecutionUnit}s using the given {@link Map}. This - * methods uses the DeploymentUtils and returns a {@link ComponentAllocation} that can be - * processed in an AF3 compatible {@link Deployment}. - */ - private List<ComponentAllocation> allocateComponentsToExecutionUnits( - IMappingEncoding mappingEncoding) { - List<ComponentAllocation> componentToExecutionUnitAllocations = - new ArrayList<ComponentAllocation>(); - for(IMappingEntry curEntry : mappingEncoding.getIMappingEntries()) { - Component curComponent = - (Component)encEntryModelElemAssoc.get(curEntry, Component.class); - // If the given entry is unknown, we examine the associated entries since the - // association may be based on some other relevant entry. This is the case for - // replication that is performed for abstract entries while we have instantiated entries - // here. - if(curComponent == null) { - for(IMappingEntry assocEntry : curEntry.getAssociatedElement()) { - curComponent = - (Component)encEntryModelElemAssoc.get(assocEntry, Component.class); - if(curComponent != null) { - curEntry = assocEntry; - break; - } - } - } - - ExecutionUnit curExecUnit = (ExecutionUnit)curEntry.getTarget().getObject(); - assert (curComponent != null && curExecUnit != null); - componentToExecutionUnitAllocations.add(createComponentAllocation(curComponent, - curExecUnit)); - } - return componentToExecutionUnitAllocations; - } - - /** - * Creates the deployment parameter map for the given {@link Deployment} by copying this map - * from an existing deployment in the {@link FileProject}. The map is extended to consider - * replica of {@link Component}s if required. - */ - // TODO: how to handle instantiated components? - private void createDeploymentParameterMap(ComponentArchitecture originalCA, - PlatformArchitecture originalPA, Deployment deployment, IMappingEncoding mapping) { - List<Deployment> allDeploymentsWithParameters = - getDeploymentsWithParametersOf(originalCA, originalPA); - - // Get the referenced Component Pool of the original Component Architecture & the deployment - // specific parameters. - ComponentArchitecture compPool = getFirstComponentPool(mapping); - List<Deployment> poolParameterDeployments = - getDeploymentsWithParametersOf(compPool, originalPA); - - if(allDeploymentsWithParameters.size() > 0) { - // Pick the first deployments with a matching parameter map. - Deployment deploymentWithParameters = allDeploymentsWithParameters.get(0); - Deployment poolParameterDeployment = null; - if(poolParameterDeployments.size() > 0) { - poolParameterDeployment = poolParameterDeployments.get(0); - } - - // For transformed components that were part of the "actual" CA. - fillDeploymentParameterMap(deployment, deploymentWithParameters); - // For transformed components that are instantiated from a "Component Pool". - fillDeploymentParameterMap(deployment, poolParameterDeployment); - } - } - - /** Adds the map of deployment specific parameters to the transformed {@link Deployment} model. */ - private void fillDeploymentParameterMap(Deployment deployment, Deployment paramDeployment) { - if(paramDeployment == null) { - return; - } - - for(Entry<DeploymentParameterKey, DeploymentParameterValue> deploymentParameter : paramDeployment - .getDeploymentParameterMap().entrySet()) { - DeploymentParameterValue value = deploymentParameter.getValue(); - Component parameterComponent = value.getComponent(); - - for(EObject genComp : origToGenAssocMap.get(parameterComponent)) { - replicateDeploymentParameterEntry(deployment, value, (Component)genComp); - } - } - } - - /** - * Creates a new key, copies and adjust the parameter value, and inserts it into the parameter - * map. - */ - private void replicateDeploymentParameterEntry(Deployment deployment, - DeploymentParameterValue parameterValue, Component component) { - DeploymentParameterKey replicaKey = - DeploymentModelElementFactory.createDeploymentParameterKey(component, - parameterValue.getExecutionUnit()); - DeploymentParameterValue copiedValue = EcoreUtils.copy(parameterValue); - copiedValue.setComponent(component); - resetIds(copiedValue); - deployment.getDeploymentParameterMap().put(replicaKey, copiedValue); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentInitializer.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentInitializer.java deleted file mode 100644 index 3264c03eaa740ce784f1cd7f834ed4e0e9f7f32f..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentInitializer.java +++ /dev/null @@ -1,147 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DeploymentInitializer.java 3561 2016-09-23 14:22:56Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.deployment; - -import static org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState.INITIALIZING; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.deployment.model.AF3DeploymentFactory; -import org.fortiss.af3.deployment.model.ComponentArchitectureReference; -import org.fortiss.af3.deployment.model.Deployment; -import org.fortiss.af3.deployment.model.PlatformArchitectureReference; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.EMFModelConcurrencyHandler; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationModuleBase; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; -import org.fortiss.af3.platform.model.PlatformArchitecture; - -/** - * Initializes a {@link Deployment} by creating a new model and setting its references to the given - * {@link ComponentArchitecture} and {@link PlatformArchitecture}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3561 $ - * @ConQAT.Rating RED Hash: 13F29ADB2E9292ADF060C64876B12389 - */ -public class DeploymentInitializer extends TransformationModuleBase<Deployment> { - - /** {@inheritDoc} */ - @Override - public Class<Deployment> getOutputType() { - return Deployment.class; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(ComponentArchitecture.class); - inputTypes.add(PlatformArchitecture.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { - Collection<Class<? extends ITransformationModule<?>>> parentModules = new HashSet<>(); - parentModules.add(ExplorationSolutionToDeployment.class); - return parentModules; - } - - /** {@inheritDoc} */ - @Override - public boolean isOptional() { - return false; - } - - /** {@inheritDoc} */ - @Override - public TransformationState getActivationStage() { - return INITIALIZING; - } - - /** {@inheritDoc} */ - @Override - public <N extends EObject, S extends EObject> Deployment transform(TransformationState state, - TransformationContext context, SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException { - ComponentArchitecture originalCA = - (ComponentArchitecture)baseModels.get(ComponentArchitecture.class); - if(originalCA == null) { - throw new TransformationModuleException( - this, - "Could not retrieve the original component architecture from the set of base models. Be sure to add it to the required input types."); - } - - PlatformArchitecture originalPA = - (PlatformArchitecture)baseModels.get(PlatformArchitecture.class); - if(originalPA == null) { - throw new TransformationModuleException( - this, - "Could not retrieve the original platform architecture from the set of base models. Be sure to add it to the required input types."); - } - - outputModel = createDeployment("Deployment", null, originalPA); - - return (Deployment)outputModel; - } - - /** - * Creates a {@link Deployment} model without requiring a model context (the bi-references do - * not notify the referenced model element). - */ - private Deployment createDeployment(String name, ComponentArchitecture compArch, - PlatformArchitecture platArch) { - Deployment deployment = AF3DeploymentFactory.eINSTANCE.createDeployment(); - deployment.setName(name); - - if(compArch != null) { - ComponentArchitectureReference caRef = - AF3DeploymentFactory.eINSTANCE.createComponentArchitectureReference(); - EMFModelConcurrencyHandler.getInstance().setReference(caRef, compArch); - deployment.setComponentArchitectureReference(caRef); - } - - if(platArch != null) { - PlatformArchitectureReference paRef = - AF3DeploymentFactory.eINSTANCE.createPlatformArchitectureReference(); - EMFModelConcurrencyHandler.getInstance().setReference(paRef, platArch); - deployment.setPlatformArchitectureReference(paRef); - } - - return deployment; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentReplicator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentReplicator.java deleted file mode 100644 index 065fe0c0fa96db879fc8a3ce7c56278c3c59878f..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentReplicator.java +++ /dev/null @@ -1,116 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DeploymentReplicator.java 3561 2016-09-23 14:22:56Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.deployment; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.deployment.model.Deployment; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationModuleBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; -import org.fortiss.af3.platform.model.PlatformArchitecture; - -/** - * Replicates the entries of the deployment parameter table such that every {@link IMappingEntry} - * indicating the replication of a {@link Component} also has a counterpart describing its - * deployment specific parameters in the table. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3561 $ - * @ConQAT.Rating RED Hash: 669DE68E282331C843578F1B689FC00B - */ -public class DeploymentReplicator extends TransformationModuleBase<Deployment> { - - /** {@inheritDoc} */ - @Override - public Class<Deployment> getOutputType() { - return Deployment.class; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(ComponentArchitecture.class); - inputTypes.add(PlatformArchitecture.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { - Collection<Class<? extends ITransformationModule<?>>> parentModules = new HashSet<>(); - parentModules.add(ExplorationSolutionToDeployment.class); - return parentModules; - } - - /** {@inheritDoc} */ - @Override - public boolean isOptional() { - return false; - } - - /** {@inheritDoc} */ - @Override - public TransformationState getActivationStage() { - return TransformationState.REPLICATED; - } - - /** {@inheritDoc} */ - @Override - public <N extends EObject, S extends EObject> Deployment transform(TransformationState state, - TransformationContext context, SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException { - ComponentArchitecture originalCA = - (ComponentArchitecture)baseModels.get(ComponentArchitecture.class); - if(originalCA == null) { - throw new TransformationModuleException( - this, - "Could not retrieve the original component architecture from the set of base models. Be sure to add it to the required input types."); - } - - PlatformArchitecture originalPA = - (PlatformArchitecture)baseModels.get(PlatformArchitecture.class); - if(originalPA == null) { - throw new TransformationModuleException( - this, - "Could not retrieve the original platform architecture from the set of base models. Be sure to add it to the required input types."); - } - - return (Deployment)outputModel; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/ExplorationSolutionToDeployment.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/ExplorationSolutionToDeployment.java deleted file mode 100644 index 3f63a92bb051c749db1623714ef4765b8cfac8c7..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/ExplorationSolutionToDeployment.java +++ /dev/null @@ -1,185 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExplorationSolutionToDeployment.java 3561 2016-09-23 14:22:56Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.deployment; - -import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.getPhysicalPlatformArchitecture; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.deployment.model.Deployment; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.InstantiatedTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationStrategyBase; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch.ComponentArchitectureTransformer; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; -import org.fortiss.af3.platform.model.PlatformArchitecture; - -/** - * Responsible for generating a {@link Deployment} that is compatible with the Deployment-plugin. - * Thus, a Component -> Platform mapping resulting form the DSE can viewed and edited within the - * {@link Deployment} editor. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3561 $ - * @ConQAT.Rating RED Hash: 18833446FE89D6A93B1DD8644415C72E - */ -public class ExplorationSolutionToDeployment extends TransformationStrategyBase<Deployment> { - - /** - * References the {@link ComponentArchitecture} that has been mapped onto a - * {@link PlatformArchitecture}. - */ - private ComponentArchitecture af3ComponentArchitecture; - - /** References the {@link PlatformArchitecture} for which this solution was generated. */ - private PlatformArchitecture af3PlatformArchitecture; - - /** - * Helper method to set the architecture model references that were provided as an input to the - * DSE. - */ - private <S extends EObject> void setArchModels(Map<Class<? extends S>, S> baseModels) - throws TransformationModuleException { - af3ComponentArchitecture = - (ComponentArchitecture)baseModels.get(ComponentArchitecture.class); - if(af3ComponentArchitecture == null) { - throw new TransformationModuleException(this, - "An ComponentArchitecture is required for this module to operate properly."); - } - - af3PlatformArchitecture = (PlatformArchitecture)baseModels.get(PlatformArchitecture.class); - if(af3PlatformArchitecture == null) { - throw new TransformationModuleException(this, - "An PlatformArchitecture is required for this module to operate properly."); - } - getPhysicalPlatformArchitecture(af3PlatformArchitecture); - } - - /** - * {@inheritDoc} - * - * @throws TransformationModuleException - * see {@link ITransformationModule}. - */ - @Override - public <N extends EObject, S extends EObject> Deployment transform(TransformationState state, - TransformationContext context, SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException { - if(state == TransformationState.INITIALIZING) { - IMappingEncoding mapping = explorationEncodings.getEncoding(IMappingEncoding.class); - if(mapping == null) { - throw new TransformationModuleException(this, - "An IMappingEncoding is required for this module to operate properly."); - } - - if(!isAdditionalArchRequiredByReplication(mapping) && - !isAdditionalArchRequiredByInstantiation(mapping)) { - addBlacklistedModule(ComponentArchitectureTransformer.class); - } - - setArchModels(baseModels); - } - - return super.transform(state, context, baseModels, explorationEncodings, transformedModels, - outputModel); - } - - /** - * Predicate if replicas were generated and hence a modified {@link ComponentArchitecture} must - * be generated that is shipped with the generated {@link Deployment}. - */ - // TODO: Use "Component" as Generic. - private boolean isAdditionalArchRequiredByReplication(IMappingEncoding mapping) { - for(IDeployableComponentAdapter<?> deployedComponent : mapping.getDeployedComponents()) { - if(mapping.getAllocatedResourcesFor(deployedComponent).size() > 1) { - return true; - } - } - return false; - } - - /** - * Predicate if "abstract" {@link Component}s were generated and hence a modified - * {@link ComponentArchitecture} must be generated that is shipped with the generated - * {@link Deployment}. - */ - // TODO: Use "Component" as Generic. - private boolean isAdditionalArchRequiredByInstantiation(IMappingEncoding mapping) { - for(IDeployableComponentAdapter<?> deployedComponent : mapping.getDeployedComponents()) { - if(deployedComponent.isInstantiation()) { - return true; - } - } - return false; - } - - /** {@inheritDoc} */ - @Override - public Class<Deployment> getOutputType() { - return Deployment.class; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> inputTypes = new HashSet<>(); - inputTypes.add(ComponentArchitecture.class); - inputTypes.add(PlatformArchitecture.class); - inputTypes.add(InstantiatedTaskMappingEncoding.class); - return inputTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public boolean isOptional() { - return false; - } - - /** {@inheritDoc} */ - @Override - public TransformationState getActivationStage() { - return TransformationState.INITIALIZING; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/element/IElementTransformationModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/element/IElementTransformationModule.java deleted file mode 100644 index 64745e90ad7b1c9dd564cdb8eeb8bd862b14ce41..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/element/IElementTransformationModule.java +++ /dev/null @@ -1,74 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IElementTransformationModule.java 3483 2016-09-09 16:41:40Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.element; - -import java.util.Map; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.graph.IDependencyModule; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; - -/** - * Interface for operations that are common to all Element Generation/Transformation Modules. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3483 $ - * @ConQAT.Rating RED Hash: B11A9819E70AA8E7ADFB2E3C1E09F368 - */ -public interface IElementTransformationModule<T extends EObject, O extends EObject> extends - ITransformationModule<T>, IDependencyModule<T, T> { - - /** Returns the Class (type) on which a concrete module operates. */ - Class<T> getElementClass(); - - /** - * Returns the Class (type) that contains the elements on which {@code this} - * {@link IElementTransformationModule} operates. - */ - Class<O> getElementContainerType(); - - /** - * Performs a model transformation for the given model element. For the transofrmation, the - * additional inputs can be used. - * - * @param inputElement - * Model element to be transformed. - * @param baseModels - * Set of (original) base models. - * @param explorationEncodings - * Encodings calculated by the DSE. - * @param transformedModels - * Set of transformed/already manipulated models. - * @return Identical to {@code outputModel}. - * @throws TransformationModuleException - * If any operation during the transformation of the given model element fails. - */ - // TODO: update method doc. - // TODO: use the generic 'T' to specify the parameter 'inputElement'. EObject has been chosen - // for now to avoid a compile error in ElementTransformtationStrategy for now but this - // workaround is not type safe. - <N extends EObject, S extends EObject> O transformElement(EObject inputElement, - Map<Class<? extends S>, S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - Map<Class<? extends N>, N> transformedModels, O outputModel) - throws TransformationModuleException; -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/element/M2MCopier.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/element/M2MCopier.java deleted file mode 100644 index f361aa9af66a55465a9f19da4940675f262bfa58..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/element/M2MCopier.java +++ /dev/null @@ -1,64 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: M2MCopier.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.element; - -import static org.fortiss.tooling.kernel.utils.EcoreUtils.addAll; - -import java.util.LinkedHashMap; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.util.EcoreUtil.Copier; - -/** - * {@link Copier} that is actually a copy of the "HackedCopied" from the EcoreUtils, but is public. - * It allows to access the correspondence map from original to copied elements (A {@link Copier} is - * a {@link LinkedHashMap} . - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: C02E7A05F42DC56E95E6E04D77E47631 - */ -public class M2MCopier extends Copier { - - // TODO: Instead of duplicating the HackedCopier code here, the Hacked copier should be made - // public and the M2MCpoier should inherit from this one. - /** {@inheritDoc} */ - @Override - protected void copyContainment(EReference eReference, EObject eObject, EObject copyEObject) { - if(eObject.eIsSet(eReference)) { - if(eReference.isMany()) { - @SuppressWarnings("unchecked") List<EObject> source = - (List<EObject>)eObject.eGet(eReference); - @SuppressWarnings("unchecked") List<EObject> target = - (List<EObject>)copyEObject.eGet(getTarget(eReference)); - if(source.isEmpty()) { - target.clear(); - } else { - addAll(target, copyAll(source)); - } - } else { - EObject childEObject = (EObject)eObject.eGet(eReference); - copyEObject.eSet(getTarget(eReference), childEObject == null ? null - : copy(childEObject)); - } - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/graph/ElementModuleDependencyGraph.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/graph/ElementModuleDependencyGraph.java deleted file mode 100644 index 079aa3a943abd4dbe7968fe224bffb104bc2d92e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/graph/ElementModuleDependencyGraph.java +++ /dev/null @@ -1,55 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.graph; - -import java.util.Comparator; -import java.util.Set; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.element.IElementTransformationModule; -import org.fortiss.af3.exploration.alg.graph.DependencyGraph; - -/** - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 62D039E116387664688AC5C1C77105FA - */ -public class ElementModuleDependencyGraph<O extends EObject> - extends - DependencyGraph<EObject, IElementTransformationModule<EObject, O>, ElementTransformationModuleEdge<EObject, O>> { - - /** Constructor. */ - public ElementModuleDependencyGraph(Set<Class<? extends EObject>> reqTypeCollection, - Class<? extends EObject> vertexType) { - super(reqTypeCollection, vertexType); - } - - /** {@inheritDoc} */ - @Override - protected void checkMissingDependencies() { - // TODO Auto-generated method stub: Not yet implemented. - } - - /** {@inheritDoc} */ - @Override - protected Comparator<IElementTransformationModule<EObject, O>> getSubExecListComparator() { - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/graph/ElementTransformationModuleEdge.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/graph/ElementTransformationModuleEdge.java deleted file mode 100644 index 55a16d43e1c90dbd155ebed2faf7d046984d5d04..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/graph/ElementTransformationModuleEdge.java +++ /dev/null @@ -1,36 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.graph; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.element.IElementTransformationModule; -import org.fortiss.af3.exploration.alg.graph.DependencyEdge; - -/** - * Wrapper for the edges in the {@link ElementModuleDependencyGraph} --> - * {@link IElementTransformationModule}s. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 009035FE7A7B34CBDF8648C5B288513F - */ -public class ElementTransformationModuleEdge<T extends EObject, O extends EObject> extends - DependencyEdge<IElementTransformationModule<T, O>> { - // No implementation required, just used in the corresponding graph. -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyChannelPortReplicator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyChannelPortReplicator.java deleted file mode 100644 index 6cad3a10ef91757b59429e74ac9cd470a11adb08..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyChannelPortReplicator.java +++ /dev/null @@ -1,143 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.safety; - -import static org.fortiss.af3.exploration.alg.util.TransformationUtils.replicateInputPortAndAttach; -import static org.fortiss.tooling.common.util.LambdaUtils.filterSet; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Channel; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.component.model.InputPort; -import org.fortiss.af3.component.model.OutputPort; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEntry; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationModuleBase; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch.ComponentArchitectureTransformer; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; - -/** - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: C027673BF2CA40B93BCFFB8C2D848554 - */ -public class SafetyChannelPortReplicator extends TransformationModuleBase<ComponentArchitecture> { - - /** {@inheritDoc} */ - @Override - public boolean isOptional() { - return true; - } - - /** {@inheritDoc} */ - @Override - public ITransformationModule.TransformationState getActivationStage() { - return TransformationState.INSTANTIATED; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { - Collection<Class<? extends ITransformationModule<?>>> parentModules = new HashSet<>(); - parentModules.add(ComponentArchitectureTransformer.class); - return parentModules; - } - - /** {@inheritDoc} */ - @Override - public <N extends EObject, S extends EObject> ComponentArchitecture transform( - ITransformationModule.TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) { - @SuppressWarnings("unchecked") SafetyFunctionArchEncoding<Component> sfaEnc = - explorationEncodings.getEncoding(SafetyFunctionArchEncoding.class); - - Collection<Component> sfComponents = new HashSet<>(); - for(SafetyFunctionArchEntry<Component> sfaEntry : sfaEnc.getAllEntries()) { - Collection<IDeployableComponentAdapter<Component>> entryCompAdps = - sfaEntry.getSafetyFunctionAdapter().getAllComponents(); - entryCompAdps.forEach(c -> sfComponents.add(c.getObject())); - } - - Collection<OutputPort> sfOutPorts = new HashSet<>(); - sfComponents.forEach(c -> sfOutPorts.addAll(c.getOutputPorts())); - - Collection<InputPort> connectedInputPorts = new HashSet<>(); - for(OutputPort curOutPort : sfOutPorts) { - curOutPort.getOutgoingChannels().forEach( - ch -> connectedInputPorts.add((InputPort)ch.getTarget())); - } - - Collection<InputPort> nonSfInputPorts = - filterSet(connectedInputPorts, p -> !sfComponents.contains(p.getComponent())); - for(InputPort inPort : nonSfInputPorts) { - Collection<EObject> genPorts = origToGenAssocMap.get(inPort); - assert (genPorts.size() == 1); - inPort = (InputPort)genPorts.stream().findAny().get(); - List<Channel> incomingChannels = inPort.getIncomingChannels(); - for(int chIdx = 1; chIdx < incomingChannels.size(); chIdx++) { - char suffix = (char)(chIdx - 1 + 'a'); - InputPort genPort = - replicateInputPortAndAttach(inPort, inPort.getComponent(), - inPort.getName() + "_" + suffix); - Channel curCh = incomingChannels.get(chIdx); - curCh.setTarget(genPort); - InputPort origPort = (InputPort)genToOrigAssocMap.get(inPort); - genToOrigAssocMap.put(genPort, origPort); - origToGenAssocMap.put(origPort, genPort); - } - } - - return (ComponentArchitecture)outputModel; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> requiredTypes = new HashSet<>(); - requiredTypes.add(ComponentArchitecture.class); - requiredTypes.add(SafetyFunctionArchEncoding.class); - return requiredTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public Class<? super ComponentArchitecture> getOutputType() { - return ComponentArchitecture.class; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyDiagUnitRemover.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyDiagUnitRemover.java deleted file mode 100644 index 4c16a2c79ef7bc4af929890506115e529f77a0e8..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/safety/SafetyDiagUnitRemover.java +++ /dev/null @@ -1,150 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.modeltransformation.safety; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Channel; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEntry; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.base.TransformationModuleBase; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.comparch.ComponentArchitectureTransformer; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService.TransformationContext; - -/** - * Module that deletes diagnostic {@link Component}s from a generated {@link ComponentArchitecture} - * if diagnostic units were not selected by the DSE for some safety function. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: DDAA602872ECECEBBE8D47728CB98F3F - */ -public class SafetyDiagUnitRemover extends TransformationModuleBase<ComponentArchitecture> { - - /** {@inheritDoc} */ - @Override - public Class<ComponentArchitecture> getOutputType() { - return ComponentArchitecture.class; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getRequiredTypes() { - Collection<Class<?>> inputModelTypes = new HashSet<>(); - inputModelTypes.add(ComponentArchitecture.class); - inputModelTypes.add(SafetyFunctionArchEncoding.class); - return inputModelTypes; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<?>> getOptionalTypes() { - return Collections.emptySet(); - } - - /** {@inheritDoc} */ - @Override - public boolean isOptional() { - return true; - } - - /** {@inheritDoc} */ - @Override - public TransformationState getActivationStage() { - return TransformationState.INITIALIZED; - } - - /** {@inheritDoc} */ - @Override - public Collection<Class<? extends ITransformationModule<?>>> getParentModules() { - Collection<Class<? extends ITransformationModule<?>>> parentModuleTypes = new HashSet<>(); - parentModuleTypes.add(ComponentArchitectureTransformer.class); - return parentModuleTypes; - } - - /** {@inheritDoc} */ - @Override - public <N extends EObject, S extends EObject> ComponentArchitecture transform( - TransformationState state, TransformationContext context, - SubClassToInstanceMap<S> baseModels, - ExplorationEncodingMap<IExplorationEncoding> explorationEncodings, - SubClassToInstanceMap<N> transformedModels, EObject outputModel) - throws TransformationModuleException { - ComponentArchitecture genCA = (ComponentArchitecture)outputModel; - if(genCA == null) { - throw new TransformationModuleException(this, - "Could not retrieve the generated Component Architecture."); - } - - @SuppressWarnings("unchecked") SafetyFunctionArchEncoding<Component> sfaEnc = - explorationEncodings.getEncoding(SafetyFunctionArchEncoding.class); - if(sfaEnc == null) { - throw new TransformationModuleException(this, - "A SafetyFunctionArchEncoding is required for this module to operate properly."); - } - - for(SafetyFunctionArchEntry<Component> sfaEntry : sfaEnc.getAllEntries()) { - if(!sfaEntry.isDiagnosicUnitPresent()) { - for(IDeployableComponentAdapter<Component> diagCompAdp : sfaEntry - .getSafetyFunctionAdapter().getDiagnosticComponents()) { - for(EObject genDiagComponent : origToGenAssocMap.get(diagCompAdp.getObject())) { - if(!(genDiagComponent instanceof Component)) { - throw new TransformationModuleException(this, "The generated element " + - genDiagComponent + - " in the generated ComponentArchitectureis not a 'Component' as it is expected."); - } - - // Get all channels connected to the current diagnostic Component. - Collection<Channel> genChannels = new ArrayList<>(); - ((Component)genDiagComponent).getInputPorts().forEach( - p -> genChannels.addAll(p.getIncomingChannels())); - ((Component)genDiagComponent).getOutputPorts().forEach( - p -> genChannels.addAll(p.getOutgoingChannels())); - // Remove all ports from Components which are connected to the diagnostic - // Component. Can be included if needed. NOTE: Instantiated components will - // introduce the "same" Port again. - // genChannels.stream().map(ch -> ch.getTarget()) - // .filter(p -> p.getOwner() != genDiagComponent) - // .forEach(c -> removeGenModelElement(c)); - // genChannels.stream().map(ch -> ch.getSource()) - // .filter(p -> p.getOwner() != genDiagComponent) - // .forEach(c -> removeGenModelElement(c)); - // Remove all Channels connected to the diagnostic Component. - genChannels.forEach(ch -> removeGenModelElement(ch)); - - removeGenModelElement(genDiagComponent); - } - } - } - } - return genCA; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FailSilentExecModelFactory.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FailSilentExecModelFactory.java deleted file mode 100644 index 4118f967f83e3648e58eb00d06181d7cacc4de25..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FailSilentExecModelFactory.java +++ /dev/null @@ -1,284 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FailSilentExecModelFactory.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel; - -import org.fortiss.af3.exploration.alg.dse.TaskMappingFactory; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.FailSilentTaskMappingCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.TaskMappingCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FailSilentTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FailSilentTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph.DecoderDependencyGraph; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover.CrossoverRandManyAllocation; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover.CrossoverSingleAllocation; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping.MutateAllocation; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping.MutateRedundancyDecrement; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping.MutateRedundancyIncrement; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.EvaluatorWrapper; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.StrictTTDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.comm.MessageDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatemapping.AbstractTaskMappingDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatemapping.FailSilentAbstractTaskMappingDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatetaskgraph.InstantiatedTaskMappingDecoderAcyclic; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule; -import org.fortiss.af3.exploration.alg.dse.evaluator.constraint.ComponentMultiAllocationConstraintEvaluator; -import org.fortiss.af3.exploration.alg.dse.evaluator.constraint.ComponentMultiDislocationConstraintEvaluator; -import org.fortiss.af3.exploration.alg.dse.evaluator.constraint.DeadlineConstraintEvaluator; -import org.fortiss.af3.exploration.alg.dse.evaluator.constraint.PeriodConstraintEvaluator; -import org.fortiss.af3.exploration.alg.dse.evaluator.constraint.SafetyIntegrityLevelConstraintEvaluator; -import org.fortiss.af3.exploration.alg.dse.evaluator.objective.FailSilentReliabilityEvaluator; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.sched.proc.EDFSchedulerBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.sched.proc.FailSilentEDFScheduler; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.time.DeadlineConstraint; -import org.fortiss.af3.exploration.model.time.PeriodConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiAllocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiDislocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.FailureMinObjective; -import org.fortiss.af3.exploration.moea.model.predefined.SafetyIntegrityLevelConstraint; -import org.fortiss.af3.safety.model.SIL; - -import com.google.inject.TypeLiteral; - -/** - * This class implements the creation of the EavaluatorWrapper for the fail silent execution model. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: E60F5831E0DBB0953D44C7EB29E08368 - */ -public class FailSilentExecModelFactory extends - TaskMappingFactory<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> { - - /** The instance (singleton) of the EvaluatorWrapper factory. */ - public static TaskMappingFactory<?, ?> getInstance() { - if(instance == null) { - instance = new FailSilentExecModelFactory(); - } - return instance; - } - - /* - * Construct Creators for the task mapping - */ - - /** {@inheritDoc} */ - @Override - public TypeLiteral<FailSilentTaskMappingEncoding> createGenotypeTypeLiteral() { - return new TypeLiteral<FailSilentTaskMappingEncoding>() { - // Anonymous. - }; - } - - /** Creates a TaskMappingCreator that matches the given execution model. */ - @Override - public TaskMappingCreator<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> - createTaskMappingCreator(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execDepGraph) { - return new FailSilentTaskMappingCreator(expSpec, systemModelAdapter, execDepGraph); - } - - /* - * Construct execution model specific operators - */ - - /** {@inheritDoc} */ - @Override - public MutateAllocation<?, ?> createMutateAllocationOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new MutateAllocation<AbstractTaskMappingEntry, AbstractTaskMappingEncoding>( - systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public MutateRedundancyDecrement<?, ?> createMutateRedundancyDecrementOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new MutateRedundancyDecrement<AbstractTaskMappingEntry, AbstractTaskMappingEncoding>( - systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public MutateRedundancyIncrement<?, ?> createMutateRedundancyIncrementOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new MutateRedundancyIncrement<AbstractTaskMappingEntry, AbstractTaskMappingEncoding>( - systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public CrossoverRandManyAllocation<?, ?> createCrossoverRandManyAllocationOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, double rate) { - return new CrossoverRandManyAllocation<AbstractTaskMappingEntry, AbstractTaskMappingEncoding>( - systemModelAdapter, rate); - } - - /** {@inheritDoc} */ - @Override - public CrossoverSingleAllocation<?, ?> createCrossoverSingleAllocationOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, double rate) { - return new CrossoverSingleAllocation<AbstractTaskMappingEntry, AbstractTaskMappingEncoding>( - systemModelAdapter, rate); - } - - /* - * Construct Decoders for the genotypes, aka task mappings. - */ - - /** {@inheritDoc} */ - @Override - public AbstractTaskMappingDecoder<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> - createAbstractTaskMappingDecoder( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - return new FailSilentAbstractTaskMappingDecoder(systemModelAdapter, expSpec); - } - - /** {@inheritDoc} */ - @SuppressWarnings({"rawtypes", "unchecked"}) - @Override - // TODO: identify why a warning is generated here. - public - InstantiatedTaskMappingDecoderAcyclic<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> - createAbstractToAcyclicTaskGraphDecoder( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new InstantiatedTaskMappingDecoderAcyclic(systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public MessageDecoder<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> - createMessageDecoder(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new MessageDecoder<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>( - systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public StrictTTDecoder<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> - createStrictTTDecoder(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - return new StrictTTDecoder<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>( - systemModelAdapter, expSpec); - } - - /** - * Creates an basic EDF scheduler that is used to decode task mappings into schedules for the - * given execution model - */ - @Override - public EDFSchedulerBase<?, ?> createEDFScheduler( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - return new FailSilentEDFScheduler(systemModelAdapter, expSpec); - } - - /* - * Construct Evaluators for Optimization Goals - */ - - /** {@inheritDoc} */ - @Override - @SuppressWarnings("unchecked") - public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, FailureMinObjective> - createFailureMinObjectiveWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - return new EvaluatorWrapper<StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>, Double, FailureMinObjective>( - (FailureMinObjective)goal, - new FailSilentReliabilityEvaluator(systemModelAdapter, (FailureMinObjective)goal), - priority, - (Class<? extends StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>>)StrictTTSchedule.class); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, DeadlineConstraint> - createDeadlineConstraintWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - return new EvaluatorWrapper<StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>, Double, DeadlineConstraint>( - (DeadlineConstraint)goal, - new DeadlineConstraintEvaluator<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>( - systemModelAdapter, (DeadlineConstraint)goal), - priority, - (Class<? extends StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>>)StrictTTSchedule.class); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, PeriodConstraint> - createPeriodConstraintWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - return new EvaluatorWrapper<StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>, Double, PeriodConstraint>( - (PeriodConstraint)goal, - new PeriodConstraintEvaluator<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>( - systemModelAdapter, (PeriodConstraint)goal), - priority, - (Class<? extends StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>>)StrictTTSchedule.class); - } - - /** {@inheritDoc} */ - // TODO: adjust when the constraint is defined for mappings. - @Override - public <RT, ET extends ExplorationTarget<RT>> - EvaluatorWrapper<?, Boolean, ComponentMultiAllocationConstraint> - createComponentMultiAllocationConstraintWrapper(ExplorationTarget<?> goal, - int priority, SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws Exception { - return new EvaluatorWrapper<FailSilentTaskMappingEncoding, Boolean, ComponentMultiAllocationConstraint>( - (ComponentMultiAllocationConstraint)goal, - new ComponentMultiAllocationConstraintEvaluator<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>( - systemModelAdapter, (ComponentMultiAllocationConstraint)goal), priority, - FailSilentTaskMappingEncoding.class); - } - - /** {@inheritDoc} */ - // TODO: adjust when the constraint is defined for mappings. - @Override - public <RT, ET extends ExplorationTarget<RT>> - EvaluatorWrapper<?, Boolean, ComponentMultiDislocationConstraint> - createComponentMultiDislocationConstraintWrapper(ExplorationTarget<?> goal, - int priority, SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws Exception { - return new EvaluatorWrapper<FailSilentTaskMappingEncoding, Boolean, ComponentMultiDislocationConstraint>( - (ComponentMultiDislocationConstraint)goal, - new ComponentMultiDislocationConstraintEvaluator<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>( - systemModelAdapter, (ComponentMultiDislocationConstraint)goal), priority, - FailSilentTaskMappingEncoding.class); - } - - /** {@inheritDoc} */ - @Override - public <RT, ET extends ExplorationTarget<RT>> - EvaluatorWrapper<?, SIL, SafetyIntegrityLevelConstraint> - createSafetyIntegrityLevelConstraintWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - return new EvaluatorWrapper<FailSilentTaskMappingEncoding, SIL, SafetyIntegrityLevelConstraint>( - (SafetyIntegrityLevelConstraint)goal, - new SafetyIntegrityLevelConstraintEvaluator<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding>( - systemModelAdapter, (SafetyIntegrityLevelConstraint)goal), priority, - FailSilentTaskMappingEncoding.class); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FaultDetectionVotingExecModelFactory.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FaultDetectionVotingExecModelFactory.java deleted file mode 100644 index bfcbdb70e7b6e7cc0a5a963958a444a5a04bc28e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/FaultDetectionVotingExecModelFactory.java +++ /dev/null @@ -1,288 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FaultDetectionVotingExecModelFactory.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel; - -import org.fortiss.af3.exploration.alg.dse.TaskMappingFactory; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.FaultDetectionVotingTaskMappingCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.create.taskmapping.TaskMappingCreator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FaultDetectionVotingTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FaultDetectionVotingTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.graph.DecoderDependencyGraph; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover.CrossoverRandManyAllocation; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.crossover.CrossoverSingleAllocation; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping.MutateAllocation; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping.MutateRedundancyDecrement; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.operator.mutate.taskmapping.MutateRedundancyIncrement; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.EvaluatorWrapper; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.StrictTTDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.comm.MessageDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatemapping.AbstractTaskMappingDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatemapping.FaultDetectionVotingAbstractTaskMappingDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.instantiatetaskgraph.InstantiatedTaskMappingDecoderAcyclic; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule; -import org.fortiss.af3.exploration.alg.dse.evaluator.constraint.ComponentMultiAllocationConstraintEvaluator; -import org.fortiss.af3.exploration.alg.dse.evaluator.constraint.ComponentMultiDislocationConstraintEvaluator; -import org.fortiss.af3.exploration.alg.dse.evaluator.constraint.DeadlineConstraintEvaluator; -import org.fortiss.af3.exploration.alg.dse.evaluator.constraint.PeriodConstraintEvaluator; -import org.fortiss.af3.exploration.alg.dse.evaluator.constraint.SafetyIntegrityLevelConstraintEvaluator; -import org.fortiss.af3.exploration.alg.dse.evaluator.objective.FaultDetectionVotingReliabilityEvaluator; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.sched.proc.EDFSchedulerBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.sched.proc.FaultDetectionVotingEDFScheduler; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.time.DeadlineConstraint; -import org.fortiss.af3.exploration.model.time.PeriodConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiAllocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiDislocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.FailureMinObjective; -import org.fortiss.af3.exploration.moea.model.predefined.SafetyIntegrityLevelConstraint; -import org.fortiss.af3.safety.model.SIL; - -import com.google.inject.TypeLiteral; - -/** - * This class implements the creation of the EavaluatorWrapper for the fault detection by voting - * model. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: 216DDCD3E6B1DF7EE26DDE78A0ACB933 - */ -public class FaultDetectionVotingExecModelFactory - extends - TaskMappingFactory<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> { - - /** The instance (singleton) of the EvaluatorWrapper factory. */ - public static TaskMappingFactory<?, ?> getInstance() { - if(instance == null) { - instance = new FailSilentExecModelFactory(); - } - return instance; - } - - /* - * Construct Creators for the task mapping - */ - - /** {@inheritDoc} */ - @Override - public TypeLiteral<FaultDetectionVotingTaskMappingEncoding> createGenotypeTypeLiteral() { - return new TypeLiteral<FaultDetectionVotingTaskMappingEncoding>() { - // Anonymous. - }; - } - - /** Creates a TaskMappingCreator that matches the given execution model. */ - @Override - public - TaskMappingCreator<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> - createTaskMappingCreator(ExplorationSpecification expSpec, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - DecoderDependencyGraph execDepGraph) { - return new FaultDetectionVotingTaskMappingCreator(expSpec, systemModelAdapter, execDepGraph); - } - - /* - * Construct execution model specific operators - */ - - /** {@inheritDoc} */ - @Override - public MutateAllocation<?, ?> createMutateAllocationOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new MutateAllocation<AbstractTaskMappingEntry, AbstractTaskMappingEncoding>( - systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public MutateRedundancyDecrement<?, ?> createMutateRedundancyDecrementOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new MutateRedundancyDecrement<AbstractTaskMappingEntry, AbstractTaskMappingEncoding>( - systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public MutateRedundancyIncrement<?, ?> createMutateRedundancyIncrementOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new MutateRedundancyIncrement<AbstractTaskMappingEntry, AbstractTaskMappingEncoding>( - systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public CrossoverRandManyAllocation<?, ?> createCrossoverRandManyAllocationOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, double rate) { - return new CrossoverRandManyAllocation<AbstractTaskMappingEntry, AbstractTaskMappingEncoding>( - systemModelAdapter, rate); - } - - /** {@inheritDoc} */ - @Override - public CrossoverSingleAllocation<?, ?> createCrossoverSingleAllocationOperator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, double rate) { - return new CrossoverSingleAllocation<AbstractTaskMappingEntry, AbstractTaskMappingEncoding>( - systemModelAdapter, rate); - } - - /* - * Construct Decoders and Schedules for the genotypes, aka task mappings. - */ - - /** {@inheritDoc} */ - @Override - public - AbstractTaskMappingDecoder<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> - createAbstractTaskMappingDecoder( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - return new FaultDetectionVotingAbstractTaskMappingDecoder(systemModelAdapter, expSpec); - } - - /** {@inheritDoc} */ - @SuppressWarnings({"rawtypes", "unchecked"}) - @Override - // TODO: identify why a warning is generated here. - public - InstantiatedTaskMappingDecoderAcyclic<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> - createAbstractToAcyclicTaskGraphDecoder( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new InstantiatedTaskMappingDecoderAcyclic(systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public - MessageDecoder<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> - createMessageDecoder(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - return new MessageDecoder<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>( - systemModelAdapter); - } - - /** {@inheritDoc} */ - @Override - public - StrictTTDecoder<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> - createStrictTTDecoder(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - return new StrictTTDecoder<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>( - systemModelAdapter, expSpec); - } - - /** {@inheritDoc} */ - @Override - public EDFSchedulerBase<?, ?> createEDFScheduler( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - return new FaultDetectionVotingEDFScheduler(systemModelAdapter, expSpec); - } - - /* - * Construct Evaluators for Optimization Goals - */ - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, FailureMinObjective> - createFailureMinObjectiveWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - return new EvaluatorWrapper<StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>, Double, FailureMinObjective>( - (FailureMinObjective)goal, - new FaultDetectionVotingReliabilityEvaluator(systemModelAdapter, - (FailureMinObjective)goal), - priority, - (Class<? extends StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>>)StrictTTSchedule.class); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, DeadlineConstraint> - createDeadlineConstraintWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - return new EvaluatorWrapper<StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>, Double, DeadlineConstraint>( - (DeadlineConstraint)goal, - new DeadlineConstraintEvaluator<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>( - systemModelAdapter, (DeadlineConstraint)goal), - priority, - (Class<? extends StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>>)StrictTTSchedule.class); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public <RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<?, Double, PeriodConstraint> - createPeriodConstraintWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - return new EvaluatorWrapper<StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>, Double, PeriodConstraint>( - (PeriodConstraint)goal, - new PeriodConstraintEvaluator<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>( - systemModelAdapter, (PeriodConstraint)goal), - priority, - (Class<? extends StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>>)StrictTTSchedule.class); - } - - /** {@inheritDoc} */ - // TODO: adjust when the constraint is defined for mappings. - @Override - public <RT, ET extends ExplorationTarget<RT>> - EvaluatorWrapper<?, Boolean, ComponentMultiAllocationConstraint> - createComponentMultiAllocationConstraintWrapper(ExplorationTarget<?> goal, - int priority, SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws Exception { - return new EvaluatorWrapper<FaultDetectionVotingTaskMappingEncoding, Boolean, ComponentMultiAllocationConstraint>( - (ComponentMultiAllocationConstraint)goal, - new ComponentMultiAllocationConstraintEvaluator<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>( - systemModelAdapter, (ComponentMultiAllocationConstraint)goal), priority, - FaultDetectionVotingTaskMappingEncoding.class); - } - - /** {@inheritDoc} */ - // TODO: adjust when the constraint is defined for mappings. - @Override - public <RT, ET extends ExplorationTarget<RT>> - EvaluatorWrapper<?, Boolean, ComponentMultiDislocationConstraint> - createComponentMultiDislocationConstraintWrapper(ExplorationTarget<?> goal, - int priority, SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws Exception { - return new EvaluatorWrapper<FaultDetectionVotingTaskMappingEncoding, Boolean, ComponentMultiDislocationConstraint>( - (ComponentMultiDislocationConstraint)goal, - new ComponentMultiDislocationConstraintEvaluator<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>( - systemModelAdapter, (ComponentMultiDislocationConstraint)goal), priority, - FaultDetectionVotingTaskMappingEncoding.class); - } - - /** {@inheritDoc} */ - @Override - public <RT, ET extends ExplorationTarget<RT>> - EvaluatorWrapper<?, SIL, SafetyIntegrityLevelConstraint> - createSafetyIntegrityLevelConstraintWrapper(ExplorationTarget<?> goal, int priority, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - return new EvaluatorWrapper<FaultDetectionVotingTaskMappingEncoding, SIL, SafetyIntegrityLevelConstraint>( - (SafetyIntegrityLevelConstraint)goal, - new SafetyIntegrityLevelConstraintEvaluator<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding>( - systemModelAdapter, (SafetyIntegrityLevelConstraint)goal), priority, - FaultDetectionVotingTaskMappingEncoding.class); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ICommunicationResourceAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ICommunicationResourceAdapter.java deleted file mode 100644 index 4a42aaee0b1c5c03388cb80736b3ee645edc4e6d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ICommunicationResourceAdapter.java +++ /dev/null @@ -1,31 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ICommunicationResourceAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -/** - * A communication resource of the target platform. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 9BE602663942089732D0AE6F15487C7C - */ -public interface ICommunicationResourceAdapter<T> extends IResourceAdapter<T> { - /** Returns the power consumed by transfering a message of the given size via this resource. */ - public double getPower(long messageSizeInBits); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IDeployableComponentAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IDeployableComponentAdapter.java deleted file mode 100644 index 44c270e6fec9612ab0674de7c601f09dd0b2a491..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IDeployableComponentAdapter.java +++ /dev/null @@ -1,125 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IDeployableComponentAdapter.java 3096 2016-06-27 08:39:10Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -import java.util.Collection; - -import org.eclipse.emf.common.util.Enumerator; -import org.fortiss.af3.component.model.Component; - -/** - * Adapter between the deployable components (=tasks) of the system meta-model used in the modeling - * tool, and the DSE. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3096 $ - * @ConQAT.Rating RED Hash: 007670AB8CFB76B65557C8B71B489691 - */ -public interface IDeployableComponentAdapter<T> extends IRequestAdapter<T>, Cloneable { - - /** - * Returns the WCET if this {@link IDeployableComponentAdapter} would be executed on the given - * {@link IExecutionUnitAdapter}. - */ - public Double getWcet(IExecutionUnitAdapter<?> executionUnit); - - /** - * Returns the consumed energy if this {@link IDeployableComponentAdapter} would be executed on - * the given {@link IExecutionUnitAdapter}. - */ - public Double getEnergyConsumption(IExecutionUnitAdapter<?> executionUnit); - - /** Returns the minimum required safety integrity level of the deployable component. */ - public Enumerator getRequiredSafetyIntegrityLevel(); - - /** Returns the period of the deployable component. */ - public Double getTimingRequirementPeriod(); - - /** Sets the period of the deployable component. */ - public void setTimingRequirementPeriod(double period); - - /** - * Predicates whether this {@link IDeployableComponentAdapter} must be instantiated by another - * {@link IDeployableComponentAdapter}. This is determined by evaluating whether - * {@link IDeployableComponentAdapter}s are given that may be used to instantiate this - * {@link IDeployableComponentAdapter}. - */ - public boolean isInstantiationRequired(); - - /** - * Returns those {@link IDeployableComponentAdapter}s that may be used to instantiate this - * {@link IDeployableComponentAdapter}. - */ - public Collection<IDeployableComponentAdapter<T>> getReplacementComponents(); - - /** - * Predicates whether this {@link IDeployableComponentAdapter} instantiates an abstract - * {@link IDeployableComponentAdapter}. - */ - public boolean isInstantiation(); - - /** - * Returns the {@link IDeployableComponentAdapter} instantiated by this - * {@link IDeployableComponentAdapter} (if applicable). - */ - public IDeployableComponentAdapter<T> getReplacedComponent(); - - /** - * Sets the replacedComponent reference of {@code this} {@link IDeployableComponentAdapter} to - * allow tracking of the "abstract" {@link IDeployableComponentAdapter}s from the instantiated - * {@link IDeployableComponentAdapter}s. - */ - // TODO: If possible, find a way to eliminate this suppresswarning. - public void setReplacedComponent( - @SuppressWarnings("rawtypes") IDeployableComponentAdapter abstractComponent); - - /** - * Whenever an {@link IDeployableComponentAdapter} is copied/cloned its references wrt. the task - * instantiation need to be updated. Hence, after cloning, this method should be called for each - * copied/cloned {@link IDeployableComponentAdapter}. - */ - public void updateInstatiationData(); - - /** - * Returns the minimum number of replications allowed for this - * {@link IDeployableComponentAdapter}. - */ - public int getMinReplication(); - - /** - * Returns the maximum number of replications allowed for this - * {@link IDeployableComponentAdapter}. - */ - public int getMaxReplication(); - - /** - * Predicate if this {@link IDeployableComponentAdapter} is strongly causal. This implies that - * its outputs to non-strongly causal {@link IDeployableComponentAdapter}s only become available - * during the next hyperperiod. - */ - public boolean isStronglyCausal(); - - /** - * Clones the {@link IDeployableComponentAdapter} on which this method is called. If - * {@link Component}s are instantiated during the exploration, this is needed. The initially - * constructed {@link IDeployableComponentAdapter}s must be replicated for each instantiated - * encoding. - */ - public IDeployableComponentAdapter<T> clone(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IExecutionUnitAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IExecutionUnitAdapter.java deleted file mode 100644 index 76b533d4e535fbe35d04792cc3e3d5aafbfc136a..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IExecutionUnitAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IExecutionUnitAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -/** - * Adapter between the execution units (=deployment target of {@link IDeployableComponentAdapter}s) - * of the system meta-model used in the modeling tool, and the DSE. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 472B54CE1884D4B90D2C2320484F6C03 - */ -public interface IExecutionUnitAdapter<T> extends IResourceAdapter<T> { - /** - * Returns the SafeFailureFraction of an execution unit. This value is required for calculating - * the safety level of a task for a given allocation. - */ - double getSafeFailureFraction(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IGatewayUnitAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IGatewayUnitAdapter.java deleted file mode 100644 index 5fb9a45e58c2b956304a43d8b4fd08d99162c508..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IGatewayUnitAdapter.java +++ /dev/null @@ -1,34 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IGatewayUnitAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -/** - * Adapter between the gateway units ({@link IResourceAdapter}s managing the connection between - * busses) of the system meta-model used in the modeling tool, and the DSE. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 8EC98B37091BA00D355CD538ECC3EC38 - */ -public interface IGatewayUnitAdapter<T> extends ICommunicationResourceAdapter<T> { - - /** Returns the worst-case time required to process a single message forwarding request. */ - public double getWCFT(); - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ILogicalArchitectureAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ILogicalArchitectureAdapter.java deleted file mode 100644 index 933d31cb04f61a6eb11729e0dd8e4e0b6d0cc025..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ILogicalArchitectureAdapter.java +++ /dev/null @@ -1,30 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ILogicalArchitectureAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -/** - * Representation of an input logical architecture. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 4BF33C0B683C342171C451A2C56C0A21 - */ -public interface ILogicalArchitectureAdapter<T> extends IModelElementAdapter<T> { - // nothing to be done here, yet -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IMemoryUnitAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IMemoryUnitAdapter.java deleted file mode 100644 index 1c293d62dbe5fd4504d46787b54b592dad5b7bba..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IMemoryUnitAdapter.java +++ /dev/null @@ -1,32 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IMemoryUnitAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -/** - * {@link IResourceAdapter} which abstracts memories. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 2F431F726B7F13373FA4F0D4CC7081CE - */ -public interface IMemoryUnitAdapter<T> extends IResourceAdapter<T> { - - /** Returns the capacity, i.e. size, of the {@link IMemoryUnitAdapter} in bytes. */ - public long getSizeInBytes(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IModelElementAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IModelElementAdapter.java deleted file mode 100644 index dc250f771c54b1f99325c07566f845290550f457..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IModelElementAdapter.java +++ /dev/null @@ -1,39 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IModelElementAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - - -/** - * Base interface for adapters between system model elements, and the DSE. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 5F67F64DB6203190B018EE1C1070BF5E - */ -public interface IModelElementAdapter<T> { - - /** Returns the model element's name. */ - public String getName(); - - /** - * Returns a reference to the model element wrapped by this {@link IModelElementAdapter}. - * Use with care! - */ - public T getObject(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IPlatformArchitectureAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IPlatformArchitectureAdapter.java deleted file mode 100644 index 17a1be20eedeffc1af9db8c35fef8062c8a768ef..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IPlatformArchitectureAdapter.java +++ /dev/null @@ -1,30 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IPlatformArchitectureAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -/** - * Representation of an input platform architecture. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: EE7A5410FB665E7E8F2A95A915780E87 - */ -public interface IPlatformArchitectureAdapter<T> extends IModelElementAdapter<T> { - // nothing to be done here, yet -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IRequestAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IRequestAdapter.java deleted file mode 100644 index 7c948e36956e814ec9e9f07bd915e61f77635025..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IRequestAdapter.java +++ /dev/null @@ -1,31 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IRequestAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -/** - * Adapter between requests (=tasks, messages, ...) of the system meta-model used in the modeling - * tool, and the DSE. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 393CD3F591A1DC207503BC45431BB2B9 - */ -public interface IRequestAdapter<T> extends IModelElementAdapter<T> { - // Empty -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IResourceAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IResourceAdapter.java deleted file mode 100644 index 33ce9c325475473438e5d4fca51d82a0df3325ec..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IResourceAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IResourceAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -/** - * Adapter between resources (=deployment target of {@link IRequestAdapter}s, i.e. execution units, - * transmission units, ...) of the system meta-model used in the modeling tool, and the DSE. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: E67441EFF61DF1B53CAE496A98578647 - */ -public interface IResourceAdapter<T> extends IModelElementAdapter<T> { - /** Predicate if the resource is a virtual or a HW resource. */ - boolean isVirtual(); - - /** Returns the resource's failure rate (in FIT) */ - Double getFailureRate(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IResourceConnectionAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IResourceConnectionAdapter.java deleted file mode 100644 index 7478dedcc646237197f17da767128f7ffbc2ff24..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/IResourceConnectionAdapter.java +++ /dev/null @@ -1,50 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IResourceConnectionAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -import java.util.Collection; - -/** - * Adapter between the {@link IResourceAdapter}s of the system meta-model used in the modeling tool, - * and the DSE. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 900103CBBD2D9A5EBD6EE435D3FDBE1A - */ -public interface IResourceConnectionAdapter { - - /** Enum which captures the direction to a target of this adapter. */ - public static enum ConnectionType { - @SuppressWarnings({"javadoc"}) - INCOMING, @SuppressWarnings({"javadoc"}) - OUTGOING, @SuppressWarnings({"javadoc"}) - BIDIRECTIONAL; - } - - /** Returns the source element of a connection of the technical architecture. */ - public IResourceAdapter<?> getSourceResource(); - - /** Returns the target element of a connection of the technical architecture. */ - public Collection<IResourceAdapter<?>> getTargetResources(); - - /** Returns the direction from the source element of this adapter to the given target. */ - public ConnectionType getConnectionType(IResourceAdapter<?> targetResource); - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ISafetyFunctionAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ISafetyFunctionAdapter.java deleted file mode 100644 index bdd7d7658e584d02b28d52687a2ac67399ffb253..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ISafetyFunctionAdapter.java +++ /dev/null @@ -1,101 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ISafetyFunctionAdapter.java 3714 2016-10-17 13:51:34Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -import java.util.Collection; - -import org.fortiss.af3.safety.model.SafetyArchitecture; - -/** - * Adapter to represent safety functions from the input system models in the DSE. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3714 $ - * @ConQAT.Rating RED Hash: 852BD44C8D9FCDE946D53DF07D234496 - */ -public interface ISafetyFunctionAdapter<T> { - - /** - * Initialization routine for externally contributed adapters that are created before the - * {@link SystemModelAdapter} of the DSE. - */ - void initializeAdapter(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter); - - /** - * Returns the collection of {@link IDeployableComponentAdapter}s that are realizing the safety - * function. - */ - Collection<IDeployableComponentAdapter<T>> getRealizingComponents(); - - /** - * Returns the collection of {@link IDeployableComponentAdapter}s that are realizing diagnostic - * functions of the actual safety function. - */ - Collection<IDeployableComponentAdapter<T>> getDiagnosticComponents(); - - /** - * Returns the {@link IDeployableComponentAdapter} that generates the output signal of the - * safety functions, i.e. a voter or HW interfacing component. - */ - // TODO: extend to collection. - IDeployableComponentAdapter<T> getOutputComponent(); - - /** - * Returns the collection of all {@link IDeployableComponentAdapter}s that represent - * {@code this} safety function. - */ - Collection<IDeployableComponentAdapter<T>> getAllComponents(); - - /** - * Returns the collection of {@link SafetyArchitecture}s that may be used to implement - * {@code this} {@link ISafetyFunctionAdapter}. - */ - Collection<SafetyArchitecture> getAllowedSafetyArchitectures(); - - /** - * Returns the allowed number of channels to realize {@code this} {@link ISafetyFunctionAdapter} - * . - */ - int[] getAllowedChannelNumbers(); - - /** - * Returns the array of allowed signal numbers that trigger the safety function subject to the - * given number of channels. E.g., for the safety function design 1oo2 and 2oo2, one and two - * would be the return values of this method. - */ - int[] getAllowedTriggerSignalNumbers(int channelNum); - - /** - * Returns the collection of trigger signal numbers that may be used to implement the allowed - * safety architectures. - */ - Collection<Integer> getAllAllowedTriggerSignalNumbers(); - - /** - * Determines whether a diagnostic unit may be added depending on the number of channels and the - * number of signals that trigger the safety function. - */ - boolean isDiagUnitAllowed(int channelNum, int triggerSignalNum); - - /** - * Returns whether each channel of {@code this} safety function requires a separate output - * {@link IDeployableComponentAdapter}. - */ - boolean hasSeparateOutPerChannel(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ISignalAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ISignalAdapter.java deleted file mode 100644 index 47da8f7a44a7fa2a0f311060d83e66de52896da8..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ISignalAdapter.java +++ /dev/null @@ -1,58 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ISignalAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -import java.util.Collection; - -import org.fortiss.af3.exploration.extension.IDseInputParameters.SignalType; - -/** - * Adapter between logical channels of the system meta-model used in the modeling - * tool, and the DSE. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 43C3B1689A7DEBF9399015DCD886B5C1 - */ -public interface ISignalAdapter<T> extends IRequestAdapter<T> { - - /** Returns the source component of this {@link ISignalAdapter}. */ - public IDeployableComponentAdapter<?> getSource(); - - /** Returns the collection of target components of this {@link ISignalAdapter}. */ - public Collection<IDeployableComponentAdapter<?>> getTargets(); - - /** - * Returns the size of the message sent via this {@link ISignalAdapter} if it was deployed onto - * the given {@link ICommunicationResourceAdapter}. - */ - public long getSignalSize(); - - /** - * Returns the {@link SignalType} of a message if it were constructed from this - * {@link ISignalAdapter}. - */ - public SignalType getSignalType(); - - /** - * Returns the transmission time of a message sent via this {@link ISignalAdapter} if it was - * deployed onto the given {@link ITransmissionUnitAdapter}. - */ - public double getTransmissionTime(ITransmissionUnitAdapter<?> transmissionUnit); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ITransmissionUnitAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ITransmissionUnitAdapter.java deleted file mode 100644 index 69e1d035cfd3a39c3418a884d5efb45ce314aa74..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/ITransmissionUnitAdapter.java +++ /dev/null @@ -1,36 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ITransmissionUnitAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -/** - * Adapter between the transmission units (=deployment target of {@link ISignalAdapter}s) - * of the system meta-model used in the modeling tool, and the DSE. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: B8404713A5834853AA4E904240DBD001 - */ -public interface ITransmissionUnitAdapter<T> extends ICommunicationResourceAdapter<T> { - - /** - * Returns the duration of a transmission of a given number of MB via this - * {@link ITransmissionUnitAdapter}. - */ - public double getTransmissionDuration(double messageSizeMB); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/InternalComponentParameters.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/InternalComponentParameters.java deleted file mode 100644 index 651ecec642b25197fdaac6f8b1dad935b1264e95..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/InternalComponentParameters.java +++ /dev/null @@ -1,77 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: InternalComponentParameters.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -import java.util.HashMap; -import java.util.Map; - -import org.fortiss.af3.component.model.Component; - -/** - * Abstracts the deployment-specific parameter values of {@link Component}s (or other model - * elements) and stores them in a simple map format. Currently, WCET and energy consumption - * parameters are supported. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 3F7EE8076CAF4B5B0DFEE76FE25F0868 - */ -public class InternalComponentParameters { - - /** Contains the WCET for each {@link IExecutionUnitAdapter}. */ - private Map<IExecutionUnitAdapter<?>, Double> wcetMap = - new HashMap<IExecutionUnitAdapter<?>, Double>(); - - /** Contains the energy consumption in Joule for each {@link IExecutionUnitAdapter}. */ - private Map<IExecutionUnitAdapter<?>, Double> energyConsumptionMap = - new HashMap<IExecutionUnitAdapter<?>, Double>(); - - /** - * Returns a map that contains the WCET values of the {@link Component} subject to the - * {@link IExecutionUnitAdapter}. - */ - public Map<IExecutionUnitAdapter<?>, Double> getWcetMap() { - return wcetMap; - } - - /** - * Sets a map that contains the WCET values of the {@link Component} subject to the - * {@link IExecutionUnitAdapter}. - */ - public void setWcetMap(Map<IExecutionUnitAdapter<?>, Double> wcetMap) { - this.wcetMap = wcetMap; - } - - /** - * Returns a map that contains the energy consumption values of the {@link Component} subject to - * the {@link IExecutionUnitAdapter} in Joule. - */ - public Map<IExecutionUnitAdapter<?>, Double> getEnergyConsumptionMap() { - return energyConsumptionMap; - } - - /** - * Sets a map that contains the energy consumption values of the {@link Component} subject to - * the {@link IExecutionUnitAdapter}. - */ - public void setEnergyConsumptionMap(Map<IExecutionUnitAdapter<?>, Double> energyConsumptionMap) { - this.energyConsumptionMap = energyConsumptionMap; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/PlatformCommunicationGraph.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/PlatformCommunicationGraph.java deleted file mode 100644 index 2a7706a3e3c6d9b0ad7ed59f5635575cdb4e6540..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/PlatformCommunicationGraph.java +++ /dev/null @@ -1,133 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: PlatformCommunicationGraph.java 3449 2016-09-02 11:06:00Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -import static org.fortiss.af3.exploration.util.ExplorationUtils.isDebugVerboseEnabled; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceConnectionAdapter.ConnectionType; -import org.fortiss.af3.exploration.alg.graph.display.JGraphTVisualizer; -import org.jgrapht.DirectedGraph; -import org.jgrapht.Graphs; -import org.jgrapht.graph.DefaultDirectedGraph; -import org.jgrapht.graph.DefaultEdge; - -/** - * Abstracts the communication network present in a platform system meta-model to a flat graph. This - * graph is needed to manage the communication of logical {@link IDeployableComponentAdapter}s after - * they have been deployed onto a concrete platform. More precisely, the graph is used for routing - * of (physical) messages and their scheduling on the communication resources, like busses. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3449 $ - * @ConQAT.Rating RED Hash: DEA30F3F5355B574E2C0AA6B1B8AE287 - */ -public class PlatformCommunicationGraph { - - /** Representation of input system model */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** The graph representing the communication structure of a platform. */ - protected DirectedGraph<IResourceAdapter<?>, DefaultEdge> platformGraph; - - /** - * /** - * Constructor. - * - * @param systemModelAdapter - * The adapter for the input model which contains the platform - */ - public PlatformCommunicationGraph(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - - platformGraph = - new DefaultDirectedGraph<IResourceAdapter<?>, DefaultEdge>(DefaultEdge.class); - - createGraph(); - } - - /** - * Creates the communication (or connection) graph which is implicitly given by the platform - * referenced in the {@link SystemModelAdapter}. This graph is used for routing messages. - */ - private void createGraph() { - DirectedGraph<IResourceAdapter<?>, DefaultEdge> tempPlatformCommGraph = - new DefaultDirectedGraph<IResourceAdapter<?>, DefaultEdge>(DefaultEdge.class); - - // Add all resources present in the platform as vertices to the "connection graph" - for(IResourceAdapter<?> resource : systemModelAdapter.getDeploymentTargets()) { - tempPlatformCommGraph.addVertex(resource); - } - for(IResourceAdapter<?> resource : systemModelAdapter.getMemoryUnits()) { - tempPlatformCommGraph.addVertex(resource); - } - for(IResourceAdapter<?> resource : systemModelAdapter.getGatewayUnits()) { - tempPlatformCommGraph.addVertex(resource); - } - for(IResourceAdapter<?> resource : systemModelAdapter.getTransmissionUnits()) { - tempPlatformCommGraph.addVertex(resource); - } - - // Successively connect the resources in the graph. The edges are given within the - // collection resource connectors are assumed to be fully connected. - for(IResourceConnectionAdapter connection : systemModelAdapter.deploymentTargetConnectors) { - // We add edges for each receiver in order to support broadcast connections - for(IResourceAdapter<?> currentReceiverResource : connection.getTargetResources()) { - // If the current resource is a child of a {@link TransmissionUnit} (like a NoC - // router), respect the direction of connections such that complex networks are - // correctly reflected. - if(connection.getConnectionType(currentReceiverResource) == ConnectionType.OUTGOING) { - Graphs.addEdgeWithVertices(platformGraph, connection.getSourceResource(), - currentReceiverResource); - } else if(connection.getConnectionType(currentReceiverResource) == ConnectionType.INCOMING) { - Graphs.addEdgeWithVertices(platformGraph, currentReceiverResource, - connection.getSourceResource()); - } else { - // Add the edges of a single connection. We add to edges for each connection - // such that an undirected graph is generated effectively. It is required to use - // this "trick" in order to be able to use the standard shortest path - // algorithms. - Graphs.addEdgeWithVertices(platformGraph, connection.getSourceResource(), - currentReceiverResource); - Graphs.addEdgeWithVertices(platformGraph, currentReceiverResource, - connection.getSourceResource()); - } - } - } - - // Debug code - if(isDebugVerboseEnabled()) { - display(); - } - } - - /** Creates a Dialog that illustrates this {@link DirectedGraph}. */ - public void display() { - JGraphTVisualizer<IResourceAdapter<?>, DefaultEdge> taskViz = - new JGraphTVisualizer<IResourceAdapter<?>, DefaultEdge>(platformGraph); - taskViz.displayGraph("Platform communication graph"); - } - - /** - * Returns the actual graph that contains information about the {@link IResourceAdapter}s and - * their connections. - */ - public DirectedGraph<IResourceAdapter<?>, DefaultEdge> getActualGraph() { - return platformGraph; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/SystemModelAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/SystemModelAdapter.java deleted file mode 100644 index 10490ab82f57fa75a71fae6e1c0960b622050857..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/SystemModelAdapter.java +++ /dev/null @@ -1,1126 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SystemModelAdapter.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.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.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Collectors; - -import org.conqat.lib.commons.collections.Pair; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.component.model.Port; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.AbstractTaskGraphEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceConnectionAdapter.ConnectionType; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.AcyclicTaskGraph; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.ChannelAdapterWeightedEdge; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.DefaultTaskGraph; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; -import org.fortiss.af3.exploration.alg.exception.InvalidTimingModelException; -import org.fortiss.af3.exploration.alg.guava.MutableSubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.extension.IDseInputParameters.SignalType; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.af3.platform.model.IPlatformArchitectureElement; -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.platform.model.annotation.ResourceLink; -import org.fortiss.af3.platform.utils.PlatformArchitectureUtils; -import org.fortiss.tooling.base.model.element.IConnection; -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.jgrapht.Graphs; -import org.jgrapht.alg.ConnectivityInspector; - -/** - * Adapter to the system model used as input for the DSE which is created for a specific DSE run. - * - * @author barner, huang - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: 55CC3C2DC873B06C65FFE05561E99650 - */ -public class SystemModelAdapter<C, E, S, G, TR, M> { - - /** - * Constant defining the allowed tolerance for the calculation of the greatest common divisor - * used in the calculation of the effective periods. - */ - protected final static int GCD_PRECISION = 3; - - /** Logical architecture of this {@link SystemModelAdapter}. */ - protected ILogicalArchitectureAdapter<?> logicalArchitecture; - - /** Platform architecture of this {@link SystemModelAdapter}. */ - protected IPlatformArchitectureAdapter<?> platformArchitecture; - - /** - * Input models that can be retrieved via {@code this} {@link SystemModelAdapter}. It references - * the original - */ - protected SubClassToInstanceMap<EObject> inputModels = MutableSubClassToInstanceMap.create(); - - /** Deployable software components, to be mapped to deployment targets provided by platform. */ - protected Collection<IDeployableComponentAdapter<C>> deployableComponents; - - /** Collection of deployable components from the base model. */ - protected Collection<C> deployableComponentObjects; - - /** - * Maps the {@link Port}s of the deployable {@link Component}s to their temporal - * {@link SignalType} (aperiodic, sporadic, etc.). - */ - protected Map<Port, SignalType> portSignalTypes; - - /** - * 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; - - /** - * Deployable software components that may be replicated (per default: all @{code - * deployableComponent}s. - */ - protected Collection<IDeployableComponentAdapter<C>> replicableComponents; - - /** Schedulable software components, to be scheduled by the internal scheduling algorithm. */ - protected Collection<IDeployableComponentAdapter<C>> schedulableComponents = new ArrayList<>(); - - /** - * Collection of software components that will be actually executed. This includes realizations - * of "abstract" software components (-> interfaces) that are contained in the - * {@code deployableComponents} collection. - */ - protected Collection<IDeployableComponentAdapter<C>> realizableDeployableComponents; - - /** - * Deployment targets, i.e. the execution units of the target platform, where deployable - * software components will be mapped to. - */ - 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; - - /** {@link Collection} of memories present in the system. */ - protected Collection<IMemoryUnitAdapter<M>> memoryUnits; - - /** - * Gateway units that are employed to manage the communication between multiple networks - * (connecting the same or different layers). - */ - protected Collection<IGatewayUnitAdapter<G>> gatewayUnits; - - // TODO Consider more than one transmission unit - /** TDMA arbitrated transmission unit */ - protected Collection<ITransmissionUnitAdapter<TR>> transmissionUnits; - - /** Contains all available communication resources of the platform. */ - protected Collection<ICommunicationResourceAdapter<TR>> availableCommunicationResource; - - /** Contains all resources that are available in the given platform. */ - protected Collection<IResourceAdapter<?>> availableResources; - - /** - * Contains all deployment target resources, i.e. the deployment targets and their - * interconnects. - */ - protected Collection<IResourceAdapter<?>> deploymentTargetResources; - - /** Contains the connections between the {@link IResourceAdapter}s of the platform. */ - protected Collection<IResourceConnectionAdapter> deploymentTargetConnectors; - - /** - * Collection of the safety functions adapters that represent the safety functions from the - * input models. - */ - protected Collection<ISafetyFunctionAdapter<C>> safetyFunctionAdapters = new ArrayList<>(); - - /** The {@link PlatformCommunicationGraph} that is given by the current platform. */ - protected PlatformCommunicationGraph platformCommunicationGraph; - - /** The set of independent {@link DefaultTaskGraph}s derived from the logical architecture. */ - protected Collection<TaskGraph> taskGraphs; - - /** - * The set of independent directed acyclic {@link DefaultTaskGraph}s derived from the logical - * architecture. - */ - protected Collection<AcyclicTaskGraph> acyclicTaskGraphs; - - /** The "messages" emitted by the sender {@link IDeployableComponentAdapter}. */ - protected Map<IDeployableComponentAdapter<C>, Collection<ISignalAdapter<S>>> emittedMessagesBySender; - - /** Hyper-period of independent tasks graphs */ - protected Double hyperPeriod; - - /** - * Map: deployable component (= task) -> corresponding (independent, connected) - * {@link DefaultTaskGraph}. - */ - protected Map<IDeployableComponentAdapter<C>, TaskGraph> componentInGraph; - - /** - * Map: deployable component (= task) -> corresponding (independent, connected) - * {@link AcyclicTaskGraph}. - */ - protected Map<IDeployableComponentAdapter<C>, AcyclicTaskGraph> componentInAcyclicGraph; - - /** - * Mapping virtual resource -> hardware resource onto which virtual resource is (statically) - * mapped, e.g., partition -> hardware execution unit / processor core. - * - * The virtual resources are considered as deployment targets where {@link IRequestAdapter}s can - * be allocated to. - * - * However, deployment targets running on the same core share the same time line. - * Hence,a map between the deployment targets and the "time line" is maintained which - * will be considered during scheduling to separate partitions in time. - */ - protected Map<IResourceAdapter<?>, IResourceAdapter<?>> virtualResourceToHardwareResourceMap; - - /** - * Identifies the {@link IModelElement} types which establish a connection between two - * {@link PlatformArchitecture}s via an {@link ResourceLink}. - */ - protected Pair<Class<? extends IModelElement>, Class<? extends IModelElement>> platformInterconnectTypes; - - /** Defines the fault containment region defined for the target {@link PlatformArchitecture}. */ - protected Class<? extends IPlatformResource> faultContainmentRegion; - - /** - * Maintains a map of {@link IExplorationEncoding}s that can be provided by {@code this} - * {@link SystemModelAdapter} by their corresponding types. - */ - private Map<Class<? extends IExplorationEncoding>, IExplorationEncoding> inputEncodings = - new HashMap<>(); - - /** Registers a given input encoding with {@code this} {@link SystemModelAdapter}. */ - protected <T extends IExplorationEncoding> void registerInputEncoding(T encoding) { - @SuppressWarnings("unchecked") Class<T> encodingType = (Class<T>)encoding.getClass(); - assert (!inputEncodings.containsKey(encodingType)) : "You are trying to add an encoding to the input encoding whose type is already registered. This is not supported"; - inputEncodings.put(encodingType, encoding); - } - - /** Returns the input encoding of the given type. */ - @SuppressWarnings("unchecked") - public <T extends IExplorationEncoding> T getInputEncoding(Class<T> encodingType) { - return (T)inputEncodings.get(encodingType); - } - - /** - * Returns the collection of {@link IExplorationEncoding} types that are availably through - * {@code this} {@link SystemModelAdapter}. - */ - public Set<Class<? extends IExplorationEncoding>> getRegisteredEncodingTypes() { - return inputEncodings.keySet(); - } - - /** Returns the input models accessible via {@code this} {@link SystemModelAdapter}. */ - public SubClassToInstanceMap<EObject> getInputModels() { - return inputModels; - } - - /** - * Adds the given model to the input models that can be obtained via {@code this} - * {@link SystemModelAdapter}. - */ - @SuppressWarnings("unchecked") - public <T extends EObject> void putInputModel(Class<? extends T> modelType, T inputModel) { - inputModels.putInstance((Class<T>)modelType, inputModel); - } - - /** - * Creates and registers an {@link AbstractTaskGraphEncoding} with @code this} - * {@link SystemModelAdapter}. - */ - protected void createAbstractTaskGraphEncoding() { - AbstractTaskGraphEncoding<AbstractTaskMappingEncoding, C> atgEnc = - new AbstractTaskGraphEncoding<>(this); - registerInputEncoding(atgEnc); - } - - /** - * Setups the list of {@link IDeployableComponentAdapter}s that are scheduleable by a - * time-triggered scheduler. - */ - protected void setupScheduleableComponents() { - for(IDeployableComponentAdapter<C> comp : deployableComponents) { - if(comp.getTimingRequirementPeriod() != null) { - schedulableComponents.add(comp); - } - } - } - - // TODO: Make the task graph setup independent from the AF3-Component Architecture and write a - // wrapper in the specific AF3 SystemModelAdapter. - /** - * Sets up the {@link DefaultTaskGraph}s for all (independent) connected sub-component - * model contained in the logical {@link ComponentArchitecture}. This method - * also determines the hyper-period of all {@link DefaultTaskGraph}s. - * - * @throws Exception - */ - protected void setupTaskGraphs() throws Exception { - // - Add data dependencies to {@link TaskGraph}s - // - Print some debugging output - // - Determine the hyper-period of all {@link TaskGraph}s contained in this {@link - // SystemModelAdapter}. - taskGraphs = new ArrayList<TaskGraph>(); - acyclicTaskGraphs = new ArrayList<>(); - - // 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(IDeployableComponentAdapter<?> deployableComponent : deployableComponents) { - temporaryTaskGraph.addTask(deployableComponent); - } - // Temporary task graph: add edges - addDataDependenciesToTaskGraph(temporaryTaskGraph); - - // 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); - - // 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); - - // Print some debugging output: print the taskgraphs and display them in a dialog. - if(isDebugVerboseEnabled()) { - printAndDisplayTaskGraphs(taskGraphs); - printAndDisplayTaskGraphs(acyclicTaskGraphs); - } - - Collection<TaskGraph> allTaskGraphs = new ArrayList<TaskGraph>(); - allTaskGraphs.addAll(taskGraphs); - allTaskGraphs.addAll(acyclicTaskGraphs); - hyperPeriod = determineHyperPeriod(allTaskGraphs); - } - - /** - * Creates a set of independent {@link TaskGraph}s of the given type ({#link graphClass}). The - * subgraphs may have different implementation to construct themselves (via - * addDataDependencies). - * - * @throws InvalidTimingModelException - * if the periods for a single task graph cannot be set up. - */ - 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<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge> ci = - new ConnectivityInspector<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge>( - monolithicTaskGraph.getGraph()); - List<Set<IDeployableComponentAdapter<?>>> connectedSets = ci.connectedSets(); - // Reconstruct TaskGraphs from vertex sets of connected components - for(Set<IDeployableComponentAdapter<?>> 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); - } - } - - // Check if tasks within current sub TaskGraph share the same common period - taskGraph.updatePeriod(); - independentTaskGraphs.add(taskGraph); - } - return independentTaskGraphs; - } - - /** - * Adds the given collection of {@link ISafetyFunctionAdapter}s to {@code this} - * {@link SystemModelAdapter} that represents the input system models. In contrast to other - * input parameters, the {@link ISafetyFunctionAdapter}s are created dynamically if a - * safety constraint is present which results in the safety functions to be - * extracted <b>after</b> the {@link SystemModelAdapter} has been constructed. - * <p> - * This method updates the set of replicable components by removing those components that are - * referenced by the safety function. - */ - // TODO: remove the enclosed cast. The difficulty is that the ISafetyFunctionAdapters are added - // from within the DSE where the system types are not known any more. - // It would be more appropriate to shift this addition before launching the DSE. - @SuppressWarnings({"unchecked", "rawtypes"}) - public void - addSafetyFunctionAdapters(Collection<ISafetyFunctionAdapter> safetyFunctionAdapters) { - if(safetyFunctionAdapters == null) { - return; - } - this.safetyFunctionAdapters - .addAll((Collection<? extends ISafetyFunctionAdapter<C>>)safetyFunctionAdapters); - - for(ISafetyFunctionAdapter<?> sfAdapter : safetyFunctionAdapters) { - replicableComponents.removeAll(sfAdapter.getDiagnosticComponents()); - replicableComponents.removeAll(sfAdapter.getRealizingComponents()); - replicableComponents.remove(sfAdapter.getOutputComponent()); - } - } - - /** - * Creates a map for the given collection of {@link TaskGraph}s which allows to identify the - * {@link TaskGraph} that contains the given {@link IDeployableComponentAdapter} as a vertex. - */ - // TODO: Here, we know that the IDeployableCOmponentAdapters are constructed using Components. - // However, we should try to avoid the "SuppressWarnings". - @SuppressWarnings("unchecked") - private <T extends TaskGraph> Map<IDeployableComponentAdapter<C>, T> - registerTaskGraphsForComponents(Collection<T> graphs) { - Map<IDeployableComponentAdapter<C>, T> componentToGraphMap = - new HashMap<IDeployableComponentAdapter<C>, T>(); - - for(T taskGraph : graphs) { - for(@SuppressWarnings("rawtypes") IDeployableComponentAdapter deployableComponent : taskGraph - .getGraph().vertexSet()) { - componentToGraphMap.put(deployableComponent, taskGraph); - } - } - - 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 IDeployableComponentAdapter}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<IDeployableComponentAdapter<?>> tasksToBeRemoved = - new HashSet<IDeployableComponentAdapter<?>>(); - 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(IDeployableComponentAdapter<?> 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. - */ - private Double determineHyperPeriod(Collection<TaskGraph> allTaskGraphs) { - Set<Double> taskgraphPeriods = new TreeSet<Double>(); - for(TaskGraph currentGraph : allTaskGraphs) { - Double period = currentGraph.getPeriod(); - if(period != null && period > 0) { - taskgraphPeriods.add(period); - } - } - - if(taskgraphPeriods.isEmpty()) { - return null; - } - return lcmDoubleCollection(taskgraphPeriods, GCD_PRECISION); - } - - /** - * Prints the given collection of {@link TaskGraph}s to the standard output and displays them in - * a separate dialog. - */ - private <T extends TaskGraph> void printAndDisplayTaskGraphs(Collection<T> taskGraphs) { - for(T taskGraph : taskGraphs) { - System.out.println("Application " + taskGraph + ":" + " period = " + - taskGraph.getPeriod()); - System.out.println(taskGraph); - System.out.println(""); - - // Open a dialog for the visualization of the TaskGraph - taskGraph.display(); - } - } - - /** - * 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) { - - IDeployableComponentAdapter<?> sourceDeployableComponent = channelAdapter.getSource(); - Collection<IDeployableComponentAdapter<?>> targetDeployableComponents = - channelAdapter.getTargets(); - - if(sourceDeployableComponent != null && !(targetDeployableComponents.isEmpty())) { - taskGraph.addDataDependency(sourceDeployableComponent, targetDeployableComponents, - channelAdapter); - } - } - } - - /** - * Creates the {@link PlatformCommunicationGraph} that is used to determine the routing of - * messages between {@link IDeployableComponentAdapter}s and their respective - * {@link IExecutionUnitAdapter}s. - */ - protected void setupPlatformGraph() { - platformCommunicationGraph = new PlatformCommunicationGraph(this); - } - - /** - * Setups the {#link emittedMessagesBySender} map which makes it possible to easily identify the - * {@link ISignalAdapter}s that are emitted by the given {@link IDeployableComponentAdapter}. - */ - protected void setupEmittedMessages() { - emittedMessagesBySender = - new HashMap<IDeployableComponentAdapter<C>, Collection<ISignalAdapter<S>>>(); - - for(IDeployableComponentAdapter<C> currentSender : deployableComponents) { - Collection<ISignalAdapter<S>> emittedMessages = new ArrayList<ISignalAdapter<S>>(); - for(ISignalAdapter<S> currentMessage : messages) { - if(currentSender == currentMessage.getSource()) { - emittedMessages.add(currentMessage); - } - } - emittedMessagesBySender.put(currentSender, emittedMessages); - } - } - - /** Returns the logical architecture that is associated with this {@link SystemModelAdapter}. */ - public ILogicalArchitectureAdapter<?> getLogicalArchitecture() { - return logicalArchitecture; - } - - /** - * Returns the platform architecture (Middleware/HW) that is associated with this - * {@link SystemModelAdapter}. - */ - public IPlatformArchitectureAdapter<?> getPlatformArchitecture() { - return platformArchitecture; - } - - /** - * Returns the deployable (software) component from the original logical architecture. May - * contain "abstract" {@link Component}s. - */ - public Collection<IDeployableComponentAdapter<C>> getDeployableComponents() { - return deployableComponents; - } - - /** - * Returns the deployable (software) component from the original logical architecture that my be - * replicated. May contain "abstract" {@link Component}s. - */ - public Collection<IDeployableComponentAdapter<C>> getReplicableComponents() { - return replicableComponents; - } - - /** - * Returns the scheduleable (software) component from the original logical architecture. May - * contain "abstract" {@link Component}s. - */ - public Collection<IDeployableComponentAdapter<C>> getScheduleableComponents() { - return schedulableComponents; - } - - /** - * Returns the deployable (software) components that can be actually executed on - * {@link ExecutionUnit}s, i.e. software components that are backed by an implementation. - */ - public Collection<IDeployableComponentAdapter<C>> getRealizableDeployableComponents() { - return realizableDeployableComponents; - } - - // TODO: Consider implementing this method as a map, since this operation is run often? - /** - * Returns the {@link IDeployableComponentAdapter} that is constructed form the given object. - * - * @param originalEObject - * The object for which the corresponding {@link IDeployableComponentAdapter} shall - * be identified. - * @return The asociated {@link IDeployableComponentAdapter}, or {@code null} if none can be - * identified. - */ - public synchronized IDeployableComponentAdapter<C> getDeployableComponentOf( - EObject originalEObject) { - for(IDeployableComponentAdapter<C> deployableComponentAdapter : deployableComponents) { - if(deployableComponentAdapter.getObject() == originalEObject) { - return deployableComponentAdapter; - } - } - return null; - } - - /** - * Returns the {@link IDeployableComponentAdapter} that wraps the given {@link EObject}. Here, - * only those {@link IDeployableComponentAdapter} are searched which can be actually executed on - * {@link ExecutionUnit}s, i.e. "abstract" components are not considered. - */ - public synchronized IDeployableComponentAdapter<C> getRealizeableDeployableComponentOf( - EObject originalEObject) { - for(IDeployableComponentAdapter<C> deployableComponentAdapter : realizableDeployableComponents) { - if(deployableComponentAdapter.getObject() == originalEObject) { - return deployableComponentAdapter; - } - } - return null; - } - - /** - * Returns the {@link ISignalAdapter} corresponding the sender and receiver {@link Component}. - * Returns null if no channel exists between the two given components. - */ - public synchronized ISignalAdapter<S> getChannelAdapter(IDeployableComponentAdapter<C> source, - IDeployableComponentAdapter<C> target) { - // TODO: Currently, top-level components are considered as deployable components (=tasks) - for(ISignalAdapter<S> currentChannel : messages) { - if(currentChannel.getSource() == source && currentChannel.getTargets().contains(target)) { - return currentChannel; - } - } - - return null; - } - - /** - * Returns the deployment targets, i.e. the execution units of the target platform, - * where deployable software components will be mapped to. - */ - public Collection<IExecutionUnitAdapter<E>> getDeploymentTargets() { - return deploymentTargets; - } - - /** Returns the {@link IMemoryUnitAdapter} present in the target platform. */ - public Collection<IMemoryUnitAdapter<M>> getMemoryUnits() { - return memoryUnits; - } - - /** Returns the gateway units present in the platform. */ - public Collection<IGatewayUnitAdapter<G>> getGatewayUnits() { - return gatewayUnits; - } - - /** Returns the systems TDMA arbitrated transmission unit */ - public Collection<ITransmissionUnitAdapter<TR>> getTransmissionUnits() { - return transmissionUnits; - } - - /** Returns all the {@link IResourceAdapter}s present in the platform. */ - public Collection<IResourceAdapter<?>> getAvailableResources() { - return availableResources; - } - - /** - * Returns the hardware resource (e.g., processor core) onto which a virtual resource - * (e.g. partition) is (statically) mapped. - */ - public IResourceAdapter<?> getHardwareResource(IResourceAdapter<?> virtualResource) { - return virtualResourceToHardwareResourceMap.get(virtualResource); - } - - /** - * Returns the {@link ISafetyFunctionAdapter}s constructed from the safety functions that are - * present in the input models. - */ - public Collection<ISafetyFunctionAdapter<C>> getSafetyFunctionAdapters() { - if(safetyFunctionAdapters != null) { - return safetyFunctionAdapters; - } - return Collections.emptySet(); - } - - /** - * Returns the {@link PlatformCommunicationGraph} required for routing of the messages located - * in different parts of the platform. - */ - public PlatformCommunicationGraph getPlatformCommunicationGraph() { - return platformCommunicationGraph; - } - - /** - * Returns the {@link TaskGraph}s of the demanded type that has been constructed by {@code this} - * {@link SystemModelAdapter}, if any exists. Otherwise, an empty collection is returned. - */ - @SuppressWarnings("unchecked") - public <T extends TaskGraph> Collection<T> getTaskGraphsByType(Class<T> tgType) { - if(DefaultTaskGraph.class.isAssignableFrom(tgType)) { - return (Collection<T>)getTaskGraphs(); - } else if(AcyclicTaskGraph.class.isAssignableFrom(tgType)) { - return (Collection<T>)getAcyclicTaskGraphs(); - } - return Collections.emptySet(); - } - - /** - * Returns all independent {@link DefaultTaskGraph}s contained in this - * {@link SystemModelAdapter}. - */ - public Collection<? extends TaskGraph> getTaskGraphs() { - return taskGraphs; - } - - /** - * Returns all independent {@link DefaultTaskGraph}s contained in this - * {@link SystemModelAdapter}. - */ - public Collection<? extends TaskGraph> getAcyclicTaskGraphs() { - return acyclicTaskGraphs; - } - - /** - * Returns the {@link DefaultTaskGraph} in which a given deployable component (=task) is - * contained. - */ - public TaskGraph getTaskGraph(IDeployableComponentAdapter<?> deployableComponent) { - return componentInGraph.get(deployableComponent); - } - - /** - * Returns the {@link DefaultTaskGraph} in which a given deployable component (=task) is - * contained. - */ - public DefaultTaskGraph getAcyclicTaskGraph(IDeployableComponentAdapter<?> deployableComponent) { - return componentInAcyclicGraph.get(deployableComponent); - } - - /** - * Returns the {@link ISignalAdapter}s "emitted" by the given - * {@link IDeployableComponentAdapter}. Returns an empty collection if the given - * {@link IDeployableComponentAdapter} does not emit anything. - */ - public Collection<ISignalAdapter<S>> getEmmittedMessages(IDeployableComponentAdapter<?> sender) { - // TODO: use another representation ro make an access via the reference obsolete - if(sender.isInstantiation()) { - sender = sender.getReplacedComponent(); - } - // TODO: replace by map or similar. - IDeployableComponentAdapter<?> origSender = - getDeployableComponentOf((EObject)sender.getObject()); - return emittedMessagesBySender.get(origSender); - } - - /** - * Returns the hyper period of all tasks in the system, i.e. the hyper-period of all independent - * {@link DefaultTaskGraph}s. - */ - public Double getHyperPeriod() { - return hyperPeriod; - } - - /** Returns whether the given {@link Component} is a deployable {@link Component}. */ - public boolean isDeployableComponent(Component component) { - return deployableComponentObjects.contains(component); - } - - /** - * Returns whether the given {@link Port} is attached to a deployable {@link Component}, i.e. - * its temporal behavior must be defined. - */ - public boolean isDeployablePort(Port port) { - return portSignalTypes.get(port) != null; - } - - /** Returns the input output behavior of the given platform connector. */ - public ConnectionType getConnectionType(Class<? extends IConnector> connector) { - return connectionTypeLUT.get(connector); - } - - // =============================================================== - // To be removed / generalized - // =============================================================== - - /** - * Wrapper for {@link #getEffectiveConnectionTargets(IConnector, Map, Collection)} that disables - * the traversal between the physical and the virtual platform. - */ - protected Collection<IConnector> getEffectiveConnectionTargets(IConnector sourceConnector, - Collection<ExecutionUnit> deploymentTargets) throws Exception { - return getEffectiveConnectionTargets(sourceConnector, null, deploymentTargets); - } - - /** - * <p> - * Determines the effective target {@link IConnector}s of a given "source" {@link IConnector}. - * Elements/{@link IConnector}s that are irrelevant to communication within the platform are not - * added to the target list. Instead, the connectors that are accessible by the source - * {@link IConnector} are traversed until relevant targets are identified, like - * {@link ExecutionUnit}s selected for the deployment. - * </p> - * <p> - * <b>NOTE:</b> This method may return targets that are not directly involved in the - * communication between {@link ExecutionUnit}s. However, 'hull' elements (or similar elements) - * that may "disturb" the communication between {@link ExecutionUnit}s will not appear. - * </p> - * <p> - * <b>Implementation Note:</b> The <i>valid</i> targets are determined via path walk following - * all connections from the source {@link IConnector} until <i>valid</i> targets are found. - * </p> - * - * @throws Exception - * if the references between the {@link IModelElement}s are incorrectly specified. - */ - protected Collection<IConnector> getEffectiveConnectionTargets(IConnector sourceConnector, - Map<IModelElement, IModelElement> invElementReferences, - Collection<ExecutionUnit> af3DeploymentTargets) throws Exception { - Collection<IConnector> targetConnectors = new HashSet<IConnector>(); - if(sourceConnector == null) { - return targetConnectors; - } - - LinkedList<IConnector> possibleTargetConnectors = new LinkedList<IConnector>(); - Collection<IConnector> visitedTargetConnectors = new HashSet<IConnector>(); - - possibleTargetConnectors.add(sourceConnector); - while(!possibleTargetConnectors.isEmpty()) { - IConnector nextTargetConnector = possibleTargetConnectors.poll(); - - // This section handles the traversal between the elements of the same platform - // architecture. - targetConnectors.addAll(seekIntraPlatformTargetConnectors(sourceConnector, - possibleTargetConnectors, visitedTargetConnectors, nextTargetConnector, - af3DeploymentTargets)); - - // This section handles the traversal between a virtual and a hardware platform - // architecture. - if(invElementReferences != null) { - targetConnectors.addAll(seekInterPlatformConnectors(nextTargetConnector, - invElementReferences, possibleTargetConnectors, af3DeploymentTargets)); - } - - visitedTargetConnectors.add(nextTargetConnector); - } - - return targetConnectors; - } - - /** - * Identifies those {@link IConnector}s that are actual target {@link IConnector}s of data sent - * out by the given {@code sourceConnector}. This methos is needed as in a - * {@link PlatformArchitecture}, there exist {@link IConnector}s which are attached to container - * elements that are not backed by physical interface ports (These are represented by the - * contained elements). - * - * @param sourceConnector - * Source {@link IConnector} for which the target {@link IConnector}s need to be - * identified. - * @param possibleTargetConnectors - * List to which those {@link IConnector}s are added that are directly connected to - * the {@code sourceConnector} but are no "communication targets" as described above - * an need further traversal. - * @param visitedTargetConnectors - * Set of already traversed connectors (to avoid loops). - * @param nextTargetConnector - * Current {@link IConnector} whose target {@link IConnector}s need to be searched. - * @return Collection of {@link IConnector}s that are actual target {@link IConnector}s of the - * {@code sourceConnector}. - */ - protected Collection<IConnector> seekIntraPlatformTargetConnectors(IConnector sourceConnector, - LinkedList<IConnector> possibleTargetConnectors, - Collection<IConnector> visitedTargetConnectors, IConnector nextTargetConnector, - Collection<ExecutionUnit> deploymentTargets) { - Collection<IConnector> targetConnectors = new ArrayList<IConnector>(); - - Collection<IConnection> attachedConnections = new ArrayList<IConnection>(); - attachedConnections.addAll(nextTargetConnector.getOutgoing()); - attachedConnections.addAll(nextTargetConnector.getIncoming()); - - for(IConnection connToTarget : attachedConnections) { - IConnector connectorTgt = null; - IConnector connectorSrc = null; - if(connToTarget.getTarget().getOwner() != nextTargetConnector.getOwner()) { - connectorTgt = connToTarget.getTarget(); - connectorSrc = connToTarget.getSource(); - } - if(connToTarget.getSource().getOwner() != nextTargetConnector.getOwner()) { - connectorTgt = connToTarget.getSource(); - connectorSrc = connToTarget.getTarget(); - } - if(connectorTgt == null || connectorSrc == null) { - throw new RuntimeException( - "Error: \"floating\" connection found during transformation for the DSE."); - } - - IHierarchicElement tgtElement = connectorTgt.getOwner(); - // Do not traverse back (to same connector) & not to the same IHierarchicElement. - if(!visitedTargetConnectors.contains(connectorTgt) && - tgtElement != sourceConnector.getOwner()) { - if(tgtElement instanceof IPlatformArchitectureElement && - isValidConnectionTarget((IPlatformArchitectureElement)tgtElement, - deploymentTargets)) { - targetConnectors.add(connectorTgt); - } else if(tgtElement == connectorSrc.getOwner().getContainer() && - !(nextTargetConnector instanceof IPlatformExport)) { - // Treatment of hull ports: Do not walk a path that would just traverse a 'hull' - // port. Hence, just consider the ports to the "outside" (upper level). - for(IConnection currConn : connectorTgt.getOutgoing()) { - IConnector currTgtConnector = currConn.getTarget(); - if(currTgtConnector.getOwner().getContainer() != tgtElement) { - if(tgtElement instanceof IPlatformArchitectureElement && - isValidConnectionTarget( - (IPlatformArchitectureElement)currTgtConnector - .getOwner(), - deploymentTargets)) { - targetConnectors.add(currTgtConnector); - } else { - possibleTargetConnectors.add(currTgtConnector); - } - } - } - - for(IConnection currConn : connectorTgt.getIncoming()) { - IConnector currTgtConnector = currConn.getSource(); - if(currTgtConnector.getOwner().getContainer() != tgtElement) { - if(tgtElement instanceof IPlatformArchitectureElement && - isValidConnectionTarget( - (IPlatformArchitectureElement)currTgtConnector - .getOwner(), - deploymentTargets)) { - targetConnectors.add(currTgtConnector); - } else { - possibleTargetConnectors.add(currTgtConnector); - } - } - } - - visitedTargetConnectors.add(connectorTgt); - } else { - possibleTargetConnectors.add(connectorTgt); - } - } - } - - return targetConnectors; - } - - /** - * Determines those {@link IConnector}s (in a different {@link PlatformArchitecture} than the - * {@code sourceConnector}) that establish a link between between two elements of different - * {@link PlatformArchitecture}s and which are connected by a {@link ResourceLink}. - * This method is agnostic of the "direction" of the {@link ResourceLink}, i.e. it does not - * matter whether the {@code sourceConnector} is attached to an - * {@link IPlatformArchitectureElement} to which the {@link ResourceLink} is annotated or is - * referenced by virtual link. - * <p> - * <b>NOTE:</b> The current implementation assumes that there exist only n:1 links between - * {@link IModelElement}s that establish a "communication path" between different platforms - * (virtual -> physical). - * - * @param sourceConnector - * {@link IConnector} for which the target {@link IConnector}s in another platform - * have to be identified. - * @param invElementReferences - * Map representing all 1:1 inverse {@link ResourceLink}s. - * @param possibleTargetConnectors - * List of {@link IConnector}s to which those {@link IConnector}s are added that are - * located in referenced {@link PlatformArchitecture} but need to be traversed - * further such that valid "communication targets" are identified. - * - * @return List of {@link IConnector}s that a message actually traverses when being sent by the - * {@code sourceConnector}. - * @throws Exception - * if the references between the {@link IModelElement}s are incorrectly specified. - */ - // TODO: Throw appropriate Exceptions on failure, i.e. wrong types of referenced elements etc. - protected Collection<IConnector> seekInterPlatformConnectors(IConnector sourceConnector, - Map<IModelElement, IModelElement> invElementReferences, - LinkedList<IConnector> possibleTargetConnectors, - Collection<ExecutionUnit> deploymentTargets) throws Exception { - Collection<IConnector> identifiedTargets = new ArrayList<IConnector>(); - - if(connectsSwHwPlatform(sourceConnector)) { - // Special treatment for the connection between the virtual - // platform and the physical platform. - IPlatformArchitectureElement referencingElement = - (IPlatformArchitectureElement)sourceConnector.getOwner(); - EList<IPlatformArchitectureElement> referencedElements = - PlatformArchitectureUtils.getReferencedElementsWithType(referencingElement, - IPlatformArchitectureElement.class); - if(referencedElements.size() == 0) { - throw new Exception( - "No Network Interface is referenced in the ResourceLink annotation of " + - referencingElement.getName() + - ". Please specify at least one reference."); - } - - for(IPlatformArchitectureElement currRefElem : referencedElements) { - if(sourceConnector.getOwner() instanceof IPlatformArchitectureElement && - isValidConnectionTarget( - (IPlatformArchitectureElement)sourceConnector.getOwner(), - deploymentTargets)) { - identifiedTargets.add(pickFirstInstanceOf(IPlatformExport.class, - currRefElem.getConnectors())); - } else { - possibleTargetConnectors.addAll(currRefElem.getPlatformConnectorUnits()); - } - } - } else if(invElementReferences.get(sourceConnector.getOwner()) != null) { - // Special treatment for the connection between the physical platform - // and the virtual platform. - IModelElement referencedElement = invElementReferences.get(sourceConnector.getOwner()); - assert (referencedElement instanceof IPlatformArchitectureElement) : "A non-platform model element has been referenced."; - IPlatformArchitectureElement referencedPlatformElement = - (IPlatformArchitectureElement)referencedElement; - IPlatformExport driverExport = - pickFirstInstanceOf(IPlatformExport.class, - referencedPlatformElement.getConnectors()); - - if(driverExport.getOwner() instanceof IPlatformArchitectureElement && - isValidConnectionTarget((IPlatformArchitectureElement)driverExport.getOwner(), - deploymentTargets)) { - identifiedTargets.add(driverExport); - } else { - // TODO: dead code path? Is not called for any recent model. - possibleTargetConnectors.addAll(referencedPlatformElement - .getPlatformConnectorUnits()); - } - } - - return identifiedTargets; - } - - /** - * Determines whether the given connector (or its containing element) is used to establish a - * connection between separate {@link PlatformArchitecture}s. This method is capable of - * identifying connections between different {@link PlatformArchitecture} even if the links are - * defined only for the elements of {@link PlatformArchitecture}. This feature requires a map - * that tracks the link between the referenced elements and the elements containing the link. - * - * @param connector - * {@link IConnection} to be examined for its role of connecting different - * {@link PlatformArchitecture}s. - * @param invNetDriverRef - * Map tracking the inverse link of inter-{@link PlatformArchitecture} links. - * @return Flag, if the given connector (or its containing {@link IModelElement}) connects model - * elements form different {@link PlatformArchitecture}s. - */ - protected boolean connectsSwHwPlatform(IConnector connector, - Map<IModelElement, IModelElement> invNetDriverRef) { - if(platformInterconnectTypes == null) { - return false; - } - - if(!connectsSwHwPlatform(connector)) { - if(connector != null) { - IHierarchicElement parent = connector.getOwner(); - // Second: physical counter part of inter-platform connection. - if(platformInterconnectTypes.getSecond().isAssignableFrom(parent.getClass()) && - invNetDriverRef.get(parent) != null) { - return true; - } - } - return false; - } - return true; - } - - /** - * Determines whether the given connector is used to establish a connection between separate - * {@link PlatformArchitecture}s. - * <p> - * <b>NOTE:</b> This method only works correctly if the given {@link IConnector} is attached to - * a {@link IModelElement} that has an explicit reference to an {@link IModelElement} of another - * {@link PlatformArchitecture}. Otherwise, use {#link connectsSwHwPlatform(IConnector, - * Map<NetworkInterface, OnChipNetworkDriver>)}. - */ - protected boolean connectsSwHwPlatform(IConnector connector) { - if(connector instanceof IPlatformExport && - platformInterconnectTypes.getFirst().isAssignableFrom( - connector.getOwner().getClass())) { - return true; - } - return false; - } - - /** - * Returns whether the given {@link IHierarchicElement} is a valid connection end-point. These - * end-points are either {@link ExecutionUnit}s selected as deployment targets for - * {@link Component}s or {@link IPlatformCommunicationResource}s whose internal structure is not - * modeled. - */ - protected boolean isValidConnectionTarget(IPlatformArchitectureElement element, - Collection<ExecutionUnit> deploymentTargets) { - if(element instanceof IPlatformResource && deploymentTargets.contains(element)) { - return true; - } else if(element instanceof IPlatformCommunicationResource && - element.getContainedElements().isEmpty()) { - return true; - } - return false; - } - - /** Returns the fault containment region specified for the target platform. */ - public Class<? extends IPlatformResource> getFaultContainmentRegion() { - return faultContainmentRegion; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/SystemParameterContainer.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/SystemParameterContainer.java deleted file mode 100644 index e57468be5b24147ae0906ba0c82f64e62e7f807a..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/SystemParameterContainer.java +++ /dev/null @@ -1,216 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch; - -import java.util.Collection; -import java.util.Map; - -import org.conqat.lib.commons.collections.Pair; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.component.model.OutputPort; -import org.fortiss.af3.component.model.Port; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceConnectionAdapter.ConnectionType; -import org.fortiss.af3.exploration.extension.IDseInputParameters.SignalType; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.af3.platform.model.IPlatformArchitectureElement; -import org.fortiss.af3.platform.model.IPlatformResource; -import org.fortiss.af3.platform.model.PlatformArchitecture; -import org.fortiss.af3.platform.model.annotation.ResourceLink; -import org.fortiss.tooling.base.model.element.IConnector; -import org.fortiss.tooling.base.model.element.IModelElement; - -import com.google.common.collect.Multimap; - -/** - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 4A757BEFD4DC271BCA27A8E131953CC4 - */ -public class SystemParameterContainer { - - /** Collection of deployable {@link Component}s for the target platform. */ - private Collection<Component> deployableComponents; - - /** - * Maps the {@link Port}s of the deployable {@link Component}s to their temporal - * {@link SignalType} (aperiodic, sporadic, etc.). - */ - private Map<Port, SignalType> portSignalTypes; - - /** {@link ExecutionUnit}s to which {@link Component}s are mapped. */ - private Collection<ExecutionUnit> deploymentTargets; - - /** Map relating deployable {@link Component}s with their respective periods. */ - private Map<Component, Double> componentPeriodMap; - - /** - * Relates {@link Component}s from the input {@link ComponentArchitecture} to their diverse - * implementations, i.e. concrete instances (if any). - */ - private Multimap<Component, Component> replacementComponents; - - /** - * Associates deployable {@link Component}s with the number of minimally and maximally allowed - * replication (1 == no replication). - */ - private Map<Component, Pair<Integer, Integer>> componentReplicationBounds; - - /** - * Associates the OutputPorts of the deployable {@link Component}s with the size of the messages - * they emit. - */ - private Map<OutputPort, Long> portMessageSizes; - - /** - * Assotiates elements of the {@link PlatformArchitecture} with their respective mean failure - * rate. - */ - private Map<IPlatformArchitectureElement, Double> resourceFailureProbabilities; - - /** - * Associates {@link IPlatformResource}s with their respective active power consumption (in - * watts). - */ - private Map<IPlatformResource, Double> resourcePowerConsumption; - - /** - * Look up table to determine the input/output directions of {@link IConnector} types of the - * target {@link PlatformArchitecture}. - */ - private Map<Class<? extends IConnector>, ConnectionType> connectionTypeLUT; - - /** - * Identifies the {@link IModelElement} types which establish a connection between two - * {@link PlatformArchitecture}s via an {@link ResourceLink}. - */ - private Pair<Class<? extends IModelElement>, Class<? extends IModelElement>> platfromInterconnectTypes; - - /** Defines the fault containment region defined for the target {@link PlatformArchitecture}. */ - private Class<? extends IPlatformResource> faultContainmentRegion; - - /** Constructor. */ - public SystemParameterContainer( - Collection<Component> deployableComponents, - Map<Port, SignalType> portSignalTypes, - Collection<ExecutionUnit> deploymentTargets, - Map<Component, Double> componentPeriodMap, - Multimap<Component, Component> replacementComponents, - Map<Component, Pair<Integer, Integer>> componentReplicationBounds, - Map<OutputPort, Long> portMessageSizes, - Map<IPlatformArchitectureElement, Double> resourceFailureMap, - Map<IPlatformResource, Double> resourcePowerConsumption, - Map<Class<? extends IConnector>, ConnectionType> connectionTypeLUT, - Pair<Class<? extends IModelElement>, Class<? extends IModelElement>> platfromInterconnectTypes, - Class<? extends IPlatformResource> faultContainmentRegion) { - this.deployableComponents = deployableComponents; - this.portSignalTypes = portSignalTypes; - this.deploymentTargets = deploymentTargets; - this.componentPeriodMap = componentPeriodMap; - this.replacementComponents = replacementComponents; - this.componentReplicationBounds = componentReplicationBounds; - this.portMessageSizes = portMessageSizes; - this.resourceFailureProbabilities = resourceFailureMap; - this.resourcePowerConsumption = resourcePowerConsumption; - this.connectionTypeLUT = connectionTypeLUT; - this.platfromInterconnectTypes = platfromInterconnectTypes; - this.faultContainmentRegion = faultContainmentRegion; - - } - - /** Returns the deployable {@link Component}s. */ - public Collection<Component> getDeployableComponents() { - return deployableComponents; - } - - /** Returns the {@link Port} to signal type associations. */ - public Map<Port, SignalType> getPortSignalTypes() { - return portSignalTypes; - } - - /** Returns the set of deployment targets (to where {@link Component}s may be mapped). */ - public Collection<ExecutionUnit> getDeploymentTargets() { - return deploymentTargets; - } - - /** Returns the associations of deployable {@link Component}s and their defined periods. */ - public Map<Component, Double> getComponentPeriodMap() { - return componentPeriodMap; - } - - /** - * Returns the associations between deployable {@link Component}s and their diverse - * implementations (if any). - */ - public Multimap<Component, Component> getReplacementComponents() { - return replacementComponents; - } - - /** - * Returns the association between deployable {@link Component}s and their minimum and maximum - * replication bound. - */ - public Map<Component, Pair<Integer, Integer>> getComponentReplicationBounds() { - return componentReplicationBounds; - } - - /** - * Returns the associations between the {@link OutputPort}s of deployable {@link Component}s and - * the size of the data they are sending. - */ - public Map<OutputPort, Long> getPortMessageSizes() { - return portMessageSizes; - } - - /** Returns the associations between platform elements and their mean failur probability. */ - public Map<IPlatformArchitectureElement, Double> getResourceFailureProbabilities() { - return resourceFailureProbabilities; - } - - /** Returns the associations between platform elements and their mean active power consumption. */ - public Map<IPlatformResource, Double> getResourcePowerConsumption() { - return resourcePowerConsumption; - } - - /** - * Returns the lookup table mapping platform connectors their respective input output direction - * type. - */ - public Map<Class<? extends IConnector>, ConnectionType> getConnectionTypeLUT() { - return connectionTypeLUT; - } - - /** - * Returns the {@link IModelElement} types connecting entities from different - * {@link PlatformArchitecture}s, e.g. a System Software and a Hardware Architecture. - */ - public Pair<Class<? extends IModelElement>, Class<? extends IModelElement>> - getPlatfromInterconnectTypes() { - return platfromInterconnectTypes; - } - - /** - * Returns the {@link IPlatformResource} that is assumed to be the fault containment region of - * the target platform. - */ - public Class<? extends IPlatformResource> getFaultContainmentRegion() { - return faultContainmentRegion; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3DeployableComponentAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3DeployableComponentAdapter.java deleted file mode 100644 index 2b129534c2ee9407c3003f2624ff798afc1161dd..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3DeployableComponentAdapter.java +++ /dev/null @@ -1,245 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3DeployableComponentAdapter.java 3096 2016-06-27 08:39:10Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - -import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation; - -import java.util.Collection; -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.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.InternalComponentParameters; -import org.fortiss.af3.safety.model.annotation.SafetyIntegrityLevel; - -/** - * Adapter between the AF3 deployable {@link Component} (=tasks) and the DSE. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3096 $ - * @ConQAT.Rating RED Hash: 63B62E3023F6ADA8D5DDC4DC72551065 - */ -public class AF3DeployableComponentAdapter extends AF3RequestAdapter<Component> implements - IDeployableComponentAdapter<Component> { - /** Map of possible Wcets defined by the deployment target. */ - private Map<IExecutionUnitAdapter<?>, Double> wcetMap; - - /** Map of possible energy consumption defined by the deployment target. */ - private Map<IExecutionUnitAdapter<?>, Double> energyMap; - - /** Minimum number of replica (1 == no replication, just the component itself). */ - private int minReplication; - - /** Maximum number of replica (1 == no replication, just the component itself). */ - private int maxReplication; - - /** Period annotation */ - private Double period; - - /** SIL annotation */ - private SafetyIntegrityLevel sil; - - /** Reference to the corresponding elements of the diverse implementations. */ - private Collection<IDeployableComponentAdapter<Component>> replacementComponents; - - /** - * "Trace" to the {@link IDeployableComponentAdapter} which {@code this} - * {@link IDeployableComponentAdapter} replaced (if applicable). - */ - private IDeployableComponentAdapter<Component> replacedComponent; - - /** - * Creates an {@link IDeployableComponentAdapter} for an {@link Component}. - * - * @throws Exception - */ - public AF3DeployableComponentAdapter(Component deployableComponent, - Map<Component, InternalComponentParameters> internalParameters) throws Exception { - super(deployableComponent); - - // TODO: possible NPE - this.wcetMap = internalParameters.get(deployableComponent).getWcetMap(); - this.energyMap = internalParameters.get(deployableComponent).getEnergyConsumptionMap(); - - // Default value. - period = 0.0; - - sil = getAnnotation(deployableComponent, SafetyIntegrityLevel.class); - - replacementComponents = new HashSet<IDeployableComponentAdapter<Component>>(); - } - - /** - * Creates an {@link IDeployableComponentAdapter} for an {@link Component} with the given - * period and replication bounds. - * - * @throws Exception - */ - public AF3DeployableComponentAdapter(Component deployableComponent, - Map<Component, InternalComponentParameters> internalParameters, Integer minReplication, - Integer maxReplication, Double period) throws Exception { - this(deployableComponent, internalParameters); - - this.minReplication = minReplication; - this.maxReplication = maxReplication; - this.period = period; - } - - /** - * Creates an {@link IDeployableComponentAdapter} for an {@link Component} with the given - * period. - * - * @throws Exception - */ - public AF3DeployableComponentAdapter(Component deployableComponent, - Map<Component, InternalComponentParameters> internalParameters, Integer minReplication, - Integer maxReplication, Double period, - Collection<IDeployableComponentAdapter<Component>> componentReplacementAdapters) - throws Exception { - this(deployableComponent, internalParameters, minReplication, maxReplication, period); - this.period = period; - - replacementComponents = componentReplacementAdapters; - } - - /** - * Creates an "concrete" {@link IDeployableComponentAdapter} for an {@link Component} with the - * given period. - * - * @param replacedComponent - * References the {@link IDeployableComponentAdapter} which the to be constructed - * {@link IDeployableComponentAdapter} instantiates. - * - * @throws Exception - */ - public AF3DeployableComponentAdapter(Component deployableComponent, - Map<Component, InternalComponentParameters> internalParameters, - IDeployableComponentAdapter<Component> replacedComponent) throws Exception { - this(deployableComponent, internalParameters, replacedComponent.getMinReplication(), - replacedComponent.getMaxReplication(), replacedComponent - .getTimingRequirementPeriod()); - - this.replacedComponent = replacedComponent; - } - - /** {@inheritDoc} */ - @Override - public Double getWcet(IExecutionUnitAdapter<?> executionUnit) { - return wcetMap.get(executionUnit); - } - - /** {@inheritDoc} */ - @Override - public Double getEnergyConsumption(IExecutionUnitAdapter<?> executionUnit) { - return energyMap.get(executionUnit); - } - - /** {@inheritDoc} */ - @Override - public Enumerator getRequiredSafetyIntegrityLevel() { - return sil.getValue(); - } - - /** {@inheritDoc} */ - @Override - public Double getTimingRequirementPeriod() { - return period; - } - - /** {@inheritDoc} */ - @Override - public void setTimingRequirementPeriod(double period) { - this.period = period; - } - - /** {@inheritDoc} */ - @Override - public boolean isInstantiationRequired() { - return !replacementComponents.isEmpty(); - } - - /** {@inheritDoc} */ - @Override - public boolean isInstantiation() { - return replacedComponent != null; - } - - /** {@inheritDoc} */ - @Override - public Collection<IDeployableComponentAdapter<Component>> getReplacementComponents() { - return replacementComponents; - } - - /** {@inheritDoc} */ - @Override - public IDeployableComponentAdapter<Component> getReplacedComponent() { - return replacedComponent; - } - - /** {@inheritDoc} */ - // TODO: If possible, find a way to avoid these suppresswarnings. - @SuppressWarnings("unchecked") - @Override - public void setReplacedComponent( - @SuppressWarnings("rawtypes") IDeployableComponentAdapter abstractComponent) { - replacedComponent = abstractComponent; - } - - /** {@inheritDoc} */ - @Override - public void updateInstatiationData() { - replacedComponent = null; - } - - /** {@inheritDoc} */ - @Override - public int getMinReplication() { - return minReplication; - } - - /** {@inheritDoc} */ - @Override - public int getMaxReplication() { - return maxReplication; - } - - /** {@inheritDoc} */ - @Override - public boolean isStronglyCausal() { - if(modelElement.isStronglyCausal()) { - return true; - } - return false; - } - - /** {@inheritDoc} */ - @Override - public AF3DeployableComponentAdapter clone() { - try { - return (AF3DeployableComponentAdapter)super.clone(); - } catch(CloneNotSupportedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ExecutionUnitAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ExecutionUnitAdapter.java deleted file mode 100644 index 6d1aa52a49ef581ee1d7ec3e1ac4f958408c9c3b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ExecutionUnitAdapter.java +++ /dev/null @@ -1,63 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3ExecutionUnitAdapter.java 2419 2016-03-04 18:05:52Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - -import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.af3.safety.model.annotation.SafeFailureFraction; - -/** - * Adapter between AF3 {@link ExecutionUnit} (=deployment target of - * {@link IDeployableComponentAdapter}s) and the DSE. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 2419 $ - * @ConQAT.Rating RED Hash: B30952C061FD25245811BD8A946F9C9C - */ -public class AF3ExecutionUnitAdapter extends AF3ResourceAdapter<ExecutionUnit> implements - IExecutionUnitAdapter<ExecutionUnit> { - /** Execution unit safe failure fraction annotation. */ - private SafeFailureFraction safeFailureFraction; - - /** - * Creates a {@link IExecutionUnitAdapter} for an {@link ExecutionUnit}. - * - * @param executionUnit - * execution unit model element. - * @param failureProb - * failure probability of the given {@link ExecutionUnit}. - * @throws Exception - */ - public AF3ExecutionUnitAdapter(ExecutionUnit executionUnit, Double failureProb) - throws Exception { - super(executionUnit, failureProb); - - safeFailureFraction = - pickFirstInstanceOf(SafeFailureFraction.class, executionUnit.getSpecifications()); - } - - /** {@inheritDoc} */ - @Override - public double getSafeFailureFraction() { - return safeFailureFraction.getValue(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3GatewayAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3GatewayAdapter.java deleted file mode 100644 index 8144ff1ef4cfcffdbea96f88775229f2e27117d0..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3GatewayAdapter.java +++ /dev/null @@ -1,95 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3GatewayAdapter.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - -import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation; - -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.exception.InvalidPlatformModelException; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.af3.platform.model.GatewayUnit; -import org.fortiss.af3.platform.model.IVirtualizationPlatformArchitectureElement; -import org.fortiss.af3.platform.model.annotation.ResourceLink; - -/** - * Adapter between the AF3 {@link GatewayUnit} and the DSE. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: 5C1F07F02B6E0AC9CE84477289D55F24 - */ -public class AF3GatewayAdapter extends AF3ResourceAdapter<GatewayUnit> implements - IGatewayUnitAdapter<GatewayUnit> { - - /** Power consumption to transfer a message of n bits via this {@link GatewayUnit}. */ - private Double power; - - /** - * Creates a {@link IExecutionUnitAdapter} for an {@link ExecutionUnit}. - * - * @param gatewayUnit - * {@link GatewayUnit} to create an adapter for. - * @param failureProb - * failure probability of the {@link GatewayUnit}. - * - * @throws Exception - * if the {@link GatewayUnit} is part of the virtual platform (e.g., a driver) that - * cannot be associated with any hardware element. - */ - public AF3GatewayAdapter(GatewayUnit gatewayUnit, Double failureProb, Double power) - throws Exception { - super(gatewayUnit, failureProb); - this.power = power; - - if(gatewayUnit instanceof IVirtualizationPlatformArchitectureElement) { - ResourceLink resLink = getAnnotation(gatewayUnit, ResourceLink.class); - if(resLink == null) { - throw new InvalidPlatformModelException(gatewayUnit, - "No Resource Link annotation has been found: None is attached to this model element."); - } - - if(resLink.getResources() != null && resLink.getResources().size() == 0) { - throw new InvalidPlatformModelException( - gatewayUnit, - "One (or even more) gateway units must be referenced by an OnChipNetworkDriver in the Resource Link annotation. Each driver must be associated with at least one hardware element that is managed by the driver."); - } - } - } - - /** {@inheritDoc} */ - @Override - public double getWCFT() { - // TODO: add timing annotation for gateways - // Currently, do nothing but returning 1.0s, since the timing annotation is missing for - // Gateways - return 0.000001; - } - - /** {@inheritDoc} */ - @Override - public double getPower(long messageSize) { - // TODO: Add an appropriate bandwidth annotation for gateway units - if(power == null) { - return 1.0; - } - return power; - // return messageSize * transmissionUnitBandwidth.getBandwidth_MBytesPerSecond() / 1e6; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3LogicalArchitectureAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3LogicalArchitectureAdapter.java deleted file mode 100644 index cc952b33d9494d08e77e714a4906b0a721595cdd..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3LogicalArchitectureAdapter.java +++ /dev/null @@ -1,39 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3LogicalArchitectureAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ILogicalArchitectureAdapter; - -/** - * Abstracts an input logical architecture, i.e. a {@link ComponentArchitecture}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 2C387880D9B47259D33539C6C062C404 - */ -public class AF3LogicalArchitectureAdapter extends AF3ModelElementAdapter<ComponentArchitecture> - implements ILogicalArchitectureAdapter<ComponentArchitecture> { - - /** Constructor. */ - public AF3LogicalArchitectureAdapter(ComponentArchitecture componentArchitecture) { - super(componentArchitecture); - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3MemoryUnitAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3MemoryUnitAdapter.java deleted file mode 100644 index 9d8e7820b5c09818d68ef2122391281b9cd8017d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3MemoryUnitAdapter.java +++ /dev/null @@ -1,69 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3MemoryUnitAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - -import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IMemoryUnitAdapter; -import org.fortiss.af3.platform.model.MemoryUnit; -import org.fortiss.af3.platform.model.PlatformArchitecture; -import org.fortiss.af3.platform.model.annotation.MemorySize; - -/** - * {@link IMemoryUnitAdapter} for memory resources of an AF3 {@link PlatformArchitecture}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 9CC5B61DC141BA18E35569D8E47E2B44 - */ -public class AF3MemoryUnitAdapter extends AF3ResourceAdapter<MemoryUnit> implements - IMemoryUnitAdapter<MemoryUnit> { - - /** References the {@link MemorySize} annotation. */ - private MemorySize memorySizeSpec; - - /** - * Constructor. - * - * @param modelElement - * {@link MemoryUnit} from the target platform. - * @param failureProb - * failure probability of the memory unit. - * - * @throws Exception - * if the memory size specification is missing. - */ - public AF3MemoryUnitAdapter(MemoryUnit modelElement, Double failureProb) throws Exception { - super(modelElement, failureProb); - - memorySizeSpec = pickFirstInstanceOf(MemorySize.class, modelElement.getSpecifications()); - - if(memorySizeSpec == null) { - throw new Exception("The memory element " + modelElement + - " does not have a MemorySize annotation."); - } - } - - /** {@inheritDoc} */ - @Override - public long getSizeInBytes() { - return memorySizeSpec.getSize(); - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ModelElementAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ModelElementAdapter.java deleted file mode 100644 index 7ad1989ced0a043540cde4c764ffd99e4794b794..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ModelElementAdapter.java +++ /dev/null @@ -1,67 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3ModelElementAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IModelElementAdapter; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.tooling.base.model.element.IModelElement; -import org.fortiss.tooling.kernel.model.INamedElement; - -/** - * Base adapter for {@link IModelElementAdapter} based model elements. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 6AB1826234EBF3C4152EA29AC444B607 - */ -public class AF3ModelElementAdapter<T extends IModelElement> implements IModelElementAdapter<T> { - /** Reference to underlying model element */ - protected T modelElement; - - /** - * Creates a {@link IExecutionUnitAdapter} for an {@link ExecutionUnit}. - */ - public AF3ModelElementAdapter(T modelElement) { - this.modelElement = modelElement; - - } - - /** {@inheritDoc} */ - @Override - public String getName() { - if(modelElement instanceof INamedElement) { - return ((INamedElement)modelElement).getName() + "(id: " + - ((INamedElement)modelElement).getId() + ")"; - } - return "<unnamed>"; - } - - /** {@inheritDoc} */ - @Override - public T getObject() { - return modelElement; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return getName(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3PlatformArchitectureAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3PlatformArchitectureAdapter.java deleted file mode 100644 index 0037ef6aa804173b4e0d29a183b9baa5e3941143..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3PlatformArchitectureAdapter.java +++ /dev/null @@ -1,38 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3PlatformArchitectureAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IPlatformArchitectureAdapter; -import org.fortiss.af3.platform.model.PlatformArchitecture; - -/** - * Abstracts an input platform architecture, i.e. a {@link PlatformArchitecture}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 712DCE109F035CD5E2271A5133DD8F26 - */ -public class AF3PlatformArchitectureAdapter extends AF3ModelElementAdapter<PlatformArchitecture> - implements IPlatformArchitectureAdapter<PlatformArchitecture> { - - /** Constructor. */ - public AF3PlatformArchitectureAdapter(PlatformArchitecture platformArchitecture) { - super(platformArchitecture); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3RequestAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3RequestAdapter.java deleted file mode 100644 index e2d125628d2fc759b4543aeb9b4d3055adcdb52c..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3RequestAdapter.java +++ /dev/null @@ -1,38 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3RequestAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IRequestAdapter; -import org.fortiss.tooling.base.model.element.IModelElement; - -/** - * Base adapter for concrete system model elements derived from {@link IRequestAdapter}. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 360D590C83C0AA1ED8FC93514115B4B8 - */ -public class AF3RequestAdapter<T extends IModelElement> extends AF3ModelElementAdapter<T> implements - IRequestAdapter<T> { - - /** Creates a {@link IRequestAdapter}. */ - public AF3RequestAdapter(T modelElement) { - super(modelElement); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ResourceAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ResourceAdapter.java deleted file mode 100644 index 45b3b23b7e08b6b1398a97b8d21ccfb40f730308..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ResourceAdapter.java +++ /dev/null @@ -1,61 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3ResourceAdapter.java 3422 2016-08-31 07:31:54Z barner $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.af3.platform.model.IVirtualizationPlatformArchitectureElement; -import org.fortiss.tooling.base.model.element.IModelElement; - -/** - * Base adapter for concrete system model elements derived from {@link IResourceAdapter}. - * - * @author barner - * @author $Author: barner $ - * @version $Rev: 3422 $ - * @ConQAT.Rating RED Hash: D20BB819CB380872F92D22A43BF00405 - */ -// TODO: Use extends IResource, here? Same would apply to Requester/resource. -public class AF3ResourceAdapter<T extends IModelElement> extends AF3ModelElementAdapter<T> - implements IResourceAdapter<T> { - /** Failure rate annotation */ - private Double failureRate; - - /** - * Creates a {@link IExecutionUnitAdapter} for an {@link ExecutionUnit}. - */ - public AF3ResourceAdapter(T modelElement, Double failureRate) throws Exception { - super(modelElement); - - this.failureRate = failureRate; - - } - - /** {@inheritDoc} */ - @Override - public Double getFailureRate() { - return failureRate; - } - - /** {@inheritDoc} */ - @Override - public boolean isVirtual() { - return getObject() instanceof IVirtualizationPlatformArchitectureElement; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ResourceConnectionAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ResourceConnectionAdapter.java deleted file mode 100644 index 16dc9a5838ef97d638532384377a618187019825..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3ResourceConnectionAdapter.java +++ /dev/null @@ -1,99 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3ResourceConnectionAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - -import java.util.Collection; -import java.util.Map; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceConnectionAdapter; -import org.fortiss.tooling.base.model.element.IConnection; - -/** - * Adapter between the AF3 {@link IConnection} and the DSE. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: A8BBE07D7959022EE9EB83874CFEC5D7 - */ -public class AF3ResourceConnectionAdapter implements IResourceConnectionAdapter { - - /** The (actual) source element of an AF3 connection in the platform. */ - IResourceAdapter<?> sourceResource; - - /** The (actual) target element of an AF3 connection in the platform. */ - Collection<IResourceAdapter<?>> targetResources; - - /** Map which contains information about the direction of the source to each target. */ - Map<IResourceAdapter<?>, ConnectionType> targetDirectionMap; - - /** Constructor. */ - public AF3ResourceConnectionAdapter(IResourceAdapter<?> source, - Collection<IResourceAdapter<?>> targetResourceList) { - this.sourceResource = source; - this.targetResources = targetResourceList; - } - - /** - * Default constructor that allows to pass a map which contains information about the direction - * of the source to each target. - */ - public AF3ResourceConnectionAdapter(IResourceAdapter<?> source, - Map<IResourceAdapter<?>, ConnectionType> targetResourceList) { - this(source, targetResourceList.keySet()); - this.targetDirectionMap = targetResourceList; - } - - /** Compatibility method for non-multicast AF3 versions. */ - public void addTargetResource(IResourceAdapter<?> targetResource) { - targetResources.add(targetResource); - } - - /** {@inheritDoc} */ - @Override - public IResourceAdapter<?> getSourceResource() { - return sourceResource; - } - - /** {@inheritDoc} */ - @Override - public Collection<IResourceAdapter<?>> getTargetResources() { - return targetResources; - } - - /** {@inheritDoc} */ - @Override - public ConnectionType getConnectionType(IResourceAdapter<?> targetResource) { - if(targetDirectionMap.get(targetResource) != null) { - return targetDirectionMap.get(targetResource); - } - return ConnectionType.BIDIRECTIONAL; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - String sourceName = sourceResource.getName(); - String targetNames = ""; - for(IResourceAdapter<?> target : targetResources) { - targetNames += target.getName() + ", "; - } - return sourceName + "->[" + targetNames + "]"; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SignalAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SignalAdapter.java deleted file mode 100644 index 6d2801bfd4ebae5f8ef94f14b508c2d94d84402c..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SignalAdapter.java +++ /dev/null @@ -1,160 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3SignalAdapter.java 2419 2016-03-04 18:05:52Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - -import java.util.Collection; -import java.util.Iterator; - -import org.fortiss.af3.component.model.Channel; -import org.fortiss.af3.component.model.InputPort; -import org.fortiss.af3.component.model.OutputPort; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISignalAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITransmissionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.comm.Message; -import org.fortiss.af3.exploration.extension.IDseInputParameters.SignalType; - -/** - * Adapter between the AF3 {@link Channel} and the DSE. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 2419 $ - * @ConQAT.Rating RED Hash: 0148888F1416B3C3E523355778EABF35 - */ -public class AF3SignalAdapter extends AF3RequestAdapter<OutputPort> implements - ISignalAdapter<OutputPort> { - /** Conversion constant for the message size. */ - private static final long MBYTES_TO_BYTES = 1000 * 1000; - - /** Message's source component */ - IDeployableComponentAdapter<?> source; - - /** Message's target component adapter */ - Collection<IDeployableComponentAdapter<?>> targets; - - /** Message's target AF3 ports. */ - Collection<InputPort> targetPorts; - - /** Message size annotation */ - long messageSize; - - /** - * Contains the {#link SignalType} of this {@link ISignalAdapter}. Defaults to {#link - * SignalType.PERIODIC}. - */ - SignalType signalType; - - /** - * Creates an {@link ISignalAdapter} for an {@link Channel}. - * - * @throws Exception - */ - public AF3SignalAdapter(OutputPort senderPort, IDeployableComponentAdapter<?> source, - Collection<InputPort> targetPorts, Collection<IDeployableComponentAdapter<?>> targets, - Long messageSize) throws Exception { - super(senderPort); - - this.source = source; - this.targets = targets; - this.targetPorts = targetPorts; - - if(messageSize != null) { - this.messageSize = messageSize; - } else { - throw new Exception("Port " + senderPort + " does not have a message size annotation."); - } - - signalType = SignalType.PERIODIC; - } - - /** {@inheritDoc} */ - @Override - public IDeployableComponentAdapter<?> getSource() { - return source; - } - - /** - * Adds a target to the target list of the channel adapter. Compatibility layer for AF3 /wo - * multicast patch. - */ - public void addTarget(IDeployableComponentAdapter<?> target) { - targets.add(target); - } - - /** {@inheritDoc} */ - @Override - public Collection<IDeployableComponentAdapter<?>> getTargets() { - // TODO: use another representation ro make an access via the reference obsolete - return targets; - } - - /** - * Returns the AF3 {@link OutputPort} that is responsible for emitting the {@link Message} (if - * required). - */ - public OutputPort getSenderPort() { - // Known by construction. - return getObject(); - } - - /** Returns the AF3 {@link InputPort} that is that receives the {@link Message} (if required). */ - public Collection<InputPort> getTargetPorts() { - return targetPorts; - } - - /** {@inheritDoc} */ - @Override - public long getSignalSize() { - return messageSize; - } - - /** {@inheritDoc} */ - @Override - public double getTransmissionTime(ITransmissionUnitAdapter<?> transmissionUnit) { - return transmissionUnit.getTransmissionDuration(messageSize / MBYTES_TO_BYTES); - } - - /** {@inheritDoc} */ - @Override - public String getName() { - String targetNameList = ""; - for(Iterator<IDeployableComponentAdapter<?>> targetIterator = targets.iterator(); targetIterator - .hasNext();) { - targetNameList += targetIterator.next().getName(); - if(targetIterator.hasNext()) { - targetNameList += ", "; - } - } - return source.getName() + "->{" + targetNameList + "}"; - } - - /** - * Sets the {#link SignalType} of this {@link AF3SignalAdapter}. - */ - public void setSignalType(SignalType signalType) { - this.signalType = signalType; - } - - /** {@inheritDoc} */ - @Override - public SignalType getSignalType() { - return signalType; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SystemModelAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SystemModelAdapter.java deleted file mode 100644 index 5d6c7256ecd6d9f7dd573ddd66e2791a29252f96..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SystemModelAdapter.java +++ /dev/null @@ -1,1080 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3SystemModelAdapter.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - -import static org.fortiss.af3.deployment.utils.DeploymentParameterUtils.getDeploymentsWithParametersOf; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.getConnectionTypeDirection; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.getInverseIntraPlatformReferences; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.isAnyChildDeploymentTarget; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.isComponentOrPortsDeployable; -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.findTargetPorts; -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.getDeployableOutputPorts; -import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.getPhysicalPlatformArchitecture; -import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.getReferencedElementsWithType; -import static org.fortiss.af3.schedule.utils.MathUtils.gcdDoubleCollection; -import static org.fortiss.tooling.base.ui.annotation.view.AnnotationViewPartBase.setUpdateEnabled; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf; -import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.conqat.lib.commons.collections.Pair; -import org.fortiss.af3.component.model.Channel; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.component.model.InputPort; -import org.fortiss.af3.component.model.OutputPort; -import org.fortiss.af3.component.model.Port; -import org.fortiss.af3.deployment.model.Deployment; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -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.IMemoryUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceConnectionAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceConnectionAdapter.ConnectionType; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISignalAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITransmissionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.InternalComponentParameters; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemParameterContainer; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3.helper.AF3DeploymentParameterMapAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; -import org.fortiss.af3.exploration.alg.exception.InvalidPlatformModelException; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.af3.platform.model.GatewayUnit; -import org.fortiss.af3.platform.model.IPlatformArchitectureElement; -import org.fortiss.af3.platform.model.IPlatformExport; -import org.fortiss.af3.platform.model.IPlatformResource; -import org.fortiss.af3.platform.model.MemoryUnit; -import org.fortiss.af3.platform.model.PlatformArchitecture; -import org.fortiss.af3.platform.model.TransmissionUnit; -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; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -/** - * {@link SystemModelAdapter} which abstracts AutoFOCUS3 models for the DSE. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: E8CE296B6BC13E3FAD86DE0A8BD606FB - */ -public class AF3SystemModelAdapter - extends - SystemModelAdapter<Component, ExecutionUnit, OutputPort, GatewayUnit, TransmissionUnit, MemoryUnit> { - - /** References the AF3 {@link PlatformArchitecture} that is adapted. */ - private PlatformArchitecture hardwarePlatformArchitecture; - - /** - * References the {@link AF3DeploymentParameterMapAdapter} providing access to the deployment - * specific parameters. - */ - private AF3DeploymentParameterMapAdapter parameterAdapter; - - /** - * Collection of {@link IDeployableComponentAdapter} which can be used to instantiate "abstract" - * {@link IDeployableComponentAdapter}s. - */ - private Collection<IDeployableComponentAdapter<Component>> componentReplacementAdapters; - - /** Contains informations whether the given AF3 model supports multicast channels. */ - boolean multicastSupport = false; - - /** References the method which returns the multicast targets (if available). */ - Method multicastGetTargets; - - /** - * Constructor. - * - * @param componentArchitecture - * main logical architecture to deploy. - * @param platformArchitecture - * main target platform. - * @param systemParameters - * required and optional parameters for the DSE. - * @throws Exception - * if the creation of the system model adapter fails due to missing inputs or - * inconsistent specifications. - */ - public AF3SystemModelAdapter(ComponentArchitecture componentArchitecture, - PlatformArchitecture platformArchitecture, SystemParameterContainer systemParameters) - throws Exception { - - checkMulticastSupport(); - - this.logicalArchitecture = new AF3LogicalArchitectureAdapter(componentArchitecture); - this.platformArchitecture = new AF3PlatformArchitectureAdapter(platformArchitecture); - this.deployableComponentObjects = systemParameters.getDeployableComponents(); - this.connectionTypeLUT = systemParameters.getConnectionTypeLUT(); - this.portSignalTypes = systemParameters.getPortSignalTypes(); - this.platformInterconnectTypes = systemParameters.getPlatfromInterconnectTypes(); - this.faultContainmentRegion = systemParameters.getFaultContainmentRegion(); - putInputModel(ComponentArchitecture.class, componentArchitecture); - putInputModel(PlatformArchitecture.class, platformArchitecture); - - // Disable any annotation view update. - setUpdateEnabled(false); - - // Determine the associated hardware platform given the platform architecture is a a model - // of a virtual platform. - hardwarePlatformArchitecture = getPhysicalPlatformArchitecture(platformArchitecture); - - this.deploymentTargets = - createDeploymentTargets(systemParameters.getDeploymentTargets(), - systemParameters.getResourceFailureProbabilities()); - - memoryUnits = - createMemoryUnits(platformArchitecture, - systemParameters.getResourceFailureProbabilities()); - gatewayUnits = - createGatewayUnits(platformArchitecture, - systemParameters.getResourceFailureProbabilities(), - systemParameters.getResourcePowerConsumption()); - transmissionUnits = - createTransmissionUnits(platformArchitecture, - systemParameters.getResourceFailureProbabilities(), - systemParameters.getResourcePowerConsumption()); - if(platformArchitecture != hardwarePlatformArchitecture) { - memoryUnits.addAll(createMemoryUnits(hardwarePlatformArchitecture, - systemParameters.getResourceFailureProbabilities())); - gatewayUnits.addAll(createGatewayUnits(hardwarePlatformArchitecture, - systemParameters.getResourceFailureProbabilities(), - systemParameters.getResourcePowerConsumption())); - transmissionUnits.addAll(createTransmissionUnits(hardwarePlatformArchitecture, - systemParameters.getResourceFailureProbabilities(), - systemParameters.getResourcePowerConsumption())); - } - - availableResources = createAvailableResources(); - - parameterAdapter = - createDeploymentParameterMap(componentArchitecture, platformArchitecture, - systemParameters.getReplacementComponents()); - deploymentTargetConnectors = - createDeploymentTargetConnectors(systemParameters.getDeploymentTargets()); - Multimap<Component, IDeployableComponentAdapter<Component>> componentToReplacementAdapter = - createComponentReplacementAdapters(systemParameters.getReplacementComponents()); - deployableComponents = - createDeployableComponents(componentToReplacementAdapter, - systemParameters.getComponentPeriodMap(), - systemParameters.getComponentReplicationBounds()); - componentReplacementAdapters = componentToReplacementAdapter.values(); - replicableComponents = new HashSet<>(deployableComponents); - realizableDeployableComponents = createRealizableDeployableComponents(deployableComponents); - Collection<ISignalAdapter<OutputPort>> unsortedMessages = - createSignalAdapters(systemParameters.getPortMessageSizes()); - messages = - sortMessagesByExpectedOrder(unsortedMessages, - systemParameters.getComponentPeriodMap()); - - virtualResourceToHardwareResourceMap = createVirtualResourceToHardwareResourceMap(); - - setupScheduleableComponents(); - setupTaskGraphs(); - setupEmittedMessages(); - setupPlatformGraph(); - createAbstractTaskGraphEncoding(); - - // Re-enable annotation view updates. - setUpdateEnabled(true); - } - - /** Determines whether the current AF3 version supports multicast channels. */ - private void checkMulticastSupport() { - Method[] methodsOfChannel = Channel.class.getMethods(); - for(Method currentChannelMethod : methodsOfChannel) { - if(currentChannelMethod.getName().equals("getTargets")) { - multicastSupport = true; - multicastGetTargets = currentChannelMethod; - } - } - } - - /** - * Creates a collection of {@link IDeployableComponentAdapter}s that are available to - * instantiate other "abstract" {@link IDeployableComponentAdapter}s. Only those - * {@link IDeployableComponentAdapter}s which are referenced by {@link Component}s of the input - * {@link ComponentArchitecture} are included in the collection. - */ - private - Multimap<Component, IDeployableComponentAdapter<Component>> - createComponentReplacementAdapters(Multimap<Component, Component> replacementComponents) - throws Exception { - Multimap<Component, IDeployableComponentAdapter<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 AF3DeployableComponentAdapter(curReplacementComponent, - internalParameterMap)); - } - } - - return rval; - } - - /** - * Determines the deployable components from an AF3 {@link ComponentArchitecture}. - * - * @throws Exception - */ - private - Collection<IDeployableComponentAdapter<Component>> - createDeployableComponents( - Multimap<Component, IDeployableComponentAdapter<Component>> componentReplacementAdapters, - Map<Component, Double> componentPeriodMap, - Map<Component, Pair<Integer, Integer>> componentReplicationBounds) - throws Exception { - Collection<IDeployableComponentAdapter<Component>> rval = new HashSet<>(); - - Map<Component, InternalComponentParameters> internalParameterMap = - createInternalParameterMaps(deployableComponentObjects); - - for(Component currentComponent : deployableComponentObjects) { - Double period = componentPeriodMap.get(currentComponent); - // TODO: The period was allowed to be null for enabling the VL routing? - // if (period == null) { - // throw new Exception("The Period for the deployable component " + currentComponent + - // " has not been defined."); - // } - Pair<Integer, Integer> replicationBounds = - 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."); - } - - rval.add(new AF3DeployableComponentAdapter(currentComponent, internalParameterMap, - replicationBounds.getFirst(), replicationBounds.getSecond(), period, - componentReplacementAdapters.get(currentComponent))); - } - - return rval; - } - - /** - * Creates a collection of {@link IDeployableComponentAdapter}s which can be instantiated to run - * on execution units. - * - * @throws Exception - * If the {@link IDeployableComponentAdapter} cannot be created for one of the - * Components that are concrete implementations of "abstract" {@link Component}s - * defined in the {@link ComponentArchitecture}. - */ - private Collection<IDeployableComponentAdapter<Component>> - createRealizableDeployableComponents( - Collection<IDeployableComponentAdapter<Component>> deployableComponents) - throws Exception { - Collection<IDeployableComponentAdapter<Component>> rval = - new ArrayList<IDeployableComponentAdapter<Component>>(); - - rval.addAll(componentReplacementAdapters); - - for(IDeployableComponentAdapter<Component> deployableComponent : deployableComponents) { - if(!deployableComponent.isInstantiationRequired()) { - rval.add(deployableComponent); - } - } - - return rval; - } - - /** - * Collects the deployment-specific parameters (namely the WCET and energy consumption values) - * of each given component using the {@link AF3DeploymentParameterMapAdapter} and transforms - * them into a {@link InternalComponentParameters} representation. - */ - private Map<Component, InternalComponentParameters> createInternalParameterMaps( - Collection<Component> deployableComponents) { - Map<Component, InternalComponentParameters> internalParameterMap = - new HashMap<Component, InternalComponentParameters>(); - - for(Component currentComponent : deployableComponents) { - 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)); - // energyConsumptionMap.put(execUnit, - // parameterAdapter.getEnergyConsumption(currentComponent, execUnit)); - } - - InternalComponentParameters parameterMap = new InternalComponentParameters(); - parameterMap.setWcetMap(wcetMap); - // parameterMap.setEnergyConsumptionMap(energyConsumptionMap); - internalParameterMap.put(currentComponent, parameterMap); - } - return internalParameterMap; - } - - /** - * Propagates the periods defined in a timing model to other deployable components that are - * required to maintain the data dependencies of the logical architecture. - * This method first propagates the defined periods along the direction of the channels to the - * "successor" {@link Component}s. Then, the periods are propagated from those {@link Component} - * s for which there exists a period now in the opposite direction, i.e. along the opposite - * direction of the channels. - * <b>Note:</b> The propagation of periods towards the inputs is dangerous as it "hides" - * under-specified models. Instead, a model constraint check should be performed before. - * - * @param deployableComponents - * @return Map that contains the - * @throws Exception - * if the timing specification of any traversed element is inconsistent. - */ - public Map<Component, Double> propagatePeriods(Map<Component, Double> deployableComponents) - throws Exception { - Map<Component, Double> componentPeriodMap = new HashMap<Component, Double>(); - // TODO: Shouldn't be implemented as a Map containing a collection; Instead a own object - // should be used (not done here due to method being static). - Map<Component, Collection<Double>> possibleComponentPeriods = - new HashMap<Component, Collection<Double>>(); - for(Entry<Component, Double> deployableComponent : deployableComponents.entrySet()) { - Collection<Double> periodAsList = new ArrayList<Double>(); - periodAsList.add(deployableComponent.getValue()); - possibleComponentPeriods.put(deployableComponent.getKey(), periodAsList); - } - - // First iterate over all successor components. The period of successor (and predecessor - // components) is determined by the minimal period that is propagated to components that are - // not referenced by a periodic constraint. - propagatePeriodsToSuccessors(deployableComponents, possibleComponentPeriods); - determineEffectivePeriodOfComponents(componentPeriodMap, possibleComponentPeriods); - - // TODO: remove these methods. As agreed some time ago, propagation of periods to - // predecessor Components is only needed for under-specified systems, so remove this logic. - // propagatePeriodsToPredecessors(componentPeriodMap, possibleComponentPeriods); - // determineEffectivePeriodOfComponents(componentPeriodMap, possibleComponentPeriods); - - componentPeriodMap.putAll(deployableComponents); - - return componentPeriodMap; - } - - /** - * 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 propagatePeriodsToSuccessors(Map<Component, Double> deployableComponents, - Map<Component, Collection<Double>> possibleComponentPeriods) throws Exception { - Set<Component> workingQueue = new HashSet<>(); - Set<Port> traversedInputPorts = new HashSet<>(); - workingQueue.addAll(deployableComponents.keySet()); - while(!workingQueue.isEmpty()) { - Component currentComponent = (Component)workingQueue.toArray()[0]; - workingQueue.remove(currentComponent); - for(OutputPort portToSuccessor : currentComponent.getOutputPorts()) { - for(Port successorPort : findTargetPorts(portToSuccessor, - deployableComponents.keySet())) { - if(!traversedInputPorts.contains(successorPort)) { - traversedInputPorts.add(successorPort); - Component successorComponent = successorPort.getComponent(); - // Successor is not referenced by a periodic constraint - if(!deployableComponents.containsKey(successorComponent)) { - Collection<Double> possiblePeriods = - possibleComponentPeriods.get(successorComponent); - // 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(successorComponent, possiblePeriods); - workingQueue.add(successorComponent); - } - } - } - } - } - } - - /** - * 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); - // } - // } - // } - // } - // } - // } - - /** - * Calculates the effective period of all successor components that are not referenced by a - * periodic constraint from the set of plausible periods propagated from other components. This - * effective period is calculated by finding the greatest common divisor of all possible periods - * of a {@link Component}. - * - * @throws Exception - * if the timing specification of any traversed element is inconsistent. - */ - private void determineEffectivePeriodOfComponents(Map<Component, Double> componentPeriodMap, - Map<Component, Collection<Double>> possibleComponentPeriods) throws Exception { - - for(Entry<Component, Collection<Double>> possibleComponentPeriod : possibleComponentPeriods - .entrySet()) { - if(isComponentOrPortsDeployable(possibleComponentPeriod.getKey(), this)) { - componentPeriodMap.put(possibleComponentPeriod.getKey(), - gcdDoubleCollection(possibleComponentPeriod.getValue(), GCD_PRECISION)); - } - } - } - - /** - * 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)) { - IDeployableComponentAdapter<?> currentSenderComponentAdapter = - getDeployableComponentAdapter(currentSenderPort.getComponent()); - if(currentSenderComponentAdapter != null) { - Collection<IDeployableComponentAdapter<?>> receiverComponentAdapters = - new ArrayList<IDeployableComponentAdapter<?>>(); - Collection<Port> targetPorts = - findTargetPorts(currentSenderPort, af3DeployableComponents); - for(Port currentReceiverPort : targetPorts) { - IDeployableComponentAdapter<?> 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 IDeployableComponentAdapter}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. - * - * @throws Exception - */ - private Collection<IMemoryUnitAdapter<MemoryUnit>> createMemoryUnits( - PlatformArchitecture platformArchitecture, - Map<IPlatformArchitectureElement, Double> resourceFailureRates) throws Exception { - Collection<IMemoryUnitAdapter<MemoryUnit>> rval = - new ArrayList<IMemoryUnitAdapter<MemoryUnit>>(); - - for(MemoryUnit currentMemoryUnit : getChildrenWithType(platformArchitecture, - MemoryUnit.class)) { - Double failureRate = resourceFailureRates.get(currentMemoryUnit); - // if(failureRate == null) { - // throw new Exception("The failure probablity for the " + - // currentMemoryUnit.getClass().getSimpleName() + " " + - // currentMemoryUnit.getName() + " has not been defined."); - // } - - rval.add(new AF3MemoryUnitAdapter(currentMemoryUnit, failureRate)); - } - - return rval; - } - - /** - * Determines the deployment targets from an AF3 {@link PlatformArchitecture}. - * - * @throws Exception - */ - private Collection<IExecutionUnitAdapter<ExecutionUnit>> createDeploymentTargets( - Collection<ExecutionUnit> targetExecutionUnits, - Map<IPlatformArchitectureElement, Double> resourceFailureProbabilies) throws Exception { - if(targetExecutionUnits.isEmpty()) { - throw new Exception( - "No deployment targets have been specified in the target platform architecture(s). Please check whether the correct platform architecture was selected and whether the desired Execution Units were selected as deployment targets (Platform Model --> Annotation View --> Deployment Target)"); - } - - Collection<IExecutionUnitAdapter<ExecutionUnit>> rval = - new ArrayList<IExecutionUnitAdapter<ExecutionUnit>>(); - - for(ExecutionUnit execUnit : targetExecutionUnits) { - Double failureProb = resourceFailureProbabilies.get(execUnit); - rval.add(new AF3ExecutionUnitAdapter(execUnit, failureProb)); - } - - return rval; - } - - // TODO: AD: I assume this mapping can be removed soon. However, there must be a decision - // whether all possible communication paths shall be stored or if the required paths shall be - // calculated when needed, i.e. during scheduling. - /** - * Build mapping virtual resource -> hardware resource onto which virtual resource is - * statically mapped, e.g., partition -> hardware execution unit / processor core. - */ - private Map<IResourceAdapter<?>, IResourceAdapter<?>> - createVirtualResourceToHardwareResourceMap() { - Map<IResourceAdapter<?>, IResourceAdapter<?>> rval = - new HashMap<IResourceAdapter<?>, IResourceAdapter<?>>(); - - // TODO: Dummy 1:1 mapping, assuming a flat platform architecture consisting of processors - // communication units. See {@link #createDeploymentTargets}. - for(IExecutionUnitAdapter<?> deploymentTarget : getDeploymentTargets()) { - rval.put(deploymentTarget, deploymentTarget); - } - for(ITransmissionUnitAdapter<?> transmissionUnit : getTransmissionUnits()) { - rval.put(transmissionUnit, transmissionUnit); - } - for(IGatewayUnitAdapter<?> gatewayUnit : getGatewayUnits()) { - rval.put(gatewayUnit, gatewayUnit); - } - - return rval; - } - - /** - * Collects all {@link GatewayUnit}s from a given AF3 Platform and returns them as a collection - * of {@link IGatewayUnitAdapter}s. - * - * @throws Exception - */ - private Collection<IGatewayUnitAdapter<GatewayUnit>> createGatewayUnits( - PlatformArchitecture platformArchitecture, - Map<IPlatformArchitectureElement, Double> resourceFailureRates, - Map<IPlatformResource, Double> resourcePowerConsumption) throws Exception { - Collection<IGatewayUnitAdapter<GatewayUnit>> rval = - new ArrayList<IGatewayUnitAdapter<GatewayUnit>>(); - - for(GatewayUnit gatewayUnit : EcoreUtils.getChildrenWithType(platformArchitecture, - GatewayUnit.class)) { - Double failureRate = resourceFailureRates.get(gatewayUnit); - // if(failureRate == null) { - // throw new Exception("The failure probablity for the " + - // gatewayUnit.getClass().getSimpleName() + " " + gatewayUnit.getName() + - // " has not been defined."); - // } - Double power = resourcePowerConsumption.get(gatewayUnit); - // TODO: We do not have a power annotation for gateways yet. - // if(power == null) { - // throw new Exception("The failure probability for the " + - // gatewayUnit.getClass().getSimpleName() + " " + gatewayUnit.getName() + - // " has not been defined."); - // } - - rval.add(new AF3GatewayAdapter(gatewayUnit, failureRate, power)); - } - - return rval; - } - - /** - * Determines the communication resource AF3 {@link PlatformArchitecture}. - * - * @throws Exception - */ - private Collection<ITransmissionUnitAdapter<TransmissionUnit>> createTransmissionUnits( - PlatformArchitecture platformArchitecture, - Map<IPlatformArchitectureElement, Double> resourceFailureRates, - Map<IPlatformResource, Double> resourcePowerConsumption) throws Exception { - Collection<ITransmissionUnitAdapter<TransmissionUnit>> rval = - new ArrayList<ITransmissionUnitAdapter<TransmissionUnit>>(); - - for(TransmissionUnit transmissionUnit : EcoreUtils.getChildrenWithType( - platformArchitecture, TransmissionUnit.class)) { - Double failureRate = resourceFailureRates.get(transmissionUnit); - // TODO: Virtual TransmissionUnits currently do not have ResourceLinks to their physical - // counterparts. - // if(!(transmissionUnit instanceof IVirtualizationPlatformArchitectureElement) && - // failureRate == null) { - // throw new Exception("The failure probablity for the " + - // transmissionUnit.getClass().getSimpleName() + " " + - // transmissionUnit.getName() + " has not been defined."); - // } - Double power = resourcePowerConsumption.get(transmissionUnit); - // if(!(transmissionUnit instanceof IVirtualizationPlatformArchitectureElement) && - // power == null) { - // throw new Exception("The failure probablity for the " + - // transmissionUnit.getClass().getSimpleName() + " " + - // transmissionUnit.getName() + " has not been defined."); - // } - - rval.add(new AF3TransmissionUnitAdapter(transmissionUnit, failureRate, power)); - } - - return rval; - } - - // TODO: Consider removing "available resources", since this might be already implemented in the - // virtual HW mapping - // TODO: Rebase createAvailableResources() upon the IPlatformResource, since this the - // appropriate marker interface. Only create new IResourceAdapters, if no other Resource is - // present already. - /** - * Creates a {@link Collection} that references all resources present in the given platform. - * Currently, those are {@link ExecutionUnit}s, {@link GatewayUnit}s, and - * {@link TransmissionUnit}s. - */ - private Collection<IResourceAdapter<?>> createAvailableResources() { - Collection<IResourceAdapter<?>> rval = new ArrayList<IResourceAdapter<?>>(); - - // TODO: Do we need to consider more than the deployment target execution units here? - // Only consider ExecutionUnits whose container are not marked as deployment targets. - // for(ExecutionUnit execUnit : getChildrenWithType( - // (PlatformArchitecture)platformArchitecture.getObject(), ExecutionUnit.class)) { - // if(!isAnyParentDeploymentTarget(execUnit, deploymentTargets)) { - // rval.add(execUnit); - // } - // } - // // Also for the hardware platform, if the primary platform is a virtual one. - // if(hardwarePlatformArchitecture != null) { - // for(ExecutionUnit execUnit : getChildrenWithType(hardwarePlatformArchitecture, - // ExecutionUnit.class)) { - // if(!isAnyParentDeploymentTarget(execUnit, deploymentTargets)) { - // rval.add(execUnit); - // } - // } - // } - - rval.addAll(deploymentTargets); - rval.addAll(memoryUnits); - rval.addAll(gatewayUnits); - rval.addAll(transmissionUnits); - - return rval; - } - - /** - * Creates the {@link IResourceConnectionAdapter}s that describe the connections present in the - * {@link PlatformArchitecture}. - * - * @throws Exception - * if the end point of a connection cannot be determined. - */ - private Collection<IResourceConnectionAdapter> createDeploymentTargetConnectors( - Collection<ExecutionUnit> af3DeploymentTargets) throws Exception { - - // Create a map that captures the inverse link of from one IModelElement to another - // IModelelement. - Map<IModelElement, IModelElement> invElementReferences = - getInverseIntraPlatformReferences( - (PlatformArchitecture)platformArchitecture.getObject(), - platformInterconnectTypes); - - // Initial traversal list of IConnectors attached to ExecutionUnits selected as deployment - // targets. - LinkedList<IConnector> deployableConnectors = new LinkedList<IConnector>(); - for(IExecutionUnitAdapter<?> execUnit : deploymentTargets) { - deployableConnectors.addAll(((ExecutionUnit)execUnit.getObject()).getConnectors()); - } - - // TODO: rewrite the code below. Handling of hull elements and virtual targets should be - // considered in a single util method. Based on the collected target connectors, the - // resourceconnectionadapters should be generated. - Collection<IConnector> visitedConnectors = new HashSet<IConnector>(); - Collection<IResourceConnectionAdapter> rval = new HashSet<IResourceConnectionAdapter>(); - while(!deployableConnectors.isEmpty()) { - IConnector currentConnector = deployableConnectors.poll(); - visitedConnectors.add(currentConnector); - // NOTE: Here, source element does not imply "source of the connection", but - // "source of the traversal". - IHierarchicElement sourceElement = currentConnector.getOwner(); - if(sourceElement instanceof ExecutionUnit || sourceElement instanceof GatewayUnit || - sourceElement instanceof TransmissionUnit) { - // Path walk to determine the *real* connection targets, i.e. ignore hull elements - // like Tiles whose contained Cores (or partitions) were selected as deployment - // targets. - Collection<IConnector> targetConnectors = - getEffectiveConnectionTargets(currentConnector, invElementReferences, - af3DeploymentTargets); - - // Create an IResourceConnectionAdapter between the sourceElement of the traversal - // and the *real* targets. - AF3ResourceConnectionAdapter connAdp = - createResourceConnection(currentConnector, targetConnectors); - if(connAdp != null) { - rval.add(connAdp); - } - visitedConnectors.addAll(targetConnectors); - - // Collect the IConnectors attached to the target elements of the created - // IResourceConnectionAdapter for further traversing the PlatformArchitecture. - // Connections between IModelElements of different PlatformArchitectures which are - // realized via ResourceLink specifications are automatically considered. - Collection<IHierarchicElement> targetElements = new HashSet<IHierarchicElement>(); - for(IConnector currentTargetConnector : targetConnectors) { - targetElements.add(currentTargetConnector.getOwner()); - } - determineNextConnectionTargets(invElementReferences, deployableConnectors, - visitedConnectors, targetElements, af3DeploymentTargets); - } - } - - return rval; - } - - /** - * Collect the IConnectors attached to the target elements of the created - * IResourceConnectionAdapter for further traversing the PlatformArchitecture. Connections - * between IModelElements of different PlatformArchitectures which are realized via ResourceLink - * specifications are automatically considered. - * - * @throws InvalidPlatformModelException - * if the references from the referencing {@link IModelElement} to the target - * {@link IModelElement} are incorrectly specified. - */ - // TODO: Refactor this method to use the static methods from the AF3Utils class instead. - private void determineNextConnectionTargets( - Map<IModelElement, IModelElement> invElementReferences, - LinkedList<IConnector> deployableConnectors, Collection<IConnector> visitedConnectors, - Collection<IHierarchicElement> targetElements, - Collection<ExecutionUnit> af3DeploymentTargets) throws InvalidPlatformModelException { - for(IHierarchicElement targetElement : targetElements) { - if(targetElement instanceof IPlatformResource && - !af3DeploymentTargets.contains(targetElement)) { - for(IConnector connectorAtTarget : targetElement.getConnectors()) { - // Do not traverse back again. - if(connectorAtTarget != targetElement) { - if(!connectsSwHwPlatform(connectorAtTarget, invElementReferences)) { - if(!visitedConnectors.contains(connectorAtTarget)) { - deployableConnectors.add(connectorAtTarget); - } - } else if(connectsSwHwPlatform(connectorAtTarget)) { - // Special treatment for the connection between the virtual - // platform and the physical platform. - GatewayUnit currentNetworkDriver = - (GatewayUnit)connectorAtTarget.getOwner(); - List<GatewayUnit> referencedNetworkInterfaces = - getReferencedElementsWithType(currentNetworkDriver, - GatewayUnit.class); - - // TODO: consider moving this check to the input model validation. - if(referencedNetworkInterfaces.size() == 0) { - throw new InvalidPlatformModelException( - currentNetworkDriver, - "No Network Interface is referenced in the ResourceLink annotation. Please specify at least one reference."); - } - - if(!visitedConnectors.contains(connectorAtTarget)) { - for(GatewayUnit refNi : referencedNetworkInterfaces) { - Collection<IHierarchicElement> targets = - new ArrayList<IHierarchicElement>(); - targets.add(currentNetworkDriver); - if(isAnyChildDeploymentTarget( - (IPlatformResource)refNi.getContainer(), - af3DeploymentTargets, ExecutionUnit.class)) { - deployableConnectors.addAll(refNi.getConnectors()); - } else { - deployableConnectors.addAll(pickInstanceOf( - IPlatformExport.class, refNi.getConnectors())); - } - } - } - visitedConnectors.add(connectorAtTarget); - - } else if(invElementReferences.get(connectorAtTarget.getOwner()) != null) { - // Special treatment for the connection between the physical platform - // and the virtual platform. - GatewayUnit currentNetworkDriver = - (GatewayUnit)invElementReferences.get(connectorAtTarget - .getOwner()); - IPlatformExport driverExport = - pickFirstInstanceOf(IPlatformExport.class, - currentNetworkDriver.getConnectors()); - - if(!visitedConnectors.contains(driverExport)) { - Collection<IHierarchicElement> targets = - new ArrayList<IHierarchicElement>(); - targets.add(driverExport.getOwner()); - deployableConnectors - .addAll(driverExport.getOwner().getConnectors()); - - visitedConnectors.add(driverExport); - } - } - } - } - } - } - } - - /** - * Creates a {@link IResourceConnectionAdapter} between the given source and the target - * elements. This method takes {@link IHierarchicElement}s as inputs and identifies the matching - * {@link IResourceConnectionAdapter}s of the given elements. - * - * @throws InvalidPlatformModelException - * if an invalid combination of of platform ports/interfaces has been detected - * (e.g., Input <-> Input). - */ - private AF3ResourceConnectionAdapter createResourceConnection(IConnector sourceConnector, - Collection<IConnector> targetConnectors) throws InvalidPlatformModelException { - IResourceAdapter<?> sourceResource = null; - Collection<IResourceAdapter<?>> targetResources = new HashSet<IResourceAdapter<?>>(); - Map<IResourceAdapter<?>, ConnectionType> targetConnType = - new HashMap<IResourceAdapter<?>, ConnectionType>(); - Collection<IHierarchicElement> targetElements = new HashSet<IHierarchicElement>(); - - // Capture information about the target elements and the IConnectors that are the actual AF3 - // targets of this connection. It is used to determine the connection direction for each - // target. - Multimap<IHierarchicElement, IConnector> targetConnsAtElement = HashMultimap.create(); - for(IConnector targetConnector : targetConnectors) { - targetElements.add(targetConnector.getOwner()); - targetConnsAtElement.put(targetConnector.getOwner(), targetConnector); - } - - // Identify the corresponding IResourceAdapters of the collection of target - // IHierarchicalElements and determine the direction of their connection. - for(IResourceAdapter<?> resource : availableResources) { - if(resource.getObject() == sourceConnector.getOwner()) { - sourceResource = resource; - } else if(targetElements.contains(resource.getObject())) { - targetResources.add(resource); - ConnectionType type = ConnectionType.BIDIRECTIONAL; - boolean firstRoundFlag = true; - for(IConnector targetConnector : targetConnsAtElement - .get((IHierarchicElement)resource.getObject())) { - if(firstRoundFlag) { - firstRoundFlag = false; - type = getConnectionTypeDirection(sourceConnector, targetConnector, this); - } else if(type != getConnectionTypeDirection(sourceConnector, targetConnector, - this)) { - type = ConnectionType.BIDIRECTIONAL; - } - } - targetConnType.put(resource, type); - } - } - assert (sourceResource != null); - - return new AF3ResourceConnectionAdapter(sourceResource, targetConnType); - } - - /** - * Returns the (first) {@link IDeployableComponentAdapter} which is associated with the given - * AF3 {@link Component}. Returns null if no matching {@link IDeployableComponentAdapter} is - * found. - */ - public IDeployableComponentAdapter<?> getDeployableComponentAdapter(Component af3Component) { - if(af3Component == null) { - throw new IllegalArgumentException( - "Cannot identify IDeployableComponentAdapters for 'null' Components"); - } - - IDeployableComponentAdapter<?> deployableComponentAdapter = null; - for(IDeployableComponentAdapter<Component> deployableComponent : deployableComponents) { - if(deployableComponent.getObject() == af3Component) { - deployableComponentAdapter = deployableComponent; - break; - } - } - - return deployableComponentAdapter; - } - - /** - * Creates a {@link AF3DeploymentParameterMapAdapter} that provides access to the deployment - * specific parameters of an AF3 {@link Deployment}. The corresponding {@link Deployment} is - * identified via the referenced {@link ComponentArchitecture} and {@link PlatformArchitecture}. - */ - private AF3DeploymentParameterMapAdapter createDeploymentParameterMap( - ComponentArchitecture componentArchitecture, PlatformArchitecture platformArchitecture, - Multimap<Component, Component> replacementComponents) { - Set<Deployment> selectedDeployments = new HashSet<Deployment>(); - - addMatchingParameterDeploymentTo(selectedDeployments, componentArchitecture, - platformArchitecture); - - Set<ComponentArchitecture> diversityArchitectureList = - getReferencedCompArchs(replacementComponents); - for(ComponentArchitecture diversityContainingArch : diversityArchitectureList) { - addMatchingParameterDeploymentTo(selectedDeployments, diversityContainingArch, - platformArchitecture); - } - - if(!selectedDeployments.isEmpty()) { - return new AF3DeploymentParameterMapAdapter(selectedDeployments); - } - return null; - } - - /** - * Searches the {@link IProjectRootElement} for {@link Deployment}s of the given - * {@link ComponentArchitecture} to the given {@link PlatformArchitecture} and adds the first - * matching {@link Deployment} to the given list. - */ - private void addMatchingParameterDeploymentTo(Set<Deployment> paramDeployments, - ComponentArchitecture componentArchitecture, PlatformArchitecture platformArchitecture) { - List<Deployment> matchingDeployments = - getDeploymentsWithParametersOf(componentArchitecture, platformArchitecture); - if(matchingDeployments != null && matchingDeployments.size() > 0) { - // Take the first "template" Deployment until a approach is implemented that allows the - // user select the desired "template" deployment. - paramDeployments.add(matchingDeployments.get(0)); - } - } - - /** - * Returns the set of {@link ComponentArchitecture}s that contain the referenced - * {@link Component}s given by the {@code replacementComponents} map. - */ - private Set<ComponentArchitecture> getReferencedCompArchs( - Multimap<Component, Component> replacementComponents) { - Set<ComponentArchitecture> referencedCompArchs = new HashSet<ComponentArchitecture>(); - for(Component diverseComponent : replacementComponents.values()) { - ComponentArchitecture diversityCompArch = - getParentElement(diverseComponent, ComponentArchitecture.class, false); - if(diversityCompArch != null) { - referencedCompArchs.add(diversityCompArch); - } - } - return referencedCompArchs; - } - - /** - * Returns the (first) {@link IExecutionUnitAdapter} which is associated with the given - * AF3 {@link ExecutionUnit}. Returns null if no matching {@link IExecutionUnitAdapter} is - * found - */ - public IExecutionUnitAdapter<?> getExecutionUnitAdapter(ExecutionUnit af3ExecutionUnit) { - if(af3ExecutionUnit == null) - throw new IllegalArgumentException( - "Cannot identify IExecutionUnitAdapter for 'null' ExecutionUnits"); - - IExecutionUnitAdapter<?> executionUnitAdapter = null; - for(IExecutionUnitAdapter<?> targetExecutionUnit : deploymentTargets) { - if(targetExecutionUnit.getObject() == af3ExecutionUnit) { - executionUnitAdapter = targetExecutionUnit; - break; - } - } - - assert (executionUnitAdapter == null) : "No IExecutionUnitAdapter found for the ExecutionUnit " + - af3ExecutionUnit.getName() + - "(ID: " + - af3ExecutionUnit.getId() + - "). Every AF3-ExecutionUnit should have a IExecutionUnitAdapter equivalent."; - - return executionUnitAdapter; - } - - /** Determine task graph for a given component */ - public TaskGraph getTaskGraph(Component component) { - // TODO: AD: The cast to the AF3 systemmodeladapter breaks the abstration the goals. It - // 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. - IDeployableComponentAdapter<?> deployableComponent = - getDeployableComponentAdapter(component); - return getTaskGraph(deployableComponent); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3TransmissionUnitAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3TransmissionUnitAdapter.java deleted file mode 100644 index 777e0464032b8fa9d6c39b30a0f676894a65c2ed..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3TransmissionUnitAdapter.java +++ /dev/null @@ -1,96 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3TransmissionUnitAdapter.java 2419 2016-03-04 18:05:52Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3; - -import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISignalAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITransmissionUnitAdapter; -import org.fortiss.af3.platform.model.TransmissionUnit; -import org.fortiss.af3.timing.model.annotation.TransmissionUnitBandwidth; - -/** - * Adapter between the AF3 {@link TransmissionUnit} and the DSE. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 2419 $ - * @ConQAT.Rating RED Hash: DB265BE931A866509C4A948684EE132A - */ -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}. */ - Collection<IResourceAdapter<?>> connectedResources; - - /** {@link TransmissionUnit} bandwidth annotation */ - TransmissionUnitBandwidth transmissionUnitBandwidth; - - /** {@link TransmissionUnit} power consumptions annotation */ - Double transmissionUnitPower; - - /** - * Creates an {@link ISignalAdapter} for an {@link TransmissionUnit}. - * - * @param transmissionUnit - * present in the target platform and for which to generate an adapter. - * @param failureProb - * failure probability of the {@code transmissionUnit}. - * @param power - * Energy required to transfer a single bit. - * - * @throws Exception - * if the bandwidth property is invalid: Non-existent or zero. - */ - public AF3TransmissionUnitAdapter(TransmissionUnit transmissionUnit, Double failureProb, - Double power) throws Exception { - super(transmissionUnit, failureProb); - this.transmissionUnitPower = power; - - // Extract annotations - 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) { - throw new Exception("The transmission unit " + transmissionUnit + - " has a bandwidth of 0 MB/s. This is not a valid attribute."); - } - } - - /** {@inheritDoc} */ - @Override - public double getPower(long messageSizeInBits) { - return messageSizeInBits / - (MBYTES_TO_BYTES * transmissionUnitBandwidth.getBandwidth_MBytesPerSecond()) * - transmissionUnitPower; - } - - /** {@inheritDoc} */ - @Override - public double getTransmissionDuration(double messageSizeMB) { - return messageSizeMB / transmissionUnitBandwidth.getBandwidth_MBytesPerSecond(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/helper/AF3DeploymentParameterMapAdapter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/helper/AF3DeploymentParameterMapAdapter.java deleted file mode 100644 index 68ea16ba18ea2db1cdc9180b7a5da051e7e5df82..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/helper/AF3DeploymentParameterMapAdapter.java +++ /dev/null @@ -1,98 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3DeploymentParameterMapAdapter.java 3038 2016-06-17 13:26:28Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.af3.helper; - -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.deployment.model.Deployment; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.af3.platform.model.annotation.EnergyConsumption; -import org.fortiss.af3.timing.model.annotation.Wcet; - -/** - * AF3 adapter that provides access to the deployment specific parameter map. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3038 $ - * @ConQAT.Rating RED Hash: 942AEE48B60B8E4E4133D5EEE17D7A8B - */ -public class AF3DeploymentParameterMapAdapter { - /** - * References the map of {@link Deployment}s that contain the parameter map of a - * {@link Component}. - */ - private Map<Component, Deployment> componentParamDeploymentMap; - - /** Constructor. */ - public AF3DeploymentParameterMapAdapter(Set<Deployment> af3DeploymentList) { - componentParamDeploymentMap = new HashMap<Component, Deployment>(); - for(Deployment singleParamDeployment : af3DeploymentList) { - ComponentArchitecture refCompArch = - (ComponentArchitecture)singleParamDeployment - .getComponentArchitectureReference().getReference(); - Collection<Component> containedComponents = - getChildrenWithType(refCompArch, Component.class); - for(Component currentComponent : containedComponents) { - componentParamDeploymentMap.put(currentComponent, singleParamDeployment); - } - } - } - - /** Returns the WCET of a component based on its deployment target. */ - public double getWcet(Component af3Component, IExecutionUnitAdapter<?> deploymentTarget) { - ExecutionUnit af3ExecutionUnit = getAf3ExecutionUnit(deploymentTarget); - boolean validAf3Elements = (af3Component != null && af3ExecutionUnit != null); - - Deployment associatedParamDeployment = componentParamDeploymentMap.get(af3Component); - Object wcetValue = - associatedParamDeployment.getDeploymentParameter(af3Component, af3ExecutionUnit, - Wcet.class, null); - return (validAf3Elements && wcetValue != null) ? ((BigDecimal)wcetValue).doubleValue() - : -1.0; - } - - /** Returns the energy consumption of a component based on its deployment target. */ - public double getEnergyConsumption(Component af3Component, - IExecutionUnitAdapter<?> deploymentTarget) { - ExecutionUnit af3ExecutionUnit = getAf3ExecutionUnit(deploymentTarget); - boolean validAf3Elements = (af3Component != null && af3ExecutionUnit != null); - - Deployment associatedParamDeployment = componentParamDeploymentMap.get(af3Component); - Object energyValue = - associatedParamDeployment.getDeploymentParameter(af3Component, af3ExecutionUnit, - EnergyConsumption.class, null); - return (validAf3Elements && energyValue != null) ? (Double)energyValue : -1.0; - } - - /** Returns the corresponding {@link ExecutionUnit} of the given {@link IExecutionUnitAdapter}. */ - private ExecutionUnit getAf3ExecutionUnit(IExecutionUnitAdapter<?> deploymentTarget) { - Object executionUnit = deploymentTarget.getObject(); - return (executionUnit instanceof ExecutionUnit) ? (ExecutionUnit)executionUnit : null; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/AcyclicTaskGraph.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/AcyclicTaskGraph.java deleted file mode 100644 index 8a3e3bba52f2cbc5827b145246e6f0888674991c..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/AcyclicTaskGraph.java +++ /dev/null @@ -1,123 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AcyclicTaskGraph.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph; - -import java.util.ArrayList; -import java.util.Collection; -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.IDeployableComponentAdapter; -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.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.ListenableDirectedWeightedGraph; - -/** - * Creates a Directed acyclic task graph of all the {@link IDeployableComponentAdapter}s. <li>Each - * {@link ISignalAdapter} is examined:</li> <li>If there exists no path between a target of the - * {@link ISignalAdapter} and it source, add an edge to the {@link DefaultTaskGraph}.</li> <li> - * Otherwise, a loop is detected. Then, the detected loop is cut either by not adding the edge (if - * the source vertex is strongly causal) or by removing an edge between the vertices (i.e. - * {@link IDeployableComponentAdapter}s) that are closest to the current {@link ISignalAdapter} by - * traversing the found path backwards and adding the current edge.</li> - * <p> - * <b>NOTE:</b> This method expects <b>correct</b> {@link ILogicalArchitectureAdapter}s as input, - * i.e. at least one {@link IDeployableComponentAdapter} of each loop must be 'strongly causal'. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: A0B0304DD3097A6E848A2128D707302F - */ -public class AcyclicTaskGraph extends DefaultTaskGraph implements TaskGraph { - - /** Constructor. */ - public AcyclicTaskGraph() { - super(); - } - - /** - * Constructor which creates an acyclic {@link TaskGraph} from a given possibly cyclic - * {@link TaskGraph}. - */ - public AcyclicTaskGraph(TaskGraph taskGraph) { - this(); - period = taskGraph.getPeriod(); - createMinSpanAcycTaskGraph(taskGraph); - } - - /** - * Creates an acyclic {@link TaskGraph} from a given general {@link TaskGraph} based on a - * calculation of the minimum spanning tree of the transitions between tasks, i.e. - * {@link ChannelAdapterWeightedEdge}s. - */ - private void createMinSpanAcycTaskGraph(TaskGraph taskGraph) { - DirectedGraph<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge> tg = - taskGraph.getGraph(); - Graphs.addAllVertices(graph, tg.vertexSet()); - - if(taskGraph.getTasks().size() == 1) { - return; - } - MinimumSpanningTree<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge> minSpanTree = - new PrimMinimumSpanningTree<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge>( - taskGraph.getGraph()); - minSpanTree.getMinimumSpanningTreeEdgeSet().stream() - .forEach(e -> graph.addEdge(tg.getEdgeSource(e), tg.getEdgeTarget(e), e)); - } - - /** {@inheritDoc} */ - @Override - public AcyclicTaskGraph copy() { - AcyclicTaskGraph clonedTaskGraph; - try { - clonedTaskGraph = (AcyclicTaskGraph)super.clone(); - } catch(CloneNotSupportedException e) { - throw new AssertionError(); - } - clonedTaskGraph.graph = - new ListenableDirectedWeightedGraph<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge>( - ChannelAdapterWeightedEdge.class); - Graphs.addGraph(clonedTaskGraph.graph, graph); - clonedTaskGraph.taskFaultDetectorsMap = - new HashMap<IDeployableComponentAdapter<?>, SortedSet<FaultDetector>>( - taskFaultDetectorsMap); - - return clonedTaskGraph; - } - - /** - * Transforms all existing {@link TaskGraph}s of {@code this} {@link TaskGraphEncoding} into - * {@link AcyclicTaskGraph}s. - */ - public static <T extends TaskGraph> Collection<AcyclicTaskGraph> transformToAcyclicGraphs( - Collection<T> cyclicTGs) { - Collection<AcyclicTaskGraph> acyclicTGCollection = new ArrayList<>(); - for(TaskGraph tg : cyclicTGs) { - AcyclicTaskGraph acycTG = new AcyclicTaskGraph(tg); - acyclicTGCollection.add(acycTG); - } - return acyclicTGCollection; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/ChannelAdapterWeightedEdge.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/ChannelAdapterWeightedEdge.java deleted file mode 100644 index 8135326ea9a83141837b2e153dd0ad439c06735c..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/ChannelAdapterWeightedEdge.java +++ /dev/null @@ -1,68 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ChannelAdapterWeightedEdge.java 2419 2016-03-04 18:05:52Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISignalAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITransmissionUnitAdapter; -import org.jgrapht.graph.DefaultWeightedEdge; - -/** - * Edge specification class for underlying graph implementation. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 2419 $ - * @ConQAT.Rating RED Hash: 3A8084865E632376419B536D6A749F0F - */ -public class ChannelAdapterWeightedEdge extends DefaultWeightedEdge { - /** {@link ISignalAdapter} represented by this edge. */ - ISignalAdapter<?> channel; - - /** {@link ITransmissionUnitAdapter} to which this {@link ISignalAdapter} is mapped. */ - ITransmissionUnitAdapter<?> transmissionUnit; - - /** Constructs a new {@link ChannelAdapterWeightedEdge} for a given {@link ISignalAdapter}. */ - public ChannelAdapterWeightedEdge(ISignalAdapter<?> channel) { - this.channel = channel; - } - - // TODO: Remove the linking of channels with transmission units. This approach is no longer - // valid for multi-hop communication. - /** - * Sets the {@link ITransmissionUnitAdapter} to which the {@link ISignalAdapter} represented by - * this {@link ChannelAdapterWeightedEdge} is mapped. - */ - public void setTransmissionUnit(ITransmissionUnitAdapter<?> transmissionUnit) { - this.transmissionUnit = transmissionUnit; - } - - /** Returns the {@link ISignalAdapter} associated with this edge. */ - public ISignalAdapter<?> getChannelAdapter() { - return channel; - } - - /** {@inheritDoc} */ - @Override - protected double getWeight() { - if(transmissionUnit != null) { - return channel.getTransmissionTime(transmissionUnit); - } - - return 0; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/DefaultTaskGraph.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/DefaultTaskGraph.java deleted file mode 100644 index de79bc751b992b5310a43f707ac158ba99af6690..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/DefaultTaskGraph.java +++ /dev/null @@ -1,314 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DefaultTaskGraph.java 3841 2016-11-04 14:51:29Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISignalAdapter; -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.jgrapht.Graphs; -import org.jgrapht.graph.ListenableDirectedWeightedGraph; -import org.jgrapht.traverse.DepthFirstIterator; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -/** - * <p> - * The TaskGraph represents the data dependencies of a single connected component between the - * deployable components (= tasks) of a systems (Tasks = vertices, channels of logical architecture - * = edges). Therefore, a system typically consists of multiple {@link DefaultTaskGraph}s that are - * owned by the corresponding {@link SystemModelAdapter} instance. - * </p> - * The TaskGraph also contains - * <ul> - * <li>Execution times of tasks.</li> - * <li>The fault-detectors used by the tasks</li> - * <li>Task execution times (currently assuming homogeneous cores)</li> - * </ul> - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3841 $ - * @ConQAT.Rating RED Hash: 33EFBE844FCFB9357C1A74239F1EAA6B - */ - -public class DefaultTaskGraph implements TaskGraph, Cloneable { - /** Underlying graph implementation */ - // TODO: Add a weight w.r.t. transmission time, when deployed - protected ListenableDirectedWeightedGraph<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge> graph; - - // TODO: Currently, all tasks in a {@link TaskGraph} must have the same period - /** The period time of this {@link DefaultTaskGraph}. */ - protected Double period; - - // TODO: Fault detector library - /** Fault detector library (map: task -> set of fault detectors) */ - protected Map<IDeployableComponentAdapter<?>, SortedSet<FaultDetector>> taskFaultDetectorsMap; - - /** Random generator */ - private RandomExploration gen = RandomExploration.getInstance(); - - /** - * Associates "abstract" {@link IDeployableComponentAdapter}s with its instances contained in - * this {@link TaskGraph}. - */ - private Multimap<IDeployableComponentAdapter<?>, IDeployableComponentAdapter<?>> abstractToInstanceTaskMap; - - /** Creates an empty {@link DefaultTaskGraph}. */ - public DefaultTaskGraph() { - - graph = - new ListenableDirectedWeightedGraph<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge>( - ChannelAdapterWeightedEdge.class); - - taskFaultDetectorsMap = - new HashMap<IDeployableComponentAdapter<?>, SortedSet<FaultDetector>>(); - - abstractToInstanceTaskMap = HashMultimap.create(); - } - - /** Registers a deployable component (=task) with the {@link DefaultTaskGraph}. */ - @Override - public boolean addTask(IDeployableComponentAdapter<?> task) { - 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(IDeployableComponentAdapter<?> task, - IDeployableComponentAdapter<?> refTask) { - // FIXME: Hack, remove the map. - abstractToInstanceTaskMap.put(refTask, task); - return graph.addVertex(task); - } - - /** {@inheritDoc} */ - @Override - public void removeTask(IDeployableComponentAdapter<?> task) { - Collection<ChannelAdapterWeightedEdge> outgoingEdges = graph.outgoingEdgesOf(task); - Collection<ChannelAdapterWeightedEdge> incomingEdges = graph.incomingEdgesOf(task); - - graph.removeVertex(task); - // The outgoing edges must be removed *after* the "abstract" node, since a - // concurrent modification is performed on the graph resulting in an exception. - graph.removeAllEdges(outgoingEdges); - graph.removeAllEdges(incomingEdges); - - // Remove from the cache. - abstractToInstanceTaskMap.removeAll(task); - } - - /** {@inheritDoc} */ - @Override - public boolean addDataDependency(IDeployableComponentAdapter<?> sourceComponent, - Collection<IDeployableComponentAdapter<?>> destinationComponents, - ISignalAdapter<?> channelAdapter) { - - boolean addingAllEdgesSuccessful = true; - - // Add edges from the source component to each receiver. - for(IDeployableComponentAdapter<?> 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; - } - } - } - - return addingAllEdgesSuccessful; - } - - /** Registers a data dependencies between a source and its destination component. */ - public boolean addDataDependency(IDeployableComponentAdapter<?> sourceComponent, - IDeployableComponentAdapter<?> destinationComponent, ISignalAdapter<?> channelAdapter) { - graph.addVertex(sourceComponent); - graph.addVertex(destinationComponent); - return graph.addEdge(sourceComponent, destinationComponent, new ChannelAdapterWeightedEdge( - channelAdapter)); - } - - /** {@inheritDoc} */ - @Override - public Set<IDeployableComponentAdapter<?>> getTasks() { - return graph.vertexSet(); - } - - // TODO: Get rid of this method! - /** {@inheritDoc} */ - @Override - public - ListenableDirectedWeightedGraph<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge> - getGraph() { - return graph; - } - - /** {@inheritDoc} */ - @Override - public Double getPeriod() { - return period; - } - - /** - * {@inheritDoc} - * - * @throws InvalidTimingModelException - * see {@link TaskGraph#updatePeriod()}. - */ - @Override - public void updatePeriod() throws InvalidTimingModelException { - boolean isFirstSet = false; - // TODO: Move these consistency check to model validation framework - for(IDeployableComponentAdapter<?> 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."); - // } - } - } - - /** Returns the fault detector with a given index / ID for a given task. */ - public FaultDetector getFaultDetector(IDeployableComponentAdapter<?> task, int id) { - if(taskFaultDetectorsMap.containsKey(task)) { - Object[] faultDetectors = taskFaultDetectorsMap.get(task).toArray(); - if(id < faultDetectors.length) { - return (FaultDetector)faultDetectors[id]; - } - } - return null; - } - - /** {@inheritDoc} */ - @Override - public void addFaultDetector(IDeployableComponentAdapter<?> task, FaultDetector faultDetector) { - if(!taskFaultDetectorsMap.containsKey(task)) { - SortedSet<FaultDetector> faultDetectors = new TreeSet<FaultDetector>(); - taskFaultDetectorsMap.put(task, faultDetectors); - } - taskFaultDetectorsMap.get(task).add(faultDetector); - } - - /** {@inheritDoc} */ - @Override - public int getRandomFaultDetectorId(IDeployableComponentAdapter<?> task) { - if(taskFaultDetectorsMap.get(task) == null) - return 0; - return gen.nextInt(taskFaultDetectorsMap.get(task).size()); - } - - /** {@inheritDoc} */ - @Override - public void display() { - JGraphTVisualizer<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge> taskViz = - new JGraphTVisualizer<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge>( - this.getGraph()); - taskViz.displayGraph("Task graph"); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - String rval = ""; - - Iterator<IDeployableComponentAdapter<?>> iter = - new DepthFirstIterator<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge>( - graph); - while(iter.hasNext()) { - IDeployableComponentAdapter<?> deployableComponent = iter.next(); - rval = rval.concat("Task " + deployableComponent.getName() + ": "); - for(ChannelAdapterWeightedEdge edge : graph.outgoingEdgesOf(deployableComponent)) { - rval = rval.concat("->" + graph.getEdgeTarget(edge).getName()); - } - rval = rval.concat("\n"); - } - - return rval; - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public DefaultTaskGraph copy() { - DefaultTaskGraph clonedTaskGraph; - try { - clonedTaskGraph = (DefaultTaskGraph)super.clone(); - } catch(CloneNotSupportedException e) { - throw new AssertionError(); - } - clonedTaskGraph.graph = - new ListenableDirectedWeightedGraph<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge>( - ChannelAdapterWeightedEdge.class); - Graphs.addGraph(clonedTaskGraph.graph, graph); - clonedTaskGraph.taskFaultDetectorsMap = - new HashMap<IDeployableComponentAdapter<?>, SortedSet<FaultDetector>>( - taskFaultDetectorsMap); - - return clonedTaskGraph; - } - - /** {@inheritDoc} */ - @Override - public boolean containsTask(IDeployableComponentAdapter<?> task) { - if(task.isInstantiationRequired()) { - // FIXME: Hack to get the DSE working again. To fix it, replace the calls that need the - // instantiated component from an abstaract component, fix at the coller side. - return abstractToInstanceTaskMap.containsKey(task) ? true : graph.containsVertex(task); - } - return graph.containsVertex(task); - } - - /** {@inheritDoc} */ - @Override - public boolean containsAnyTaskOf(Collection<IDeployableComponentAdapter<?>> taskSet) { - for(IDeployableComponentAdapter<?> task : taskSet) { - if(containsTask(task)) { - return true; - } - } - return false; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraph.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraph.java deleted file mode 100644 index 6cf0235440cbd8fbbf19b2223436d886f83767ae..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraph.java +++ /dev/null @@ -1,109 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: TaskGraph.java 3841 2016-11-04 14:51:29Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph; - -import java.util.Collection; -import java.util.Set; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISignalAdapter; -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; - -/** - * Interface for {@link TaskGraph}s which are the (flattened) DSE-internal representations of a - * (hierarchical) logical architecture. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3841 $ - * @ConQAT.Rating RED Hash: 4F59C3F451E5B93C26979ECB988961CD - */ -public interface TaskGraph { - - /** Registers a data dependencies between a source and its destination components. */ - public boolean addDataDependency(IDeployableComponentAdapter<?> sourceComponent, - Collection<IDeployableComponentAdapter<?>> destinationComponents, - ISignalAdapter<?> channelAdapter); - - // TODO: Get rid of this method! - /** Returns the underlying {@link ListenableDirectedWeightedGraph}. */ - public - ListenableDirectedWeightedGraph<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge> - getGraph(); - - /** - * Updates the period of this {@link TaskGraph}: Determine the common period of the tasks - * within - * an independent task graph if it exists. Otherwise, set it to 0. - * - * @throws InvalidTimingModelException - * if the periods of the {@link TaskGraph}'s task are inconsistent. - */ - public void updatePeriod() throws InvalidTimingModelException; - - /** Returns the {@link TaskGraph}s period. */ - public Double getPeriod(); - - /** Returns the set of deployable components (=tasks) of this {@link TaskGraph}. */ - public Set<IDeployableComponentAdapter<?>> getTasks(); - - /** - * Checks whether {@code this} {@link TaskGraph} contains the given - * {@link IDeployableComponentAdapter} or an instance of it. - */ - public boolean containsTask(IDeployableComponentAdapter<?> task); - - /** - * Checks whether {@code this} {@link TaskGraph} contains any of the given - * {@link IDeployableComponentAdapter}s. - */ - public boolean containsAnyTaskOf(Collection<IDeployableComponentAdapter<?>> taskSet); - - /** - * Adds the given {@link IDeployableComponentAdapter} to the {@link TaskGraph}, i.e. as a vertex - * to the corresponding {@link DirectedGraph}. - */ - public boolean addTask(IDeployableComponentAdapter<?> 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(IDeployableComponentAdapter<?> task, - IDeployableComponentAdapter<?> refTask); - - /** Removes the given {@code task} and its data dependencies from the {@link TaskGraph}. */ - public void removeTask(IDeployableComponentAdapter<?> task); - - /** Creates a Dialog that illustrates this {@link TaskGraph}. */ - public void display(); - - /** Creates and returns a copy of {@code this} {@link TaskGraph}. */ - public <T extends TaskGraph> T copy(); - - /** Registers a fault detector for a given task. */ - public void addFaultDetector(IDeployableComponentAdapter<?> deployableComponent, - FaultDetector faultDetector); - - /** Returns a random fault detector index / ID for the given task. */ - public int getRandomFaultDetectorId(IDeployableComponentAdapter<?> deployableComponent); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraphInstantiator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraphInstantiator.java deleted file mode 100644 index 8272f2df0b0f6bd0fcee1c46dd27d56eb41d133e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/taskgraph/TaskGraphInstantiator.java +++ /dev/null @@ -1,177 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: TaskGraphInstantiator.java 3841 2016-11-04 14:51:29Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -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.IDeployableComponentAdapter; -import org.jgrapht.graph.ListenableDirectedWeightedGraph; - -/** - * Manages the construction of {@link TaskGraph}s whose vertices are exclusively instances of - * {@link IDeployableComponentAdapter}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3841 $ - * @ConQAT.Rating RED Hash: 1A1A0F4F180366BE93A6BC9B30E28C3E - */ -public class TaskGraphInstantiator<T extends TaskGraph> { - - /** - * Holds for each {@link TaskGraph} in the system a map that relates possibly abstract - * {@link IDeployableComponentAdapter} with the {@link IDeployableComponentAdapter} that - * instantiate them. - */ - private Map<T, Map<IDeployableComponentAdapter<?>, IDeployableComponentAdapter<?>>> instanceToAbstractNodeMap; - - /** - * Constructs a {@link TaskGraphInstantiator} that can create a {@link TaskGraph} containing - * only {@link IDeployableComponentAdapter} instances from the given {#link abstractGraph} - * using the given {#link encoding}. - */ - public TaskGraphInstantiator(T abstractGraph, - InstantiatedTaskMappingEncoding<? extends InstantiatedTaskMappingEntry> encoding) { - instanceToAbstractNodeMap = - new HashMap<T, Map<IDeployableComponentAdapter<?>, IDeployableComponentAdapter<?>>>(); - instanceToAbstractNodeMap.put(abstractGraph, - createAbstractInstantiatedNodeAssociations(encoding)); - } - - /** - * Constructs a {@link TaskGraphInstantiator} that can create {@link TaskGraph}s containing - * only {@link IDeployableComponentAdapter} instances from the given {#link abstractGraphs} - * using the given {#link encoding}. - */ - public TaskGraphInstantiator(Collection<T> abstractGraphs, - InstantiatedTaskMappingEncoding<? extends InstantiatedTaskMappingEntry> encoding) { - instanceToAbstractNodeMap = - new HashMap<T, Map<IDeployableComponentAdapter<?>, IDeployableComponentAdapter<?>>>(); - for(T taskGraph : abstractGraphs) { - instanceToAbstractNodeMap.put(taskGraph, - createAbstractInstantiatedNodeAssociations(encoding)); - } - } - - /** - * Creates {@link TaskGraph}s containing only {@link IDeployableComponentAdapter} instances for - * each {@link TaskGraph} in the given collection. - */ - public Collection<T> createMultipleInstanceTaskGraphs(Collection<T> abstractGraphs) { - Collection<T> instanceTaskGraphs = new ArrayList<T>(); - for(T taskGraph : abstractGraphs) { - instanceTaskGraphs.add(createInstanceTaskGraph(taskGraph)); - } - return instanceTaskGraphs; - } - - /** - * Creates a single {@link TaskGraph} containing only {@link IDeployableComponentAdapter} - * instances for the given {@link TaskGraph}. - */ - public T createInstanceTaskGraph(T abstractGraph) { - T instanceTaskGraph = abstractGraph.copy(); - - Map<IDeployableComponentAdapter<?>, IDeployableComponentAdapter<?>> nodeCorrespondenceMap = - instanceToAbstractNodeMap.get(abstractGraph); - assert (nodeCorrespondenceMap != null); - - Set<IDeployableComponentAdapter<?>> removeableVertices = - new HashSet<IDeployableComponentAdapter<?>>(); - for(Entry<IDeployableComponentAdapter<?>, IDeployableComponentAdapter<?>> instancePair : nodeCorrespondenceMap - .entrySet()) { - IDeployableComponentAdapter<?> instComp = instancePair.getKey(); - IDeployableComponentAdapter<?> abstrComp = instancePair.getValue(); - if(abstractGraph.containsTask(abstrComp) && abstrComp.isInstantiationRequired()) { - insertInstanceComponent(instanceTaskGraph, abstrComp, instComp); - // Add the instantiated "abstract" Component to the set of Components which shall be - // removed from the instanceGraph. Here, a set of these components is needed to not - // trying to remove the same abstract component twice by accident. - removeableVertices.add(abstrComp); - } - } - for(IDeployableComponentAdapter<?> abstractComponent : removeableVertices) { - instanceTaskGraph.removeTask(abstractComponent); - } - - return instanceTaskGraph; - } - - /** - * Replaces the given {#link abstractNode} with the given {#link instanceNode} in the {#link - * instanceTaskGraph}. - */ - public void - insertInstanceComponent(T instanceTaskGraph, - IDeployableComponentAdapter<?> abstractNode, - IDeployableComponentAdapter<?> instanceNode) { - ListenableDirectedWeightedGraph<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge> graph = - instanceTaskGraph.getGraph(); - instanceTaskGraph.addTask(instanceNode, abstractNode); - - Collection<ChannelAdapterWeightedEdge> incomingEdges = graph.incomingEdgesOf(abstractNode); - for(ChannelAdapterWeightedEdge incoming : incomingEdges) { - graph.addEdge(graph.getEdgeSource(incoming), instanceNode, - new ChannelAdapterWeightedEdge(incoming.getChannelAdapter())); - } - - Collection<ChannelAdapterWeightedEdge> outgoingEdges = graph.outgoingEdgesOf(abstractNode); - for(ChannelAdapterWeightedEdge outgoing : outgoingEdges) { - graph.addEdge(instanceNode, graph.getEdgeTarget(outgoing), - new ChannelAdapterWeightedEdge(outgoing.getChannelAdapter())); - } - } - - /** - * Creates a map which relates "abstract" {@link IDeployableComponentAdapter} with the - * {@link IDeployableComponentAdapter} instantiating the "abstract" - * {@link IDeployableComponentAdapter}. - */ - /** - * Creates a map which relates "abstract" {@link IDeployableComponentAdapter} with the - * {@link IDeployableComponentAdapter} instantiating the "abstract" - * {@link IDeployableComponentAdapter}. - */ - private - Map<IDeployableComponentAdapter<?>, IDeployableComponentAdapter<?>> - createAbstractInstantiatedNodeAssociations( - InstantiatedTaskMappingEncoding<? extends InstantiatedTaskMappingEntry> encoding) { - Map<IDeployableComponentAdapter<?>, IDeployableComponentAdapter<?>> instanceToAbstractNodeMap = - new HashMap<IDeployableComponentAdapter<?>, IDeployableComponentAdapter<?>>(); - for(IDeployableComponentAdapter<?> instantiatedComponent : encoding.getDeployedComponents()) { - if(instantiatedComponent.isInstantiation()) { - instanceToAbstractNodeMap.put(instantiatedComponent, - instantiatedComponent.getReplacedComponent()); - } else { - instanceToAbstractNodeMap.put(instantiatedComponent, instantiatedComponent); - } - } - - // assert (getMissingComponentInstantiations(abstractGraph).isEmpty()) : - // "Some abstract Components are missing an instatiation in the encoding."; - return instanceToAbstractNodeMap; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/comm/Message.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/comm/Message.java deleted file mode 100644 index dd6e1f0505dee1c7b20f0114c1cf5828296aceea..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/comm/Message.java +++ /dev/null @@ -1,263 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: Message.java 3841 2016-11-04 14:51:29Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.comm; - -import java.util.Collection; -import java.util.HashSet; - -import org.fortiss.af3.component.model.Channel; -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.IResourceAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISignalAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITransmissionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.jgrapht.DirectedGraph; -import org.jgrapht.graph.DefaultEdge; - -/** - * Unidirectional message between a sender and a receiver (identified by their respective - * {@link TimeSlot} of the {@link StrictTTSchedule}). While data dependencies between - * deployable components mapped to the same deployment target are assumed to be implemented using - * shared memory buffers (and the communication to consume no time), data dependencies between - * deployable components mapped to different deployment targets are modeled using explicit messages - * via a communication resource (e.g. a TDMA arbitrated bus). - * - * <ul> - * <li>TODO: Consider memory access times for intra-deployment unit communication</li> - * <li>TODO: Replace {@link Message} with {@link Channel} from the logical architecture, or an - * according adapter class?</li> - * </ul> - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3841 $ - * @ConQAT.Rating RED Hash: 915C92CFE08F605A2E1D1A5E25941AFC - */ -public class Message implements Comparable<Message> { - - /** References the sender of this {@link Message}, i.e. a deployed component/task. */ - private IMappingEntry sender; - - /** References the {@link IMappingEntry}s that are receivers of this {@link Message}. */ - private Collection<IMappingEntry> receiverMappingEntries; - - /** References the receiver of this {@link Message}, i.e. a deployed component/task. */ - private Collection<IResourceAdapter<?>> receiverResources; - - /** - * References the route (of platform resources) which this message must traverse to provide its - * content. - */ - private DirectedGraph<IResourceAdapter<?>, DefaultEdge> route; - - /** {@link ISignalAdapter} which is the logical counterpart of this {@link Message} */ - private ISignalAdapter<?> messageAdapter; - - /** {@link TimeSlot} in which sender of message is scheduled */ - private TimeSlot senderTimeSlot; - - /** {@link TimeSlot} in which receiver of message is scheduled */ - private HashSet<TimeSlot> receiverTimeSlots; - - /** Worst-case transmission time of message on its {@link ITransmissionUnitAdapter} */ - private double wctt; - - /** Contains the calculated size of the message. */ - private long sizeInBytes; - - /** - * Constructs a new {@link Message} between a sender and a receiver (identified by their - * respective {@link IMappingEntry}s in the {@link IMappingEncoding}). - */ - public Message(ISignalAdapter<?> channelAdapter, IMappingEntry deployedSender, - Collection<? extends IMappingEntry> receiverEntries) { - this.messageAdapter = channelAdapter; - this.sender = deployedSender; - if(sender != null && sender.getTarget() != null) { - sizeInBytes = messageAdapter.getSignalSize(); - } - - this.receiverResources = new HashSet<IResourceAdapter<?>>(); - this.receiverMappingEntries = new HashSet<IMappingEntry>(); - for(IMappingEntry receiver : receiverEntries) { - addReceiver(receiver); - } - - this.receiverTimeSlots = new HashSet<TimeSlot>(); - } - - /** - * Constructs a new {@link Message} between a sender and a receiver (identified by their - * respective {@link TimeSlot}s in the {@link StrictTTSchedule}). - */ - public Message(ISignalAdapter<?> channelAdapter, TimeSlot senderTimeSlot, - HashSet<TimeSlot> receiverTimeSlots) { - this(channelAdapter, senderTimeSlot, receiverTimeSlots, channelAdapter.getSignalSize()); - } - - /** - * Constructs a new {@link Message} between a sender and a receiver (identified by their - * respective {@link TimeSlot}s in the {@link StrictTTSchedule}). - */ - public Message(ISignalAdapter<?> channelAdapter, TimeSlot senderTimeSlot, - HashSet<TimeSlot> receiverTimeSlots, long messageSizeInBytes) { - this.messageAdapter = channelAdapter; - this.senderTimeSlot = senderTimeSlot; - this.receiverTimeSlots = receiverTimeSlots; - - wctt = 0.0; - sizeInBytes = messageSizeInBytes; - - this.receiverResources = new HashSet<IResourceAdapter<?>>(); - for(TimeSlot currentReceiverSlot : receiverTimeSlots) { - addReceiverResource(currentReceiverSlot.getResource()); - } - } - - /** - * Adds a sender time slot to this message, it the time. - */ - public boolean addMessageSenderTimeSlot(TimeSlot senderSlot) { - if(senderSlot == null || senderSlot.getResource() == null || - senderSlot.getResource() != sender.getTarget()) { - return false; - } - this.senderTimeSlot = senderSlot; - return true; - } - - /** - * Adds a receiver time slot to the receiver list of this message and calculates the route to - * the {@link IResourceAdapter} it has been deployed upon. - */ - public boolean addMessageReceiverTimeSlots(TimeSlot receiverSlot) { - assert (receiverSlot != null) : "A reciever slot may not be null."; - return receiverTimeSlots.add(receiverSlot); - } - - /** Adds an {@link IMappingEntry} as a receiver of this message. */ - public void addReceiver(IMappingEntry receiver) { - receiverMappingEntries.add(receiver); - receiverResources.add(receiver.getTarget()); - } - - /** Adds an {@link IMappingEntry} as a receiver of this message. */ - public void addReceiverResource(IResourceAdapter<?> reciever) { - receiverResources.add(reciever); - } - - /** Returns the {@link ISignalAdapter} corresponding to this messages */ - public ISignalAdapter<?> getSignalAdapter() { - return messageAdapter; - } - - /** - * Returns the size of the message (in bytes) which is defined via the data type and its - * implementation in the sending execution unit. - */ - public long getMessageSize() { - return sizeInBytes; - } - - /** Returns the {@link IMappingEntry} of the sender of this message. */ - public IMappingEntry getSender() { - return sender; - } - - /** Returns the {@link IMappingEntry}s that receive this message. */ - public Collection<IMappingEntry> getReceiverMappingEntries() { - return receiverMappingEntries; - } - - /** - * Returns the {@link Collection} of {@link IMappingEntry}s that are the receivers of this - * message. - */ - public Collection<IResourceAdapter<?>> getReceiverResources() { - return receiverResources; - // Collection<IResourceAdapter<?>> recvResources = new HashSet<>(); - // for(IMappingEntry entry : receiverMappingEntries) { - // recvResources.add(entry.getTarget()); - // } - // return recvResources; - } - - /** Returns the route which this {@link Message} must traverse. */ - public DirectedGraph<IResourceAdapter<?>, DefaultEdge> getRoute() { - return route; - } - - /** - * Sets the route in the form of a {@link DirectedGraph} which this {@link Message} must - * traverse. - */ - public void setRoute(DirectedGraph<IResourceAdapter<?>, DefaultEdge> messageRoute) { - route = messageRoute; - } - - /** Returns the {@link TimeSlot} of the sender. */ - public TimeSlot getSenderTimeSlot() { - return senderTimeSlot; - } - - /** Returns the {@link TimeSlot} of the receiver. */ - public HashSet<TimeSlot> getReceiverTimeSlots() { - return receiverTimeSlots; - } - - /** Returns worst-case transmission time (in seconds) */ - public double getWCTT() { - return wctt; - } - - /** Sets the WCTT (in seconds) for this message. This method is used for message scheduling. */ - public void setWCTT(double calculatedWctt) { - wctt = calculatedWctt; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - String receiverStr = "["; - for(TimeSlot currentReceiverSlot : receiverTimeSlots) { - receiverStr += currentReceiverSlot + ", "; - } - return senderTimeSlot + "->" + receiverStr + "]"; - } - - /** {@inheritDoc} */ - @Override - public int compareTo(Message compareMessage) { - assert (this.senderTimeSlot != null); - if(this.senderTimeSlot == null) { - return -1; - } - assert (compareMessage.getSenderTimeSlot() != null); - - if(this.senderTimeSlot.getEndTime() > compareMessage.getSenderTimeSlot().getEndTime()) { - return 1; - } else if(this.senderTimeSlot.getEndTime() == compareMessage.getSenderTimeSlot() - .getEndTime()) { - return 0; - } else { - return -1; - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/comm/MessageGenerator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/comm/MessageGenerator.java deleted file mode 100644 index 09093dc2e5455ae99558aa090171a505d6879f20..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/comm/MessageGenerator.java +++ /dev/null @@ -1,194 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MessageGenerator.java 3964 2016-12-12 12:55:09Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.comm; - -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.castToRawColl; -import static org.fortiss.tooling.common.util.LambdaUtils.filterSet; - -import java.util.Collection; -import java.util.HashSet; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.comm.constraint.InternalIsolatedCommunicationSet; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ISignalAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; - -/** - * Responsible for generating the {@link Message}s that must be sent between different - * {@link IMappingEntry}s to satisfy the data dependencies that are encoded in the input logical - * architecture. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3964 $ - * @ConQAT.Rating RED Hash: 3DC72E01DAA810BB02C17F77FF868FB1 - */ -public class MessageGenerator<S extends TaskMappingEntry, T extends TaskMappingEncoding<S>> { - - /** Reference to the systemModel. */ - private SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Constructor. */ - public MessageGenerator(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } - - /** - * Generates messages from the given {#link encoding}. This methods evaluates the {#link - * encoding} - */ - public Collection<Message> generateMessages(T encoding) { - Collection<Message> generatedMessages = new HashSet<Message>(); - - // TODO: represent the signals in the task graph: do not use the systemModelAdapter here. - // Consequence: there may be multiple edges between two vertices (tasks). - for(S entry : encoding.getMappingEntries()) { - IDeployableComponentAdapter<?> senderComponent = entry.getDeployableComponent(); - if(senderComponent.isInstantiation()) { - senderComponent = senderComponent.getReplacedComponent(); - } - - Collection<ISignalAdapter<?>> emittedMessages = - castToRawColl(systemModelAdapter.getEmmittedMessages(senderComponent)); - - Collection<InternalIsolatedCommunicationSet> allIsoCommConstr = - encoding.getConstraintsOf(InternalIsolatedCommunicationSet.class); - Collection<InternalIsolatedCommunicationSet> otherIsoCommConstr = - getOtherIsolationCommConstraints(encoding, entry); - - for(ISignalAdapter<?> currentMessageAdapter : emittedMessages) { - // Create a Collection of dependent MappingEntries, for which messages are generated - // (if required). - Collection<S> mappingEntriesOfSuccesors = - getSuccessorMappingEntries(encoding, currentMessageAdapter); - Message generatedMessage = - generateMessageForSenderEntry(currentMessageAdapter, entry, - mappingEntriesOfSuccesors, allIsoCommConstr, otherIsoCommConstr); - if(generatedMessage != null) { - generatedMessages.add(generatedMessage); - } - } - } - - return generatedMessages; - } - - /** - * Creates a {@link Collection} which contains all {@link IMappingEntry}s that are causally - * depend on the given sender {@link IDeployableComponentAdapter}. - */ - private Collection<S> getSuccessorMappingEntries(T encoding, ISignalAdapter<?> emittedMessage) { - Collection<S> mappingEntriesOfSuccesors = new HashSet<S>(); - Collection<IDeployableComponentAdapter<?>> realSuccessorComponents = new HashSet<>(); - - for(IDeployableComponentAdapter<?> successorComponent : emittedMessage.getTargets()) { - if(successorComponent.isInstantiationRequired()) { - // Since the generated message refer to the components in the system model adapter, - // we must search the encoding for equivalent components in this special case - // (instantiation). - realSuccessorComponents.addAll(successorComponent.getReplacementComponents()); - } else { - realSuccessorComponents.add(successorComponent); - } - } - - for(IDeployableComponentAdapter<?> successorComponent : realSuccessorComponents) { - Collection<IDeployableComponentAdapter<?>> encComps = - filterSet(encoding.getDeployedComponents(), - c -> c.getObject() == successorComponent.getObject()); - for(IDeployableComponentAdapter<?> encComp : encComps) { - mappingEntriesOfSuccesors.addAll(encoding.getMappingEntriesOf(encComp)); - } - } - return mappingEntriesOfSuccesors; - } - - /** - * Creates a new Message for the given {#link senderMappingEntry} and its receiver - * {@link IMappingEntry}s if the sender and the receiver are not mapped onto the same - * {@link IExecutionUnitAdapter}. - */ - private Message generateMessageForSenderEntry(ISignalAdapter<?> senderChannel, - S senderMappingEntry, Collection<S> mappingEntriesOfSuccesors, - Collection<InternalIsolatedCommunicationSet> allConstraints, - Collection<InternalIsolatedCommunicationSet> otherConstraints) { - - Collection<S> receiverEntries = new HashSet<S>(); - for(S mappingEntryReceiver : mappingEntriesOfSuccesors) { - // TODO: knowledge about prev steps. - IMappingEntry constrEntry = - mappingEntryReceiver.getAssociatedElement(AbstractTaskMappingEntry.class); - if((senderMappingEntry.getTarget() != mappingEntryReceiver.getTarget())) { - if(isPartOfIsolationCommConstraint(allConstraints, senderMappingEntry) && - !otherConstraints.stream().anyMatch(c -> c.contains(constrEntry))) { - receiverEntries.add(mappingEntryReceiver); - } else if(!isPartOfIsolationCommConstraint(allConstraints, senderMappingEntry)) { - receiverEntries.add(mappingEntryReceiver); - } - } - } - - if(!receiverEntries.isEmpty()) { - return new Message(senderChannel, senderMappingEntry, receiverEntries); - } - return null; - } - - /** - * Returns whether the given {@link IMappingEntry} is included in any of the given - * {@link InternalIsolatedCommunicationSet}s. - */ - private boolean isPartOfIsolationCommConstraint( - Collection<InternalIsolatedCommunicationSet> isoComm, IMappingEntry entry) { - IMappingEntry actualEntry = entry.getAssociatedElement(AbstractTaskMappingEntry.class); - - for(InternalIsolatedCommunicationSet constr : isoComm) { - if(constr.contains(actualEntry)) { - return true; - } - } - - return false; - } - - /** - * Returns a collection of all {@link InternalIsolatedCommunicationSet} constraints that do not - * include the given {@link IMappingEntry}. - */ - private Collection<InternalIsolatedCommunicationSet> getOtherIsolationCommConstraints( - T outGenotype, S entry) { - // TODO: here we use the knowledge that we have instantiated task mapping entries. - IMappingEntry actualEntry = entry.getAssociatedElement(AbstractTaskMappingEntry.class); - - Collection<InternalIsolatedCommunicationSet> otherConstraints = new HashSet<>(); - Collection<InternalIsolatedCommunicationSet> isoComm = - outGenotype.getConstraintsOf(InternalIsolatedCommunicationSet.class); - for(InternalIsolatedCommunicationSet constr : isoComm) { - if(!constr.getIsolatedCommunicationSet().contains(actualEntry)) { - otherConstraints.add(constr); - } - } - - return otherConstraints; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/faultmodel/FaultDetector.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/faultmodel/FaultDetector.java deleted file mode 100644 index cc71e85deab1a10010da6f7105142eb5f51fbeb0..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/faultmodel/FaultDetector.java +++ /dev/null @@ -1,73 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FaultDetector.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.faultmodel; - -/** - * Abstraction of {@link FaultDetector}s (providing information on the runtime overhead caused by - * the {@link FaultDetector}, as well as its coverage (capability to detect faults). - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 78332B5EF499ADEADA289AEF620A74C6 - */ -public class FaultDetector implements java.lang.Comparable<FaultDetector> { - - /** {@link FaultDetector}'s runtime overhead. */ - private double overhead; - - /** {@link FaultDetector}'s coverage. */ - private double coverage; - - /** Constructs a new {@link FaultDetector}. */ - public FaultDetector(double o, double c) { - overhead = o; - coverage = c; - } - - /** Returns the {@link FaultDetector}'s overhead. */ - public double getOverhead() { - return overhead; - } - - /** Returns the {@link FaultDetector}'s coverage. */ - public double getCoverage() { - return coverage; - } - - /** {@inheritDoc} */ - @Override - public int compareTo(FaultDetector fd) { - // sort the detector according to overhead - if(overhead < fd.overhead) { - return -1; - } else if(overhead > fd.overhead) { - return 1; - } else { - return(coverage <= fd.coverage ? -1 : 1); - } - } - - /** {@inheritDoc} */ - @Override - public String toString() { - - return "(" + overhead + "," + coverage + ")"; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/IMappingEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/IMappingEncoding.java deleted file mode 100644 index fcc86a2d774ed5ed44373027cae899f30cafead3..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/IMappingEncoding.java +++ /dev/null @@ -1,63 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IMappingEncoding.java 3885 2016-11-11 09:41:01Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.mapping; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -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.service.IExplorationEncoding; - -/** - * Generalized interface for accessing Request->Resource mappings that are the result of a DSE. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3885 $ - * @ConQAT.Rating RED Hash: 884953D9058F7E1B31B4131B21BC2C90 - */ -public interface IMappingEncoding extends IExplorationEncoding { - - /** - * Returns the allocation of a specific {@link IRequestAdapter} to its {@link IMappingEntry}s. - */ - public Collection<IResourceAdapter<?>> getAllocatedResourcesFor(IRequestAdapter<?> request); - - /** - * Returns the collection of {@link IMappingEntry}s which represent the (multi-)allocation of - * the given {@link IDeployableComponentAdapter}s to {@link IExecutionUnitAdapter}s. - */ - public Collection<IMappingEntry> getIMappingEntriesOf(IDeployableComponentAdapter<?> component); - - /** - * Returns whether {@code this} {@link IMappingEncoding} contains the given - * {@link IMappingEntry}. - */ - public boolean containsEntry(IMappingEntry entry); - - /** - * Returns the collection of {@link IMappingEntry}s contained in {@code this} - * {@link IMappingEncoding}. - */ - public Collection<IMappingEntry> getIMappingEntries(); - - /** Returns the collection of deployed {@link IDeployableComponentAdapter}s. */ - public Collection<IDeployableComponentAdapter<?>> getDeployedComponents(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/IMappingEntry.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/IMappingEntry.java deleted file mode 100644 index 20215f5d6adfd65543c2ea41d4b9747ee47269d0..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/IMappingEntry.java +++ /dev/null @@ -1,42 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IMappingEntry.java 3560 2016-09-23 14:13:46Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.mapping; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.guava.IAssociativeElement; - -/** - * External interface that provides the entries of an {@link IMappingEncoding}. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3560 $ - * @ConQAT.Rating RED Hash: BF7C1120AAA8DA2FDA560144FAD21A27 - */ -public interface IMappingEntry extends IAssociativeElement<IMappingEntry> { - - /** Return target resource to which the request is mapped. */ - IExecutionUnitAdapter<?> getTarget(); - - /** - * Returns the {@link IDeployableComponentAdapter} that is represented by this - * {@link IMappingEntry}. - */ - IDeployableComponentAdapter<?> getDeployableComponent(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/comm/IMessageRouter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/comm/IMessageRouter.java deleted file mode 100644 index ba90fa408727992cf65f0a07792d80a2bcd9026b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/comm/IMessageRouter.java +++ /dev/null @@ -1,66 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IMessageRouter.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.comm; - -import java.util.Collection; -import java.util.Map; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ICommunicationResourceAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.comm.Message; -import org.jgrapht.DirectedGraph; -import org.jgrapht.graph.DefaultEdge; - -/** - * Interface for entities that route messages on a physical/virtual platform. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 5F0B78D029247AC29FA251D735077ED3 - */ -public interface IMessageRouter { - - /** - * Calculates the message routes for each {@link Message} given in the {@link Collection} {#link - * messagesToRoute}. - * - * @return {@link Map} that relates the Message to its route. - */ - Map<Message, DirectedGraph<IResourceAdapter<?>, DefaultEdge>> calculateMessageRoutes( - Collection<Message> messagesToRoute); - - /** - * Returns the remaining {@link Message}/communication graphs for the given {@link Message}, - * where ... denotes the already processed {@link ICommunicationResourceAdapter}. - */ - // TODO: replace the IResourceAdapter with an ICommunicationResourceAdapter. - Map<IResourceAdapter<?>, DirectedGraph<IResourceAdapter<?>, DefaultEdge>> - getRemainingMessageGraphs(Message message, IResourceAdapter<?> processedResource, - DirectedGraph<IResourceAdapter<?>, DefaultEdge> messageRoute); - - /** - * Calculates the route of a message from the source to given receivers. The route is given as a - * {@link DirectedGraph} whose leaves are the target {@link IResourceAdapter}s. - */ - DirectedGraph<IResourceAdapter<?>, DefaultEdge> calculateMessageRoute( - IResourceAdapter<?> source, Collection<IResourceAdapter<?>> receiverResources); - - /** Returns the route which the given {@link Message} must traverse to deliver its content. */ - DirectedGraph<IResourceAdapter<?>, DefaultEdge> getRouteOf(Message msg); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/comm/MessageRouterBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/comm/MessageRouterBase.java deleted file mode 100644 index f771ffb55002478bf88854c4f78831fe796be085..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/comm/MessageRouterBase.java +++ /dev/null @@ -1,91 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MessageRouterBase.java 3062 2016-06-20 17:59:20Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.comm; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.comm.Message; -import org.jgrapht.DirectedGraph; -import org.jgrapht.Graph; -import org.jgrapht.graph.DefaultEdge; - -/** - * Base class which caches previously calculated routes of {@link Message}s. Varying methods to - * calculate the routes can be implemented in the derived classes. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3062 $ - * @ConQAT.Rating RED Hash: 894341A61C2055313F5094D54B266862 - */ -public abstract class MessageRouterBase implements IMessageRouter { - - /** Representation of input system model */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Graph containing the communication graph of the platform onto which the deployment is done. */ - protected Graph<IResourceAdapter<?>, DefaultEdge> platformCommunicationGraph; - - /** Contains the calculated routes of the generated {@link Message}s. */ - private Map<Message, DirectedGraph<IResourceAdapter<?>, DefaultEdge>> messagesRoutes; - - /** Constructs a scheduler for a given input model. */ - protected MessageRouterBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - messagesRoutes = - new ConcurrentHashMap<Message, DirectedGraph<IResourceAdapter<?>, DefaultEdge>>(); - platformCommunicationGraph = - systemModelAdapter.getPlatformCommunicationGraph().getActualGraph(); - } - - /** {@inheritDoc} */ - @Override - public synchronized Map<Message, DirectedGraph<IResourceAdapter<?>, DefaultEdge>> - calculateMessageRoutes(Collection<Message> messagesToRoute) { - Map<Message, DirectedGraph<IResourceAdapter<?>, DefaultEdge>> messagesRoutes = - new HashMap<Message, DirectedGraph<IResourceAdapter<?>, DefaultEdge>>(); - - // Calculate the route of each message and associate the route with the message. - for(Message currentMessage : messagesToRoute) { - DirectedGraph<IResourceAdapter<?>, DefaultEdge> calculatedMessageRoute = - calculateMessageRoute(currentMessage.getSender().getTarget(), - currentMessage.getReceiverResources()); - // Check if any *invalid* communication were required by the mapping. - if(calculatedMessageRoute == null) { - return null; - } - messagesRoutes.put( - currentMessage, - calculateMessageRoute(currentMessage.getSender().getTarget(), - currentMessage.getReceiverResources())); - } - - return messagesRoutes; - } - - /** {@inheritDoc} */ - @Override - public DirectedGraph<IResourceAdapter<?>, DefaultEdge> getRouteOf(Message msg) { - return messagesRoutes.get(msg); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/comm/ShortestPathRouter.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/comm/ShortestPathRouter.java deleted file mode 100644 index 23c8c273a0ce28e2a61985e05e0960a63104e1f2..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/mapping/comm/ShortestPathRouter.java +++ /dev/null @@ -1,141 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ShortestPathRouter.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.comm; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.comm.Message; -import org.jgrapht.DirectedGraph; -import org.jgrapht.Graphs; -import org.jgrapht.alg.BellmanFordShortestPath; -import org.jgrapht.alg.ConnectivityInspector; -import org.jgrapht.graph.DefaultDirectedGraph; -import org.jgrapht.graph.DefaultEdge; -import org.jgrapht.graph.DirectedSubgraph; - -/** - * Calculates the shortest path from the sending entity to its receivers on a physical/virtual - * platform. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 20D3874505D5F1F82D9865AEFE65733F - */ -public class ShortestPathRouter extends MessageRouterBase { - - /** Buffers the already calculated shortest paths for the sender {@link IResourceAdapter}. */ - private Map<IResourceAdapter<?>, BellmanFordShortestPath<IResourceAdapter<?>, DefaultEdge>> shortestPathForSender; - - /** Constructs a simple shortest path router for a given exploration run */ - public ShortestPathRouter(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - super(systemModelAdapter); - - // TODO: Replace with more efficient Dijkstra, which needs an modification to contain the - // shortest paths to all other vertices in the graph. - shortestPathForSender = - new ConcurrentHashMap<IResourceAdapter<?>, BellmanFordShortestPath<IResourceAdapter<?>, DefaultEdge>>(); - } - - /** {@inheritDoc} */ - @Override - public synchronized DirectedGraph<IResourceAdapter<?>, DefaultEdge> calculateMessageRoute( - IResourceAdapter<?> source, Collection<IResourceAdapter<?>> receiverResources) { - // Generates a graph that contains the message's path to each receiver in the following - // manner: - // - Find the shortest path from the sender to each receiver (using BellmanFord) - // - Construct a graph from the edge list of the shortest path to each receiver - DefaultDirectedGraph<IResourceAdapter<?>, DefaultEdge> messageGraph = - new DefaultDirectedGraph<IResourceAdapter<?>, DefaultEdge>(DefaultEdge.class); - - // Check, if the shortest paths have already been calculated for the given sender/source. If - // not start a new shortest path analysis using BellmanFord. - BellmanFordShortestPath<IResourceAdapter<?>, DefaultEdge> shortestPathForCurrentMessage = - shortestPathForSender.get(source); - if(shortestPathForCurrentMessage == null) { - shortestPathForCurrentMessage = - new BellmanFordShortestPath<IResourceAdapter<?>, DefaultEdge>( - platformCommunicationGraph, source); - shortestPathForSender.put(source, shortestPathForCurrentMessage); - } - - for(IResourceAdapter<?> currentReceiver : receiverResources) { - List<DefaultEdge> shortestMessagePath = - shortestPathForCurrentMessage.getPathEdgeList(currentReceiver); - // No valid path between source and receiver => invalid mapping; - if(shortestMessagePath == null) { - return null; - } - // Add all vertices and edges. - Graphs.addAllEdges(messageGraph, platformCommunicationGraph, shortestMessagePath); - } - - return messageGraph; - } - - /** {@inheritDoc} */ - @Override - public Map<IResourceAdapter<?>, DirectedGraph<IResourceAdapter<?>, DefaultEdge>> - getRemainingMessageGraphs(Message message, IResourceAdapter<?> communicationResource, - DirectedGraph<IResourceAdapter<?>, DefaultEdge> messageRoute) { - // Get the direct successors of the current message sender, which form the senders of the - // generated messages. - List<IResourceAdapter<?>> directSuccessorVertices = - Graphs.successorListOf(messageRoute, communicationResource); - - Set<IResourceAdapter<?>> targetVertices = new HashSet<IResourceAdapter<?>>(); - targetVertices.add(communicationResource); - targetVertices.addAll(message.getReceiverResources()); - - // Generate a working graph, that will be used to identify the correct allocation of - // receivers to newly created messages. Therefore, the connection to the current sender is - // cut. - DirectedGraph<IResourceAdapter<?>, DefaultEdge> workingGraph = - new DefaultDirectedGraph<IResourceAdapter<?>, DefaultEdge>(DefaultEdge.class); - Graphs.addGraph(workingGraph, messageRoute); - for(DefaultEdge edgeFromProcessedResource : workingGraph.edgesOf(communicationResource)) { - workingGraph.removeEdge(edgeFromProcessedResource); - } - - // Generate the routes of the successor messages using the connctivity inspector and the - // workingGraph. For each successor message, a subgraph is determined that contains all - // reachable receivers. - ConnectivityInspector<IResourceAdapter<?>, DefaultEdge> messageConnectivity = - new ConnectivityInspector<IResourceAdapter<?>, DefaultEdge>(workingGraph); - Map<IResourceAdapter<?>, DirectedGraph<IResourceAdapter<?>, DefaultEdge>> remainingSubGraphs = - new HashMap<IResourceAdapter<?>, DirectedGraph<IResourceAdapter<?>, DefaultEdge>>(); - for(IResourceAdapter<?> successor : directSuccessorVertices) { - Set<IResourceAdapter<?>> successorRouteVertices = - messageConnectivity.connectedSetOf(successor); - successorRouteVertices.add(communicationResource); - remainingSubGraphs.put(successor, - new DirectedSubgraph<IResourceAdapter<?>, DefaultEdge>(messageRoute, - successorRouteVertices, null)); - } - - return remainingSubGraphs; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/random/RandomExploration.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/random/RandomExploration.java deleted file mode 100644 index 240c2c5727ec563396658e143ff29f389c1572c3..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/random/RandomExploration.java +++ /dev/null @@ -1,152 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: RandomExploration.java 3462 2016-09-06 08:33:17Z barner $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.random; - -import java.security.SecureRandom; -import java.util.Random; - -import com.google.common.primitives.Longs; - -/** - * Central random number generator for the Exploration. It provides access to both - * deterministic/pseudo-random and "real" random number generators. The type of generator must be - * defined during construction time. - * <p> - * The driving idea behind this centralized random number generator is to provide the possibility to - * generate reproducible results by providing identical seeds. On the other hand "real" randomness - * must be also provided for practical applications. - * - * @author diewald - * @author $Author: barner $ - * @version $Rev: 3462 $ - * @ConQAT.Rating RED Hash: B4E865FF325751300B2D1982B0AF231E - */ -public class RandomExploration { - - /** Defines the types of random number generators that are used within the DSE. */ - public static enum RandomnessType { - /** Deterministic random number generator (using the provided seed). */ - deterministic, - /** Pseudo random number generator (ignoring the seed). */ - pseudoRandom, - /** "Real" random number generator. */ - realRandom; - } - - /** Defines the type of random numbers that this class shall provide. */ - RandomnessType randType; - - /** Thread-safe singleton. */ - private static final class InstanceHolder { - /** The actual instance of this single. Synchronization is done by the ClassLoader. */ - static final RandomExploration INSTANCE = new RandomExploration(); - } - - /** Constructor. Avoid instantiation by other objects. */ - private RandomExploration() { - } - - /** Provides the RandomExploration number generator singleton. */ - public static RandomExploration getInstance() { - return InstanceHolder.INSTANCE; - } - - /** Flag to allow the singleton to be initialized only once. */ - private boolean isInitialized = false; - - /** Actual random number Generator. */ - private Random randGenerator; - - /** - * Initialize the central random number generator of the DSE by providing information about the - * randomness type and the seed that shall be used for this exploration run. - * - * @param randType - * {@link RandomnessType} that shall be used within the DSE. - * @param seed - * Seed to be forwarded to the "real" random number generator. - * @throws Exception - * if the centralized random number generator has been initialized before. - */ - public boolean init(RandomnessType randType, long seed) throws Exception { - if(isInitialized) { - throw new Exception("The RandomExploration singleton can only be initialized once."); - } - if(randType == RandomnessType.deterministic) { - randGenerator = new Random(seed); - } else if(randType == RandomnessType.pseudoRandom) { - randGenerator = new Random(); - } else if(randType == RandomnessType.realRandom) { - randGenerator = new SecureRandom(Longs.toByteArray(seed)); - } - isInitialized = true; - - return true; - } - - /** - * Re-Initialize the central random number generator of the DSE, which must be performed if - * successive runs of the DSE shall have a deterministic behavior. - * - * @throws Exception - * Exception if the singleton has not been initialized before, or if another - * instance of the backend random number generator cannot be instantiated. - */ - public void reInit() throws Exception { - if(!isInitialized) { - throw new Exception( - "The RandomExploration singleton can only be reinitialized if init(...) has been called before."); - } - randGenerator = randGenerator.getClass().newInstance(); - } - - /** - * Provides the next boolean value as given by the chosen random generator. Wrapper for - * {@link Random#nextBoolean()}. - */ - public boolean nextBoolean() { - assert (randGenerator != null); - - return randGenerator.nextBoolean(); - } - - /** - * Provides the next double value as given by the chosen random generator. Wrapper for - * {@link Random#nextDouble()}. - */ - public double nextDouble() { - assert (randGenerator != null); - - return randGenerator.nextDouble(); - } - - /** - * Provides the next boolean value as given by the chosen random generator. Wrapper for - * {@link Random#nextInt(int)}. - */ - public int nextInt(int n) { - assert (randGenerator != null); - - return randGenerator.nextInt(n); - } - - /** Returns whether the centralized random number generator has been initialized. */ - public boolean isInitialized() { - return isInitialized; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/ScheduleRuntimeException.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/ScheduleRuntimeException.java deleted file mode 100644 index 7874969f1c1c7e28a742ef33741c0d52adbda2a4..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/ScheduleRuntimeException.java +++ /dev/null @@ -1,63 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ScheduleRuntimeException.java 2403 2016-03-03 17:10:02Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.sched; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule; - -/** - * {@link RuntimeException} that is specific for errors in the scheduling. It allows to obtain the - * faulty {@link StrictTTSchedule} via getter method such that it can be displayed in the schedule - * plotter. - * <p> - * Since Opt4J does not allow to throw exceptions in the decoding phase, the only "clean" way to - * hand faulty {@link StrictTTSchedule}s to the UI is using {@link RuntimeException}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 2403 $ - * @ConQAT.Rating RED Hash: 3C8D6FADE4C493AE91FDCA058607F7E2 - */ -public class ScheduleRuntimeException extends RuntimeException { - - /** The associated {@link StrictTTSchedule} of this exception. */ - private StrictTTSchedule<?, ?> schedule; - - /** Constructor. */ - public ScheduleRuntimeException(StrictTTSchedule<?, ?> schedule) { - super(); - this.schedule = schedule; - } - - /** - * Returns the (invalid) {@link StrictTTSchedule} that is which is associated with this - * exception and provides the given message. - */ - public ScheduleRuntimeException(StrictTTSchedule<?, ?> schedule, String message) { - super(message); - this.schedule = schedule; - } - - /** - * Returns the (invalid) {@link StrictTTSchedule} that is which is associated with this - * exception. - */ - public StrictTTSchedule<?, ?> getSchedule() { - return schedule; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/SchedulerBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/SchedulerBase.java deleted file mode 100644 index 594c224a11fc17b1eb4d531e51522a438a766bb2..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/SchedulerBase.java +++ /dev/null @@ -1,91 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SchedulerBase.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.sched; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.time.DeadlineConstraint; - -/** - * Base class for schedulers. - * - * @author barner - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: 5D9B8619C180BEC70FE003273BF660D7 - */ -public class SchedulerBase { - /** Precision for double */ - protected final static int DOUBLE_PRECISION = 10; - - /** Representation of input system model */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** Contains the References to the {@link ExplorationTarget}s related to timing. */ - protected Collection<DeadlineConstraint> deadlines; - - /** Contains the reference deployable component -> deadline value. */ - protected Map<IDeployableComponentAdapter<?>, DeadlineConstraint> componentDeadlineSourceMap; - - /** Contains the reference deadline -> target component. */ - protected Map<DeadlineConstraint, IDeployableComponentAdapter<?>> deadlineTargetComponent; - - /** Constructs a scheduler for a given input model. */ - public SchedulerBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - this.systemModelAdapter = systemModelAdapter; - this.deadlines = - expSpec.getTargets().stream().filter(t -> (t instanceof DeadlineConstraint)) - .map(DeadlineConstraint.class::cast).collect(Collectors.toList()); - - componentDeadlineSourceMap = - new HashMap<IDeployableComponentAdapter<?>, DeadlineConstraint>(); - deadlineTargetComponent = new HashMap<DeadlineConstraint, IDeployableComponentAdapter<?>>(); - - createComponentDeadlineMap(); - } - - /** - * Creates two maps that <li>relate a {@link IDeployableComponentAdapter} which is defined as - * the "source" of a deadline to its {@link DeadlineConstraint} and <li>a map that relates - * {@link DeadlineConstraint}s with its "target" {@link IDeployableComponentAdapter}s. - */ - private void createComponentDeadlineMap() { - if(deadlines == null) { - return; - } - - for(DeadlineConstraint currentDeadline : deadlines) { - for(IDeployableComponentAdapter<?> deployableComponent : systemModelAdapter - .getDeployableComponents()) { - if(deployableComponent.getObject() == currentDeadline.getStartComponent()) { - componentDeadlineSourceMap.put(deployableComponent, currentDeadline); - } else if(deployableComponent.getObject() == currentDeadline.getEndComponent()) { - deadlineTargetComponent.put(currentDeadline, deployableComponent); - } - } - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/comm/TDMABusScheduler.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/comm/TDMABusScheduler.java deleted file mode 100644 index 3b6ae34728c305a00def174812e98138ecf95394..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/comm/TDMABusScheduler.java +++ /dev/null @@ -1,701 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: TDMABusScheduler.java 3878 2016-11-10 09:53:30Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.sched.comm; - -import static java.lang.Math.max; -import static java.lang.Math.min; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskgraph.InstantiatedAcyclicTaskGraphEncoding; -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.backend.opt4j.solution.StrictTTSchedule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.StrictTTSchedule.ResourceSchedule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.TimeSlot; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ICommunicationResourceAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -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.IResourceAdapter; -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.arch.taskgraph.AcyclicTaskGraph; -import org.fortiss.af3.exploration.alg.dse.sysmodel.comm.Message; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.comm.IMessageRouter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.comm.ShortestPathRouter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.sched.SchedulerBase; -import org.fortiss.af3.exploration.alg.graph.display.JGraphTVisualizer; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.jgrapht.DirectedGraph; -import org.jgrapht.Graphs; -import org.jgrapht.graph.DefaultEdge; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -/** - * Simple TDMA bus scheduler that adds the communication time to a pure task schedule - * ({@link StrictTTSchedule}). - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3878 $ - * @ConQAT.Rating RED Hash: 70E109DCCBC19C091032DDCA8DF96AAE - */ -public class TDMABusScheduler<S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - extends SchedulerBase { - - /** - * References the {@link IMessageRouter} used to determine the path of generated {@link Message} - * s within this scheduler. - */ - private IMessageRouter messageRouter; - - /** Constructs a {@link TDMABusScheduler} for a given input model. */ - public TDMABusScheduler(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - super(systemModelAdapter, expSpec); - this.messageRouter = new ShortestPathRouter(systemModelAdapter); - } - - /** Add simple TDMA bus schedule / communication time to a pure task schedule. */ - public void schedule(StrictTTSchedule<S, T> schedule, Collection<Message> generatedMessages, - InstantiatedAcyclicTaskGraphEncoding<S, ?> acycItgEnc) { - Multimap<TimeSlot, Message> emitableMessagesPerSlot = HashMultimap.create(); - Map<TimeSlot, Integer> reqRecvMsgsPerSlot = new HashMap<TimeSlot, Integer>(); - - // Add the information about the allocated TimeSlots for the senders and the receivers of - // the messages to the generated messages. This information stems from the schedule of the - // the execution units - Map<Message, DirectedGraph<IResourceAdapter<?>, DefaultEdge>> messageRoutes = - new HashMap<Message, DirectedGraph<IResourceAdapter<?>, DefaultEdge>>(); - for(Message message : generatedMessages) { - TimeSlot senderSlot = schedule.getTimeSlotOf(message.getSender()); - if(senderSlot == null) { - // Message is not schedulable (e.g. an RC message) --> Skip scheduling this message. - continue; - } - - IDeployableComponentAdapter<?> senderComponent = - senderSlot.getDeployedRequester().getDeployableComponent(); - message.addMessageSenderTimeSlot(senderSlot); - emitableMessagesPerSlot.put(senderSlot, message); - - for(IMappingEntry receiverEntry : message.getReceiverMappingEntries()) { - // If the receiver entry is only executed during the next hyperperiod, do not - // consider this receiver here. - AcyclicTaskGraph correspondingTaskGraph = - acycItgEnc.getTaskGraphOf(senderComponent); - - IDeployableComponentAdapter<?> receiverComponent = - receiverEntry.getDeployableComponent(); - if(correspondingTaskGraph.getGraph().containsEdge(senderComponent, - receiverComponent)) { - TimeSlot recvTimeSlot = schedule.getTimeSlotOf(receiverEntry); - message.addMessageReceiverTimeSlots(recvTimeSlot); - - Integer numReqMsgs = reqRecvMsgsPerSlot.get(recvTimeSlot); - if(numReqMsgs == null) { - numReqMsgs = Integer.valueOf(0); - } - numReqMsgs++; - reqRecvMsgsPerSlot.put(recvTimeSlot, numReqMsgs); - } - } - - messageRoutes.put(message, messageRouter.calculateMessageRoute(message - .getSenderTimeSlot().getResource(), message.getReceiverResources())); - } - - // Construct a message queue whose ordering defines the type of scheduling, i.e. ESF, EDF - // etc. It is initially filled with the generated messages resulting from the encoding and - // also captures messages generated by this message scheduler. - LinkedList<Message> messageReleaseQueue = new LinkedList<Message>(); - LinkedList<Message> messageReadyQueue = new LinkedList<Message>(); - for(Message readyMessage : generatedMessages) { - TimeSlot senderSlot = readyMessage.getSenderTimeSlot(); - if(senderSlot == null) { - // Message is not schedulable (e.g. an RC message) --> Skip scheduling this message. - continue; - } - - if(!anyPredecessorSlotRequiresMsgs(senderSlot, reqRecvMsgsPerSlot) && - reqRecvMsgsPerSlot.get(senderSlot) == null) { - messageReadyQueue.add(readyMessage); - } else { - messageReleaseQueue.add(readyMessage); - } - } - Collections.sort(messageReadyQueue); - - // Process all messages present in the schedule. Note that new messages are generated during - // message scheduling as a consequence of multi-hop messaging. - while(!messageReadyQueue.isEmpty()) { - // Update the currently considered message with the one that has the earliest start - // time. - Message currentMessage = messageReadyQueue.poll(); - - // First, we need to retrieve the next communication resource along which the current - // message being routed. This is the second element in the list of participating - // communication resources, since the first one is the sender. - DirectedGraph<IResourceAdapter<?>, DefaultEdge> messageGraph = - messageRoutes.get(currentMessage); - - Set<DefaultEdge> senderResourceEdges = - messageGraph.edgesOf(currentMessage.getSenderTimeSlot().getResource()); - - // Debug code. - if(senderResourceEdges.size() != 1) { - JGraphTVisualizer<IResourceAdapter<?>, DefaultEdge> taskViz = - new JGraphTVisualizer<IResourceAdapter<?>, DefaultEdge>(messageGraph); - taskViz.displayGraph("Invalid message path"); - } - - // Here, we assume that a message may have only one source element. This assumption fits - // to multi-cast messaging and the principle how new messages are generated. - assert senderResourceEdges.size() == 1 : "Each message must have exactly one source slot!"; - ICommunicationResourceAdapter<?> communicationResource = - (ICommunicationResourceAdapter<?>)messageGraph - .getEdgeTarget(senderResourceEdges.iterator().next()); - - // Create a time slot for the current message in the schedule of the next - // communication resource (of the route). - TimeSlot communicationSlot = - createCommunicationTimeSlot(schedule, currentMessage, communicationResource); - TimeSlot senderSlot = currentMessage.getSenderTimeSlot(); - communicationSlot.addPredecessor(currentMessage.getSenderTimeSlot()); - for(TimeSlot successorSlot : currentMessage.getReceiverTimeSlots()) { - communicationSlot.addSuccessor(successorSlot); - senderSlot.replaceSuccessor(successorSlot, communicationSlot); - successorSlot.replacePredecessor(senderSlot, communicationSlot); - } - - // It is required to shift the receiver tasks by the amount of time - // that the communicationSlot requires for transmission. This is needed to - // maintain causality. - shiftReceiverSlot(schedule, currentMessage, communicationSlot); - - // Determine and generate successor messages from the current one. - // TODO: remove dependency on the TimeSlot - Collection<TimeSlot> reachedReceiverSlots = new HashSet<TimeSlot>(); - Collection<Message> succMessages = - generateSuccessorMessages(schedule, currentMessage, messageGraph, - communicationResource, communicationSlot, messageRoutes, - reqRecvMsgsPerSlot, reachedReceiverSlots); - messageReadyQueue.addAll(succMessages); - - // The ready and release queues are updated for the next iteration. - List<TimeSlot> readySenderSlots = - findNextSenderSlots(reachedReceiverSlots, reqRecvMsgsPerSlot, - emitableMessagesPerSlot); - updateMessageQueues(readySenderSlots, emitableMessagesPerSlot, messageReleaseQueue, - messageReadyQueue); - } - - if(!messageReleaseQueue.isEmpty()) { - schedule = null; - } - - // if(isDebugVerboseEnabled() && !messageReleaseQueue.isEmpty()) { - // JGraphTVisualizer<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge> acycInst = - // new JGraphTVisualizer<>(acycItgEnc.getTaskGraphs().stream().findAny().get() - // .getGraph()); - // acycInst.displayGraph("Acyc Inst TDMA"); - // } - // - // assert (messageReleaseQueue.isEmpty()); - } - - /** - * Determines whether the given {@link TimeSlot} or any of its predecessors must wait for - * {@link Message}s to arrive such that they can be executed. Therefore a map is required which - * counts the number of remaining {@link Message}s required as input for each {@link TimeSlot}. - * Note that {@link TimeSlot}s that do not require {@link Message}s as input may not be present - * in the map. - * <p> - * Implementation note: This method considers the case at which all predecessors are located on - * the same {@link IExecutionUnitAdapter} as the given {@link TimeSlot}, i.e. at which no - * {@link Message}s are required to pass the output from the predecessors to the input of the - * given successor {@link TimeSlot}. - * - * @param msgSenderSlot - * {@link TimeSlot} whose predecessors shall be checked for requiring {@link Message} - * s (typically the sender {@link TimeSlot} of a {@link Message}. - * @param reqRecvMsgsPerSlot - * Map containing information about the remaining {@link Message}s that are required - * to execute a specific {@link TimeSlot} (-> key). - * @return Boolean indicating if any (relevant) predecessor is waiting for a {@link Message} to - * be executed. - */ - private boolean anyPredecessorSlotRequiresMsgs(TimeSlot msgSenderSlot, - Map<TimeSlot, Integer> reqRecvMsgsPerSlot) { - LinkedList<TimeSlot> predecessorList = new LinkedList<TimeSlot>(); - predecessorList.addAll(msgSenderSlot.getPredecessors()); - while(!predecessorList.isEmpty()) { - TimeSlot currentPredescessor = predecessorList.poll(); - if(currentPredescessor.getResource() != msgSenderSlot.getResource()) { - predecessorList.addAll(currentPredescessor.getPredecessors()); - if(reqRecvMsgsPerSlot.get(currentPredescessor) != null && - reqRecvMsgsPerSlot.get(currentPredescessor) > 0) { - return true; - } - } - } - - return false; - } - - // TODO: split this method into smaller ones, as this is spaghetti code. - // TODO: another notion for messages is needed: Eliminate the message route map (annotate - // directly) - /** - * Generates (and registers) new messages for the remaining path of the message. If there are - * more than one resource "following" the just considered resource, multiple messages are - * generated. - * - * @param schedule - * The schedule for which messages shall be generated. - * @param currentMessage - * The message for which its successors shall be generated. - * @param currentMessageGraph - * The graph containing the path of the message in the platform. - * @param communicationResource - * The communication {@link IResourceAdapter} for which the successor messages shall - * be generated. This is typically the (single) successor vertex of the source of the - * current message graph. - * @param communicationSlot - * The schedule time slot which identifies the sender of the generated messages. - * @param messageRoutes - * Map that associates {@link Message}s with the (remaining) routes/paths they need - * to traverse. - * @param reqRecvMsgsPerSlot - * Stores the number of messages a {@link TimeSlot} (of an - * {@link IExecutionUnitAdapter} must receive in order to be executed. Used for - * slot-shifting. - * @param reachedReceiverSlots - * Collection of {@link TimeSlot}s that received a message. - */ - private Collection<Message> generateSuccessorMessages(StrictTTSchedule<S, T> schedule, - Message currentMessage, - DirectedGraph<IResourceAdapter<?>, DefaultEdge> currentMessageGraph, - IResourceAdapter<?> communicationResource, TimeSlot communicationSlot, - Map<Message, DirectedGraph<IResourceAdapter<?>, DefaultEdge>> messageRoutes, - Map<TimeSlot, Integer> reqRecvMsgsPerSlot, Collection<TimeSlot> reachedReceiverSlots) { - Collection<Message> generatedMessages = new HashSet<Message>(); - - // From the receiver time slots representing the logical receivers of the current message, - // create a collection of the (platform) resources that onto which these time slots are - // deployed. - Collection<TimeSlot> currentMessageRecieverSlots = currentMessage.getReceiverTimeSlots(); - Collection<IResourceAdapter<?>> currentMessageReceiverResources = - new ArrayList<IResourceAdapter<?>>(); - for(TimeSlot currentReceiverSlot : currentMessageRecieverSlots) { - currentMessageReceiverResources.add(currentReceiverSlot.getResource()); - } - - // Retrieve the routes of the successor messages - Map<IResourceAdapter<?>, DirectedGraph<IResourceAdapter<?>, DefaultEdge>> remainingRoutes = - messageRouter.getRemainingMessageGraphs(currentMessage, communicationResource, - currentMessageGraph); - // Generate a new message for each direct successor in the communication graph. - for(IResourceAdapter<?> nextCommunicationResource : Graphs.successorListOf( - currentMessageGraph, communicationResource)) { - // Check, if a new message is required, i.e. the current direct successor is no receiver - // of the message. - if(!currentMessageReceiverResources.contains(nextCommunicationResource)) { - // Identify the route route corresponding to the current successor and generate a - // list of receiver resources. - DirectedGraph<IResourceAdapter<?>, DefaultEdge> successorRoute = - remainingRoutes.get(nextCommunicationResource); - HashSet<TimeSlot> successorReceiverSlots = new HashSet<TimeSlot>(); - for(TimeSlot receiverSlot : currentMessageRecieverSlots) { - if(successorRoute.containsVertex(receiverSlot.getResource())) { - successorReceiverSlots.add(receiverSlot); - } - } - - // Finally, generate the message. - if(!successorReceiverSlots.isEmpty()) { - Message successorMessage = - new Message(currentMessage.getSignalAdapter(), communicationSlot, - successorReceiverSlots); - generatedMessages.add(successorMessage); - messageRoutes.put(successorMessage, successorRoute); - } - } else { - // Book keeping for the messages that have received the target TimeSlots. - for(TimeSlot currentReceiverSlot : currentMessageRecieverSlots) { - if(currentReceiverSlot.getResource() == nextCommunicationResource) { - reachedReceiverSlots.add(currentReceiverSlot); - Integer remainingMsgCount = reqRecvMsgsPerSlot.get(currentReceiverSlot); - if(remainingMsgCount != null) { - remainingMsgCount--; - reqRecvMsgsPerSlot.put(currentReceiverSlot, remainingMsgCount); - } - } - } - } - } - - return generatedMessages; - } - - /** - * From a given collection of {@link TimeSlot}s that have received a {@link Message}, this - * method determines those {@link TimeSlot}s that are ready to emit {@link Message}s themselves. - * In order to determine these {@link TimeSlot}s a map that counts the missing number of - * {@link Message}s that must be received per {@link TimeSlot} and a map referencing the - * {@link Message}s that are emitted per {@link TimeSlot} are required. - * - * @param reachedReceiverSlots - * {@link TimeSlot}s that have received a {@link Message} in the current iteration of - * the schedule. - * @param reqRecvMsgsPerSlot - * Map counting the remaining number of required messages to execute the receiver - * {@link TimeSlot}. - * @param emitableMessagesPerSlot - * Map referencing the {@link Message} which are emitted after executing the - * associated {@link TimeSlot} (-> key). - * @return List of {@link TimeSlot}s that may emit {@link Message}. - */ - private List<TimeSlot> findNextSenderSlots(Collection<TimeSlot> reachedReceiverSlots, - Map<TimeSlot, Integer> reqRecvMsgsPerSlot, - Multimap<TimeSlot, Message> emitableMessagesPerSlot) { - List<TimeSlot> nextReadySenderSlots = new ArrayList<TimeSlot>(); - - for(TimeSlot receiverSlot : reachedReceiverSlots) { - LinkedList<TimeSlot> possiblyReadySuccessors = new LinkedList<TimeSlot>(); - possiblyReadySuccessors.add(receiverSlot); - - while(!possiblyReadySuccessors.isEmpty()) { - TimeSlot currentSuccessor = possiblyReadySuccessors.poll(); - Integer requiredMsgNumForCurrentSuccessor = - reqRecvMsgsPerSlot.get(currentSuccessor); - if(requiredMsgNumForCurrentSuccessor != null && - requiredMsgNumForCurrentSuccessor == 0) { - nextReadySenderSlots.add(currentSuccessor); - } else if(requiredMsgNumForCurrentSuccessor == null) { - possiblyReadySuccessors.addAll(currentSuccessor.getSuccessors()); - } - } - } - - return nextReadySenderSlots; - } - - /** - * Modifies the given ready and release queues such that the (now) emittable messages are moved - * to the ready queue and are eliminated from the release queue. - * - * @param readySenderSlots - * List of {@link TimeSlot}s which are ready to emit {@link Message}s, i.e. - * {@link TimeSlot}s which themselves (or their predecessors) have received all - * required {@link Message}s those {@link TimeSlot}s require as input. - * @param emittableMessagesPerSlot - * Map containing the {@link Message}s each {@link TimeSlot} emits, once it is ready. - * @param messageReleaseQueue - * Queue containing the non-ready {@link Message}s. - * @param messageQueueReady - * Queue containing the {@link Message}s that can be scheduled. - */ - private void updateMessageQueues(List<TimeSlot> readySenderSlots, - Multimap<TimeSlot, Message> emittableMessagesPerSlot, - LinkedList<Message> messageReleaseQueue, LinkedList<Message> messageQueueReady) { - - for(TimeSlot currentSlot : readySenderSlots) { - Collection<Message> readyMessages = emittableMessagesPerSlot.get(currentSlot); - messageQueueReady.addAll(readyMessages); - messageReleaseQueue.removeAll(readyMessages); - } - Collections.sort(messageQueueReady); - } - - /** - * Creates the {@link TimeSlot} on a communication resource (like an - * {@link ITransmissionUnitAdapter}) - * for a given Message. - * - * @param schedule - * The currently considered schedule. - * @param message - * Message, for which the slot has to be created. - * @param communicationResource - * An {@link ITransmissionUnitAdapter} or {@link IGatewayUnitAdapter} in whose - * schedule the {@link TimeSlot} is about being registered. - * @return The {@link TimeSlot} that has just been added to the schedule. - */ - private TimeSlot createCommunicationTimeSlot(StrictTTSchedule<S, T> schedule, Message message, - ICommunicationResourceAdapter<?> communicationResource) { - // final double minTransmissionDuration = 0.1; - // Constant used for bit->MByte transformation. - final double bitsPerMByte = 8 * 1024 * 1024; - double messageStartTime = message.getSenderTimeSlot().getEndTime(); - - // Determine the time required for the transmission of the message. A minimal transmission - // time is added to avoid time slots with a duration of zero. - double resourceWCTT = 0.0; - if(communicationResource instanceof ITransmissionUnitAdapter) { - resourceWCTT = - ((ITransmissionUnitAdapter<?>)communicationResource) - .getTransmissionDuration(message.getMessageSize() / bitsPerMByte); - } else if(communicationResource instanceof IGatewayUnitAdapter) { - resourceWCTT = ((IGatewayUnitAdapter<?>)communicationResource).getWCFT(); - } - // resourceWCTT = Math.max(resourceWCTT, minTransmissionDuration); - - // Create a new slot for the message. - TimeSlot communicationSlot = - new TimeSlot(message, communicationResource, messageStartTime, messageStartTime + - resourceWCTT); - - // Insert the created slot into the schedule of the communication resource. - if(schedule.getResourceSchedule(communicationResource) != null) { - shiftSlotToEarliestPossibleTime(schedule.getResourceSchedule(communicationResource), - communicationSlot); - } - schedule.registerTimeSlot(communicationSlot, null, communicationResource); - - return communicationSlot; - } - - /** - * Moves the given {@link TimeSlot} to the earliest 'position' in the given - * {@link ResourceSchedule} where it does not overlap with other {@link TimeSlot}s of the target - * {@link IResourceAdapter}. - * - * @param resourceSchedule - * The {@link ResourceSchedule} containing the {#link insertSlot}. - * @param insertSlot - * The {@link TimeSlot} that shall be shifted to a non-overlapping 'position' of the - * given {@link ResourceSchedule}. - */ - private void shiftSlotToEarliestPossibleTime(ResourceSchedule resourceSchedule, - TimeSlot insertSlot) { - double earliestPossibleStartTime = insertSlot.getStartTime(); - - // Determine the slots of the resource schedule that are temporally located 'behind' the - // start time of the slot to be inserted since these slots may impact the 'position' of the - // slot to be inserted. - TreeSet<TimeSlot> orderedResourceSchedule = new TreeSet<TimeSlot>(); - orderedResourceSchedule.addAll(resourceSchedule.keySet()); - TreeSet<TimeSlot> relevantTimeSlots = new TreeSet<TimeSlot>(); - relevantTimeSlots.addAll(orderedResourceSchedule.tailSet(insertSlot)); - - // Depending on the existence of a temporally preceding (by the start time) slot, determine - // the earliest possible start time of the slot to be inserted. - // - lower(...) returning null implies no preceding slot present - // - otherwise: the earliest possible start time is that of the inserted slot or the 'end - // time' of the preceding slot - if(orderedResourceSchedule.lower(insertSlot) != null) { - earliestPossibleStartTime = - Math.max(orderedResourceSchedule.lower(insertSlot).getEndTime(), - insertSlot.getStartTime()); - } - - // Find the earliest possible start time for the slot to be inserted that is determined by a - // sufficiently large 'time gap' relative to already present slots in the schedule. - // NOTE: More "beautiful" solutions are possible, but cause errors if double values are used - // due to precision errors during variable assignment. - double timeGap = 0.0; - for(TimeSlot nextTimeSlot : relevantTimeSlots) { - timeGap = nextTimeSlot.getStartTime() - earliestPossibleStartTime; - if(timeGap > insertSlot.getDuration()) - break; - earliestPossibleStartTime = nextTimeSlot.getEndTime(); - } - - // Perform the shift of the slot to the earliest valid start time. - double shiftTime = earliestPossibleStartTime - insertSlot.getStartTime(); - insertSlot.shift(shiftTime); - } - - /** - * Shifts {@link TimeSlot}s that are receivers of the given message backwards on their - * respective {@link ResourceSchedule}, if required. The amount of time by which the receiving - * {@link TimeSlot}s are shifted is determined by the 'end time' of the {#link - * communicationSlot}. - * Subsequent slots, that are affected by the shift of a receiver, are also shifted until there - * exists no more temporal overlap between time slots. - * - * @param schedule - * The currently considered schedule. - * @param shiftMessage - * The message - * @param communicationSlot - * The {@link TimeSlot} allocated at a {@link ICommunicationResourceAdapter} whose - * insertion (possibly) triggers the shift of other {@link TimeSlot}s. - */ - private void shiftReceiverSlot(StrictTTSchedule<S, T> schedule, Message shiftMessage, - TimeSlot communicationSlot) { - - Comparator<TimeSlot> startTimeComparator = new TimeSlot.StartTimeSlotComparator(); - - // Perform the shifting for each receiver slot of the message - for(TimeSlot receiverSlot : shiftMessage.getReceiverTimeSlots()) { - // Associates a TimeSlot with its direct predecessor TimeSlot. - Multimap<TimeSlot, TimeSlot> succToPredSlotForShift = HashMultimap.create(); - succToPredSlotForShift.put(receiverSlot, communicationSlot); - // List of successor TimeSlots that must be considered in the successive shifts. - LinkedList<TimeSlot> succSlotsToBeShifted = new LinkedList<TimeSlot>(); - succSlotsToBeShifted.add(receiverSlot); - // Amount of time the affected receivers/predecessors. - double shiftTime = 0; - - while(!succSlotsToBeShifted.isEmpty()) { - TimeSlot successorSlot = succSlotsToBeShifted.poll(); - double latestPredFinishTime = 0; - for(TimeSlot predecessor : succToPredSlotForShift.get(successorSlot)) { - latestPredFinishTime = max(latestPredFinishTime, predecessor.getEndTime()); - } - - shiftTime = latestPredFinishTime - successorSlot.getStartTime(); - - // Is the shifting of the successor required? It may have been become irrelevant due - // to shifting other TimeSlots on the same resource. - if(shiftTime > 0) { - // Shift slots of causality violating slot. - HashSet<TimeSlot> shiftedSlots = - shiftResourceSlots(successorSlot, shiftTime, - schedule.getResourceSchedule(successorSlot.getResource())); - assert (schedule.getResourceSchedule(successorSlot.getResource()) - .validateResourceSchedule()); - - // Do not consider shifted TimeSlots that are located (temporally) before their - // successors. - Collection<TimeSlot> irrelevantSlots = new ArrayList<TimeSlot>(); - for(TimeSlot currentShiftedSlot : shiftedSlots) { - if(currentShiftedSlot.getEndTime() <= successorSlot.getStartTime()) { - irrelevantSlots.add(currentShiftedSlot); - } - } - shiftedSlots.removeAll(irrelevantSlots); - // Add remaining successors with causality violation to the slots to be - // processed. - for(TimeSlot currentShiftedSlot : shiftedSlots) { - Collection<TimeSlot> succSlots = currentShiftedSlot.getSuccessors(); - for(TimeSlot succSlot : succSlots) { - if(succSlot.getStartTime() < currentShiftedSlot.getEndTime()) { - if(!succSlotsToBeShifted.contains(succSlot)) { - succSlotsToBeShifted.add(succSlot); - } - succToPredSlotForShift.put(succSlot, currentShiftedSlot); - } - } - } - Collections.sort(succSlotsToBeShifted, startTimeComparator); - } - } - } - assert (schedule.validateSchedule(true)); - } - - /** - * Shifts the given {@link TimeSlot} in the given {@link ResourceSchedule} by the given amount - * of time. The method shifts all {@link TimeSlot}s that are in the time frame of the start time - * of the given {@link TimeSlot} and its time shift value. By successive shifting, it is ensured - * that no temporal overlaps occur in the given {@link ResourceSchedule}. - * - * @param slotToShift - * The slot that shall be shifted at the resource. - * @param shiftTime - * The amount of time the given {@link TimeSlot} shall be shifted. - * @param receiverResourceSchedule - * The {@link ResourceSchedule} that contains the given {@link TimeSlot}. - * @return Set of all shifted slot by this method. - */ - private HashSet<TimeSlot> shiftResourceSlots(TimeSlot slotToShift, double shiftTime, - ResourceSchedule receiverResourceSchedule) { - HashSet<TimeSlot> allShiftedSlots = new HashSet<TimeSlot>(); - - Set<TimeSlot> receiverResourceSlots = new HashSet<TimeSlot>(); - receiverResourceSlots.addAll(receiverResourceSchedule.keySet()); - - // Determine the slots that must be 'directly' shifted due to the communication slot. - // The affected slots are those that are located between the 'end time' of the - // communication slot and the start time of the receiver slot. - List<TimeSlot> slotsToBeShifted = new LinkedList<TimeSlot>(); - for(TimeSlot slotAtReceiver : receiverResourceSchedule.keySet()) { - if(slotAtReceiver.getStartTime() >= slotToShift.getStartTime() && - slotAtReceiver.getStartTime() < slotToShift.getStartTime() + shiftTime) { - slotsToBeShifted.add(slotAtReceiver); - } - } - - // Start and end times of the block of shifted slots per round in the loop below. - double shiftedBlockStartTime; - double prevShiftedSlotEndTime = slotToShift.getStartTime() + shiftTime; - - // Perform the iterative shifting of the affected time slots. - HashSet<TimeSlot> shiftedTimeSlots = new HashSet<TimeSlot>(); - while(!slotsToBeShifted.isEmpty()) { - // Perform the actual shift of the defined slots and mark the start and end times of - // the shifted slot 'block'. - shiftedBlockStartTime = Double.MAX_VALUE; - for(TimeSlot slotAtReceiver : slotsToBeShifted) { - double blockShiftTime = prevShiftedSlotEndTime - slotAtReceiver.getStartTime(); - assert (blockShiftTime >= 0) : "The TDMAScheduler attempts to shift the TimeSlot " + - slotAtReceiver + " towards an earlier point in time."; - slotAtReceiver.shift(blockShiftTime); - shiftedTimeSlots.add(slotAtReceiver); - shiftedBlockStartTime = min(shiftedBlockStartTime, slotAtReceiver.getStartTime()); - prevShiftedSlotEndTime = slotAtReceiver.getEndTime(); - } - slotsToBeShifted.clear(); - allShiftedSlots.addAll(shiftedTimeSlots); - - // Determine the slots that must be shifted due to the shift of the slots at the - // beginning of the loop. - for(TimeSlot slotAtReceiver : receiverResourceSlots) { - if(!containsTimeSlot(shiftedTimeSlots, slotAtReceiver) && - slotAtReceiver.getStartTime() >= shiftedBlockStartTime && - slotAtReceiver.getStartTime() < prevShiftedSlotEndTime) { - slotsToBeShifted.add(slotAtReceiver); - } - } - - shiftedTimeSlots.clear(); - Collections.sort(slotsToBeShifted); - } - return allShiftedSlots; - } - - /** - * Evaluates whether {#link slot} is contained in the given set of {@link TimeSlot}s based on - * the {@code hashCode} method. - */ - private boolean containsTimeSlot(Set<TimeSlot> timeSlotSet, TimeSlot slot) { - for(TimeSlot slotOfSet : timeSlotSet) { - if(slotOfSet.hashCode() == slot.hashCode()) { - return true; - } - } - return false; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/EDFSchedulerBase.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/EDFSchedulerBase.java deleted file mode 100644 index 379089cddc728ef76f102d379b6e4995938b4db3..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/EDFSchedulerBase.java +++ /dev/null @@ -1,597 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: EDFSchedulerBase.java 3879 2016-11-10 10:33:35Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.sched.proc; - -import static org.fortiss.af3.exploration.util.ExplorationUtils.isDebugVerboseEnabled; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.apfloat.Apcomplex; -import org.apfloat.Apfloat; -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; -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.backend.opt4j.solution.StrictTTSchedule; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.TimeSlot; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -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; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; -import org.fortiss.af3.exploration.alg.dse.sysmodel.sched.ScheduleRuntimeException; -import org.fortiss.af3.exploration.alg.dse.sysmodel.sched.SchedulerBase; -import org.fortiss.af3.exploration.alg.dse.sysmodel.sched.comm.TDMABusScheduler; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.time.DeadlineConstraint; -import org.jgrapht.Graphs; -import org.jgrapht.traverse.TopologicalOrderIterator; - -import com.google.common.collect.LinkedListMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; - -/** - * Base class for EDF task schedulers. - * - * @author huang - * @author $Author: diewald $ - * @version $Rev: 3879 $ - * @ConQAT.Rating RED Hash: 80775D6B8937A4999108E8FBDC4BD749 - */ -public abstract class EDFSchedulerBase<S extends InstantiatedTaskMappingEntry, T extends InstantiatedTaskMappingEncoding<S>> - extends SchedulerBase { - /** TODO SchedulingObject */ - protected class SchedulingObject implements java.lang.Comparable<SchedulingObject>, Cloneable { - /** Scheduled deployable component */ - protected IDeployableComponentAdapter<?> deployableComponent; - - /** Release time */ - protected double release; - - /** Deadline */ - protected double deadline; - - /** Ready time */ - protected double ready; - - /** Topological index */ - protected int index; - - /** Successor {@link SchedulingObject}s of this {@link SchedulingObject}. */ - protected LinkedList<SchedulingObject> successors; - - /** Predecessor {@link SchedulingObject}s of this {@link SchedulingObject}. */ - protected LinkedList<SchedulingObject> predecessors; - - /** Unscheduled predecessor {@link SchedulingObject}s of this {@link SchedulingObject}. */ - protected LinkedList<SchedulingObject> unscheduledPredecessors; - - /** Comparator defining the priority of {@link SchedulingObject}s based on their deadline. */ - SchedulingObjectComparator comparator; - - /** - * Constructs a scheduling object for a deployable component with a release time and a - * deadline. - */ - public SchedulingObject(SchedulingObjectComparator comparator, - IDeployableComponentAdapter<?> deployableComponent, double release, double deadline) { - this.comparator = comparator; - this.deployableComponent = deployableComponent; - this.release = release; - this.deadline = deadline; - ready = -1; - index = -1; - predecessors = new LinkedList<SchedulingObject>(); - unscheduledPredecessors = new LinkedList<SchedulingObject>(); - successors = new LinkedList<SchedulingObject>(); - } - - /** {@inheritDoc} */ - @Override - public SchedulingObject clone() { - SchedulingObject newobj = - new SchedulingObject(comparator, deployableComponent, release, deadline); - newobj.ready = this.ready; - newobj.index = this.index; - newobj.predecessors.addAll(this.predecessors); - newobj.unscheduledPredecessors.addAll(this.unscheduledPredecessors); - newobj.successors.addAll(this.successors); - return newobj; - } - - /** - * Adjusts the references of the given {@link SchedulingObject} to those given in the set of - * {@link SchedulingObject}s. This method <b>must</b> be executed after all desired clones - * are created to correctly reference coned components. - */ - public void adjustSchedObjReferences(SortedSet<SchedulingObject> possibleReferences) { - for(SchedulingObject predOrSuccSchedObject : possibleReferences) { - Map<SchedulingObject, SchedulingObject> replaceMap = - new HashMap<SchedulingObject, SchedulingObject>(); - for(SchedulingObject predObj : predecessors) { - if(predObj.deployableComponent == predOrSuccSchedObject.deployableComponent) { - replaceMap.put(predObj, predOrSuccSchedObject); - } - } - for(java.util.Map.Entry<SchedulingObject, SchedulingObject> entry : replaceMap - .entrySet()) { - predecessors.remove(entry.getKey()); - predecessors.add(entry.getValue()); - } - replaceMap.clear(); - - for(SchedulingObject succObj : successors) { - if(succObj.deployableComponent == predOrSuccSchedObject.deployableComponent) { - replaceMap.put(succObj, predOrSuccSchedObject); - } - } - for(java.util.Map.Entry<SchedulingObject, SchedulingObject> entry : replaceMap - .entrySet()) { - successors.remove(entry.getKey()); - successors.add(entry.getValue()); - } - replaceMap.clear(); - } - unscheduledPredecessors.clear(); - unscheduledPredecessors.addAll(predecessors); - } - - /** - * Overrides the deadline associated with this scheduling object. - * - * @return Returns true if the given value is smaller than or equal to the current deadline - * and has been - * set, otherwise returns false. - */ - public boolean setDeadline(double newDeadline) { - double minDeadline = Math.min(this.deadline, newDeadline); - if(minDeadline <= this.deadline) { - this.deadline = minDeadline; - return true; - } - return false; - } - - /** - * Returns the collection of {@link SchedulingObject}s that are predecessors of this - * {@link SchedulingObject}. - */ - public Collection<SchedulingObject> getPredecessors() { - return predecessors; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "(" + deployableComponent.getName() + "," + release + "," + deadline + ")"; - } - - /** {@inheritDoc} */ - @Override - public int compareTo(SchedulingObject obj) { - return comparator.compare(this, obj); - } - } - - /** - * Compares two {@link SchedulingObject}s by deadline, topological index, or owner - * {@link TaskGraph}. - */ - private class SchedulingObjectComparator implements Comparator<SchedulingObject> { - - /** - * References the {@link TaskMappingEncoding} for which {@code this} {@link Comparator} is - * defined. - */ - private InstantiatedAcyclicTaskGraphEncoding<S, ?> acycItgEnc; - - /** - * Constructs a {@link SchedulingObjectComparator} which is subject to the given - * {@link TaskMappingEncoding}. - */ - SchedulingObjectComparator(InstantiatedAcyclicTaskGraphEncoding<S, ?> acycItgEnc) { - this.acycItgEnc = acycItgEnc; - } - - /** {@inheritDoc} */ - @Override - public int compare(SchedulingObject obj1, SchedulingObject obj2) { - // edf - if(obj1.deadline < obj2.deadline) { - return -1; - } else if(obj1.deadline < obj2.deadline) { - return 1; - } else { - // equal deadline, are them from the same tg? - if(acycItgEnc.getTaskGraphOf(obj1.deployableComponent) == acycItgEnc - .getTaskGraphOf(obj2.deployableComponent)) { - // from same tg, topological order - if(obj1.index < obj2.index) { - return -1; - } else if(obj1.index > obj2.index) { - return 1; - } else { - // same index? then it is the same scheduling object - return 0; - } - } - - // TODO: This used to be based on TaskGraph.index. Check if the implementation based - // on the {@link TaskGraph}s {@link #hashCode} is also correct. - return Integer - .compare(acycItgEnc.getTaskGraphOf(obj1.deployableComponent).hashCode(), - acycItgEnc.getTaskGraphOf(obj2.deployableComponent).hashCode()); - } - } - } - - /** Constructs a simple EDF scheduler for a given exploration run */ - public EDFSchedulerBase(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - super(systemModelAdapter, expSpec); - } - - /** - * Creates and returns a release queue for the given {@link TaskMappingEncoding}. A release - * queue contains those {@link SchedulingObject}s which remain to be scheduled. - */ - private synchronized SortedSet<SchedulingObject> createReleaseQueue( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - InstantiatedAcyclicTaskGraphEncoding<S, ?> acycItgEnc) { - SchedulingObjectComparator EDFTopologicalComparator = - new SchedulingObjectComparator(acycItgEnc); - TreeSet<SchedulingObject> releaseQueue = - new TreeSet<SchedulingObject>(EDFTopologicalComparator); - - for(AcyclicTaskGraph taskGraph : acycItgEnc.getTaskGraphs()) { - SortedSet<SchedulingObject> localReleaseQueue = - new TreeSet<SchedulingObject>(EDFTopologicalComparator); - int index = 0; - TopologicalOrderIterator<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge> iter = - new TopologicalOrderIterator<IDeployableComponentAdapter<?>, ChannelAdapterWeightedEdge>( - taskGraph.getGraph()); - while(iter.hasNext()) { - IDeployableComponentAdapter<?> deployableComponent = iter.next(); - // create the instance of each hyper-period - for(int i = 0; i < systemModelAdapter.getHyperPeriod() / taskGraph.getPeriod(); i++) { - double releasetime = i * taskGraph.getPeriod(); - double effectiveDeadline = releasetime + taskGraph.getPeriod(); - - SchedulingObject sobject = - new SchedulingObject(EDFTopologicalComparator, deployableComponent, - releasetime, effectiveDeadline); - // set the topological index - sobject.index = index++; - // add the predecessor list - for(ChannelAdapterWeightedEdge edge : taskGraph.getGraph().incomingEdgesOf( - deployableComponent)) { - IDeployableComponentAdapter<?> sourceComponent = - taskGraph.getGraph().getEdgeSource(edge); - // look into the previous allocated scheduling objects - for(SchedulingObject pred : localReleaseQueue) { - if(pred.deployableComponent == sourceComponent) { - pred.successors.add(sobject); - sobject.predecessors.add(pred); - sobject.unscheduledPredecessors.add(pred); - } - } - } - // set source tasks to be ready - if(sobject.predecessors.isEmpty()) { - sobject.ready = sobject.release; - } else { - sobject.release = -1; - } - // add the object into release queue - localReleaseQueue.add(sobject); - } - } - - releaseQueue.addAll(localReleaseQueue); - } - // debug - if(isDebugVerboseEnabled()) { - System.out.println(releaseQueue); - } - return releaseQueue; - } - - /** - * Simple EDF scheduler. It works as follows: - * <ul> - * <li>the task graph with shortest deadline goes first</li> - * <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) { - SortedSet<SchedulingObject> releaseQueue = - createReleaseQueue(systemModelAdapter, acycItgEnc); - // Create copy of release queue - if(releaseQueue.isEmpty()) { - throw new RuntimeException("Scheduler failed..."); - } - SortedSet<SchedulingObject> releaseQueueLocal = - new TreeSet<SchedulingObject>(new SchedulingObjectComparator(acycItgEnc)); - for(SchedulingObject obj : releaseQueue) { - releaseQueueLocal.add(obj.clone()); - } - // Adjust the references to predecessors and successors due to cloning. - for(SchedulingObject obj : releaseQueueLocal) { - obj.adjustSchedObjReferences(releaseQueueLocal); - } - - // Initialize ready queue - SortedSet<SchedulingObject> readyQueue = - new TreeSet<SchedulingObject>(new SchedulingObjectComparator(acycItgEnc)); - for(SchedulingObject obj : releaseQueueLocal) { - if(obj.ready >= 0) { - readyQueue.add(obj); - } - } - releaseQueueLocal.removeAll(readyQueue); - - // maintain the current time on each resource - Map<IExecutionUnitAdapter<?>, Apfloat> currenttimes = - new HashMap<IExecutionUnitAdapter<?>, Apfloat>(); - - // This map contains the information which scheduling object represents which - // IDeployableComponentAdapter - Map<IDeployableComponentAdapter<?>, SchedulingObject> schedulingComponentMap = - new HashMap<IDeployableComponentAdapter<?>, EDFSchedulerBase<S, T>.SchedulingObject>(); - for(SchedulingObject obj : releaseQueueLocal) { - schedulingComponentMap.put(obj.deployableComponent, obj); - } - - // This map remembers which slot is added for which entry. - Map<S, TimeSlot> mappingEntryToTimeSlot = new HashMap<S, TimeSlot>(); - - // This map associated each SchedulingObject with the TimeSlots that have been generated for - // it. - Multimap<SchedulingObject, TimeSlot> generatedTimeSlots = LinkedListMultimap.create(); - - // the main loop - while(!readyQueue.isEmpty()) { - // Add and resort ready queue acc. to deadlines (they can appear dynamically after the - // execution of another component) - Collection<IDeployableComponentAdapter<?>> componentsWithDeadlines = - Sets.intersection(schedulingComponentMap.keySet(), - componentDeadlineSourceMap.keySet()); - if(!componentsWithDeadlines.isEmpty()) { - for(IDeployableComponentAdapter<?> currentDeadlineComponent : componentsWithDeadlines) { - // Retrieve the IDeployableComponentAdapter that is the target of the current - // deadline. - // TODO: remove or abstract DeadlineConstraint here? - DeadlineConstraint currentDeadline = - componentDeadlineSourceMap.get(currentDeadlineComponent); - IDeployableComponentAdapter<?> targetDeployableComponent = - deadlineTargetComponent.get(currentDeadline); - TaskGraph tgOfDeadlineTarget = - systemModelAdapter.getAcyclicTaskGraph(targetDeployableComponent); - Collection<IDeployableComponentAdapter<?>> deadlineTargetPredescessors = - Graphs.predecessorListOf(tgOfDeadlineTarget.getGraph(), - targetDeployableComponent); - - // TODO: Separate method to adjust readyQueue. - deadlineTargetPredescessors.add(targetDeployableComponent); - for(IDeployableComponentAdapter<?> currentPredessor : deadlineTargetPredescessors) { - SchedulingObject predSchedObj = - schedulingComponentMap.get(currentPredessor); - if(predSchedObj != null && readyQueue.contains(predSchedObj)) { - SchedulingObject predescessorSchedulingObject = - schedulingComponentMap.get(currentPredessor); - readyQueue.remove(predescessorSchedulingObject); - predescessorSchedulingObject.setDeadline(currentDeadline.getDeadline()); - readyQueue.add(predescessorSchedulingObject); - } - } - } - } - - // Pick first task in the ready queue... - SchedulingObject schedulingObject = readyQueue.first(); - - // ...and schedule it - Apfloat finishTime = - scheduleObject(schedulingObject, acycItgEnc, taskMapping, schedule, - currenttimes, mappingEntryToTimeSlot, generatedTimeSlots); - - // Check if any successor becomes ready - List<SchedulingObject> toBeRemoved = new ArrayList<SchedulingObject>(); - for(SchedulingObject object : releaseQueueLocal) { - if(object.predecessors.contains(schedulingObject)) { - object.ready = - (object.ready > finishTime.doubleValue() ? object.ready : finishTime - .doubleValue()); - object.unscheduledPredecessors.remove(schedulingObject); - if(object.unscheduledPredecessors.isEmpty()) { - toBeRemoved.add(object); - } - } - } - - // Move the ready scheduling objects to the ready queue - readyQueue.addAll(toBeRemoved); - releaseQueueLocal.removeAll(toBeRemoved); - - // Remove current scheduling object - readyQueue.remove(schedulingObject); - } - - if(!releaseQueueLocal.isEmpty()) { - for(SchedulingObject schObj : releaseQueueLocal) { - Double compPeriod = schObj.deployableComponent.getTimingRequirementPeriod(); - if(compPeriod != null) { - throw new RuntimeException("The Components " + releaseQueueLocal + - " were not scheduled..."); - } - } - } - - if(!schedule.validateSchedule(true)) { - throw new RuntimeException("Schedule is not valid..."); - } - } - - /** 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, - Map<S, TimeSlot> mappingEntryToTimeSlot, - Multimap<SchedulingObject, TimeSlot> generatedTimeSlots) { - - // TODO: use another representation ro make an access via the reference obsolete - // IDeployableComponentAdapter deployableComponent = schedulingObject.deployableComponent; - // if(deployableComponent.isInstantiation()) { - // deployableComponent = deployableComponent.getReplacedComponent(); - // } - Collection<S> entries = encoding.getMappingEntriesOf(schedulingObject.deployableComponent); - - TaskGraph taskGraph = acycItgEnc.getTaskGraphOf(schedulingObject.deployableComponent); - - Apfloat startTime = new Apfloat(-1, DOUBLE_PRECISION); - Apfloat finishTime = new Apfloat(-1, DOUBLE_PRECISION); - - 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); - - // 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)); - startTime = new Apfloat(0, DOUBLE_PRECISION); - } else { - startTime = currentTimeMap.get(hardwareDeploymentTarget); - } - - // The start time should be no less than the ready time - Apfloat readyTime = new Apfloat(schedulingObject.ready, DOUBLE_PRECISION); - if(startTime.compareTo(readyTime) < 0) { - startTime = readyTime; - } - - // Add execution time - Apfloat deployableComponentExecutionTime = - getExecutionTime(encoding, acycItgEnc, schedulingObject.deployableComponent, - entry); - if(deployableComponentExecutionTime.compareTo(Apcomplex.ZERO) == -1) { - throw new ScheduleRuntimeException(schedule, - "Could not determine the runtime execution time for the Component " + - schedulingObject.deployableComponent + - ". Did you specify a WCET for the allocation pair <" + - schedulingObject.deployableComponent + ", " + - entry.getTarget().getObject() + "?"); - } - - Apfloat deployableComponentEndTime = startTime.add(deployableComponentExecutionTime); - - // Determine the predecessor time slots - List<TimeSlot> predecessorSlots = new ArrayList<TimeSlot>(); - for(SchedulingObject predecessor : schedulingObject.getPredecessors()) { - predecessorSlots.addAll(generatedTimeSlots.get(predecessor)); - } - - // Build time slot - long iteration = java.lang.Math.round(schedulingObject.release / taskGraph.getPeriod()); - iteration = iteration >= 0 ? iteration : 0; - TimeSlot deployableComponentSlot = - schedule.createTimeSlot(entry, deploymentTarget, predecessorSlots, - startTime.floatValue(), deployableComponentEndTime.floatValue(), - iteration); - - // Register the generated TimeSlot at its predecessors. - for(SchedulingObject predecessor : schedulingObject.getPredecessors()) { - Collection<TimeSlot> predecessorSlotsLoc = generatedTimeSlots.get(predecessor); - for(TimeSlot predecessorSlot : predecessorSlotsLoc) { - predecessorSlot.addSuccessor(deployableComponentSlot); - } - } - - // Book keeping - mappingEntryToTimeSlot.put(entry, deployableComponentSlot); - - // Consider incoming messages that need to arrive before the current - // deployableComponentSlot. Note that this can result in the injection of additional - // slots into the schedule (e.g., voters), and hence can cause a delayed scheduling of - // the current deployableComponentSlot. - // Add the information about the sender and the receiver TimeSlots which contain the - // start and end times of the Message. - Apfloat delay = - registerIncomingMessagesWithSchedule(encoding, acycItgEnc, schedule, - mappingEntryToTimeSlot, schedulingObject.deployableComponent, - startTime, entry.getTarget(), iteration, deployableComponentSlot); - - deployableComponentSlot.shift(delay.floatValue()); - deployableComponentEndTime = - new Apfloat(deployableComponentSlot.getEndTime(), DOUBLE_PRECISION); - - // Book keeping - currentTimeMap.put(hardwareDeploymentTarget, deployableComponentEndTime); - generatedTimeSlots.put(schedulingObject, deployableComponentSlot); - - // Overall finish time of all replicas - if(finishTime.compareTo(deployableComponentEndTime) < 0) { - finishTime = deployableComponentEndTime; - } - } - - return finishTime; - - } - - /** Returns the execution time for the given {@link IDeployableComponentAdapter}. */ - protected abstract Apfloat getExecutionTime( - TaskMappingEncoding<? extends TaskMappingEntry> encoding, - InstantiatedAcyclicTaskGraphEncoding<S, ?> acycItgEnc, - IDeployableComponentAdapter<?> deployableComponent, S entry); - - /** - * Registers the incoming inter-deployment target messages of a given deloyable component - * with the {@link StrictTTSchedule}. These messages are later processed by the - * {@link TDMABusScheduler}. - * - * This method may inject additional slots into the schedule (e.g., voters), and hence - * returns the delay of the {@code deployableComponent} for which this method has been - * invoked. - * - * TODO: Data dependencies within one deployment target are considered by the respective - * schedule and are assumed to be handled in zero time --> Explicitly model shared memory - * communication, etc. - */ - protected abstract Apfloat registerIncomingMessagesWithSchedule(T encoding, - InstantiatedAcyclicTaskGraphEncoding<S, ?> acycItgEnc, StrictTTSchedule<S, T> schedule, - Map<S, TimeSlot> mappingEntryToTimeSlot, - IDeployableComponentAdapter<?> deployableComponent, Apfloat starttime, - IExecutionUnitAdapter<?> deploymentTarget, long iteration, TimeSlot slot); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/FailSilentEDFScheduler.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/FailSilentEDFScheduler.java deleted file mode 100644 index c32652fafbe5c9479db981d770746e6b54157561..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/FailSilentEDFScheduler.java +++ /dev/null @@ -1,78 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FailSilentEDFScheduler.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.sched.proc; - -import java.util.Map; - -import org.apfloat.Apcomplex; -import org.apfloat.Apfloat; -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; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FailSilentTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FailSilentTaskMappingEntry; -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.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.model.ExplorationSpecification; - -/** - * Base class for EDF task schedulers - * - * @author huang, barner - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 21ACBD17F086C199D5C3980D653CF1D8 - */ -public class FailSilentEDFScheduler extends - EDFSchedulerBase<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> { - - /** Constructs a simple EDF scheduler for a given exploration run */ - public FailSilentEDFScheduler(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - super(systemModelAdapter, expSpec); - } - - /** - * Returns the execution time for the current - * {@link org.fortiss.af3.exploration.alg.dse.sysmodel.sched.proc.EDFSchedulerBase.SchedulingObject} - * . - */ - @Override - protected Apfloat getExecutionTime(TaskMappingEncoding<? extends TaskMappingEntry> encoding, - InstantiatedAcyclicTaskGraphEncoding<FailSilentTaskMappingEntry, ?> acycItgEnc, - IDeployableComponentAdapter<?> deployableComponent, FailSilentTaskMappingEntry entry) { - Apfloat executiontime = - new Apfloat(deployableComponent.getWcet(entry.getTarget()), DOUBLE_PRECISION); - return executiontime; - } - - /** {@inheritDoc} */ - @Override - protected Apfloat registerIncomingMessagesWithSchedule(FailSilentTaskMappingEncoding encoding, - InstantiatedAcyclicTaskGraphEncoding<FailSilentTaskMappingEntry, ?> acycItgEnc, - StrictTTSchedule<FailSilentTaskMappingEntry, FailSilentTaskMappingEncoding> schedule, - Map<FailSilentTaskMappingEntry, TimeSlot> mappingEntryToTimeSlot, - IDeployableComponentAdapter<?> deployableComponent, Apfloat starttime, - IExecutionUnitAdapter<?> deploymentTarget, long iteration, TimeSlot slot) { - // TODO Auto-generated method stub - return Apcomplex.ZERO; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/FaultDetectionVotingEDFScheduler.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/FaultDetectionVotingEDFScheduler.java deleted file mode 100644 index a975eb41c583cfbf43c383c7a5a1b03798624d36..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/dse/sysmodel/sched/proc/FaultDetectionVotingEDFScheduler.java +++ /dev/null @@ -1,140 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FaultDetectionVotingEDFScheduler.java 3032 2016-06-16 18:13:12Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.dse.sysmodel.sched.proc; - -import java.util.Map; - -import org.apfloat.Apfloat; -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; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FaultDetectionVotingTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.instantiatedmapping.FaultDetectionVotingTaskMappingEntry; -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.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.ChannelAdapterWeightedEdge; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; -import org.fortiss.af3.exploration.alg.dse.sysmodel.faultmodel.FaultDetector; -import org.fortiss.af3.exploration.model.ExplorationSpecification; - -/** - * Base class for EDF task schedulers - * - * @author huang, barner - * @author $Author: diewald $ - * @version $Rev: 3032 $ - * @ConQAT.Rating RED Hash: 44B8FB0DC59D2D4E937A988892764F4E - */ -public class FaultDetectionVotingEDFScheduler - extends - EDFSchedulerBase<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> { - - /** Constructs a simple EDF scheduler for a given exploration run */ - public FaultDetectionVotingEDFScheduler( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ExplorationSpecification expSpec) { - super(systemModelAdapter, expSpec); - } - - /** - * {@inheritDoc}. - * <p> - * For {@link FaultDetectionVotingEDFScheduler}, this method injects voters (deployed with the - * same deployment target as the sender) that are required to reduce the output of replicated - * sender components. - * </p> - */ - @Override - protected - Apfloat - registerIncomingMessagesWithSchedule( - FaultDetectionVotingTaskMappingEncoding encoding, - InstantiatedAcyclicTaskGraphEncoding<FaultDetectionVotingTaskMappingEntry, ?> acycItgEnc, - StrictTTSchedule<FaultDetectionVotingTaskMappingEntry, FaultDetectionVotingTaskMappingEncoding> schedule, - Map<FaultDetectionVotingTaskMappingEntry, TimeSlot> mappingEntryToTimeSlot, - IDeployableComponentAdapter<?> receiver, Apfloat deployableComponentStartTime, - IExecutionUnitAdapter<?> deploymentTarget, long iteration, TimeSlot slot) { - - Apfloat voterDelay = new Apfloat(0, DOUBLE_PRECISION); - - TaskGraph taskGraph = acycItgEnc.getTaskGraphOf(receiver); - for(ChannelAdapterWeightedEdge edge : taskGraph.getGraph().incomingEdgesOf(receiver)) { - IDeployableComponentAdapter<?> sender = taskGraph.getGraph().getEdgeSource(edge); - - // See if the sender has been replicated - // TODO: Remove the need to use the encoding here: can the information be obtained in - // another fashion? - if(encoding.getMappingEntriesOf(sender) != null && - encoding.getMappingEntriesOf(sender).size() > 1) { - - // Add voter to reduce result produced by replicated senders. - // TODO currently, the voter execution time is assumed to be 10 us, and it needs to - // be specified in nano seconds - Apfloat voterExecutionTime = new Apfloat(10.0 * 1000); - - // Compute the starting time of the voter. We add 'voterDelay' that accumulates - // the total delay caused by voters added in previous iterations of this loops - // (i.e., - // for incoming messages from other replicated senders) - Apfloat tempTimp = - deployableComponentStartTime.add(voterExecutionTime).add(voterDelay); - - // Accumulate delay caused by all voters - voterDelay = voterDelay.add(voterExecutionTime); - - // TODO: Create a class that represents voters similar to - // IDeployableComponentAdapter. - @SuppressWarnings("unused") TimeSlot voterSlot = - schedule.createVoterSlot(null, deploymentTarget, - deployableComponentStartTime.add(voterDelay).floatValue(), - tempTimp.floatValue(), iteration); - - } - } - - return voterDelay; - } - - /** {@inheritDoc} */ - @Override - protected - Apfloat - getExecutionTime( - TaskMappingEncoding<? extends TaskMappingEntry> encoding, - InstantiatedAcyclicTaskGraphEncoding<FaultDetectionVotingTaskMappingEntry, ?> acycItgEnc, - IDeployableComponentAdapter<?> deployableComponent, - FaultDetectionVotingTaskMappingEntry entry) { - - // Base execution time - Apfloat executionTime = - new Apfloat(deployableComponent.getWcet(entry.getTarget()), DOUBLE_PRECISION); - - // Scale with fault-detector overhead - FaultDetector detector = - acycItgEnc.getTaskGraphOf(deployableComponent).getFaultDetector( - deployableComponent, entry.getFaultDetectorID()); - Apfloat overhead = new Apfloat(1.0 + detector.getOverhead(), DOUBLE_PRECISION); - - executionTime = executionTime.multiply(overhead); - - return executionTime; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/ConstraintGenerationException.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/ConstraintGenerationException.java deleted file mode 100644 index a580dabd8bd2d9cf50dfb3bf0f0745d55ffa74d9..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/ConstraintGenerationException.java +++ /dev/null @@ -1,50 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ConstraintGenerationException.java 3480 2016-09-09 13:31:04Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.exception; - -import org.fortiss.af3.exploration.model.ExplorationConstraint; - -/** - * Exception for failures in the automatic constraint generation. Displays some information about - * the failed constraint. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3480 $ - * @ConQAT.Rating RED Hash: 06BEABDBFFDF545A4AD61AE4CB7B291C - */ -public class ConstraintGenerationException extends ExplorationException { - - /** - * Constructs a {@link ConstraintGenerationException} with information about the failed - * {@link ExplorationConstraint} and the given message. - */ - public ConstraintGenerationException(Class<? extends ExplorationConstraint<?>> constraintType, - String msg) { - super("Failed to generate a " + constraintType.getSimpleName() + ": " + msg); - } - - /** - * Constructs a {@link ConstraintGenerationException} with information about the failed - * {@link ExplorationConstraint} and the given message and the given {@link Exception}. - */ - public ConstraintGenerationException(Class<? extends ExplorationConstraint<?>> constraintType, - String msg, Exception e) { - super("Failed to generate a " + constraintType.getSimpleName() + ": " + msg, e); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/ExplorationException.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/ExplorationException.java deleted file mode 100644 index 49e634d099539dbe62dc4eb21841eb874f70d85c..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/ExplorationException.java +++ /dev/null @@ -1,39 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.exception; - -/** - * General DSE Exception. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 2D4E3A121A6206178E049DB5F3E78C01 - */ -public class ExplorationException extends Exception { - - /** General DSE exception taking an error message. */ - public ExplorationException(String message) { - super("DSE:" + message); - } - - /** General DSE exception taking an error message and an wrapped exception. */ - public ExplorationException(String message, Exception e) { - super("DSE:" + message, e); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/ExplorationServiceException.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/ExplorationServiceException.java deleted file mode 100644 index 33423bbefb5a2460e3d4a75c84ea51697c0c2e94..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/ExplorationServiceException.java +++ /dev/null @@ -1,49 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExplorationServiceException.java 3480 2016-09-09 13:31:04Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.exception; - -import org.fortiss.af3.exploration.alg.service.IExplorationService; - -/** - * Base exception class for any exploration service. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3480 $ - * @ConQAT.Rating RED Hash: DDF848903BB908E18D06F9C70BF4F800 - */ -public class ExplorationServiceException extends ExplorationException { - - /** - * Constructs an {@link ExplorationServiceException} with information about the failed - * {@link IExplorationService} and the given message. - */ - public ExplorationServiceException(Class<? extends IExplorationService<?>> serviceType, - String msg) { - super(serviceType.getSimpleName() + " failed: " + msg); - } - - /** - * Constructs a {@link ExplorationServiceException} with information about the failed - * {@link IExplorationService} and the given message and the given {@link Exception}. - */ - public ExplorationServiceException(Class<? extends IExplorationService<?>> serviceType, - String msg, Exception e) { - super(serviceType.getSimpleName() + " failed: " + msg, e); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/InvalidPlatformModelException.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/InvalidPlatformModelException.java deleted file mode 100644 index 23200a53fc16451c62e2fffe6e892cafabb143e4..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/InvalidPlatformModelException.java +++ /dev/null @@ -1,59 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: InvalidPlatformModelException.java 3425 2016-08-31 07:44:08Z barner $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.exception; - -import org.fortiss.af3.platform.model.IPlatformArchitectureElement; -import org.fortiss.af3.platform.model.PlatformArchitecture; -import org.fortiss.af3.platform.model.PlatformConnectorUnit; - -/** - * Exception to be thrown whenever an input {@link PlatformArchitecture} model to the DSE has been - * detected. - * - * @author diewald - * @author $Author: barner $ - * @version $Rev: 3425 $ - * @ConQAT.Rating RED Hash: 7ED78C34875421F8F10F00D08A0B88B3 - */ -public class InvalidPlatformModelException extends Exception { - - /** Constructor. */ - public InvalidPlatformModelException(IPlatformArchitectureElement element, String msg) { - super("A PlatformArchitecture contains the invalid element " + element.getName() + "(id: " + - element.getId() + "). Details:\n" + msg); - } - - /** Constructor that stacks an additional {@link Exception}. */ - public InvalidPlatformModelException(IPlatformArchitectureElement element, String msg, - Exception e) { - super("A PlatformArchitecture contains the invalid element " + element.getName() + "(id: " + - element.getId() + "). Details:\n" + msg, e); - } - - /** Constructor. */ - public InvalidPlatformModelException(PlatformConnectorUnit element, String msg) { - super("A PlatformArchitecture contains the invalid element " + element.getName() + "(id: " + - element.getId() + "). Details:\n" + msg); - } - - /** Constructor that stacks an additional {@link Exception}. */ - public InvalidPlatformModelException(PlatformConnectorUnit element, String msg, Exception e) { - super("A PlatformArchitecture contains the invalid element " + element.getName() + "(id: " + - element.getId() + "). Details:\n" + msg, e); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/InvalidTimingModelException.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/InvalidTimingModelException.java deleted file mode 100644 index f8e947c3177759c3454bd7910670ab498fe00e3b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/InvalidTimingModelException.java +++ /dev/null @@ -1,39 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: InvalidTimingModelException.java 3480 2016-09-09 13:31:04Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.exception; - -/** - * {@link InvalidTimingModelException} for invalid timing specification/models. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3480 $ - * @ConQAT.Rating RED Hash: 859D59665309F360498315DB741603A3 - */ -public class InvalidTimingModelException extends ExplorationException { - - /** Constructor. */ - public InvalidTimingModelException(String msg) { - super("Found an invalid timing specification: " + msg); - } - - /** Constructor attaching the input {@link Exception}. */ - public InvalidTimingModelException(String msg, Exception e) { - super("Found an invalid timing specification: " + msg, e); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/TransformationModuleException.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/TransformationModuleException.java deleted file mode 100644 index 11d5e9f980758d3e5be2486134179779f565d94b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/exception/TransformationModuleException.java +++ /dev/null @@ -1,43 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: TransformationModuleException.java 3480 2016-09-09 13:31:04Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.exception; - -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; - -/** - * Exception to be thrown if some transformation within a {@link ITransformationModule} fails. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3480 $ - * @ConQAT.Rating RED Hash: 730EECECFC68E0037214F56F3C9EBB57 - */ -public class TransformationModuleException extends ExplorationException { - - /** Constructor. */ - public TransformationModuleException(ITransformationModule<?> module, String message) { - super("Transformation module " + module.getClass().getSimpleName() + " failed: " + message); - } - - /** Constructor that stacks an additional {@link Exception}. */ - public TransformationModuleException(ITransformationModule<?> module, String message, - Exception e) { - super("Transformation module " + module.getClass().getSimpleName() + " failed: " + message, - e); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/DependencyEdge.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/DependencyEdge.java deleted file mode 100644 index ce9ce41b697410046e7ce2e4dd9ee43e24812351..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/DependencyEdge.java +++ /dev/null @@ -1,49 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.graph; - -import java.util.HashSet; -import java.util.Set; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.jgrapht.graph.DefaultEdge; - -/** - * Edge to represent the in- and output types of an operation to calculate the operation's - * dependencies. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: F6601B178D6393FD17C6C74C2D34043A - */ -public class DependencyEdge<T> extends DefaultEdge { - - /** The {@link ComposableDecoder} represented by {@code this} edge. */ - Set<T> elements = new HashSet<>(); - - /** Sets the {@link ComposableDecoder} represented by {@code this} edge. */ - public void addDecoder(T element) { - elements.add(element); - } - - /** Returns the {@link ComposableDecoder} represented by {@code this} edge. */ - public Set<T> getElements() { - return elements; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/DependencyGraph.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/DependencyGraph.java deleted file mode 100644 index 4ced529b2cdbcac0334fdad24d15be58f1c136a8..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/DependencyGraph.java +++ /dev/null @@ -1,375 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExecDependencyGraph.java 3449 2016-09-02 11:06:00Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.graph; - -import static org.apache.commons.collections4.CollectionUtils.isEqualCollection; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Set; -import java.util.stream.Collectors; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode.ComposableDecoder; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.exception.MissingDependencyException; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.util.GraphUtils; -import org.jgrapht.DirectedGraph; -import org.jgrapht.Graphs; -import org.jgrapht.experimental.dag.DirectedAcyclicGraph; -import org.jgrapht.experimental.dag.DirectedAcyclicGraph.CycleFoundException; -import org.jgrapht.graph.DefaultDirectedGraph; -import org.opt4j.core.optimizer.IncompatibilityException; -import org.opt4j.core.problem.Creator; -import org.opt4j.core.problem.Decoder; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -/** - * Defines the Execution order of {@link Decoder}s / {@link Creator}s etc. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3449 $ - * @ConQAT.Rating RED Hash: 8596106CB7E41FE2577F1CCBAF9DED58 - */ -// TODO: extend documentation. -// TODO: extend for the evaluator registration. -public abstract class DependencyGraph<V, T extends IDependencyModule<V, ? extends V>, E extends DependencyEdge<T>> { - - /** Internal graph representation for the execution order of s. */ - @SuppressWarnings("unchecked") - protected DirectedAcyclicGraph<Class<? extends V>, E> dependencyDagGraph = - new DirectedAcyclicGraph<Class<? extends V>, E>( - (Class<? extends E>)DependencyEdge.class); - - /** Contains the calculated execution order for operators. */ - protected LinkedList<T> operatorExecOrder = new LinkedList<>(); - - /** Type of the vertices of {@code this} dependency graph. */ - private Class<? extends V> vertexType; - - /** Collection of requested types. */ - private Set<Class<? extends V>> requestedTypes; - - /** Collection of all required types. */ - private Set<Class<? extends V>> requiredTypes = new HashSet<>(); - - /** Operators which implement an identity operation. */ - private Multimap<Class<? extends V>, T> identityOperators = HashMultimap.create(); - - /** Constructor. */ - public DependencyGraph(Set<Class<? extends V>> reqTypeCollection, Class<? extends V> vertexType) { - requestedTypes = reqTypeCollection; - this.vertexType = vertexType; - } - - /** - * Adds the input types and the generated output types of the given - * operator to this {@link DependencyGraph}. They are connected by edges - * which represent the given operator. - * - * @throws CycleFoundException - * If adding the given operator to {@code this} graph would result - * in circular dependencies in executing the operators. - */ - public void addOperator(T edgeOperator) throws CycleFoundException { - Collection<Class<? extends V>> requiredTypes = getReqInputTypesFrom(edgeOperator); - // TODO: add a proper exception. - if(vertexType.isAssignableFrom(edgeOperator.getOutputType())) { - @SuppressWarnings("unchecked") Class<V> outType = - (Class<V>)edgeOperator.getOutputType(); - // Decoder graph. Add vertices, then edges. - dependencyDagGraph.addVertex(outType); - requiredTypes.forEach(p -> dependencyDagGraph.addVertex(p)); - for(Class<? extends V> inputPheno : requiredTypes) { - // Allow Identity Decoders. - if(inputPheno.equals(edgeOperator.getOutputType())) { - identityOperators.put(inputPheno, edgeOperator); - } else { - E edge = dependencyDagGraph.getEdge(inputPheno, outType); - if(edge == null) { - edge = dependencyDagGraph.addDagEdge(inputPheno, outType); - } - edge.addDecoder(edgeOperator); - } - } - } - } - - /** - * Validates whether all required inputs demanded by the given module are V types and - * returns a casted collection of the required inputs if the mentioned condition is met. - * Otherwise, an exception is thrown. - */ - @SuppressWarnings("unchecked") - private Collection<Class<? extends V>> getReqInputTypesFrom(T module) { - Collection<Class<? extends V>> castedInputTypes = new HashSet<>(); - for(Class<?> curInputType : module.getRequiredTypes()) { - if(curInputType.isAssignableFrom(vertexType)) { - throw new IncompatibilityException("The required input type " + - curInputType.getSimpleName() + " is not an " + vertexType.getSimpleName() + - "."); - } - castedInputTypes.add((Class<? extends V>)curInputType); - } - return castedInputTypes; - } - - /** - * Returns the calculated execution order of the operator such that the - * requested input types can be obtained. - * - * @throws MissingDependencyException - * if some required input type of a operator is - * not provided by another one. - */ - public List<T> getOperatorExecOrder() throws MissingDependencyException { - if(operatorExecOrder.isEmpty()) { - calculateExecutionOrder(); - } - return operatorExecOrder; - } - - /** - * Calculates a feasible execution order of operators w.r.t. to the dependencies implicitly - * encoded in the input parameters. - * - * @throws MissingDependencyException - * if some required input type of a operator is - * not provided by another one. - */ - private void calculateExecutionOrder() throws MissingDependencyException { - // TODO: add comments to explain the resoning inside this method. - @SuppressWarnings("unchecked") DirectedGraph<Class<? extends V>, E> execOrderGraph = - new DefaultDirectedGraph<>((Class<? extends E>)DependencyEdge.class); - Queue<Class<? extends V>> inputTypes = new LinkedList<>(); - Set<Class<? extends V>> traversedTypes = new HashSet<>(); - Set<E> requiredOperators = new HashSet<>(); - inputTypes.addAll(requestedTypes); - while(!inputTypes.isEmpty()) { - @SuppressWarnings("unchecked") Class<V> operatorInputType = (Class<V>)inputTypes.poll(); - requiredOperators.addAll(dependencyDagGraph.incomingEdgesOf(operatorInputType)); - for(E edge : requiredOperators) { - Class<? extends V> srcType = dependencyDagGraph.getEdgeSource(edge); - if(!traversedTypes.contains(srcType)) { - inputTypes.add(srcType); - traversedTypes.add(srcType); - } - } - } - - Collection<Class<? extends V>> inTypes = - requiredOperators.stream().map(d -> dependencyDagGraph.getEdgeSource(d)) - .collect(Collectors.toList()); - getIdentityOperatorsOf(inTypes).entrySet().forEach( - e -> identityOperators.put(e.getKey(), e.getValue())); - getIdentityOperatorsOf(requestedTypes).entrySet().forEach( - e -> identityOperators.put(e.getKey(), e.getValue())); - - for(E edge : requiredOperators) { - Graphs.addEdgeWithVertices(execOrderGraph, dependencyDagGraph, edge); - } - - // DEBUG code: only include if the dependency graph shall be debugged. Otherwise, two - // windows for each individual and iteration will be produced. - // if(isDebugVerboseEnabled()) { - // ObjectJGraphTVisualizer<Class<? extends V>, E> graphViz = - // new ObjectJGraphTVisualizer<Class<? extends V>, E>(dependencyDagGraph); - // graphViz.displayGraph("Dependency graph"); - // - // } - // - // if(isDebugVerboseEnabled()) { - // ObjectJGraphTVisualizer<Class<? extends V>, E> graphViz = - // new ObjectJGraphTVisualizer<Class<? extends V>, E>(execOrderGraph); - // graphViz.displayGraph("Dependency graph (Exec Order)"); - // - // } - - calculateExecOrderList(execOrderGraph); - - checkMissingDependencies(); - } - - /** - * Each implementation of the {@link DependencyGraph} must provide a check for missing - * dependencies, sine there may be alternative ways to retrieve the required inputs, e.g., via - * the {@link SystemModelAdapter} in the {@link ComposableDecoder}s. - * - * @throws MissingDependencyException - * If any required input of some required module is missing. - */ - protected abstract void checkMissingDependencies() throws MissingDependencyException; - - /** - * Calculates the effective execution order of the operators and adds them to the internal list - * of {@code this} {@link DependencyGraph}. - */ - private void calculateExecOrderList(DirectedGraph<Class<? extends V>, E> execOrderGraph) { - Queue<Class<? extends V>> traversalQueue = new LinkedList<>(); - traversalQueue.addAll(requestedTypes); - - while(!traversalQueue.isEmpty()) { - Class<? extends V> encType = traversalQueue.poll(); - - if(execOrderGraph.containsVertex(encType)) { - for(E decoderEdge : execOrderGraph.incomingEdgesOf(encType)) { - decoderEdge.getElements().forEach(e -> operatorExecOrder.addFirst(e)); - - // If not yet present, consider the results for the iteration over the next - // "graph layer". - Class<? extends V> decInputType = execOrderGraph.getEdgeSource(decoderEdge); - if(decInputType != null && !traversalQueue.contains(decInputType)) { - traversalQueue.add(decInputType); - } - } - } - - if(identityOperators.containsKey(encType)) { - identityOperators.get(encType).stream().filter(i -> !operatorExecOrder.contains(i)) - .forEach(i -> operatorExecOrder.addFirst(i)); - } - } - - if(getSubExecListComparator() != null) { - Iterator<T> operatorIt = operatorExecOrder.iterator(); - T nextOperator = operatorIt.next(); - while(operatorIt.hasNext()) { - T curOperator = nextOperator; - List<T> curSubList = new ArrayList<>(); - - while(isEqualCollection(curOperator.getRequiredTypes(), - nextOperator.getRequiredTypes())) { - curSubList.add(nextOperator); - if(operatorIt.hasNext()) { - nextOperator = operatorIt.next(); - } else { - break; - } - } - - Collections.sort(curSubList, getSubExecListComparator()); - } - } - } - - /** - * Returns a {@link Comparator} that is used to sort Operators which could be executed at the - * same time since their dependencies are satisfied. If no specialized {@link Comparator} is - * returned, these operations are executed in an arbitrary order. - * Here, the implementing classes must provide the {@link Comparator} as this ordering is - * implementation-specific in contrast to the pure resolution of dependencies. - */ - protected abstract Comparator<T> getSubExecListComparator(); - - /** - * Returns the set of <i>all</i> vertices that must be processed to obtain - * the requested outputs. - */ - public Set<Class<? extends V>> getAllRequiredTypes() { - if(requiredTypes.isEmpty()) { - // FIXME: calculation is launched excessively and returns empty collections. - calculateAllRequiredTypes(); - } - Set<Class<? extends V>> reqInputSet = new HashSet<>(); - for(Class<? extends V> reqInType : requiredTypes) { - reqInputSet.add(reqInType); - } - return reqInputSet; - } - - /** - * Calculates the set of vertices that must be processed to obtain the - * requested outputs. - */ - private void calculateAllRequiredTypes() { - for(Class<? extends V> reqType : requestedTypes) { - requiredTypes.addAll(GraphUtils.getAllPredescesorsOf(dependencyDagGraph, reqType)); - } - requiredTypes.addAll(requestedTypes); - } - - /** Returns the set of all requested vertices. */ - public Set<Class<? extends V>> getAllRequestedTypes() { - Set<Class<? extends V>> inputTypeSet = new HashSet<>(); - for(Class<? extends V> encType : requestedTypes) { - if(Phenotype.class.isAssignableFrom(encType)) { - inputTypeSet.add(encType); - } - } - return inputTypeSet; - } - - /** - * Returns a collection of identity operators which operate on the given input types. The set of - * operators to be checked equals the set of operators in the graph. - */ - private Map<Class<? extends V>, T> getIdentityOperatorsOf( - Collection<Class<? extends V>> encodingTypes) { - Map<Class<? extends V>, T> filteredIdentityOperators = new HashMap<>(); - for(E edge : dependencyDagGraph.edgeSet()) { - Class<? extends V> srcType = dependencyDagGraph.getEdgeSource(edge); - if((srcType == dependencyDagGraph.getEdgeTarget(edge)) && - encodingTypes.contains(srcType)) { - assert (edge.getElements().size() > 1) : "Only one identity decoder for each element type is supported."; - filteredIdentityOperators.put(srcType, edge.getElements().stream().findAny().get()); - } - } - return filteredIdentityOperators; - } - - /** - * Comparator to allow ordering of operator lists by means of the execution - * order defined in a {@link DependencyGraph}. - */ - public static class DependencyComparator<V, T extends IDependencyModule<V, ? extends V>, E extends DependencyEdge<T>> - implements Comparator<T> { - - /** List of the execution order of {@link ComposableDecoder}s. */ - List<T> execDecList; - - /** - * Constructor. - * - * @throws MissingDependencyException - * if some required input type of an operator - * is not provided by another one. - */ - public DependencyComparator(DependencyGraph<V, T, E> execDepGraph) - throws MissingDependencyException { - execDecList = execDepGraph.getOperatorExecOrder(); - } - - /** {@inheritDoc} */ - @Override - public int compare(T left, T right) { - return Integer.compare(execDecList.indexOf(left), execDecList.indexOf(right)); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/IDependencyModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/IDependencyModule.java deleted file mode 100644 index 2843e7c705cc73fca064bee981a87eab2628d1da..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/IDependencyModule.java +++ /dev/null @@ -1,51 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.graph; - -import java.util.Collection; - -/** - * Interface to be implemented by operations that have dependencies and which are used in a process - * like the DSE. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 67E0B43053EED579C5476BECE8F4BD0C - */ -// TODO: the Generic "I" is intended to define the input types. Unfortunately, using it in the -// transformation framework, causes some issues. In a future version, check the possibilities to use -// this parameter. Also apply this modification in the DependencyGraph class and its users in the -// Decoders and Element-wise transformation framework. -public interface IDependencyModule<I, O> { - /** - * Returns the collection of input types that are required as direct - * inputs to {@code this} operation. - */ - Collection<Class<?>> getRequiredTypes(); - - /** - * Returns the collection of input types that may provide optional information - * for the operation applied to the required inputs but which are not required for the - * operation. - */ - Collection<Class<?>> getOptionalTypes(); - - /** Returns the resulting type of {@code this} operation. */ - Class<? super O> getOutputType(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/AF3JGraphTVisualizer.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/AF3JGraphTVisualizer.java deleted file mode 100644 index 0a259bf9f8a70fff30c522f531018b0a1ee52a27..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/AF3JGraphTVisualizer.java +++ /dev/null @@ -1,116 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3JGraphTVisualizer.java 3449 2016-09-02 11:06:00Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.graph.display; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import javax.swing.JFrame; - -import org.fortiss.tooling.base.model.element.IModelElement; -import org.jgrapht.DirectedGraph; -import org.jgrapht.Graph; -import org.jgrapht.ext.JGraphXAdapter; -import org.jgrapht.graph.DefaultDirectedGraph; -import org.jgrapht.graph.DefaultEdge; - -import com.mxgraph.layout.mxFastOrganicLayout; -import com.mxgraph.swing.mxGraphComponent; -import com.mxgraph.util.mxConstants; - -/** - * Used for visualizing graphs (from JGraphT). To display a graph, this class must be instantiated - * first, and then the {@code displayGraph} method must be called. - * - * Usage Example: - * {@code JGraphTVisualizer<IDeployableComponentAdapter, ChannelAdapterWeightedEdge> taskViz = - new JGraphTVisualizer<IDeployableComponentAdapter, ChannelAdapterWeightedEdge>( - taskGraph.getGraph()); - taskViz.displayGraph(); } - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3449 $ - * @ConQAT.Rating RED Hash: 4143D97A7629D710B21A4F56991A4ABA - */ -public class AF3JGraphTVisualizer<V extends IModelElement, E extends DefaultEdge> { - - /** - * Contains the graph which was given to the Constructor, except that the vertices have been - * converted to Named vertices to support comprehensive visualization. - */ - private DirectedGraph<NamedAF3Vertex<V>, DefaultEdge> namedGraph; - - /** Constructor. */ - public AF3JGraphTVisualizer(Graph<V, E> g) { - namedGraph = constructNamedGraph(g); - } - - /** Displays the graph given in the constructor. */ - public void displayGraph(String graphWindowTitle) { - // Create an adapter for JGraphX, via an adapter. - JGraphXAdapter<NamedAF3Vertex<V>, DefaultEdge> jgxAdapter = - new JGraphXAdapter<NamedAF3Vertex<V>, DefaultEdge>(namedGraph); - - // Disable labels of edges. - jgxAdapter.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_NOLABEL, "1"); - - // positioning via jgraphx layouts - mxFastOrganicLayout layout = new mxFastOrganicLayout(jgxAdapter); - // layout.setMinDistanceLimit(layout.getMinDistanceLimit() * 2); - // The higher, the more separated layout. - layout.setForceConstant(layout.getForceConstant() * 1.5); - layout.execute(jgxAdapter.getDefaultParent()); - - mxGraphComponent graphComponent = new mxGraphComponent(jgxAdapter); - - // Draws the window containing the graph. - JFrame frame = new JFrame(); - frame.setTitle(graphWindowTitle); - frame.getContentPane().add(graphComponent); - frame.pack(); - frame.setVisible(true); - } - - /** - * Converts the given graph to graph that has {@link NamedVertex}-Nodes instead of the original - * vertices. Displaying those is more convenient. - */ - private DirectedGraph<NamedAF3Vertex<V>, DefaultEdge> constructNamedGraph( - Graph<V, E> originalGraph) { - DirectedGraph<NamedAF3Vertex<V>, DefaultEdge> namedGraph = - new DefaultDirectedGraph<NamedAF3Vertex<V>, DefaultEdge>(DefaultEdge.class); - Set<E> originalEdgeSet = originalGraph.edgeSet(); - Map<V, NamedAF3Vertex<V>> relateVertexToNamedElement = new HashMap<V, NamedAF3Vertex<V>>(); - - for(V currentVertex : originalGraph.vertexSet()) { - NamedAF3Vertex<V> currentNamedVertex = new NamedAF3Vertex<V>(currentVertex); - namedGraph.addVertex(currentNamedVertex); - relateVertexToNamedElement.put(currentVertex, currentNamedVertex); - } - - for(E edge : originalEdgeSet) { - namedGraph.addEdge(relateVertexToNamedElement.get(originalGraph.getEdgeSource(edge)), - relateVertexToNamedElement.get(originalGraph.getEdgeTarget(edge))); - } - - return namedGraph; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/JGraphTVisualizer.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/JGraphTVisualizer.java deleted file mode 100644 index 3319b13b06ebbf9c662c6d50cf79cf6a7f57c143..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/JGraphTVisualizer.java +++ /dev/null @@ -1,121 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: JGraphTVisualizer.java 3449 2016-09-02 11:06:00Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.graph.display; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import javax.swing.JFrame; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IModelElementAdapter; -import org.jgrapht.DirectedGraph; -import org.jgrapht.Graph; -import org.jgrapht.ext.JGraphXAdapter; -import org.jgrapht.graph.DefaultDirectedGraph; -import org.jgrapht.graph.DefaultEdge; - -import com.mxgraph.layout.mxFastOrganicLayout; -import com.mxgraph.swing.mxGraphComponent; -import com.mxgraph.util.mxConstants; - -/** - * Used for visualizing graphs (from JGraphT). To display a graph, this class must be instantiated - * first, and then the {@code displayGraph} method must be called. - * - * Usage Example: - * {@code JGraphTVisualizer<IDeployableComponentAdapter, ChannelAdapterWeightedEdge> taskViz = - new JGraphTVisualizer<IDeployableComponentAdapter, ChannelAdapterWeightedEdge>( - taskGraph.getGraph()); - taskViz.displayGraph(); } - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3449 $ - * @ConQAT.Rating RED Hash: 7E2D63783EC218613547C0118F4174AD - */ -public class JGraphTVisualizer<V extends IModelElementAdapter<?>, E extends DefaultEdge> { - - /** - * Contains the graph which was given to the Constructor, except that the vertices have been - * converted to Named vertices to support comprehensive visualization. - */ - private DirectedGraph<NamedVertex<V>, DefaultEdge> namedGraph; - - /** Constructor. */ - public JGraphTVisualizer(Graph<V, E> g) { - namedGraph = constructNamedGraph(g); - } - - /** Displays the graph given in the constructor. */ - public void displayGraph(String graphWindowTitle) { - // Create an adapter for JGraphX, via an adapter. - JGraphXAdapter<NamedVertex<V>, DefaultEdge> jgxAdapter = - new JGraphXAdapter<NamedVertex<V>, DefaultEdge>(namedGraph); - - // Disable labels of edges. - jgxAdapter.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_NOLABEL, "1"); - - // positioning via jgraphx layouts - mxFastOrganicLayout layout = new mxFastOrganicLayout(jgxAdapter); - // layout.setMinDistanceLimit(layout.getMinDistanceLimit() * 2); - // The higher, the more separated layout. - layout.setForceConstant(layout.getForceConstant() * 1.5); - layout.execute(jgxAdapter.getDefaultParent()); - - mxGraphComponent graphComponent = new mxGraphComponent(jgxAdapter); - - // Draws the window containing the graph. - JFrame frame = new JFrame(); - frame.setTitle(graphWindowTitle); - frame.getContentPane().add(graphComponent); - frame.pack(); - frame.setVisible(true); - - // mxGraphView view = graphComponent.getGraph().getView(); - // int compLen = graphComponent.getWidth(); - // int viewLen = (int)view.getGraphBounds().getWidth(); - // view.setScale((double)compLen / viewLen * view.getScale()); - } - - /** - * Converts the given graph to graph that has {@link NamedVertex}-Nodes instead of the original - * vertices. Displaying those is more convenient. - */ - private DirectedGraph<NamedVertex<V>, DefaultEdge> - constructNamedGraph(Graph<V, E> originalGraph) { - DirectedGraph<NamedVertex<V>, DefaultEdge> namedGraph = - new DefaultDirectedGraph<NamedVertex<V>, DefaultEdge>(DefaultEdge.class); - Set<E> originalEdgeSet = originalGraph.edgeSet(); - Map<V, NamedVertex<V>> relateVertexToNamedElement = new HashMap<V, NamedVertex<V>>(); - - for(V currentVertex : originalGraph.vertexSet()) { - NamedVertex<V> currentNamedVertex = new NamedVertex<V>(currentVertex); - namedGraph.addVertex(currentNamedVertex); - relateVertexToNamedElement.put(currentVertex, currentNamedVertex); - } - - for(E edge : originalEdgeSet) { - namedGraph.addEdge(relateVertexToNamedElement.get(originalGraph.getEdgeSource(edge)), - relateVertexToNamedElement.get(originalGraph.getEdgeTarget(edge))); - } - - return namedGraph; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/NamedAF3Vertex.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/NamedAF3Vertex.java deleted file mode 100644 index 2303916b89f75d475a76d8d955421832f6cb11f3..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/NamedAF3Vertex.java +++ /dev/null @@ -1,50 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: NamedAF3Vertex.java 3449 2016-09-02 11:06:00Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.graph.display; - -import java.io.Serializable; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IModelElementAdapter; -import org.fortiss.tooling.base.model.element.IModelElement; -import org.fortiss.tooling.kernel.model.INamedElement; - -/** - * Wrapper class for displaying arbitrary Vertices inheriting from {@link IModelElementAdapter} of a - * graph (-> JGraphT). It is used to display the name of the elements. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3449 $ - * @ConQAT.Rating RED Hash: 4A7ACFD903986FE7649D5CD3CD2539B6 - */ -public class NamedAF3Vertex<V extends IModelElement> implements Serializable { - - /** The element associated with this vertex wrapper. */ - private INamedElement namedElement; - - /** Constructor. */ - NamedAF3Vertex(V currentVertex) { - namedElement = (INamedElement)currentVertex; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return namedElement.getName() + "(ID: " + namedElement.getId() + ")"; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/NamedVertex.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/NamedVertex.java deleted file mode 100644 index 42dbc9ca8c487f1b48713bcaf4301bad0636f5a6..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/NamedVertex.java +++ /dev/null @@ -1,49 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: NamedVertex.java 3449 2016-09-02 11:06:00Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.graph.display; - -import java.io.Serializable; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IModelElementAdapter; -import org.fortiss.tooling.kernel.model.INamedElement; - -/** - * Wrapper class for displaying arbitrary Vertices inheriting from {@link IModelElementAdapter} of a - * graph (-> JGraphT). It is used to display the name of the elements. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3449 $ - * @ConQAT.Rating RED Hash: 9907E0B5FFFA80715FA2FEC540FF1DD1 - */ -public class NamedVertex<V extends IModelElementAdapter<?>> implements Serializable { - - /** The element associated with this vertex wrapper. */ - private INamedElement namedElement; - - /** Constructor. */ - NamedVertex(V currentVertex) { - namedElement = (INamedElement)currentVertex.getObject(); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return namedElement.getName() + "(ID: " + namedElement.getId() + ")"; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/ObjectJGraphTVisualizer.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/ObjectJGraphTVisualizer.java deleted file mode 100644 index 3383ced7f4f2d0b3d27529ae1836b845a751a9f5..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/ObjectJGraphTVisualizer.java +++ /dev/null @@ -1,120 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ObjectJGraphTVisualizer.java 3449 2016-09-02 11:06:00Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.graph.display; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import javax.swing.JFrame; - -import org.jgrapht.DirectedGraph; -import org.jgrapht.Graph; -import org.jgrapht.ext.JGraphXAdapter; -import org.jgrapht.graph.DefaultDirectedGraph; -import org.jgrapht.graph.DefaultEdge; - -import com.mxgraph.layout.mxFastOrganicLayout; -import com.mxgraph.swing.mxGraphComponent; -import com.mxgraph.util.mxConstants; - -/** - * Used for visualizing graphs (from JGraphT). To display a graph, this class must be instantiated - * first, and then the {@code displayGraph} method must be called. - * Used to display generic Java Objects. - * - * Usage Example: - * {@code ObjectJGraphTVisualizer<IDeployableComponentAdapter, ChannelAdapterWeightedEdge> taskViz = - new ObjectJGraphTVisualizer<IDeployableComponentAdapter, ChannelAdapterWeightedEdge>( - taskGraph.getGraph()); - taskViz.displayGraph(); } - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3449 $ - * @ConQAT.Rating RED Hash: 037B28D833AC8839E34F6A09BBC67FCC - */ -public class ObjectJGraphTVisualizer<V, E extends DefaultEdge> { - - /** - * Contains the graph which was given to the Constructor, except that the vertices have been - * converted to Named vertices to support comprehensive visualization. - */ - private DirectedGraph<ObjectVertex<V>, DefaultEdge> namedGraph; - - /** Constructor. */ - public ObjectJGraphTVisualizer(Graph<V, E> g) { - namedGraph = constructNamedGraph(g); - } - - /** Displays the graph given in the constructor. */ - public void displayGraph(String graphWindowTitle) { - // Create an adapter for JGraphX, via an adapter. - JGraphXAdapter<ObjectVertex<V>, DefaultEdge> jgxAdapter = new JGraphXAdapter<>(namedGraph); - - // Disable labels of edges. - jgxAdapter.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_NOLABEL, "1"); - - // positioning via jgraphx layouts - mxFastOrganicLayout layout = new mxFastOrganicLayout(jgxAdapter); - // layout.setMinDistanceLimit(layout.getMinDistanceLimit() * 2); - // The higher, the more separated layout. - layout.setForceConstant(layout.getForceConstant() * 1.5); - layout.execute(jgxAdapter.getDefaultParent()); - - mxGraphComponent graphComponent = new mxGraphComponent(jgxAdapter); - - // Draws the window containing the graph. - JFrame frame = new JFrame(); - frame.setTitle(graphWindowTitle); - frame.getContentPane().add(graphComponent); - frame.pack(); - frame.setVisible(true); - - // mxGraphView view = graphComponent.getGraph().getView(); - // int compLen = graphComponent.getWidth(); - // int viewLen = (int)view.getGraphBounds().getWidth(); - // view.setScale((double)compLen / viewLen * view.getScale()); - } - - /** - * Converts the given graph to graph that has {@link NamedVertex}-Nodes instead of the original - * vertices. Displaying those is more convenient. - */ - private DirectedGraph<ObjectVertex<V>, DefaultEdge> constructNamedGraph( - Graph<V, E> originalGraph) { - DirectedGraph<ObjectVertex<V>, DefaultEdge> namedGraph = - new DefaultDirectedGraph<>(DefaultEdge.class); - Set<E> originalEdgeSet = originalGraph.edgeSet(); - Map<V, ObjectVertex<V>> relateVertexToNamedElement = new HashMap<>(); - - for(V currentVertex : originalGraph.vertexSet()) { - ObjectVertex<V> currentNamedVertex = new ObjectVertex<V>(currentVertex); - namedGraph.addVertex(currentNamedVertex); - relateVertexToNamedElement.put(currentVertex, currentNamedVertex); - } - - for(E edge : originalEdgeSet) { - namedGraph.addEdge(relateVertexToNamedElement.get(originalGraph.getEdgeSource(edge)), - relateVertexToNamedElement.get(originalGraph.getEdgeTarget(edge))); - } - - return namedGraph; - } - -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/ObjectVertex.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/ObjectVertex.java deleted file mode 100644 index fc56948f0083586c11644f9862fb8a86195a8ff5..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/graph/display/ObjectVertex.java +++ /dev/null @@ -1,46 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ObjectVertex.java 3449 2016-09-02 11:06:00Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.graph.display; - -/** - * Wrapped for generic Java objects to be displayed in the graph dialog. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3449 $ - * @ConQAT.Rating RED Hash: 8458522DFDB8E0C35A7CE894B95F8DE4 - */ -public class ObjectVertex<V> { - - /** The element associated with this vertex wrapper. */ - private V element; - - /** Constructor. */ - ObjectVertex(V currentVertex) { - element = currentVertex; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - if(element instanceof Class) { - return ((Class<?>)element).getSimpleName(); - } - return element.toString(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/HashTypedBiMap.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/HashTypedBiMap.java deleted file mode 100644 index 23749aae0322ccd505c88c0512a7c1e93c2d6df1..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/HashTypedBiMap.java +++ /dev/null @@ -1,141 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.guava; - -import java.util.Map; -import java.util.Set; - -import com.google.common.collect.BiMap; -import com.google.common.collect.ForwardingMap; -import com.google.common.collect.HashBiMap; - -/** - * {@link BiMap} implementation whose keys and values are pairs of an object and an associated type. - * This {@link BiMap} is symmetric: It allows references of multiple keys to the same object iff - * the keys have different types. Hence, the 1:1 association between keys and values of - * {@link BiMap}s is preserved. - * - * For an extended documentation please see {@link BiMap}. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 61D141A942DCC63BB01CCCB03E96D8C0 - */ -public class HashTypedBiMap<K, V> extends ForwardingMap<TypedPair<K, V>, TypedPair<V, K>> implements - TypedBiMap<K, V>/* , BiMap<TypedPair<K, V>, TypedPair<V, K>> */{ - - /** - * Returns a new, empty {@code HashBiMap} with the default initial capacity (16). - */ - public static <K, V> HashTypedBiMap<K, V> create() { - return create(16); - } - - /** - * Constructs a new, empty bimap with the specified expected size. - * - * @param expectedSize - * the expected number of entries - * @throws IllegalArgumentException - * if the specified expected size is negative - */ - public static <K, V> HashTypedBiMap<K, V> create(int expectedSize) { - return new HashTypedBiMap<K, V>(expectedSize); - } - - /** - * Constructs a new bimap containing initial values from {@code map}. The bimap is created with - * an - * initial capacity sufficient to hold the mappings in the specified map. - */ - public static <K, V> HashTypedBiMap<K, V> create( - Map<? extends TypedPair<K, V>, ? extends TypedPair<V, K>> map) { - HashTypedBiMap<K, V> bimap = create(map.size()); - bimap.putAll(map); - return bimap; - } - - /** {@link BiMap} holding the actual entries of {@code this} map. */ - protected BiMap<TypedPair<K, V>, TypedPair<V, K>> delegateMap; - - /** - * Provides the inverse view on {@code this} {@link TypedBiMap} that is backed by the same - * delegate {@link BiMap}. - */ - protected TypedBiMap<V, K> inverseView; - - /** Hidden constructor to be called from the static create methods. */ - private HashTypedBiMap(int expectedSize) { - this(expectedSize, null, null); - } - - /** Hidden constructor to be called from the static create methods. */ - private HashTypedBiMap(int expectedSize, TypedBiMap<V, K> inverseView, - BiMap<TypedPair<K, V>, TypedPair<V, K>> delegateMap) { - if(inverseView == null) { - this.delegateMap = HashBiMap.create(expectedSize); - this.inverseView = - new HashTypedBiMap<V, K>(expectedSize, this, this.delegateMap.inverse()); - } else { - this.inverseView = inverseView; - this.delegateMap = delegateMap; - } - } - - /** {@inheritDoc} */ - @Override - protected BiMap<TypedPair<K, V>, TypedPair<V, K>> delegate() { - return delegateMap; - } - - /** {@inheritDoc} */ - @Override - public V get(K key, Class<? extends V> valType) { - @SuppressWarnings("unchecked") TypedPair<V, K> retVal = - delegate().get(new TypedPair<K, V>(key, (Class<V>)valType)); - return retVal != null ? retVal.getFirst() : null; - } - - /** {@inheritDoc} */ - @Override - public V put(K key, Class<? extends V> valType, V value, Class<? extends K> keyType) { - @SuppressWarnings("unchecked") TypedPair<V, K> oldPair = - delegate().forcePut(new TypedPair<K, V>(key, (Class<V>)valType), - new TypedPair<V, K>(value, (Class<K>)keyType)); - return oldPair != null ? oldPair.getFirst() : null; - } - - /** {@inheritDoc} */ - @Override - public TypedPair<V, K> forcePut(TypedPair<K, V> key, TypedPair<V, K> value) { - return delegate().forcePut(key, value); - } - - /** {@inheritDoc} */ - @Override - public Set<TypedPair<V, K>> values() { - return delegate().values(); - } - - /** {@inheritDoc} */ - @Override - public TypedBiMap<V, K> inverse() { - return inverseView; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/IAssociativeElement.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/IAssociativeElement.java deleted file mode 100644 index 9215f23bc1c349b9600be2c3b082801c06f21183..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/IAssociativeElement.java +++ /dev/null @@ -1,62 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.guava; - -import java.util.Collection; - -/** - * {@link IAssociativeElement} define corresponding {@link IAssociativeElement}s of another DSE - * process stage. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 15C2804564EEF90274824F42727178C9 - */ -public interface IAssociativeElement<T extends IAssociativeElement<?>> { - - /** - * Adds the given {@code entry} to the set of associated {@link IAssociativeElement}s of - * {@code this} {@link IAssociativeElement}. - * - * @param entry - * The {@link IAssociativeElement} to associate with. - */ - void addAssociatedElement(T entry); - - /** - * Removes the given {@code entry} to the set of associated {@link IAssociativeElement}s of - * {@code this} {@link IAssociativeElement}. - * - * @param entry - * The {@link IAssociativeElement} to remove if any is present. - */ - void rmAssociatedElement(T entry); - - /** - * Returns the set of associated {@link IAssociativeElement}s of {@code this} - * {@link IAssociativeElement}. - */ - Collection<T> getAssociatedElement(); - - /** - * Returns the associated {@link IAssociativeElement} of {@code this} - * {@link IAssociativeElement} which has the given type. - */ - <S extends T> S getAssociatedElement(Class<S> type); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/ImmutableSubClassToInstanceMap.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/ImmutableSubClassToInstanceMap.java deleted file mode 100644 index 9ac626696452dddfc397847a3c840d642af8a0f2..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/ImmutableSubClassToInstanceMap.java +++ /dev/null @@ -1,208 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.guava; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.io.Serializable; -import java.util.Map; - -import com.google.common.annotations.GwtIncompatible; -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ForwardingMap; -import com.google.common.collect.ImmutableMap; -import com.google.common.primitives.Primitives; - -/** - * Immutable version of the {@link SubClassToInstanceMap}. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 5799B3F8B07B48DE4742FFBA3F02E28F - */ -@SuppressWarnings("javadoc") -@GwtIncompatible(value = "") -public final class ImmutableSubClassToInstanceMap<B> extends ForwardingMap<Class<? extends B>, B> - implements ClassToInstanceMap<B>, Serializable { - - private static final ImmutableSubClassToInstanceMap<Object> EMPTY = - new ImmutableSubClassToInstanceMap<Object>(ImmutableMap.<Class<?>, Object>of()); - - /** - * Returns an empty {@code ImmutableClassToInstanceMap}. - * - * @since 19.0 - */ - @SuppressWarnings("unchecked") - public static <B> ImmutableSubClassToInstanceMap<B> of() { - return (ImmutableSubClassToInstanceMap<B>)EMPTY; - } - - /** - * Returns an {@code ImmutableClassToInstanceMap} containing a single entry. - * - * @since 19.0 - */ - public static <B, T extends B> ImmutableSubClassToInstanceMap<B> of(Class<T> type, T value) { - ImmutableMap<Class<? extends B>, B> map = - ImmutableMap.<Class<? extends B>, B>of(type, value); - return new ImmutableSubClassToInstanceMap<B>(map); - } - - /** - * Returns a new builder. The generated builder is equivalent to the builder - * created by the {@link Builder} constructor. - */ - public static <B> Builder<B> builder() { - return new Builder<B>(); - } - - /** - * A builder for creating immutable class-to-instance maps. Example: - * - * <pre> - * { - * @code static final ImmutableClassToInstanceMap<Handler> HANDLERS = - * new ImmutableClassToInstanceMap.Builder<Handler>() - * .put(FooHandler.class, new FooHandler()) - * .put(BarHandler.class, new SubBarHandler()) - * .put(Handler.class, new QuuxHandler()).build(); - * } - * </pre> - * - * <p> - * After invoking {@link #build()} it is still possible to add more entries and build again. - * Thus each map generated by this builder will be a superset of any map generated before it. - * - * @since 2.0 - */ - public static final class Builder<B> { - private final ImmutableMap.Builder<Class<? extends B>, B> mapBuilder = ImmutableMap - .builder(); - - /** - * Associates {@code key} with {@code value} in the built map. Duplicate - * keys are not allowed, and will cause {@link #build} to fail. - */ - public <T extends B> Builder<B> put(Class<T> key, T value) { - mapBuilder.put(key, value); - return this; - } - - /** - * Associates all of {@code map's} keys and values in the built map. - * Duplicate keys are not allowed, and will cause {@link #build} to fail. - * - * @throws NullPointerException - * if any key or value in {@code map} is null - * @throws ClassCastException - * if any value is not an instance of the type - * specified by its key - */ - public <T extends B> Builder<B> putAll(Map<? extends Class<? extends T>, ? extends T> map) { - for(Entry<? extends Class<? extends T>, ? extends T> entry : map.entrySet()) { - Class<? extends T> type = entry.getKey(); - T value = entry.getValue(); - mapBuilder.put(type, cast(type, value)); - } - return this; - } - - private static <B, T extends B> T cast(Class<T> type, B value) { - return Primitives.wrap(type).cast(value); - } - - /** - * Returns a new immutable class-to-instance map containing the entries - * provided to this builder. - * - * @throws IllegalArgumentException - * if duplicate keys were added - */ - public ImmutableSubClassToInstanceMap<B> build() { - ImmutableMap<Class<? extends B>, B> map = mapBuilder.build(); - if(map.isEmpty()) { - return of(); - } - return new ImmutableSubClassToInstanceMap<B>(map); - } - } - - /** - * Returns an immutable map containing the same entries as {@code map}. If {@code map} somehow - * contains entries with duplicate keys (for example, if - * it is a {@code SortedMap} whose comparator is not <i>consistent with - * equals</i>), the results of this method are undefined. - * - * <p> - * <b>Note:</b> Despite what the method name suggests, if {@code map} is an - * {@code ImmutableClassToInstanceMap}, no copy will actually be performed. - * - * @throws NullPointerException - * if any key or value in {@code map} is null - * @throws ClassCastException - * if any value is not an instance of the type - * specified by its key - */ - public static <B, S extends B> ImmutableSubClassToInstanceMap<B> copyOf( - Map<? extends Class<? extends S>, ? extends S> map) { - if(map instanceof ImmutableSubClassToInstanceMap) { - @SuppressWarnings({"unchecked", "rawtypes"})// covariant casts safe (unmodifiable) - ImmutableSubClassToInstanceMap<B> cast = (ImmutableSubClassToInstanceMap)map; - return cast; - } - return new Builder<B>().putAll(map).build(); - } - - private final ImmutableMap<Class<? extends B>, B> delegate; - - private ImmutableSubClassToInstanceMap(ImmutableMap<Class<? extends B>, B> delegate) { - this.delegate = delegate; - } - - @Override - protected Map<Class<? extends B>, B> delegate() { - return delegate; - } - - @Override - @SuppressWarnings("unchecked") - // value could not get in if not a T - public - <T extends B> T getInstance(Class<T> type) { - return (T)delegate.get(checkNotNull(type)); - } - - /** - * Guaranteed to throw an exception and leave the map unmodified. - * - * @throws UnsupportedOperationException - * always - * @deprecated Unsupported operation. - */ - @Deprecated - @Override - public <T extends B> T putInstance(Class<T> type, T value) { - throw new UnsupportedOperationException(); - } - - Object readResolve() { - return isEmpty() ? of() : this; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/MutableSubClassToInstanceMap.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/MutableSubClassToInstanceMap.java deleted file mode 100644 index fcf9e206de51b501f6f96673190f8df96ff63371..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/MutableSubClassToInstanceMap.java +++ /dev/null @@ -1,96 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ - -package org.fortiss.af3.exploration.alg.guava; - -import static org.conqat.lib.commons.reflect.ReflectionUtils.performNearestClassLookup; - -import java.util.HashMap; -import java.util.Map; - -import com.google.common.collect.ForwardingMap; -import com.google.common.primitives.Primitives; - -/** - * - * Modifiable version of this {@link SubClassToInstanceMap}. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 8468901743C15A9207F471E7DA9C5982 - */ -// using writeReplace instead of standard serialization -public final class MutableSubClassToInstanceMap<B> extends ForwardingMap<Class<? extends B>, B> - implements SubClassToInstanceMap<B> { - - /** Backend map to hold the actual content. */ - protected Map<Class<? extends B>, B> delegate; - - /** - * Returns a new {@code MutableClassToInstanceMap} instance backed by a {@link HashMap} using - * the default initial capacity and load factor. - */ - public static <B> MutableSubClassToInstanceMap<B> create() { - return new MutableSubClassToInstanceMap<B>(new HashMap<Class<? extends B>, B>()); - } - - /** - * Returns a new {@code MutableClassToInstanceMap} instance backed by a given - * empty {@code backingMap}. The caller surrenders control of the backing map, - * and thus should not allow any direct references to it to remain accessible. - */ - public static <B> MutableSubClassToInstanceMap<B> create(Map<Class<? extends B>, B> backingMap) { - return new MutableSubClassToInstanceMap<B>(backingMap); - } - - /** Constructor. */ - private MutableSubClassToInstanceMap(Map<Class<? extends B>, B> delegate) { - this.delegate = delegate; - } - - /** {@inheritDoc} */ - @Override - public <T extends B> T putInstance(Class<T> type, T value) { - return cast(type, put(type, value)); - } - - /** {@inheritDoc} */ - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public <T extends B> T getInstance(Class<T> type) { - T retVal = cast(type, get(type)); - if(retVal == null) { - // The raw map cast is extremely ugly, but we ensure beforehand that the delegate map - // contains only types which we want. - return (T)performNearestClassLookup(type, (Map)delegate); - } - return retVal; - } - - /** Support method for using primitive types in this map. */ - private static <B, T extends B> T cast(Class<T> type, B value) { - return Primitives.wrap(type).cast(value); - } - - /** {@inheritDoc} */ - @Override - protected Map<Class<? extends B>, B> delegate() { - return delegate; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/SubClassToInstanceMap.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/SubClassToInstanceMap.java deleted file mode 100644 index d2f01e757afdb637cd06a202c5b13f470f849808..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/SubClassToInstanceMap.java +++ /dev/null @@ -1,35 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.guava; - -import com.google.common.collect.ClassToInstanceMap; - - -/** - * Same as the interface {@link ClassToInstanceMap} with the major difference that instance are not - * bound to specific types. Maps implementing this interface will also return a sub-type instance of - * a given type, namely the one which is the closest match in the type hierarchy. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: F1956060FD1344C790EFC4E91D9E93DE - */ -public interface SubClassToInstanceMap<B> extends ClassToInstanceMap<B> { - // Marker interface. -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/SubClassToInstanceMultiMap.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/SubClassToInstanceMultiMap.java deleted file mode 100644 index 4531fe5b274d7ad93c1e615d2a87c40a3cbc12bc..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/SubClassToInstanceMultiMap.java +++ /dev/null @@ -1,188 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.guava; - -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.performNearestClassLookup; - -import java.util.Collection; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multiset; - -/** - * {@link Multimap} whose keys are types. Further, this map performs a lookup in the type hierarchy - * if it does not contain the given type (key). The lookup is performed for {@code get} and - * {@code put} methods. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: CC647C9387B56DEBC3D623D45294571E - */ -public class SubClassToInstanceMultiMap<K, V> implements Multimap<Class<? extends K>, V> { - - /** Backend {@link Multimap} that holds the actual keys and values. */ - Multimap<Class<? extends K>, V> delegateMap = HashMultimap.create(); - - /** Bound up to which a lookup is performed. */ - final Class<? extends K> typeBound; - - /** - * Constructor. The type parameter defines how far (in the inheritance tree) a lookup of - * alternative keys shall be performed if {@code this} {@link Multimap} does not directly - * contain the given key. The given type bound is considered to be exclusive, i.e. if the lookup - * returns the same type as the bound, its result will be ignored. - * - * @param typeBound - * Type bound up to which a lookup for matching keys is performed if the backend map - * does not contain a given key directly. - */ - public SubClassToInstanceMultiMap(Class<? extends K> typeBound) { - super(); - this.typeBound = typeBound; - } - - /** {@inheritDoc} */ - @Override - public int size() { - return delegateMap.size(); - } - - /** {@inheritDoc} */ - @Override - public boolean isEmpty() { - return delegateMap.isEmpty(); - } - - /** {@inheritDoc} */ - @Override - public boolean containsKey(Object key) { - return delegateMap.containsKey(key); - } - - /** {@inheritDoc} */ - @Override - public boolean containsValue(Object value) { - return delegateMap.containsValue(value); - } - - /** {@inheritDoc} */ - @Override - public boolean containsEntry(Object key, Object value) { - return delegateMap.containsEntry(key, value); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public boolean put(Class<? extends K> key, V value) { - Class<?> existingKey = performNearestClassLookup(key, delegateMap.keySet()); - if(typeBound.isAssignableFrom(existingKey)) { - key = (Class<? extends K>)existingKey; - } - return delegateMap.put(key, value); - } - - /** {@inheritDoc} */ - @Override - public boolean remove(Object key, Object value) { - return delegateMap.remove(key, value); - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public boolean putAll(Class<? extends K> key, Iterable<? extends V> values) { - Class<?> existingKey = performNearestClassLookup(key, delegateMap.keySet()); - if(typeBound.isAssignableFrom(existingKey)) { - key = (Class<? extends K>)existingKey; - } - return delegateMap.putAll(key, values); - } - - /** {@inheritDoc} */ - @Override - public boolean putAll(Multimap<? extends Class<? extends K>, ? extends V> multimap) { - return delegateMap.putAll(multimap); - } - - /** {@inheritDoc} */ - @Override - public Collection<V> replaceValues(Class<? extends K> key, Iterable<? extends V> values) { - - return delegateMap.replaceValues(key, values); - } - - /** {@inheritDoc} */ - @Override - public Collection<V> removeAll(Object key) { - return delegateMap.removeAll(key); - } - - /** {@inheritDoc} */ - @Override - public void clear() { - delegateMap.clear(); - } - - /** {@inheritDoc} */ - @Override - public Collection<V> get(Class<? extends K> key) { - Collection<V> retVal = delegateMap.get(key); - if(retVal.isEmpty()) { - retVal = ExplorationAlgUtils.performNearestClassLookup(key, delegateMap); - } - return retVal; - } - - /** {@inheritDoc} */ - @Override - public Set<Class<? extends K>> keySet() { - return delegateMap.keySet(); - } - - /** {@inheritDoc} */ - @Override - public Multiset<Class<? extends K>> keys() { - return delegateMap.keys(); - } - - /** {@inheritDoc} */ - @Override - public Collection<V> values() { - return delegateMap.values(); - } - - /** {@inheritDoc} */ - @Override - public Collection<Entry<Class<? extends K>, V>> entries() { - return delegateMap.entries(); - } - - /** {@inheritDoc} */ - @Override - public Map<Class<? extends K>, Collection<V>> asMap() { - return delegateMap.asMap(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/TypedBiMap.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/TypedBiMap.java deleted file mode 100644 index b70e5ba0bd448e9c4adfa58321443df0efca225b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/TypedBiMap.java +++ /dev/null @@ -1,71 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.guava; - -import com.google.common.collect.BiMap; - -/** - * {@link BiMap} implementation whose keys and values are pairs of an object and an associated type. - * This {@link BiMap} is symmetric: It allows references of multiple keys to the same object iff - * the keys have different types. Hence, the 1:1 association between keys and values of - * {@link BiMap}s is preserved. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: BBD46247817C0DEFFDA8BB8F76B2215B - */ -public interface TypedBiMap<K, V> extends BiMap<TypedPair<K, V>, TypedPair<V, K>> { - - /** - * Returns the value from the map which is referenced by the given key and which has the - * given type. - * In a {@link TypedBiMap} a key may reference multiple values that have a different type. - * Please see {@link BiMap#get(Object)} for extended documentation on the put method. - * - * @param key - * identifies a set of values with their types. - * @param valType - * Type of the value to return. - * @return value uniquely identified by the key and the value type. - */ - V get(K key, Class<? extends V> valType); - - /** - * Adds the given {@code value} to {@code this} {@link TypedBiMap}. It is uniquely identified by - * the {@code key} and the type of the {@code value} ({@code valueType}). - * In order to allow an inverse lookup, the keys must be also associated with a type ( - * {@code keyType}). - * For more details about {@link BiMap}s, please consult {@link BiMap#put(Object, Object)} - * - * @param key - * The referencing key object. - * @param valType - * Type of the value. - * @param value - * The value object placed in the map. - * @param keyType - * Type of the key object. - * @return The old value uniquely identified by the {@code key} and the {@code valueType}. - */ - V put(K key, Class<? extends V> valType, V value, Class<? extends K> keyType); - - /** {@inheritDoc} */ - @Override - TypedBiMap<V, K> inverse(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/TypedPair.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/TypedPair.java deleted file mode 100644 index 62fa16b9c1dbfcf3be2b81a958fef41a404e90d7..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/guava/TypedPair.java +++ /dev/null @@ -1,50 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.guava; - -import org.conqat.lib.commons.collections.ImmutablePair; -import org.conqat.lib.commons.collections.Pair; - -/** - * {@link Pair} whose first entry is an actual object whereas the second entry defines its type. Its - * hash value is calculated from the hash codes of its entries. - * The main purpose of the {@link TypedPair} is to support {@link TypedBiMap}s. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: FF13396A37CA9800CBE10A9E71DCB868 - */ -public class TypedPair<S, T> extends Pair<S, Class<T>> { - - /** Constructor. */ - public TypedPair(ImmutablePair<S, Class<T>> p) { - super(p); - } - - /** Constructor. */ - public TypedPair(S first, Class<T> second) { - super(first, second); - } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - return first.hashCode() + second.hashCode(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/prototypes/PrototypeProvider.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/prototypes/PrototypeProvider.java deleted file mode 100644 index 52eed25e118de2225657b9fa7277036809ba63e0..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/prototypes/PrototypeProvider.java +++ /dev/null @@ -1,64 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: PrototypeProvider.java 3223 2016-07-06 14:11:30Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.prototypes; - -import static org.fortiss.af3.exploration.alg.util.DesignSpaceExplorationModelElementFactory.createDseSpecification; -import static org.fortiss.af3.exploration.alg.util.DesignSpaceExplorationModelElementFactory.createExplorationManager; - -import org.fortiss.af3.exploration.moea.model.DseSpecification; -import org.fortiss.af3.exploration.moea.model.ExplorationManager; -import org.fortiss.tooling.kernel.extension.base.PrototypeProviderBase; - -/** - * Prototype provider for design space exploration object. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3223 $ - * @ConQAT.Rating RED Hash: 8055A580C651768C5276701935502CED - */ -public class PrototypeProvider extends PrototypeProviderBase { - - /** Stores the category to display for these prototypes. */ - protected final static String CATEGORY_NAME = "Design Space Exploration"; - - /** {@inheritDoc} */ - @Override - protected void registerPrototypes() { - setupExplorationManagerPrototypes(); - setupDseSpecificationPrototypes(); - } - - /** - * Defines prototypes for {@link ExplorationManager}s which are used to manage DSE - * models. - */ - private void setupExplorationManagerPrototypes() { - registerPrimaryPrototype("Design Space Exploration", - createExplorationManager("Design Space Exploration"), CATEGORY_NAME); - } - - /** - * Defines prototypes for {@link DseSpecification}s which are used to create and configure - * DSE models. - */ - private void setupDseSpecificationPrototypes() { - registerPrimaryPrototype("DSE Specification", createDseSpecification("DSE Specification"), - CATEGORY_NAME); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/ExplorationEncodingMap.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/ExplorationEncodingMap.java deleted file mode 100644 index 6bb4bf09b9ee2964aba602f1d5973c70f7d6e2bb..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/ExplorationEncodingMap.java +++ /dev/null @@ -1,126 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExplorationEncodingMap.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service; - -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map.Entry; -import java.util.Set; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.CompositePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; - -/** - * Allows to capture the already created/decoded {@link Phenotype}s and pass them to their successor - * creators/decoders as a flat map that associates a {@link Phenotype}s type with its instance. - * Using a {@link CompositePhenotype} for this job allows to "protect" the internal map from - * unintended read/write operations. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: B3D01F49934EBEC4E69A3DED907F8E47 - */ -public class ExplorationEncodingMap<T extends IExplorationEncoding> implements - Iterable<Entry<Class<? extends T>, T>> { - - /** References the {@link SystemModelAdapter} that provides an abstraction of the input models. */ - protected SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter; - - /** - * Map which correlates the {@link IExplorationEncoding} classes with their corresponding - * {@link IExplorationEncoding}s. - */ - protected LinkedHashMap<Class<? extends T>, T> encodings = new LinkedHashMap<>(); - - /** Constructor. */ - public ExplorationEncodingMap(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - this.systemModelAdapter = systemModelAdapter; - } - - /** - * Returns whether {@code this} {@link ExplorationEncodingMap} contains an encoding that is - * assignable from the given encoding type. - */ - public boolean containsEncoding(Class<? extends T> encodingType) { - if(getEncodingInternal(encodingType) != null) { - return true; - } - return false; - } - - /** - * Returns the {@link IExplorationEncoding} of the given type. If no - * {@link IExplorationEncoding} of the given type - * can be found, {@code null} is returned. - */ - public <E extends T> E getEncoding(Class<E> subGenotypeClass) { - return getEncodingInternal(subGenotypeClass); - } - - /** Internal helper method to retrieve a sub-{@link IExplorationEncoding} by its type hierarchy. */ - protected <E extends IExplorationEncoding> E getEncodingInternal(Class<E> encodingType) { - for(Entry<Class<? extends T>, T> composablePheno : encodings.entrySet()) { - if(encodingType.isAssignableFrom(composablePheno.getKey())) { - @SuppressWarnings("unchecked") E retPhenotype = (E)composablePheno.getValue(); - return retPhenotype; - } - } - return null; - } - - /** - * Adds the {@link IExplorationEncoding} to {@code this} map and uses the given type as its - * identifier. - */ - public void putEncoding(Class<? extends T> subSeqClass, T subSeqPheno) { - encodings.put(subSeqClass, subSeqPheno); - } - - /** {@inheritDoc} */ - @Override - public Iterator<Entry<Class<? extends T>, T>> iterator() { - return encodings.entrySet().iterator(); - } - - /** - * Returns the set of all identifiers that are related with the {@link IExplorationEncoding}s in - * {@code this} map. - */ - public Set<Class<? extends T>> keySet() { - return encodings.keySet(); - } - - /** - * Adds all entries of the given {@link ExplorationEncodingMap} to {@code this} - * {@link ExplorationEncodingMap}. - */ - public void addAll(ExplorationEncodingMap<T> addMap) { - addMap.forEach(e -> encodings.put(e.getKey(), e.getValue())); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - String ownName = getClass().getSimpleName() + ": \n"; - StringBuilder strBuilder = new StringBuilder(ownName); - encodings.keySet().forEach(p -> strBuilder.append("-> " + p.getSimpleName() + "\n")); - return strBuilder.toString(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/ExplorationService.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/ExplorationService.java deleted file mode 100644 index 819243fe2fb8326e17bb691e1650c5f221be9be2..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/ExplorationService.java +++ /dev/null @@ -1,111 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExplorationService.java 3404 2016-08-26 15:01:08Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service; - -import java.util.HashMap; -import java.util.Map; - -import org.fortiss.af3.exploration.alg.ExplorationAlgActivator; -import org.fortiss.af3.exploration.alg.exception.ExplorationServiceException; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; - -/** - * The {@link ExplorationService} singleton manages all services offered by the - * org.fortiss.af3.exploration.alg plugin. - * - * Service instances are retrieved by calling {@link #getService(Class)} with the type of the - * desired {@link IExplorationService}. If the {@link IExplorationService} has not been instantiated - * yet, this step is automatically performed by {@code this} {@link ExplorationService} manager. - * - * <p> - * - * <b>NOTE:<b> Only one service instance can be registered for one service type. If it is desired to - * exchange the service implementations during runtime, - * {@link #replaceService(Class, IExplorationService)} must be used. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3404 $ - * @ConQAT.Rating RED Hash: 7247E5017491A17EC3514FF9A9B06BA5 - */ -public class ExplorationService { - - /** Holds the instance of the transformation service. */ - private volatile static ExplorationService INSTANCE; - - /** Associates {@link IExplorationService} types with their singleton instances. */ - private Map<Class<? extends IExplorationService<?>>, IExplorationService<?>> services = - new HashMap<>(); - - /** Constructor. */ - private ExplorationService() { - // Prevent direct instantiation. - } - - /** The instance (singleton) of the ExplorationTransformationService. */ - public static synchronized ExplorationService getInstance() { - if(INSTANCE == null) { - INSTANCE = new ExplorationService(); - } - return INSTANCE; - } - - /** - * Returns the service instance that is associated with the given {@code serviceType}. - * - * @param serviceType - * Type of the service. - * @return The service's instance registered for the given service type. - */ - public static <T extends IExplorationService<?>> T getService(Class<T> serviceType) { - @SuppressWarnings("unchecked") T service = (T)getInstance().services.get(serviceType); - if(service == null) { - BundleContext ctx = - FrameworkUtil.getBundle(ExplorationAlgActivator.class).getBundleContext(); - service = ctx.getService(ctx.getServiceReference(serviceType)); - getInstance().services.put(serviceType, service); - } - return service; - } - - /** - * Replaces the association of the given {@code serviceType} with its existing service instance - * with the given instance. If no association exists already, the <i>new</i> association is - * registered anyways. - * - * @param serviceType - * Type of the service. - * @param serviceInstance - * The sevice's replacement instance. - * @return The previously registered service instance, or {@code null} if none exists. - * @throws ExplorationServiceException - * If the OSGI service holder throws an exception. - */ - public static <T extends IExplorationService<?>, S extends T, U extends T> S replaceService( - Class<T> serviceType, U serviceInstance) throws ExplorationServiceException { - @SuppressWarnings("unchecked") S oldInstance = (S)getInstance().services.get(serviceType); - // Decrease the service use by ungetting again. - BundleContext ctx = - FrameworkUtil.getBundle(ExplorationAlgActivator.class).getBundleContext(); - ctx.ungetService(ctx.getServiceReference(oldInstance.getClass())); - - getInstance().services.put(serviceType, serviceInstance); - return oldInstance; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationConstraintTransformationService.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationConstraintTransformationService.java deleted file mode 100644 index a14e1a3466cf1b228296add94058db06ade81e33..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationConstraintTransformationService.java +++ /dev/null @@ -1,58 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.GenericConstraint; - -/** - * This service transforms a collection of given {@link GenericConstraint}s to - * {@link ExplorationConstraint}s that can be processed internally by the DSE, e.g. in operators, - * such that the DSE's efficiency can be increased. It does so by providing registered - * {@link IExplorationContraintTransformationModule}s with the {@link GenericConstraint}s for which - * the modules were registered and collecting the transformation results of each module. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 7A75CD30C8AA2AD3ABAC06C73054E9BD - */ -public interface IExplorationConstraintTransformationService extends - IExplorationService<IExplorationContraintTransformationModule<?>> { - - // TODO: Should we use a separate marker for external Constrains? - /** - * Returns the collection of transformed {@link ExplorationConstraint}s produced by the - * registered {@link IExplorationContraintTransformationModule}s. - * - * @param systemModelAdapter - * Abstraction of the input models. - * @param genericConstraints - * Collection of constraints possibly pointing to external constraint models. - * @return Collection of transformed {@link ExplorationConstraint}s. - * @throws ExplorationException - * if any of the registered transformation fails. - */ - Collection<ExplorationConstraint<?>> getTransformedConstraints( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - Collection<GenericConstraint<?>> genericConstraints) throws ExplorationException; -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationContraintTransformationModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationContraintTransformationModule.java deleted file mode 100644 index fd56a89ed60dbf13660f3b45a6622e4264e57663..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationContraintTransformationModule.java +++ /dev/null @@ -1,56 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.GenericConstraint; -import org.fortiss.tooling.kernel.service.base.IEObjectAware; - -/** - * Module that transforms constraints of an external constraint model into - * {@link ExplorationConstraint}s that are directly supported by the DSE. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 72A8AB784EE942A8248900D95E541CD3 - */ -public interface IExplorationContraintTransformationModule<T extends GenericConstraint<?>> extends - IEObjectAware<T>, IExplorationModule { - - /** - * Transforms constraints encoded in the given {@link GenericConstraint} to - * {@link ExplorationConstraint}s that are directly supported by the DSE. The resulting - * constraints may be used to increase the performance of the DSE. - * - * @param systemModelAdapter - * Abstraction of the input models. - * @param currentConstraint - * Constraint to be transformed (input). - * @return Possibly empty collection of transformed {@link ExplorationConstraint}s. - * @throws ExplorationException - * If the transformation fails for any reason. - */ - Collection<ExplorationConstraint<?>> transformConstraint( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - GenericConstraint<?> currentConstraint) throws ExplorationException; -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationEncoding.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationEncoding.java deleted file mode 100644 index 41a4c00397972a1adc4a1831d49e7bb80bb7671f..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationEncoding.java +++ /dev/null @@ -1,32 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IExplorationEncoding.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service; - -/** - * Marker interface for Encodings. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: D4EAFD5767642D6B5B7CFA5451C5587F - */ -// TODO: evaluate whether it would be better to let the geno- and phenotype inherit from an -// "Encoding". -public interface IExplorationEncoding { - // Marker interface. -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationEvaluatationService.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationEvaluatationService.java deleted file mode 100644 index 10a8dc529cf98affac1d9379b66ae9e6a1202648..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationEvaluatationService.java +++ /dev/null @@ -1,48 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service; - -import java.util.Collection; -import java.util.Set; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate.ComposableEvaluator; - -/** - * {@link IExplorationService} interface to register evaluators for the DSE. See - * {@link IExplorationTargetEvaluator} for the interface that needs to be implemented by concrete - * evaluator modules. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: F61CDC13323C4ADBE8A39612128EDCCA - */ -public interface IExplorationEvaluatationService<T extends IExplorationModule> extends - IExplorationService<T> { - - /** - * Returns the collection of input model types that are required to execute the given set of - * {@link ComposableEvaluator}s. The models corresponding to these types can be retrieved via - * the {@link IExplorationTransformationService}. - * - * @param evaluators - * Set of evaluators that shall be executed. - */ - Collection<Class<?>> getRequiredTransformedModels( - Set<IExplorationTargetEvaluator<?, ?, ?>> evaluators); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationModule.java deleted file mode 100644 index be9aaa416c18435cae7853c073bec0ab1307c50a..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationModule.java +++ /dev/null @@ -1,31 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service; - -import org.fortiss.tooling.kernel.introspection.IIntrospectionItem; - -/** - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: AAA680418C0CCCB395ACA156289AB2D0 - */ -public interface IExplorationModule extends IIntrospectionItem { - // Marker interface. -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationRepairService.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationRepairService.java deleted file mode 100644 index 222a16c26a0d7bfee1aa6038089a7d53e1685049..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationRepairService.java +++ /dev/null @@ -1,51 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service; - -import java.util.List; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.opt4j.core.Genotype; - -/** - * Service that manages repair functions that can be applied to {@link Genotype}s. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 9EB85316A5C5B235C9AB18DB47830ADB - */ -public interface IExplorationRepairService extends IExplorationService<IRepairModule<?>> { - - /** - * Returns the collection of {@link IRepairModule} instances that shall be applied to the given - * {@link Genotype}. - * The {@link IRepairModule}s shall be executed in the given order. - * - * @param genotype - * {@link Genotype} that could be repaired. - * @param systemModelAdapter - * current {@link SystemModelAdapter} of the DSE. - * @return List of applicable {@link IRepairModule}s (in order). - * @throws ExplorationException - * if any applicable {@link IRepairModule} could not be instantiated. - */ - <T extends Genotype> List<IRepairModule<T>> getRepairFunctionsOf(T genotype, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws ExplorationException; -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationService.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationService.java deleted file mode 100644 index 0f0d8d350d495c3f5ef9292820627030c4b4c680..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationService.java +++ /dev/null @@ -1,46 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IExplorationService.java 3404 2016-08-26 15:01:08Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service; - -import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService; - -/** - * Interface for services provided by the org.fortiss.af3.exploration.alg plugin. - * - * Each service must implement the given startup routines. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3404 $ - * @ConQAT.Rating RED Hash: 2E9D50738CE2D45BD1160C9951F97B11 - */ -public interface IExplorationService<T extends IExplorationModule> extends - IIntrospectiveKernelService { - - /** - * Initialization routine of {@link IExplorationService}s which is the first method to be - * launched within services. - */ - void initializeService(); - - /** - * Startup routine of {@link IExplorationEncoding}s which is triggered after <i>all</i> services - * have been initialized. - */ - void startService(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationTargetEvaluator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationTargetEvaluator.java deleted file mode 100644 index 0c06ae3d7add5e40c681975a1814365158c50279..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationTargetEvaluator.java +++ /dev/null @@ -1,84 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service; - -import java.util.Collection; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate.ComposableEvaluator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.tooling.kernel.service.base.IEObjectAware; -import org.opt4j.core.Value; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * Interface to be implemented by {@link IExplorationModule}s that perform evaluations of - * individuals (= candidate solutions). These are generated during the execution of the DSE. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: A008A0C188C912DCB1A397CCDB4EFCD9 - */ -public interface IExplorationTargetEvaluator<P, RT, S extends ExplorationTarget<RT>> extends - IEObjectAware<S>, IExplorationModule { - - /** - * Evaluates a phenotype w.r.t. a given objective dimension - * - * @param transformedModels - */ - public Value<?> evaluateGoal(P phenotype, FlatPhenotypeMap<Phenotype> phenotypeTypeMap, - ClassToInstanceMap<EObject> transformedModels) throws Exception; - - /** Validate if objective has been correctly specified. */ - public boolean validateInputs() throws Exception; - - /** - * Returns the set of input types (classes) which are required for the enclosed - * {@link ComposableEvaluator}. - */ - Collection<Class<?>> getRequiredInputTypes(); - - /** Returns the phenotype type for which this evaluator is registered. */ - // Only needed until the automatic model transformation is finished - Class<?> getPrimaryInputType(); - - /** - * Creates an instance of {@code this} {@link IExplorationTargetEvaluator}. The - * {@code systemModelAdapter} and the {@code explorationTarget} are passed from the DSE - * framework. - * - * @param systemModelAdapter - * Internal representation of the base models. - * @param explorationTarget - * Specifies the concrete exploration target including the parameters. - * @return A new instance of {@code this} {@link IExplorationTargetEvaluator}. - * @throws InstantiationException - * If the instantiation of a new {@link IExplorationTargetEvaluator} fails. - * @throws Exception - * if the input validation fails. - */ - IExplorationTargetEvaluator<P, RT, S> createEvaluator( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, S explorationTarget) - throws InstantiationException, Exception; -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationTransformationService.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationTransformationService.java deleted file mode 100644 index e0a948929fb6eb1c64fe7673c16abc09a261537a..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IExplorationTransformationService.java +++ /dev/null @@ -1,179 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: IExplorationTransformationService.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service; - -import java.util.Collection; - -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.FlatPhenotypeMap; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationStrategy; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.internal.ExplorationTransformationService; -import org.fortiss.af3.exploration.moea.model.solutions.SingleExplorationSolutionMap; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; - -import com.google.common.collect.ClassToInstanceMap; - -/** - * {@link IExplorationService} interface of the {@link IExplorationTransformationService}. - * It enables users to obtain transformed EMF models of a given type from a provided (candidate) - * solution calculated by the DSE and the respective base models. - * A transformed model is returned if: <li>The provided input (base models and candidate solution - * encodings) match the required ones.</li> <li>All required {@link ITransformationModule}s are - * present.</li> <li>None of the executed {@link ITransformationModule}s fails.</li> - * <p> - * The {@link IExplorationTransformationService} is organized by {@link ITransformationStrategy}s - * and {@link ITransformationModule}s. The modules encapsulate isolated steps in a transformation - * process that are defined in the strategy and the {@link ITransformationModule} interface. The - * strategies link the {@link ITransformationModule}s and are responsible for the correct order of - * execution. - * <p> - * The transformation process (--> strategy) is organized into sub-Modules encapsulating single - * steps. Each of the sub-Modules may define further submodules that can be also - * {@link ITransformationStrategy}s (Composite pattern). - * <p> - * The {@link IExplorationTransformationService} differs between two context from which the - * transformation has been triggered and which must be given. If the transformation is triggered by - * a {@link TransformationContext#DSE_INTERNAL} context, the resulting model will be "floating". - * Otherwise, if the transformation is launched with a {@link TransformationContext#EXPORT} context, - * the resulting model will be injected in the corresponding AF3 project. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: 5F57C933AAA212E14E536D5137B83A63 - */ -public interface IExplorationTransformationService extends - IExplorationService<ITransformationModule<?>> { - /** - * Enum describing the context from which the transformation is requested. It is used to limit - * the number of transformations to the required minimum to obtain a better DSE performance. - */ - public static enum TransformationContext { - /** "Full" transformation, including virtual links. */ - EXPORT, - /** "Minimal" transformation, e.g. for an export towards the SafetyComplianceChecker. */ - DSE_INTERNAL - } - - /** - * Returns whether any registered {@link ITransformationStrategy} can transforms its input to - * the given model type. - * - * @param transformedModelType - * output model type. - * @return if a model of the given type can be produced by the - * {@link IExplorationTransformationService}. - */ - boolean canTransformOutputType(Class<?> transformedModelType); - - /** - * Generates models of the requested types ({@code transformedModelTypes}) using the set of - * solution models contained in the given {@link SingleExplorationSolutionMap} and the - * collection of given {@code baseModel}s. - * - * @param solution - * {@link SingleExplorationSolutionMap} containing the solution models. - * @param baseModels - * EMF models used as a basis to generate the transformed model. - * @param transformedModelTypes - * Type of the transformed models that shall be returned. - * @return The transformed models which were requested. - * @throws Exception - * If no {@link ITransformationModule} has been registered which can produce the - * demanded model, or if some required solution encoding was not passed. - */ - <U extends EObject, S extends EObject> ClassToInstanceMap<U> - getTransformedModels(TransformationContext context, ITopLevelElement modelContext, - SingleExplorationSolutionMap solution, SubClassToInstanceMap<S> baseModels, - Collection<Class<? extends EObject>> transformedModelTypes, - String transformedModelName) throws Exception; - - /** - * Generates a model of the requested type ({@code transformedModelType}) using the set of - * solution models contained in the given {@link SingleExplorationSolutionMap} and the - * collection of given {@code baseModel}s. - * - * @param solution - * {@link SingleExplorationSolutionMap} containing the solution models. - * @param baseModels - * EMF models used as a basis to generate the transformed model. - * @param transformedModelType - * Type of the transformed model. - * @return The transformed model. - * @throws Exception - * If no {@link ITransformationModule} has been registered which can produce the - * demanded model, or if some required solution encoding was not passed. - */ - <U extends EObject, S extends EObject> U getTransformedModel(TransformationContext context, - ITopLevelElement modelContext, SingleExplorationSolutionMap solution, - SubClassToInstanceMap<S> baseModels, Class<U> transformedModelType, - String transformedModelName) throws Exception; - - /** - * Generates models of the requested types ({@code transformedModelTypes}) using the set of - * solution models contained in the given {@link SingleExplorationSolutionMap} and the - * collection of given {@code baseModel}s. - * - * @param encodings - * {@link SingleExplorationSolutionMap} containing the solution models. - * @param baseModels - * EMF models used as a basis to generate the transformed model. - * @param transformedModelTypes - * Type of the transformed models that shall be returned. - * @return The transformed models which were requested. - * @throws Exception - * If no {@link ITransformationModule} has been registered which can produce the - * demanded model, or if some required solution encoding was not passed. - */ - <U extends EObject, S extends EObject> ClassToInstanceMap<U> - getTransformedModels(TransformationContext context, ITopLevelElement modelContext, - ExplorationEncodingMap<IExplorationEncoding> encodings, - SubClassToInstanceMap<S> baseModels, - Collection<Class<? extends EObject>> transformedModelTypes, - String transformedModelName) throws Exception; - - /** - * Generates a model of the requested type ({@code transformedModelType}) using the set of - * {@link Phenotype}s contained in the given {@link FlatPhenotypeMap} and the - * collection of given {@code baseModel}s. - * - * @param encodings - * {@link SingleExplorationSolutionMap} containing the solution models. - * @param baseModels - * EMF models used as a basis to generate the transformed model. - * @param transformedModelType - * Type of the transformed model. - * @return The transformed model. - * @throws Exception - * If no {@link ITransformationModule} has been registered which can produce the - * demanded model, or if some required solution encoding was not passed. - */ - <U extends EObject, S extends EObject> U getTransformedModel(TransformationContext context, - ITopLevelElement modelContext, ExplorationEncodingMap<IExplorationEncoding> encodings, - SubClassToInstanceMap<S> baseModels, Class<U> transformedModelType, - String transformedModelName) throws Exception; - - /** - * Resets the lists of {@link ITransformationModule}s registered at {@code this} - * {@link ExplorationTransformationService}. - */ - void resetRegisteredModules(); -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IRepairModule.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IRepairModule.java deleted file mode 100644 index 7ea2e8ae0f49d3ea3246982fef2346b159443e78..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/IRepairModule.java +++ /dev/null @@ -1,70 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service; - -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.model.ExplorationSolution; -import org.fortiss.tooling.kernel.service.base.IObjectAware; -import org.opt4j.core.Genotype; -import org.opt4j.core.Value; - -/** - * {@link IRepairModule}s are used to "repair" {@link Genotype}s based on the information found in - * the {@link Genotype} encoding itself and/or the evaluation results given as an - * {@link ExplorationSolution}. - * <p> - * The ability to "repair" {@link Genotype}s allows to increase the efficiency of genetic algorithms - * by injecting domain-/problem-specific knowledge into the optimization process. It allows to - * "correct" parts of the passed {@link Genotype} which cause obvious constraint violations. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 634DBC7336F4BF234743B53311DC9061 - */ -public interface IRepairModule<T extends Genotype> extends IObjectAware<T>, IExplorationModule { - - /** - * Indicates whether a given {@link Genotype} should be repaired based on an evaluation of the - * given {@link Genotype} and the set of passed evaluation {@link Value}s. - * - * @param genotype - * {@link Genotype} to be repaired. - * @param evaluations - * Set of evaluation results. - * @return Whether repairing the {@link Genotype} is indicated. - */ - boolean needsRepair(Genotype genotype, Collection<Value<?>> evaluations); - - /** - * Performs the repair operation on the given {@link Genotype}. The concrete repair operation - * that shall be applied are derived from the {@link Genotype} itself and the passed evaluation - * results. - * - * @param genotype - * {@link Genotype} to be repaired. - * @param evaluations - * Evaluation results. - * @throws ExplorationException - * if any repair operation causes a serious error to the overall DSE process. - */ - void repairGenotype(Genotype genotype, Collection<Value<?>> evaluations) - throws ExplorationException; -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationConstraintTransformationService.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationConstraintTransformationService.java deleted file mode 100644 index 40c9dcbe0706264664bc60c6443d1bed513ee3b7..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationConstraintTransformationService.java +++ /dev/null @@ -1,121 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service.internal; - -import java.util.ArrayList; -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.alg.service.IExplorationConstraintTransformationService; -import org.fortiss.af3.exploration.alg.service.IExplorationContraintTransformationModule; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.GenericConstraint; -import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase; - -/** - * Provides the {@link IExplorationConstraintTransformationService}. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: E351D0E84E76CE9A068A708652287EF2 - */ -public class ExplorationConstraintTransformationService extends - EObjectAwareServiceBase<IExplorationContraintTransformationModule<?>> implements - IExplorationConstraintTransformationService { - - /** The evaluator provider extension point ID. */ - private static final String EXTENSION_POINT_NAME = - "org.fortiss.af3.exploration.alg.constraintTransformationModule"; - - /** The evaluator provider configuration element name. */ - private static final String CONFIGURATION_ELEMENT_NAME = "constraintTransformationModule"; - - /** The evaluator class attribute name. */ - private static final String HANDLER_CLASS_ATTRIBUTE_NAME = "module"; - - /** Holds the instance of the evaluation service. */ - private volatile static ExplorationConstraintTransformationService INSTANCE; - - /** The instance (singleton) of the ExplorationTransformationService. */ - public static synchronized ExplorationConstraintTransformationService getInstance() { - if(INSTANCE == null) { - INSTANCE = new ExplorationConstraintTransformationService(); - } - return INSTANCE; - } - - /** Constructor. */ - private ExplorationConstraintTransformationService() { - // Prevent direct instantiation. - } - - /** {@inheritDoc} */ - @Override - public String getIntrospectionDescription() { - // TODO Auto-generated method stub - return null; - } - - /** {@inheritDoc} */ - @Override - public String getIntrospectionLabel() { - // TODO Auto-generated method stub - return null; - } - - /** - * {@inheritDoc} - * - * @throws ExplorationException - */ - @Override - public Collection<ExplorationConstraint<?>> getTransformedConstraints( - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - Collection<GenericConstraint<?>> genericConstraints) throws ExplorationException { - Collection<ExplorationConstraint<?>> transformedConstraints = new ArrayList<>(); - for(GenericConstraint<?> currentConstraint : genericConstraints) { - for(IExplorationContraintTransformationModule<?> module : getRegisteredHandlers(currentConstraint - .getClass())) { - transformedConstraints.addAll(module.transformConstraint(systemModelAdapter, - currentConstraint)); - } - } - - return transformedConstraints; - } - - /** {@inheritDoc} */ - @Override - protected String getExtensionPointName() { - return EXTENSION_POINT_NAME; - } - - /** {@inheritDoc} */ - @Override - protected String getConfigurationElementName() { - return CONFIGURATION_ELEMENT_NAME; - } - - /** {@inheritDoc} */ - @Override - protected String getHandlerClassAttribute() { - return HANDLER_CLASS_ATTRIBUTE_NAME; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationEvaluationService.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationEvaluationService.java deleted file mode 100644 index f1d35de2564a3a6182d95c179f94e95d2981f876..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationEvaluationService.java +++ /dev/null @@ -1,251 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service.internal; - -import static org.fortiss.af3.exploration.alg.service.ExplorationService.getService; -import static org.fortiss.tooling.common.util.LambdaUtils.filterSet; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.evaluate.ComposableEvaluator; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem.EvaluatorWrapper; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationServiceException; -import org.fortiss.af3.exploration.alg.service.IExplorationEvaluatationService; -import org.fortiss.af3.exploration.alg.service.IExplorationService; -import org.fortiss.af3.exploration.alg.service.IExplorationTargetEvaluator; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.MOExplorationObjective; -import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem; -import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase; -import org.opt4j.core.Genotype; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -/** - * Implementation of the {@link IExplorationEvaluatationService} which handles the instantiation of - * the Evaluators based on the Exploration target. The evaluators are registered as extensions. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: FABD9E6D5F88ECF5BF57EDC9334DF996 - */ -public class ExplorationEvaluationService<T extends IExplorationTargetEvaluator<?, ?, ?>> extends - EObjectAwareServiceBase<T> implements IExplorationEvaluatationService<T> { - - /** The evaluator provider extension point ID. */ - private static final String EXTENSION_POINT_NAME = "org.fortiss.af3.exploration.alg.evaluator"; - - /** The evaluator provider configuration element name. */ - private static final String CONFIGURATION_ELEMENT_NAME = "evaluator"; - - /** The evaluator class attribute name. */ - private static final String HANDLER_CLASS_ATTRIBUTE_NAME = "module"; - - /** Holds the instance of the evaluation service. */ - private volatile static ExplorationEvaluationService<?> INSTANCE; - - /** - * Associates the registered {@link ComposableEvaluator}s with their required types from the - * {@link IExplorationTransformationService} - */ - private Multimap<Class<IExplorationTargetEvaluator<?, ?, ?>>, Class<?>> requiredTransformedModels = - HashMultimap.create(); - - /** Constructor. */ - private ExplorationEvaluationService() { - // Prevent direct instantiation. - } - - /** The instance (singleton) of the ExplorationTransformationService. */ - @SuppressWarnings("rawtypes") - public static synchronized ExplorationEvaluationService<?> getInstance() { - if(INSTANCE == null) { - INSTANCE = new ExplorationEvaluationService(); - } - return INSTANCE; - } - - /** {@inheritDoc} */ - @Override - public String getIntrospectionDescription() { - return "This services enables the registration of evaluators (quantifiers) to the DSE."; - } - - /** {@inheritDoc} */ - @Override - public String getIntrospectionLabel() { - return "Evaluator Service"; - } - - /** {@inheritDoc} */ - @Override - public boolean showInIntrospectionNavigation() { - return true; - } - - /** {@inheritDoc} */ - @Override - public IIntrospectionDetailsItem getDetailsItem() { - return null; - } - - /** {@inheritDoc} */ - // NB: Each {@link ExplorationTarget} may have only _ONE_ {@link Evaluator}. - @Override - protected boolean requiresUniqueHandler() { - return true; - } - - /** {@inheritDoc} */ - @Override - protected String getExtensionPointName() { - return EXTENSION_POINT_NAME; - } - - /** {@inheritDoc} */ - @Override - protected String getConfigurationElementName() { - return CONFIGURATION_ELEMENT_NAME; - } - - /** {@inheritDoc} */ - @Override - protected String getHandlerClassAttribute() { - return HANDLER_CLASS_ATTRIBUTE_NAME; - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public Collection<Class<?>> getRequiredTransformedModels( - Set<IExplorationTargetEvaluator<?, ?, ?>> evaluators) { - Set<Class<?>> retVal = new HashSet<>(); - evaluators.forEach(e -> retVal.addAll(requiredTransformedModels - .get((Class<IExplorationTargetEvaluator<?, ?, ?>>)e.getClass()))); - return retVal; - } - - /** {@inheritDoc} */ - @Override - public void startService() { - super.startService(); - - Collection<Class<?>> allRequiredInputs = new HashSet<>(); - - for(IExplorationTargetEvaluator<?, ?, ?> evaluator : getInstance().getAllHandlers()) { - allRequiredInputs.addAll(evaluator.getRequiredInputTypes()); - // @CodeFormatterOff - Collection<Class<?>> curNonPhenotypeInputTypes = - filterSet(allRequiredInputs, - t -> !(ComposablePhenotype.class.isAssignableFrom(t) - || Genotype.class.isAssignableFrom(t))); - // @CodeFormatterOn - - // TODO: check also if the phenotypes exist. - try { - checkInputConsistency(curNonPhenotypeInputTypes); - } catch(ExplorationServiceException e) { - throw new RuntimeException("Error starting the ExplorationEvaluationService.", e); - } - - // Here, we assume that all *checked* (see above) remaining models must be provided by - // the transformation service. - @SuppressWarnings("unchecked") Class<IExplorationTargetEvaluator<?, ?, ?>> evaluatorType = - (Class<IExplorationTargetEvaluator<?, ?, ?>>)evaluator.getClass(); - requiredTransformedModels.putAll(evaluatorType, curNonPhenotypeInputTypes); - } - } - - /** - * Returns whether the given collection of non-Phenotype types can be obtained by the - * {@link IExplorationTransformationService}. - */ - @SuppressWarnings("unchecked") - private void checkInputConsistency(Collection<Class<?>> requiredNonPhenoInputs) - throws ExplorationServiceException { - for(Class<?> curInputType : requiredNonPhenoInputs) { - if(!getService(IExplorationTransformationService.class).canTransformOutputType( - curInputType)) { - throw new ExplorationServiceException( - (Class<? extends IExplorationService<?>>)IExplorationEvaluatationService.class, - "The required input type " + curInputType.getSimpleName() + - " is not a Phenotype, nor can it be produced by the" + - " IExplorationTransformationService. Please check the required" + - " types and/or the registration of the needed ITransformationStrategies."); - } - } - } - - /** - * Creates an {@link EvaluatorWrapper} for the given {@link ExplorationTarget} if a handler has - * been registered for it. - * - * @param systemModelAdapter - * {@link SystemModelAdapter} abstracting the base models (e.g., technical - * architecture). - * @param explorationTarget - * {@link ExplorationTarget} to create an {@link EvaluatorWrapper} for. - * @return The instantiated {@link EvaluatorWrapper}. - * @throws Exception - * if some required input is missing. - * @throws InstantiationException - * if the construction of the evaluator fails due to some unknown reason. - */ - public <P, RT, ET extends ExplorationTarget<RT>> EvaluatorWrapper<P, RT, ET> - createEvalWrapperFor(SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter, - ET explorationTarget) throws InstantiationException, Exception { - @SuppressWarnings("unchecked") Collection<IExplorationTargetEvaluator<P, RT, ET>> evaluatorHandlers = - (Collection<IExplorationTargetEvaluator<P, RT, ET>>)getInstance() - .getRegisteredHandlers(explorationTarget.getClass()); - if(evaluatorHandlers != null && evaluatorHandlers.size() > 0) { - // assert (evaluatorHandlers.size() > 0) : "No evaluator registered for " + - // explorationTarget.getClass().getSimpleName() + "."; - assert (evaluatorHandlers.size() <= 1) : "Multiple evaluators registered for " + - explorationTarget.getClass().getSimpleName() + "."; - - // The "template" evaluator. - IExplorationTargetEvaluator<P, RT, ET> evaluatorHandler = - evaluatorHandlers.stream().findAny().get(); - // The actual instance used for evaluation. - IExplorationTargetEvaluator<P, RT, ET> evaluator = - evaluatorHandler.createEvaluator(systemModelAdapter, explorationTarget); - - @SuppressWarnings("unchecked") Class<P> primaryInputType = - (Class<P>)evaluatorHandler.getPrimaryInputType(); - assert (Phenotype.class.isAssignableFrom(primaryInputType)) : "The primary input type is not a genotype. Only Genotypes are currently supported."; - - int priority = 9999; - if(explorationTarget instanceof MOExplorationObjective<?>) { - priority = ((MOExplorationObjective<?>)explorationTarget).getPriority(); - } - - return new EvaluatorWrapper<P, RT, ET>(explorationTarget, evaluator, priority, - primaryInputType); - } - - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationRepairService.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationRepairService.java deleted file mode 100644 index 206078226ca94e43b7b605381ea92b0efd367db7..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationRepairService.java +++ /dev/null @@ -1,132 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service.internal; - -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.castToRawColl; - -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.exception.ExplorationException; -import org.fortiss.af3.exploration.alg.service.IExplorationRepairService; -import org.fortiss.af3.exploration.alg.service.IRepairModule; -import org.fortiss.tooling.kernel.service.base.ObjectAwareServiceBase; -import org.opt4j.core.Genotype; - -/** - * Implementation of the {@link IExplorationRepairService}. - * It constructs and returns {@link IRepairModule} instances when the relveant fodules for a given - * {@link Genotype} are queried. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 99E4B395ED3A42C94B39E5A078C714D5 - */ -public class ExplorationRepairService extends ObjectAwareServiceBase<IRepairModule<?>> implements - IExplorationRepairService { - - /** The evaluator provider extension point ID. */ - private static final String EXTENSION_POINT_NAME = - "org.fortiss.af3.exploration.alg.repairModule"; - - /** The evaluator provider configuration element name. */ - private static final String CONFIGURATION_ELEMENT_NAME = "repairModule"; - - /** The evaluator class attribute name. */ - private static final String HANDLER_CLASS_ATTRIBUTE_NAME = "module"; - - /** Holds the instance of the evaluation service. */ - private volatile static ExplorationRepairService INSTANCE; - - /** Constructor. */ - private ExplorationRepairService() { - // Prevent direct instantiation. - } - - /** The instance (singleton) of the ExplorationTransformationService. */ - public static synchronized ExplorationRepairService getInstance() { - if(INSTANCE == null) { - INSTANCE = new ExplorationRepairService(); - } - return INSTANCE; - } - - /** {@inheritDoc} */ - @Override - protected String getExtensionPointName() { - return EXTENSION_POINT_NAME; - } - - /** {@inheritDoc} */ - @Override - protected String getConfigurationElementName() { - return CONFIGURATION_ELEMENT_NAME; - } - - /** {@inheritDoc} */ - @Override - protected String getHandlerClassAttribute() { - return HANDLER_CLASS_ATTRIBUTE_NAME; - } - - /** {@inheritDoc} */ - @Override - public String getIntrospectionDescription() { - // TODO Auto-generated method stub - return null; - } - - /** {@inheritDoc} */ - @Override - public String getIntrospectionLabel() { - // TODO Auto-generated method stub - return null; - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override - public <T extends Genotype> List<IRepairModule<T>> getRepairFunctionsOf(T genotype, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) throws ExplorationException { - List<IRepairModule<T>> repairModuleInstances = new ArrayList<>(); - Collection<IRepairModule<?>> registeredHandlers = - castToRawColl(getRegisteredHandlers(genotype.getClass())); - - for(IRepairModule<?> curModuleTemplate : registeredHandlers) { - IRepairModule<T> moduleInstance; - try { - Constructor<IRepairModule<T>> extConstructor = - (Constructor<IRepairModule<T>>)curModuleTemplate.getClass().getConstructor( - SystemModelAdapter.class); - moduleInstance = extConstructor.newInstance(systemModelAdapter); - } catch(Exception e) { - throw new ExplorationException( - "Could not instantiate the repair module from its registered template. Please check if the required Constructors are present.", - e); - } - - repairModuleInstances.add(moduleInstance); - } - - return repairModuleInstances; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationTransformationService.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationTransformationService.java deleted file mode 100644 index 5a4e32604456c423187fbee25b9e34aeb93e9550..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationTransformationService.java +++ /dev/null @@ -1,452 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExplorationTransformationService.java 3730 2016-10-19 15:43:43Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.service.internal; - -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.pickSubTypesOf; -import static org.fortiss.tooling.base.ui.annotation.view.AnnotationViewPartBase.isUpdateEnabled; -import static org.fortiss.tooling.base.ui.annotation.view.AnnotationViewPartBase.setUpdateEnabled; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Queue; - -import org.conqat.lib.commons.collections.Pair; -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.Phenotype; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule.TransformationState; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationStrategy; -import org.fortiss.af3.exploration.alg.guava.MutableSubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.guava.SubClassToInstanceMap; -import org.fortiss.af3.exploration.alg.service.ExplorationEncodingMap; -import org.fortiss.af3.exploration.alg.service.IExplorationEncoding; -import org.fortiss.af3.exploration.alg.service.IExplorationTransformationService; -import org.fortiss.af3.exploration.moea.model.solutions.SingleExplorationSolutionMap; -import org.fortiss.af3.project.model.FileProject; -import org.fortiss.af3.project.utils.ProjectUtils; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; -import org.fortiss.tooling.kernel.model.INamedElement; -import org.fortiss.tooling.kernel.service.ITransformationService; -import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase; - -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.MutableClassToInstanceMap; - -/** - * Implementation of the {@link ITransformationService} that manages model transformations from - * {@link IExplorationEncoding}s to EMF models. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3730 $ - * @ConQAT.Rating RED Hash: 301B07DFE96F2C7EB78D305C86E92AB8 - */ -public class ExplorationTransformationService<T extends ITransformationModule<?>> extends - EObjectAwareServiceBase<T> implements IExplorationTransformationService { - - /** Holds the instance of the transformation service. */ - private volatile static ExplorationTransformationService<?> INSTANCE; - - /** Associates module types that are accessible via the service to their Prototype instance. */ - private Map<Class<? extends ITransformationModule<?>>, ITransformationModule<?>> moduleMap = - new HashMap<>(); - - /** Associates the types of output models with the corresponding {@link ITransformationModule}. */ - private Map<Class<?>, ITransformationModule<?>> modulesByOutput = new HashMap<>(); - - /** Associates the registered {@link ITransformationModule} with their required input types. */ - private Multimap<ITransformationModule<?>, Class<?>> inputTypesOfModules = HashMultimap - .create(); - - /** The {@link ExplorationTransformationService} extension point ID. */ - private static final String EXTENSION_POINT_NAME = - "org.fortiss.af3.exploration.alg.transformationModule"; - - /** The {@link ExplorationTransformationService} configuration element name. */ - private static final String CONFIGURATION_ELEMENT_NAME = "transformationModule"; - - /** The {@link ITransformationModule} class attribute name. */ - private static final String HANDLER_CLASS_ATTRIBUTE_NAME = "module"; - - /** Cache the Annotation View's update status. */ - private boolean annotationUpdateEnabled; - - /** Constructor. */ - private ExplorationTransformationService() { - // Prevent direct instantiation. - } - - /** The instance (singleton) of the ExplorationTransformationService. */ - @SuppressWarnings("rawtypes") - public static synchronized ExplorationTransformationService<?> getInstance() { - if(INSTANCE == null) { - INSTANCE = new ExplorationTransformationService(); - } - return INSTANCE; - } - - /** {@inheritDoc} */ - @Override - public void startService() { - super.startService(); - - for(ITransformationModule<?> module : getAllHandlers()) { - @SuppressWarnings("unchecked") Class<? extends ITransformationModule<?>> moduleType = - (Class<? extends ITransformationModule<?>>)module.getClass(); - moduleMap.put(moduleType, module); - } - - List<Pair<Class<?>, T>> rmAccessibleHandlers = new ArrayList<>(); - for(Entry<Class<?>, List<T>> elementHandlerList : handlerMap.entrySet()) { - for(T handler : elementHandlerList.getValue()) { - - // Sub-module handling. - Collection<Class<? extends ITransformationModule<?>>> parentModuleTypes = - handler.getParentModules(); - for(Class<? extends ITransformationModule<?>> parentType : parentModuleTypes) { - ITransformationModule<?> parentModule = moduleMap.get(parentType); - if(parentModule != null) { - parentModule.getSubModules().add(handler); - } - } - - // Mark modules to be removed from the handler map: they shall not be directly - // accessible. - // TODO: is a better mechanism than the identification via the strategy needed? - if(!(handler instanceof ITransformationStrategy)) { - rmAccessibleHandlers.add(new Pair<Class<?>, T>(elementHandlerList.getKey(), - handler)); - } - } - } - - // Remove modules from the handler map that shall not be directly accessible. - for(Pair<Class<?>, T> rmElement : rmAccessibleHandlers) { - allHandlersSet.remove(rmElement.getSecond()); - List<T> handlerList = handlerMap.get(rmElement.getFirst()); - handlerList.remove(rmElement.getSecond()); - if(handlerList.isEmpty()) { - handlerMap.remove(rmElement.getFirst()); - } - } - - // Finally, register the remaining modules with the internal data structures. - for(T module : getAllHandlers()) { - try { - registerTransformationModuleInternal(module); - } catch(Exception e) { - // TODO: Make the tooling kernel aware of exceptions during startup. - e.printStackTrace(); - } - } - } - - /** - * Registers the given {@link ITransformationModule} with the - * {@link ExplorationTransformationService}. - * - * @param module - * {@link ITransformationModule} to be registered. - * @throws Exception - * If an {@link ITransformationModule} that produces the same output model type as - * the given {@link ITransformationModule} has already been registered. - */ - protected void registerTransformationModuleInternal(T module) throws Exception { - // if(modulesByOutput.containsKey(module.getOutputType())) { - // throw new Exception( - // "An ITransformationModule has already been registered to produce the target model type " - // + - // module.getOutputType() + - // " (currently registered ITransformationModule: " + - // module.getClass().getSimpleName() + - // ". It is only allowed to register one ITransformationModule per target model type."); - // } - - if(inputTypesOfModules.containsKey(module)) { - inputTypesOfModules.removeAll(module); - } - inputTypesOfModules.putAll(module, module.getRequiredTypes()); - - modulesByOutput.put(module.getOutputType(), module); - } - - /** {@inheritDoc} */ - @Override - public <U extends EObject, S extends EObject> U getTransformedModel( - TransformationContext context, ITopLevelElement modelContext, - SingleExplorationSolutionMap solution, SubClassToInstanceMap<S> baseModels, - Class<U> transformedModelType, String transformedModelName) throws Exception { - Collection<Class<? extends EObject>> reqType = new ArrayList<>(); - reqType.add(transformedModelType); - ClassToInstanceMap<U> retMap = - getTransformedModels(context, modelContext, solution, baseModels, reqType, - transformedModelName); - return retMap.getInstance(transformedModelType); - } - - /** {@inheritDoc} */ - @Override - public boolean canTransformOutputType(Class<?> transformedModelType) { - return modulesByOutput.get(transformedModelType) != null; - } - - /** {@inheritDoc} */ - @Override - public <U extends EObject, S extends EObject> ClassToInstanceMap<U> - getTransformedModels(TransformationContext context, ITopLevelElement modelContext, - SingleExplorationSolutionMap solution, SubClassToInstanceMap<S> baseModels, - Collection<Class<? extends EObject>> transformedModelTypes, - String transformedModelName) throws Exception { - // First, collect all transformation modules which would generate the requested output. - Collection<ITransformationModule<?>> topLvlModules = new HashSet<>(); - for(Class<? extends EObject> tModelType : transformedModelTypes) { - ITransformationModule<?> module = modulesByOutput.get(tModelType); - if(module == null) { - throw new Exception( - "No ITransformationModule has been registerd which prduces the demanded output model type. Aborting."); - } - topLvlModules.add(module); - } - - // Then, we check whether all required inputs for the corresponding ITransformationModule - // and its sub-Modules are present. - // TODO: instead of triggering the transformations here, use a threaded implementation in - // the ITransformation's base class. - ExplorationEncodingMap<IExplorationEncoding> solutionEncodings = - new ExplorationEncodingMap<>(null); - Queue<ITransformationModule<?>> moduleTraversalList = new LinkedList<>(); - moduleTraversalList.addAll(topLvlModules); - while(!moduleTraversalList.isEmpty()) { - ITransformationModule<?> currentModule = moduleTraversalList.poll(); - for(Class<IExplorationEncoding> solutionType : pickSubTypesOf( - IExplorationEncoding.class, currentModule.getRequiredTypes())) { - Object solutionModel = solution.getSolutionModel(solutionType); - if(solutionModel != null) { - solutionEncodings - .putEncoding(solutionType, (IExplorationEncoding)solutionModel); - } else if(!currentModule.isOptional()) { - throw new Exception( - "The required solution encoding " + - solutionType.getSimpleName() + - " could not be found in the given set of solutions. Please check whether all required solution model have been requested from the DSE."); - } - } - - moduleTraversalList.addAll(currentModule.getSubModules()); - currentModule.getSubModules().forEach(m -> topLvlModules.remove(m)); - } - - // TODO: Add a meaningful TransformationException here. - assert (topLvlModules.size() == 1); - - ITransformationModule<?> rootModule = topLvlModules.stream().findAny().get(); - ITransformationModule<?> moduleInstance = rootModule.createModuleInstance(); - if(moduleInstance instanceof ITransformationStrategy) { - ((ITransformationStrategy<?>)moduleInstance).setModelContext(modelContext); - ((ITransformationStrategy<?>)moduleInstance).setModelName(transformedModelName); - } - - // Disable any Annotation view update - if(isUpdateEnabled()) { - annotationUpdateEnabled = true; - setUpdateEnabled(false); - } - - SubClassToInstanceMap<U> transformedModels = MutableSubClassToInstanceMap.create(); - moduleInstance.transform(TransformationState.INITIALIZING, context, baseModels, - solutionEncodings, transformedModels, null); - - if(context == TransformationContext.EXPORT && - moduleInstance instanceof ITransformationStrategy) { - // Derive the file project from any of the base models - if(baseModels.isEmpty()) { - throw new Exception( - "Cannot add the transformed model to the parent project. No base model has been given by which the project is determined."); - } - - FileProject fp = null; - Iterator<S> bMit = baseModels.values().iterator(); - while(bMit.hasNext() && fp == null) { - fp = ProjectUtils.getFileProject(bMit.next()); - } - ((ITransformationStrategy<?>)moduleInstance).addModelToProject(fp, modelContext); - } - - // Disable any Annotation view update - if(annotationUpdateEnabled) { - setUpdateEnabled(true); - } - - ClassToInstanceMap<U> retModels = MutableClassToInstanceMap.create(); - for(Class<? extends EObject> retType : transformedModelTypes) { - assert (transformedModels.get(retType) != null); - @SuppressWarnings("unchecked") Class<? extends U> castedRetType = - (Class<? extends U>)retType; - retModels.put(castedRetType, transformedModels.get(retType)); - } - - return retModels; - } - - /** {@inheritDoc} */ - @Override - public <U extends EObject, S extends EObject> U getTransformedModel( - TransformationContext context, ITopLevelElement modelContext, - ExplorationEncodingMap<IExplorationEncoding> phenotypes, - SubClassToInstanceMap<S> baseModels, Class<U> transformedModelType, - String transformedModelName) throws Exception { - Collection<Class<? extends EObject>> reqType = new ArrayList<>(); - reqType.add(transformedModelType); - ClassToInstanceMap<U> retMap = - getTransformedModels(context, modelContext, phenotypes, baseModels, reqType, - transformedModelName); - return retMap.getInstance(transformedModelType); - } - - /** {@inheritDoc} */ - @Override - public <U extends EObject, S extends EObject> ClassToInstanceMap<U> - getTransformedModels(TransformationContext context, ITopLevelElement modelContext, - ExplorationEncodingMap<IExplorationEncoding> phenotypes, - SubClassToInstanceMap<S> baseModels, - Collection<Class<? extends EObject>> transformedModelTypes, - String transformedModelName) throws Exception { - // First, collect all transformation modules which would generate the requested output. - Collection<ITransformationModule<?>> topLvlModules = new HashSet<>(); - for(Class<? extends EObject> tModelType : transformedModelTypes) { - ITransformationModule<?> module = modulesByOutput.get(tModelType); - if(module == null) { - throw new Exception( - "No ITransformationModule has been registerd which produces the demanded output model type. Aborting."); - } - topLvlModules.add(module); - } - - // Then, we check whether all required inputs for the corresponding ITransformationModule - // and its sub-Modules are present. - // TODO: instead of triggering the transformations here, use a threaded implementation in - // the ITransformation's base class. - ExplorationEncodingMap<IExplorationEncoding> encodings = new ExplorationEncodingMap<>(null); - Queue<ITransformationModule<?>> moduleTraversalList = new LinkedList<>(); - moduleTraversalList.addAll(topLvlModules); - while(!moduleTraversalList.isEmpty()) { - ITransformationModule<?> currentModule = moduleTraversalList.poll(); - for(Class<Phenotype> solutionType : pickSubTypesOf(Phenotype.class, - currentModule.getRequiredTypes())) { - IExplorationEncoding phenotype = phenotypes.getEncoding(solutionType); - if(phenotype != null) { - encodings.putEncoding(solutionType, phenotype); - } else if(!currentModule.isOptional()) { - throw new Exception( - "The required phenotype encoding " + - solutionType.getSimpleName() + - " could not be found in the given set of phenotypes. Please check whether all required phenotypes have been requested from the DSE."); - } - } - - moduleTraversalList.addAll(currentModule.getSubModules()); - currentModule.getSubModules().forEach(m -> topLvlModules.remove(m)); - } - - // TODO: Add a meaningful TransformationException here. - assert (topLvlModules.size() == 1); - - // TODO: here, we will actually need the systemModelAdapter, since this method is called - // from the DSE process itself. - ITransformationModule<?> rootModule = topLvlModules.stream().findAny().get(); - ITransformationModule<?> moduleInstance = rootModule.createModuleInstance(); - if(moduleInstance instanceof ITransformationStrategy) { - ((ITransformationStrategy<?>)moduleInstance).setModelContext(modelContext); - } - SubClassToInstanceMap<U> transformedModels = MutableSubClassToInstanceMap.create(); - @SuppressWarnings("unchecked") U transformedModel = - (U)moduleInstance.transform(TransformationState.INITIALIZING, context, baseModels, - encodings, transformedModels, null); - - if(transformedModel instanceof INamedElement) { - ((INamedElement)transformedModel).setName(transformedModelName); - } - - ClassToInstanceMap<U> retModels = MutableClassToInstanceMap.create(); - for(Class<? extends EObject> retType : transformedModelTypes) { - assert (transformedModels.get(retType) != null); - @SuppressWarnings("unchecked") Class<? extends U> castedRetType = - (Class<? extends U>)retType; - retModels.put(castedRetType, transformedModels.get(retType)); - } - - return retModels; - } - - /** {@inheritDoc} */ - @Override - public void resetRegisteredModules() { - modulesByOutput.clear(); - inputTypesOfModules.clear(); - } - - /** {@inheritDoc} */ - @Override - public String getIntrospectionDescription() { - return "\n\nThis service manages the transformation of DSE-internal encodings to EMF models." + - "\nThe resulting EMF models can bei either derived models, i.e., models that are based on some input 'template model', which are" + - "\nreplicated and enriched with information generated by a DSE run, or 'new' models which are generated using information obtained" + - "\nfrom a DSE run exclusively." + - "\n\nThe service extension point is '" + - EXTENSION_POINT_NAME + "'."; - } - - /** {@inheritDoc} */ - @Override - public String getIntrospectionLabel() { - return "DSE Transformation Service"; - } - - /** {@inheritDoc} */ - @Override - protected String getExtensionPointName() { - return EXTENSION_POINT_NAME; - } - - /** {@inheritDoc} */ - @Override - protected String getConfigurationElementName() { - return CONFIGURATION_ELEMENT_NAME; - } - - /** {@inheritDoc} */ - @Override - protected String getHandlerClassAttribute() { - return HANDLER_CLASS_ATTRIBUTE_NAME; - } - - /** {@inheritDoc} */ - @Override - public void initializeService() { - super.initializeService(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/AF3Utils.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/AF3Utils.java deleted file mode 100644 index b3c0012c7acfff8bb24e97a7bc93366ca22ac37e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/AF3Utils.java +++ /dev/null @@ -1,735 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: AF3Utils.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.util; - -import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.isAtomicComponent; -import static org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceConnectionAdapter.ConnectionType.BIDIRECTIONAL; -import static org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceConnectionAdapter.ConnectionType.INCOMING; -import static org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceConnectionAdapter.ConnectionType.OUTGOING; -import static org.fortiss.af3.exploration.alg.util.DesignSpaceExplorationModelElementFactory.createComponentMultiAllocationConstraint; -import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.getReferencedElementsWithType; -import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.getResourceReferences; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getParentsWithType; -import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; - -import org.conqat.lib.commons.collections.Pair; -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Channel; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.component.model.InputPort; -import org.fortiss.af3.component.model.OutputPort; -import org.fortiss.af3.component.model.Port; -import org.fortiss.af3.deployment.model.ComponentAllocation; -import org.fortiss.af3.deployment.model.Deployment; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.safetyfunctionarch.SafetyFunctionArchEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IModelElementAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceConnectionAdapter.ConnectionType; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.fortiss.af3.exploration.alg.exception.InvalidPlatformModelException; -import org.fortiss.af3.exploration.alg.exception.InvalidTimingModelException; -import org.fortiss.af3.exploration.alg.guava.TypedBiMap; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiAllocationConstraint; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.af3.platform.model.IPlatformPort; -import org.fortiss.af3.platform.model.IPlatformResource; -import org.fortiss.af3.platform.model.IVirtualizationPlatformArchitectureElement; -import org.fortiss.af3.platform.model.PlatformArchitecture; -import org.fortiss.af3.platform.model.PlatformConnectorUnit; -import org.fortiss.af3.platform.model.annotation.ResourceLink; -import org.fortiss.af3.safety.model.SafetyArchitecture; -import org.fortiss.tooling.base.model.element.IConnection; -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.IIdLabeled; -import org.jgrapht.DirectedGraph; -import org.jgrapht.graph.DefaultEdge; - -/** - * Utility methods which help to abstract AF3 specifica for the DSE. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: 39567BA5F53AF0F47D6906A4226F424A - */ -public class AF3Utils { - - /** Constructor. Prevent initialization. */ - private AF3Utils() { - } - - /** - * Translates the safety architecture encoded in a {@link SafetyFunctionArchEntry} to a - * {@link SafetyArchitecture} enum representation. - * - * @param sfaEntry - * {@link SafetyFunctionArchEntry} to be translated. - * @return The encoded {@link SafetyArchitecture}, or {@code null} if no matching enum is found. - */ - public static SafetyArchitecture getSFArchFromEntry(SafetyFunctionArchEntry<?> sfaEntry) { - int channelNum = sfaEntry.getNumChannels(); - int triggerNum = sfaEntry.getNumTriggerSignal(); - boolean diagnosisPresent = sfaEntry.isDiagnosicUnitPresent(); - boolean diagnosisConnected = sfaEntry.isDiagnosicUnitConnected(); - - if(diagnosisConnected) { - if(channelNum == 1 && triggerNum == 1) { - return SafetyArchitecture.ARCH_1OO1_D; - } else if(channelNum == 2 && triggerNum == 1) { - return SafetyArchitecture.ARCH_1OO2_D; - } - } else { - if(channelNum == 1 && triggerNum == 1) { - return diagnosisPresent ? SafetyArchitecture.ARCH_1OO1_DU - : SafetyArchitecture.ARCH_1OO1; - } else if(channelNum == 2 && triggerNum == 1) { - return diagnosisPresent ? SafetyArchitecture.ARCH_1OO2_DU - : SafetyArchitecture.ARCH_1OO2; - } else if(channelNum == 3 && triggerNum == 1) { - return diagnosisPresent ? SafetyArchitecture.ARCH_1OO3_DU - : SafetyArchitecture.ARCH_1OO3; - } else if(channelNum == 2 && triggerNum == 2) { - return diagnosisPresent ? SafetyArchitecture.ARCH_2OO2_DU - : SafetyArchitecture.ARCH_2OO2; - } else if(channelNum == 3 && triggerNum == 2) { - return diagnosisPresent ? SafetyArchitecture.ARCH_2OO3_DU - : SafetyArchitecture.ARCH_2OO3; - } else if(channelNum == 4 && triggerNum == 2) { - return SafetyArchitecture.ARCH_2OO4; - } - } - - return null; - } - - /** - * Returns the number of independent safety channels encoded in a {@link SafetyArchitecture}. - * - * @param sfArch - * {@link SafetyArchitecture} from which the channel number shall be extracted. - * @return Number of channels, or {@code null} if no {@link SafetyArchitecture} is given or the - * architecture is unknown. - */ - public static Integer getChannelNumbersSafetyArch(SafetyArchitecture sfArch) { - if(sfArch == null) { - return null; - } - - switch(sfArch) { - case ARCH_1OO1: - case ARCH_1OO1_D: - case ARCH_1OO1_DU: - return 1; - case ARCH_1OO2: - case ARCH_1OO2_D: - case ARCH_1OO2_DU: - case ARCH_2OO2: - case ARCH_2OO2_DU: - return 2; - case ARCH_1OO3: - case ARCH_1OO3_DU: - case ARCH_2OO3: - case ARCH_2OO3_DU: - return 3; - case ARCH_2OO4: - return 4; - default: - return null; - } - } - - /** - * Returns the number signals from independent safety channels that are required to trigger the - * actual safety function. This information is extracted form the given - * {@link SafetyArchitecture}. - * - * @param sfArch - * {@link SafetyArchitecture} from which the number of triggers shall be extracted. - * @return Number of triggers, or {@code null} if no {@link SafetyArchitecture} is given or the - * architecture is unknown. - */ - public static Integer getTriggerNumbersSafetyArch(SafetyArchitecture sfArch) { - if(sfArch == null) { - return null; - } - - switch(sfArch) { - case ARCH_1OO1: - case ARCH_1OO1_D: - case ARCH_1OO1_DU: - case ARCH_1OO2: - case ARCH_1OO2_D: - case ARCH_1OO2_DU: - case ARCH_1OO3: - case ARCH_1OO3_DU: - return 1; - case ARCH_2OO2: - case ARCH_2OO2_DU: - case ARCH_2OO3: - case ARCH_2OO3_DU: - case ARCH_2OO4: - return 2; - default: - return null; - } - } - - /** - * Returns whether the given {@link SafetyArchitecture} encodes the presence of one or more - * diagnostic units. - * - * @param sfArch - * {@link SafetyArchitecture} encoding the presence of diagnostic unit (s). - * @return Presence of diagnostic unit(s), or {@code null} if no {@link SafetyArchitecture} is - * given or the architecture is unknown. - */ - public static Optional<Boolean> isDiagPresentSafetyArch(SafetyArchitecture sfArch) { - switch(sfArch) { - case ARCH_1OO1_D: - case ARCH_1OO1_DU: - case ARCH_1OO2_D: - case ARCH_2OO2_DU: - case ARCH_1OO2_DU: - case ARCH_1OO3_DU: - case ARCH_2OO3_DU: - return Optional.of(true); - case ARCH_1OO1: - case ARCH_1OO2: - case ARCH_2OO2: - case ARCH_1OO3: - case ARCH_2OO3: - case ARCH_2OO4: - return Optional.of(false); - default: - return Optional.empty(); - } - } - - /** - * Returns whether the given {@link SafetyArchitecture} encodes the presence of one or more - * diagnostic units that directly influence whether the safety function is triggered. - * - * @param sfArch - * {@link SafetyArchitecture} encoding the presence of diagnostic unit (s). - * @return Presence of diagnostic unit(s) influencing the safety function's output, or - * {@code null} if no {@link SafetyArchitecture} is given or the architecture is - * unknown. - */ - public static Optional<Boolean> isDiagConnectedSafetyArch(SafetyArchitecture sfArch) { - switch(sfArch) { - case ARCH_1OO1_D: - case ARCH_1OO2_D: - return Optional.of(true); - case ARCH_1OO1: - case ARCH_1OO1_DU: - case ARCH_1OO2: - case ARCH_1OO2_DU: - case ARCH_2OO2: - case ARCH_2OO2_DU: - case ARCH_1OO3: - case ARCH_1OO3_DU: - case ARCH_2OO3: - case ARCH_2OO3_DU: - case ARCH_2OO4: - return Optional.of(false); - default: - return Optional.empty(); - } - } - - /** - * Determines the {@link ConnectionType} of a connection by examining the class of the given - * connector that is the target of the current connection. - * - * @param targetConnector - * Target {@link IConnector} of the {@link IConnection} whose direction shall be - * determined. - * @return {@link ConnectionType} specifying the direction of the {@link IConnection}. - * @throws InvalidPlatformModelException - * if an invalid combination of of platform ports/interfaces has been detected - * (e.g., Input <-> Input). - */ - // TODO: update doc. - public static ConnectionType getConnectionTypeDirection(IConnector sourceConnector, - IConnector targetConnector, SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws InvalidPlatformModelException { - // By the method signature, we know the instance type is a IConnector class. - @SuppressWarnings("unchecked") ConnectionType connectionTypeSource = - systemModelAdapter.getConnectionType((Class<? extends IConnector>)sourceConnector - .eClass().getInstanceClass()); - @SuppressWarnings("unchecked") ConnectionType connectionTypeTarget = - systemModelAdapter.getConnectionType((Class<? extends IConnector>)targetConnector - .eClass().getInstanceClass()); - // assert (connectionTypeSource != null && connectionTypeTarget != null) : - // "Could not identify the type of one of the connection targets."; - if((connectionTypeSource == INCOMING && connectionTypeTarget == INCOMING) || - (connectionTypeSource == OUTGOING && connectionTypeTarget == OUTGOING)) { - throw new InvalidPlatformModelException( - (PlatformConnectorUnit)sourceConnector, - "A platform port or interface (see above) for incoming or outgoing traffic is connected to an port or interface of the same type. This is not allowed."); - } - - if(connectionTypeSource == OUTGOING && connectionTypeTarget == INCOMING) { - return OUTGOING; - } else if(connectionTypeSource == INCOMING && connectionTypeTarget == OUTGOING) { - return INCOMING; - } else if((connectionTypeSource == BIDIRECTIONAL || connectionTypeSource == null) && - (connectionTypeTarget != null && connectionTypeTarget != BIDIRECTIONAL)) { - // Revert the direction for the target port, since we are examining the connection from - // its source. - return connectionTypeTarget == INCOMING ? OUTGOING : INCOMING; - } else if((connectionTypeTarget == BIDIRECTIONAL || connectionTypeTarget == null) && - (connectionTypeSource != null && connectionTypeSource != BIDIRECTIONAL)) { - return connectionTypeSource; - } - return BIDIRECTIONAL; - } - - /** - * Returns the type of communication the given port can handle: incoming, outgoing, or - * bidirectional traffic. - * - * @param sourceConnector - * {@link IConnector} to be examined. - * @return The port type (default = bidirectional). - */ - public static ConnectionType getPortDirection(IPlatformPort sourceConnector, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) { - // By the method signature, we know the instance type is a IConnector class. - @SuppressWarnings("unchecked") ConnectionType connectionTypeSource = - systemModelAdapter.getConnectionType((Class<? extends IConnector>)sourceConnector - .eClass().getInstanceClass()); - return connectionTypeSource != null ? connectionTypeSource : BIDIRECTIONAL; - } - - /** - * Predicate whether the subject {@link PlatformConnectorUnit} is a connector of the given - * {@link IModelElementAdapter}. - */ - public static boolean - isConnectorOf(PlatformConnectorUnit pConn, IModelElementAdapter<?> element) { - return pConn.getOwner() == element.getObject(); - } - - /** - * Predicate whether the subject {@link PlatformConnectorUnit}'s containing element is contained - * in the given {@link IModelElementAdapter} and also contained in the given - * {@link DirectedGraph}. - */ - public static boolean isContainedInResource(PlatformConnectorUnit pConn, - IModelElementAdapter<?> element) { - return pConn.getOwner() == ((IHierarchicElement)element.getObject()).getContainer(); - } - - /** - * Predicate whether the subject {@link PlatformConnectorUnit} is the predecessor - * {@link PlatformConnectorUnit} for the device-internal communication of the given - * {@link IModelElementAdapter}. - */ - public static boolean - isDeviceInternalPredecessor(PlatformConnectorUnit connCandidate, - IModelElementAdapter<?> element, - DirectedGraph<PlatformConnectorUnit, DefaultEdge> route) { - // The following rules apply for device internal communication: - // - Sender Port is on the same device OR - // - its reference port is one layer "below", e.g. Gateway -> Router AND - // - the sender connector must have been traversed (natural for path walking a multicast - // message. - if(route.containsVertex(connCandidate) && - (isConnectorOf(connCandidate, element) || isContainedInResource(connCandidate, - element))) { - return true; - } - return false; - } - - /** - * Returns the collection of {@link InputPort}s and {@link OutputPort}s attached to the given - * {@link Component}. - * - * @param component - * Containing {@link Component}. - * @return Collection of attached {@link InputPort}s and {@link OutputPort}s as {@link Port}s. - */ - public static Collection<Port> getInputOutputPortsOf(Component component) { - Collection<Port> ports = new ArrayList<Port>(); - ports.addAll(component.getInputPorts()); - ports.addAll(component.getOutputPorts()); - return ports; - } - - /** - * Returns the collection of {@link Port}s which are connected via {@link Channel}s with the - * given {@link Port} - * - * @param port - * {@link Port} whose connected {@link Port}s shall be found. - * @return Collection of connected {@link Port}s. - */ - public static Collection<Port> getConnectedPortsOf(Port port) { - Collection<Port> connectedPorts = new ArrayList<Port>(); - port.getIncomingChannels().stream().forEach(conn -> connectedPorts.add(conn.getSource())); - port.getOutgoingChannels().stream().forEach(conn -> connectedPorts.add(conn.getTarget())); - return connectedPorts; - } - - /** - * Returns the collection of <i>all</i> directly connected {@link Channel}s of the given - * {@link Component}. - * - * @param component - * Subject {@link Component}. - * @return Collection of directly connected {@link Channel}s. - */ - public static Collection<Channel> getConnectedChannelsOf(Component component) { - Collection<Port> containedPorts = getInputOutputPortsOf(component); - Collection<Channel> connectedChannels = new ArrayList<>(); - containedPorts.stream().forEach( - p -> p.getIncomingChannels().stream().forEach(ch -> connectedChannels.add(ch))); - containedPorts.stream().forEach( - p -> p.getOutgoingChannels().stream().forEach(ch -> connectedChannels.add(ch))); - return connectedChannels; - } - - /** - * Checks whether any parent {@link IPlatformResource} of the given {@code element} is a - * deployment target defined by the set of deployment targets ({@code deploymentTargets}). - * If any parent element has been found that is a deployment target, {@code true} is returned. - * The method considers parents in the following order: <li>Check the direct parent (container). - * </li> <li>Check all referenced resources as defined in the {@link ResourceLink} annotation.</li> - * <li>Go to the parent resource and run the same checks.</li> <li>Run the above checks for all - * references Resources as given by the {@link ResourceLink} annotations.</> - * - * @param element - * {@link IPlatformResource} whose parents shall be examined if they are deployment - * targets. - * @param deploymentTargets - * set of deployment target resources. - * @return Whether or not any parent is deployment target by the rules explained above. - */ - public static boolean isAnyParentDeploymentTarget(IPlatformResource element, - Collection<IPlatformResource> deploymentTargets) { - EObject parent = element.eContainer(); - if(parent == null) { - return false; - } - - List<IPlatformResource> resRefs = getResourceReferences((IModelElement)element); - - if(deploymentTargets.contains(parent)) { - return true; - } else if(element instanceof IVirtualizationPlatformArchitectureElement && - element instanceof IModelElement) { - if(resRefs.stream().anyMatch(r -> deploymentTargets.contains(r))) { - return true; - } - } - - if(isAnyParentDeploymentTarget(element, deploymentTargets)) { - return true; - } - - for(IPlatformResource curRes : resRefs) { - if(isAnyParentDeploymentTarget(curRes, deploymentTargets)) { - return true; - } - } - - return false; - } - - /** - * Checks whether any child element of the given element is a deplyoment target and conforms to - * the given type. - */ - public static <T extends IPlatformResource & IHierarchicElement> boolean - isAnyChildDeploymentTarget(IPlatformResource element, Collection<T> deploymentTargets, - Class<T> targetType) { - return getChildrenWithType(element, targetType).stream().anyMatch( - child -> deploymentTargets.contains(child)); - } - - /** - * Helper method to capture the inverse "links" of {@link ResourceLink} annotations. - * - * @param referencingPlatformArchitecture - * {@link PlatformArchitecture} containing the {@link ResourceLink}s. - * @param interPlatformConnectingElements - * {@link Pair} of {@link IModelElement} classes identifying those element types that - * reference (first element) another element of another platform (second element) and - * thereby establish a "communication link" between both platforms. - * @return Map representing the "inverse" 1:1 references of {@link ResourceLink}s. - */ - public static - Map<IModelElement, IModelElement> - getInverseIntraPlatformReferences( - PlatformArchitecture referencingPlatformArchitecture, - Pair<Class<? extends IModelElement>, Class<? extends IModelElement>> interPlatformConnectingElements) { - Map<IModelElement, IModelElement> invElementReferences = - new HashMap<IModelElement, IModelElement>(); - - if(interPlatformConnectingElements != null) { - for(IModelElement referencingElement : getChildrenWithType( - referencingPlatformArchitecture, interPlatformConnectingElements.getFirst())) { - for(IModelElement referencedElement : getReferencedElementsWithType( - referencingElement, interPlatformConnectingElements.getSecond())) { - invElementReferences.put(referencedElement, referencingElement); - } - } - } - - return invElementReferences; - } - - /** - * Returns a map containing the inverse references represented by {@link ResourceLink}s between - * {@link IModelElement}s of {@link PlatformArchitecture}s. - * - * @param af3Deployment - * {@link Deployment} for whose linked {@link PlatformArchitecture} the inverse - * {@link ResourceLink} references have to be found. - * @param interPlatformConnectingElements - * {@link Pair} of {@link IModelElement} classes identifying those element types that - * reference (first element) another element of another platform (second element) and - * thereby establish a "communication link" between both platforms. - * @return The inverse {@link ResourceLink} references, or an empty map if none were identified. - */ - public static - Map<IModelElement, IModelElement> - getInverseIntraPlatformReferences( - Deployment af3Deployment, - Pair<Class<? extends IModelElement>, Class<? extends IModelElement>> interPlatformConnectingElements) { - IModelElement platformReference = - af3Deployment.getPlatformArchitectureReference().getReference(); - PlatformArchitecture af3PlatformArchitecture = null; - if(platformReference instanceof PlatformArchitecture) { - af3PlatformArchitecture = (PlatformArchitecture)platformReference; - return getInverseIntraPlatformReferences(af3PlatformArchitecture, - interPlatformConnectingElements); - } - return Collections.emptyMap(); - } - - /** - * Searches the given {@link ComponentArchitecture} for {@link ComponentDiverseImplRef}s and - * returns all referenced {@link Component}s (representing an implementation of the referencing - * {@link Component}). - * - * @param compArch - * The {@link ComponentArchitecture} to be searched for references. - * @return Collection of all {@link Component}s referenced by the - * {@link ComponentDiverseImplRef} {@link IModelElementSpecification} in the given - * {@link ComponentArchitecture} : - */ - // public static Collection<Component> getAllReferencedDiverseComponentsOf( - // ComponentArchitecture compArch) { - // Collection<Component> referencedComponents = new ArrayList<Component>(); - // List<ComponentDiverseImplRef> diversitySpec = - // getChildrenWithType(compArch, ComponentDiverseImplRef.class); - // for(ComponentDiverseImplRef diverseComponentSpec : diversitySpec) { - // // We assume that the diverse components of one component are located in one and the - // // same ComponentArchitecture. Hence, it suffices to determine the parent - // // ComponentArchitecture by the first element in the List. - // referencedComponents.addAll(diverseComponentSpec.getComponentRef()); - // } - // return referencedComponents; - // } - - /** - * Creates a set of {@link ComponentMultiAllocationConstraint}s that is constructed from the - * {@link ComponentAllocation}s contained in the given {@link Deployment}. - * - * @param deployment - * {@link Deployment} containing the {@link ComponentAllocation}s. - * @return Set of {@link ComponentMultiAllocationConstraint}s with the same references as the - * {@link ComponentAllocation}s. - */ - public static Collection<ComponentMultiAllocationConstraint> createConstraintsFromDeployment( - Deployment deployment) { - Collection<ComponentAllocation> allocatedComponents = deployment.getComponentAllocations(); - Function<ComponentAllocation, ComponentMultiAllocationConstraint> mapper = - ca -> createComponentMultiAllocationConstraint(ca.getComponent(), new BasicEList<>( - Arrays.asList(ca.getExecutionUnit()))); - return allocatedComponents.stream().map(mapper) - .map(ComponentMultiAllocationConstraint.class::cast).collect(Collectors.toList()); - } - - /** - * Returns the first identified <i>Component Pool</i> that is associated with the given - * {@link ComponentArchitecture}. This method uses the set of diverse implementations of - * {@link IDeployableComponentAdapter}s from the input {@link ComponentArchitecture} and returns - * its containing {@link ComponentArchitecture}. This method assumes that there exists maximally - * one <i>Component Pool</i> per "actual" {@link ComponentArchitecture}. - * - * @param mapping - * {@link IMappingEncoding} whose {@link IDeployableComponentAdapter}s referenced by - * the {@link IMappingEntry}s are used to identify the <i>Component Pool</i>. - * @return The {@link ComponentArchitecture} identified as the <i>Component Pool</i> or - * {@code null} if none is found. - */ - public static ComponentArchitecture getFirstComponentPool(IMappingEncoding mapping) { - for(IDeployableComponentAdapter<?> deployableComponent : mapping.getDeployedComponents()) { - if(deployableComponent.isInstantiation()) { - // TODO: Avoid casting: Parameterize the IModelElementAdapter to use EObject-derived - // generics? - ComponentArchitecture parentCA = - getParentElement((EObject)deployableComponent.getObject(), - ComponentArchitecture.class, false); - if(parentCA != null) { - return parentCA; - } - } else if(deployableComponent.isInstantiationRequired()) { - for(IDeployableComponentAdapter<?> replacementComponent : deployableComponent - .getReplacementComponents()) { - // TODO: Avoid casting: Parameterize the IModelElementAdapter to use - // EObject-derived generics? - ComponentArchitecture parentCA = - getParentElement((EObject)replacementComponent.getObject(), - ComponentArchitecture.class, false); - if(parentCA != null) { - return parentCA; - } - } - } - } - return null; - } - - /** - * Resets the IDs of the given {@code root} object and its contained elements to 0. - * - * @param root - * {@link EObject} for which and for whose contained elements, the id will be set to - * 0. - */ - public static void resetIds(IIdLabeled root) { - for(TreeIterator<EObject> iter = root.eAllContents(); iter.hasNext();) { - EObject obj = iter.next(); - if(obj instanceof IIdLabeled) { - ((IIdLabeled)obj).setId(0); - } - } - root.setId(0); - } - - /** - * Checks whether any parent {@link Component} of the given {@link EObject} is chosen to be - * deployable element. - * - * @param startElement - * The element whose parents shall be evaluated w.r.t. the deployable property - * @return True if any parent {@link Component} is chosen to be deployed, false otherwise. - * @throws InvalidTimingModelException - * if the deployable element cannot be identified. - */ - public static <T extends EObject> boolean isAnyParentComponentDeployable(EObject startElement, - SystemModelAdapter<?, ?, ?, ?, ?, ?> systemModelAdapter) - throws InvalidTimingModelException { - EList<Component> parentElements = getParentsWithType(startElement, Component.class); - - for(Component parentComponent : parentElements) { - if(systemModelAdapter.isDeployableComponent(parentComponent)) { - return true; - } - } - - return false; - } - - // - /** - * Returns whether any container {@link Component} of the given {@code startElement} - * {@link Component} is a deployable {@link Component}. Therefore the - * {@code encEntryModelElemAssoc} map is checked for containing any entry that is associated - * with one of the containing {@link Component}s. - * - * @param startElement - * {@link Component} to check. - * @param encEntryModelElemAssoc - * associations between {@link TaskMappingEntry}s and {@link Component}s. - * @return Whether any containing {@link Component} is deployed. - * @throws InvalidTimingModelException - */ - public static <T extends EObject> boolean isAnyParentComponentDeployable(EObject startElement, - TypedBiMap<Object, EObject> encEntryModelElemAssoc) throws InvalidTimingModelException { - EList<Component> parentElements = getParentsWithType(startElement, Component.class); - - for(Component parentComponent : parentElements) { - AbstractTaskMappingEntry entry = - (AbstractTaskMappingEntry)encEntryModelElemAssoc.inverse().get(parentComponent, - AbstractTaskMappingEntry.class); - if(entry != null) { - return true; - } - } - - return false; - } - - /** - * Predicate if a the given {@link Component} is principally deployable, i.e. it is either - * defined to be deployable (e.g., by a trigger) or an atomic {@link Component}. - * - * @param deployComponent - * The {@link Component} to be checked whether it shall be deployed onto - * {@link ExecutionUnit}s - * @return boolean, if the given {@link Component} shall be considered deployable. - * @throws Exception - * if the timing specification of any traversed element is inconsistent. - */ - public static boolean isComponentOrPortsDeployable(Component deployComponent, - SystemModelAdapter<Component, ?, ?, ?, ?, ?> systemModelAdapter) throws Exception { - for(Port port : deployComponent.getInputPorts()) { - if(systemModelAdapter.isDeployablePort(port)) { - return true; - } - } - for(Port port : deployComponent.getOutputPorts()) { - if(systemModelAdapter.isDeployablePort(port)) { - return true; - } - } - if(systemModelAdapter.isDeployableComponent(deployComponent) || - (!isAnyParentComponentDeployable(deployComponent, systemModelAdapter) && isAtomicComponent(deployComponent))) { - return true; - } - return false; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/DesignSpaceExplorationModelElementFactory.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/DesignSpaceExplorationModelElementFactory.java deleted file mode 100644 index 1a72926f0a28239b4f6c5d773f6e1bbf15e9147e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/DesignSpaceExplorationModelElementFactory.java +++ /dev/null @@ -1,299 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DesignSpaceExplorationModelElementFactory.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.util; - -import static org.fortiss.af3.exploration.util.ExplorationDslModelElementFactory.createObjectiveExpression; -import static org.fortiss.af3.exploration.util.ExplorationDslModelElementFactory.createSummationOp; -import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.prepareUniqueID; - -import org.eclipse.emf.common.util.EList; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.exploration.dsl.model.expressions.Expression; -import org.fortiss.af3.exploration.dsl.model.expressions.ObjectiveExpression; -import org.fortiss.af3.exploration.dsl.model.operators.LocationOp; -import org.fortiss.af3.exploration.dsl.model.operators.LocationOperatorEnum; -import org.fortiss.af3.exploration.dsl.model.operators.OperatorsFactory; -import org.fortiss.af3.exploration.dsl.model.operators.OptimizationDirectionEnum; -import org.fortiss.af3.exploration.dsl.model.operators.SummationOp; -import org.fortiss.af3.exploration.dsl.model.patterns.LocationProperty; -import org.fortiss.af3.exploration.dsl.model.patterns.PatternsFactory; -import org.fortiss.af3.exploration.model.ExplorationFactory; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.moea.model.DseSpecification; -import org.fortiss.af3.exploration.moea.model.ExplorationManager; -import org.fortiss.af3.exploration.moea.model.MoeaFactory; -import org.fortiss.af3.exploration.moea.model.parameters.EAOptimizer; -import org.fortiss.af3.exploration.moea.model.parameters.ExecutionModel; -import org.fortiss.af3.exploration.moea.model.parameters.ParametersFactory; -import org.fortiss.af3.exploration.moea.model.parameters.SystemParameters; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiAllocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiDislocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.EnergyMinObjective; -import org.fortiss.af3.exploration.moea.model.predefined.FailureMinObjective; -import org.fortiss.af3.exploration.moea.model.predefined.FailureType; -import org.fortiss.af3.exploration.moea.model.predefined.PredefinedFactory; -import org.fortiss.af3.exploration.moea.model.predefined.ReliabilityAnalysis; -import org.fortiss.af3.exploration.moea.model.predefined.SafetyIntegrityLevelConstraint; -import org.fortiss.af3.exploration.moea.model.solutions.SingleExplorationSolutionMap; -import org.fortiss.af3.exploration.moea.model.solutions.SolutionsFactory; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; -import org.fortiss.tooling.kernel.service.IPersistencyService; - -/** - * Model element factory for design space exploration. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: 257EF37D5DE22B7960D54E5CAB3EE3A8 - */ -public class DesignSpaceExplorationModelElementFactory { - - /** Creates a ExplorationManager specification. */ - public static ExplorationManager createExplorationManager(String name) { - ExplorationManager manager = MoeaFactory.eINSTANCE.createExplorationManager(); - manager.setName(name); - - return manager; - } - - /** Creates an instance of a {@link DseSpecification} with default parameters. */ - public static DseSpecification createDseSpecification(String name) { - DseSpecification dse = MoeaFactory.eINSTANCE.createDseSpecification(); - dse.setName(name); - return dse; - } - - /** Creates an instance of a {@link DseSpecification} with default parameters. */ - public static DseSpecification createDefaultDseSpecification(ITopLevelElement modelContext) { - return createDseSpecification("Default DSE model", ExecutionModel.TT_FAIL_SILENCE, - createDefaultEAOptimizer(), modelContext); - } - - /** Creates an instance of a {@link DseSpecification} with default parameters. */ - public static DseSpecification addDefaultDesignSpaceExploration(ExplorationManager explManager) { - ITopLevelElement modelContext = - IPersistencyService.getInstance().getTopLevelElementFor(explManager); - DseSpecification dse = - createDseSpecification("Default DSE model", ExecutionModel.TT_FAIL_SILENCE, - createDefaultEAOptimizer(), modelContext); - prepareUniqueID(dse, explManager); - modelContext.runAsCommand(() -> explManager.getDseSpecifications().add(dse)); - return dse; - } - - /** Creates an instance of a {@link DseSpecification} with the given parameters. */ - public static DseSpecification createDseSpecification(String name, ExecutionModel execModel, - EAOptimizer eaOptimizer, ITopLevelElement modelContext) { - DseSpecification dse = createDseSpecification(name); - Runnable defaultDSE = () -> { - dse.setParameters(createSystemParameters(execModel)); - dse.setOptimizer(eaOptimizer); - // A goal specification does not require any default values, so created here. - dse.setTargetSpecification(ExplorationFactory.eINSTANCE - .createExplorationSpecification()); - }; - modelContext.runAsCommand(defaultDSE); - return dse; - } - - /** "Wrapper" for creating an instance of default DSE parameters for the model. */ - public static SystemParameters createSystemParameters(ExecutionModel execModel) { - SystemParameters dseParams = ParametersFactory.eINSTANCE.createSystemParameters(); - dseParams.setExecutionModel(execModel); - return dseParams; - } - - /** Creates an default EA optimizer configuration */ - public static EAOptimizer createDefaultEAOptimizer() { - // Parameter defaults are preset in exploration.ecore. - return ParametersFactory.eINSTANCE.createEAOptimizer(); - } - - /** Creates an empty {@link SingleExplorationSolutionMap}. */ - public static SingleExplorationSolutionMap createSingleExplorationSolutionMap() { - SingleExplorationSolutionMap solMap = - SolutionsFactory.eINSTANCE.createSingleExplorationSolutionMap(); - // Initialize the Ecore map via the getter: If this method is not called after construction - // of the SingleExplortationSolutionMap, other operations on the solution set will cause a - // NPE. - solMap.getSolutionMap(); - return solMap; - } - - /** - * Creates an energy minimization objective within the goal specification of the current DSE - * model. - */ - public static EnergyMinObjective addEnergyMinObjective(ExplorationSpecification targetSpec) { - EnergyMinObjective energyObjective = createEnergyMinObjective(); - ITopLevelElement modelContext = - IPersistencyService.getInstance().getTopLevelElementFor(targetSpec); - prepareUniqueID(energyObjective, targetSpec); - modelContext.runAsCommand(() -> targetSpec.getTargets().add(energyObjective)); - return energyObjective; - } - - /** - * Creates an {@link EnergyMinObjective} that minimizes the sum of the energy consumption that - * is specified by {@link LocationProperty}s. - */ - public static EnergyMinObjective createEnergyMinObjective() { - EnergyMinObjective energyObjective = PredefinedFactory.eINSTANCE.createEnergyMinObjective(); - energyObjective.setName("Energy Minimization"); - energyObjective.setPriority(0); - ObjectiveExpression optExpr = createObjectiveExpression(OptimizationDirectionEnum.MIN); - optExpr.setRight(createEnergyConsumptionSumExpression()); - energyObjective.setMoeaExpression(optExpr); - return energyObjective; - } - - /** - * Creates an {@link Expression} that provides the summed energy consumption of all allocated - * components. - */ - public static SummationOp<Double> createEnergyConsumptionSumExpression() { - SummationOp<Double> sumOp = createSummationOp(); - LocationProperty<Component, ExecutionUnit, Double> allocProp = - PatternsFactory.eINSTANCE.createLocationProperty(); - LocationOp<Component, ExecutionUnit> allocOp = - OperatorsFactory.eINSTANCE.createLocationOp(); - allocOp.setOperator(LocationOperatorEnum.ALLOCATION); - allocProp.setLocOp(allocOp); - sumOp.setRight(allocProp); - return sumOp; - } - - /** - * Creates a {@link FailureMinObjective} and adds it to the given - * {@link ExplorationSpecification}. - */ - public static FailureMinObjective addFailureMinObjective(ExplorationSpecification targetSpec) { - FailureMinObjective failureMinObjective = createFailureMinObjective(); - ITopLevelElement modelContext = - IPersistencyService.getInstance().getTopLevelElementFor(targetSpec); - prepareUniqueID(failureMinObjective, targetSpec); - modelContext.runAsCommand(() -> targetSpec.getTargets().add(failureMinObjective)); - return failureMinObjective; - } - - /** Creates a default {@link FailureMinObjective}. */ - public static FailureMinObjective createFailureMinObjective() { - FailureMinObjective failureMinObjective = - PredefinedFactory.eINSTANCE.createFailureMinObjective(); - failureMinObjective.setName("Failure Minimization"); - failureMinObjective.setType(FailureType.ALL); - failureMinObjective.setPriority(1); - failureMinObjective.setMoeaExpression(createFailureMinExpression()); - return failureMinObjective; - } - - /** - * Creates an {@link ObjectiveExpression} for {@link FailureMinObjective}s that aims to minimize - * the failure probability based on a {@link ReliabilityAnalysis}. - */ - public static ObjectiveExpression createFailureMinExpression() { - ReliabilityAnalysis relAnalysis = createReliabilityAnalysis(); - ObjectiveExpression objectiveExpr = - createObjectiveExpression(OptimizationDirectionEnum.MIN); - objectiveExpr.setRight(relAnalysis); - return objectiveExpr; - } - - /** - * Creates an {@link ReliabilityAnalysis} to analyze the reliability of the given - * {@link Component}. Used in {@link FailureMinObjective}s . - */ - public static ReliabilityAnalysis createReliabilityAnalysis() { - ReliabilityAnalysis relAnalysis = PredefinedFactory.eINSTANCE.createReliabilityAnalysis(); - return relAnalysis; - } - - /** - * Creates a fixed deployment constraint within the goal specification of the current DSE model. - */ - public static ComponentMultiAllocationConstraint addMultiComponentAllocationConstraint( - ExplorationSpecification targetSpec) { - ComponentMultiAllocationConstraint fixedDeploymentConstraint = - createComponentMultiAllocationConstraint(); - prepareUniqueID(fixedDeploymentConstraint, targetSpec); - ITopLevelElement modelContext = - IPersistencyService.getInstance().getTopLevelElementFor(targetSpec); - modelContext.runAsCommand(() -> targetSpec.getTargets().add(fixedDeploymentConstraint)); - return fixedDeploymentConstraint; - } - - /** Creates an {@link ComponentMultiAllocationConstraint} constraint. */ - public static ComponentMultiAllocationConstraint createComponentMultiAllocationConstraint( - Component comp, EList<ExecutionUnit> execUnits) { - ComponentMultiAllocationConstraint mCompAllocationConstraint = - createComponentMultiAllocationConstraint(); - mCompAllocationConstraint.setComponentMultiAllocations(comp, execUnits); - return mCompAllocationConstraint; - } - - /** Creates an "empty" {@link ComponentMultiAllocationConstraint} constraint. */ - public static ComponentMultiAllocationConstraint createComponentMultiAllocationConstraint() { - ComponentMultiAllocationConstraint mCompAllocationConstraint = - PredefinedFactory.eINSTANCE.createComponentMultiAllocationConstraint(); - mCompAllocationConstraint.setName("Component Allocation Constraint (1:n)"); - return mCompAllocationConstraint; - } - - /** - * Creates a {@link ComponentMultiDislocationConstraint} to the given - * {@link ExplorationSpecification}. - */ - public static ComponentMultiDislocationConstraint addComponentMultiDislocationConstraint( - ExplorationSpecification targetSpec) { - ComponentMultiDislocationConstraint multiComponentDislocationConstraint = - createComponentMultiDislocationConstraint(); - prepareUniqueID(multiComponentDislocationConstraint, targetSpec); - ITopLevelElement modelContext = - IPersistencyService.getInstance().getTopLevelElementFor(targetSpec); - modelContext.runAsCommand(() -> targetSpec.getTargets().add( - multiComponentDislocationConstraint)); - return multiComponentDislocationConstraint; - } - - /** Creates an "empty" {@link ComponentMultiDislocationConstraint}. */ - public static ComponentMultiDislocationConstraint createComponentMultiDislocationConstraint() { - ComponentMultiDislocationConstraint multiComponentDislocationConstraint = - PredefinedFactory.eINSTANCE.createComponentMultiDislocationConstraint(); - multiComponentDislocationConstraint.setName("Multi Component Dislocation Constraint (1:n)"); - return multiComponentDislocationConstraint; - } - - /** - * Creates a safety integrity level constraint within the goal specification of the current DSE - * model. - */ - public static SafetyIntegrityLevelConstraint addSafetyIntegrityLevelConstraint( - ExplorationSpecification targetSpec) { - SafetyIntegrityLevelConstraint safetyIntegrityLevelConstraint = - PredefinedFactory.eINSTANCE.createSafetyIntegrityLevelConstraint(); - safetyIntegrityLevelConstraint.setName("Safety Integrity Level Constraint"); - prepareUniqueID(safetyIntegrityLevelConstraint, targetSpec); - ITopLevelElement modelContext = - IPersistencyService.getInstance().getTopLevelElementFor(targetSpec); - modelContext - .runAsCommand(() -> targetSpec.getTargets().add(safetyIntegrityLevelConstraint)); - return safetyIntegrityLevelConstraint; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/ExplorationAlgDebugUtils.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/ExplorationAlgDebugUtils.java deleted file mode 100644 index f285ba15a3d7a8c0c49b403480714ebb4f33d688..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/ExplorationAlgDebugUtils.java +++ /dev/null @@ -1,123 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.util; - -import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.pickInstanceOf; - -import java.util.Collection; -import java.util.stream.Collectors; - -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.comm.constraint.InternalIsolatedCommunicationSet; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.TaskMappingEntry; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.taskmapping.abstractmapping.AbstractTaskMappingEncoding; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.genotype.ComposableGenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.ComposablePhenotype; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.phenotype.CompositePhenotype; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry; -import org.opt4j.core.genotype.CompositeGenotype; - -/** - * Collection of methods that are useful for debuggin purposes of the ExplorationAlg plugin, but not - * during normal operation. - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: B4ADC69BAF7049289957228D33C2D7A9 - */ -public class ExplorationAlgDebugUtils { - - /** - * TBD. - */ - public static <E extends TaskMappingEntry> boolean checkTaskMappingForSFConsistency( - TaskMappingEncoding<E> encoding) { - // TODO #checking: Implement this method in a generic manner to check the number of channels - // of safety functions with the entry number in the allocation encodings. - Collection<E> sfEs = - encoding.getMappingEntries() - .stream() - .filter(e -> e.getDeployableComponent().getName() - .contains("SafetyProtection")).collect(Collectors.toList()); - Collection<E> ioEs = - encoding.getMappingEntries().stream() - .filter(e -> e.getDeployableComponent().getName().contains("IOServer")) - .collect(Collectors.toList()); - - return sfEs.size() == ioEs.size(); - } - - /** - * Returns the set of all {@link ComposablePhenotype}s that are contained in the given - * {@link CompositePhenotype}, or any of its sub {@link CompositePhenotype}s. - * - * @param compositePhenotype - * {@link CompositePhenotype} whose child {@link ComposablePhenotype}s shall be - * identified. - * @return Set of <i>all</i> child {@link ComposablePhenotype}s. - */ - public static Collection<ComposablePhenotype<?>> getAllSubPhenotypes( - CompositePhenotype<?> compositePhenotype) { - Collection<ComposablePhenotype<?>> allSubPhenotypes = compositePhenotype.getSubPhenotypes(); - pickInstanceOf(CompositePhenotype.class, allSubPhenotypes).forEach( - p -> allSubPhenotypes.addAll(getAllSubPhenotypes(p))); - return allSubPhenotypes; - } - - /** - * Returns the set of all {@link ComposableGenotype}s that are contained in the given - * {@link CompositeGenotype}, or any of its sub {@link CompositeGenotype}s. - * - * @param compositeGenotype - * {@link CompositeGenotype} whose child {@link ComposableGenotype}s shall be - * identified. - * @return Set of <i>all</i> child {@link ComposableGenotype}s. - */ - public static Collection<ComposableGenotype> getAllSubGenotypes( - CompositeGenotype<?, ?> compositeGenotype) { - @SuppressWarnings("unchecked") Collection<ComposableGenotype> allSubGenotypes = - (Collection<ComposableGenotype>)compositeGenotype.values(); - pickInstanceOf(CompositeGenotype.class, allSubGenotypes).forEach( - p -> allSubGenotypes.addAll(getAllSubGenotypes(p))); - return allSubGenotypes; - } - - /** - * Checks whether all {@link IMappingEntry}s referenced in - * {@link InternalIsolatedCommunicationSet} constraints also exist in the allocation map of the - * given {@link AbstractTaskMappingEncoding}. - * - * @param encoding - * {@link AbstractTaskMappingEncoding} to examine for consistency. - * @return If the mapping is consistent w.r.t. the {@link InternalIsolatedCommunicationSet}. - */ - public static boolean mappingContainsAllIsolationCommEntries( - AbstractTaskMappingEncoding encoding) { - Collection<InternalIsolatedCommunicationSet> constrs = - encoding.getConstraintsOf(InternalIsolatedCommunicationSet.class); - for(InternalIsolatedCommunicationSet curConstr : constrs) { - for(IMappingEntry entry : curConstr.getIsolatedCommunicationSet()) { - if(!encoding.containsEntry(entry)) { - return false; - } - } - } - return true; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/ExplorationAlgUtils.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/ExplorationAlgUtils.java deleted file mode 100644 index 692ee697be1ffd14d56902b7847d12835f94aefc..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/ExplorationAlgUtils.java +++ /dev/null @@ -1,904 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExplorationAlgUtils.java 3788 2016-10-27 08:23:59Z barner $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.util; - -import static org.eclipse.emf.ecore.util.EcoreUtil.getAllContents; -import static org.fortiss.af3.exploration.alg.util.AF3Utils.isAnyParentDeploymentTarget; -import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.getReferencedElementsWithType; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getParentsWithType; - -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Set; -import java.util.Stack; -import java.util.function.Predicate; - -import org.conqat.lib.commons.reflect.ReflectionUtils; -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.Channel; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.component.model.InputPort; -import org.fortiss.af3.component.model.OutputPort; -import org.fortiss.af3.component.model.Port; -import org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution.TimeSlot; -import org.fortiss.af3.exploration.alg.exception.InvalidTimingModelException; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.IProblemDimension; -import org.fortiss.af3.platform.model.IPlatformResource; -import org.fortiss.af3.platform.model.IVirtualizationPlatformArchitectureElement; -import org.fortiss.af3.platform.model.annotation.ResourceLink; -import org.fortiss.af3.platform.utils.PlatformArchitectureUtils; -import org.fortiss.tooling.base.model.element.IHierarchicElement; -import org.fortiss.tooling.base.model.element.IHierarchicElementContainer; -import org.fortiss.tooling.base.model.element.IModelElement; -import org.fortiss.tooling.base.model.element.IModelElementSpecification; - -import com.google.common.collect.Multimap; - -/** - * Static utility methods mainly used in the Design Space Exploration. - * - * @author diewald - * @author $Author: barner $ - * @version $Rev: 3788 $ - * @ConQAT.Rating RED Hash: 64B8E1722C6214FDD71D77056383EEEA - */ -public class ExplorationAlgUtils { - - /** Constructor. Prevent initialization. */ - private ExplorationAlgUtils() { - } - - /** - * Returns the given Collection as a Collection of the raw types of its elements. - * - * @param origCollection - * Collection to be casted. - * @return Collection of the raw types of the input collection, or {@code null} if the - * Collection cannot be created. - */ - @SuppressWarnings("unchecked") - public static <C extends Collection<T>, T, CR extends Collection<? super T>> CR castToRawColl( - C origCollection) { - CR castedCollection = (CR)Collections.emptySet(); - if(origCollection != null && !origCollection.isEmpty()) { - try { - castedCollection = (CR)origCollection.getClass().newInstance(); - ((Collection<T>)castedCollection).addAll(origCollection); - } catch(InstantiationException | IllegalAccessException e) { - // Never here. - e.printStackTrace(); - } - } - return castedCollection; - } - - /** - * Returns the given Collection as a Collection of the raw types of its elements. - * - * @param origCollection - * Collection to be casted. - * @return Collection of the raw types of the input collection, or {@code null} if the - * Collection cannot be created. - */ - @SuppressWarnings("unchecked") - public static <C extends Collection<T>, T, CR extends Collection<? super T>> CR castToRawColl( - C origCollection, Class<CR> castedCollType) { - CR castedCollection = (CR)Collections.emptySet(); - if(origCollection != null && !origCollection.isEmpty()) { - try { - castedCollection = castedCollType.newInstance(); - ((Collection<T>)castedCollection).addAll(origCollection); - } catch(InstantiationException | IllegalAccessException e) { - // Never here. - e.printStackTrace(); - } - } - return castedCollection; - } - - /** - * For a given Object, determine whether it is a sub-class of any of the classes contained in - * the given collection. - */ - public static boolean isAssignableFromAny(Object obj, Collection<Class<?>> classes) { - return classes.stream().anyMatch(cls -> cls.isAssignableFrom(obj.getClass())); - } - - /** - * Finds the (target) {@link InputPort}s to which the given {@link OutputPort} is connected. - * 'Target Ports' are connected {@link InputPort}s of {@link Component}s from the set of - * {@code deployableComponents}. - * - * @param sourcePort - * The port to start the search from. - * @param deployableComponents - * Collection of 'deployable' {@link Component}s present in the input logical - * architecture. - * @return The list of target ports of atomic {@link Component}s. - */ - public static List<Port> findTargetPorts(OutputPort sourcePort, - Collection<Component> deployableComponents) { - if(!deployableComponents.contains(sourcePort.getComponent())) { - return Collections.emptyList(); - } - List<Port> targets = new ArrayList<>(); - LinkedList<Channel> exploreChannels = new LinkedList<Channel>(); - exploreChannels.addAll(sourcePort.getOutgoingChannels()); - while(!exploreChannels.isEmpty()) { - Channel currentExploreChannel = exploreChannels.removeFirst(); - Component currentTargetComponent = currentExploreChannel.getTarget().getComponent(); - if(deployableComponents.contains(currentTargetComponent)) { - targets.add(currentExploreChannel.getTarget()); - } else { - exploreChannels.addAll(currentExploreChannel.getTarget().getOutgoingChannels()); - } - } - return targets; - } - - /** - * Returns a list of source ports within the given {@link ComponentArchitecture}. Source ports - * are defined as ports that do not have direct inputs. - * - * @param componentArchitecture - * The {@link ComponentArchitecture} for whom source ports shall be identified. - * @return {@link EList} of source {@link OutputPort}s. - * @throws InvalidTimingModelException - * if the timing specification of any traversed element is inconsistent. - */ - public static EList<OutputPort> getSourcePorts(ComponentArchitecture componentArchitecture) - throws InvalidTimingModelException { - if(componentArchitecture == null) { - return null; - } - - EList<OutputPort> allOutputPortsInArch = - getChildrenWithType(componentArchitecture, OutputPort.class); - EList<OutputPort> sourcePortList = new BasicEList<OutputPort>(); - for(OutputPort currentOutputPort : allOutputPortsInArch) { - // Filter out ports that represent the transition through a hierarchic hull. - if(currentOutputPort.getIncoming().isEmpty() /* - * && - * !isAnyParentComponentDeployable( - * currentOutputPort.getComponent()) - */) { - // FIXME: HERE - sourcePortList.add(currentOutputPort); - } - } - - return sourcePortList; - } - - /** - * Returns the set of {@link OutputPort}s of all given 'deployable' {@link Component}s. - * - * @param deployableComponents - * Collection of all {@link OutputPort}s of 'deployable' {@link Component}s. - * @return List of 'deployable' {@link OutputPort}s or an empty list if none can be identified. - */ - public static EList<OutputPort> getDeployableOutputPorts( - Collection<Component> deployableComponents) { - EList<OutputPort> sourcePortList = new BasicEList<OutputPort>(); - - for(Component component : deployableComponents) { - sourcePortList.addAll(component.getOutputPorts()); - } - - return sourcePortList; - } - - /** - * Returns all Objects from the given Collection which inherit from the given class. - * - * @param targetClass - * Class providing the type filer. - * @param sourceColl - * Collection of Objects to be filtered. - * @return Collection of objects inheriting from the given class. - */ - @SuppressWarnings("unchecked") - public static <T> Collection<T> pickInstanceOf(Class<T> targetClass, Collection<?> sourceColl) { - Collection<T> filteredColl = new ArrayList<>(); - for(Object srcObj : sourceColl) { - if(targetClass.isAssignableFrom(srcObj.getClass())) { - filteredColl.add((T)srcObj); - } - } - return filteredColl; - } - - /** - * Returns the first found object from the given collection that inherits from the given class. - * - * @param targetClass - * Type to check the inheritance of the collection's objects. - * @param sourceColl - * Objects to examine. - * @return The first found object inheriting from the given class, or {@code null} if none is - * found. - */ - @SuppressWarnings("unchecked") - public static <T> T pickFirstInstanceOf(Class<T> targetClass, Collection<?> sourceColl) { - for(Object srcObj : sourceColl) { - if(targetClass.isAssignableFrom(srcObj.getClass())) { - return (T)srcObj; - } - } - return null; - } - - /** - * Returns all Classes from the given Collection which inherit from the given class. - * - * @param targetClass - * Class providing the type filer. - * @param sourceTypeColl - * Collection of Classes to be filtered. - * @return Collection of Classes inheriting from the given class. - */ - @SuppressWarnings("unchecked") - public static <T> Collection<Class<T>> pickSubTypesOf(Class<T> targetClass, - Collection<Class<?>> sourceTypeColl) { - Collection<Class<T>> filteredColl = new ArrayList<>(); - for(Class<?> srcType : sourceTypeColl) { - if(targetClass.isAssignableFrom(srcType)) { - filteredColl.add((Class<T>)srcType); - } - } - return filteredColl; - } - - /** - * Returns all Objects from the given Collection which inherit from the given collection of - * classes. - * - * @param filterClasses - * Class providing the type filer. - * @param unfilteredCollection - * Collection of Objects to be filtered. - * @return Collection of Classes that do not inherit from the given class. - */ - public static <T, S extends T> Collection<T> filterByTypeUnsafe( - Collection<Class<?>> filterClasses, Collection<T> unfilteredCollection) { - if(unfilteredCollection == null) { - return null; - } - - Collection<T> filteredCollection = new ArrayList<>(); - for(T element : unfilteredCollection) { - if(filterClasses.stream().anyMatch(c -> c.isAssignableFrom(element.getClass()))) { - filteredCollection.add(element); - } - } - return filteredCollection; - } - - /** - * Filters all Classes from the given Collection which inherit from the given class. - * - * @param targetClass - * Class providing the type filer. - * @param sourceTypeColl - * Collection of Classes to be filtered. - * @return Collection of Classes that do not inherit from the given class. - */ - @SuppressWarnings("unchecked") - public static <T> Collection<Class<T>> filterOutSubTypesOf(Class<T> targetClass, - Collection<Class<?>> sourceTypeColl) { - Collection<Class<T>> filteredColl = new ArrayList<>(); - for(Class<?> srcType : sourceTypeColl) { - if(!targetClass.isAssignableFrom(srcType)) { - filteredColl.add((Class<T>)srcType); - } - } - return filteredColl; - } - - /** - * Determines whether the given {@link IHierarchicElement} is relevant for the - * deployment exploration (atomic communication resources, deployment targets etc). - * - * @param element - * The element to be examined. - * @return Boolean indicating the relevance of of the given {@link IHierarchicElement} for the - * DSE. - */ - public static boolean isPlatformTargetResource(IPlatformResource element, - Collection<IPlatformResource> targetResources) { - if(!isAnyParentDeploymentTarget(element, targetResources) && - (element instanceof IHierarchicElementContainer && ((IHierarchicElementContainer)element) - .getContainedElements().isEmpty()) || targetResources.contains(element)) { - return true; - } - return false; - } - - /** - * Determines whether an {@link IPlatformResource} is a virtual platform element (like a - * partition). - * - * @param element - * The element to be examined. - * @return see above - */ - public static boolean isVirtualResource(IHierarchicElement element) { - if(element instanceof IVirtualizationPlatformArchitectureElement) { - return true; - } - - return false; - } - - /** - * Returns a list of child elements of the given type for each parent in the given collection. - * NOTE: This operation can be very costly, if elements are contained in the list which are far - * up in the hierarchy. - * - * @param parents - * Collection of parents to be examined. - * @param type - * The class to be filter for. - * @return List of child elements of the given type. - */ - public static <S> EList<S> getAllChildrenWithType(Collection<? extends EObject> parents, - Class<S> type) { - EList<S> childrenWithType = new BasicEList<S>(); - for(EObject currentParent : parents) { - childrenWithType.addAll(getChildrenWithType(currentParent, type)); - } - return childrenWithType; - } - - /** - * Determines whether the given hardware element is virtualized by a - * {@link IVirtualizationPlatformArchitectureElement}. - * - * @param element - * The hardware platform element to be examined. - * @param virtualizationProviders - * The (complete) collection of {@link IVirtualizationPlatformArchitectureElement}s - * present in the system. - * @return Boolean indicating the presence of a - * {@link IVirtualizationPlatformArchitectureElement} connected to the given - * hardware element. - */ - public static boolean hasVirtualizationLayer(IPlatformResource element, - Collection<IVirtualizationPlatformArchitectureElement> virtualizationProviders) { - Collection<IPlatformResource> selfAndParentElements = new HashSet<>(); - selfAndParentElements.add(element); - selfAndParentElements.addAll(getParentsWithType(element, IPlatformResource.class)); - - Collection<IPlatformResource> virtualizedResources = new HashSet<IPlatformResource>(); - for(IVirtualizationPlatformArchitectureElement currentVirtualizationProvider : virtualizationProviders) { - virtualizedResources.addAll(PlatformArchitectureUtils - .getResourceReferences((IModelElement)currentVirtualizationProvider)); - } - - return (Collections.disjoint(selfAndParentElements, virtualizedResources)) ? false : true; - } - - /** - * Collects and returns all {@link IModelElementSpecification}s of the given type which are - * contained in the specification list of the elements and their children which are referenced - * by a {@link ResourceLink} {@link IModelElementSpecification} of the given - * {@link IModelElement}. If no {@link ResourceLink} is specified for the given - * {@link IModelElement} or if no referenced {@link IModelElement} or one of its children - * contains a {@link IModelElementSpecification} of the given type, an empty list is returned. - * - * @param specType - * The {@link IModelElementSpecification} type to search for. - * @param modelElement - * {@link IModelElement} containing a {@link ResourceLink} to other - * {@link IModelElement}s. - * @return List of {@link IModelElementSpecification}s contained in the referenced - * {@link IModelElement}s or one of its children. - */ - public static <T extends IModelElementSpecification> List<T> - getAllReferencedSpecificationsWithType(Class<T> specType, IModelElement modelElement) { - List<T> specifications = new ArrayList<T>(); - if(modelElement == null) { - return specifications; - } - - Collection<IHierarchicElement> referencedElements = - getReferencedElementsWithType(modelElement, IHierarchicElement.class); - for(IHierarchicElement refElement : referencedElements) { - specifications.addAll(getChildrenWithType(refElement, specType)); - } - - return specifications; - } - - /** - * Returns the {@link ResourceLink} {@link IModelElementSpecification} of the given - * {@link IModelElement} or the {@link ResourceLink} or the {@link ResourceLink} of the parent - * {@link IModelElement} that is "closest" to the given {@link IModelElement} regarding the - * hierarchy. - * - * @param element - * The {@link IModelElement} which a matching (see above) {@link ResourceLink} shall - * be found. - * @return {@link ResourceLink} {@link IModelElementSpecification}, or <code>null</code> if - * neither the given {@link IModelElement}, nor any of its containing elements contains - * a {@link ResourceLink} {@link IModelElementSpecification}. - */ - public static ResourceLink getSelfOrAnyParentResourceLink(IModelElement element) { - ResourceLink resourceLink = - pickFirstInstanceOf(ResourceLink.class, element.getSpecifications()); - if(resourceLink == null) { - List<ResourceLink> parentResourceLinks = - getParentsWithType(element, ResourceLink.class); - if(!parentResourceLinks.isEmpty()) { - // List is ordered from the element itself to the top element -> find "closest" - // resource link of the given element. - resourceLink = parentResourceLinks.get(0); - } - } - return resourceLink; - } - - /** - * Determines whether the given {@link IHierarchicElement}s are contained within the - * same (parent) {@link IHierarchicElement}. - * - * @param elementA - * The first {@link IHierarchicElement} to be checked. - * @param elementB - * The {@link IHierarchicElement} to be checked against. - * @return see above. - */ - public static boolean haveSameParentElement(IHierarchicElement elementA, - IHierarchicElement elementB) { - return (elementA.getContainer() == elementB.getContainer()) ? true : false; - } - - /** - * Determines whether the given {@link IHierarchicElement}s are contained within the - * same (parent) {@link IHierarchicElement}s. This method is an extension to {#link - * haveSameParentElement(IHierarchicElement, IHierarchicElement)} which also considers the case - * where the given elements can be part of a virtual platform. - * - * @param elementA - * The first {@link IHierarchicElement} to be checked. - * @param elementB - * The {@link IHierarchicElement} to be checked against. - * @param virtualizationProviders - * The (complete) collection of {@link IVirtualizationPlatformArchitectureElement}s - * present in the - * system. - * @return see above. - */ - public static boolean haveSameParentHardwareElement(IHierarchicElement elementA, - IHierarchicElement elementB, - Collection<IVirtualizationPlatformArchitectureElement> virtualizationProviders) { - elementA = getReferencedElementsWithType(elementA, IHierarchicElement.class).get(0); - elementB = getReferencedElementsWithType(elementB, IHierarchicElement.class).get(0); - return (haveSameParentElement(elementA, elementB)) ? true : false; - } - - /** - * Creates a filtered list from a given list of superclasses of the filter class. - * - * @param generalList - * The list of superclasses of {#link filterClass} which will be filtered. - * @param filterClass - * The class by which the given list shall be filtered - * @return The filter list with elements of the type T - */ - @SuppressWarnings("unchecked") - public static <S, T extends S> EList<T> getElementsWithType(EList<S> generalList, - Class<T> filterClass) { - EList<T> filteredList = new BasicEList<T>(); - for(S listElement : generalList) { - if(filterClass.isAssignableFrom(listElement.getClass())) { - filteredList.add((T)listElement); - } - } - - return filteredList; - } - - /** - * Returns the List of <i>all</i> {@link TimeSlot}s that are predecessors of the given - * {@link TimeSlot}. Therefore, this method evaluates the predecessor field of {@link TimeSlot} - * s. - * - * @param timeSlot - * The {@link TimeSlot} for which the predecessors shall be identified. - * @return List of all predecessor {@link TimeSlot}s. - */ - public static List<TimeSlot> getAllPredecessorsOfTimeSlot(TimeSlot timeSlot) { - List<TimeSlot> predescessorList = new ArrayList<TimeSlot>(); - Queue<TimeSlot> toBeVisited = new LinkedList<TimeSlot>(); - toBeVisited.addAll(timeSlot.getPredecessors()); - while(!toBeVisited.isEmpty()) { - TimeSlot currentPredecessor = toBeVisited.poll(); - if(!predescessorList.contains(currentPredecessor)) { - predescessorList.add(currentPredecessor); - toBeVisited.addAll(currentPredecessor.getPredecessors()); - } - } - - return predescessorList; - } - - /** - * Returns the List of <i>all</i> {@link TimeSlot}s that are successors of the given - * {@link TimeSlot}. Therefore, this method evaluates the successor field of {@link TimeSlot}s. - * - * @param timeSlot - * The {@link TimeSlot} for which the successors shall be identified. - * @return List of all successor {@link TimeSlot}s. - */ - public static List<TimeSlot> getAllSuccessorsOfTimeSlot(TimeSlot timeSlot) { - List<TimeSlot> successorList = new ArrayList<TimeSlot>(); - Queue<TimeSlot> toBeVisited = new LinkedList<TimeSlot>(); - toBeVisited.addAll(timeSlot.getSuccessors()); - while(!toBeVisited.isEmpty()) { - TimeSlot currentPredecessor = toBeVisited.poll(); - if(!successorList.contains(currentPredecessor)) { - successorList.add(currentPredecessor); - toBeVisited.addAll(currentPredecessor.getSuccessors()); - } - } - - return successorList; - } - - /** - * Returns a collection of all child {@link EObject}s that have either of the given types. - * - * @param parent - * {@link EObject} to start the search from. - * @param typeList - * filter types for the child elements. - * @return Collection of child {@link EObject}s conforming to either of the given types. - */ - @SuppressWarnings("unchecked") - public static <T extends EObject> Collection<T> getChildrenWithTypes(EObject parent, - Collection<Class<?>> typeList, boolean isReflexive) { - Collection<T> children = new HashSet<T>(); - if(isReflexive && isAssignableFromAny(parent, typeList)) { - children.add((T)parent); - } - - TreeIterator<EObject> content = getAllContents(parent, true); - while(content.hasNext()) { - EObject child = content.next(); - if(isAssignableFromAny(child, typeList)) { - children.add((T)child); - } - } - return children; - } - - /** - * Debug method to search collections for strings. - * - * @param searchString - * The string for which the elements in the collection shall be evaluated against. - * @param objectCollection - * The collection of objects to be examined - * @return boolean, if any object's toString method contains the search string. - */ - public static boolean containsElementByString(String searchString, - Collection<?> objectCollection) { - for(Object obj : objectCollection) { - if(obj.toString().contains(searchString)) { - return true; - } - } - return false; - } - - /** - * Returns the superclass of the given element which implements the given interface. - * - * @param element - * The element whose implementing interface class shall be returned. - * @param superClass - * The interface class for which the superclasses of {#link element} shall be - * examined - * @return The first identified instance of a superclass implementing {#link superClass}, or - * {#code null} if none was found. - */ - @SuppressWarnings("unchecked") - public static <T> Class<T> getSuperClassOfImplementingInterface(EObject element, - Class<T> superClass) { - EList<EClass> superClasses = element.eClass().getESuperTypes(); - for(EClass currentSuperClass : superClasses) { - if(superClass.isAssignableFrom(currentSuperClass.getInstanceClass())) { - return (Class<T>)currentSuperClass.getInstanceClass(); - } - } - return null; - } - - /** - * Determines the {@link IProblemDimension} of the given {@link ExplorationTarget}. - * - * @param goal - * The {@link ExplorationTarget} whose {@link IProblemDimension} shall be identified. - * @return The {@link IProblemDimension} of the given {@link ExplorationTarget} or {#code null} - * if none is identified. - */ - public static <T extends IProblemDimension> Class<IProblemDimension> - getAssociatedDimensionFromGoal(ExplorationTarget<?> goal) { - return getSuperClassOfImplementingInterface(goal, IProblemDimension.class); - } - - /** - * Given an object that directly or indirectly inherits from the given interface, this method - * returns the substitution class type of the generic parameter of the given interface. - * <p> - * <b>NOTE:</b> This method works only for interfaces that have a single generic type parameter. - * <p> - * This method makes no assumptions about the location of the substitution in the class - * hierarchy. - * <p> - * <p> - * This method first identifies the path from the given object's class to the given interface in - * the class hierarchy. This path is then traversed and each found generic substitution is - * examined whether it substitutes the generic of the given interface. - * - * @param object - * Object for which the substitution type defined in the given class shall be found. - * @param interfaceClass - * Interface defining or redefining the generic type of interest. - * @return Class type substituting the generic parameter of the given interface. - */ - public static Class<?> - getSubstitutionTypeOfGenericIface(Object object, Class<?> interfaceClass) { - // First, identify the "hierarchy path" from the given object to the target interface. - LinkedList<Class<?>> inheritancePath = getClassPathToIface(object, interfaceClass); - - Stack<Type> paramTypeStack = new Stack<>(); - LinkedList<Class<?>> hierTraversalList = new LinkedList<>(); - hierTraversalList.addAll(inheritancePath); - - Type currParamRawType = null; - Predicate<Class<?>> targetIfaceFound = t -> t != null && t.isAssignableFrom(interfaceClass); - // Outer loop: Inspect the "hierarchy path". - do { - Class<?> hierStackElem = hierTraversalList.poll(); - Type[] genTypes = hierStackElem.getGenericInterfaces(); - LinkedList<Type> typesToTraverse = new LinkedList<>(); - typesToTraverse.addAll(Arrays.asList(genTypes)); - - // Inner loop: Inspect a single generic substitution. - while(!typesToTraverse.isEmpty() && !targetIfaceFound.test((Class<?>)currParamRawType)) { - Type currTraversedType = typesToTraverse.poll(); - paramTypeStack.add(currTraversedType); - - // Skip non-parameterized types (like other interfaces): Would be a wrong path. - if(currTraversedType instanceof ParameterizedType) { - currParamRawType = ((ParameterizedType)currTraversedType).getRawType(); - // Only follow the "path" of this generic parameter if it matches the previously - // identified path to the given interface. - if(inheritancePath.contains(currParamRawType)) { - Collection<Type> matchedTypes = - processParentParamerType(typesToTraverse, currParamRawType); - typesToTraverse.addAll(0, matchedTypes); - } - } else { - // Otherwise, remove the current parameter type from the "path" stack: It would - // lead to the generic of the interface. - paramTypeStack.pop(); - } - } - if(!targetIfaceFound.test((Class<?>)currParamRawType)) { - // This generic substitution was not the right one --> clean the "path". - paramTypeStack.clear(); - } - } while(!hierTraversalList.isEmpty() && !targetIfaceFound.test((Class<?>)currParamRawType)); - - // Return the class of the substituting parameter type. - if(targetIfaceFound.test((Class<?>)currParamRawType)) { - Type paramType = paramTypeStack.get(0); - if(paramType instanceof ParameterizedType) { - Type actParamType = ((ParameterizedType)paramType).getActualTypeArguments()[0]; - if(actParamType instanceof Class<?>) { - return (Class<?>)actParamType; - } else if(actParamType instanceof ParameterizedType) { - return (Class<?>)((ParameterizedType)actParamType).getRawType(); - } - } - } - - return null; - } - - /** - * Identifies the type parameter from the super classes/interface which matches the - * - * @param typesToTraverse - * @param rawType - */ - private static Collection<Type> processParentParamerType(LinkedList<Type> typesToTraverse, - Type rawType) { - Collection<Type> matchingTypes = new ArrayList<>(); - Type[] typeParams = ((Class<?>)rawType).getGenericInterfaces(); - Collection<Type> xT = Arrays.asList(((Class<?>)rawType).getTypeParameters()); - for(Type parentType : typeParams) { - if(parentType instanceof ParameterizedType) { - Type[] typeArgs = ((ParameterizedType)parentType).getActualTypeArguments(); - if(typeArgs.length == 1 && xT.contains(typeArgs[0])) { - matchingTypes.add(parentType); - } - } - } - return matchingTypes; - } - - /** - * Determines the path in the class hierarchy from the given object's class to the interface. It - * returns a list view on the identified path. - * <p> - * <b>NOTE:</b> The given object's class must be always below the given interface's class in the - * class hierarchy. Although this property is enforced if the second class is an interface, it - * is specifically noted here since normal classes and interface cannot be differentiated here. - * - * @param object - * Object inheriting from {@code interfaceClass}. - * @param interfaceClass - * Interface forming the top of the stack and defining the end of the path. - * @return Path between the given object's class and the given interface as a linked list. - */ - private static LinkedList<Class<?>> getClassPathToIface(Object object, Class<?> interfaceClass) { - LinkedList<Class<?>> traversalList = new LinkedList<>(); - Stack<Class<?>> hierarchyBrachStack = new Stack<>(); - LinkedList<Class<?>> ifacesTraversalList = new LinkedList<>(); - - ifacesTraversalList.addAll(Arrays.asList(object.getClass().getInterfaces())); - while(!ifacesTraversalList.isEmpty()) { - Class<?> currIface = ifacesTraversalList.poll(); - traversalList.add(currIface); - if(currIface.equals(interfaceClass)) { - break; - } - - Class<?>[] parentIfaces = currIface.getInterfaces(); - if(parentIfaces.length > 0) { - // Add candidate paths to the classes to traverse. If multiple candidate paths are - // found, remember the branch point. - // Note: always insert the parent interface at the top of the traversal list. - ifacesTraversalList.addAll(0, Arrays.asList(parentIfaces)); - if(parentIfaces.length > 1) { - hierarchyBrachStack.add(currIface); - } - } else { - // No more parent classes: Remove invalid path fragment from the stack (does not - // lead to the target interface). - int lastBranchIdx = 1; - if(!hierarchyBrachStack.isEmpty()) { - Class<?> lastHierBranch = hierarchyBrachStack.lastElement(); - traversalList.indexOf(lastHierBranch); - } - List<Class<?>> rmFromTravStrack = new ArrayList<>(); - rmFromTravStrack.addAll(traversalList.subList(lastBranchIdx, traversalList.size())); - traversalList.removeAll(rmFromTravStrack); - } - } - return traversalList; - } - - /** - * Returns the typed key from the map which is the best match for the given - * class. The best match is defined by the first match occurring in a breath - * first search of the inheritance tree, where the base class is always - * visited before the implemented interfaces. Interfaces are traversed in - * the order they are defined in the source file. The only exception is {@link Object}, which is - * considered only as the very last option. - * <p> - * As this lookup can be expensive (reflective iteration over the entire inheritance tree) the - * results should be cached if multiple lookups for the same class are expected. - * - * @param clazz - * the class being looked up. - * @param keySet - * the set of keys to perform the lookup in. - * @return the best match found or <code>null</code> if no matching key - * was found. Note that <code>null</code> will also be returned if - * the entry for the best matching class was <code>null</code>. - * - * Adapted from {@link ReflectionUtils#performNearestClassLookup(Class, Map)}. - */ - @SuppressWarnings("unchecked") - public static <K> Class<? extends K> performNearestClassLookup(Class<? extends K> clazz, - Set<Class<? extends K>> keySet) { - Queue<Class<? extends K>> q = new LinkedList<Class<? extends K>>(); - q.add(clazz); - - Class<? extends K> current = null; - while(!q.isEmpty()) { - current = q.poll(); - if(keySet.contains(current)) { - return current; - } - - Class<?> superClass = current.getSuperclass(); - if(superClass != null && superClass != Object.class) { - q.add((Class<? extends K>)superClass); - } - - for(Class<?> iface : current.getInterfaces()) { - q.add((Class<? extends K>)iface); - } - } - return current; - } - - /** - * Returns the value from the {@link Multimap}, whose key is the best match for the given - * class. The best match is defined by the first match occurring in a breath - * first search of the inheritance tree, where the base class is always - * visited before the implemented interfaces. Interfaces are traversed in - * the order they are defined in the source file. The only exception is {@link Object}, which is - * considered only as the very last option. - * <p> - * As this lookup can be expensive (reflective iteration over the entire inheritance tree) the - * results should be cached if multiple lookups for the same class are expected. - * - * - * @param clazz - * the class being looked up. - * @param classMap - * the {@link Multimap} to perform the lookup in. - * @return the best match found or the empty set if no matching entry - * was found. Note that the empty set will also be returned if - * the entry for the best matching class was the empty set. - * - * Adapted from {@link ReflectionUtils#performNearestClassLookup(Class, Map)}. - */ - public static <K, T> Collection<T> performNearestClassLookup(Class<? extends K> clazz, - Multimap<Class<? extends K>, T> classMap) { - Class<? extends K> key = performNearestClassLookup(clazz, classMap.keySet()); - return classMap.get(key); - } - - /** - * Takes a checked Exception and allows its usage in a RuntimeException based environment. - * - * @param exception - * Exception to wrap. - * @return not used, only rethrows the Exception. - * @throws T - * the original Exception. - */ - @SuppressWarnings("unchecked") - public static <T extends Exception> RuntimeException rethrow(Exception exception) throws T { - throw (T)exception; // rely on vacuous cast - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/ExplorationEcoreUtils.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/ExplorationEcoreUtils.java deleted file mode 100644 index d2502f226b4504d7999d2ccc4a863d79bd09f96d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/ExplorationEcoreUtils.java +++ /dev/null @@ -1,58 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExplorationEcoreUtils.java 3490 2016-09-13 11:39:58Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.util; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil.Copier; -import org.fortiss.tooling.kernel.utils.EcoreUtils; - -/** - * Utility methods for the interaction with EMF models (candidates to be moved into the - * {@link EcoreUtils} class). - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3490 $ - * @ConQAT.Rating RED Hash: 4A4BB45D2EEB3A65FFFF569F32D4EAD0 - */ -public class ExplorationEcoreUtils { - - /** Prevent instantiation. */ - private ExplorationEcoreUtils() { - } - - /** - * Returns a self-contained copy of the given <code>eObject</code>. - * Here, the copier that performs the copy operation must be given. The copier (which is a - * LinkedHashMap) can be further utilized to obtain information about the copied elements. - * - * @param eObject - * the object to copy. - * @param copier - * This copier will be used to perform the actual copy operation. - * @return the copy. - * @see Copier - */ - public static <T extends EObject> T copy(T eObject, Copier copier) { - EObject result = copier.copy(eObject); - copier.copyReferences(); - - @SuppressWarnings("unchecked") T t = (T)result; - return t; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/GraphUtils.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/GraphUtils.java deleted file mode 100644 index e70336e7472c872c398abfe6c40e3241683244ab..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/GraphUtils.java +++ /dev/null @@ -1,192 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: GraphUtils.java 3478 2016-09-09 09:54:32Z diewald $ -| | -| Copyright 2015 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.util; - -import static org.jgrapht.Graphs.predecessorListOf; -import static org.jgrapht.Graphs.successorListOf; - -import java.util.ArrayList; -import java.util.Collection; - -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.taskgraph.TaskGraph; -import org.jgrapht.DirectedGraph; -import org.jgrapht.Graph; -import org.jgrapht.Graphs; -import org.jgrapht.traverse.BreadthFirstIterator; - -/** - * Utility methods that extend the analysis capabilities for JGrapht graphs. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3478 $ - * @ConQAT.Rating RED Hash: 75C160B842E5F4700D0A4B19B9DD64F4 - */ -public class GraphUtils { - - /** Constructor. Prevent initialization. */ - private GraphUtils() { - } - - /** - * Return s the first found {@link Graph} from the given collection that contains the given - * vertex. - * - * @param vertex - * vertex to search for. - * @param graphCollection - * Collection of {@link Graph}s to be examined. - * @return First {@link Graph} containing the given vertex. - */ - public static <V, E> Graph<V, E> getGraphOf(V vertex, - Collection<? extends Graph<V, E>> graphCollection) { - for(Graph<V, E> graph : graphCollection) { - if(graph.containsVertex(vertex)) { - return graph; - } - } - return null; - } - - /** - * Returns the first found {@link TaskGraph} from the given collection that contains the given - * {@link IDeployableComponentAdapter}. - * - * @param vertex - * {@link IDeployableComponentAdapter} to search for. - * @param graphCollection - * Collection of {@link TaskGraph}s to be examined. - * @return First {@link TaskGraph} containing the given vertex. - */ - public static <T extends TaskGraph> T getGraphOf(IDeployableComponentAdapter<?> vertex, - Collection<T> graphCollection) { - for(T graph : graphCollection) { - if(graph.containsTask(vertex)) { - return graph; - } - } - // Fallback: get graph via the ref object. Must be in the same graph. - // FIXME: remove this fallback!!! - return getGraphByObjOf(vertex, graphCollection); - // return null; - } - - /** - * Returns the first found {@link TaskGraph} from the given collection that contains the given - * {@link IDeployableComponentAdapter}. The {@link TaskGraph} is identified by comparing the - * referenced objects of the contained tasks, which must be in the same graphs by construction. - * - * @param vertex - * {@link IDeployableComponentAdapter} to search for. - * @param graphCollection - * Collection of {@link TaskGraph}s to be examined. - * @return First {@link TaskGraph} containing the given vertex. - */ - public static <T extends TaskGraph> T getGraphByObjOf(IDeployableComponentAdapter<?> vertex, - Collection<T> graphCollection) { - for(T graph : graphCollection) { - for(IDeployableComponentAdapter<?> comp : graph.getTasks()) { - if(comp.getObject() == vertex.getObject()) { - return graph; - } - } - } - return null; - } - - /** - * Determines all predecessors of the given vertex, not just the direct ones as provided by the - * {@link Graphs} utility class. - * - * @param graph - * The graph containing the vertex {#link vertex}. - * @param vertex - * The vertex whose predecessors shall be determined. - * @return Collection of predecessor vertices. - */ - public static <V, E> Collection<V> getAllPredescesorsOf(DirectedGraph<V, E> graph, V vertex) { - Collection<V> predescessorList = new ArrayList<V>(); - ArrayList<V> workingQueue = new ArrayList<V>(); - workingQueue.addAll(Graphs.predecessorListOf(graph, vertex)); - while(!workingQueue.isEmpty()) { - V currentPredescessor = workingQueue.get(0); - workingQueue.remove(0); - - if(!predescessorList.contains(currentPredescessor)) { - predescessorList.add(currentPredescessor); - workingQueue.addAll(predecessorListOf(graph, currentPredescessor)); - } - } - return predescessorList; - } - - /** - * Determines all successors of the given vertex, not just the direct ones as provided by the - * {@link Graphs} utility class. - * - * @param graph - * The graph containing the vertex {#link vertex}. - * @param vertex - * The vertex whose successors shall be determined. - * @return Collection of successor vertices. - */ - public static <V, E> Collection<V> getAllSuccessorsOf(DirectedGraph<V, E> graph, V vertex) { - Collection<V> successorList = new ArrayList<V>(); - ArrayList<V> workingQueue = new ArrayList<V>(); - workingQueue.addAll(Graphs.successorListOf(graph, vertex)); - while(!workingQueue.isEmpty()) { - V currentSuccessor = workingQueue.get(0); - workingQueue.remove(0); - - if(!successorList.contains(currentSuccessor)) { - successorList.add(currentSuccessor); - workingQueue.addAll(successorListOf(graph, currentSuccessor)); - } - } - return successorList; - } - - /** - * Determines whether a path exists between the given vertices in the given - * {@link DirectedGraph}. - * - * @param graph - * {@link DirectedGraph} containing the vertices - * @param sourceVertex - * Vertex from which the search starts. - * @param endVertex - * Vertex to be searched for. - * @return boolean indication whether or not the given graph contains a (directed) path between - * source- and the end vertex. - */ - public static <V, E> boolean directedPathExisits(DirectedGraph<V, E> graph, V sourceVertex, - V endVertex) { - boolean pathExists = false; - BreadthFirstIterator<V, E> bfsIter = new BreadthFirstIterator<V, E>(graph, sourceVertex); - while(bfsIter.hasNext() && !pathExists) { - if(bfsIter.next() == endVertex) { - pathExists = true; - } - } - - return pathExists; - } - - // public static <V> Class<V> createDummyTypeVertex() -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/TransformationUtils.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/TransformationUtils.java deleted file mode 100644 index 2f98ac815f55031972871d63585427a00bb28e3e..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/alg/util/TransformationUtils.java +++ /dev/null @@ -1,425 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: TransformationUtils.java 3808 2016-11-02 08:51:03Z diewald $ -| | -| Copyright 2014 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.alg.util; - -import static org.fortiss.af3.component.utils.ComponentModelElementFactory.createChannelAndAttach; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; - -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.fortiss.af3.component.model.Channel; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.component.model.InputPort; -import org.fortiss.af3.component.model.OutputPort; -import org.fortiss.af3.component.model.Port; -import org.fortiss.af3.component.utils.ComponentModelElementFactory; -import org.fortiss.af3.deployment.model.Deployment; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.EMFModelConcurrencyHandler; -import org.fortiss.af3.exploration.alg.dse.modeltransformation.ITransformationModule; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; -import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEncoding; -import org.fortiss.af3.exploration.alg.exception.TransformationModuleException; -import org.fortiss.af3.platform.model.PlatformArchitecture; -import org.fortiss.tooling.base.model.layout.Dimension; -import org.fortiss.tooling.base.model.layout.EOrientation; -import org.fortiss.tooling.base.model.layout.ILayoutData; -import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; -import org.fortiss.tooling.base.model.layout.Point; -import org.fortiss.tooling.base.utils.OffsetOrientationUtils; -import org.fortiss.tooling.kernel.model.INamedElement; - -import com.google.common.collect.Multimap; - -/** - * Utility methods for transforming DSE-internal models to AF3 models. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3808 $ - * @ConQAT.Rating RED Hash: 6B9BE839721175731A1FB29A00FD5556 - */ -public class TransformationUtils { - - /** Constructor. Prevent initialization. */ - private TransformationUtils() { - } - - /** - * Returns a list of target ports within the given {@link ComponentArchitecture}. Target ports - * are defined as ports that do not have direct outputs. - * - * @param componentArchitecture - * The {@link ComponentArchitecture} for whom source ports shall be identified. - * @return {@link EList} of target {@link InputPort}s. - */ - public static EList<InputPort> getTargetPorts(ComponentArchitecture componentArchitecture) { - if(componentArchitecture == null) { - return null; - } - - EList<InputPort> allOutputPortsInArch = - getChildrenWithType(componentArchitecture, InputPort.class); - EList<InputPort> targetPortList = new BasicEList<InputPort>(); - for(InputPort currentOutputPort : allOutputPortsInArch) { - // Filter out ports that represent the transition through a hierarchic hull. - if(currentOutputPort.getOutgoing().isEmpty()) { - targetPortList.add(currentOutputPort); - } - } - - return targetPortList; - } - - /** - * Creates an identical copy of a given {@link InputPort}. Used for the replication of logical - * architectures. - * - * @param referencePort - * The {@link InputPort} to be replicated. - * @param replicationOwner - * The {@link Component} to which the replicated {@link InputPort} shall be attached - * to. - * @param portName - * The name of the replicated port {@link InputPort} (NB: It must be different to the - * original name if attached to the same {@link Component}. Otherwise the containing - * architecture is invalid. - * @return The replicated {@link InputPort}. - */ - public static InputPort replicateInputPortAndAttach(Port referencePort, - Component replicationOwner, String portName) { - InputPort replicatedInputPort = - ComponentModelElementFactory.createInputPort(portName, referencePort.getComment()); - replicatedInputPort.getSpecifications().clear(); - replicatedInputPort.getSpecifications().addAll( - EcoreUtil.copyAll(referencePort.getSpecifications())); - - replicationOwner.getConnectors().add(replicatedInputPort); - - return replicatedInputPort; - } - - /** - * Creates an identical copy of a given {@link OutputPort}. Used for the replication of logical - * architectures. - * - * @param referencePort - * The {@link OutputPort} to be replicated. - * @param replicationOwner - * The {@link Component} to which the replicated {@link OutputPort} shall be attached - * to. - * @param portName - * The name of the replicated port {@link OutputPort} (NB: It must be different to - * the original name if attached to the same {@link Component}. Otherwise the - * containing architecture is invalid. - * @return The replicated {@link OutputPort}. - */ - public static OutputPort replicateOutputPortAndAttach(Port referencePort, - Component replicationOwner, String portName) { - OutputPort replicatedOutputPort = - ComponentModelElementFactory.createOutputPort(portName, referencePort.getComment()); - replicatedOutputPort.getSpecifications().clear(); - replicatedOutputPort.getSpecifications().addAll( - EcoreUtil.copyAll(referencePort.getSpecifications())); - - replicationOwner.getConnectors().add(replicatedOutputPort); - - return replicatedOutputPort; - } - - /** - * Sets the position of the generated {@link Component} with some offset to the position of the - * original, i.e. source, {@link Component}. - */ - public static void setGenComponentPos(Component sourceComponent, Component generatedComponent) { - if(generatedComponent != null && - generatedComponent.getLayoutData().get(0) instanceof Point && - sourceComponent.getLayoutData().get(0) instanceof Point) { - Point p = (Point)sourceComponent.getLayoutData().get(0); - p = calulateOffset(p, sourceComponent, 5, false, false); - generatedComponent.getLayoutData().set(0, p); - } - } - - /** - * Adds the suffix that denotes the replication number to the given instantiated element. - * - * @param origElement - * Element of the original input model. - * @param abstractElement - * "Abstract", replicated, element from the generated model. - * @param instantiatedElement - * Instantiated element from the element library. - */ - public static void setReplicaAwareInstElementName(INamedElement origElement, - INamedElement abstractElement, INamedElement instantiatedElement) { - String suffix = abstractElement.getName().replace(origElement.getName(), ""); - instantiatedElement.setName(instantiatedElement.getName() + suffix); - } - - /** - * Calculates a point (at which a component can be placed) by the using the information about - * the {@link Dimension}s of the {#code refenceComponent} and an additional offset. The boolean - * parameters are used to determine whether the dimension of the {@code referenceComponent} in - * the one or the other direction shall be taken into account. - * NOTE: negative values in the parameter {#code offsetDistance} cause a shift to the upper - * left, otherwise to the lower right. - */ - public static Point calulateOffset(Point pointToMove, Component referenceComponent, - int offsetDistance, boolean horizontalOffset, boolean verticalOffset) { - int xOffsetToReferenceComponent = 0; - int yOffsetToReferenceComponent = 0; - - // Retrieve the information about the dimensions of the parent Component, if this - // information is relevant for the shift. - ILayoutData dimensionOfReplicatedComponent = referenceComponent.getLayoutData().get(1); - if(dimensionOfReplicatedComponent instanceof Dimension) { - if(horizontalOffset) { - xOffsetToReferenceComponent = - ((Dimension)dimensionOfReplicatedComponent).getWidth(); - } - if(verticalOffset) { - yOffsetToReferenceComponent = - ((Dimension)dimensionOfReplicatedComponent).getHeight(); - } - } - - // Consider the dimensions of the referenced Component as an additional shift to the left, - // if the offset variable defines a shift to the left. - if(offsetDistance < 0) { - xOffsetToReferenceComponent = -xOffsetToReferenceComponent; - yOffsetToReferenceComponent = -yOffsetToReferenceComponent; - } - - // Calculate the coordinates of the shifted point that will be returned. - pointToMove.setX(pointToMove.getX() + xOffsetToReferenceComponent + offsetDistance); - pointToMove.setY(pointToMove.getY() + yOffsetToReferenceComponent + offsetDistance); - - return pointToMove; - } - - /** - * Creates a set of {@link Channel}s that connects the given {#link generatedPort} with the - * {#link connectedPorts}. The given {#link parentComponent} will contain the resulting set of - * {@link Channel}s. - */ - public static <T extends Port, S extends Port> void connectPort(T generatedPort, - Collection<S> connectedPorts, Component parentComponent) { - for(S currentPortToBeConnected : connectedPorts) { - // Depending on the port type (input, output), we need to swap the creation of the - // Channel's sources and targets. - if(generatedPort instanceof InputPort) { - createChannelAndAttach(parentComponent.getParentComponent(), "", - currentPortToBeConnected, generatedPort); - } else if(generatedPort instanceof OutputPort) { - createChannelAndAttach(parentComponent.getParentComponent(), "", generatedPort, - currentPortToBeConnected); - } - } - } - - /** - * Returns the set of {@link IDeployableComponentAdapter}s that is defined by the given - * {@link IMappingEncoding}. This method is intended to be used within - * {@link ITransformationModule}s. - * - * @param tModule - * Calling {@link ITransformationModule}. - * @param mapping - * {@link IMappingEncoding} that encodes the deployed - * {@link IDeployableComponentAdapter}s. - * @return Collection of deployable {@link IDeployableComponentAdapter}s. - * @throws TransformationModuleException - * If one {@link IDeployableComponentAdapter} of the mapping does not wrap an AF3 - * {@link Component} but any other object. - */ - public static Collection<IDeployableComponentAdapter<Component>> retrieveDeployableComponents( - ITransformationModule<?> tModule, IMappingEncoding mapping) - throws TransformationModuleException { - Collection<IDeployableComponentAdapter<Component>> deplCompAdps = new ArrayList<>(); - for(IDeployableComponentAdapter<?> comp : mapping.getDeployedComponents()) { - if(comp.getObject() instanceof Component) { - @SuppressWarnings("unchecked") IDeployableComponentAdapter<Component> castComp = - (IDeployableComponentAdapter<Component>)comp; - deplCompAdps.add(castComp); - } else { - throw new TransformationModuleException(tModule, - "Error. The ComponentAdapter from the DSE is not an adapter for an AF3 component."); - } - } - - return deplCompAdps; - } - - /** - * Returns a {@link Map} that associates the Components of the given Architecture with the - * {@link IDeployableComponentAdapter}s from the exploration. - * - * @throws TransformationModuleException - * if a {@link Component} from the original {@link ComponentArchitecture} cannot be - * associated with one, but only one, Component in the output architecture. - */ - // TODO: update doc. - public static Map<IDeployableComponentAdapter<Component>, Component> getDeployableComponentMap( - ITransformationModule<?> tModule, Multimap<EObject, EObject> origToGenAssocMap, - Collection<IDeployableComponentAdapter<Component>> deplCompCollection) - throws TransformationModuleException { - Map<IDeployableComponentAdapter<Component>, Component> deployableComponentsOfReplicatedArch = - new ConcurrentHashMap<>(); - for(IDeployableComponentAdapter<Component> deployableComponent : deplCompCollection) { - Component correspondingAF3Component = deployableComponent.getObject(); - if(deployableComponent.isInstantiation()) { - correspondingAF3Component = deployableComponent.getReplacedComponent().getObject(); - } - Collection<EObject> genComponentColl = origToGenAssocMap.get(correspondingAF3Component); - if(genComponentColl == null || genComponentColl.isEmpty()) { - throw new TransformationModuleException(tModule, - "No generated Component that is association with the Component " + - correspondingAF3Component.getName() + " has been found."); - } else if(genComponentColl.size() > 1) { - throw new TransformationModuleException( - tModule, - "More than one generated Component that are associated with the original Component " + - correspondingAF3Component.getName() + - " have been found. This is not supported in this stage of the transformation."); - } - - Component deployableAF3Component = (Component)genComponentColl.stream().findAny().get(); - deployableComponentsOfReplicatedArch.put(deployableComponent, deployableAF3Component); - } - return deployableComponentsOfReplicatedArch; - } - - /** - * Arranges the given {@link Port}s such that they are placed with equal distances either on - * left or the right side of the given {@link Component}. The given {@link Component} must be - * the owner of all ports given in the list. - */ - public static void arrangePorts(EList<? extends Port> connectorsToArrange, - ILayoutedModelElement parentElement) { - if(parentElement.getLayoutData().get(1) instanceof Dimension) { - int voterHeight = ((Dimension)parentElement.getLayoutData().get(1)).getHeight(); - float distanceBetweenPorts = voterHeight / (connectorsToArrange.size() + 1); - float currentPortOffset = distanceBetweenPorts / 2; - - for(Port currentPort : connectorsToArrange) { - EOrientation inOutOrientation; - if(currentPort instanceof OutputPort) { - inOutOrientation = EOrientation.EAST; - } else { - inOutOrientation = EOrientation.WEST; - } - OffsetOrientationUtils.setOffsetOrientation(currentPort, "coffsetorientation", - (int)currentPortOffset, inOutOrientation); - - currentPortOffset = currentPortOffset + distanceBetweenPorts; - } - } - } - - /** - * Corrects the cross references between two generated models such that they do not point to the - * original model elements but the generated ones. - * - * @param originalElements - * Elements from the original model to which elements from generated models might - * point. - * @param generatedElements - * Elements from generated model to which other model elements shall possibly point - * instead. - * @param origToGenAssocMap - * Map associating "original" elements with their corresponding element(s) in the - * generated models. - * @param genToOrigAssocMap - * Map associating the "generated" elements with their corresponding element in the - * original model. - */ - public static void correctInterModelReferences(Collection<EObject> originalElements, - Collection<EObject> generatedElements, Multimap<EObject, EObject> origToGenAssocMap, - Map<EObject, EObject> genToOrigAssocMap) { - for(EObject originalObj : originalElements) { - assert (origToGenAssocMap.get(originalObj) != null); - EObject generatedObj = origToGenAssocMap.get(originalObj).stream().findAny().get(); - Collection<EReference> origReferences = originalObj.eClass().getEReferences(); - origReferences = - origReferences.stream().filter(r -> !r.isContainment()) - .collect(Collectors.toList()); - for(EReference curReference : origReferences) { - EObject referencedObj = (EObject)originalObj.eGet(curReference); - assert (origToGenAssocMap.get(referencedObj) != null); - Optional<EObject> generatedReferencedObj = - origToGenAssocMap.get(referencedObj).stream().findAny(); - if(generatedReferencedObj.isPresent()) { - generatedObj.eSet(curReference, generatedReferencedObj.get()); - } - } - } - - for(EObject generatedObj : genToOrigAssocMap.keySet()) { - if(generatedElements.contains(generatedObj)) { - EObject originalObj = genToOrigAssocMap.get(generatedObj); - if(originalObj != null) { - Collection<EReference> origReferences = originalObj.eClass().getEReferences(); - origReferences = - origReferences.stream().filter(r -> !r.isContainment()) - .collect(Collectors.toList()); - for(EReference curReference : origReferences) { - EObject referencedObj = (EObject)originalObj.eGet(curReference); - if(referencedObj == originalObj) { - originalObj.eSet(curReference, generatedObj); - } - } - } - } - } - } - - /** - * Reset the references to the {@link ComponentArchitecture} and {@link PlatformArchitecture} in - * the given temporary {@link Deployment} (that is not hooked to the project resource) in order - * to avoid dangling references from the Component/PlatformArchitecture's EOpposite references. - * - * If the given {@link Deployment} is a local variable (i.e., in particular, if its - * {@code eContainer} is not set, it will be will be garbage-collected when the corresponding - * method returns. - * - * @param deployment - * (Temporary) {@link Deployment} for which Component/PlatformArchitecture references - * should be reset. - */ - public static void resetDeploymentReferences(Deployment deployment) { - if(deployment == null) { - return; - } - - EMFModelConcurrencyHandler.getInstance().resetReference( - deployment.getComponentArchitectureReference()); - EMFModelConcurrencyHandler.getInstance().resetReference( - deployment.getPlatformArchitectureReference()); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/dsl/model/patterns/impl/ElementPropertyStaticImpl.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/dsl/model/patterns/impl/ElementPropertyStaticImpl.java deleted file mode 100644 index de4400a9e89985152148fe5cca814e0a452f58a3..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/dsl/model/patterns/impl/ElementPropertyStaticImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ElementPropertyStaticImpl.java 3175 2016-07-04 15:25:48Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.dsl.model.patterns.impl; - -import java.util.function.Function; - -import org.fortiss.af3.exploration.dsl.model.patterns.ElementProperty; -import org.fortiss.tooling.base.model.element.IModelElement; - -/** - * Static method implementations for {@link ElementProperty}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3175 $ - * @ConQAT.Rating RED Hash: 69F3C2837A82885469BD94FC694E42BE - */ -public class ElementPropertyStaticImpl { - - /** Static implementation of the method {@link ElementProperty#getProperty()} using lambdas. */ - public static <T, ME extends IModelElement> T getProperty(ElementProperty<ME, T> pattern) { - // FIXME: in the model, there should be a type definition for the java type "Function" to be - // type-safer. - Function<ME, T> propRetrievalFunc = pattern.getPropertyGetter(); - if(propRetrievalFunc != null) { - ME modelElement = pattern.getModelElement(); - if(modelElement != null) { - return propRetrievalFunc.apply(modelElement); - } - } - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/migration/ExpTargetMigrator.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/migration/ExpTargetMigrator.java deleted file mode 100644 index 5010c433ada1e9ca3f4a1663860d316c51504944..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/migration/ExpTargetMigrator.java +++ /dev/null @@ -1,314 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExpTargetMigrator.java 3382 2016-08-08 15:26:54Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.migration; - -import static org.fortiss.af3.exploration.alg.util.DesignSpaceExplorationModelElementFactory.createComponentMultiAllocationConstraint; -import static org.fortiss.af3.exploration.alg.util.DesignSpaceExplorationModelElementFactory.createComponentMultiDislocationConstraint; -import static org.fortiss.af3.exploration.alg.util.DesignSpaceExplorationModelElementFactory.createEnergyMinObjective; -import static org.fortiss.af3.exploration.alg.util.DesignSpaceExplorationModelElementFactory.createFailureMinObjective; -import static org.fortiss.af3.exploration.util.CommonExplorationTagetModelElementFactory.createComponentAllocationConstraint; -import static org.fortiss.af3.exploration.util.CommonExplorationTagetModelElementFactory.createComponentDislocationConstraint; -import static org.fortiss.af3.project.utils.ProjectUtils.getFileProject; -import static org.fortiss.tooling.base.utils.MigrationUtils.migrateINamedCommentedElement; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstChildWithType; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.ecore.xml.type.AnyType; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.exploration.model.DesignSpaceExploration; -import org.fortiss.af3.exploration.model.ExcludeDeploymentConstraint; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.FixedDeploymentConstraint; -import org.fortiss.af3.exploration.model.location.ComponentAllocationConstraint; -import org.fortiss.af3.exploration.model.location.ComponentDislocationConstraint; -import org.fortiss.af3.exploration.model.time.DeadlineConstraint; -import org.fortiss.af3.exploration.model.time.TimeFactory; -import org.fortiss.af3.exploration.moea.model.DseSpecification; -import org.fortiss.af3.exploration.moea.model.ExplorationManager; -import org.fortiss.af3.exploration.moea.model.MoeaFactory; -import org.fortiss.af3.exploration.moea.model.parameters.EAOptimizer; -import org.fortiss.af3.exploration.moea.model.parameters.ExecutionModel; -import org.fortiss.af3.exploration.moea.model.parameters.ParametersFactory; -import org.fortiss.af3.exploration.moea.model.parameters.SystemParameters; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiAllocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiDislocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.EnergyMinObjective; -import org.fortiss.af3.exploration.moea.model.predefined.FailureMinObjective; -import org.fortiss.af3.exploration.moea.model.predefined.PredefinedFactory; -import org.fortiss.af3.exploration.moea.model.predefined.SafetyIntegrityLevelConstraint; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.af3.project.model.FileProject; -import org.fortiss.tooling.kernel.extension.IMigrationProvider; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; -import org.fortiss.tooling.kernel.model.IProjectRootElement; - -/** - * {@link IMigrationProvider} to separate the existing concrete {@link ExplorationTarget}s from the - * exploration.ecore that shall only contain the meta-model framework in future. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3382 $ - * @ConQAT.Rating RED Hash: 3916135E9F817DADDA281A7BD6931D85 - */ -@SuppressWarnings("deprecation") -public class ExpTargetMigrator implements IMigrationProvider { - - /** {@inheritDoc} */ - @Override - public boolean needMigration(ITopLevelElement modelElement, - Map<EObject, AnyType> unknownFeatures) { - EObject rootModelElement = modelElement.getRootModelElement(); - if(rootModelElement instanceof FileProject) { - EList<IProjectRootElement> topLvlElements = - ((FileProject)rootModelElement).getRootElements(); - for(IProjectRootElement currPrjRootElement : topLvlElements) { - if(currPrjRootElement instanceof org.fortiss.af3.exploration.model.ExplorationManager) { - return true; - } - } - } - return false; - } - - /** {@inheritDoc} */ - @Override - public void migrate(ITopLevelElement modelElement, Map<EObject, AnyType> unknownFeatures) { - org.fortiss.af3.exploration.model.ExplorationManager oldManager = - getFirstChildWithType(modelElement.getRootModelElement(), - org.fortiss.af3.exploration.model.ExplorationManager.class); - - // Migrate the contained DesignSpaceExploration models. - EList<DesignSpaceExploration> oldDesignSpaceExploration = oldManager.getDseModel(); - EList<DseSpecification> newDseSpecificationList = new BasicEList<>(); - for(DesignSpaceExploration currentDSE : oldDesignSpaceExploration) { - DseSpecification newDseSpecification = migrateDesignSpaceExploration(currentDSE); - // EList<ExplorationTarget<?>> newTargetList = - // newDseSpecification.getTargetSpecification().getTargets(); - // Migrate the ExplorationSpecification. - EList<ExplorationTarget<?>> targetList = - currentDSE.getTargetSpecification().getTargets(); - Collection<ExplorationTarget<?>> additionList = new ArrayList<>(); - Collection<ExplorationTarget<?>> removalList = new ArrayList<>(); - for(ExplorationTarget<?> currTarget : targetList) { - ExplorationTarget<?> newTarget = null; - // Constraint-specific migration methods. - // NOTE: Period constraints are not migrated, no information is contained in them - // that is worth preserving, they are deduced from a timing model. - if(currTarget instanceof org.fortiss.af3.exploration.model.EnergyMinObjective) { - newTarget = - migrateEnergyMin((org.fortiss.af3.exploration.model.EnergyMinObjective)currTarget); - } else if(currTarget instanceof org.fortiss.af3.exploration.model.FailureMinObjective) { - newTarget = - migrateFailureMin((org.fortiss.af3.exploration.model.FailureMinObjective)currTarget); - } else if(currTarget instanceof org.fortiss.af3.exploration.model.FixedDeploymentConstraint) { - newTarget = - migrateFixedDeploymentConstraint((org.fortiss.af3.exploration.model.FixedDeploymentConstraint)currTarget); - } else if(currTarget instanceof org.fortiss.af3.exploration.model.ExcludeDeploymentConstraint) { - newTarget = - migrateExcludeDeploymentConstraint((org.fortiss.af3.exploration.model.ExcludeDeploymentConstraint)currTarget); - } else if(currTarget instanceof org.fortiss.af3.exploration.model.time.DeadlineConstraint) { - newTarget = - migrateDeadlineConstraint((org.fortiss.af3.exploration.model.DeadlineConstraint)currTarget); - } else if(currTarget instanceof org.fortiss.af3.exploration.model.SafetyIntegrityLevelConstraint) { - newTarget = - migrateSILConstraint((org.fortiss.af3.exploration.model.SafetyIntegrityLevelConstraint)currTarget); - } - - if(newTarget != null) { - additionList.add(newTarget); - } else { - // Copy due to containment, otherwise the ExplorationTaget is removed from the - // collection over which we are iterating leading to a - // ConcurrentModificationException. - additionList.add(EcoreUtil.copy(currTarget)); - } - removalList.add(currTarget); - } - newDseSpecification.getTargetSpecification().getTargets().clear(); - newDseSpecification.getTargetSpecification().getTargets().addAll(additionList); - newDseSpecificationList.add(newDseSpecification); - } - // Migrate the Exploration Manager. - ExplorationManager newManager = - migrateExplorationManager(oldManager, newDseSpecificationList); - // Delete the old Exploration Manger (and its contatnts) and add the new one to the - // FileProject. - FileProject parentProject = getFileProject(oldManager); - EcoreUtil.delete(oldManager); - parentProject.getRootElements().add(newManager); - } - - /** - * Migrates an {@link org.fortiss.af3.exploration.model.ExplorationManager} and sets the given - * set of already migrated {@link DseSpecification}s. - */ - @SuppressWarnings("javadoc") - private ExplorationManager migrateExplorationManager( - org.fortiss.af3.exploration.model.ExplorationManager oldManager, - EList<DseSpecification> newDseSpecifications) { - ExplorationManager newManager = MoeaFactory.eINSTANCE.createExplorationManager(); - migrateINamedCommentedElement(oldManager, newManager); - newManager.getDseSpecifications().addAll(newDseSpecifications); - return newManager; - } - - /** - * Migrates a {@link DesignSpaceExploration} element to a {@link DseSpecification} (new naming - * and location). - */ - @SuppressWarnings("javadoc") - private DseSpecification migrateDesignSpaceExploration(DesignSpaceExploration oldParameters) { - DseSpecification newDseSpec = MoeaFactory.eINSTANCE.createDseSpecification(); - newDseSpec.setName(oldParameters.getName()); - newDseSpec.setId(oldParameters.getId()); - // Optimizer attribute. - if(oldParameters.getOptimizer() instanceof org.fortiss.af3.exploration.model.EAOptimizer) { - org.fortiss.af3.exploration.model.EAOptimizer oldEAOptimizer = - (org.fortiss.af3.exploration.model.EAOptimizer)oldParameters.getOptimizer(); - newDseSpec.setOptimizer(migrateEAOptimizer(oldEAOptimizer)); - } - // Parameter attribute. - if(oldParameters.getParameters() != null) { - org.fortiss.af3.exploration.model.DSEParameters oldDseParameters = - oldParameters.getParameters(); - newDseSpec.setParameters(migrateDseParameters(oldDseParameters)); - } - // Target specification refrence (remains the same). - if(oldParameters.getTargetSpecification() != null) { - // We need to copy the target specification due to the containment. The contained - // ExplorationTargets are migrated in the parent migrate method. - ExplorationSpecification copiedTargetSpec = - copy(oldParameters.getTargetSpecification()); - newDseSpec.setTargetSpecification(copiedTargetSpec); - } - return newDseSpec; - } - - /** Migrates an {@link EAOptimizer} due to its new location. */ - private EAOptimizer migrateEAOptimizer( - org.fortiss.af3.exploration.model.EAOptimizer oldEAOptimizer) { - EAOptimizer newEAOptimizer = ParametersFactory.eINSTANCE.createEAOptimizer(); - newEAOptimizer.setAlpha(oldEAOptimizer.getAlpha()); - newEAOptimizer.setIterations(oldEAOptimizer.getIterations()); - newEAOptimizer.setParallelExecution(oldEAOptimizer.isParallelExecution()); - newEAOptimizer.setSpea2Tournament(oldEAOptimizer.getSpea2Tournament()); - return newEAOptimizer; - } - - /** - * Migrates a {@link org.fortiss.af3.exploration.model.DSEParameters} element to a - * {@link SystemParameters} (new naming and location). - */ - @SuppressWarnings("javadoc") - private SystemParameters migrateDseParameters( - org.fortiss.af3.exploration.model.DSEParameters oldParameters) { - SystemParameters newParameters = ParametersFactory.eINSTANCE.createSystemParameters(); - String oldParameterLiteral = oldParameters.getExecutionModel().getLiteral(); - newParameters.setExecutionModel(ExecutionModel.get(oldParameterLiteral)); - return newParameters; - } - - /** Migrates the {@link EnergyMinObjective} to its new ecore representation. */ - private EnergyMinObjective migrateEnergyMin( - org.fortiss.af3.exploration.model.EnergyMinObjective oldObjective) { - EnergyMinObjective newObjective = createEnergyMinObjective(); - migrateINamedCommentedElement(oldObjective, newObjective); - newObjective.setPriority(0); - return newObjective; - } - - /** Migrates the {@link FailureMinObjective} to its new ecore representation. */ - private FailureMinObjective migrateFailureMin( - org.fortiss.af3.exploration.model.FailureMinObjective oldObjective) { - FailureMinObjective newObjective = createFailureMinObjective(); - migrateINamedCommentedElement(oldObjective, newObjective); - newObjective.setPriority(1); - newObjective.setTargetComponent(oldObjective.getComponent()); - return newObjective; - } - - /** Creates an {@link ReliabilityAnalysis} for {@link FailureMinObjective}s. */ - - /** - * Migrates the old {@link FixedDeploymentConstraint} to the - * {@link ComponentAllocationConstraint}. - */ - @SuppressWarnings("javadoc") - private ComponentMultiAllocationConstraint migrateFixedDeploymentConstraint( - org.fortiss.af3.exploration.model.FixedDeploymentConstraint oldConstraint) { - ComponentMultiAllocationConstraint newConstraint = - createComponentMultiAllocationConstraint(); - migrateINamedCommentedElement(oldConstraint, newConstraint); - Component comp = oldConstraint.getDeployableComponent(); - for(ExecutionUnit execUnit : oldConstraint.getDeploymentTargets()) { - ComponentAllocationConstraint cAllocConst = - createComponentAllocationConstraint(comp, execUnit); - newConstraint.getSingleLocationConstraints().add(cAllocConst); - } - return newConstraint; - } - - /** - * Migrates the old {@link ExcludeDeploymentConstraint} to the - * {@link ComponentDislocationConstraint}. - */ - @SuppressWarnings("javadoc") - private ComponentMultiDislocationConstraint migrateExcludeDeploymentConstraint( - org.fortiss.af3.exploration.model.ExcludeDeploymentConstraint oldConstraint) { - ComponentMultiDislocationConstraint newConstraint = - createComponentMultiDislocationConstraint(); - migrateINamedCommentedElement(oldConstraint, newConstraint); - Component comp = oldConstraint.getDeployableComponent(); - for(ExecutionUnit execUnit : oldConstraint.getDeploymentTargets()) { - ComponentDislocationConstraint cDislocConst = - createComponentDislocationConstraint(comp, execUnit); - newConstraint.getSingleLocationConstraints().add(cDislocConst); - } - return newConstraint; - } - - /** Migrates the {@link DeadlineConstraint} to its new ecore representation. */ - private DeadlineConstraint migrateDeadlineConstraint( - org.fortiss.af3.exploration.model.DeadlineConstraint oldConstraint) { - DeadlineConstraint newConstraint = TimeFactory.eINSTANCE.createDeadlineConstraint(); - migrateINamedCommentedElement(oldConstraint, newConstraint); - newConstraint.setStartComponent(oldConstraint.getStartComponent()); - newConstraint.setEndComponent(oldConstraint.getEndComponent()); - newConstraint.setDeadline(oldConstraint.getDeadline()); - return newConstraint; - } - - /** Migrates the {@link SafetyIntegrityLevelConstraint} to its new ecore representation. */ - private SafetyIntegrityLevelConstraint migrateSILConstraint( - org.fortiss.af3.exploration.model.SafetyIntegrityLevelConstraint oldConstraint) { - SafetyIntegrityLevelConstraint newConstraint = - PredefinedFactory.eINSTANCE.createSafetyIntegrityLevelConstraint(); - migrateINamedCommentedElement(oldConstraint, newConstraint); - return newConstraint; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/model/location/impl/LocationConstraintStaticImpl.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/model/location/impl/LocationConstraintStaticImpl.java deleted file mode 100644 index d7d455c2578e3757835e64f897d4aff4ebbcd0ad..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/model/location/impl/LocationConstraintStaticImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: LocationConstraintStaticImpl.java 3175 2016-07-04 15:25:48Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.model.location.impl; - -import org.fortiss.af3.exploration.dsl.model.expressions.ElementExpression; -import org.fortiss.af3.exploration.dsl.model.expressions.Expression; -import org.fortiss.af3.exploration.dsl.model.operators.LocationOp; -import org.fortiss.af3.exploration.dsl.model.patterns.LocationPattern; -import org.fortiss.af3.exploration.model.location.LocationConstraint; -import org.fortiss.tooling.base.model.element.IModelElement; - -/** - * Static method implementations for {@link LocationConstraint}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3175 $ - * @ConQAT.Rating RED Hash: 9FA66BE6E22D5A6076D7F92D407412E5 - */ -public class LocationConstraintStaticImpl { - - /** Static implementation of the {@link LocationConstraint#getLeftModelElement()} method. */ - public static <LHT extends IModelElement, RHT extends IModelElement> LHT getLeftModelElement( - LocationConstraint<LHT, RHT> constr) { - if(constr == null) { - return null; - } - LocationOp<LHT, RHT> locOp = getLocationOperator(constr); - if(locOp != null) { - // TODO: Write helper method for ElementExpressions. - ElementExpression<LHT> leftExpr = locOp.getLeft(); - if(leftExpr != null) { - return leftExpr.getModelElement(); - } - } - return null; - } - - /** Static implementation of the {@link LocationConstraint#getRightModelElement()} method. */ - public static <LHT extends IModelElement, RHT extends IModelElement> RHT getRightModelElement( - LocationConstraint<LHT, RHT> constr) { - if(constr == null) { - return null; - } - LocationOp<LHT, RHT> locOp = getLocationOperator(constr); - if(locOp != null) { - // TODO: Write helper method for ElementExpressions. - ElementExpression<RHT> rightExpr = locOp.getRight(); - if(rightExpr != null) { - return rightExpr.getModelElement(); - } - } - return null; - } - - /** - * Returns the {@link LocationOp} of the given {@link LocationConstraint}, or{@code null} if noe - * is found. - */ - @SuppressWarnings("unchecked") - public static - <LHT extends IModelElement, RHT extends IModelElement, LO extends LocationOp<LHT, RHT>> - LO getLocationOperator(LocationConstraint<LHT, RHT> locConstraint) { - if(locConstraint == null) { - return null; - } - Expression expr = locConstraint.getMoeaExpression(); - if(expr instanceof LocationPattern) { - Expression lpExpr = ((LocationPattern<?, ?>)expr).getExpression(); - if(lpExpr instanceof LocationOp) { - return (LO)lpExpr; - } - } - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/model/time/impl/DeadlineConstraintStaticImpl.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/model/time/impl/DeadlineConstraintStaticImpl.java deleted file mode 100644 index aa6c253d318dea6519f03dacb1cca339a89ccf35..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/model/time/impl/DeadlineConstraintStaticImpl.java +++ /dev/null @@ -1,197 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DeadlineConstraintStaticImpl.java 3175 2016-07-04 15:25:48Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.model.time.impl; - -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.exploration.dsl.model.expressions.ArithmeticExpression; -import org.fortiss.af3.exploration.dsl.model.expressions.BooleanExpression; -import org.fortiss.af3.exploration.dsl.model.expressions.ConstraintExpression; -import org.fortiss.af3.exploration.dsl.model.operators.ArithmeticOp; -import org.fortiss.af3.exploration.dsl.model.patterns.ElementProperty; -import org.fortiss.af3.exploration.dsl.model.patterns.TwoPropertyValueComparison; -import org.fortiss.af3.exploration.dsl.model.types.NumberLiteral; -import org.fortiss.af3.exploration.model.ExplorationConstraint; -import org.fortiss.af3.exploration.model.time.DeadlineConstraint; - -/** - * Static method implementations for {@link DeadlineConstraint}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3175 $ - * @ConQAT.Rating RED Hash: F30BAF00E90C97718413C99F6E06DAE6 - */ -public class DeadlineConstraintStaticImpl { - - /** Static implementation of the {@link DeadlineConstraint#getStartComponent()} method. */ - public static Component getStartComponent(DeadlineConstraint constr) { - if(constr == null) { - return null; - } - ElementProperty<Component, Double> startProp = getFirstElemProp(constr); - if(startProp != null) { - return startProp.getModelElement(); - } - return null; - } - - /** Static implementation of the {@link DeadlineConstraint#setStartComponent(Component)} method. */ - public static void setStartComponent(DeadlineConstraint constr, Component component) { - if(constr == null || component == null) { - return; - } - ElementProperty<Component, Double> startProp = getFirstElemProp(constr); - if(startProp != null) { - startProp.setModelElement(component); - } - } - - /** Static implementation of the {@link DeadlineConstraint#getEndComponent()} method. */ - public static Component getEndComponent(DeadlineConstraint constr) { - if(constr == null) { - return null; - } - ElementProperty<Component, Double> startProp = getSecondElemProp(constr); - if(startProp != null) { - return startProp.getModelElement(); - } - return null; - } - - /** Static implementation of the {@link DeadlineConstraint#setEndComponent(Component)} method. */ - public static void setEndComponent(DeadlineConstraint constr, Component component) { - if(constr == null || component == null) { - return; - } - ElementProperty<Component, Double> startProp = getSecondElemProp(constr); - if(startProp != null) { - startProp.setModelElement(component); - } - } - - /** Static implementation of the {@link DeadlineConstraint#getDeadline()} method. */ - public static Double getDeadline(DeadlineConstraint constr) { - if(constr == null) { - return null; - } - NumberLiteral<Double> deadline = getDeadlineNumberLiteral(constr); - if(deadline != null) { - return deadline.getValue(); - } - return null; - } - - /** Static implementation of the {@link DeadlineConstraint#setDeadline(Double)} method. */ - public static void setDeadline(DeadlineConstraint constr, Double period) { - if(constr == null || period == null) { - return; - } - NumberLiteral<Double> deadline = getDeadlineNumberLiteral(constr); - if(deadline != null) { - deadline.setValue(period); - } - } - - // FIXME: move the majority of the methods below to a util class for - // TwoPropertyValueComparison(Pattern)!!! - - /** Returns the first {@link ElementProperty} (a {@link Component}) from a DeadlineConstraint. */ - public static ElementProperty<Component, Double> getFirstElemProp(DeadlineConstraint constr) { - if(constr == null) { - return null; - } - ArithmeticOp<Double, ElementProperty<Component, Double>, ElementProperty<Component, Double>> arithOp = - getLeftArithmeticOperator(constr); - if(arithOp != null) { - return arithOp.getLeft(); - } - return null; - } - - /** Returns the second {@link ElementProperty} (a {@link Component}) from a DeadlineConstraint . */ - public static ElementProperty<Component, Double> getSecondElemProp(DeadlineConstraint constr) { - if(constr == null) { - return null; - } - ArithmeticOp<Double, ElementProperty<Component, Double>, ElementProperty<Component, Double>> arithOp = - getLeftArithmeticOperator(constr); - if(arithOp != null) { - return arithOp.getRight(); - } - return null; - } - - /** Returns the left-side {@link ArithmeticOp} from a DeadlineConstraint . */ - @SuppressWarnings("unchecked") - public static - ArithmeticOp<Double, ElementProperty<Component, Double>, ElementProperty<Component, Double>> - getLeftArithmeticOperator(DeadlineConstraint constr) { - if(constr == null) { - return null; - } - TwoPropertyValueComparison<Double, Component, Component> propValComp = - getPropValCompExpression(constr); - if(propValComp != null) { - ArithmeticExpression<Double> aExpr = propValComp.getLeft(); - if(aExpr instanceof ArithmeticOp) { - return (ArithmeticOp<Double, ElementProperty<Component, Double>, ElementProperty<Component, Double>>)aExpr; - } - } - return null; - } - - /** Returns the right hand side {@link NumberLiteral} (the deadline) from a DeadlineConstraint. */ - public static NumberLiteral<Double> getDeadlineNumberLiteral(DeadlineConstraint constr) { - if(constr == null) { - return null; - } - TwoPropertyValueComparison<Double, Component, Component> propValComp = - getPropValCompExpression(constr); - if(propValComp != null) { - ArithmeticExpression<Double> aExpr = propValComp.getRight(); - if(aExpr instanceof NumberLiteral) { - return (NumberLiteral<Double>)aExpr; - } - } - return null; - } - - /** - * Returns the {@link TwoPropertyValueComparison} of a DeadlineConstraint from the containing - * {@link ExplorationConstraint}. - */ - public static TwoPropertyValueComparison<Double, Component, Component> - getPropValCompExpression(DeadlineConstraint constr) { - if(constr == null) { - return null; - } - - if(constr.getExpression() instanceof ConstraintExpression) { - @SuppressWarnings("unchecked") ConstraintExpression<BooleanExpression> cExpr = - (ConstraintExpression<BooleanExpression>)constr.getExpression(); - if(cExpr.getExpression() instanceof TwoPropertyValueComparison) { - // Type Parameter enforced by access methods. - @SuppressWarnings("unchecked") TwoPropertyValueComparison<Double, Component, Component> compExpr = - (TwoPropertyValueComparison<Double, Component, Component>)cExpr - .getExpression(); - return compExpr; - } - } - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/model/time/impl/PeriodConstraintStaticImpl.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/model/time/impl/PeriodConstraintStaticImpl.java deleted file mode 100644 index ef72322baf397c6d32d3d587f8728e53df007026..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/model/time/impl/PeriodConstraintStaticImpl.java +++ /dev/null @@ -1,139 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: PeriodConstraintStaticImpl.java 3175 2016-07-04 15:25:48Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.model.time.impl; - -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.exploration.dsl.model.expressions.ArithmeticExpression; -import org.fortiss.af3.exploration.dsl.model.expressions.ConstraintExpression; -import org.fortiss.af3.exploration.dsl.model.patterns.ElementProperty; -import org.fortiss.af3.exploration.dsl.model.patterns.SinglePropValueComparison; -import org.fortiss.af3.exploration.dsl.model.types.NumberLiteral; -import org.fortiss.af3.exploration.model.time.PeriodConstraint; -import org.fortiss.tooling.base.model.element.IModelElement; - -/** - * Static method implementations for {@link PeriodConstraint}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3175 $ - * @ConQAT.Rating RED Hash: E6236644C07DC9F14B7B9EFBA2C4456A - */ -public class PeriodConstraintStaticImpl { - - /** Static implementation of the {@link PeriodConstraint#getComponent()} method. */ - public static Component getComponent(PeriodConstraint constr) { - if(constr == null) { - return null; - } - ElementProperty<Component, Double> elemProp = getElementProperty(constr); - if(elemProp != null) { - return elemProp.getModelElement(); - } - return null; - } - - /** Static implementation of the {@link PeriodConstraint#setComponent(Component)} method. */ - public static void setComponent(PeriodConstraint constr, Component component) { - if(constr == null) { - return; - } - ElementProperty<Component, Double> elemProp = getElementProperty(constr); - if(elemProp != null) { - elemProp.setModelElement(component); - } - } - - /** Static implementation of the {@link PeriodConstraint#getPeriod()} method. */ - public static Double getPeriod(PeriodConstraint constr) { - if(constr == null) { - return null; - } - NumberLiteral<Double> periodLiteral = getNumberLiteral(constr); - if(periodLiteral != null) { - return periodLiteral.getValue(); - } - return null; - } - - /** Static implementation of the {@link PeriodConstraint#setPeriod(Double)} method. */ - public static void setPeriod(PeriodConstraint constr, Double period) { - if(constr == null) { - return; - } - NumberLiteral<Double> periodLiteral = getNumberLiteral(constr); - if(periodLiteral != null) { - periodLiteral.setValue(period); - } - } - - /** - * Returns the {@link ElementProperty} which is contained in {@code this} - * {@link PeriodConstraint}. - */ - // Type parameters are enforced by construction. - @SuppressWarnings("unchecked") - public static <ME extends IModelElement, T> ElementProperty<ME, T> getElementProperty( - PeriodConstraint constr) { - if(constr == null) { - return null; - } - if(constr.getExpression() instanceof ConstraintExpression) { - ConstraintExpression<?> expr = (ConstraintExpression<?>)constr.getExpression(); - if(expr instanceof SinglePropValueComparison) { - SinglePropValueComparison<Double, Component> svCompExpr = - (SinglePropValueComparison<Double, Component>)expr.getExpression(); - if(svCompExpr != null) { - ArithmeticExpression<?> leftExpr = svCompExpr.getLeft(); - if(leftExpr instanceof ElementProperty) { - return((ElementProperty<ME, T>)leftExpr); - } - } - } - } - - return null; - } - - /** - * Returns the {@link NumberLiteral} which is contained in {@code this} {@link PeriodConstraint} - * . - */ - // Type parameters are enforced by construction. - @SuppressWarnings("unchecked") - public static <T> NumberLiteral<T> getNumberLiteral(PeriodConstraint constr) { - if(constr == null) { - return null; - } - if(constr.getExpression() instanceof ConstraintExpression<?>) { - ConstraintExpression<?> expr = (ConstraintExpression<?>)constr.getExpression(); - if(expr instanceof SinglePropValueComparison) { - SinglePropValueComparison<Double, Component> svCompExpr = - (SinglePropValueComparison<Double, Component>)expr.getExpression(); - if(svCompExpr != null) { - ArithmeticExpression<?> rightExpr = svCompExpr.getRight(); - if(rightExpr instanceof NumberLiteral) { - return (NumberLiteral<T>)rightExpr; - } - } - } - } - - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/ComponentMultiAllocationConstraintStaticImpl.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/ComponentMultiAllocationConstraintStaticImpl.java deleted file mode 100644 index 363e04a3b6f8e80e1b5d8aff4634d4466860527d..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/ComponentMultiAllocationConstraintStaticImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComponentMultiAllocationConstraintStaticImpl.java 3175 2016-07-04 15:25:48Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.moea.model.predefined.impl; - -import static org.fortiss.af3.exploration.util.CommonExplorationTagetModelElementFactory.createComponentAllocationConstraint; - -import java.util.Collection; - -import org.eclipse.emf.common.util.EList; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.exploration.model.location.ComponentAllocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiAllocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiDislocationConstraint; -import org.fortiss.af3.platform.model.ExecutionUnit; - -/** - * Static method implementations for {@link ComponentMultiDislocationConstraint}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3175 $ - * @ConQAT.Rating RED Hash: 05F85B5BF28D876C4A154669D9EA8A4D - */ -public class ComponentMultiAllocationConstraintStaticImpl { - /** - * Static implementation of the - * {@link ComponentMultiAllocationConstraint#setComponentMultiAllocations(Component, EList)} - * method. - */ - public static void setComponentMultiAllocations(ComponentMultiAllocationConstraint constr, - Component comp, Collection<ExecutionUnit> execUnits) { - if(constr == null) { - return; - } - constr.getSingleLocationConstraints().clear(); - for(ExecutionUnit singleExecUnit : execUnits) { - ComponentAllocationConstraint allocConstr = - createComponentAllocationConstraint(comp, singleExecUnit); - constr.getSingleLocationConstraints().add(allocConstr); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/ComponentMultiDislocationConstraintStaticImpl.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/ComponentMultiDislocationConstraintStaticImpl.java deleted file mode 100644 index 8a3a06b0e29fc81be168d70e5daf0319cd6ab969..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/ComponentMultiDislocationConstraintStaticImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ComponentMultiDislocationConstraintStaticImpl.java 3175 2016-07-04 15:25:48Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.moea.model.predefined.impl; - -import static org.fortiss.af3.exploration.util.CommonExplorationTagetModelElementFactory.createComponentDislocationConstraint; - -import java.util.Collection; - -import org.eclipse.emf.common.util.EList; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.exploration.model.location.ComponentDislocationConstraint; -import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiDislocationConstraint; -import org.fortiss.af3.platform.model.ExecutionUnit; - -/** - * Static method implementations for {@link ComponentMultiDislocationConstraint}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3175 $ - * @ConQAT.Rating RED Hash: DAB3972C88C638BF0154E795AAE18D77 - */ -public class ComponentMultiDislocationConstraintStaticImpl { - /** - * Static implementation of the - * {@link ComponentMultiDislocationConstraint#setComponentMultiDislocations(Component, EList)} - * method. - */ - public static void setComponentMultiDislocations(ComponentMultiDislocationConstraint constr, - Component comp, Collection<ExecutionUnit> execUnits) { - if(constr == null) { - return; - } - constr.getSingleLocationConstraints().clear(); - for(ExecutionUnit singleExecUnit : execUnits) { - // LocationConstraint<Component, Dislocation, ExecutionUnit> - ComponentDislocationConstraint allocConstr = - createComponentDislocationConstraint(comp, singleExecUnit); - constr.getSingleLocationConstraints().add(allocConstr); - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/FailureMinObjectiveStaticImpl.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/FailureMinObjectiveStaticImpl.java deleted file mode 100644 index 0001c3c8fc22fa2ed7392886d632d3d69a9623bf..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/FailureMinObjectiveStaticImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: FailureMinObjectiveStaticImpl.java 3175 2016-07-04 15:25:48Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.moea.model.predefined.impl; - -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.exploration.dsl.model.expressions.ArithmeticExpression; -import org.fortiss.af3.exploration.dsl.model.expressions.ObjectiveExpression; -import org.fortiss.af3.exploration.moea.model.predefined.FailureMinObjective; -import org.fortiss.af3.exploration.moea.model.predefined.ReliabilityAnalysis; - -/** - * Static method implementations for {@link FailureMinObjective}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3175 $ - * @ConQAT.Rating RED Hash: 1DE500E6121C2F819A7C6E6F765C06B5 - */ -public class FailureMinObjectiveStaticImpl { - - /** - * Static implementation of the {@link FailureMinObjective#setTargetComponent(Component)} - * method. - */ - public static void setFailureMinTargetComponent(FailureMinObjective objective, - Component targetComponent) { - if(objective == null || targetComponent == null) { - return; - } - // The targetComponent is set in the ReliabilityAnalysis expression. - ReliabilityAnalysis relAnalysis = getReliabilityAnalysis(objective); - if(relAnalysis != null) { - relAnalysis.setModelElement(targetComponent); - } - } - - /** Static implementation of the {@link FailureMinObjective#getTargetComponent()} method. */ - public static Component getFailureMinTargetComponent(FailureMinObjective objective) { - if(objective == null) { - return null; - } - // The targetComponent is set in the ReliabilityAnalysis expression. - ReliabilityAnalysis relAnalysis = getReliabilityAnalysis(objective); - if(relAnalysis != null) { - return relAnalysis.getModelElement(); - } - return null; - } - - /** - * Returns the {@link ReliabilityAnalysis} expression contained in a {@link FailureMinObjective} - * . - */ - public static ReliabilityAnalysis getReliabilityAnalysis(FailureMinObjective objective) { - if(objective == null) { - return null; - } - // Walk the expressions until the ReliabilityAnalysis is found (hardcoded). - if(objective.getExpression() instanceof ObjectiveExpression) { - ObjectiveExpression expr = (ObjectiveExpression)objective.getExpression(); - ArithmeticExpression<?> aExpr = expr.getRight(); - if(aExpr instanceof ReliabilityAnalysis) { - return (ReliabilityAnalysis)aExpr; - } - } - return null; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/MultiLocationConstraintStaticImpl.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/MultiLocationConstraintStaticImpl.java deleted file mode 100644 index 52a1cd06e8aebe22648740554c009451d7497418..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/MultiLocationConstraintStaticImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: MultiLocationConstraintStaticImpl.java 3175 2016-07-04 15:25:48Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.moea.model.predefined.impl; - -import static java.util.Collections.emptyList; - -import java.util.List; -import java.util.stream.Collectors; - -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.EList; -import org.fortiss.af3.exploration.moea.model.predefined.MultiLocationConstraint; -import org.fortiss.tooling.base.model.element.IModelElement; - -/** - * Static method implementations for {@link MultiLocationConstraint}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3175 $ - * @ConQAT.Rating RED Hash: 7D7F93B4F0608FF645807A144462CBB2 - */ -public class MultiLocationConstraintStaticImpl { - - /** Static implementation of {@link MultiLocationConstraint#getLeftMultiLocationModelElement}. */ - public static <LHT extends IModelElement, RHT extends IModelElement> LHT - getLeftMultiLocationModelElement(MultiLocationConstraint<LHT, RHT> constr) { - if(constr == null) { - return null; - } - if(!constr.getSingleLocationConstraints().isEmpty()) { - // Get(0): The left hand side is equal for all location constraints, so the first one - // suffices. - return constr.getSingleLocationConstraints().get(0).getLeftModelElement(); - } - return null; - } - - /** - * Static implementation of - * {@link MultiLocationConstraint#getAllRightMultiLocationModelElements}. - */ - @SuppressWarnings("unchecked") - public static <LHT extends IModelElement, RHT extends IModelElement> EList<RHT> - getAllRightMultiLocationModelElements(MultiLocationConstraint<LHT, RHT> constr) { - if(constr == null) { - return null; - } - if(!constr.getSingleLocationConstraints().isEmpty()) { - List<RHT> cList = - constr.getSingleLocationConstraints().parallelStream() - .map(c -> c.getRightModelElement()).collect(Collectors.toList()); - BasicEList<RHT> reList = new BasicEList<>(); - reList.addAll(cList); - return reList; - } - return (EList<RHT>)emptyList(); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/SafetyIntegrityLevelConstraintStaticImpl.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/SafetyIntegrityLevelConstraintStaticImpl.java deleted file mode 100644 index 894511cb7d1fd3bcf1d7c1d087d89ef3c86b2887..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/predefined/impl/SafetyIntegrityLevelConstraintStaticImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SafetyIntegrityLevelConstraintStaticImpl.java 3175 2016-07-04 15:25:48Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.moea.model.predefined.impl; - -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.EList; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.exploration.moea.model.predefined.SafetyIntegrityLevelConstraint; -import org.fortiss.af3.safety.model.SIL; -import org.fortiss.af3.safety.model.annotation.SafetyIntegrityLevel; - -/** - * Static method implementations for {@link SafetyIntegrityLevelConstraint}s. - * - * @author alex - * @author $Author: diewald $ - * @version $Rev: 3175 $ - * @ConQAT.Rating RED Hash: EFE01687D21E30B46F1CF8B675DEAC8B - */ -public class SafetyIntegrityLevelConstraintStaticImpl { - - /** Static implementation of the method {@link SafetyIntegrityLevelConstraint#getLimitation}. */ - public static EList<SIL> getLimitation(SafetyIntegrityLevelConstraintImpl constr) { - EList<SIL> comSILs = new BasicEList<>(); - for(Component comp : constr.getComponents()) { - // TODO: NPE - SafetyIntegrityLevel sil = - (SafetyIntegrityLevel)comp.getSpecifications().stream() - .filter(s -> s instanceof SafetyIntegrityLevel).findAny().get(); - comSILs.add(sil.getSilValue()); - } - return comSILs; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/solutions/impl/SingleExplorationSolutionMapStaticImpl.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/solutions/impl/SingleExplorationSolutionMapStaticImpl.java deleted file mode 100644 index 7eafe843126f703415fd4791016cd04731fb0dd6..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/moea/model/solutions/impl/SingleExplorationSolutionMapStaticImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: SingleExplorationSolutionMapStaticImpl.java 3175 2016-07-04 15:25:48Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.moea.model.solutions.impl; - -import java.util.Map.Entry; - -import org.fortiss.af3.exploration.moea.model.solutions.SingleExplorationSolutionMap; - -/** - * Static method implementations for {@link SingleExplorationSolutionMap}s. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3175 $ - * @ConQAT.Rating RED Hash: F3A72F82B0887E116A69B4CA93C4D7D5 - */ -public class SingleExplorationSolutionMapStaticImpl { - - /** - * Static implementation of the method - * {@link SingleExplorationSolutionMap#getSolutionModel(Class)}. - */ - @SuppressWarnings("unchecked") - public static <T> T getModel(SingleExplorationSolutionMap singleExpSol, Class<T> modelType) { - T solutionModel = (T)singleExpSol.getSolutionModelMap().get(modelType); - - if(solutionModel == null) { - for(Entry<Class<?>, Object> entry : singleExpSol.getSolutionModelMap()) { - if(modelType.isAssignableFrom(entry.getKey())) { - solutionModel = (T)entry.getValue(); - } - } - } - - return solutionModel; - } - - /** - * Static implementation of the method - * {@link SingleExplorationSolutionMap#putSolutionModel(Class, Object)}. - */ - public static <T> void putSolutionModel(SingleExplorationSolutionMap singleExpSol, - Class<T> modelType, T solutionModel) { - singleExpSol.getSolutionModelMap().put(modelType, solutionModel); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/port/DSEPortingUtils.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/port/DSEPortingUtils.java deleted file mode 100644 index bd54e4dff10d65db8372393cbaaca94cd682619b..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/port/DSEPortingUtils.java +++ /dev/null @@ -1,430 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ -| | -| Copyright 2017 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.port; - -import static org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceConnectionAdapter.ConnectionType.BIDIRECTIONAL; -import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.getReferencedElementsWithType; -import static org.fortiss.tooling.common.util.LambdaUtils.filterStream; -import static org.fortiss.tooling.common.util.LambdaUtils.getFirst; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType; -import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf; -import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.conqat.lib.commons.collections.Pair; -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.component.model.ComponentArchitecture; -import org.fortiss.af3.component.model.OutputPort; -import org.fortiss.af3.component.model.Port; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceConnectionAdapter.ConnectionType; -import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemParameterContainer; -import org.fortiss.af3.exploration.dsl_v2.model.booleanp.allocation.Allocation; -import org.fortiss.af3.exploration.extension.IDseInputParameters.DeployableComponents; -import org.fortiss.af3.exploration.extension.IDseInputParameters.SignalType; -import org.fortiss.af3.exploration.extension.IDseInputParameters.TemporalTriggers; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.moea.model.annotation.ComponentDiverseImplRef; -import org.fortiss.af3.exploration.projectmodel.DSE; -import org.fortiss.af3.expression.model.types.TBool; -import org.fortiss.af3.expression.model.types.TDouble; -import org.fortiss.af3.expression.model.types.TInt; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.af3.platform.model.IPhysicalPlatformArchitectureElement; -import org.fortiss.af3.platform.model.IPlatformArchitectureElement; -import org.fortiss.af3.platform.model.IPlatformResource; -import org.fortiss.af3.platform.model.IVirtualizationPlatformArchitectureElement; -import org.fortiss.af3.platform.model.PlatformArchitecture; -import org.fortiss.af3.platform.model.TransmissionUnit; -import org.fortiss.af3.platform.utils.PlatformArchitectureUtils; -import org.fortiss.af3.project.model.FileProject; -import org.fortiss.af3.project.model.typesystem.IType; -import org.fortiss.af3.task.model.TaskAllocation; -import org.fortiss.af3.task.model.TaskArchitecture; -import org.fortiss.tooling.base.model.element.IConnector; -import org.fortiss.tooling.base.model.element.IModelElement; -import org.fortiss.tooling.kernel.utils.EcoreUtils; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -/** - * - * @author diewald - * @author $Author: hoelzl $ - * @version $Rev: 18709 $ - * @ConQAT.Rating RED Hash: 521ACFFC7C8AFC41A24550984444D37E - */ -public class DSEPortingUtils { - /** - * Lookup table for to determine the direction of a connection by the type of the target - * {@link IConnector}. - */ - // TODO: UsePlatformPort? - public static Map<Class<? extends IConnector>, ConnectionType> connectionTypeLUT = Collections - .unmodifiableMap(new HashMap<Class<? extends IConnector>, ConnectionType>() { - { - } - }); - - /** - * Returns the type of communication the given port can handle: incoming, outgoing, or - * bidirectional traffic. - * - * @param sourceConnector - * {@link IConnector} to be examined. - * @return The port type (default = bidirectional). - */ - public static ConnectionType getPortDirection(IConnector sourceConnector) { - ConnectionType connectionTypeSource = connectionTypeLUT.get(sourceConnector.getClass()); - return connectionTypeSource != null ? connectionTypeSource : BIDIRECTIONAL; - } - - /** - * Creates a collection of deployment targets (that are {@link ExecutionUnit}s) from the given - * collection of {@code platformArchitecture}s. Therefore, the {@link DeploymentGranularity} - * annotation is examined for each {@link ExecutionUnit} present in the given Platforms. - * - * @param platformArchitectures - * for which to extract the collection of deployment {@link ExecutionUnit}s. - * @return collection of deployment targets. - * @throws Exception - * if an invalid combination of {@link DeploymentGranularity} specifications has - * been detected. - */ - public static Collection<ExecutionUnit> createDeploymentTargets( - Collection<PlatformArchitecture> platformArchitectures) throws Exception { - Collection<ExecutionUnit> rval = new HashSet<>(); - - FileProject prj = - getParentElement(getFirst(platformArchitectures, x -> true).get(), - FileProject.class, false); - DSE af3DSE = pickFirstInstanceOf(DSE.class, prj.getRootElements()); - - ExplorationSpecification expSpec = af3DSE.getExplorationSpecification(); - - Collection<Allocation> allocConstrSet = - EcoreUtils.getChildrenWithType(expSpec, Allocation.class); - for(Allocation alloc : allocConstrSet) { - Collection<IModelElement> targetElementSet = - alloc.getRight().getSetReference().getEntries(); - filterStream(targetElementSet, e -> e instanceof ExecutionUnit).map( - ExecutionUnit.class::cast).forEach(e -> rval.add(e)); - } - - // for(PlatformArchitecture curPA : platformArchitectures) { - // for(DeploymentGranularity deplAnn : getChildrenWithType(curPA, - // DeploymentGranularity.class)) { - // IModelElement execUnit = deplAnn.getSpecificationOf(); - // - // // If the current deployment target is a virtual ExecutionUnit, e.g. a partition, - // // ensure that none its referenced physical ExecutionUnits (or any of theri parents) - // // are also selected as deployment targets. - // if(execUnit instanceof IVirtualizationPlatformArchitectureElement && - // execUnit instanceof ExecutionUnit) { - // for(IHierarchicElement currentHardwareResource : getReferencedElementsWithType( - // execUnit, IHierarchicElement.class)) { - // if(isAnyParentDeploymentTarget(currentHardwareResource)) { - // String refHwResourceName = currentHardwareResource.toString(); - // if(currentHardwareResource instanceof INamedElement) { - // refHwResourceName = - // ((INamedElement)currentHardwareResource).getName() + - // "(id: " + - // ((INamedElement)currentHardwareResource).getId() + - // ")"; - // } - // throw new Exception("The referenced hardware resource " + - // refHwResourceName + - // " or one of its containers of the virtual element " + - // ((ExecutionUnit)execUnit).getName() + "(id: " + - // ((ExecutionUnit)execUnit).getId() + - // ") has been chosen as a deployment target.\n" + - // "This is not allowed for elements with a virtualization layer."); - // } - // } - // } - // - // if(execUnit instanceof ExecutionUnit && deplAnn.isIsDeploymentTarget()) { - // rval.add((ExecutionUnit)execUnit); - // } - // } - // } - - if(rval.isEmpty()) { - throw new Exception( - "No deployment targets have been specified in the target platform architecture(s)." - + " Please check whether the correct platform architecture was selected and whether" - + " the desired Execution Units were selected as deployment targets" - + " (Platform Model --> Annotation View --> Deployment Target)"); - } - - return rval; - } - - // TODO: Why is the FailureRate annotation bound to IPhysicalPlatformElement instead of - // IPlatformResource? - /** - * Creates a Map that relates all annotated {@link IPlatformArchitectureElement}s with their - * specified {@link FailureRate}. - */ - public static Map<IPlatformArchitectureElement, Double> createFailureRateMap( - Collection<PlatformArchitecture> platformArchitectures) throws Exception { - Map<IPlatformArchitectureElement, Double> failureRateMap = new HashMap<>(); - for(PlatformArchitecture pa : platformArchitectures) { - for(IPlatformArchitectureElement platformElement : getChildrenWithType(pa, - IPlatformArchitectureElement.class)) { - failureRateMap.put(platformElement, getResourceFailureRate(platformElement)); - } - } - - return failureRateMap; - } - - /** - * Extracts the failure probability of a given {@link IPlatformResource}. If the - * {@code resourceElement} is a {@link IVirtualizationPlatformArchitectureElement}, the average - * value of the referenced {@link IPhysicalPlatformArchitectureElement}s is used. - * - * @param resourceElement - * resource for which to determine the failure probability. - * @return failure probability of the given {@code resourceElement}. - * @throws Exception - * if the failure probability is not correctly defined in the model. - */ - // TODO: check, whether it make sense to move the failure rate annotation to the AF3 platform - // since it would allow a simple analysis of hierarchical platforms. - public static Double getResourceFailureRate(IPlatformArchitectureElement resourceElement) - throws Exception { - - // If the annotated element is a part of the system software, the resource links are used to - // determine the speed of the associated resources. - if(resourceElement instanceof IVirtualizationPlatformArchitectureElement) { - Collection<IPhysicalPlatformArchitectureElement> associatedResources = - getReferencedElementsWithType(resourceElement, - IPhysicalPlatformArchitectureElement.class); - - if(!(associatedResources.isEmpty())) { - Double avgFailureRate = Double.valueOf(0); - for(IPhysicalPlatformArchitectureElement currentAssociatedResource : associatedResources) { - if(currentAssociatedResource instanceof IModelElement) { - // FIXME: For now, just use a default value. - return 10E-6; - // FailureRate failureRateAnnotation = - // getAnnotation((IModelElement)currentAssociatedResource, - // FailureRate.class); - // - // if(failureRateAnnotation != null) { - // avgFailureRate += failureRateAnnotation.getFailureRate_FIT(); - // } else { - // throw new Exception("The platform resource " + - // currentAssociatedResource + - // " does not have a failure rate annotation."); - // } - } - } - - return avgFailureRate / associatedResources.size(); - } else if(resourceElement instanceof ExecutionUnit) { - // For now the failure rates are only evaluated for ExecutionUnits, so the failure - // rate annotation is only required for these resources. - throw new Exception("The virtual resource " + resourceElement.toString() + - " does not reference a physical resource"); - } - } else { - // FIXME: For now, just use a default value. - return 10E-6; - // FailureRate failureRateAnnotation = - // pickFirstInstanceOf(FailureRate.class, - // ((IModelElement)resourceElement).getSpecifications()); - // - // if(failureRateAnnotation != null) { - // return failureRateAnnotation.getFailureRate_FIT(); - // } - // throw new Exception("The platform resource " + resourceElement + - // " does not have a failure rate annotation."); - } - - return null; - // throw new Exception("The failure rate for the platform resource " + resourceElement + - // " coult not be determined."); - } - - /** - * Creates a map of all {@link IPlatformResource} which have an annotated power consumption - * value and their specified value. - */ - public static Map<IPlatformResource, Double> createPowerConsumptionMap( - Collection<PlatformArchitecture> platformArchitectures) throws Exception { - Map<IPlatformResource, Double> powerConsumptionMap = new HashMap<>(); - powerConsumptionMap.putAll(getTransmissionUnitPowerConsumption(platformArchitectures)); - return powerConsumptionMap; - } - - /** Maps all {@link TransmissionUnit}s to their annotated power consumption value. */ - // TODO: We need a way to define the energy consumed by transmission units like busses: stand-by - // + active. Currently, we hard-code the consumed energy while a transmission Unit is active - // while we assue that it does not consume energy in the idle state. - public static Map<IPlatformResource, Double> getTransmissionUnitPowerConsumption( - Collection<PlatformArchitecture> platformArchitectures) { - Map<IPlatformResource, Double> powerConsumptionMap = new HashMap<>(); - for(PlatformArchitecture pa : platformArchitectures) { - for(TransmissionUnit tu : getChildrenWithType(pa, TransmissionUnit.class)) { - powerConsumptionMap.put(tu, 1.0); - } - } - - return powerConsumptionMap; - } - - /** - * Maps all deployable {@link Component}s to their specified periodicities. Non-periodic - * {@link Component} are not supported. - */ - // FIXME: The period is hard-coded here. It must be taken from the yet-to-come timing model. - public static Map<Component, Double> createComponentPeriodMap( - Collection<Component> deployableComponents) { - Map<Component, Double> componentPeriodMap = new HashMap<>(); - for(Component deployableComponent : deployableComponents) { - componentPeriodMap.put(deployableComponent, 10.0); - } - return componentPeriodMap; - } - - /** - * Maps all "abstract" and deployable {@link Component}s the set of {@link Component}s which are - * selected as their diverse implementations by means of the {@link ComponentDiverseImplRef} - * annotation. - */ - public static Multimap<Component, Component> createComponentReplacementMap( - Collection<Component> deployableComponent) { - Multimap<Component, Component> replacementComponentMap = HashMultimap.create(); - for(Component component : deployableComponent) { - // ComponentDiverseImplRef componentReplacementRef = - // AnnotationUtils.getAnnotation(component, ComponentDiverseImplRef.class); - // replacementComponentMap.putAll(component, componentReplacementRef.getComponentRef()); - replacementComponentMap.putAll(component, Collections.emptyList()); - } - return replacementComponentMap; - } - - /** - * Maps all deployable {@link Component}s to their amount of minimal required and maximally - * allowed replicas. A value of 1 implies that the component is present only once (without - * actual replica in the resulting solution calculated by the DSE). - */ - // FIXME: - public static Map<Component, Pair<Integer, Integer>> createComponentReplicationMap( - Collection<Component> deployableComponents) throws Exception { - Map<Component, Pair<Integer, Integer>> replicationBoundMap = new HashMap<>(); - for(Component component : deployableComponents) { - // TODO: where shall the replication bound be placed? ComponentArchitecture, - // TaskArchitecture? - // ReplicationBounds replicationBounds = getAnnotation(component, - // ReplicationBounds.class); - // if(replicationBounds == null) { - // throw new Exception("The replication bounds of the component " + - // component.getName() + " is not defined."); - // } - Pair<Integer, Integer> minMaxBounds = new Pair<>(1, 1); - replicationBoundMap.put(component, minMaxBounds); - } - - return replicationBoundMap; - } - - /** - * Returns the temporal triggers of the deployable {@link Component}s' {@link Port}s. - * - * @param deployableComponents - * Collection of {@link Component}s tthat shall be deployed. - * @return Map of the ports with a temporal trigger. - */ - public static TemporalTriggers - getPortTimingProperties(DeployableComponents deployableComponents) { - TemporalTriggers portSignalTypes = new TemporalTriggers(); - Collection<Port> allPorts = new ArrayList<>(); - for(Component currComp : deployableComponents) { - allPorts.addAll(getChildrenWithType(currComp, Port.class)); - } - allPorts.parallelStream().forEach(p -> portSignalTypes.put(p, SignalType.PERIODIC)); - return portSignalTypes; - } - - /** Maps the {@link OutputPort}s of {@link Component}s to their respective bit size. */ - public static Map<OutputPort, Long> createMessageSizeMap( - Collection<Component> deployableComponents) throws Exception { - Map<OutputPort, Long> messageSizes = new HashMap<>(); - for(Component component : deployableComponents) { - for(OutputPort port : component.getOutputPorts()) { - IType outType = port.getVariableType(); - // FIXME: Primitive fixed bit length assignments for the types. Should be done based - // on the platform. - if(outType instanceof TBool) { - messageSizes.put(port, (long)1); - } else if(outType instanceof TInt) { - messageSizes.put(port, (long)32); - } else if(outType instanceof TDouble) { - messageSizes.put(port, (long)64); - } else { - throw new Exception("No type has been defined for the output port" + port + - " that is compatible with the MOEA-based DSE exploration."); - } - } - } - - return messageSizes; - } - - /** - * Creates a container that contains all required and optional information to execute the - * MOEA-based DSE which are not AF3 standard parameters. - */ - public static SystemParameterContainer createSystemParameterContainer( - ComponentArchitecture componentArchitecture, PlatformArchitecture platformArchitecture, - TaskArchitecture taskArchitecture) throws Exception { - DeployableComponents deployableComponents = new DeployableComponents(); - // FIXME: We select the atomic components from the ComponentArchitecture to be deployed at - // the moment. Instead, the TaskArchitecture should be used here. - for(TaskAllocation taskAlloc : taskArchitecture.getTaskAllocations()) { - deployableComponents.addAll(taskAlloc.getComponents()); - } - - // Set: if we have only a hardware platform, then it will be returned by getHardwarePlatform - // --> no duplicates. - Set<PlatformArchitecture> targetPlatforms = new HashSet<>(); - targetPlatforms.add(platformArchitecture); - targetPlatforms.add(PlatformArchitectureUtils - .getPhysicalPlatformArchitecture(platformArchitecture)); - - Collection<ExecutionUnit> deploymentTargets = createDeploymentTargets(targetPlatforms); - - return new SystemParameterContainer(deployableComponents, - getPortTimingProperties(deployableComponents), deploymentTargets, - createComponentPeriodMap(deployableComponents), - createComponentReplacementMap(deployableComponents), - createComponentReplicationMap(deployableComponents), - createMessageSizeMap(deployableComponents), createFailureRateMap(targetPlatforms), - createPowerConsumptionMap(targetPlatforms), connectionTypeLUT, null, null); - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/util/CommonExplorationTagetModelElementFactory.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/util/CommonExplorationTagetModelElementFactory.java deleted file mode 100644 index a9890739dfc8b10b9eb053bfdcbc37f4bed09161..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/util/CommonExplorationTagetModelElementFactory.java +++ /dev/null @@ -1,137 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: CommonExplorationTagetModelElementFactory.java 3175 2016-07-04 15:25:48Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.util; - -import static org.fortiss.af3.exploration.util.ExplorationDslModelElementFactory.createLocationPattern; -import static org.fortiss.af3.exploration.util.ExplorationDslModelElementFactory.createTwoProValCompExpression; - -import org.fortiss.af3.component.model.Component; -import org.fortiss.af3.exploration.dsl.model.expressions.ConstraintExpression; -import org.fortiss.af3.exploration.dsl.model.operators.ArithmeticOperatorEnum; -import org.fortiss.af3.exploration.dsl.model.operators.ComparisonOperatorEnum; -import org.fortiss.af3.exploration.dsl.model.operators.LocationOperatorEnum; -import org.fortiss.af3.exploration.dsl.model.patterns.LocationPattern; -import org.fortiss.af3.exploration.dsl.model.patterns.SinglePropValueComparison; -import org.fortiss.af3.exploration.dsl.model.patterns.TwoPropertyValueComparison; -import org.fortiss.af3.exploration.model.ExplorationSpecification; -import org.fortiss.af3.exploration.model.ExplorationTarget; -import org.fortiss.af3.exploration.model.location.ComponentAllocationConstraint; -import org.fortiss.af3.exploration.model.location.ComponentDislocationConstraint; -import org.fortiss.af3.exploration.model.location.LocationConstraint; -import org.fortiss.af3.exploration.model.location.LocationFactory; -import org.fortiss.af3.exploration.model.time.DeadlineConstraint; -import org.fortiss.af3.exploration.model.time.PeriodConstraint; -import org.fortiss.af3.exploration.model.time.TimeFactory; -import org.fortiss.af3.platform.model.ExecutionUnit; -import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; -import org.fortiss.tooling.kernel.service.IPersistencyService; - -/** - * Model element factory for {@link ExplorationTarget}s that are common for all DSE backends. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3175 $ - * @ConQAT.Rating RED Hash: 7CD442DF6ED6930102EBA2590ACE8AE1 - */ -public class CommonExplorationTagetModelElementFactory { - - // FIXME: Construct the Expression already if no parameters are passed & use setter methods in - // the method of Allocation/DislocationConstraints. - /** Creates a {@link ComponentAllocationConstraint}. */ - public static ComponentAllocationConstraint createComponentAllocationConstraint(Component comp, - ExecutionUnit execUnit) { - ComponentAllocationConstraint cAllocConstr = createComponentAllocationConstraint(); - // Construct the corresponding Expression via the LocationPattern. - cAllocConstr.setMoeaExpression(createLocationPattern(comp, LocationOperatorEnum.ALLOCATION, - execUnit)); - return cAllocConstr; - } - - /** Creates a {@link ComponentAllocationConstraint}. */ - public static ComponentAllocationConstraint createComponentAllocationConstraint() { - ComponentAllocationConstraint cAllocConstr = - LocationFactory.eINSTANCE.createComponentAllocationConstraint(); - cAllocConstr.setName("Component Allocation Constraint"); - return cAllocConstr; - } - - /** Creates a {@link ComponentDislocationConstraint}. */ - public static ComponentDislocationConstraint createComponentDislocationConstraint( - Component comp, ExecutionUnit execUnit) { - ComponentDislocationConstraint cDislocConstr = createComponentDislocationConstraint(); - // Construct the corresponding Expression via the LocationPattern. - cDislocConstr.setMoeaExpression(createLocationPattern(comp, - LocationOperatorEnum.DISLOCATION, execUnit)); - return cDislocConstr; - } - - /** Creates a {@link ComponentDislocationConstraint}. */ - public static ComponentDislocationConstraint createComponentDislocationConstraint() { - ComponentDislocationConstraint cDislocConstr = - LocationFactory.eINSTANCE.createComponentDislocationConstraint(); - cDislocConstr.setName("Component Dislocation Constraint"); - return cDislocConstr; - } - - /** Creates a deadline constraint within the goal specification of the current DSE model. */ - public static DeadlineConstraint addDeadlineConstraint(ExplorationSpecification targetSpec) { - DeadlineConstraint deadlineConstraint = createDeadlineConstraint(); - ITopLevelElement modelContext = - IPersistencyService.getInstance().getTopLevelElementFor(targetSpec); - modelContext.runAsCommand(() -> targetSpec.getTargets().add(deadlineConstraint)); - return deadlineConstraint; - } - - /** Creates an "empty" {@link DeadlineConstraint}. */ - public static DeadlineConstraint createDeadlineConstraint() { - DeadlineConstraint deadlineConstr = TimeFactory.eINSTANCE.createDeadlineConstraint(); - deadlineConstr.setName("Deadline Constraint"); - TwoPropertyValueComparison<Double, Component, Component> twoPropValExpr = - createTwoProValCompExpression(ArithmeticOperatorEnum.SUB, - ComparisonOperatorEnum.LESS_OR_EQUAL); - ConstraintExpression<TwoPropertyValueComparison<Double, Component, Component>> cExpr = - ExplorationDslModelElementFactory.createConstraintExpression(null, null, - twoPropValExpr); - deadlineConstr.setMoeaExpression(cExpr); - return deadlineConstr; - } - - /** Creates an "empty" {@link PeriodConstraint}. */ - public static PeriodConstraint createPeriodConstraint() { - PeriodConstraint periodConstr = TimeFactory.eINSTANCE.createPeriodConstraint(); - periodConstr.setName("Period Constraint"); - SinglePropValueComparison<Double, Component> singlePropValExpr = - ExplorationDslModelElementFactory - .createSinglePropValueCompExpression(ComparisonOperatorEnum.LESS_OR_EQUAL); - ConstraintExpression<SinglePropValueComparison<Double, Component>> cExpr = - ExplorationDslModelElementFactory.createConstraintExpression(null, null, - singlePropValExpr); - periodConstr.setMoeaExpression(cExpr); - return periodConstr; - } - - /** Creates a {@link LocationConstraint} by using a {@link LocationPattern}. */ - public static LocationConstraint<Component, ExecutionUnit> createLocationConstraint( - LocationPattern<Component, ExecutionUnit> locationPattern) { - LocationConstraint<Component, ExecutionUnit> createLocationConstraint = - LocationFactory.eINSTANCE.createLocationConstraint(); - createLocationConstraint.setMoeaExpression(locationPattern); - return createLocationConstraint; - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/util/DSLUtils.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/util/DSLUtils.java deleted file mode 100644 index 93bd067e648ed6cd334524400222f92973140858..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/util/DSLUtils.java +++ /dev/null @@ -1,69 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: DSLUtils.java 3175 2016-07-04 15:25:48Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.util; - -import java.util.ArrayList; - -import org.fortiss.af3.exploration.dsl.model.expressions.Expression; -import org.fortiss.af3.exploration.dsl.model.operators.DualOperator; -import org.fortiss.af3.exploration.dsl.model.operators.Operator; - -/** - * Utility methods for the constraint DSL. - * - * @author eder - * @author $Author: diewald $ - * @version $Rev: 3175 $ - * @ConQAT.Rating RED Hash: 1A3F69CC68A6046206A2D005911AC4A6 - */ -public class DSLUtils { - - /** Returns an {@link Expression} as a list of all leafs in the expression tree */ - public static - ArrayList<? extends org.fortiss.af3.exploration.dsl.model.expressions.Expression> - expressionToList(org.fortiss.af3.exploration.dsl.model.expressions.Expression expression) { - if(expression instanceof DualOperator<?, ?, ?>) { - ArrayList<? extends org.fortiss.af3.exploration.dsl.model.expressions.Expression> left = - expressionToList((org.fortiss.af3.exploration.dsl.model.expressions.Expression)((DualOperator<?, ?, ?>)expression) - .getLeft()); - ArrayList<? extends org.fortiss.af3.exploration.dsl.model.expressions.Expression> right = - expressionToList((org.fortiss.af3.exploration.dsl.model.expressions.Expression)((DualOperator<?, ?, ?>)expression) - .getRight()); - ArrayList<org.fortiss.af3.exploration.dsl.model.expressions.Expression> result = - new ArrayList<>(); - result.addAll(left); - result.add((org.fortiss.af3.exploration.dsl.model.expressions.Expression)((DualOperator<?, ?, ?>)expression)); - result.addAll(right); - return result; - } else if(expression instanceof Operator<?, ?>) { - ArrayList<? extends org.fortiss.af3.exploration.dsl.model.expressions.Expression> right = - expressionToList((org.fortiss.af3.exploration.dsl.model.expressions.Expression)((DualOperator<?, ?, ?>)expression) - .getRight()); - ArrayList<org.fortiss.af3.exploration.dsl.model.expressions.Expression> result = - new ArrayList<>(); - result.add((org.fortiss.af3.exploration.dsl.model.expressions.Expression)((Operator<?, ?>)expression)); - result.addAll(right); - return right; - } else { - ArrayList<org.fortiss.af3.exploration.dsl.model.expressions.Expression> list = - new ArrayList<org.fortiss.af3.exploration.dsl.model.expressions.Expression>(); - list.add(expression); - return list; - } - } -} diff --git a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/util/ExplorationDslModelElementFactory.java b/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/util/ExplorationDslModelElementFactory.java deleted file mode 100644 index abcd5c4207d1e1305d4f928b627bb8a501ae9fe4..0000000000000000000000000000000000000000 --- a/org.fortiss.af3.exploration.alg/master/src/org/fortiss/af3/exploration/util/ExplorationDslModelElementFactory.java +++ /dev/null @@ -1,171 +0,0 @@ -/*--------------------------------------------------------------------------+ -$Id: ExplorationDslModelElementFactory.java 3175 2016-07-04 15:25:48Z diewald $ -| | -| Copyright 2016 ForTISS GmbH | -| | -| Licensed under the Apache License, Version 2.0 (the "License"); | -| you may not use this file except in compliance with the License. | -| You may obtain a copy of the License at | -| | -| http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | -| See the License for the specific language governing permissions and | -| limitations under the License. | -+--------------------------------------------------------------------------*/ -package org.fortiss.af3.exploration.util; - -import org.eclipse.emf.common.util.EList; -import org.fortiss.af3.exploration.dsl.model.expressions.ArithmeticExpression; -import org.fortiss.af3.exploration.dsl.model.expressions.BooleanExpression; -import org.fortiss.af3.exploration.dsl.model.expressions.ConstraintExpression; -import org.fortiss.af3.exploration.dsl.model.expressions.ElementExpression; -import org.fortiss.af3.exploration.dsl.model.expressions.Expression; -import org.fortiss.af3.exploration.dsl.model.expressions.ExpressionsFactory; -import org.fortiss.af3.exploration.dsl.model.expressions.ObjectiveExpression; -import org.fortiss.af3.exploration.dsl.model.expressions.PrefixExpression; -import org.fortiss.af3.exploration.dsl.model.operators.ArithmeticOp; -import org.fortiss.af3.exploration.dsl.model.operators.ArithmeticOperatorEnum; -import org.fortiss.af3.exploration.dsl.model.operators.ComparisonOperatorEnum; -import org.fortiss.af3.exploration.dsl.model.operators.LocationOp; -import org.fortiss.af3.exploration.dsl.model.operators.LocationOperatorEnum; -import org.fortiss.af3.exploration.dsl.model.operators.OperatorsFactory; -import org.fortiss.af3.exploration.dsl.model.operators.OptimizationDirection; -import org.fortiss.af3.exploration.dsl.model.operators.OptimizationDirectionEnum; -import org.fortiss.af3.exploration.dsl.model.operators.SummationOp; -import org.fortiss.af3.exploration.dsl.model.patterns.ElementProperty; -import org.fortiss.af3.exploration.dsl.model.patterns.LocationPattern; -import org.fortiss.af3.exploration.dsl.model.patterns.PatternsFactory; -import org.fortiss.af3.exploration.dsl.model.patterns.SinglePropValueComparison; -import org.fortiss.af3.exploration.dsl.model.patterns.TwoPropertyValueComparison; -import org.fortiss.af3.exploration.dsl.model.types.NumberLiteral; -import org.fortiss.af3.exploration.dsl.model.types.TypesFactory; -import org.fortiss.af3.exploration.model.location.LocationConstraint; -import org.fortiss.tooling.base.model.element.IModelElement; - -/** - * Model element factory for Expressions of the explorationDsl. - * - * @author diewald - * @author $Author: diewald $ - * @version $Rev: 3175 $ - * @ConQAT.Rating RED Hash: 36D3F25F5EA7F85C19CF2C18C62F4082 - */ -public class ExplorationDslModelElementFactory { - - /** Creates an "empty" {@link SummationOp}. */ - public static <T> SummationOp<T> createSummationOp() { - SummationOp<T> sumOp = OperatorsFactory.eINSTANCE.createSummationOp(); - sumOp.setOperator(ArithmeticOperatorEnum.ADD); - return sumOp; - } - - /** - * Creates an {@link ObjectiveExpression} optimizing towards the given - * {@link OptimizationDirection}. - */ - public static ObjectiveExpression - createObjectiveExpression(OptimizationDirectionEnum direction) { - ObjectiveExpression expr = ExpressionsFactory.eINSTANCE.createObjectiveExpression(); - expr.setOperator(direction); - return expr; - } - - /** Creates an "empty" {@link ConstraintExpression}. */ - public static <T extends BooleanExpression> ConstraintExpression<T> createConstraintExpression( - EList<PrefixExpression> prefixes, EList<BooleanExpression> predicates, T expression) { - ConstraintExpression<T> expr = ExpressionsFactory.eINSTANCE.createConstraintExpression(); - if(prefixes != null) { - expr.getPrefix().addAll(prefixes); - } - if(predicates != null) { - expr.getPredicate().addAll(predicates); - } - expr.setExpression(expression); - return expr; - } - - /** Creates a {@link LocationPattern} used in {@link LocationConstraint}s. */ - @SuppressWarnings("unchecked") - public static <LHT extends IModelElement, RHT extends IModelElement> LocationPattern<LHT, RHT> - createLocationPattern() { - LocationPattern<IModelElement, IModelElement> locPattern = - PatternsFactory.eINSTANCE.createLocationPattern(); - return (LocationPattern<LHT, RHT>)locPattern; - } - - /** Creates a {@link LocationPattern} used in {@link LocationConstraint}s. */ - @SuppressWarnings("unchecked") - public static <LHT extends IModelElement, RHT extends IModelElement> LocationPattern<LHT, RHT> - createLocationPattern(LHT sourceObj, LocationOperatorEnum op, RHT targetObj) { - LocationPattern<IModelElement, IModelElement> locPattern = - PatternsFactory.eINSTANCE.createLocationPattern(); - // Create the left side, the operator, and the right hand side. - LocationOp<IModelElement, IModelElement> lop = - OperatorsFactory.eINSTANCE.createLocationOp(); - locPattern.setExpression(lop); - ElementExpression<IModelElement> leftExpr = createElementExpression(sourceObj); - locPattern.getExpression().setLeft(leftExpr); - locPattern.getExpression().setOperator(op); - ElementExpression<IModelElement> rightExpr = createElementExpression(targetObj); - locPattern.getExpression().setRight(rightExpr); - - return (LocationPattern<LHT, RHT>)locPattern; - } - - /** - * Creates an {@link ElementExpression} used to reference {@link IModelElement}s from - * {@link Expression}s. - */ - public static <ME extends IModelElement> ElementExpression<ME> createElementExpression( - ME modelElement) { - ElementExpression<ME> elemExpr = ExpressionsFactory.eINSTANCE.createElementExpression(); - elemExpr.setModelElement(modelElement); - return elemExpr; - } - - /** Creates an "empty" {@link ElementProperty} (no values/references are set). */ - public static <ME extends IModelElement, T> ElementProperty<ME, T> createElementProperty() { - ElementProperty<ME, T> elemProp = PatternsFactory.eINSTANCE.createElementProperty(); - return elemProp; - } - - /** Creates an "empty" {@link SinglePropValueComparison} (no values/references are set). */ - public static <T, ME extends IModelElement> SinglePropValueComparison<T, ME> - createSinglePropValueCompExpression(ComparisonOperatorEnum compOpType) { - ElementProperty<ME, T> modelElement = createElementProperty(); - // TODO: let the creator pass the literal? Differentiation by T? should the NumberLiteral - // class be an interface? - NumberLiteral<T> numLit = TypesFactory.eINSTANCE.createNumberLiteral(); - SinglePropValueComparison<T, ME> singleCompPropPattern = - PatternsFactory.eINSTANCE.createSinglePropValueComparison(); - singleCompPropPattern.setLeft(modelElement); - singleCompPropPattern.setOperator(compOpType); - singleCompPropPattern.setRight(numLit); - return singleCompPropPattern; - } - - /** Creates an "empty" {@link TwoPropertyValueComparison} (no values/references are set). */ - public static <T, FME extends IModelElement, SME extends IModelElement> - TwoPropertyValueComparison<T, FME, SME> createTwoProValCompExpression( - ArithmeticOperatorEnum arithOpType, ComparisonOperatorEnum compOpType) { - ElementProperty<FME, T> firstModelElement = createElementProperty(); - ElementProperty<SME, T> secondModelElement = createElementProperty(); - ArithmeticOp<T, ArithmeticExpression<T>, ArithmeticExpression<T>> arithOp = - OperatorsFactory.eINSTANCE.createArithmeticOp(); - arithOp.setOperator(arithOpType); - arithOp.setLeft(firstModelElement); - arithOp.setRight(secondModelElement); - // TODO: let the creator pass the literal? Differentiation by T? should the NumberLiteral - // class be an interface? - NumberLiteral<T> numLit = TypesFactory.eINSTANCE.createNumberLiteral(); - TwoPropertyValueComparison<T, FME, SME> twoCompPattern = - PatternsFactory.eINSTANCE.createTwoPropertyValueComparison(); - twoCompPattern.setLeft(arithOp); - twoCompPattern.setOperator(compOpType); - twoCompPattern.setRight(numLit); - return twoCompPattern; - } -}