Package ca.nengo.model

Examples of ca.nengo.model.StructuralException


    for (int i = 0; i < nodes.length; i++) {
      try {
        result[i] = getConstantOutput(i, evalPoints, origin);
      } catch (SimulationException e) {
        throw new StructuralException("Node " + i + " does not have the Origin " + origin);
      }
    }

    return result;
  }
View Full Code Here


    synchronized (node) {
      SimulationMode mode = node.getMode();

      node.setMode(SimulationMode.CONSTANT_RATE);
      if ( !node.getMode().equals(SimulationMode.CONSTANT_RATE) ) {
        throw new StructuralException(
          "To find decoders using this method, all Nodes must support CONSTANT_RATE simulation mode");
      }

      for (int i = 0; i < result.length; i++) {
        node.setRadialInput(getRadialInput(evalPoints[i], nodeIndex));
View Full Code Here

    for (int i = 0; i < nodes.length; i++) {
      float[][] output;
      try {
        output = getSignalOutput(i, evalSignals, origin);
      } catch (SimulationException e) {
        throw new StructuralException("Node " + i + " does not have the Origin " + origin);
      }
     
      for(int j=0; j < output.length; j++)
        result[i][j] = output[j];
    }
View Full Code Here

    synchronized (node) {
      SimulationMode mode = node.getMode();

      node.setMode(SimulationMode.RATE);
      if ( !node.getMode().equals(SimulationMode.RATE) ) {
        throw new StructuralException(
          "To find decoders using this method, all Nodes must support RATE simulation mode");
      }

      for (int i = 0; i < evalSignals.length; i++) {
        node.reset(false);
View Full Code Here

  /**
   * @see ca.nengo.model.nef.NEFEnsemble#addBiasOrigin(ca.nengo.model.Origin, int, java.lang.String, boolean)
   */
    public BiasOrigin addBiasOrigin(Origin existing, int numInterneurons, String name, boolean excitatory) throws StructuralException {
    if ( !(existing instanceof DecodedOrigin) ) {
      throw new StructuralException("A DecodedOrigin is needed to make a BiasOrigin");
    }

    DecodedOrigin o = (DecodedOrigin) existing;
    BiasOrigin result = new BiasOrigin(this, name, getNodes(), o.getNodeOrigin(),
        getConstantOutputs(myEvalPoints, o.getNodeOrigin()), numInterneurons, excitatory);
View Full Code Here

  @Override
    public Termination addDecodedTermination(String name, float[][] matrix, float tauPSC,
            boolean isModulatory) throws StructuralException {
       if (matrix.length != myDimension) {
             throw new StructuralException("Output dimension " + matrix.length + " doesn't equal ensemble dimension " + myDimension);
         }
       return super.addDecodedTermination(name, matrix, tauPSC, isModulatory);
  }
View Full Code Here

  @Override
    public Termination addDecodedTermination(String name, float[][] matrix, float[] tfNumerator, float[] tfDenominator,
            float passthrough, boolean isModulatory) throws StructuralException {
      if (matrix.length != myDimension) {
          throw new StructuralException("Output dimension " + matrix.length + " doesn't equal ensemble dimension " + myDimension);
      }
      return super.addDecodedTermination(name, matrix, tfNumerator,tfDenominator, passthrough, isModulatory);
  }
View Full Code Here

     * @see ca.nengo.model.ExpandableNode#addTermination(java.lang.String, float[][], float, boolean)
     */
    public synchronized Termination addPESTermination(String name, float[][] weights, float tauPSC, boolean modulatory) throws StructuralException {
        //TODO: check name for duplicate
        if (myExpandableNodes.length != weights.length) {
            throw new StructuralException(weights.length + " sets of weights given for "
                    + myExpandableNodes.length + " expandable nodes");
        }

        int dimension = weights[0].length;

        Termination[] components = new Termination[myExpandableNodes.length];
        for (int i = 0; i < myExpandableNodes.length; i++) {
            if (weights[i].length != dimension) {
                throw new StructuralException("Equal numbers of weights are needed for termination onto each node");
            }

            components[i] = myExpandableNodes[i].addTermination(name, new float[][]{weights[i]}, tauPSC, modulatory);
        }

        PlasticEnsembleTermination result;

        // Make sure that the components are plastic, otherwise make a non-plastic termination
        if (isPopulationPlastic(components)) {
            PlasticNodeTermination[] pnts = new PlasticNodeTermination[components.length];
            for (int i=0; i<components.length; i++) {
                pnts[i] = (PlasticNodeTermination) components[i];
            }

            result = new PESTermination(this, name, pnts);

            // Set the number of tasks equal to the number of threads
            int numTasks = ca.nengo.util.impl.NodeThreadPool.getNumJavaThreads();
            numTasks = numTasks < 1 ? 1 : numTasks;

            LearningTask[] tasks = new LearningTask[numTasks];

            int termsPerTask = (int) Math.ceil((float) components.length / (float) numTasks);
            int termOffset = 0;
            int termStartIndex, termEndIndex;

            for (int i = 0; i < numTasks; i++) {
                termStartIndex = termOffset;
                termEndIndex = components.length - termOffset >= termsPerTask ? termOffset + termsPerTask : components.length;
                termOffset += termsPerTask;

                tasks[i] = new LearningTask(this, result, termStartIndex, termEndIndex);
            }
            addTasks(tasks);
        } else {
            throw new StructuralException("Ensemble contains non-plastic node terminations");
        }

        myPlasticEnsembleTerminations.put(name, result);
        fireVisibleChangeEvent();

View Full Code Here

     * @see ca.nengo.model.ExpandableNode#addTermination(java.lang.String, float[][], float, boolean)
     */
    public synchronized Termination addHPESTermination(String name, float[][] weights, float tauPSC, boolean modulatory, float[] theta) throws StructuralException {
        //TODO: check name for duplicate
        if (myExpandableNodes.length != weights.length) {
            throw new StructuralException(weights.length + " sets of weights given for "
                    + myExpandableNodes.length + " expandable nodes");
        }

        int dimension = weights[0].length;

        Termination[] components = new Termination[myExpandableNodes.length];
        for (int i = 0; i < myExpandableNodes.length; i++) {
            if (weights[i].length != dimension) {
                throw new StructuralException("Equal numbers of weights are needed for termination onto each node");
            }

            components[i] = myExpandableNodes[i].addTermination(name, new float[][]{weights[i]}, tauPSC, modulatory);
        }

        PlasticEnsembleTermination result;

        // Make sure that the components are plastic, otherwise make a non-plastic termination
        if (isPopulationPlastic(components)) {
            PlasticNodeTermination[] pnts = new PlasticNodeTermination[components.length];
            for (int i=0; i<components.length; i++) {
                pnts[i] = (PlasticNodeTermination) components[i];
            }

            result = new hPESTermination(this, name, pnts, theta);

            // Set the number of tasks equal to the number of threads
            int numTasks = ca.nengo.util.impl.NodeThreadPool.getNumJavaThreads();
            numTasks = numTasks < 1 ? 1 : numTasks;

            LearningTask[] tasks = new LearningTask[numTasks];

            int termsPerTask = (int) Math.ceil((float) components.length / (float) numTasks);
            int termOffset = 0;
            int termStartIndex, termEndIndex;

            for (int i = 0; i < numTasks; i++) {
                termStartIndex = termOffset;
                termEndIndex = components.length - termOffset >= termsPerTask ? termOffset + termsPerTask : components.length;
                termOffset += termsPerTask;

                tasks[i] = new LearningTask(this, result, termStartIndex, termEndIndex);
            }
            addTasks(tasks);
        } else {
            throw new StructuralException("Ensemble contains non-plastic node terminations");
        }

        myPlasticEnsembleTerminations.put(name, result);
        fireVisibleChangeEvent();

View Full Code Here

     * @see ca.nengo.model.ExpandableNode#addTermination(java.lang.String, float[][], float, boolean)
     */
    public synchronized Termination addBCMTermination(String name, float[][] weights, float tauPSC, boolean modulatory, float[] theta) throws StructuralException {
        //TODO: check name for duplicate
        if (myExpandableNodes.length != weights.length) {
            throw new StructuralException(weights.length + " sets of weights given for "
                    + myExpandableNodes.length + " expandable nodes");
        }

        int dimension = weights[0].length;

        Termination[] components = new Termination[myExpandableNodes.length];
        for (int i = 0; i < myExpandableNodes.length; i++) {
            if (weights[i].length != dimension) {
                throw new StructuralException("Equal numbers of weights are needed for termination onto each node");
            }

            components[i] = myExpandableNodes[i].addTermination(name, new float[][]{weights[i]}, tauPSC, modulatory);
        }

        PlasticEnsembleTermination result;

        // Make sure that the components are plastic, otherwise make a non-plastic termination
        if (isPopulationPlastic(components)) {
            PlasticNodeTermination[] pnts = new PlasticNodeTermination[components.length];
            for (int i=0; i < components.length; i++) {
                pnts[i] = (PlasticNodeTermination) components[i];
            }

            result = new BCMTermination(this, name, pnts, theta);

            // Set the number of tasks equal to the number of threads
            int numTasks = ca.nengo.util.impl.NodeThreadPool.getNumJavaThreads();
            numTasks = numTasks < 1 ? 1 : numTasks;

            LearningTask[] tasks = new LearningTask[numTasks];

            int termsPerTask = (int) Math.ceil((float) components.length / (float) numTasks);
            int termOffset = 0;
            int termStartIndex, termEndIndex;

            for (int i = 0; i < numTasks; i++) {
                termStartIndex = termOffset;
                termEndIndex = components.length - termOffset >= termsPerTask ? termOffset + termsPerTask : components.length;
                termOffset += termsPerTask;

                tasks[i] = new LearningTask(this, result, termStartIndex, termEndIndex);
            }
            addTasks(tasks);
        } else {
            throw new StructuralException("Ensemble contains non-plastic node terminations");
        }

        myPlasticEnsembleTerminations.put(name, result);
        fireVisibleChangeEvent();

View Full Code Here

TOP

Related Classes of ca.nengo.model.StructuralException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.