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

- Correctly respect allocation constraints: Outdated if caused a random...

- Correctly respect allocation constraints: Outdated if caused a random assignment for single components in the mutateAllocation Operation.
- Re-add check for the allocation constraints in the corresponding evaluator.
parent 8c285148
No related branches found
No related tags found
No related merge requests found
...@@ -610,8 +610,8 @@ public abstract class TaskMappingEncoding<T extends TaskMappingEntry> implements ...@@ -610,8 +610,8 @@ public abstract class TaskMappingEncoding<T extends TaskMappingEntry> implements
* Determines if a deployable component is subject to a * Determines if a deployable component is subject to a
* {@link ComponentMultiAllocationConstraint} * {@link ComponentMultiAllocationConstraint}
*/ */
public boolean hasFixedDeployment(IDeployableComponentAdapter<?> deployableComponent) { public boolean hasLimitedDeployment(IDeployableComponentAdapter<?> deployableComponent) {
return fixAllocatedComponents.contains(deployableComponent); return allowedAllocations.containsKey(deployableComponent);
} }
// TODO: Do not handle this in the encodings / mutation operators! // TODO: Do not handle this in the encodings / mutation operators!
......
...@@ -111,7 +111,7 @@ public class MutateAllocation<S extends TaskMappingEntry, T extends TaskMappingE ...@@ -111,7 +111,7 @@ public class MutateAllocation<S extends TaskMappingEntry, T extends TaskMappingE
S selectedEntry = assignedResources.get(selIdx); S selectedEntry = assignedResources.get(selIdx);
// This respects {@link ExcludeDeploymentConstraint}s. // This respects {@link ExcludeDeploymentConstraint}s.
if(encoding.hasFixedDeployment(deployableComponent)) { if(encoding.hasLimitedDeployment(deployableComponent)) {
List<IExecutionUnitAdapter<?>> targets = List<IExecutionUnitAdapter<?>> targets =
new ArrayList<>(encoding.getAllowedAllocations(deployableComponent)); new ArrayList<>(encoding.getAllowedAllocations(deployableComponent));
int selExecU = max(0, rand.nextInt(targets.size()) - 1); int selExecU = max(0, rand.nextInt(targets.size()) - 1);
......
...@@ -51,7 +51,7 @@ public abstract class MutateRedundancy<S extends TaskMappingEntry, T extends Tas ...@@ -51,7 +51,7 @@ public abstract class MutateRedundancy<S extends TaskMappingEntry, T extends Tas
// TODO: remove filter for fixed Deployment: It is not needed. // TODO: remove filter for fixed Deployment: It is not needed.
// No replication for Components with a fixed Deployment & Components which shall // No replication for Components with a fixed Deployment & Components which shall
// not be replicated (see the SystemModelAdapter). // not be replicated (see the SystemModelAdapter).
if(!encoding.hasFixedDeployment(deployableComponent) && if(!encoding.hasLimitedDeployment(deployableComponent) &&
systemModelAdapter.getReplicableComponents().contains(deployableComponent)) { systemModelAdapter.getReplicableComponents().contains(deployableComponent)) {
// TODO: Model minimum and maximum replication count as constraint? // TODO: Model minimum and maximum replication count as constraint?
......
...@@ -32,6 +32,7 @@ import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegen ...@@ -32,6 +32,7 @@ import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegen
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.IDeployableComponentAdapter; 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.IExecutionUnitAdapter;
import org.fortiss.af3.exploration.alg.dse.sysmodel.arch.SystemModelAdapter; 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.alg.service.IExplorationTargetEvaluator;
import org.fortiss.af3.exploration.model.ExplorationTarget; import org.fortiss.af3.exploration.model.ExplorationTarget;
import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiAllocationConstraint; import org.fortiss.af3.exploration.moea.model.predefined.ComponentMultiAllocationConstraint;
...@@ -64,7 +65,12 @@ public class ComponentMultiAllocationConstraintEvaluator<S extends InstantiatedT ...@@ -64,7 +65,12 @@ public class ComponentMultiAllocationConstraintEvaluator<S extends InstantiatedT
@Override @Override
public DoubleValue evaluateGoal(T phenotype, FlatPhenotypeMap<Phenotype> phenotypeTypeMap, public DoubleValue evaluateGoal(T phenotype, FlatPhenotypeMap<Phenotype> phenotypeTypeMap,
ClassToInstanceMap<EObject> transformedModels) { ClassToInstanceMap<EObject> transformedModels) {
// Already considered in the operators. for(IMappingEntry mappingEntry : phenotype.getIMappingEntries()) {
if(optTarget.getAllRightMultiLocationModelElements().contains(
mappingEntry.getDeployableComponent().getObject())) {
return new DoubleValue(Double.MAX_VALUE);
}
}
return new DoubleValue(0.0); return new DoubleValue(0.0);
} }
...@@ -102,8 +108,22 @@ public class ComponentMultiAllocationConstraintEvaluator<S extends InstantiatedT ...@@ -102,8 +108,22 @@ public class ComponentMultiAllocationConstraintEvaluator<S extends InstantiatedT
@Override @Override
public boolean validateInternal(ExplorationTarget<?> expTarget, T solution, public boolean validateInternal(ExplorationTarget<?> expTarget, T solution,
SolutionQuantification value) { SolutionQuantification value) {
// Already considered in the operators.
// TODO: Just to be safe: add a real check. 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; return true;
} }
......
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