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

Exploration.alg: Generalize Geno-/Phenotype reflection in the Decoders.

refs 3279
parent 7f11dce7
No related branches found
No related tags found
No related merge requests found
Showing
with 44 additions and 107 deletions
ComposableDecoder.java 197abec80b880e25fccfc66d61b471b0b5d7e10f RED
ComposableDecoderBase.java 4f366cc6c0f8ca929cac43d9c5de675cbafbb132 RED
ComposableDecoderBase.java 9b6114516ea001aeceb00f894d61336994097465 RED
CompositeDecoder.java 9d34dd0b342e6433ab894974f9430531ce2de39a RED
CompositeDecoderBase.java 1bc1860ed616010f7f459ed6579989f155f607c2 RED
PhenotypeDecoder.java 44079e8545aaf8b8729919f0b07c774c3ca0df06 RED
......@@ -15,9 +15,14 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegene.decode;
import java.util.Collection;
import java.util.Collections;
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 com.google.common.reflect.TypeToken;
/**
* Base class for {@link ComposableDecoder}s.
*
......@@ -25,12 +30,35 @@ import org.fortiss.af3.exploration.alg.dse.backend.opt4j.extensions.compositegen
*/
public abstract class ComposableDecoderBase<G extends ComposableGenotype, P extends ComposablePhenotype<?>>
implements ComposableDecoder<G, P> {
/** Type information: Concrete input genotype of the decoder. */
private TypeToken<G> genotype = new TypeToken<G>(getClass()) { // Empty class
};
/** Type information: Concrete input phenotype of the decoder. */
private TypeToken<P> phenotype = new TypeToken<P>(getClass()) { // Empty class
};
/** {@inheritDoc} */
@Override
public Class<?> getPrimaryInputType() {
if(genotype.getType() instanceof Class) {
return (Class<?>)genotype.getType();
}
return genotype.getRawType();
}
/** {@inheritDoc} */
@Override
public Collection<Class<?>> getOptionalTypes() {
return Collections.emptySet();
}
// 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();
// }
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public Class<? super P> getOutputType() {
if(genotype.getType() instanceof Class) {
return (Class<? super P>)phenotype.getType();
}
return null;
}
}
MessageDecoder.java 155958e769b3ddb18deac0d2ff595977f5252192 RED
MessageDecoder.java 4ad8b9325ad1032437426c5f1636448b54b7883c RED
......@@ -17,7 +17,6 @@ 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.backend.opt4j.encoding.comm.MessageEncoding;
......@@ -131,12 +130,6 @@ public class MessageDecoder<S extends TaskMappingEntry<ITaskAdapter<?>, Partitio
return reqTypes;
}
/** {@inheritDoc} */
@Override
public Collection<Class<?>> getOptionalTypes() {
return Collections.emptySet();
}
/** {@inheritDoc} */
@SuppressWarnings("rawtypes")
@Override
......
PartitionMappingDecoderGraph.java d164596ac52b41fbe7be9b926418a5cbf53edb08 RED
PartitionMappingIdentityDecoder.java e1a56b26ca22e952b8c965f79ff748f48da3407c RED
PartitionMappingDecoderGraph.java 4541c30721d8898a269320fbf5bbc65627548160 RED
PartitionMappingIdentityDecoder.java 45a0f3748f01beb741390d564a707f19cf3fd2b6 RED
......@@ -111,23 +111,4 @@ public class PartitionMappingDecoderGraph extends
reqTypes.add(PartitionMappingEncoding.class);
return reqTypes;
}
/** {@inheritDoc} */
@Override
public Collection<Class<?>> getOptionalTypes() {
Collection<Class<?>> optTypes = new ArrayList<>();
return optTypes;
}
/** {@inheritDoc} */
@Override
public Class<PlatformCommunicationGraphEncoding> getOutputType() {
return PlatformCommunicationGraphEncoding.class;
}
/** {@inheritDoc} */
@Override
public Class<?> getPrimaryInputType() {
return PlatformCommunicationGraphEncoding.class;
}
}
......@@ -60,16 +60,4 @@ public class PartitionMappingIdentityDecoder
optTypes.add(PartitionMappingEncoding.class);
return optTypes;
}
/** {@inheritDoc} */
@Override
public Class<PartitionMappingEncoding> getOutputType() {
return PartitionMappingEncoding.class;
}
/** {@inheritDoc} */
@Override
public Class<?> getPrimaryInputType() {
return PartitionMappingEncoding.class;
}
}
SFEncodingDecoder.java 8e1594c92aa5e0c23d07038bb63db5b483c4f727 RED
SFGraphDecoder.java 833d6662ea99c8c7b92ba229c117f200a0300667 RED
SFMappingConstraintDecoder.java b347e65e6b805103e133386ef76c2297a829559a RED
SFMappingDecoder.java ec3d91b8cacb5743517d87a1c9eed347549d8acc RED
SFEncodingDecoder.java ed80fb718ebef561d42610709820852ff777d609 RED
SFGraphDecoder.java 5b6a65e02f9132348a5051b431581a32fe14046e RED
SFMappingConstraintDecoder.java 3fe95f631eb32d8f1757dba46a2c93be3e04f5af RED
SFMappingDecoder.java b3985407125fe2e36882385aff269b0dc46689cd RED
......@@ -70,13 +70,6 @@ public class SFEncodingDecoder<C>
return reqTypes;
}
/** {@inheritDoc} */
@Override
public Collection<Class<?>> getOptionalTypes() {
Collection<Class<?>> optTypes = new ArrayList<>();
return optTypes;
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
......
......@@ -17,7 +17,6 @@ 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;
......@@ -155,12 +154,6 @@ public class SFGraphDecoder<C>
return reqTypes;
}
/** {@inheritDoc} */
@Override
public Collection<Class<?>> getOptionalTypes() {
return Collections.emptySet();
}
/** {@inheritDoc} */
@SuppressWarnings("rawtypes")
@Override
......
......@@ -17,7 +17,6 @@ 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;
......@@ -112,21 +111,9 @@ public class SFMappingConstraintDecoder<C>
return requiredTypes;
}
/** {@inheritDoc} */
@Override
public Collection<Class<?>> getOptionalTypes() {
return Collections.emptySet();
}
/** {@inheritDoc} */
@Override
public Class<? super AbstractTaskMappingEncoding> getOutputType() {
return AbstractTaskMappingEncoding.class;
}
/** {@inheritDoc} */
@Override
public Class<?> getPrimaryInputType() {
return AbstractTaskMappingEncoding.class;
return SafetyFunctionArchEncoding.class;
}
}
......@@ -20,7 +20,6 @@ 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;
......@@ -273,18 +272,6 @@ public class SFMappingDecoder<C>
return reqTypes;
}
/** {@inheritDoc} */
@Override
public Collection<Class<?>> getOptionalTypes() {
return Collections.emptySet();
}
/** {@inheritDoc} */
@Override
public Class<AbstractTaskMappingEncoding> getOutputType() {
return AbstractTaskMappingEncoding.class;
}
/** {@inheritDoc} */
@Override
public Class<?> getPrimaryInputType() {
......
......@@ -72,17 +72,4 @@ public class TaskInstanceResourceAlignmentDecoder extends
Collection<Class<?>> optTypes = new ArrayList<>();
return optTypes;
}
/** {@inheritDoc} */
@SuppressWarnings("rawtypes")
@Override
public Class<InstantiatedTaskMappingEncoding> getOutputType() {
return InstantiatedTaskMappingEncoding.class;
}
/** {@inheritDoc} */
@Override
public Class<?> getPrimaryInputType() {
return InstantiatedTaskMappingEncoding.class;
}
}
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