diff --git a/pom.xml b/pom.xml index 79fcd9386e67a7cb72a5953749ec6943a25b5e2c..4c0f94ac8cad5f7ca9c370c9883e898d0fab8277 100644 --- a/pom.xml +++ b/pom.xml @@ -128,7 +128,7 @@ <repositories> <repository> <id>snapshots</id> - <name>Syncleus Maven Snapshot Respository</name> + <name>Syncleus Maven Snapshot Repository</name> <url>http://ezekiel2.syncleus.com:8080/archiva/repository/snapshots/</url> <releases> <enabled>true</enabled> diff --git a/src/main/java/com/syncleus/dann/attributes/hat/MutableAttributeTreeAdjacencyGraph.java b/src/main/java/com/syncleus/dann/attributes/hat/MutableAttributeTreeAdjacencyGraph.java index c006ecb95df3ec90ccfaec2aee3d04fe95dc6d37..c0a265ba96acd20852079f215dd623a829b54cb7 100644 --- a/src/main/java/com/syncleus/dann/attributes/hat/MutableAttributeTreeAdjacencyGraph.java +++ b/src/main/java/com/syncleus/dann/attributes/hat/MutableAttributeTreeAdjacencyGraph.java @@ -62,49 +62,49 @@ public class MutableAttributeTreeAdjacencyGraph<N extends AbstractHierarchicalAt @Override public Graph<N, E> cloneAdd(final E newEdge) { - // TODO Fix this! + // TODO Implement this method throw new IllegalStateException("Operation not yet supported"); } @Override public Graph<N, E> cloneAdd(final N newNode) { - // TODO Fix this! + // TODO Implement this method throw new IllegalStateException("Operation not yet supported"); } @Override public Graph<N, E> cloneAdd(final Set<N> newNodes, final Set<E> newEdges) { - // TODO Fix this! + // TODO Implement this method throw new IllegalStateException("Operation not yet supported"); } @Override public Graph<N, E> cloneRemove(final E edgeToRemove) { - // TODO Fix this! + // TODO Implement this method throw new IllegalStateException("Operation not yet supported"); } @Override public Graph<N, E> cloneRemove(final N nodeToRemove) { - // TODO Fix this! + // TODO Implement this method throw new IllegalStateException("Operation not yet supported"); } @Override public Graph<N, E> cloneRemove(final Set<N> deleteNodes, final Set<E> deleteEdges) { - // TODO Fix this! + // TODO Implement this method throw new IllegalStateException("Operation not yet supported"); } @Override public Object clone() { - // TODO Fix this! + // TODO Implement this method throw new IllegalStateException("Operation not yet supported"); } } diff --git a/src/main/java/com/syncleus/dann/genetics/Chromatid.java b/src/main/java/com/syncleus/dann/genetics/Chromatid.java index bf1e627c64103c21cbb2a0e2d70a88413a3858e9..c3cc5f16f8525b5a632560123d29034e5a0c5d3e 100644 --- a/src/main/java/com/syncleus/dann/genetics/Chromatid.java +++ b/src/main/java/com/syncleus/dann/genetics/Chromatid.java @@ -51,7 +51,7 @@ public interface Chromatid<G extends Gene> extends Cloneable List<? extends G> crossover(int point); /** * The second step in crossover. This will replace its own genetic code with - * the specefied genetic segment at the specefied crossover point. + * the specified genetic segment at the specified crossover point. * * @param geneticSegment Segmet of genetic code crossing over. * @param point Crossover point (index) where genes are spliced diff --git a/src/main/java/com/syncleus/dann/genetics/wavelets/ExpressionFunction.java b/src/main/java/com/syncleus/dann/genetics/wavelets/ExpressionFunction.java index 2192d9c04449badc843dd89b0f6f6cd6a6cf93a5..ee78a2ab8d89a95222707e526882f62b2157caf2 100644 --- a/src/main/java/com/syncleus/dann/genetics/wavelets/ExpressionFunction.java +++ b/src/main/java/com/syncleus/dann/genetics/wavelets/ExpressionFunction.java @@ -242,7 +242,7 @@ public class ExpressionFunction implements Cloneable * Mutates by incorporating a new signal into the mutated result.<br/> <br/> * May mutate by:<br/> <ul> <li>adding the new signal</li> </ul> * - * @param newReceptor The new receptor to possibly incorperate into mutation + * @param newReceptor The new receptor to possibly incorporate into mutation * @param deviation RANDOM deviation for mutation. * @return New mutated wavelet */ diff --git a/src/main/java/com/syncleus/dann/graph/AbstractAdjacencyGraph.java b/src/main/java/com/syncleus/dann/graph/AbstractAdjacencyGraph.java index 11bac2c41c035b3e7c62169329c5fea6cb0481fc..04ce2d23ec3a68aacc22a7335e8bd01692a8e71d 100644 --- a/src/main/java/com/syncleus/dann/graph/AbstractAdjacencyGraph.java +++ b/src/main/java/com/syncleus/dann/graph/AbstractAdjacencyGraph.java @@ -343,35 +343,35 @@ public abstract class AbstractAdjacencyGraph<N, E extends Edge<N>> implements Gr @Override public Graph<N, E> cloneAdd(final N newNode) { - // TODO fill this in + // TODO Implement this method return null; } @Override public Graph<N, E> cloneAdd(final Set<N> newNodes, final Set<E> newEdges) { - // TODO fill this in + // TODO Implement this method return null; } @Override public Graph<N, E> cloneRemove(final E edgeToRemove) { - // TODO fill this in + // TODO Implement this method return null; } @Override public Graph<N, E> cloneRemove(final N nodeToRemove) { - // TODO fill this in + // TODO Implement this method return null; } @Override public Graph<N, E> cloneRemove(final Set<N> deleteNodes, final Set<E> deleteEdges) { - // TODO fill this in + // TODO Implement this method return null; } diff --git a/src/main/java/com/syncleus/dann/graph/Graph.java b/src/main/java/com/syncleus/dann/graph/Graph.java index 0e4f46d7310c04d146a3da5e4c9f479b0d7dd7c6..ec68ef37041f3e00e41150fcf14c6f82344e8889 100644 --- a/src/main/java/com/syncleus/dann/graph/Graph.java +++ b/src/main/java/com/syncleus/dann/graph/Graph.java @@ -52,7 +52,7 @@ public interface Graph<N, E extends Edge<N>> extends Serializable, Cloneable, Xm /** * Get a set of all edges in the graph. Two edges in the set, and in the graph, * may have the same end points unless equals in the edges used by this graph - * restrict that possiblity. + * restrict that possibility. * * @return An unmodifiable set of a all edges in the graph. * @since 2.0 diff --git a/src/main/java/com/syncleus/dann/graph/drawing/hyperassociativemap/HyperassociativeMap.java b/src/main/java/com/syncleus/dann/graph/drawing/hyperassociativemap/HyperassociativeMap.java index 5048d015a8ef2b610dbd30a4cc4db2c3161d27ce..ee07d912583bf3b715822c61197b825ce05440cf 100644 --- a/src/main/java/com/syncleus/dann/graph/drawing/hyperassociativemap/HyperassociativeMap.java +++ b/src/main/java/com/syncleus/dann/graph/drawing/hyperassociativemap/HyperassociativeMap.java @@ -284,6 +284,7 @@ public class HyperassociativeMap<G extends Graph<N, ?>, N> implements GraphDrawe final Map<N, Double> neighbors = getNeighbors(nodeToAlign); Vector compositeVector = new Vector(location.getDimensions()); + // align with neighbours for (final Entry<N, Double> neighborEntry : neighbors.entrySet()) { final N neighbor = neighborEntry.getKey(); diff --git a/src/main/java/com/syncleus/dann/graph/drawing/hyperassociativemap/LayeredBrainHyperassociativeMap.java b/src/main/java/com/syncleus/dann/graph/drawing/hyperassociativemap/LayeredBrainHyperassociativeMap.java index 5e618a619055472b0a92b6cc7eeee11c34bfd5e9..b4e3da477d11adc2052d57f09639fbe8b87838db 100644 --- a/src/main/java/com/syncleus/dann/graph/drawing/hyperassociativemap/LayeredBrainHyperassociativeMap.java +++ b/src/main/java/com/syncleus/dann/graph/drawing/hyperassociativemap/LayeredBrainHyperassociativeMap.java @@ -81,38 +81,48 @@ public class LayeredBrainHyperassociativeMap extends HyperassociativeMap<Feedfor { final BackpropNeuron neuronToQuery = nodeToQuery; - if( (this.cached) && (this.neighbors.containsKey(neuronToQuery)) ) - return this.neighbors.get(neuronToQuery); + if (cached && (neighbors.containsKey(neuronToQuery))) + { + return neighbors.get(neuronToQuery); + } - //populate initial associations based off edges + // populate initial associations based off edges final Map<BackpropNeuron, Double> associations = new HashMap<BackpropNeuron, Double>(); - for(final Synapse neighborEdge : this.getGraph().getAdjacentEdges(nodeToQuery)) + for (final Synapse<BackpropNeuron> neighborEdge : getGraph().getAdjacentEdges(nodeToQuery)) { - final Double currentWeight = (this.isUsingWeights() ? neighborEdge.getWeight() : this.getEquilibriumDistance()); - //TODO fix this typing - for(final Object neighbor : neighborEdge.getNodes()) - if( !neighbor.equals(nodeToQuery) ) - associations.put((BackpropNeuron)neighbor, currentWeight); + final Double currentWeight = (isUsingWeights() ? neighborEdge.getWeight() : getEquilibriumDistance()); + for (final BackpropNeuron neighbor : neighborEdge.getNodes()) + { + if (!neighbor.equals(nodeToQuery)) + { + associations.put(neighbor, currentWeight); + } + } } - //add aditional associations per layer. - for(final Set<BackpropNeuron> layer : this.getGraph().getLayers()) + // add aditional associations per layer. + for (final Set<BackpropNeuron> layer : getGraph().getLayers()) { - if( layer.contains(neuronToQuery) ) + if (layer.contains(neuronToQuery)) { - for(final BackpropNeuron layerNeuron : layer) + for (final BackpropNeuron layerNeuron : layer) { - if( (neuronToQuery instanceof BackpropStaticNeuron) && (layerNeuron instanceof BackpropStaticNeuron) ) - associations.put(layerNeuron, this.getEquilibriumDistance()); - else if( (!(neuronToQuery instanceof BackpropStaticNeuron)) && (!(layerNeuron instanceof BackpropStaticNeuron)) ) - associations.put(layerNeuron, this.getEquilibriumDistance()); + if (((neuronToQuery instanceof BackpropStaticNeuron) + && (layerNeuron instanceof BackpropStaticNeuron)) + || (!(neuronToQuery instanceof BackpropStaticNeuron) + && !(layerNeuron instanceof BackpropStaticNeuron))) + { + associations.put(layerNeuron, getEquilibriumDistance()); + } } } } associations.remove(nodeToQuery); - if( this.cached ) - this.neighbors.put(neuronToQuery, associations); + if (cached) + { + neighbors.put(neuronToQuery, associations); + } return associations; } diff --git a/src/main/java/com/syncleus/dann/graph/topological/Topography.java b/src/main/java/com/syncleus/dann/graph/topological/Topography.java index 2bb131276d1868ed87b7a0f3963702568a540da9..4093b328a4c89241479706e64027d4a66ff43b5a 100644 --- a/src/main/java/com/syncleus/dann/graph/topological/Topography.java +++ b/src/main/java/com/syncleus/dann/graph/topological/Topography.java @@ -40,10 +40,10 @@ import com.syncleus.dann.math.counting.Counters; public final class Topography { - //this is a utility class so we cant instantiate it, make default constructor private + // this is an utility class so we cant instantiate it, make default constructor private private Topography() { - throw new IllegalStateException("This is a utility class, it cant be instantiated"); + throw new IllegalStateException("This is an utility class, it can not be instantiated"); } /** @@ -66,7 +66,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -96,9 +97,10 @@ public final class Topography } /** - * Determines whether this graph is strongly connected. A graph is strongly connected if and only if - * every node is strongly connected to every other node. - * @return If this graph is strongly connected + * Determines whether this graph is strongly connected. + * A graph is strongly connected if, and only if every node is strongly + * connected to every other node. + * @return whether this graph is strongly connected * @see com.syncleus.dann.graph.topological.Topography#isStronglyConnected(Graph) */ public static <N, E extends Edge<N>> boolean isStronglyConnected(final Graph<N, E> graph) @@ -111,7 +113,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -139,7 +142,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -176,7 +180,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -223,7 +228,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -261,11 +267,12 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } - // TODO fill this in + // TODO implement this throw new UnsupportedOperationException(); } @@ -288,24 +295,25 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } if( !Topography.isSubGraph(graph, subGraph) ) return false; - //findCycles all edges in the parent graph, but not in the subgraph + // findCycles all edges in the parent graph, but not in the subgraph final Set<E> exclusiveParentEdges = new HashSet<E>(graph.getEdges()); final Set<? extends E> subedges = subGraph.getEdges(); exclusiveParentEdges.removeAll(subedges); - //check to make sure none of the edges exclusive to the parent graph - //connect to any of the nodes in the subgraph. + // check to make sure none of the edges exclusive to the parent graph + // connect to any of the nodes in the subgraph. final Set<? extends N> subnodes = subGraph.getNodes(); for(final E exclusiveParentEdge : exclusiveParentEdges) for(final N exclusiveParentNode : exclusiveParentEdge.getNodes()) if( subnodes.contains(exclusiveParentNode) ) return false; - //passed all the tests, must be maximal + // passed all the tests, must be maximal return true; } @@ -320,7 +328,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -337,7 +346,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -354,7 +364,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -371,7 +382,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -388,7 +400,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -405,7 +418,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -422,7 +436,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -439,7 +454,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -456,7 +472,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -479,7 +496,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -502,7 +520,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -525,7 +544,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -548,7 +568,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -576,7 +597,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -593,7 +615,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -619,7 +642,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -642,7 +666,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -670,7 +695,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -687,7 +713,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -737,7 +764,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -770,7 +798,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -801,7 +830,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -838,7 +868,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -874,7 +905,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -919,7 +951,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -966,11 +999,12 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } - // TODO fill this in + // TODO implement this throw new UnsupportedOperationException(); } @@ -984,11 +1018,12 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } - // TODO fill this in + // TODO implement this throw new UnsupportedOperationException(); } @@ -1003,7 +1038,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -1020,7 +1056,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -1037,7 +1074,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -1055,7 +1093,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -1073,7 +1112,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -1091,7 +1131,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -1109,7 +1150,8 @@ public final class Topography } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -1118,25 +1160,25 @@ public final class Topography } /** - * Removes a set of nodes and a set of edges from the given graph. First, it removes all nodes from the graph. - * Then, it removes all edges in the edges to remove that are not connected to the given node. It then - * returns an ImmutableAdjacencyGraph with the given nodes and edges removed. + * Removes a set of nodes and a set of edges from the given graph. + * First, it removes all nodes from the graph. + * Then, it removes all edges in the edges to remove that are not connected to the given node. * @param deleteNodes The nodes to remove * @param deleteEdges The edges to remove in addition to the nodes - * @return A graph of the remaining nodes + * @return an ImmutableAdjacencyGraph with the given nodes and edges removed */ private static <N, E extends Edge<N>> ImmutableAdjacencyGraph<N, Edge<N>> deleteFromGraph(final Graph<N, E> graph, final Set<N> deleteNodes, final Set<E> deleteEdges) { - //remove the deleteNodes + // remove the deleteNodes final Set<N> cutNodes = graph.getNodes(); cutNodes.removeAll(deleteNodes); - //remove the deleteEdges + // remove the deleteEdges final Set<Edge<N>> cutEdges = new HashSet<Edge<N>>(deleteEdges); - for(final E edge : deleteEdges) + for (final E edge : deleteEdges) cutEdges.remove(edge); - //remove any remaining deleteEdges which connect to removed deleteNodes - //also replace deleteEdges that have one removed node but still have - //2 or more remaining deleteNodes with a new edge. + // remove any remaining deleteEdges which connect to removed deleteNodes + // also replace deleteEdges that have one removed node but still have + // 2 or more remaining deleteNodes with a new edge. final Set<Edge<N>> removeEdges = new HashSet<Edge<N>>(); final Set<Edge<N>> addEdges = new HashSet<Edge<N>>(); for(final Edge<N> cutEdge : cutEdges) @@ -1152,8 +1194,8 @@ public final class Topography for(final Edge<N> removeEdge : removeEdges) cutEdges.remove(removeEdge); cutEdges.addAll(addEdges); - //check if a graph from the new set of deleteEdges and deleteNodes is still - //connected + // check if a graph from the new set of deleteEdges and deleteNodes is + // still connected return new ImmutableAdjacencyGraph<N, Edge<N>>(cutNodes, cutEdges); } diff --git a/src/main/java/com/syncleus/dann/graph/tree/Trees.java b/src/main/java/com/syncleus/dann/graph/tree/Trees.java index 5f188c299210e988fc31314eca9b1b896e39c86c..4183573df08f62ae3214c458754f824695ca5a01 100644 --- a/src/main/java/com/syncleus/dann/graph/tree/Trees.java +++ b/src/main/java/com/syncleus/dann/graph/tree/Trees.java @@ -51,11 +51,12 @@ public final class Trees } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } - // TODO check if subgraph is actually a subgraph, another words that it is a subset of nodes and edges + // TODO check if subgraph is actually a subgraph; in other words, that it is a subset of nodes and edges // TODO in fact we probably want to rethink this entirely return ((graph.getNodes().containsAll(subGraph.getNodes())) && (Topography.isWeaklyConnected(subGraph)) @@ -72,7 +73,8 @@ public final class Trees } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -89,7 +91,8 @@ public final class Trees } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -106,11 +109,12 @@ public final class Trees } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } - //TODO implement this + // TODO implement this throw new UnsupportedOperationException(); } @@ -124,7 +128,8 @@ public final class Trees } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } @@ -151,17 +156,20 @@ public final class Trees } catch(UnsupportedOperationException caught) { - //if its not supported lets handle it as if its not optimized + // if it is not supported, lets handle it as if it was not + // optimized } } - //TODO make this more efficient + // TODO make this more efficient final Set<Graph<N, E>> components = Topography.getMaximallyConnectedComponents(graph); - for(Graph<N, E> component : components) + for (Graph<N, E> component : components) { final DirectedGraph<N, E> directedComponent = new ImmutableDirectedAdjacencyGraph<N, E>(component); - if( !Trees.isRootedTree(directedComponent) ) + if (!Trees.isRootedTree(directedComponent)) + { return false; + } } return true; } diff --git a/src/main/java/com/syncleus/dann/graphicalmodel/bayesian/AbstractBayesianAdjacencyNetwork.java b/src/main/java/com/syncleus/dann/graphicalmodel/bayesian/AbstractBayesianAdjacencyNetwork.java index 0127db8cdf6647a00eb23e2193410ac12012ead8..9c5e9f6b30f5c93069edba6d731b1c53163e571d 100644 --- a/src/main/java/com/syncleus/dann/graphicalmodel/bayesian/AbstractBayesianAdjacencyNetwork.java +++ b/src/main/java/com/syncleus/dann/graphicalmodel/bayesian/AbstractBayesianAdjacencyNetwork.java @@ -200,7 +200,8 @@ public abstract class AbstractBayesianAdjacencyNetwork<N extends BayesianNode, E return xml; } - protected static class NodeConnectivity<N extends BayesianNode, E extends BayesianEdge<N>> extends HashMap<N, Set<E>> + // TODO unused, remove? + private static class NodeConnectivity<N extends BayesianNode, E extends BayesianEdge<N>> extends HashMap<N, Set<E>> { private static final long serialVersionUID = -3068604309573134643L; diff --git a/src/main/java/com/syncleus/dann/math/Vector.java b/src/main/java/com/syncleus/dann/math/Vector.java index b1f4c9863697727429cb628d431446e4c628a13c..ea00ce941e704543fd97607b1529c6c02c299d18 100644 --- a/src/main/java/com/syncleus/dann/math/Vector.java +++ b/src/main/java/com/syncleus/dann/math/Vector.java @@ -222,7 +222,7 @@ public class Vector implements Serializable * point. * * @return The distance component of this point using hyper-spherical - * coordinates. + * coordinates, in [0, Double.MAX_VALUE]. * @since 1.0 */ public double getDistance() diff --git a/src/main/java/com/syncleus/dann/math/wave/wavelet/SharpenedWaveletFunction.java b/src/main/java/com/syncleus/dann/math/wave/wavelet/SharpenedWaveletFunction.java index 8ffc1eedc7e263cac87503ba59cfe59875df0321..5ce05a4797f15237efb3ff721a680c77738528bf 100644 --- a/src/main/java/com/syncleus/dann/math/wave/wavelet/SharpenedWaveletFunction.java +++ b/src/main/java/com/syncleus/dann/math/wave/wavelet/SharpenedWaveletFunction.java @@ -80,6 +80,7 @@ public class SharpenedWaveletFunction extends SharpenedWaveFunction return (1 / (this.getDistribution() * Math.sqrt(2 * Math.PI))) * Math.exp(-1 * (Math.pow((this.getX() - this.getCenter()), 2)) / (2 * Math.pow(this.getDistribution(), 2))); } + @Override public double calculate() { if( this.constantMode ) diff --git a/src/main/java/com/syncleus/dann/neural/AbstractNeuron.java b/src/main/java/com/syncleus/dann/neural/AbstractNeuron.java index fbe2d2cba4549406151ec669dc4cc1197366162b..b322acbc0953150814e6ff8750517095fd14d068 100644 --- a/src/main/java/com/syncleus/dann/neural/AbstractNeuron.java +++ b/src/main/java/com/syncleus/dann/neural/AbstractNeuron.java @@ -47,7 +47,7 @@ public abstract class AbstractNeuron implements Neuron { return brain; } - // TODO consider making this public and moving it to the neuron interface + // TODO consider making this public and moving it to the neuron interface protected abstract double getOutput(); } diff --git a/src/main/java/com/syncleus/dann/neural/OutputNeuron.java b/src/main/java/com/syncleus/dann/neural/OutputNeuron.java index 1b40784700581358cc98fa76e828bf8fcf57edf8..ec02dc9191f21ac66e64e57d9cd33521479914dd 100644 --- a/src/main/java/com/syncleus/dann/neural/OutputNeuron.java +++ b/src/main/java/com/syncleus/dann/neural/OutputNeuron.java @@ -31,6 +31,7 @@ public interface OutputNeuron extends Neuron * Obtains the current output for this neuron. * * @return The current output of the neuron. + * @since 1.0 */ double getOutput(); } diff --git a/src/main/java/com/syncleus/dann/neural/activation/ActivationFunction.java b/src/main/java/com/syncleus/dann/neural/activation/ActivationFunction.java index ee837422e4248d3f4abf2a870aa9c7e79faa15e0..effe8fed42621b66b3b9901757ae655645886c89 100644 --- a/src/main/java/com/syncleus/dann/neural/activation/ActivationFunction.java +++ b/src/main/java/com/syncleus/dann/neural/activation/ActivationFunction.java @@ -18,11 +18,11 @@ ******************************************************************************/ package com.syncleus.dann.neural.activation; -// TODO rework this so it will work with piecewise and ramping activation function, a derivative isnt enough for that +// TODO rework this so it will work with piecewise and ramping activation function, a derivative is not enough for that /** * An interface containing methods for an activation function as well as its - * derivative. This is used in propogating as well as backpropogating activity. + * derivative. This is used in propagating as well as back-propagating activity. * * @author Jeffrey Phillips Freeman * @since 1.0 diff --git a/src/main/java/com/syncleus/dann/neural/backprop/AbstractBackpropNeuron.java b/src/main/java/com/syncleus/dann/neural/backprop/AbstractBackpropNeuron.java index 689782fdfcd4955fcf1d4b61c0ff298c0b842c5d..1cbb3dab7a2c7602dae94d6056ab3832834507be 100644 --- a/src/main/java/com/syncleus/dann/neural/backprop/AbstractBackpropNeuron.java +++ b/src/main/java/com/syncleus/dann/neural/backprop/AbstractBackpropNeuron.java @@ -143,13 +143,12 @@ public abstract class AbstractBackpropNeuron extends AbstractActivationNeuron im */ protected void calculateDeltaTrain() { - // TODO fix bad typing double newDeltaTrain = 0.0; -// for(final Synapse currentSynapse : this.getBrain().getTraversableEdges(this)) -// this.deltaTrain += (currentSynapse.getWeight() * this.deltaTrainDestinations.get(currentSynapse)); - for(final Object currentSynapse : this.getBrain().getTraversableEdges(this)) - newDeltaTrain += (((Synapse)currentSynapse).getWeight() * this.deltaTrainDestinations.get(currentSynapse)); - newDeltaTrain *= this.activateDerivitive(); + for (final Synapse<Neuron> currentSynapse : getBrain().getTraversableEdges(this)) + { + newDeltaTrain += (currentSynapse.getWeight() * getDeltaTrainDestinations().get(currentSynapse)); + } + newDeltaTrain *= activateDerivitive(); setDeltaTrain(newDeltaTrain); } diff --git a/src/main/java/com/syncleus/dann/neural/backprop/AbstractBackpropStaticNeuron.java b/src/main/java/com/syncleus/dann/neural/backprop/AbstractBackpropStaticNeuron.java index 200a853e7888d26f76dca8d1af739359e2c35ae6..9f66c141c82fe96d229671b9cb86f193c805ac19 100644 --- a/src/main/java/com/syncleus/dann/neural/backprop/AbstractBackpropStaticNeuron.java +++ b/src/main/java/com/syncleus/dann/neural/backprop/AbstractBackpropStaticNeuron.java @@ -35,11 +35,10 @@ public abstract class AbstractBackpropStaticNeuron extends AbstractBackpropNeuro @Override public void tick() { - //TODO fix this, bad typing -// for(final Synapse current : this.getBrain().getTraversableEdges(this)) -// current.setInput(this.output); - for(final Object current : this.getBrain().getTraversableEdges(this)) - ((Synapse)current).setInput(this.output); + for (final Synapse current : getBrain().getTraversableEdges(this)) + { + current.setInput(output); + } } @Override diff --git a/src/main/java/com/syncleus/dann/neural/backprop/AbstractOutputBackpropNeuron.java b/src/main/java/com/syncleus/dann/neural/backprop/AbstractOutputBackpropNeuron.java index bb417bb364a94726a890db417cc0d3d1e88ee5e2..0d99d092c5e492d345bb8de26e17e43f98c9555a 100644 --- a/src/main/java/com/syncleus/dann/neural/backprop/AbstractOutputBackpropNeuron.java +++ b/src/main/java/com/syncleus/dann/neural/backprop/AbstractOutputBackpropNeuron.java @@ -66,8 +66,8 @@ public abstract class AbstractOutputBackpropNeuron extends AbstractBackpropNeuro } /** - * Creates a new instance of this class with the specified activation function - * and learning rate. + * Creates a new instance of this class with the specified activation + * function and learning rate. * * @param activationFunction The activation used by this neuron. * @param learningRate The learning rate for this neuron. @@ -90,31 +90,19 @@ public abstract class AbstractOutputBackpropNeuron extends AbstractBackpropNeuro this.desired = trainingToSet; } - /** - * Calculates the Delta Train based on all the destination synapses. - * - * @see com.syncleus.dann.neural.backprop.SimpleBackpropNeuron#backPropagate - * @since 1.0 - */ @Override protected void calculateDeltaTrain() { double newDeltaTrain = 0.0; - // TODO fix this, bad typing -// for(final Synapse currentSynapse : super.getBrain().getTraversableEdges(this)) -// this.deltaTrain += (currentSynapse.getWeight() * this.deltaTrainDestinations.get(currentSynapse)); - for(final Object currentSynapse : super.getBrain().getTraversableEdges(this)) - newDeltaTrain += (((Synapse)currentSynapse).getWeight() * this.getDeltaTrainDestinations().get(currentSynapse)); - newDeltaTrain += (this.desired - this.getOutput()); - newDeltaTrain *= super.activateDerivitive(); + for (final Synapse currentSynapse : getBrain().getTraversableEdges(this)) + { + newDeltaTrain += currentSynapse.getWeight() * getDeltaTrainDestinations().get(currentSynapse); + } + newDeltaTrain += desired - getOutput(); + newDeltaTrain *= activateDerivitive(); setDeltaTrain(newDeltaTrain); } - /** - * Obtains the current output for this neuron. - * - * @return The current output of the neuron. - */ @Override public double getOutput() { diff --git a/src/main/java/com/syncleus/dann/neural/backprop/brain/FullyConnectedFeedforwardBrain.java b/src/main/java/com/syncleus/dann/neural/backprop/brain/FullyConnectedFeedforwardBrain.java index eee970f3efb5cc654aa86c8bcd241469e2074f7b..0b805360bc61c8c5fb9f3c7d3924a3bd0e067dbf 100644 --- a/src/main/java/com/syncleus/dann/neural/backprop/brain/FullyConnectedFeedforwardBrain.java +++ b/src/main/java/com/syncleus/dann/neural/backprop/brain/FullyConnectedFeedforwardBrain.java @@ -46,7 +46,7 @@ public final class FullyConnectedFeedforwardBrain<IN extends InputBackpropNeuron this.learningRate = learningRate; this.activationFunction = activationFunction; - this.initalizeNetwork(neuronsPerLayer); + initalizeNetwork(neuronsPerLayer); } /** @@ -61,30 +61,28 @@ public final class FullyConnectedFeedforwardBrain<IN extends InputBackpropNeuron this.learningRate = learningRate; this.activationFunction = activationFunction; - this.initalizeNetwork(neuronsPerLayer); + initalizeNetwork(neuronsPerLayer); } - /** - * Since a specific ActivationFunction or learning rate is needed then this - * should be overridden in a child class. - * - * @param layer the current layer index for which we are creating the neuron. - * @param index The index of the new neuron within the layer. - * @return The new SimpleBackpropNeuron to be added to the current layer. - * @since 2.0 - */ @Override protected N createNeuron(final int layer, final int index) { final BackpropNeuron neuron; - if( layer == 0 ) + + if (layer == 0) + { neuron = new SimpleInputBackpropNeuron(this); - else if( layer >= (this.getLayerCount() - 1) ) - neuron = new SimpleOutputBackpropNeuron(this, this.activationFunction, this.learningRate); + } + else if (layer >= (getLayerCount() - 1)) + { + neuron = new SimpleOutputBackpropNeuron(this, activationFunction, learningRate); + } else - neuron = new SimpleBackpropNeuron(this, this.activationFunction, this.learningRate); + { + neuron = new SimpleBackpropNeuron(this, activationFunction, learningRate); + } - //TODO fix this typing + // TODO fix typing return (N) neuron; } } diff --git a/src/main/java/com/syncleus/dann/neural/som/brain/AbstractSomBrain.java b/src/main/java/com/syncleus/dann/neural/som/brain/AbstractSomBrain.java index f553c71308ecca613e6617f3bd9eebcdf0205eed..2f3fa7bb7e94c1f101fa056f42ceab8377099943 100644 --- a/src/main/java/com/syncleus/dann/neural/som/brain/AbstractSomBrain.java +++ b/src/main/java/com/syncleus/dann/neural/som/brain/AbstractSomBrain.java @@ -99,11 +99,11 @@ public abstract class AbstractSomBrain<IN extends SomInputNeuron, ON extends Som @Override public void run() { - final double currentDistance = this.neuronPoint.calculateRelativeTo(this.bestMatchPoint).getDistance(); - if( currentDistance < this.neighborhoodRadius ) + final double currentDistance = neuronPoint.calculateRelativeTo(bestMatchPoint).getDistance(); + if (currentDistance < neighborhoodRadius) { final double neighborhoodAdjustment = neighborhoodFunction(currentDistance); - this.neuron.train(this.learningRate, neighborhoodAdjustment); + neuron.train(learningRate, neighborhoodAdjustment); } } } @@ -147,11 +147,11 @@ public abstract class AbstractSomBrain<IN extends SomInputNeuron, ON extends Som final List<IN> newInputs = new ArrayList<IN>(); for(int inputIndex = 0; inputIndex < inputCount; inputIndex++) { - //TODO fix this it is type unsafe + // TODO fix typing final SomInputNeuron safeNewNeuron = new SimpleSomInputNeuron(this); final IN newNeuron = (IN) safeNewNeuron; newInputs.add(newNeuron); - //TODO fix this it is type unsafe + // TODO fix typing super.add((N)newNeuron); } this.inputs = Collections.unmodifiableList(newInputs); @@ -182,22 +182,22 @@ public abstract class AbstractSomBrain<IN extends SomInputNeuron, ON extends Som @Override public void createOutput(final Vector position) { - //make sure we have the proper dimentionality + // make sure we have the proper dimentionality if( position.getDimensions() != this.upperBounds.getDimensions() ) throw new IllegalArgumentException("Dimentionality mismatch"); - //increase the upper bounds if needed + // increase the upper bounds if needed this.updateBounds(position); - //create and add the new output neuron + // create and add the new output neuron final SimpleSomNeuron outputNeuron = new SimpleSomNeuron(this); - //TODO fix this it is type unsafe + // TODO fix typing this.outputs.put(position, (ON)outputNeuron); - //TODO fix this it is type unsafe + // TODO fix typing this.add((N)outputNeuron); - //connect all inputs to the new neuron - //TODO fix this it is type unsafe + // connect all inputs to the new neuron + // TODO fix typing for(final InputNeuron input : this.inputs) { final Synapse<N> synapse = new SimpleSynapse<N>((N)input, (N)outputNeuron); @@ -442,7 +442,7 @@ public abstract class AbstractSomBrain<IN extends SomInputNeuron, ON extends Som } /** - * Gets the current input value at the specied index. + * Gets the current input value at the specified index. * * @param index Index of the input to get. * @return The current value for the specified input. @@ -463,22 +463,22 @@ public abstract class AbstractSomBrain<IN extends SomInputNeuron, ON extends Som @Override public final Map<Vector, double[]> getOutputWeightVectors() { - //iterate through the output lattice + // iterate through the output lattice final HashMap<Vector, double[]> weightVectors = new HashMap<Vector, double[]>(); for(final Entry<Vector, ON> output : outputs.entrySet()) { final double[] weightVector = new double[inputs.size()]; final ON currentNeuron = output.getValue(); final Vector currentPoint = output.getKey(); - //iterate through the weight vectors of the current neuron - //TODO fix this, it is badly typed + // iterate through the weight vectors of the current neuron + // TODO fix typing for(final S source : this.getInEdges((N)currentNeuron)) { assert (source.getSourceNode() instanceof InputNeuron); final int sourceIndex = inputs.indexOf((InputNeuron) source.getSourceNode()); weightVector[sourceIndex] = source.getWeight(); } - //add the current weight vector to the map + // add the current weight vector to the map weightVectors.put(currentPoint, weightVector); } return Collections.unmodifiableMap(weightVectors);