Skip to content
Snippets Groups Projects
Commit 3309f481 authored by Simon Barner's avatar Simon Barner
Browse files
into 3337

Conflicts:
	org.fortiss.af3.exploration.alg/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/comparch/.ratings
	org.fortiss.af3.exploration.alg/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/.ratings
	org.fortiss.af3.exploration.alg/src/org/fortiss/af3/exploration/alg/dse/modeltransformation/deployment/DeploymentFinalizer.java
	org.fortiss.af3.exploration.alg/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/.ratings
	org.fortiss.af3.exploration.alg/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SystemModelAdapter.java
	org.fortiss.af3.exploration.alg/src/org/fortiss/af3/exploration/alg/plot/.ratings
	org.fortiss.af3.exploration.alg/src/org/fortiss/af3/exploration/alg/util/.ratings
	org.fortiss.af3.exploration.alg/src/org/fortiss/af3/exploration/alg/util/TransformationUtils.java


Signed-off-by: default avatarSimon Barner <barner@fortiss.org>
parents cb61f410 1fb1a3b9
No related branches found
No related tags found
1 merge request!93337: exploration.alog
Showing
with 167 additions and 136 deletions
......@@ -77,7 +77,7 @@ public abstract class MappingEntryBase<S extends IRequestAdapter<?>, T extends I
/** {@inheritDoc} */
@Override
public Collection<IMappingEntry<S, T>> getAssociatedElement() {
public Collection<IMappingEntry<S, T>> getAssociatedElements() {
return associatedEntries.values();
}
......
TaskMappingEncoding.java 8b337aaedd0ab5be1a904d7bdec4cdf7da05381d RED
TaskMappingEncoding.java 7581cce920312520380bafd3bbb65685a4ad79b8 RED
TaskMappingEntry.java 407c9065007f8cd4adc8b64eea13a837bba581ae RED
......@@ -151,7 +151,7 @@ public abstract class TaskMappingEncoding<S extends ITaskAdapter<?>, T extends T
*/
protected void addAllocation(T entry) {
allocationMap.put(entry.getSource(), entry);
referencedByMap.putAll(entry, entry.getAssociatedElement());
referencedByMap.putAll(entry, entry.getAssociatedElements());
}
/**
......
......@@ -3,6 +3,6 @@ DecodeInterceptor.java 2cd170507345f42ea9034ccafb2362c55e0a3f05 YELLOW
Decodes.java 8c9dd7de94c97f1beb2870b5c9a4c3becffee378 YELLOW
DecodingInterceptModule.java 4def3126e57d404e81b3c63484ad9ff375454ff3 YELLOW
Genotyped.java c74c870c570597bdb373308fa339ccf2c8e88942 YELLOW
GuiceDecoder.java a5a2186ca51ba32f78fa8d671688e495334e41de RED
PhenotypeCache.java d3c69d197487eab2b818ad7499bf6ccdc86f7ff0 YELLOW
GuiceDecoder.java 4797ffe3c342302365142d277c9a6d4eb226f071 RED
PhenotypeCache.java 5aaedf91502b02735a266bcb0a27453f197ebe87 YELLOW
PluginDecoder.java 359f2460393d4bc0cd14d593dff8ec219969f582 YELLOW
......@@ -138,7 +138,7 @@ public class GuiceDecoder extends AbstractModule
@Override
protected void configure() {
install(this);
install(new PhenotypeCache());
install(PhenotypeCache.getPrototype());
// Install a dummy value provider for the validate methods.
install(new ValueProvider<Value<?>>(new BooleanValue(true)));
......
......@@ -35,7 +35,21 @@ import com.google.inject.Provides;
public class PhenotypeCache extends EncodingCache<Phenotype> {
/** Holder singleton of Phenotypes that can be used in the next iteration. */
private PreservablePhenotypeHolder preservedPhenos = PreservablePhenotypeHolder.getInstance();
public PreservablePhenotypeHolder preservedPhenos;
/** Prototype Constructor. */
private PhenotypeCache() {
}
/** Constructor. */
private PhenotypeCache(PreservablePhenotypeHolder preservedPhenos) {
this.preservedPhenos = preservedPhenos;
}
/** Returns a new Prototype of the Phenotype Cache to install the Provider in Guice. */
public static PhenotypeCache getPrototype() {
return new PhenotypeCache();
}
/**
* Returns an instance of the {@link PhenotypeCache} per thread. If the cache is requested from
......@@ -44,8 +58,8 @@ public class PhenotypeCache extends EncodingCache<Phenotype> {
*/
@Provides
@ThreadScoped
public PhenotypeCache getEncodingCache() {
return new PhenotypeCache();
public PhenotypeCache getEncodingCache(PreservablePhenotypeHolder holder) {
return new PhenotypeCache(holder);
}
/**
......
Phenotype.java f05a45ea3b3577079b4f894aa97af1ab3620c5e7 YELLOW
PhenotypeBase.java aa44517704b33a198b2fd6ba24c50c83f61a060f YELLOW
PhenotypeProviderGenerator.java 7dd56a30c9245c7151935d10b05c33ad35a0e35d YELLOW
PreservablePhenotypeHolder.java 7ecaf3448550d377a7a6d72081e3031d34c58b81 YELLOW
PreservablePhenotypeHolder.java 9dd1258c18a85dfb7a34b4a262434736b223f828 YELLOW
ProvidingPhenotype.java c3178001c842fb0fad36a6bfac5da525fdd1954a YELLOW
......@@ -23,6 +23,7 @@ import org.opt4j.core.Individual;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.google.inject.AbstractModule;
import com.google.inject.Singleton;
/**
......@@ -33,22 +34,11 @@ import com.google.inject.Singleton;
* @author diewald
*/
@Singleton
public class PreservablePhenotypeHolder {
public class PreservablePhenotypeHolder extends AbstractModule {
/** Holds preserved {@link Phenotype}s. */
protected Multimap<Genotype, Phenotype> preserveMap = HashMultimap.create();
/** Instance holder. */
private static PreservablePhenotypeHolder instance;
/** Singleton accessor. */
public static PreservablePhenotypeHolder getInstance() {
if(instance == null) {
instance = new PreservablePhenotypeHolder();
}
return instance;
}
/**
* Adds the given {@link Genotype} (key) and the collection of preservable {@link Phenotype}s to
* {@code this} holder.
......
MatingCrossoverMutateRepair.java fb86c40edc92fb56f7c66e2da1ee59ed7993d637 YELLOW
MatingCrossoverMutateRepair.java c6bd85c76466d4684ddd88a48321840f5022792c YELLOW
MatingCrossoverMutateRepairModule.java f1e17e5a5f94238fc81ff50d01a5537a98069a04 YELLOW
......@@ -61,8 +61,7 @@ import com.google.inject.Inject;
public class MatingCrossoverMutateRepair extends MatingCrossoverMutate {
/** Holder for {@link Phenotype}s that can be reused in the offspring individual. */
protected PreservablePhenotypeHolder preservablePhenos =
PreservablePhenotypeHolder.getInstance();
protected PreservablePhenotypeHolder preservablePhenos;
/** Finds the {@link Phenotype}s that depend on a modified {@link Genotype}. */
protected DependentPhenotypeFinder dependPhenoFinder;
......@@ -75,9 +74,11 @@ public class MatingCrossoverMutateRepair extends MatingCrossoverMutate {
public MatingCrossoverMutateRepair(Crossover<Genotype> crossover, Mutate<Genotype> mutate,
Copy<Genotype> copy, Coupler coupler, CrossoverRate crossoverRate,
MutationRate mutationRate, Rand random, IndividualFactory individualFactory,
PreservablePhenotypeHolder preservablePhenos,
DependentPhenotypeFinder dependPhenoFinder) {
super(crossover, mutate, copy, coupler, crossoverRate, mutationRate, random,
individualFactory);
this.preservablePhenos = preservablePhenos;
this.dependPhenoFinder = dependPhenoFinder;
}
......
DseProcessProblemModule.java c7bfd211b82d5f317b65f78f9b008c72dcdcc0c9 YELLOW
StrictTTDecoder.java 9ced8d5abd55c2f32b1a3379c77e6b62bfae1ff2 RED
StrictTTDecoder.java 370f92d5f652dd76029cd00eaf138786a9427769 RED
......@@ -15,6 +15,9 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.alg.dse.backend.opt4j.problem;
import static org.eclipse.core.runtime.Assert.isTrue;
import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.isValidateScheduleEnabled;
import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.comm.MessageEncoding;
import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.partitionmapping.PartitionMappingEncoding;
import org.fortiss.af3.exploration.alg.dse.backend.opt4j.encoding.platform.PlatformCommunicationGraphEncoding;
......@@ -78,31 +81,16 @@ public class StrictTTDecoder<S extends InstantiatedTaskMappingEntry, T extends I
StrictTTSchedule<S, T> schedule = new StrictTTSchedule<S, T>((T)itmEnc);
simpleEDFScheduler.schedule((InstantiatedAcyclicTaskGraphEncoding<S>)acycItgEnc, partEnc,
(T)itmEnc, 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(),
(InstantiatedAcyclicTaskGraphEncoding<S>)acycItgEnc, pcgEncoding);
assert (schedule.validateSchedule(true));
return schedule;
}
public StrictTTSchedule<S, T> decodeInternal(T itmEnc, MessageEncoding<S, T> msgEnc,
InstantiatedAcyclicTaskGraphEncoding<S> acycItgEnc,
PlatformCommunicationGraphEncoding pcgEncoding, PartitionMappingEncoding partEnc) {
// 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>(itmEnc);
simpleEDFScheduler.schedule(acycItgEnc, partEnc, itmEnc, schedule);
assert (schedule.validateSchedule(true));
if(isValidateScheduleEnabled()) {
isTrue(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,
pcgEncoding);
assert (schedule.validateSchedule(true));
simpleBusScheduler.schedule(schedule, msgEnc.getPeriodicMessages(), pcgEncoding);
if(isValidateScheduleEnabled()) {
isTrue(schedule.validateSchedule(true));
}
return schedule;
}
......
InstantiatedTaskMappingDecoder.java 3475c1c3813a46d603415ff8272d47ed5b929d0f RED
InstantiatedTaskMappingDecoder.java 807ded55ba24de344c5dc022c28b12bed12ca074 RED
InstantiatedTaskMappingDecoderAcyclic.java 64e0233f8ece8109f3ad0472dbaea0e182932093 RED
......@@ -15,8 +15,6 @@
+--------------------------------------------------------------------------*/
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;
......@@ -103,8 +101,9 @@ public class InstantiatedTaskMappingDecoder<T extends InstantiatedTaskMappingEnt
private void removeInterSafetyChannelSignals(SafetyFunctionArchEncoding sfEnc,
InstantiatedTaskGraphEncoding<T> itgEnc) throws DecodingException {
for(SafetyFunctionArchEntry sfEntry : sfEnc.getAllEntries()) {
@SuppressWarnings("unchecked")
Collection<ITaskAdapter<?>> sfCompAdps =
castToRawColl(sfEntry.getSafetyFunctionAdapter().getRealizingComponents());
(Collection<ITaskAdapter<?>>)(Collection<?>)(sfEntry.getSafetyFunctionAdapter().getRealizingComponents());
assert (sfCompAdps.size() > 0);
ITaskAdapter<?> sfCompAdp = sfCompAdps.stream().findAny().get();
......@@ -127,10 +126,12 @@ public class InstantiatedTaskMappingDecoder<T extends InstantiatedTaskMappingEnt
Collection<ITaskAdapter<?>> connectedDiagUnits = new ArrayList<>();
Collection<ITaskAdapter<?>> connectedOutUnit = new ArrayList<>();
for(int channelIdx = 0; channelIdx < sfEntry.getNumChannels(); channelIdx++) {
@SuppressWarnings("unchecked")
Collection<ITaskAdapter<?>> sfUnits =
castToRawColl(sfEntry.getSafetyFunctionAdapter().getRealizingComponents());
(Collection<ITaskAdapter<?>>)(Collection<?>)sfEntry.getSafetyFunctionAdapter().getRealizingComponents();
@SuppressWarnings("unchecked")
Collection<ITaskAdapter<?>> diagUnits =
castToRawColl(sfEntry.getSafetyFunctionAdapter().getDiagnosticComponents());
(Collection<ITaskAdapter<?>>)(Collection<?>)sfEntry.getSafetyFunctionAdapter().getDiagnosticComponents();
// TODO: knowledge about the modeL: output unit not instantiated:
ITaskAdapter<?> outputUnit =
sfEntry.getSafetyFunctionAdapter().getOutputComponent();
......
FailSilentAbstractTaskMappingDecoder.java c19c1991ad08fd424b7973211bc8ea07836661a7 RED
FaultDetectionVotingAbstractTaskMappingDecoder.java 28aec484fa4f8420b4e6fe53ce591624c9cefea6 RED
FaultDetectionVotingAbstractTaskMappingDecoder.java 18d7eca9327e334e5aafeefba601fc55df5be899 RED
TaskInstanceResourceAlignmentDecoder.java 8567290ebc74927263f5265f44d7acdcbf99797f RED
......@@ -68,14 +68,14 @@ public class FaultDetectionVotingAbstractTaskMappingDecoder
// Missing Associations between instantiated and abstract entries indicate the need to
// create or remove corresp. entries.
for(AbstractTaskMappingEntry abstrEntry : abstrEntries) {
if(abstrEntry.getAssociatedElement().isEmpty()) {
if(abstrEntry.getAssociatedElements().isEmpty()) {
outGenotype.createAndAddEntry(abstrEntry);
}
}
Collection<FaultDetectionVotingTaskMappingEntry> rmEntries = new ArrayList<>();
for(FaultDetectionVotingTaskMappingEntry instEntry : instEntries) {
if(instEntry.getAssociatedElement().isEmpty()) {
if(instEntry.getAssociatedElements().isEmpty()) {
rmEntries.add(instEntry);
}
}
......
IExplorationSolution.java cca30446b15bf5345e1dddfcd7ade42a0b3d5510 YELLOW
IScheduleSolution.java 817553162aa9f1a0e7807f6eba4ddcfad2f382bc YELLOW
StrictTTSchedule.java 38a2b5bae8bee3a6d366551c2dc925f4aaf7e1f2 RED
TimeSlot.java ec0a244cd513dd0a233f2077a7995dc45e719d64 RED
ResourceSchedule.java 989df2d9088175dc7dd73a49af6566e03bcfdcd6 YELLOW
StrictTTSchedule.java eef1496d1dffe2f8b18d3e50960951a214ee3235 RED
TimeSlot.java d17bd9bb919567e240f232f4862d0240d7e31ba7 RED
/*-------------------------------------------------------------------------+
| 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
*/
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;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2019 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.TreeMap;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IRequestAdapter;
/**
* {@link TreeMap}-based Schedule of a single resource.
*
* @author diewald
*/
public class ResourceSchedule extends TreeMap<TimeSlot, IRequestAdapter<?>> {
/**
* Shifts the given {@link TimeSlot} by the given amount of time and all (temporal) successor
* {@link TimeSlot}s of this resource as needed. This means, only those {@link TimeSlot}s are
* shifted that would overlap.
*/
public Collection<TimeSlot> shiftSlotAndSuccessors(TimeSlot slot, double amount) {
Collection<TimeSlot> shiftedSlots = new ArrayList<>();
double prevEndTime = slot.getStartTime() + amount;
for(TimeSlot succSlot : this.tailMap(slot).keySet()) {
double currDiff = prevEndTime - succSlot.getStartTime();
if(currDiff > 0.0) {
shiftedSlots.add(succSlot);
succSlot.shift(currDiff);
} else {
// If the current slot needs no more shift, successors also don't need a shift.
// Know by the order by start times.
break;
}
prevEndTime = succSlot.getEndTime();
}
return shiftedSlots;
}
/**
* 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;
}
}
......@@ -15,24 +15,26 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.alg.dse.backend.opt4j.solution;
import static java.util.stream.Collectors.toList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
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.PhenotypeBase;
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.IGatewayUnitAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IRequestAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITransmissionUnitAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.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;
......@@ -53,38 +55,17 @@ public class StrictTTSchedule<S extends TaskMappingEntry<ITaskAdapter<?>, IExecu
// 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;
private Map<IResourceAdapter<?>, ResourceSchedule> schedule =
new HashMap<IResourceAdapter<?>, ResourceSchedule>();
/**
* Associates the {@link IMappingEntry}s with their {@link TimeSlot}s. Essentially, a different
* perspective onto the {#link schedule}.
*/
private Map<S, TimeSlot> timeSlotsOfMappingEntries;
private Map<S, TimeSlot> timeSlotsOfMappingEntries = new HashMap<S, TimeSlot>();
// TODO: Check if there is an Opt4J mechanism to obtain the genotype for a phenotype if this is
// required (e.g., in an evaluator)
......@@ -97,15 +78,11 @@ public class StrictTTSchedule<S extends TaskMappingEntry<ITaskAdapter<?>, IExecu
*/
public StrictTTSchedule(T encoding) {
this.encoding = encoding;
schedule = new HashMap<IResourceAdapter<?>, ResourceSchedule>();
timeSlotsOfMappingEntries = new HashMap<S, TimeSlot>();
}
/** Copy constructor. */
public StrictTTSchedule(StrictTTSchedule<S, T> schedule) {
this.encoding = schedule.encoding;
this.schedule = new HashMap<IResourceAdapter<?>, ResourceSchedule>();
timeSlotsOfMappingEntries = new HashMap<S, TimeSlot>();
this(schedule.encoding);
for(Entry<IResourceAdapter<?>, ResourceSchedule> resSched : schedule.schedule.entrySet()) {
ResourceSchedule newSched = new ResourceSchedule();
......@@ -226,8 +203,9 @@ public class StrictTTSchedule<S extends TaskMappingEntry<ITaskAdapter<?>, IExecu
* 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);
Collection<TimeSlot> predessorSlots, double start, double end, long iteration) {
TimeSlot slot = createTimeSlot(deployedRequest, deploymentTarget, predessorSlots, start,
end, iteration);
slot.setVoter(true);
return slot;
}
......@@ -257,16 +235,6 @@ public class StrictTTSchedule<S extends TaskMappingEntry<ITaskAdapter<?>, IExecu
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
......@@ -279,14 +247,6 @@ public class StrictTTSchedule<S extends TaskMappingEntry<ITaskAdapter<?>, IExecu
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();
......@@ -297,6 +257,18 @@ public class StrictTTSchedule<S extends TaskMappingEntry<ITaskAdapter<?>, IExecu
return schedule.get(resource);
}
public Collection<TimeSlot> getTransientSuccessorsOf(TimeSlot slot) {
Collection<TimeSlot> successors = new ArrayList<>();
Queue<TimeSlot> successorsToVisit = new LinkedList<>();
successorsToVisit.addAll(slot.getSuccessors());
while(!successorsToVisit.isEmpty()) {
TimeSlot visitedTimeSlot = successorsToVisit.poll();
successors.add(visitedTimeSlot);
successorsToVisit.addAll(visitedTimeSlot.getSuccessors());
}
return successors;
}
/**
* Returns the {@link TimeSlot} that has been reserved for the given {@link IMappingEntry}.
* Returns null, if no {@link TimeSlot} could be found.
......@@ -305,6 +277,15 @@ public class StrictTTSchedule<S extends TaskMappingEntry<ITaskAdapter<?>, IExecu
return timeSlotsOfMappingEntries.get(entry);
}
/**
* Returns the {@link TimeSlot} that has been reserved for the given {@link IMappingEntry}.
* Returns null, if no {@link TimeSlot} could be found.
*/
public Collection<TimeSlot> getTimeSlotsOf(ITaskAdapter<?> task) {
Collection<S> entries = encoding.getMappingEntriesOf(task);
return entries.stream().map(e -> getTimeSlotOf(e)).collect(toList());
}
/**
* Return the earliest start time of all time slots that are allocated for the given request.
*/
......
......@@ -20,9 +20,9 @@ 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.ITaskAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IExecutionUnitAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IResourceAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.ITaskAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.comm.Message;
import org.fortiss.af3.exploration.alg.dse.sysmodel.mapping.IMappingEntry;
......@@ -48,10 +48,10 @@ public class TimeSlot implements java.lang.Comparable<TimeSlot> {
private Message deployedMessage;
/** References the {@link TimeSlot}s that are causal predecessors of this {@link TimeSlot}. */
private Collection<TimeSlot> predecessorSlots;
private Collection<TimeSlot> predecessorSlots = new HashSet<TimeSlot>();;
/** References the {@link TimeSlot}s that are causal successors of this {@link TimeSlot}. */
private Collection<TimeSlot> successorSlots;
private Collection<TimeSlot> successorSlots = new HashSet<TimeSlot>();;
/** Start time of {@link TimeSlot}. */
private double startTime;
......@@ -74,34 +74,22 @@ public class TimeSlot implements java.lang.Comparable<TimeSlot> {
* allocated for a voter.
*/
public TimeSlot(IMappingEntry<ITaskAdapter<?>, ?> deployedRequest, IResourceAdapter<?> resource,
double startTime, double endTime, int iteration, boolean isVoterSlot) {
Collection<TimeSlot> predecessorSlots, 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<ITaskAdapter<?>, ?> 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<ITaskAdapter<?>, ?> deployedRequest, double startTime,
double endTime) {
this(deployedRequest, deployedRequest.getTarget(), startTime, endTime, 0, false);
public TimeSlot(IMappingEntry<ITaskAdapter<?>, ?> deployedRequest,
Collection<TimeSlot> predecessorSlots, double startTime, double endTime) {
this(deployedRequest, deployedRequest.getTarget(), predecessorSlots, startTime, endTime, 0,
false);
}
/**
......@@ -109,8 +97,8 @@ public class TimeSlot implements java.lang.Comparable<TimeSlot> {
* {@link ICommunicationResourceAdapter}s.
*/
public TimeSlot(Message deployedMessage, ICommunicationResourceAdapter<?> resource,
double startTime, double endTime) {
this(null, resource, startTime, endTime, 0, false);
Collection<TimeSlot> predecessorSlots, double startTime, double endTime) {
this(null, resource, predecessorSlots, startTime, endTime, 0, false);
this.deployedMessage = deployedMessage;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment