Package ca.nengo.model

Examples of ca.nengo.model.StructuralException


    }

    public synchronized Termination addPreLearnTermination(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 PreLearnTermination(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


    BiasTermination biasTermination = null;
    try {
      LinearSystem baseDynamics = (LinearSystem) baseTermination.getDynamics().clone();
      biasTermination = new BiasTermination(this, biasName, baseTermination.getName(), baseDynamics, integrator, biasEncoders, false);
    } catch (CloneNotSupportedException e) {
      throw new StructuralException("Can't clone dynamics for bias termination", e);
    }
    BiasTermination interneuronTermination = new BiasTermination(this, interName, baseTermination.getName(), interneuronDynamics, integrator, biasEncoders, true);

    biasTermination.setModulatory(baseTermination.getModulatory());
    interneuronTermination.setModulatory(baseTermination.getModulatory());
View Full Code Here

    return getNodes().length;
  }

    public synchronized void setNodeCount(int n) throws StructuralException {
    if (myEnsembleFactory==null) {
      throw new StructuralException("Error changing node count: EnsembleFactory has not been set");
    }
    if (n<1) {
      throw new StructuralException("Error changing node count: Cannot have "+n+" neurons");
    }


    NEFNode[] nodes = new NEFNode[n];

    NodeFactory nodeFactory=myEnsembleFactory.getNodeFactory();

    for (int i = 0; i < n; i++) {
      Node node = nodeFactory.make("node" + i);
      if ( !(node instanceof NEFNode) ) {
        throw new StructuralException("Nodes must be NEFNodes");
      }
      nodes[i] = (NEFNode) node;

      nodes[i].setMode(SimulationMode.CONSTANT_RATE);
      if ( !nodes[i].getMode().equals(SimulationMode.CONSTANT_RATE) ) {
        throw new StructuralException("Neurons in an NEFEnsemble must support CONSTANT_RATE mode");
      }

      nodes[i].setMode(getMode());
    }
    redefineNodes(nodes);
View Full Code Here

  public Node make(String name) throws StructuralException {
    float maxRate = myMaxRate.sample()[0];   
    float intercept = myIntercept.sample()[0];
   
    if (maxRate < 0) {
      throw new StructuralException("Max firing rate must be > 0");
    }
    if (maxRate > 1f / myTauRef) {
      ourLogger.warn("Decreasing maximum firing rate which was greater than inverse of refractory period");
      maxRate = (1f / myTauRef) - .001f;
    }
View Full Code Here

  public Neuron make(String name) throws StructuralException {
    float maxRate = myMaxRate.sample()[0];   
    float intercept = myIntercept.sample()[0];
   
    if (maxRate < 0) {
      throw new StructuralException("Max firing rate must be > 0");
    }
    if (maxRate > 1f / myTauRef) {
      ourLogger.warn("Decreasing maximum firing rate which was greater than inverse of refractory period");
      maxRate = (1f / myTauRef) - .001f;
    }
View Full Code Here

   */
  public void setTau(float tau) throws StructuralException {
    if (myDynamics instanceof LTISystem) {
      CanonicalModel.changeTimeConstant((LTISystem) myDynamics, tau);
    } else {
      throw new StructuralException("Can't set time constant of non-LTI dynamics");
    }
  }
View Full Code Here

   */
    public Origin addDecodedOrigin(String name, Function[] functions, String nodeOrigin, Network environment,
      Probe probe, float startTime, float endTime) throws StructuralException, SimulationException {

      if (myDecodedOrigins.containsKey(name)) {
            throw new StructuralException("The ensemble already contains a origin named " + name);
        }

    probe.reset();
    environment.run(startTime, endTime);
    float[] times = probe.getData().getTimes();
View Full Code Here

   */
    public Origin addDecodedOrigin(String name, Function[] functions, String nodeOrigin, Network environment,
      Probe probe, Termination termination, float[][] evalPoints, float transientTime) throws StructuralException, SimulationException {

      if (myDecodedOrigins.containsKey(name)) {
            throw new StructuralException("The ensemble already contains a origin named " + name);
        }

    float[][] values = new float[evalPoints.length][];
    for (int i = 0; i < evalPoints.length; i++) {
      Function[] f = new Function[evalPoints[i].length];
View Full Code Here

   */
  public Origin addDecodedOrigin(String name, Function[] functions, String nodeOrigin, Network environment,
      Probe probe, Probe state, float startTime, float endTime, float tau) throws StructuralException, SimulationException {

      if (myDecodedOrigins.containsKey(name)) {
            throw new StructuralException("The ensemble already contains a origin named " + name);
        }

    probe.reset();
    state.reset();
    environment.run(startTime, endTime);
View Full Code Here

    public Termination addDecodedTermination(String name, float[][] matrix, float tauPSC, boolean isModulatory)
            throws StructuralException {

      for(Termination t : getTerminations()) {
          if(t.getName().equals(name))
            throw new StructuralException("The ensemble already contains a termination named " + name);
        }

        float scale = 1 / tauPSC; //output scaling to make impulse integral = 1

        LinearSystem dynamics = new SimpleLTISystem(
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.