Commit d19096c1 authored by Sebastian Vollbrecht's avatar Sebastian Vollbrecht

Merge branch 'infeasibleRefactoring'

Closes #2.
parents 727102c0 129f3a2d
...@@ -20,9 +20,8 @@ package graphgen.datastructures; ...@@ -20,9 +20,8 @@ package graphgen.datastructures;
import java.util.Objects; import java.util.Objects;
/** /**
* A basic class for arranging objects in pairs. Every pairing is immutable once * A basic class for arranging objects in pairs. Every pairing is immutable once created. To create a pair, use the
* created. To create a pair, use the static * static {@link Pair#makePair(Object, Object)} constructor.
* {@link Pair#makePair(Object, Object)} constructor.
* *
* @param <T1> the type of the first element * @param <T1> the type of the first element
* @param <T2> the type of the second element * @param <T2> the type of the second element
...@@ -89,7 +88,8 @@ public class Pair<T1, T2> { ...@@ -89,7 +88,8 @@ public class Pair<T1, T2> {
return false; return false;
if (second == null) { if (second == null) {
return other.second == null; return other.second == null;
} else return second.equals(other.second); } else
return second.equals(other.second);
} }
} }
...@@ -21,10 +21,8 @@ import java.util.Optional; ...@@ -21,10 +21,8 @@ import java.util.Optional;
import java.util.Random; import java.util.Random;
/** /**
* A wrapper class for {@link Random} instances. This class disallows random * A wrapper class for {@link Random} instances. This class disallows random number generation without having seeded the
* number generation without having seeded the wrapped random instance * wrapped random instance beforehand, so that the graph generator does not generate 'true' random numbers by accident.
* beforehand, so that the graph generator does not generate 'true' random
* numbers by accident.
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
*/ */
...@@ -35,8 +33,8 @@ public class SeededRandom { ...@@ -35,8 +33,8 @@ public class SeededRandom {
private final Random rng; private final Random rng;
/** /**
* Creates a new, unseeded SeededRandom instance. Before random numbers can be * Creates a new, unseeded SeededRandom instance. Before random numbers can be generated, a call to the {@link
* generated, a call to the {@link #setSeed(long)} method will be necessary. * #setSeed(long)} method will be necessary.
*/ */
public SeededRandom() { public SeededRandom() {
this.rng = new Random(); this.rng = new Random();
...@@ -44,8 +42,8 @@ public class SeededRandom { ...@@ -44,8 +42,8 @@ public class SeededRandom {
} }
/** /**
* Creates a new, seeded SeededRandom instance. Using this constructor, a call * Creates a new, seeded SeededRandom instance. Using this constructor, a call to the {@link #setSeed(long)} method
* to the {@link #setSeed(long)} method is unnecessary. * is unnecessary.
* *
* @param seed the seed to pass to the random instance * @param seed the seed to pass to the random instance
*/ */
...@@ -65,13 +63,11 @@ public class SeededRandom { ...@@ -65,13 +63,11 @@ public class SeededRandom {
} }
/** /**
* Returns a random integer value between 0 (inclusive) and the given bound * Returns a random integer value between 0 (inclusive) and the given bound (exclusive).
* (exclusive).
* *
* @param bound the given bound * @param bound the given bound
* @return the random integer value * @return the random integer value
* @throws UnsupportedOperationException if this instance has not yet been * @throws UnsupportedOperationException if this instance has not yet been seeded
* seeded
*/ */
public int nextInt(int bound) { public int nextInt(int bound) {
checkSeededStatus(); checkSeededStatus();
...@@ -82,8 +78,7 @@ public class SeededRandom { ...@@ -82,8 +78,7 @@ public class SeededRandom {
* Returns a random double value between 0.0 (inclusive) and 1.0 (exclusive). * Returns a random double value between 0.0 (inclusive) and 1.0 (exclusive).
* *
* @return the random double value * @return the random double value
* @throws UnsupportedOperationException if this instance has not yet been * @throws UnsupportedOperationException if this instance has not yet been seeded
* seeded
*/ */
public double nextDouble() { public double nextDouble() {
checkSeededStatus(); checkSeededStatus();
...@@ -94,8 +89,7 @@ public class SeededRandom { ...@@ -94,8 +89,7 @@ public class SeededRandom {
* Returns the wrapped random instance. * Returns the wrapped random instance.
* *
* @return the wrapped instance * @return the wrapped instance
* @throws UnsupportedOperationException if this instance has not yet been * @throws UnsupportedOperationException if this instance has not yet been seeded
* seeded
*/ */
public Random getRandom() { public Random getRandom() {
checkSeededStatus(); checkSeededStatus();
......
...@@ -21,9 +21,8 @@ import modsched.Edge; ...@@ -21,9 +21,8 @@ import modsched.Edge;
import modsched.Node; import modsched.Node;
/** /**
* An enumeration which stores possible edge types. The {@link #ALL} type is * An enumeration which stores possible edge types. The {@link #ALL} type is meant to be a representative of both
* meant to be a representative of both forward edges and backedges, similar to * forward edges and backedges, similar to a wildcard.
* a wildcard.
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
*/ */
......
...@@ -47,9 +47,8 @@ public enum EdgeValue { ...@@ -47,9 +47,8 @@ public enum EdgeValue {
BACKEDGE_DISTANCE; BACKEDGE_DISTANCE;
/** /**
* Returns whether the given edge matches this edge value constant. This is * Returns whether the given edge matches this edge value constant. This is useful to filter out backedges when the
* useful to filter out backedges when the edge delay is needed, or forward * edge delay is needed, or forward edges when either the backedge delay or the backedge distance are needed.
* edges when either the backedge delay or the backedge distance are needed.
* *
* @param <N> the edge's node type * @param <N> the edge's node type
* @param edge the given edge * @param edge the given edge
......
...@@ -21,8 +21,7 @@ import modsched.EichenbergerFormulation; ...@@ -21,8 +21,7 @@ import modsched.EichenbergerFormulation;
import modsched.MoovacFormulation; import modsched.MoovacFormulation;
/** /**
* An enumeration which stores possible iterative modulo scheduling formulation * An enumeration which stores possible iterative modulo scheduling formulation types.
* types.
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
*/ */
......
...@@ -20,9 +20,8 @@ package graphgen.enums; ...@@ -20,9 +20,8 @@ package graphgen.enums;
import graphgen.graph.ResourceNode; import graphgen.graph.ResourceNode;
/** /**
* An enumeration which stores possible resource types. The {@link #ALL} type is * An enumeration which stores possible resource types. The {@link #ALL} type is meant to be a representative of both
* meant to be a representative of both limited and unlimited resources, similar * limited and unlimited resources, similar to a wildcard.
* to a wildcard.
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
*/ */
......
...@@ -20,26 +20,25 @@ package graphgen.generator.components; ...@@ -20,26 +20,25 @@ package graphgen.generator.components;
import graphgen.datastructures.SeededRandom; import graphgen.datastructures.SeededRandom;
/** /**
* An interface which all components participating in the creation of graphs can * An interface which all components participating in the creation of graphs can implement. It provides initialization
* implement. It provides initialization methods. * methods.
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
*/ */
public interface Initializable { public interface Initializable {
/** /**
* Grants the implementing class access to the graph generator's random number * Grants the implementing class access to the graph generator's random number generator. This method is called
* generator. This method is called only <i>once</i> when the generator itself * only
* is constructed. * <i>once</i> when the generator itself is constructed.
* *
* @param rng the graph generator's random number generator * @param rng the graph generator's random number generator
*/ */
public abstract void init(SeededRandom rng); public abstract void init(SeededRandom rng);
/** /**
* Resets the implementing class, preparing it for the generation of a new * Resets the implementing class, preparing it for the generation of a new graph. This method is called every time
* graph. This method is called every time before the generator begins * before the generator begins generating a new graph.
* generating a new graph.
*/ */
public abstract void reset(); public abstract void reset();
} }
...@@ -24,28 +24,24 @@ import graphgen.graph.ResourceNode; ...@@ -24,28 +24,24 @@ import graphgen.graph.ResourceNode;
import java.util.Map; import java.util.Map;
/** /**
* An interface which all classes participating in the creation of edges must * An interface which all classes participating in the creation of edges must implement. It provides setter methods for
* implement. It provides setter methods for layer structures and ASAP times * layer structures and ASAP times maps, which are useful for edge creation components which use the nodes' depths.
* maps, which are useful for edge creation components which use the nodes'
* depths.
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
*/ */
public interface EdgeCreationComponent extends Initializable { public interface EdgeCreationComponent extends Initializable {
/** /**
* Sets the layer structure of the implementing class, which can be used * Sets the layer structure of the implementing class, which can be used optionally for different purposes, such as
* optionally for different purposes, such as edge validity checks or edge value * edge validity checks or edge value computations regarding the depth of nodes.
* computations regarding the depth of nodes.
* *
* @param layers the layer structure to use * @param layers the layer structure to use
*/ */
public abstract void setLayerStructure(LayerStructure layers); public abstract void setLayerStructure(LayerStructure layers);
/** /**
* Sets the ASAP times map of the implementing class, which can be used * Sets the ASAP times map of the implementing class, which can be used optionally for different purposes, such as
* optionally for different purposes, such as backedge validity checks or * backedge validity checks or backedge value computations regarding the 'ASAP depth' of nodes.
* backedge value computations regarding the 'ASAP depth' of nodes.
* *
* @param asapTimes the ASAP times map to use * @param asapTimes the ASAP times map to use
*/ */
......
...@@ -30,10 +30,9 @@ import java.util.Map; ...@@ -30,10 +30,9 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
* A combined value computer combines several arbitrary value computers into a * A combined value computer combines several arbitrary value computers into a single one. Its computations are based on
* single one. Its computations are based on all contained value computers' * all contained value computers' decisions. This is done through an integer {@link FoldingStrategy folding strategy},
* decisions. This is done through an integer {@link FoldingStrategy folding * which combines several values into a single one.
* strategy}, which combines several values into a single one.
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
*/ */
...@@ -43,9 +42,8 @@ public class CombinedValueComputer extends ValueComputer { ...@@ -43,9 +42,8 @@ public class CombinedValueComputer extends ValueComputer {
private final List<ValueComputer> valueComputers; private final List<ValueComputer> valueComputers;
/** /**
* Creates a new combined value computer based on the provided value computers * Creates a new combined value computer based on the provided value computers and the given folding strategy. The
* and the given folding strategy. The folding strategy combines the values of * folding strategy combines the values of the given value computers into a single one.
* the given value computers into a single one.
* *
* @param strategy the strategy to use * @param strategy the strategy to use
* @param valueComputers the value computers to combine into a single one * @param valueComputers the value computers to combine into a single one
......
...@@ -24,8 +24,7 @@ import graphgen.graph.ResourceNode; ...@@ -24,8 +24,7 @@ import graphgen.graph.ResourceNode;
import java.util.Map; import java.util.Map;
/** /**
* This computer class always returns a constant value when computing delays or * This computer class always returns a constant value when computing delays or distances between nodes.
* distances between nodes.
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
*/ */
...@@ -34,8 +33,7 @@ public class ConstantValueComputer extends ValueComputer { ...@@ -34,8 +33,7 @@ public class ConstantValueComputer extends ValueComputer {
private final int constant; private final int constant;
/** /**
* Constructs a new constant value computer which will use the constant when * Constructs a new constant value computer which will use the constant when computing values.
* computing values.
* *
* @param constant the constant * @param constant the constant
*/ */
......
...@@ -31,20 +31,17 @@ import java.util.Map; ...@@ -31,20 +31,17 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
* This value computer computes edge values based on the depth of the edge's * This value computer computes edge values based on the depth of the edge's source nodes. If a node's computed depth
* source nodes. If a node's computed depth value is not contained in the * value is not contained in the provided map of value computers and their depths, the corresponding value will be
* provided map of value computers and their depths, the corresponding value * retrieved through linear interpolation of the values of the closest two value computers.
* will be retrieved through linear interpolation of the values of the closest
* two value computers.
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
*/ */
public class DepthValueComputer extends ValueComputer { public class DepthValueComputer extends ValueComputer {
/** /**
* This map is used to compute the nodes' depths. It can either be based on the * This map is used to compute the nodes' depths. It can either be based on the graph's layer structure or the
* graph's layer structure or the nodes' ASAP depths (depending on the provided * nodes' ASAP depths (depending on the provided {@link #useASAPDepths} flag).
* {@link #useASAPDepths} flag).
*/ */
private final Map<Integer, Integer> depthsByID; private final Map<Integer, Integer> depthsByID;
...@@ -52,15 +49,13 @@ public class DepthValueComputer extends ValueComputer { ...@@ -52,15 +49,13 @@ public class DepthValueComputer extends ValueComputer {
private final boolean useASAPDepths; private final boolean useASAPDepths;
/** /**
* Constructs a new depth based value computer using the provided mapping of * Constructs a new depth based value computer using the provided mapping of depths to value computers. The
* depths to value computers. The additional boolean flag denotes whether the * additional boolean flag denotes whether the nodes' ASAP times or the nodes' layer depths should be used when
* nodes' ASAP times or the nodes' layer depths should be used when computing * computing their respective depths.
* their respective depths.
* *
* @param valueComputersByDepth the mapping of depths to value computers * @param valueComputersByDepth the mapping of depths to value computers
* @param useASAPDepths true to use the nodes' ASAP times instead of the * @param useASAPDepths true to use the nodes' ASAP times instead of the layer depths when computing the
* layer depths when computing the nodes' depths, * nodes' depths, otherwise false
* otherwise false
* @throws NullPointerException if the mapping is null * @throws NullPointerException if the mapping is null
* @throws IllegalArgumentException if the mapping is empty * @throws IllegalArgumentException if the mapping is empty
*/ */
......
...@@ -34,8 +34,7 @@ public class DistributionValueComputer extends ValueComputer { ...@@ -34,8 +34,7 @@ public class DistributionValueComputer extends ValueComputer {
private final Distribution<Integer> distribution; private final Distribution<Integer> distribution;
/** /**
* Constructs a new single distribution value computer using the given * Constructs a new single distribution value computer using the given distribution.
* distribution.
* *
* @param distribution the given distribution * @param distribution the given distribution
*/ */
......
...@@ -31,8 +31,7 @@ import java.util.Optional; ...@@ -31,8 +31,7 @@ import java.util.Optional;
import java.util.Set; import java.util.Set;
/** /**
* This value computer returns values identical to values of a provided set of * This value computer returns values identical to values of a provided set of edges.
* edges.
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
*/ */
...@@ -42,10 +41,9 @@ public class IdenticalValueComputer extends ValueComputer { ...@@ -42,10 +41,9 @@ public class IdenticalValueComputer extends ValueComputer {
private final Optional<Distribution<Integer>> defaultDistribution; private final Optional<Distribution<Integer>> defaultDistribution;
/** /**
* Constructs a new identical value computer for the specified * Constructs a new identical value computer for the specified {@link EdgeValue}, using the provided set of edges.
* {@link EdgeValue}, using the provided set of edges. If the provided set of * If the provided set of edges does not contain a value for a given pair of source and destination nodes during
* edges does not contain a value for a given pair of source and destination * graph creation, a corresponding exception will be thrown.
* nodes during graph creation, a corresponding exception will be thrown.
* *
* @param edgeValue the specified edge value * @param edgeValue the specified edge value
* @param edges the set of edges * @param edges the set of edges
...@@ -56,16 +54,13 @@ public class IdenticalValueComputer extends ValueComputer { ...@@ -56,16 +54,13 @@ public class IdenticalValueComputer extends ValueComputer {
} }
/** /**
* Constructs a new identical value computer for the specified * Constructs a new identical value computer for the specified {@link EdgeValue}, using the provided set of edges.
* {@link EdgeValue}, using the provided set of edges. The given distribution * The given distribution will be used for pairs of nodes which are not contained in the set of edges. If the
* will be used for pairs of nodes which are not contained in the set of edges. * specified distribution is null however, exceptions will be thrown instead.
* If the specified distribution is null however, exceptions will be thrown
* instead.
* *
* @param edgeValue the specified edge value * @param edgeValue the specified edge value
* @param edges the set of edges * @param edges the set of edges
* @param defaultDistribution the distribution to use for nodes that are not * @param defaultDistribution the distribution to use for nodes that are not contained in the set of edges
* contained in the set of edges
* @throws NullPointerException if the edge value or the set of edges is null * @throws NullPointerException if the edge value or the set of edges is null
*/ */
public IdenticalValueComputer(EdgeValue edgeValue, Set<Edge<ResourceNode>> edges, public IdenticalValueComputer(EdgeValue edgeValue, Set<Edge<ResourceNode>> edges,
......
...@@ -24,9 +24,8 @@ import graphgen.graph.ResourceNode; ...@@ -24,9 +24,8 @@ import graphgen.graph.ResourceNode;
import java.util.Map; import java.util.Map;
/** /**
* This value computer computes edge values based on the limitedness of the * This value computer computes edge values based on the limitedness of the edge's nodes. It uses four value computers,
* edge's nodes. It uses four value computers, one for each combination of node * one for each combination of node limitedness.
* limitedness.
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
*/ */
...@@ -38,24 +37,20 @@ public class LimitednessValueComputer extends ValueComputer { ...@@ -38,24 +37,20 @@ public class LimitednessValueComputer extends ValueComputer {
private final ValueComputer unlimitedUnlimitedValueComputer; private final ValueComputer unlimitedUnlimitedValueComputer;
/** /**
* Constructs a new limitedness based value computer using the provided value * Constructs a new limitedness based value computer using the provided value computers.
* computers.
* *
* @param limitedLimitedValueComputer the value computer for values of edges * @param limitedLimitedValueComputer the value computer for values of edges which connect limited nodes to
* which connect limited nodes to limited * limited nodes
* nodes * @param limitedUnlimitedValueComputer the value computer for values of edges which connect limited nodes to
* @param limitedUnlimitedValueComputer the value computer for values of edges
* which connect limited nodes to
* unlimited nodes * unlimited nodes
* @param unlimitedLimitedValueComputer the value computer for values of edges * @param unlimitedLimitedValueComputer the value computer for values of edges which connect unlimited nodes to
* which connect unlimited nodes to
* limited nodes * limited nodes
* @param unlimitedUnlimitedValueComputer the value computer for values of edges * @param unlimitedUnlimitedValueComputer the value computer for values of edges which connect unlimited nodes to
* which connect unlimited nodes to
* unlimited nodes * unlimited nodes
*/ */
public LimitednessValueComputer(ValueComputer limitedLimitedValueComputer, public LimitednessValueComputer(ValueComputer limitedLimitedValueComputer,
ValueComputer limitedUnlimitedValueComputer, ValueComputer unlimitedLimitedValueComputer, ValueComputer limitedUnlimitedValueComputer,
ValueComputer unlimitedLimitedValueComputer,
ValueComputer unlimitedUnlimitedValueComputer) { ValueComputer unlimitedUnlimitedValueComputer) {
this.limitedLimitedValueComputer = limitedLimitedValueComputer; this.limitedLimitedValueComputer = limitedLimitedValueComputer;
......
...@@ -24,9 +24,8 @@ import java.util.HashMap; ...@@ -24,9 +24,8 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* This is the class which every edge value computer must implement. An edge * This is the class which every edge value computer must implement. An edge value computer computes edge delays,
* value computer computes edge delays, backedge delays and backedge distances * backedge delays and backedge distances for edges connecting given source and destination nodes.
* for edges connecting given source and destination nodes.
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
*/ */
...@@ -45,8 +44,7 @@ public abstract class ValueComputer implements EdgeCreationComponent { ...@@ -45,8 +44,7 @@ public abstract class ValueComputer implements EdgeCreationComponent {
} }
/** /**
* Retrieves the edge value of the edge connecting the source node to the * Retrieves the edge value of the edge connecting the source node to the destination node.
* destination node.
* *
* @param src the edge's source node * @param src the edge's source node
* @param dst the edge's destination node * @param dst the edge's destination node
...@@ -73,8 +71,7 @@ public abstract class ValueComputer implements EdgeCreationComponent { ...@@ -73,8 +71,7 @@ public abstract class ValueComputer implements EdgeCreationComponent {
} }
/** /**
* Computes the edge value of the edge connecting the source node to the * Computes the edge value of the edge connecting the source node to the destination node.
* destination node.
* *
* @param src the edge's source node * @param src the edge's source node
* @param dst the edge's destination node * @param dst the edge's destination node
...@@ -83,8 +80,7 @@ public abstract class ValueComputer implements EdgeCreationComponent { ...@@ -83,8 +80,7 @@ public abstract class ValueComputer implements EdgeCreationComponent {
protected abstract int computeValue(ResourceNode src, ResourceNode dst); protected abstract int computeValue(ResourceNode src, ResourceNode dst);
/** /**
* Resets the implementing class, preparing it for the generation of a new * Resets the implementing class, preparing it for the generation of a new graph.
* graph.
*/ */
protected abstract void implementedReset(); protected abstract void implementedReset();
......
...@@ -33,9 +33,8 @@ import java.util.Map; ...@@ -33,9 +33,8 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
* A combined edge includer combines several arbitrary edge includers into a * A combined edge includer combines several arbitrary edge includers into a single one. Its edge inclusion decisions
* single one. Its edge inclusion decisions are based on all contained edge * are based on all contained edge includers' decisions. This is done through a {@link FoldingStrategy folding
* includers' decisions. This is done through a {@link FoldingStrategy folding
* strategy}, which combines several decisions into a single one. * strategy}, which combines several decisions into a single one.
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
...@@ -48,9 +47,8 @@ public class CombinedEdgeIncluder extends EdgeIncluder { ...@@ -48,9 +47,8 @@ public class CombinedEdgeIncluder extends EdgeIncluder {
private final List<EdgeIncluder> edgeIncluders; private final List<EdgeIncluder> edgeIncluders;
/** /**
* Creates a new combined edge includer based on the provided edge includers and * Creates a new combined edge includer based on the provided edge includers and the given folding strategy. The
* the given folding strategy. The folding strategy combines the decisions of * folding strategy combines the decisions of the given edge includers into a single one.
* the given edge includers into a single one.
* *
* @param strategy the strategy to use * @param strategy the strategy to use
* @param edgeIncluders the edge includers to combine into a single one * @param edgeIncluders the edge includers to combine into a single one
......
...@@ -33,20 +33,17 @@ import java.util.Map; ...@@ -33,20 +33,17 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
* The depth edge includer bases its inclusion decisions on the depth * The depth edge includer bases its inclusion decisions on the depth information of an edge's source node. If a node's
* information of an edge's source node. If a node's computed depth value is not * computed depth value is not contained in the provided map of edge includers and their depths, the corresponding
* contained in the provided map of edge includers and their depths, the * decision will be computed probabilistically (see {@link DepthNodeCreator}).
* corresponding decision will be computed probabilistically (see
* {@link DepthNodeCreator}).
* *
* @author Sebastian Vollbrecht * @author Sebastian Vollbrecht
*/ */
public class DepthEdgeIncluder extends EdgeIncluder { public class DepthEdgeIncluder extends EdgeIncluder {